-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/indy-vdr-resolver
- Loading branch information
Showing
36 changed files
with
1,839 additions
and
197 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
89 changes: 89 additions & 0 deletions
89
packages/anoncreds/src/formats/AnonCredsCredentialFormat.ts
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,89 @@ | ||
import type { AnonCredsCredential, AnonCredsCredentialOffer, AnonCredsCredentialRequest } from '../models' | ||
import type { CredentialPreviewAttributeOptions, CredentialFormat, LinkedAttachment } from '@aries-framework/core' | ||
|
||
/** | ||
* This defines the module payload for calling CredentialsApi.createProposal | ||
* or CredentialsApi.negotiateOffer | ||
*/ | ||
export interface AnonCredsProposeCredentialFormat { | ||
schemaIssuerId?: string | ||
schemaId?: string | ||
schemaName?: string | ||
schemaVersion?: string | ||
|
||
credentialDefinitionId?: string | ||
issuerId?: string | ||
|
||
attributes?: CredentialPreviewAttributeOptions[] | ||
linkedAttachments?: LinkedAttachment[] | ||
|
||
// Kept for backwards compatibility | ||
schemaIssuerDid?: string | ||
issuerDid?: string | ||
} | ||
|
||
/** | ||
* This defines the module payload for calling CredentialsApi.acceptProposal | ||
*/ | ||
export interface AnonCredsAcceptProposalFormat { | ||
credentialDefinitionId?: string | ||
attributes?: CredentialPreviewAttributeOptions[] | ||
linkedAttachments?: LinkedAttachment[] | ||
} | ||
|
||
/** | ||
* This defines the module payload for calling CredentialsApi.acceptOffer. No options are available for this | ||
* method, so it's an empty object | ||
*/ | ||
export type AnonCredsAcceptOfferFormat = Record<string, never> | ||
|
||
/** | ||
* This defines the module payload for calling CredentialsApi.offerCredential | ||
* or CredentialsApi.negotiateProposal | ||
*/ | ||
export interface AnonCredsOfferCredentialFormat { | ||
credentialDefinitionId: string | ||
attributes: CredentialPreviewAttributeOptions[] | ||
linkedAttachments?: LinkedAttachment[] | ||
} | ||
|
||
/** | ||
* This defines the module payload for calling CredentialsApi.acceptRequest. No options are available for this | ||
* method, so it's an empty object | ||
*/ | ||
export type AnonCredsAcceptRequestFormat = Record<string, never> | ||
|
||
export interface AnonCredsCredentialFormat extends CredentialFormat { | ||
formatKey: 'anoncreds' | ||
credentialRecordType: 'anoncreds' | ||
credentialFormats: { | ||
createProposal: AnonCredsProposeCredentialFormat | ||
acceptProposal: AnonCredsAcceptProposalFormat | ||
createOffer: AnonCredsOfferCredentialFormat | ||
acceptOffer: AnonCredsAcceptOfferFormat | ||
createRequest: never // cannot start from createRequest | ||
acceptRequest: AnonCredsAcceptRequestFormat | ||
} | ||
// TODO: update to new RFC once available | ||
// Format data is based on RFC 0592 | ||
// https://github.com/hyperledger/aries-rfcs/tree/main/features/0592-indy-attachments | ||
formatData: { | ||
proposal: { | ||
schema_issuer_id?: string | ||
schema_name?: string | ||
schema_version?: string | ||
schema_id?: string | ||
|
||
cred_def_id?: string | ||
issuer_id?: string | ||
|
||
// TODO: we don't necessarily need to include these in the AnonCreds Format RFC | ||
// as it's a new one and we can just forbid the use of legacy properties | ||
schema_issuer_did?: string | ||
issuer_did?: string | ||
} | ||
offer: AnonCredsCredentialOffer | ||
request: AnonCredsCredentialRequest | ||
credential: AnonCredsCredential | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
packages/anoncreds/src/formats/LegacyIndyCredentialFormat.ts
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,67 @@ | ||
import type { | ||
AnonCredsAcceptOfferFormat, | ||
AnonCredsAcceptProposalFormat, | ||
AnonCredsAcceptRequestFormat, | ||
AnonCredsOfferCredentialFormat, | ||
} from './AnonCredsCredentialFormat' | ||
import type { AnonCredsCredential, AnonCredsCredentialOffer, AnonCredsCredentialRequest } from '../models' | ||
import type { CredentialPreviewAttributeOptions, CredentialFormat, LinkedAttachment } from '@aries-framework/core' | ||
|
||
/** | ||
* This defines the module payload for calling CredentialsApi.createProposal | ||
* or CredentialsApi.negotiateOffer | ||
* | ||
* NOTE: This doesn't include the `issuerId` and `schemaIssuerId` properties that are present in the newer format. | ||
*/ | ||
export interface LegacyIndyProposeCredentialFormat { | ||
schemaIssuerDid?: string | ||
schemaId?: string | ||
schemaName?: string | ||
schemaVersion?: string | ||
|
||
credentialDefinitionId?: string | ||
issuerDid?: string | ||
|
||
attributes?: CredentialPreviewAttributeOptions[] | ||
linkedAttachments?: LinkedAttachment[] | ||
} | ||
|
||
export interface LegacyIndyCredentialRequest extends AnonCredsCredentialRequest { | ||
// prover_did is optional in AnonCreds credential request, but required in legacy format | ||
prover_did: string | ||
} | ||
|
||
export interface LegacyIndyCredentialFormat extends CredentialFormat { | ||
formatKey: 'indy' | ||
|
||
// The stored type is the same as the anoncreds credential service | ||
credentialRecordType: 'anoncreds' | ||
|
||
// credential formats are the same as the AnonCreds credential format | ||
credentialFormats: { | ||
// The createProposal interface is different between the interfaces | ||
createProposal: LegacyIndyProposeCredentialFormat | ||
acceptProposal: AnonCredsAcceptProposalFormat | ||
createOffer: AnonCredsOfferCredentialFormat | ||
acceptOffer: AnonCredsAcceptOfferFormat | ||
createRequest: never // cannot start from createRequest | ||
acceptRequest: AnonCredsAcceptRequestFormat | ||
} | ||
|
||
// Format data is based on RFC 0592 | ||
// https://github.com/hyperledger/aries-rfcs/tree/main/features/0592-indy-attachments | ||
formatData: { | ||
proposal: { | ||
schema_name?: string | ||
schema_issuer_did?: string | ||
schema_version?: string | ||
schema_id?: string | ||
|
||
cred_def_id?: string | ||
issuer_did?: string | ||
} | ||
offer: AnonCredsCredentialOffer | ||
request: LegacyIndyCredentialRequest | ||
credential: AnonCredsCredential | ||
} | ||
} |
Oops, something went wrong.