-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add JSON-LD Credential and Presentation handling/sign support t…
…hat is compatible with React-Native
- Loading branch information
Showing
8 changed files
with
181 additions
and
45 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 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 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,2 +1,2 @@ | ||
export * from './utils'; | ||
export * from './types'; | ||
export * from './utils' | ||
export * from './types' |
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 * from './ICredential' | ||
export * from './vc-data-models' | ||
export * from './presentation-exchange' |
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,30 @@ | ||
export interface PresentationSubmission { | ||
/** | ||
* A UUID or some other unique ID to identify this Presentation Submission | ||
*/ | ||
id: string | ||
/** | ||
* A UUID or some other unique ID to identify this Presentation Definition | ||
*/ | ||
definition_id: string | ||
/** | ||
* List of descriptors of how the claims are being mapped to presentation definition | ||
*/ | ||
descriptor_map: Array<Descriptor> | ||
} | ||
|
||
export interface Descriptor { | ||
/** | ||
* ID to identify the descriptor from Presentation Definition Input Descriptor it coresponds to. | ||
*/ | ||
id: string | ||
/** | ||
* The path where the verifiable credential is located in the presentation submission json | ||
*/ | ||
path: string | ||
path_nested?: Descriptor | ||
/** | ||
* The Proof or JWT algorith that the proof is in | ||
*/ | ||
format: string | ||
} |
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 { ProofPurpose, SignatureTypes } from './vc-data-models' | ||
|
||
export interface ProofOptions { | ||
/** | ||
* The signature type. For instance RsaSignature2018 | ||
*/ | ||
type?: SignatureTypes | string | ||
|
||
/** | ||
* Type supports selective disclosure? | ||
*/ | ||
typeSupportsSelectiveDisclosure?: boolean | ||
|
||
/** | ||
* A challenge protecting against replay attacks | ||
*/ | ||
challenge?: string | ||
|
||
/** | ||
* A domain protecting against replay attacks | ||
*/ | ||
domain?: string | ||
|
||
/** | ||
* The purpose of this proof, for instance assertionMethod or authentication, see https://www.w3.org/TR/vc-data-model/#proofs-signatures-0 | ||
*/ | ||
proofPurpose?: ProofPurpose | string | ||
|
||
/** | ||
* The ISO8601 date-time string for creation. You can update the Proof value later in the callback. If not supplied the current date/time will be used | ||
*/ | ||
created?: string | ||
|
||
/** | ||
* Similar to challenge. A nonce to protect against replay attacks, used in some ZKP proofs | ||
*/ | ||
nonce?: string | ||
} |
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,94 @@ | ||
import { | ||
VerifiablePresentation, | ||
CompactJWT, | ||
UnsignedCredential, | ||
CredentialSubject, | ||
VerifiableCredential, | ||
UnsignedPresentation, | ||
ProofType, | ||
CredentialStatus, | ||
} from '@veramo/core' | ||
import { PresentationSubmission } from './presentation-exchange' | ||
|
||
export type W3CVerifiablePresentationSP = VerifiablePresentation | VerifiablePresentationSP | CompactJWT | ||
export type W3CVerifiableCredentialSP = VerifiableCredential | VerifiableCredentialSP | CompactJWT | ||
|
||
export enum SignatureTypes { | ||
Ed25519Signature2018 = 'Ed25519Signature2018', | ||
Ed25519Signature2020 = 'Ed25519Signature2020', | ||
EcdsaSecp256k1Signature2019 = 'EcdsaSecp256k1Signature2019', | ||
EcdsaSecp256k1RecoverySignature2020 = 'EcdsaSecp256k1RecoverySignature2020', | ||
JsonWebSignature2020 = 'JsonWebSignature2020', | ||
RsaSignature2018 = 'RsaSignature2018', | ||
GpgSignature2020 = 'GpgSignature2020', | ||
JcsEd25519Signature2020 = 'JcsEd25519Signature2020', | ||
BbsBlsSignatureProof2020 = 'BbsBlsSignatureProof2020', | ||
BbsBlsBoundSignatureProof2020 = 'BbsBlsBoundSignatureProof2020', | ||
} | ||
|
||
export enum ProofPurpose { | ||
assertionMethod = 'assertionMethod', | ||
authentication = 'authentication', | ||
keyAgreement = 'keyAgreement', | ||
contractAgreement = 'contactAgreement', | ||
capabilityInvocation = 'capabilityInvocation', | ||
capabilityDelegation = 'capabilityDelegation', | ||
} | ||
|
||
export interface CredentialStatusSP extends CredentialStatus { | ||
id: string | ||
type: string | ||
revocationListIndex?: string | ||
revocationListCredential?: string | ||
} | ||
|
||
/*export interface ICredentialIssuer { | ||
id: string | ||
[x: string]: unknown | ||
}*/ | ||
|
||
/*export interface ICredentialSubject { | ||
id?: string | ||
[x: string]: unknown | ||
}*/ | ||
|
||
export interface CredentialProofSP extends ProofType { | ||
type: string | SignatureTypes // The proof type | ||
created: string // The ISO8601 date-time string for creation | ||
proofPurpose: ProofPurpose | string // The specific intent for the proof | ||
verificationMethod: string // A set of parameters required to independently verify the proof | ||
challenge?: string // A challenge to protect against replay attacks | ||
domain?: string // A string restricting the (usage of a) proof to the domain and protects against replay attacks | ||
proofValue?: string // One of any number of valid representations of proof values | ||
jws?: string // JWS based proof | ||
nonce?: string // Similar to challenge. A nonce to protect against replay attacks, used in some ZKP proofs | ||
requiredRevealStatements?: string[] // The parts of the proof that must be revealed in a derived proof | ||
|
||
[x: string]: string | string[] | undefined | ||
} | ||
|
||
export interface UnsignedCredentialSP extends UnsignedCredential { | ||
credentialSubject: CredentialSubject[] | CredentialSubject | ||
credentialStatus?: CredentialStatusSP | ||
validFrom?: string | ||
validUntil?: string | ||
} | ||
|
||
export interface VerifiableCredentialSP extends UnsignedCredentialSP { | ||
proof: CredentialProofSP | CredentialProofSP[] | ||
} | ||
|
||
export interface UnsignedPresentationSP extends UnsignedPresentation { | ||
type: string[] | string | ||
verifiableCredential: W3CVerifiableCredentialSP[] | ||
presentation_submission?: PresentationSubmission | ||
|
||
[x: string]: any | ||
} | ||
|
||
export interface VerifiablePresentationSP extends UnsignedPresentationSP { | ||
// Last one is from Veramo | ||
proof: CredentialProofSP | CredentialProofSP[] | { proof: ProofType } | ||
} |