Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #10 from m00sey/feat/edges-data-auth
Browse files Browse the repository at this point in the history
Feat/edges data auth
  • Loading branch information
m00sey committed Oct 2, 2023
2 parents 92c86a7 + ee354eb commit 1701349
Show file tree
Hide file tree
Showing 18 changed files with 688 additions and 107 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# qvi-ts

[![CI](https://github.com/GLEIF-IT/qvi-ts/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/GLEIF-IT/qvi-ts/actions/workflows/main.yml)
[![codecov](https://codecov.io/gh/GLEIF-IT/qvi-ts/graph/badge.svg?token=DKG7H94FLS)](https://codecov.io/gh/GLEIF-IT/qvi-ts)
[![Documentation](https://img.shields.io/badge/documentation-grey?)](https://gleif-it.github.io/qvi-ts/)

[![codecov](https://codecov.io/gh/m00sey/qvi-ts/graph/badge.svg?token=DKG7H94FLS)](https://codecov.io/gh/m00sey/qvi-ts)

[![Documentation](https://img.shields.io/badge/documentation-grey?)](https://gleif-it.github.io/qvi-ts/)
# qvi-ts
QVI SDK for the vLEI Ecosystem

### Development

Expand Down
73 changes: 0 additions & 73 deletions src/credentials.ts

This file was deleted.

1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export type AID = string;
export * from './qvi/qvi';
46 changes: 46 additions & 0 deletions src/le/credentials/ecr-auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Saider } from 'signify-ts';
import { AID } from '../../index';

export interface ECRAuthvLEICredentialArgs {
readonly qviAID: AID;
readonly timestamp: string;
readonly recipient: AID;
readonly LEI: string;
readonly personLegalName: string;
readonly engagementContextRole: string;
}

export class ECRAuthvLEICredentialData {
readonly d: string;
readonly i: AID;
readonly dt: string;
readonly AID: AID;
readonly LEI: string;
readonly personLegalName: string;
readonly engagementContextRole: string;

constructor({
qviAID,
timestamp,
recipient,
LEI,
personLegalName,
engagementContextRole,
}: ECRAuthvLEICredentialArgs) {
this.i = qviAID;
this.dt = timestamp;
this.AID = recipient;
this.LEI = LEI;
this.personLegalName = personLegalName;
this.engagementContextRole = engagementContextRole;
this.d = Saider.saidify({
d: '',
i: this.i,
dt: this.dt,
AID: this.AID,
LEI: this.LEI,
personLegalName: this.personLegalName,
officialOrganizationalRole: this.engagementContextRole,
})[1]['d'];
}
}
46 changes: 46 additions & 0 deletions src/le/credentials/oor-auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Saider } from 'signify-ts';
import { AID } from '../../index';

export interface OORAuthvLEICredentialArgs {
readonly qviAID: AID;
readonly timestamp: string;
readonly recipient: AID;
readonly LEI: string;
readonly personLegalName: string;
readonly officialOrganizationalRole: string;
}

export class OORAuthvLEICredentialData {
readonly d: string;
readonly i: AID;
readonly dt: string;
readonly AID: AID;
readonly LEI: string;
readonly personLegalName: string;
readonly officialOrganizationalRole: string;

constructor({
qviAID,
timestamp,
recipient,
LEI,
personLegalName,
officialOrganizationalRole,
}: OORAuthvLEICredentialArgs) {
this.i = qviAID;
this.dt = timestamp;
this.AID = recipient;
this.LEI = LEI;
this.personLegalName = personLegalName;
this.officialOrganizationalRole = officialOrganizationalRole;
this.d = Saider.saidify({
d: '',
i: this.i,
dt: this.dt,
AID: this.AID,
LEI: this.LEI,
personLegalName: this.personLegalName,
officialOrganizationalRole: this.officialOrganizationalRole,
})[1]['d'];
}
}
88 changes: 88 additions & 0 deletions src/le/le.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { SignifyClient } from 'signify-ts';
import { Schema } from '../schema';
import { Rules } from '../rules';
import { ECRAuthvLEICredentialData } from './credentials/ecr-auth';
import { ECRAuthEdge } from '../qvi/credentials/ecr';
import { AID } from '..';
import { OORAuthvLEICredentialData } from './credentials/oor-auth';
import { OORAuthEdge } from '../qvi/credentials/oor';

type qb64 = string;

export class LE {
private readonly client: SignifyClient;
private readonly name: string;
private readonly registryAID: qb64;

/**
* LE
*
* Class for performing LE as a QVI opertations:
*
* - Issue Engagement Context Role Auth Credential
* - Issue Official Organizational Role Auth Credential
*
* @param client
* @param name
* @param registryAID
*/
constructor(client: SignifyClient, name: string, registryAID: qb64) {
this.client = client;
this.name = name;
this.registryAID = registryAID;
}

/**
* Create ECR Auth Credential
*
* @param {AID} issuee AID of QVI
* @param {ECRAuthvLEICredentialData} data
* @param {ECRAuthEdge} edge}
* @returns
*/
public async createECRAuthCredential(
issuee: AID,
data: ECRAuthvLEICredentialData,
edge: ECRAuthEdge
) {
return await this.client
.credentials()
.issue(
this.name,
this.registryAID,
Schema.ECRAuth,
issuee,
data,
Rules.ECRAuth,
edge,
false
);
}

/**
* Create OOR Auth Credential
*
* @param {AID} issuee AID of QVI
* @param {OORAuthvLEICredentialData} data
* @param {OORAuthEdge} edge}
* @returns
*/
public async createOORAuthCredential(
issuee: AID,
data: OORAuthvLEICredentialData,
edge: OORAuthEdge
) {
return await this.client
.credentials()
.issue(
this.name,
this.registryAID,
Schema.OORAuth,
issuee,
data,
Rules.OORAuth,
edge,
false
);
}
}
75 changes: 75 additions & 0 deletions src/qvi/credentials/ecr.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { Saider } from 'signify-ts';
import { Schema } from '../../schema';
import { AID } from '../..';

export interface ECRvLEICredentialDataArgs {
nonce: string;
issuee: AID;
timestamp: string;
LEI: string;
personLegalName: string;
engagementContextRole: string;
}

export class ECRvLEICredentialData {
readonly d: string;
readonly u: string;
readonly i: string;
readonly dt: string;
readonly LEI: string;
readonly personLegalName: string;
readonly engagementContextRole: string;

constructor({
nonce,
issuee,
timestamp,
LEI,
personLegalName,
engagementContextRole,
}: ECRvLEICredentialDataArgs) {
this.u = nonce;
this.i = issuee;
this.dt = timestamp;
this.LEI = LEI;
this.personLegalName = personLegalName;
this.engagementContextRole = engagementContextRole;
this.d = Saider.saidify({
d: '',
u: this.u,
i: this.i,
dt: this.dt,
LEI: this.LEI,
personLegalName: this.personLegalName,
engagementContextRole: this.engagementContextRole,
})[1]['d'];
}
}

export interface ECRAuthEdgeArgs {
auth: ECRAuthvLEIEdgeData;
}

export class ECRAuthEdge {
readonly d: string;
readonly auth: ECRAuthvLEIEdgeData;

constructor({ auth }: ECRAuthEdgeArgs) {
this.d = Saider.saidify({ d: '', auth: auth })[1]['d'];
this.auth = auth;
}
}

export interface ECRAuthvLEIEdgeDataArgs {
legalEntity: AID;
}

export class ECRAuthvLEIEdgeData {
readonly n: string; // SAID of the the issuing LEs Legal Entity vLEI Credential
readonly s: string = Schema.LE;
readonly o: string = 'I2I';

constructor({ legalEntity }: ECRAuthvLEIEdgeDataArgs) {
this.n = legalEntity;
}
}
38 changes: 38 additions & 0 deletions src/qvi/credentials/le.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Saider } from 'signify-ts';
import { QVIvLEIEdge } from '../qvi';
import { AID } from '../..';

export interface LEvLEICredentialDataArgs {
readonly issuee: AID;
readonly timestamp: string;
readonly LEI: string;
}

export class LEvLEICredentialData {
readonly d: string;
readonly i: AID;
readonly dt: string;
readonly LEI: string;

constructor({ issuee, timestamp, LEI }: LEvLEICredentialDataArgs) {
this.i = issuee;
this.dt = timestamp;
this.LEI = LEI;
this.d = Saider.saidify({
d: '',
i: this.i,
dt: this.dt,
LEI: this.LEI,
})[1]['d'];
}
}

export class LEvLEICredentialEdge {
readonly d: string;
readonly qvi: QVIvLEIEdge;

constructor(qviAID: string) {
this.qvi = new QVIvLEIEdge(qviAID);
this.d = Saider.saidify({ d: '', qvi: this.qvi })[1]['d'];
}
}
Loading

0 comments on commit 1701349

Please sign in to comment.