This repository has been archived by the owner on May 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from m00sey/feat/edges-data-auth
Feat/edges data auth
- Loading branch information
Showing
18 changed files
with
688 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export type AID = string; | ||
export * from './qvi/qvi'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']; | ||
} | ||
} |
Oops, something went wrong.