From cd6f99deb237f7cd816aa81f4c4a2d1f058e186e Mon Sep 17 00:00:00 2001 From: vbasiuk Date: Thu, 5 Sep 2024 12:36:11 +0300 Subject: [PATCH 01/11] feat: add optional displayMethod to CredentialRequest --- package-lock.json | 4 ++-- package.json | 2 +- src/credentials/models.ts | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6e0bdcf0..808b2b91 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@0xpolygonid/js-sdk", - "version": "1.18.1", + "version": "1.18.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@0xpolygonid/js-sdk", - "version": "1.18.1", + "version": "1.18.2", "license": "MIT or Apache-2.0", "dependencies": { "@noble/curves": "^1.4.0", diff --git a/package.json b/package.json index 61c48f1a..f838a93a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@0xpolygonid/js-sdk", - "version": "1.18.1", + "version": "1.18.2", "description": "SDK to work with Polygon ID", "main": "dist/node/cjs/index.js", "module": "dist/node/esm/index.js", diff --git a/src/credentials/models.ts b/src/credentials/models.ts index a13b49e9..3cd4624d 100644 --- a/src/credentials/models.ts +++ b/src/credentials/models.ts @@ -1,6 +1,7 @@ import { JsonDocumentObject } from '../iden3comm'; import { CredentialStatusType, + DisplayMethod, MerklizedRootPosition, RefreshService, SubjectPosition @@ -42,6 +43,10 @@ export interface CredentialRequest { * refreshService */ refreshService?: RefreshService; + /** + * displayMethod + */ + displayMethod?: DisplayMethod; /** * claim version */ From 0cd2e983efcff6063d34a696ac694e5c5fee877d Mon Sep 17 00:00:00 2001 From: vbasiuk Date: Thu, 5 Sep 2024 13:35:38 +0300 Subject: [PATCH 02/11] assign display method --- src/credentials/credential-wallet.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/credentials/credential-wallet.ts b/src/credentials/credential-wallet.ts index 7079eca4..faf04b40 100644 --- a/src/credentials/credential-wallet.ts +++ b/src/credentials/credential-wallet.ts @@ -287,6 +287,7 @@ export class CredentialWallet implements ICredentialWallet { cr.type = credentialType; cr.expirationDate = expirationDate ? new Date(expirationDate * 1000).toISOString() : undefined; cr.refreshService = request.refreshService; + cr.displayMethod = request.displayMethod; cr.issuanceDate = new Date().toISOString(); cr.credentialSubject = credentialSubject; cr.issuer = issuer.string(); From b1535cc4edf82be9e8a2b387d57a7967a40bb5b4 Mon Sep 17 00:00:00 2001 From: vbasiuk Date: Thu, 5 Sep 2024 13:51:54 +0300 Subject: [PATCH 03/11] add display method schema to context if present --- src/credentials/credential-wallet.ts | 8 ++++++-- src/verifiable/constants.ts | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/credentials/credential-wallet.ts b/src/credentials/credential-wallet.ts index faf04b40..359f8000 100644 --- a/src/credentials/credential-wallet.ts +++ b/src/credentials/credential-wallet.ts @@ -267,9 +267,13 @@ export class CredentialWallet implements ICredentialWallet { } const context = [ VerifiableConstants.JSONLD_SCHEMA.W3C_CREDENTIAL_2018, - VerifiableConstants.JSONLD_SCHEMA.IDEN3_CREDENTIAL, - schema.$metadata.uris['jsonLdContext'] + VerifiableConstants.JSONLD_SCHEMA.IDEN3_CREDENTIAL ]; + if (request.displayMethod) { + context.push(VerifiableConstants.JSONLD_SCHEMA.IDEN3_BASIC_DISPLAY_METHOD_V1); + } + context.push(schema.$metadata.uris['jsonLdContext']); + const credentialType = [ VerifiableConstants.CREDENTIAL_TYPE.W3C_VERIFIABLE_CREDENTIAL, request.type diff --git a/src/verifiable/constants.ts b/src/verifiable/constants.ts index b1fd2521..c66ecedd 100644 --- a/src/verifiable/constants.ts +++ b/src/verifiable/constants.ts @@ -16,6 +16,8 @@ export const VerifiableConstants = Object.freeze({ JSONLD_SCHEMA: { // JSONLDSchemaIden3Credential is a schema for context with Iden3Credential type IDEN3_CREDENTIAL: 'https://schema.iden3.io/core/jsonld/iden3proofs.jsonld', + // JSONLDSchemaIden3BasicDisplayMethod is a schema for context with Iden3BasicDisplayMethodV1 type + IDEN3_BASIC_DISPLAY_METHOD_V1: 'https://schema.iden3.io/core/jsonld/displayMethod.jsonld', // JSONLDSchemaW3CCredential2018 is a schema for context with VerifiableCredential type W3C_CREDENTIAL_2018: 'https://www.w3.org/2018/credentials/v1', W3C_VC_DOCUMENT_2018: `{"@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","VerifiableCredential":{"@id":"https://www.w3.org/2018/credentials#VerifiableCredential","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","cred":"https://www.w3.org/2018/credentials#","sec":"https://w3id.org/security#","xsd":"http://www.w3.org/2001/XMLSchema#","credentialSchema":{"@id":"cred:credentialSchema","@type":"@id","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","cred":"https://www.w3.org/2018/credentials#","JsonSchemaValidator2018":"cred:JsonSchemaValidator2018"}},"credentialStatus":{"@id":"cred:credentialStatus","@type":"@id"},"credentialSubject":{"@id":"cred:credentialSubject","@type":"@id"},"evidence":{"@id":"cred:evidence","@type":"@id"},"expirationDate":{"@id":"cred:expirationDate","@type":"xsd:dateTime"},"holder":{"@id":"cred:holder","@type":"@id"},"issued":{"@id":"cred:issued","@type":"xsd:dateTime"},"issuer":{"@id":"cred:issuer","@type":"@id"},"issuanceDate":{"@id":"cred:issuanceDate","@type":"xsd:dateTime"},"proof":{"@id":"sec:proof","@type":"@id","@container":"@graph"},"refreshService":{"@id":"cred:refreshService","@type":"@id","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","cred":"https://www.w3.org/2018/credentials#","ManualRefreshService2018":"cred:ManualRefreshService2018"}},"termsOfUse":{"@id":"cred:termsOfUse","@type":"@id"},"validFrom":{"@id":"cred:validFrom","@type":"xsd:dateTime"},"validUntil":{"@id":"cred:validUntil","@type":"xsd:dateTime"}}},"VerifiablePresentation":{"@id":"https://www.w3.org/2018/credentials#VerifiablePresentation","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","cred":"https://www.w3.org/2018/credentials#","sec":"https://w3id.org/security#","holder":{"@id":"cred:holder","@type":"@id"},"proof":{"@id":"sec:proof","@type":"@id","@container":"@graph"},"verifiableCredential":{"@id":"cred:verifiableCredential","@type":"@id","@container":"@graph"}}},"EcdsaSecp256k1Signature2019":{"@id":"https://w3id.org/security#EcdsaSecp256k1Signature2019","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","xsd":"http://www.w3.org/2001/XMLSchema#","challenge":"sec:challenge","created":{"@id":"http://purl.org/dc/terms/created","@type":"xsd:dateTime"},"domain":"sec:domain","expires":{"@id":"sec:expiration","@type":"xsd:dateTime"},"jws":"sec:jws","nonce":"sec:nonce","proofPurpose":{"@id":"sec:proofPurpose","@type":"@vocab","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","assertionMethod":{"@id":"sec:assertionMethod","@type":"@id","@container":"@set"},"authentication":{"@id":"sec:authenticationMethod","@type":"@id","@container":"@set"}}},"proofValue":"sec:proofValue","verificationMethod":{"@id":"sec:verificationMethod","@type":"@id"}}},"EcdsaSecp256r1Signature2019":{"@id":"https://w3id.org/security#EcdsaSecp256r1Signature2019","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","xsd":"http://www.w3.org/2001/XMLSchema#","challenge":"sec:challenge","created":{"@id":"http://purl.org/dc/terms/created","@type":"xsd:dateTime"},"domain":"sec:domain","expires":{"@id":"sec:expiration","@type":"xsd:dateTime"},"jws":"sec:jws","nonce":"sec:nonce","proofPurpose":{"@id":"sec:proofPurpose","@type":"@vocab","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","assertionMethod":{"@id":"sec:assertionMethod","@type":"@id","@container":"@set"},"authentication":{"@id":"sec:authenticationMethod","@type":"@id","@container":"@set"}}},"proofValue":"sec:proofValue","verificationMethod":{"@id":"sec:verificationMethod","@type":"@id"}}},"Ed25519Signature2018":{"@id":"https://w3id.org/security#Ed25519Signature2018","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","xsd":"http://www.w3.org/2001/XMLSchema#","challenge":"sec:challenge","created":{"@id":"http://purl.org/dc/terms/created","@type":"xsd:dateTime"},"domain":"sec:domain","expires":{"@id":"sec:expiration","@type":"xsd:dateTime"},"jws":"sec:jws","nonce":"sec:nonce","proofPurpose":{"@id":"sec:proofPurpose","@type":"@vocab","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","assertionMethod":{"@id":"sec:assertionMethod","@type":"@id","@container":"@set"},"authentication":{"@id":"sec:authenticationMethod","@type":"@id","@container":"@set"}}},"proofValue":"sec:proofValue","verificationMethod":{"@id":"sec:verificationMethod","@type":"@id"}}},"RsaSignature2018":{"@id":"https://w3id.org/security#RsaSignature2018","@context":{"@version":1.1,"@protected":true,"challenge":"sec:challenge","created":{"@id":"http://purl.org/dc/terms/created","@type":"xsd:dateTime"},"domain":"sec:domain","expires":{"@id":"sec:expiration","@type":"xsd:dateTime"},"jws":"sec:jws","nonce":"sec:nonce","proofPurpose":{"@id":"sec:proofPurpose","@type":"@vocab","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","assertionMethod":{"@id":"sec:assertionMethod","@type":"@id","@container":"@set"},"authentication":{"@id":"sec:authenticationMethod","@type":"@id","@container":"@set"}}},"proofValue":"sec:proofValue","verificationMethod":{"@id":"sec:verificationMethod","@type":"@id"}}},"proof":{"@id":"https://w3id.org/security#proof","@type":"@id","@container":"@graph"}}}` From 7959edeecdadbe2c3d90d0893fffb827af5f6556 Mon Sep 17 00:00:00 2001 From: vbasiuk Date: Thu, 5 Sep 2024 14:24:11 +0300 Subject: [PATCH 04/11] add custom context --- src/credentials/credential-wallet.ts | 20 ++++++++++++++------ src/credentials/models.ts | 4 ++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/credentials/credential-wallet.ts b/src/credentials/credential-wallet.ts index 359f8000..e9fff0e0 100644 --- a/src/credentials/credential-wallet.ts +++ b/src/credentials/credential-wallet.ts @@ -7,7 +7,8 @@ import { CredentialStatus, RevocationStatus, CredentialStatusType, - State + State, + DisplayMethodType } from './../verifiable'; import { JSONSchema } from '../schema-processor'; @@ -265,14 +266,21 @@ export class CredentialWallet implements ICredentialWallet { if (!schema.$metadata.uris['jsonLdContext']) { throw new Error('jsonLdContext is missing is the schema'); } + if (!request.context) { + request.context = []; + } + if ( + request.displayMethod?.type === DisplayMethodType.Iden3BasicDisplayMethodV1 && + !request.context.includes(VerifiableConstants.JSONLD_SCHEMA.IDEN3_BASIC_DISPLAY_METHOD_V1) + ) { + request.context.push(VerifiableConstants.JSONLD_SCHEMA.IDEN3_BASIC_DISPLAY_METHOD_V1); + } const context = [ + ...request.context, VerifiableConstants.JSONLD_SCHEMA.W3C_CREDENTIAL_2018, - VerifiableConstants.JSONLD_SCHEMA.IDEN3_CREDENTIAL + VerifiableConstants.JSONLD_SCHEMA.IDEN3_CREDENTIAL, + schema.$metadata.uris['jsonLdContext'] ]; - if (request.displayMethod) { - context.push(VerifiableConstants.JSONLD_SCHEMA.IDEN3_BASIC_DISPLAY_METHOD_V1); - } - context.push(schema.$metadata.uris['jsonLdContext']); const credentialType = [ VerifiableConstants.CREDENTIAL_TYPE.W3C_VERIFIABLE_CREDENTIAL, diff --git a/src/credentials/models.ts b/src/credentials/models.ts index 3cd4624d..12bc614f 100644 --- a/src/credentials/models.ts +++ b/src/credentials/models.ts @@ -47,6 +47,10 @@ export interface CredentialRequest { * displayMethod */ displayMethod?: DisplayMethod; + /** + * optional custrom context (for not iden3 refres service or display method) + */ + context?: string[]; /** * claim version */ From b5d72bd821ddc037146f681d061cc97f423f2fbe Mon Sep 17 00:00:00 2001 From: vbasiuk Date: Thu, 5 Sep 2024 14:25:36 +0300 Subject: [PATCH 05/11] fix --- src/credentials/models.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/credentials/models.ts b/src/credentials/models.ts index 12bc614f..9a4b26aa 100644 --- a/src/credentials/models.ts +++ b/src/credentials/models.ts @@ -48,7 +48,7 @@ export interface CredentialRequest { */ displayMethod?: DisplayMethod; /** - * optional custrom context (for not iden3 refres service or display method) + * optional custom context (for not iden3 refres service or display method) */ context?: string[]; /** From c4afb307ebb6e14a0b2705e99e13d2e337fe5aa9 Mon Sep 17 00:00:00 2001 From: vbasiuk Date: Thu, 5 Sep 2024 14:35:11 +0300 Subject: [PATCH 06/11] fix comment --- src/credentials/models.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/credentials/models.ts b/src/credentials/models.ts index 9a4b26aa..c95c2b76 100644 --- a/src/credentials/models.ts +++ b/src/credentials/models.ts @@ -48,7 +48,7 @@ export interface CredentialRequest { */ displayMethod?: DisplayMethod; /** - * optional custom context (for not iden3 refres service or display method) + * optional custom context (for not iden3 refresh service or display method) */ context?: string[]; /** From 3d51d3c1c37f305bf0829d721950ef8ae987d833 Mon Sep 17 00:00:00 2001 From: vbasiuk Date: Thu, 5 Sep 2024 14:35:36 +0300 Subject: [PATCH 07/11] update context comment --- src/credentials/models.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/credentials/models.ts b/src/credentials/models.ts index c95c2b76..db529f21 100644 --- a/src/credentials/models.ts +++ b/src/credentials/models.ts @@ -48,7 +48,7 @@ export interface CredentialRequest { */ displayMethod?: DisplayMethod; /** - * optional custom context (for not iden3 refresh service or display method) + * optional custom context */ context?: string[]; /** From 367d0a58f3ae45635a65b6e8aa11c688977c2a61 Mon Sep 17 00:00:00 2001 From: vbasiuk Date: Thu, 5 Sep 2024 14:39:21 +0300 Subject: [PATCH 08/11] IDEN_DISPLAY_METHOD --- src/credentials/credential-wallet.ts | 4 ++-- src/verifiable/constants.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/credentials/credential-wallet.ts b/src/credentials/credential-wallet.ts index e9fff0e0..508d4918 100644 --- a/src/credentials/credential-wallet.ts +++ b/src/credentials/credential-wallet.ts @@ -271,9 +271,9 @@ export class CredentialWallet implements ICredentialWallet { } if ( request.displayMethod?.type === DisplayMethodType.Iden3BasicDisplayMethodV1 && - !request.context.includes(VerifiableConstants.JSONLD_SCHEMA.IDEN3_BASIC_DISPLAY_METHOD_V1) + !request.context.includes(VerifiableConstants.JSONLD_SCHEMA.IDEN_DISPLAY_METHOD) ) { - request.context.push(VerifiableConstants.JSONLD_SCHEMA.IDEN3_BASIC_DISPLAY_METHOD_V1); + request.context.push(VerifiableConstants.JSONLD_SCHEMA.IDEN_DISPLAY_METHOD); } const context = [ ...request.context, diff --git a/src/verifiable/constants.ts b/src/verifiable/constants.ts index c66ecedd..875aaf1c 100644 --- a/src/verifiable/constants.ts +++ b/src/verifiable/constants.ts @@ -17,7 +17,7 @@ export const VerifiableConstants = Object.freeze({ // JSONLDSchemaIden3Credential is a schema for context with Iden3Credential type IDEN3_CREDENTIAL: 'https://schema.iden3.io/core/jsonld/iden3proofs.jsonld', // JSONLDSchemaIden3BasicDisplayMethod is a schema for context with Iden3BasicDisplayMethodV1 type - IDEN3_BASIC_DISPLAY_METHOD_V1: 'https://schema.iden3.io/core/jsonld/displayMethod.jsonld', + IDEN_DISPLAY_METHOD: 'https://schema.iden3.io/core/jsonld/displayMethod.jsonld', // JSONLDSchemaW3CCredential2018 is a schema for context with VerifiableCredential type W3C_CREDENTIAL_2018: 'https://www.w3.org/2018/credentials/v1', W3C_VC_DOCUMENT_2018: `{"@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","VerifiableCredential":{"@id":"https://www.w3.org/2018/credentials#VerifiableCredential","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","cred":"https://www.w3.org/2018/credentials#","sec":"https://w3id.org/security#","xsd":"http://www.w3.org/2001/XMLSchema#","credentialSchema":{"@id":"cred:credentialSchema","@type":"@id","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","cred":"https://www.w3.org/2018/credentials#","JsonSchemaValidator2018":"cred:JsonSchemaValidator2018"}},"credentialStatus":{"@id":"cred:credentialStatus","@type":"@id"},"credentialSubject":{"@id":"cred:credentialSubject","@type":"@id"},"evidence":{"@id":"cred:evidence","@type":"@id"},"expirationDate":{"@id":"cred:expirationDate","@type":"xsd:dateTime"},"holder":{"@id":"cred:holder","@type":"@id"},"issued":{"@id":"cred:issued","@type":"xsd:dateTime"},"issuer":{"@id":"cred:issuer","@type":"@id"},"issuanceDate":{"@id":"cred:issuanceDate","@type":"xsd:dateTime"},"proof":{"@id":"sec:proof","@type":"@id","@container":"@graph"},"refreshService":{"@id":"cred:refreshService","@type":"@id","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","cred":"https://www.w3.org/2018/credentials#","ManualRefreshService2018":"cred:ManualRefreshService2018"}},"termsOfUse":{"@id":"cred:termsOfUse","@type":"@id"},"validFrom":{"@id":"cred:validFrom","@type":"xsd:dateTime"},"validUntil":{"@id":"cred:validUntil","@type":"xsd:dateTime"}}},"VerifiablePresentation":{"@id":"https://www.w3.org/2018/credentials#VerifiablePresentation","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","cred":"https://www.w3.org/2018/credentials#","sec":"https://w3id.org/security#","holder":{"@id":"cred:holder","@type":"@id"},"proof":{"@id":"sec:proof","@type":"@id","@container":"@graph"},"verifiableCredential":{"@id":"cred:verifiableCredential","@type":"@id","@container":"@graph"}}},"EcdsaSecp256k1Signature2019":{"@id":"https://w3id.org/security#EcdsaSecp256k1Signature2019","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","xsd":"http://www.w3.org/2001/XMLSchema#","challenge":"sec:challenge","created":{"@id":"http://purl.org/dc/terms/created","@type":"xsd:dateTime"},"domain":"sec:domain","expires":{"@id":"sec:expiration","@type":"xsd:dateTime"},"jws":"sec:jws","nonce":"sec:nonce","proofPurpose":{"@id":"sec:proofPurpose","@type":"@vocab","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","assertionMethod":{"@id":"sec:assertionMethod","@type":"@id","@container":"@set"},"authentication":{"@id":"sec:authenticationMethod","@type":"@id","@container":"@set"}}},"proofValue":"sec:proofValue","verificationMethod":{"@id":"sec:verificationMethod","@type":"@id"}}},"EcdsaSecp256r1Signature2019":{"@id":"https://w3id.org/security#EcdsaSecp256r1Signature2019","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","xsd":"http://www.w3.org/2001/XMLSchema#","challenge":"sec:challenge","created":{"@id":"http://purl.org/dc/terms/created","@type":"xsd:dateTime"},"domain":"sec:domain","expires":{"@id":"sec:expiration","@type":"xsd:dateTime"},"jws":"sec:jws","nonce":"sec:nonce","proofPurpose":{"@id":"sec:proofPurpose","@type":"@vocab","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","assertionMethod":{"@id":"sec:assertionMethod","@type":"@id","@container":"@set"},"authentication":{"@id":"sec:authenticationMethod","@type":"@id","@container":"@set"}}},"proofValue":"sec:proofValue","verificationMethod":{"@id":"sec:verificationMethod","@type":"@id"}}},"Ed25519Signature2018":{"@id":"https://w3id.org/security#Ed25519Signature2018","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","xsd":"http://www.w3.org/2001/XMLSchema#","challenge":"sec:challenge","created":{"@id":"http://purl.org/dc/terms/created","@type":"xsd:dateTime"},"domain":"sec:domain","expires":{"@id":"sec:expiration","@type":"xsd:dateTime"},"jws":"sec:jws","nonce":"sec:nonce","proofPurpose":{"@id":"sec:proofPurpose","@type":"@vocab","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","assertionMethod":{"@id":"sec:assertionMethod","@type":"@id","@container":"@set"},"authentication":{"@id":"sec:authenticationMethod","@type":"@id","@container":"@set"}}},"proofValue":"sec:proofValue","verificationMethod":{"@id":"sec:verificationMethod","@type":"@id"}}},"RsaSignature2018":{"@id":"https://w3id.org/security#RsaSignature2018","@context":{"@version":1.1,"@protected":true,"challenge":"sec:challenge","created":{"@id":"http://purl.org/dc/terms/created","@type":"xsd:dateTime"},"domain":"sec:domain","expires":{"@id":"sec:expiration","@type":"xsd:dateTime"},"jws":"sec:jws","nonce":"sec:nonce","proofPurpose":{"@id":"sec:proofPurpose","@type":"@vocab","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","assertionMethod":{"@id":"sec:assertionMethod","@type":"@id","@container":"@set"},"authentication":{"@id":"sec:authenticationMethod","@type":"@id","@container":"@set"}}},"proofValue":"sec:proofValue","verificationMethod":{"@id":"sec:verificationMethod","@type":"@id"}}},"proof":{"@id":"https://w3id.org/security#proof","@type":"@id","@container":"@graph"}}}` From 5575ce9ed0eb9209911826cb563a6e82d1872aa4 Mon Sep 17 00:00:00 2001 From: vbasiuk Date: Thu, 5 Sep 2024 14:39:59 +0300 Subject: [PATCH 09/11] comment --- src/verifiable/constants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/verifiable/constants.ts b/src/verifiable/constants.ts index 875aaf1c..56d2c214 100644 --- a/src/verifiable/constants.ts +++ b/src/verifiable/constants.ts @@ -16,7 +16,7 @@ export const VerifiableConstants = Object.freeze({ JSONLD_SCHEMA: { // JSONLDSchemaIden3Credential is a schema for context with Iden3Credential type IDEN3_CREDENTIAL: 'https://schema.iden3.io/core/jsonld/iden3proofs.jsonld', - // JSONLDSchemaIden3BasicDisplayMethod is a schema for context with Iden3BasicDisplayMethodV1 type + // JSONLDSchemaIden3DisplayMethod is a schema for context with Iden3BasicDisplayMethodV1 type IDEN_DISPLAY_METHOD: 'https://schema.iden3.io/core/jsonld/displayMethod.jsonld', // JSONLDSchemaW3CCredential2018 is a schema for context with VerifiableCredential type W3C_CREDENTIAL_2018: 'https://www.w3.org/2018/credentials/v1', From bd64665ef93a8f4cf73b236a457196029e103a00 Mon Sep 17 00:00:00 2001 From: vbasiuk Date: Thu, 5 Sep 2024 14:40:45 +0300 Subject: [PATCH 10/11] IDEN3_DISPLAY_METHOD --- src/credentials/credential-wallet.ts | 4 ++-- src/verifiable/constants.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/credentials/credential-wallet.ts b/src/credentials/credential-wallet.ts index 508d4918..ed62b4b4 100644 --- a/src/credentials/credential-wallet.ts +++ b/src/credentials/credential-wallet.ts @@ -271,9 +271,9 @@ export class CredentialWallet implements ICredentialWallet { } if ( request.displayMethod?.type === DisplayMethodType.Iden3BasicDisplayMethodV1 && - !request.context.includes(VerifiableConstants.JSONLD_SCHEMA.IDEN_DISPLAY_METHOD) + !request.context.includes(VerifiableConstants.JSONLD_SCHEMA.IDEN3_DISPLAY_METHOD) ) { - request.context.push(VerifiableConstants.JSONLD_SCHEMA.IDEN_DISPLAY_METHOD); + request.context.push(VerifiableConstants.JSONLD_SCHEMA.IDEN3_DISPLAY_METHOD); } const context = [ ...request.context, diff --git a/src/verifiable/constants.ts b/src/verifiable/constants.ts index 56d2c214..ee8e7857 100644 --- a/src/verifiable/constants.ts +++ b/src/verifiable/constants.ts @@ -17,7 +17,7 @@ export const VerifiableConstants = Object.freeze({ // JSONLDSchemaIden3Credential is a schema for context with Iden3Credential type IDEN3_CREDENTIAL: 'https://schema.iden3.io/core/jsonld/iden3proofs.jsonld', // JSONLDSchemaIden3DisplayMethod is a schema for context with Iden3BasicDisplayMethodV1 type - IDEN_DISPLAY_METHOD: 'https://schema.iden3.io/core/jsonld/displayMethod.jsonld', + IDEN3_DISPLAY_METHOD: 'https://schema.iden3.io/core/jsonld/displayMethod.jsonld', // JSONLDSchemaW3CCredential2018 is a schema for context with VerifiableCredential type W3C_CREDENTIAL_2018: 'https://www.w3.org/2018/credentials/v1', W3C_VC_DOCUMENT_2018: `{"@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","VerifiableCredential":{"@id":"https://www.w3.org/2018/credentials#VerifiableCredential","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","cred":"https://www.w3.org/2018/credentials#","sec":"https://w3id.org/security#","xsd":"http://www.w3.org/2001/XMLSchema#","credentialSchema":{"@id":"cred:credentialSchema","@type":"@id","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","cred":"https://www.w3.org/2018/credentials#","JsonSchemaValidator2018":"cred:JsonSchemaValidator2018"}},"credentialStatus":{"@id":"cred:credentialStatus","@type":"@id"},"credentialSubject":{"@id":"cred:credentialSubject","@type":"@id"},"evidence":{"@id":"cred:evidence","@type":"@id"},"expirationDate":{"@id":"cred:expirationDate","@type":"xsd:dateTime"},"holder":{"@id":"cred:holder","@type":"@id"},"issued":{"@id":"cred:issued","@type":"xsd:dateTime"},"issuer":{"@id":"cred:issuer","@type":"@id"},"issuanceDate":{"@id":"cred:issuanceDate","@type":"xsd:dateTime"},"proof":{"@id":"sec:proof","@type":"@id","@container":"@graph"},"refreshService":{"@id":"cred:refreshService","@type":"@id","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","cred":"https://www.w3.org/2018/credentials#","ManualRefreshService2018":"cred:ManualRefreshService2018"}},"termsOfUse":{"@id":"cred:termsOfUse","@type":"@id"},"validFrom":{"@id":"cred:validFrom","@type":"xsd:dateTime"},"validUntil":{"@id":"cred:validUntil","@type":"xsd:dateTime"}}},"VerifiablePresentation":{"@id":"https://www.w3.org/2018/credentials#VerifiablePresentation","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","cred":"https://www.w3.org/2018/credentials#","sec":"https://w3id.org/security#","holder":{"@id":"cred:holder","@type":"@id"},"proof":{"@id":"sec:proof","@type":"@id","@container":"@graph"},"verifiableCredential":{"@id":"cred:verifiableCredential","@type":"@id","@container":"@graph"}}},"EcdsaSecp256k1Signature2019":{"@id":"https://w3id.org/security#EcdsaSecp256k1Signature2019","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","xsd":"http://www.w3.org/2001/XMLSchema#","challenge":"sec:challenge","created":{"@id":"http://purl.org/dc/terms/created","@type":"xsd:dateTime"},"domain":"sec:domain","expires":{"@id":"sec:expiration","@type":"xsd:dateTime"},"jws":"sec:jws","nonce":"sec:nonce","proofPurpose":{"@id":"sec:proofPurpose","@type":"@vocab","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","assertionMethod":{"@id":"sec:assertionMethod","@type":"@id","@container":"@set"},"authentication":{"@id":"sec:authenticationMethod","@type":"@id","@container":"@set"}}},"proofValue":"sec:proofValue","verificationMethod":{"@id":"sec:verificationMethod","@type":"@id"}}},"EcdsaSecp256r1Signature2019":{"@id":"https://w3id.org/security#EcdsaSecp256r1Signature2019","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","xsd":"http://www.w3.org/2001/XMLSchema#","challenge":"sec:challenge","created":{"@id":"http://purl.org/dc/terms/created","@type":"xsd:dateTime"},"domain":"sec:domain","expires":{"@id":"sec:expiration","@type":"xsd:dateTime"},"jws":"sec:jws","nonce":"sec:nonce","proofPurpose":{"@id":"sec:proofPurpose","@type":"@vocab","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","assertionMethod":{"@id":"sec:assertionMethod","@type":"@id","@container":"@set"},"authentication":{"@id":"sec:authenticationMethod","@type":"@id","@container":"@set"}}},"proofValue":"sec:proofValue","verificationMethod":{"@id":"sec:verificationMethod","@type":"@id"}}},"Ed25519Signature2018":{"@id":"https://w3id.org/security#Ed25519Signature2018","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","xsd":"http://www.w3.org/2001/XMLSchema#","challenge":"sec:challenge","created":{"@id":"http://purl.org/dc/terms/created","@type":"xsd:dateTime"},"domain":"sec:domain","expires":{"@id":"sec:expiration","@type":"xsd:dateTime"},"jws":"sec:jws","nonce":"sec:nonce","proofPurpose":{"@id":"sec:proofPurpose","@type":"@vocab","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","assertionMethod":{"@id":"sec:assertionMethod","@type":"@id","@container":"@set"},"authentication":{"@id":"sec:authenticationMethod","@type":"@id","@container":"@set"}}},"proofValue":"sec:proofValue","verificationMethod":{"@id":"sec:verificationMethod","@type":"@id"}}},"RsaSignature2018":{"@id":"https://w3id.org/security#RsaSignature2018","@context":{"@version":1.1,"@protected":true,"challenge":"sec:challenge","created":{"@id":"http://purl.org/dc/terms/created","@type":"xsd:dateTime"},"domain":"sec:domain","expires":{"@id":"sec:expiration","@type":"xsd:dateTime"},"jws":"sec:jws","nonce":"sec:nonce","proofPurpose":{"@id":"sec:proofPurpose","@type":"@vocab","@context":{"@version":1.1,"@protected":true,"id":"@id","type":"@type","sec":"https://w3id.org/security#","assertionMethod":{"@id":"sec:assertionMethod","@type":"@id","@container":"@set"},"authentication":{"@id":"sec:authenticationMethod","@type":"@id","@container":"@set"}}},"proofValue":"sec:proofValue","verificationMethod":{"@id":"sec:verificationMethod","@type":"@id"}}},"proof":{"@id":"https://w3id.org/security#proof","@type":"@id","@container":"@graph"}}}` From 207ce50ac852257d002c08daaa9d0240dd65f8a3 Mon Sep 17 00:00:00 2001 From: vbasiuk Date: Thu, 5 Sep 2024 15:16:35 +0300 Subject: [PATCH 11/11] replace if with ?? --- src/credentials/credential-wallet.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/credentials/credential-wallet.ts b/src/credentials/credential-wallet.ts index ed62b4b4..b150d83b 100644 --- a/src/credentials/credential-wallet.ts +++ b/src/credentials/credential-wallet.ts @@ -266,9 +266,7 @@ export class CredentialWallet implements ICredentialWallet { if (!schema.$metadata.uris['jsonLdContext']) { throw new Error('jsonLdContext is missing is the schema'); } - if (!request.context) { - request.context = []; - } + request.context = request.context ?? []; if ( request.displayMethod?.type === DisplayMethodType.Iden3BasicDisplayMethodV1 && !request.context.includes(VerifiableConstants.JSONLD_SCHEMA.IDEN3_DISPLAY_METHOD)