@credo-ts/openid4vc 0.6.0-pr-2209-20250321171013 → 0.6.0-pr-2195-20250321182650

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/build/openid4vc-holder/OpenId4VcHolderApi.d.ts +126 -21
  2. package/build/openid4vc-holder/OpenId4VcHolderApi.js +36 -21
  3. package/build/openid4vc-holder/OpenId4VcHolderApi.js.map +1 -1
  4. package/build/openid4vc-holder/OpenId4VcHolderModule.js +3 -3
  5. package/build/openid4vc-holder/OpenId4VcHolderModule.js.map +1 -1
  6. package/build/openid4vc-holder/OpenId4VciHolderService.d.ts +5 -6
  7. package/build/openid4vc-holder/OpenId4VciHolderService.js +13 -15
  8. package/build/openid4vc-holder/OpenId4VciHolderService.js.map +1 -1
  9. package/build/openid4vc-holder/OpenId4VciHolderServiceOptions.d.ts +3 -3
  10. package/build/openid4vc-holder/OpenId4VciHolderServiceOptions.js +2 -2
  11. package/build/openid4vc-holder/OpenId4VciHolderServiceOptions.js.map +1 -1
  12. package/build/openid4vc-holder/OpenId4vpHolderService.d.ts +132 -0
  13. package/build/openid4vc-holder/OpenId4vpHolderService.js +317 -0
  14. package/build/openid4vc-holder/OpenId4vpHolderService.js.map +1 -0
  15. package/build/openid4vc-holder/OpenId4vpHolderServiceOptions.d.ts +81 -0
  16. package/build/openid4vc-holder/{OpenId4vcSiopHolderServiceOptions.js → OpenId4vpHolderServiceOptions.js} +1 -1
  17. package/build/openid4vc-holder/OpenId4vpHolderServiceOptions.js.map +1 -0
  18. package/build/openid4vc-holder/index.d.ts +2 -2
  19. package/build/openid4vc-holder/index.js +2 -2
  20. package/build/openid4vc-holder/index.js.map +1 -1
  21. package/build/openid4vc-issuer/OpenId4VcIssuerApi.d.ts +194 -44
  22. package/build/openid4vc-issuer/OpenId4VcIssuerModule.js +1 -1
  23. package/build/openid4vc-issuer/OpenId4VcIssuerModule.js.map +1 -1
  24. package/build/openid4vc-issuer/OpenId4VcIssuerModuleConfig.d.ts +7 -7
  25. package/build/openid4vc-issuer/OpenId4VcIssuerModuleConfig.js +2 -10
  26. package/build/openid4vc-issuer/OpenId4VcIssuerModuleConfig.js.map +1 -1
  27. package/build/openid4vc-issuer/OpenId4VcIssuerService.d.ts +197 -48
  28. package/build/openid4vc-issuer/OpenId4VcIssuerService.js +28 -19
  29. package/build/openid4vc-issuer/OpenId4VcIssuerService.js.map +1 -1
  30. package/build/openid4vc-issuer/OpenId4VcIssuerServiceOptions.d.ts +11 -6
  31. package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRecord.d.ts +11 -1
  32. package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRecord.js +2 -0
  33. package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRecord.js.map +1 -1
  34. package/build/openid4vc-issuer/repository/OpenId4VcIssuerRecord.js +2 -2
  35. package/build/openid4vc-issuer/repository/OpenId4VcIssuerRecord.js.map +1 -1
  36. package/build/openid4vc-issuer/router/accessTokenEndpoint.js +1 -1
  37. package/build/openid4vc-issuer/router/accessTokenEndpoint.js.map +1 -1
  38. package/build/openid4vc-issuer/router/authorizationChallengeEndpoint.js +1 -1
  39. package/build/openid4vc-issuer/router/authorizationChallengeEndpoint.js.map +1 -1
  40. package/build/openid4vc-issuer/router/authorizationServerMetadataEndpoint.js +1 -1
  41. package/build/openid4vc-issuer/router/authorizationServerMetadataEndpoint.js.map +1 -1
  42. package/build/openid4vc-issuer/router/credentialEndpoint.js +4 -3
  43. package/build/openid4vc-issuer/router/credentialEndpoint.js.map +1 -1
  44. package/build/openid4vc-issuer/router/credentialOfferEndpoint.js +15 -0
  45. package/build/openid4vc-issuer/router/credentialOfferEndpoint.js.map +1 -1
  46. package/build/openid4vc-issuer/router/issuerMetadataEndpoint.js +1 -1
  47. package/build/openid4vc-issuer/router/issuerMetadataEndpoint.js.map +1 -1
  48. package/build/openid4vc-verifier/OpenId4VcVerifierApi.d.ts +12 -25
  49. package/build/openid4vc-verifier/OpenId4VcVerifierApi.js +16 -25
  50. package/build/openid4vc-verifier/OpenId4VcVerifierApi.js.map +1 -1
  51. package/build/openid4vc-verifier/OpenId4VcVerifierModule.js +5 -8
  52. package/build/openid4vc-verifier/OpenId4VcVerifierModule.js.map +1 -1
  53. package/build/openid4vc-verifier/OpenId4VcVerifierModuleConfig.d.ts +30 -7
  54. package/build/openid4vc-verifier/OpenId4VcVerifierModuleConfig.js +16 -12
  55. package/build/openid4vc-verifier/OpenId4VcVerifierModuleConfig.js.map +1 -1
  56. package/build/openid4vc-verifier/OpenId4VpVerifierService.d.ts +51 -0
  57. package/build/openid4vc-verifier/OpenId4VpVerifierService.js +765 -0
  58. package/build/openid4vc-verifier/OpenId4VpVerifierService.js.map +1 -0
  59. package/build/openid4vc-verifier/OpenId4VpVerifierServiceOptions.d.ts +146 -0
  60. package/build/openid4vc-verifier/{OpenId4VcSiopVerifierServiceOptions.js → OpenId4VpVerifierServiceOptions.js} +1 -1
  61. package/build/openid4vc-verifier/OpenId4VpVerifierServiceOptions.js.map +1 -0
  62. package/build/openid4vc-verifier/index.d.ts +2 -2
  63. package/build/openid4vc-verifier/index.js +2 -2
  64. package/build/openid4vc-verifier/index.js.map +1 -1
  65. package/build/openid4vc-verifier/repository/OpenId4VcVerificationSessionRecord.d.ts +39 -14
  66. package/build/openid4vc-verifier/repository/OpenId4VcVerificationSessionRecord.js +38 -8
  67. package/build/openid4vc-verifier/repository/OpenId4VcVerificationSessionRecord.js.map +1 -1
  68. package/build/openid4vc-verifier/repository/OpenId4VcVerifierRecord.d.ts +3 -3
  69. package/build/openid4vc-verifier/router/authorizationEndpoint.d.ts +2 -10
  70. package/build/openid4vc-verifier/router/authorizationEndpoint.js +94 -105
  71. package/build/openid4vc-verifier/router/authorizationEndpoint.js.map +1 -1
  72. package/build/openid4vc-verifier/router/authorizationRequestEndpoint.d.ts +2 -10
  73. package/build/openid4vc-verifier/router/authorizationRequestEndpoint.js +21 -22
  74. package/build/openid4vc-verifier/router/authorizationRequestEndpoint.js.map +1 -1
  75. package/build/shared/callbacks.d.ts +13 -5
  76. package/build/shared/callbacks.js +104 -13
  77. package/build/shared/callbacks.js.map +1 -1
  78. package/build/shared/issuerMetadataUtils.d.ts +102 -144
  79. package/build/shared/models/OpenId4VcJwtIssuer.d.ts +2 -3
  80. package/build/shared/models/index.d.ts +10 -10
  81. package/build/shared/models/index.js +5 -5
  82. package/build/shared/models/index.js.map +1 -1
  83. package/build/shared/router/context.d.ts +3 -3
  84. package/build/shared/router/context.js +7 -3
  85. package/build/shared/router/context.js.map +1 -1
  86. package/build/shared/transactionData.d.ts +5 -0
  87. package/build/shared/transactionData.js +22 -0
  88. package/build/shared/transactionData.js.map +1 -0
  89. package/build/shared/utils.d.ts +6 -8
  90. package/build/shared/utils.js +34 -105
  91. package/build/shared/utils.js.map +1 -1
  92. package/package.json +7 -8
  93. package/build/openid4vc-holder/OpenId4vcSiopHolderService.d.ts +0 -32
  94. package/build/openid4vc-holder/OpenId4vcSiopHolderService.js +0 -300
  95. package/build/openid4vc-holder/OpenId4vcSiopHolderService.js.map +0 -1
  96. package/build/openid4vc-holder/OpenId4vcSiopHolderServiceOptions.d.ts +0 -38
  97. package/build/openid4vc-holder/OpenId4vcSiopHolderServiceOptions.js.map +0 -1
  98. package/build/openid4vc-verifier/OpenId4VcSiopVerifierService.d.ts +0 -55
  99. package/build/openid4vc-verifier/OpenId4VcSiopVerifierService.js +0 -553
  100. package/build/openid4vc-verifier/OpenId4VcSiopVerifierService.js.map +0 -1
  101. package/build/openid4vc-verifier/OpenId4VcSiopVerifierServiceOptions.d.ts +0 -77
  102. package/build/openid4vc-verifier/OpenId4VcSiopVerifierServiceOptions.js.map +0 -1
  103. package/build/openid4vc-verifier/repository/OpenId4VcRelyingPartyEventEmitter.d.ts +0 -49
  104. package/build/openid4vc-verifier/repository/OpenId4VcRelyingPartyEventEmitter.js +0 -230
  105. package/build/openid4vc-verifier/repository/OpenId4VcRelyingPartyEventEmitter.js.map +0 -1
  106. package/build/openid4vc-verifier/repository/OpenId4VcRelyingPartySessionManager.d.ts +0 -19
  107. package/build/openid4vc-verifier/repository/OpenId4VcRelyingPartySessionManager.js +0 -144
  108. package/build/openid4vc-verifier/repository/OpenId4VcRelyingPartySessionManager.js.map +0 -1
  109. package/build/shared/transform.d.ts +0 -5
  110. package/build/shared/transform.js +0 -69
  111. package/build/shared/transform.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"OpenId4VciHolderServiceOptions.js","sourceRoot":"","sources":["../../src/openid4vc-holder/OpenId4VciHolderServiceOptions.ts"],"names":[],"mappings":";;;AAQA,+CAAoF;AAI3E,4GAJqB,2BAA2B,OAIrB;AAFpC,0GAAsG;AAWzF,QAAA,oCAAoC,GAA2C;IAC1F,qEAAiC,CAAC,SAAS;IAC3C,qEAAiC,CAAC,WAAW;IAC7C,qEAAiC,CAAC,OAAO;IACzC,qEAAiC,CAAC,KAAK;IACvC,qEAAiC,CAAC,OAAO;CAC1C,CAAA"}
1
+ {"version":3,"file":"OpenId4VciHolderServiceOptions.js","sourceRoot":"","sources":["../../src/openid4vc-holder/OpenId4VciHolderServiceOptions.ts"],"names":[],"mappings":";;;AAQA,sDAAwF;AAI/E,4GAJqB,8BAA2B,OAIrB;AAFpC,0GAAsG;AAWzF,QAAA,oCAAoC,GAA2C;IAC1F,qEAAiC,CAAC,SAAS;IAC3C,qEAAiC,CAAC,WAAW;IAC7C,qEAAiC,CAAC,OAAO;IACzC,qEAAiC,CAAC,KAAK;IACvC,qEAAiC,CAAC,OAAO;CAC1C,CAAA"}
@@ -0,0 +1,132 @@
1
+ import type { AgentContext, DifPresentationExchangeSubmission } from '@credo-ts/core';
2
+ import type { OpenId4VpAcceptAuthorizationRequestOptions, OpenId4VpResolvedAuthorizationRequest, ResolveOpenId4VpAuthorizationRequestOptions } from './OpenId4vpHolderServiceOptions';
3
+ import { DcqlService, DifPresentationExchangeService } from '@credo-ts/core';
4
+ export declare class OpenId4VpHolderService {
5
+ private presentationExchangeService;
6
+ private dcqlService;
7
+ constructor(presentationExchangeService: DifPresentationExchangeService, dcqlService: DcqlService);
8
+ private getOpenid4vpClient;
9
+ private handlePresentationExchangeRequest;
10
+ private handleDcqlRequest;
11
+ resolveAuthorizationRequest(agentContext: AgentContext,
12
+ /**
13
+ * Can be:
14
+ * - JWT
15
+ * - URI containing request or request_uri param
16
+ * - Request payload
17
+ */
18
+ authorizationRequest: string | Record<string, unknown>, options?: ResolveOpenId4VpAuthorizationRequestOptions): Promise<OpenId4VpResolvedAuthorizationRequest>;
19
+ private extendCredentialsWithTransactionDataHashes;
20
+ acceptAuthorizationRequest(agentContext: AgentContext, options: OpenId4VpAcceptAuthorizationRequestOptions): Promise<{
21
+ readonly ok: true;
22
+ readonly authorizationResponse: ({
23
+ vp_token: string | Record<string, any> | Record<string, string | Record<string, any>> | [string | Record<string, any>, ...(string | Record<string, any>)[]];
24
+ presentation_submission?: any;
25
+ access_token?: string | undefined;
26
+ token_type?: string | undefined;
27
+ expires_in?: number | undefined;
28
+ state?: string | undefined;
29
+ refresh_token?: string | undefined;
30
+ id_token?: string | undefined;
31
+ } & {
32
+ [k: string]: unknown;
33
+ } & {
34
+ presentation_submission?: DifPresentationExchangeSubmission;
35
+ }) | {
36
+ response: string;
37
+ };
38
+ readonly authorizationResponsePayload: {
39
+ vp_token: string | Record<string, any> | Record<string, string | Record<string, any>> | [string | Record<string, any>, ...(string | Record<string, any>)[]];
40
+ presentation_submission?: any;
41
+ access_token?: string | undefined;
42
+ token_type?: string | undefined;
43
+ expires_in?: number | undefined;
44
+ state?: string | undefined;
45
+ refresh_token?: string | undefined;
46
+ id_token?: string | undefined;
47
+ } & {
48
+ [k: string]: unknown;
49
+ } & {
50
+ presentation_submission?: DifPresentationExchangeSubmission;
51
+ };
52
+ readonly serverResponse?: undefined;
53
+ readonly redirectUri?: undefined;
54
+ readonly presentationDuringIssuanceSession?: undefined;
55
+ } | {
56
+ readonly ok: false;
57
+ readonly serverResponse: {
58
+ readonly status: number;
59
+ readonly body: string | Record<string, unknown> | null;
60
+ };
61
+ readonly authorizationResponse: ({
62
+ vp_token: string | Record<string, any> | Record<string, string | Record<string, any>> | [string | Record<string, any>, ...(string | Record<string, any>)[]];
63
+ presentation_submission?: any;
64
+ access_token?: string | undefined;
65
+ token_type?: string | undefined;
66
+ expires_in?: number | undefined;
67
+ state?: string | undefined;
68
+ refresh_token?: string | undefined;
69
+ id_token?: string | undefined;
70
+ } & {
71
+ [k: string]: unknown;
72
+ } & {
73
+ presentation_submission?: DifPresentationExchangeSubmission;
74
+ }) | {
75
+ response: string;
76
+ };
77
+ readonly authorizationResponsePayload: {
78
+ vp_token: string | Record<string, any> | Record<string, string | Record<string, any>> | [string | Record<string, any>, ...(string | Record<string, any>)[]];
79
+ presentation_submission?: any;
80
+ access_token?: string | undefined;
81
+ token_type?: string | undefined;
82
+ expires_in?: number | undefined;
83
+ state?: string | undefined;
84
+ refresh_token?: string | undefined;
85
+ id_token?: string | undefined;
86
+ } & {
87
+ [k: string]: unknown;
88
+ } & {
89
+ presentation_submission?: DifPresentationExchangeSubmission;
90
+ };
91
+ readonly redirectUri?: undefined;
92
+ readonly presentationDuringIssuanceSession?: undefined;
93
+ } | {
94
+ readonly ok: true;
95
+ readonly serverResponse: {
96
+ readonly status: number;
97
+ readonly body: Record<string, unknown>;
98
+ };
99
+ readonly authorizationResponse: ({
100
+ vp_token: string | Record<string, any> | Record<string, string | Record<string, any>> | [string | Record<string, any>, ...(string | Record<string, any>)[]];
101
+ presentation_submission?: any;
102
+ access_token?: string | undefined;
103
+ token_type?: string | undefined;
104
+ expires_in?: number | undefined;
105
+ state?: string | undefined;
106
+ refresh_token?: string | undefined;
107
+ id_token?: string | undefined;
108
+ } & {
109
+ [k: string]: unknown;
110
+ } & {
111
+ presentation_submission?: DifPresentationExchangeSubmission;
112
+ }) | {
113
+ response: string;
114
+ };
115
+ readonly authorizationResponsePayload: {
116
+ vp_token: string | Record<string, any> | Record<string, string | Record<string, any>> | [string | Record<string, any>, ...(string | Record<string, any>)[]];
117
+ presentation_submission?: any;
118
+ access_token?: string | undefined;
119
+ token_type?: string | undefined;
120
+ expires_in?: number | undefined;
121
+ state?: string | undefined;
122
+ refresh_token?: string | undefined;
123
+ id_token?: string | undefined;
124
+ } & {
125
+ [k: string]: unknown;
126
+ } & {
127
+ presentation_submission?: DifPresentationExchangeSubmission;
128
+ };
129
+ readonly redirectUri: string | undefined;
130
+ readonly presentationDuringIssuanceSession: string | undefined;
131
+ }>;
132
+ }
@@ -0,0 +1,317 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.OpenId4VpHolderService = void 0;
13
+ const core_1 = require("@credo-ts/core");
14
+ const openid4vp_1 = require("@openid4vc/openid4vp");
15
+ const callbacks_1 = require("../shared/callbacks");
16
+ let OpenId4VpHolderService = class OpenId4VpHolderService {
17
+ constructor(presentationExchangeService, dcqlService) {
18
+ this.presentationExchangeService = presentationExchangeService;
19
+ this.dcqlService = dcqlService;
20
+ }
21
+ getOpenid4vpClient(agentContext, trustedCertificates) {
22
+ const callbacks = (0, callbacks_1.getOid4vcCallbacks)(agentContext, trustedCertificates);
23
+ return new openid4vp_1.Openid4vpClient({ callbacks });
24
+ }
25
+ async handlePresentationExchangeRequest(agentContext, _presentationDefinition, transactionData) {
26
+ const presentationDefinition = _presentationDefinition;
27
+ this.presentationExchangeService.validatePresentationDefinition(presentationDefinition);
28
+ const presentationExchange = {
29
+ definition: presentationDefinition,
30
+ credentialsForRequest: await this.presentationExchangeService.getCredentialsForRequest(agentContext, presentationDefinition),
31
+ };
32
+ const availableCredentialIds = presentationExchange.credentialsForRequest.requirements.flatMap((requirement) => requirement.submissionEntry.map((entry) => entry.inputDescriptorId));
33
+ // for each transaction data entry, get all credentials that can be used to sign the respective transaction
34
+ const matchedTransactionData = transactionData?.map((entry) => ({
35
+ entry,
36
+ matchedCredentialIds: entry.transactionData.credential_ids.filter((credentialId) => availableCredentialIds.includes(credentialId)),
37
+ }));
38
+ return { pex: presentationExchange, matchedTransactionData };
39
+ }
40
+ async handleDcqlRequest(agentContext, dcql, transactionData) {
41
+ const dcqlQuery = this.dcqlService.validateDcqlQuery(dcql);
42
+ const dcqlQueryResult = await this.dcqlService.getCredentialsForRequest(agentContext, dcqlQuery);
43
+ // for each transaction data entry, get all credentials that can be used to sign the respective transaction
44
+ const matchedTransactionData = transactionData?.map((entry) => ({
45
+ entry,
46
+ matchedCredentialIds: entry.transactionData.credential_ids.filter((credentialId) => dcqlQueryResult.credential_matches[credentialId].success),
47
+ }));
48
+ return { dcql: { queryResult: dcqlQueryResult }, matchedTransactionData };
49
+ }
50
+ async resolveAuthorizationRequest(agentContext,
51
+ /**
52
+ * Can be:
53
+ * - JWT
54
+ * - URI containing request or request_uri param
55
+ * - Request payload
56
+ */
57
+ authorizationRequest, options) {
58
+ const openid4vpClient = this.getOpenid4vpClient(agentContext, options?.trustedCertificates);
59
+ const { params } = openid4vpClient.parseOpenid4vpAuthorizationRequest({ authorizationRequest });
60
+ const verifiedAuthorizationRequest = await openid4vpClient.resolveOpenId4vpAuthorizationRequest({
61
+ authorizationRequestPayload: params,
62
+ origin: options?.origin,
63
+ });
64
+ const { client, pex, transactionData, dcql } = verifiedAuthorizationRequest;
65
+ if (client.scheme !== 'x509_san_dns' && client.scheme !== 'did' && client.scheme !== 'web-origin') {
66
+ throw new core_1.CredoError(`Client scheme '${client.scheme}' is not supported`);
67
+ }
68
+ const pexResult = pex?.presentation_definition
69
+ ? await this.handlePresentationExchangeRequest(agentContext, pex.presentation_definition, transactionData)
70
+ : undefined;
71
+ const dcqlResult = dcql?.query ? await this.handleDcqlRequest(agentContext, dcql.query, transactionData) : undefined;
72
+ agentContext.config.logger.debug('verified Authorization Request');
73
+ agentContext.config.logger.debug(`request '${authorizationRequest}'`);
74
+ return {
75
+ authorizationRequestPayload: verifiedAuthorizationRequest.authorizationRequestPayload,
76
+ transactionData: pexResult?.matchedTransactionData ?? dcqlResult?.matchedTransactionData,
77
+ presentationExchange: pexResult?.pex,
78
+ dcql: dcqlResult?.dcql,
79
+ origin: options?.origin,
80
+ };
81
+ }
82
+ extendCredentialsWithTransactionDataHashes(
83
+ // Either PEX or DCQL
84
+ selectedCredentials, transactionData, selectedTransactionDataCredentials) {
85
+ // TODO: it would make sense for oid4vc to also handle this validation logic, but it would require
86
+ // knowledge of PEX / DCQL...
87
+ if (!transactionData && !selectedTransactionDataCredentials)
88
+ return selectedCredentials;
89
+ if (!selectedTransactionDataCredentials) {
90
+ throw new core_1.CredoError('Autohrization request contains transaction data entries, but no credential ids to sign transaction data hashes provided in acceptAuthorizationRequest method.');
91
+ }
92
+ if (!transactionData) {
93
+ throw new core_1.CredoError('Autohrization request doe not contains transaction data entries, but credentail ids were provided to sign transaction data hashes in acceptAuthorizationRequest method.');
94
+ }
95
+ if (transactionData.length !== selectedTransactionDataCredentials.length) {
96
+ throw new core_1.CredoError('Credential ids to sign transaction data hashes provided in acceptAuthorizationRequest method, but the length does not match the number of transaction data entries from the authorization request.');
97
+ }
98
+ const credentialsToTransactionData = {};
99
+ for (const transactionDataIndex in transactionData) {
100
+ const transactionDataEntry = transactionData[transactionDataIndex];
101
+ const { credentialId } = selectedTransactionDataCredentials[transactionDataIndex];
102
+ if (!transactionDataEntry.transactionData.credential_ids.includes(credentialId)) {
103
+ throw new core_1.CredoError(`Credential id '${credentialId}' selected to sign transaction data with index '${transactionDataIndex}' is not present in allowed credential ids for transaction. Allowed credential ids are ${transactionDataEntry.transactionData.credential_ids.join(', ')}`);
104
+ }
105
+ if (!selectedCredentials[credentialId]) {
106
+ throw new core_1.CredoError(`Credential id '${credentialId}' selected to sign transaction data with index '${transactionDataIndex}', but credential is not included in the credentials for the presentation.`);
107
+ }
108
+ // NOTE: in the next releaes of DCQL this will also be an array, so this code can soon be simplified
109
+ const credentialsForId = Array.isArray(selectedCredentials[credentialId])
110
+ ? selectedCredentials[credentialId]
111
+ : [selectedCredentials[credentialId]];
112
+ const unsupportedFormats = credentialsForId
113
+ .filter((c) => c.claimFormat !== core_1.ClaimFormat.SdJwtVc)
114
+ .map((c) => c.claimFormat);
115
+ if (unsupportedFormats.length > 0) {
116
+ throw new core_1.CredoError(`Credential id '${credentialId}' selected to sign transaction data with index '${transactionDataIndex}' unsupported format(s) ${unsupportedFormats.join(', ')}. Only '${core_1.ClaimFormat.SdJwtVc}' is supported for transaction data signing in Credo at the moment.`);
117
+ }
118
+ if (!credentialsToTransactionData[credentialId]) {
119
+ credentialsToTransactionData[credentialId] = [];
120
+ }
121
+ credentialsToTransactionData[credentialId].push(transactionDataEntry);
122
+ }
123
+ const updatedCredentials = {
124
+ ...selectedCredentials,
125
+ };
126
+ for (const [credentialId, entries] of Object.entries(credentialsToTransactionData)) {
127
+ const allowedHashAlgs = entries.reduce((allowedHashValues, entry) => (entry.transactionData.transaction_data_hashes_alg ?? ['sha-256']).filter((value) => !allowedHashValues || allowedHashValues.includes(value)), undefined);
128
+ if (!allowedHashAlgs || allowedHashAlgs.length === 0) {
129
+ throw new core_1.CredoError(`Unable to determine hash alg for credential with id '${credentialId}' and transaction data indexes ${entries.map((e) => e.transactionDataIndex).join(' ')}, no common 'transaction_data_hashes_alg' value found.`);
130
+ }
131
+ const supportedHashAlgs = ['sha-1', 'sha-256'];
132
+ const supportedAllowedHashAlgs = supportedHashAlgs.filter((alg) => allowedHashAlgs.includes(alg));
133
+ if (supportedAllowedHashAlgs.length === 0) {
134
+ throw new core_1.CredoError(`Unable to create transaction data hash for credential with id '${credentialId}' and transaction data indexes ${entries.map((e) => e.transactionDataIndex).join(' ')}. None of the common allowed hash algorithms is supported by Credo: ${allowedHashAlgs.join(', ')}. Supported hash algs are ${supportedHashAlgs.join(', ')}.`);
135
+ }
136
+ // Not required, but we include it by default as otherwise we need to look at all entries to
137
+ // see if any specified an alg array
138
+ const [transactionDataHahsesAlg] = supportedAllowedHashAlgs;
139
+ const transactionDataHashes = entries.map((entry) => core_1.TypedArrayEncoder.toBase64URL(core_1.Hasher.hash(entry.encoded, transactionDataHahsesAlg)));
140
+ const credentialsForId = Array.isArray(updatedCredentials[credentialId])
141
+ ? updatedCredentials[credentialId]
142
+ : [updatedCredentials[credentialId]];
143
+ const updatedCredentialsForId = credentialsForId.map((credential) => {
144
+ if (credential.claimFormat !== core_1.ClaimFormat.SdJwtVc) {
145
+ // We already verified this above
146
+ throw new core_1.CredoError(`Unexpected claim format '${credential.claimFormat}' for transaction data, expected '${core_1.ClaimFormat.SdJwtVc}'`);
147
+ }
148
+ return {
149
+ ...credential,
150
+ additionalPayload: {
151
+ ...(credential.additionalPayload ?? {}),
152
+ transaction_data_hashes: transactionDataHashes,
153
+ transaction_data_hashes_alg: transactionDataHahsesAlg,
154
+ },
155
+ };
156
+ });
157
+ // Will soon be simplified once DCQL also uses array
158
+ updatedCredentials[credentialId] = Array.isArray(updatedCredentials[credentialId])
159
+ ? updatedCredentialsForId
160
+ : updatedCredentialsForId[0];
161
+ }
162
+ return updatedCredentials;
163
+ }
164
+ async acceptAuthorizationRequest(agentContext, options) {
165
+ const { authorizationRequestPayload, presentationExchange, dcql, transactionData } = options;
166
+ const openid4vpClient = this.getOpenid4vpClient(agentContext);
167
+ const authorizationResponseNonce = await agentContext.wallet.generateNonce();
168
+ const { nonce } = authorizationRequestPayload;
169
+ const parsedClientId = (0, openid4vp_1.getOpenid4vpClientId)({ authorizationRequestPayload, origin: options.origin });
170
+ // If client_id_scheme was used we need to use the legacy client id.
171
+ const clientId = parsedClientId.legacyClientId ?? parsedClientId.clientId;
172
+ let openid4vpOptions;
173
+ if ((0, openid4vp_1.isOpenid4vpAuthorizationRequestDcApi)(authorizationRequestPayload)) {
174
+ if (!options.origin) {
175
+ throw new core_1.CredoError('Missing required parameter `origin` parameter for accepting openid4vp dc api requests.');
176
+ }
177
+ openid4vpOptions = { type: 'openId4VpDcApi', clientId, origin: options.origin, verifierGeneratedNonce: nonce };
178
+ }
179
+ else {
180
+ const responseUri = authorizationRequestPayload.response_uri ?? authorizationRequestPayload.redirect_uri;
181
+ if (!responseUri) {
182
+ throw new core_1.CredoError('Missing required parameter `response_uri` or `redirect_uri` in the authorization request.');
183
+ }
184
+ openid4vpOptions = {
185
+ type: 'openId4Vp',
186
+ mdocGeneratedNonce: authorizationResponseNonce,
187
+ responseUri,
188
+ clientId,
189
+ verifierGeneratedNonce: nonce,
190
+ };
191
+ }
192
+ let vpToken;
193
+ let presentationSubmission = undefined;
194
+ const parsedTransactionData = authorizationRequestPayload.transaction_data
195
+ ? (0, openid4vp_1.parseTransactionData)({
196
+ transactionData: authorizationRequestPayload.transaction_data,
197
+ })
198
+ : undefined;
199
+ // Handle presentation exchange part
200
+ if (authorizationRequestPayload.presentation_definition || presentationExchange) {
201
+ if (!presentationExchange) {
202
+ throw new core_1.CredoError('Authorization request included presentation definition. `presentationExchange` MUST be supplied to accept authorization requests.');
203
+ }
204
+ if (!authorizationRequestPayload.presentation_definition) {
205
+ throw new core_1.CredoError('`presentationExchange` was supplied, but no presentation definition was found in the presentation request.');
206
+ }
207
+ const credentialsWithTransactionData = this.extendCredentialsWithTransactionDataHashes(presentationExchange.credentials, parsedTransactionData, transactionData);
208
+ const { presentationSubmission: _presentationSubmission, encodedVerifiablePresentations } = await this.presentationExchangeService.createPresentation(agentContext, {
209
+ credentialsForInputDescriptor: credentialsWithTransactionData,
210
+ presentationDefinition: authorizationRequestPayload.presentation_definition,
211
+ challenge: nonce,
212
+ domain: clientId,
213
+ presentationSubmissionLocation: core_1.DifPresentationExchangeSubmissionLocation.EXTERNAL,
214
+ openid4vp: openid4vpOptions,
215
+ });
216
+ vpToken =
217
+ encodedVerifiablePresentations.length === 1 && _presentationSubmission?.descriptor_map[0]?.path === '$'
218
+ ? encodedVerifiablePresentations[0]
219
+ : encodedVerifiablePresentations;
220
+ presentationSubmission = _presentationSubmission;
221
+ }
222
+ else if (authorizationRequestPayload.dcql_query || dcql) {
223
+ if (!authorizationRequestPayload.dcql_query) {
224
+ throw new core_1.CredoError(`'dcql' was supplied, but no dcql request was found in the presentation request.`);
225
+ }
226
+ if (!dcql) {
227
+ throw new core_1.CredoError(`Authorization request included dcql request. 'dcql' MUST be supplied to accept authorization requests.`);
228
+ }
229
+ const credentialsWithTransactionData = this.extendCredentialsWithTransactionDataHashes(dcql.credentials, parsedTransactionData, transactionData);
230
+ const { encodedDcqlPresentation } = await this.dcqlService.createPresentation(agentContext, {
231
+ credentialQueryToCredential: credentialsWithTransactionData,
232
+ challenge: nonce,
233
+ domain: clientId,
234
+ openid4vp: openid4vpOptions,
235
+ });
236
+ vpToken = encodedDcqlPresentation;
237
+ }
238
+ else {
239
+ throw new core_1.CredoError('Either pex or dcql must be provided');
240
+ }
241
+ const response = await openid4vpClient.createOpenid4vpAuthorizationResponse({
242
+ authorizationRequestPayload,
243
+ authorizationResponsePayload: {
244
+ vp_token: vpToken,
245
+ presentation_submission: presentationSubmission,
246
+ },
247
+ jarm: authorizationRequestPayload.response_mode && (0, openid4vp_1.isJarmResponseMode)(authorizationRequestPayload.response_mode)
248
+ ? {
249
+ encryption: { nonce: authorizationResponseNonce },
250
+ serverMetadata: {
251
+ authorization_signing_alg_values_supported: [],
252
+ authorization_encryption_alg_values_supported: ['ECDH-ES'],
253
+ authorization_encryption_enc_values_supported: ['A128GCM', 'A256GCM', 'A128CBC-HS256'],
254
+ },
255
+ }
256
+ : undefined,
257
+ });
258
+ const authorizationResponsePayload = response.authorizationResponsePayload;
259
+ const authorizationResponse = response.jarm?.responseJwt
260
+ ? { response: response.jarm.responseJwt }
261
+ : authorizationResponsePayload;
262
+ // TODO: we should include more typing here that the user
263
+ // still needs to submit the response. or as we discussed, split
264
+ // this method up in create and submit
265
+ if ((0, openid4vp_1.isOpenid4vpAuthorizationRequestDcApi)(authorizationRequestPayload)) {
266
+ return {
267
+ ok: true,
268
+ authorizationResponse,
269
+ authorizationResponsePayload,
270
+ };
271
+ }
272
+ // TODO: parse response in openi4vp library so we can have typed error
273
+ // as well as typed response (with redirect_uri/presentation_during_issuance_session)
274
+ const result = await openid4vpClient.submitOpenid4vpAuthorizationResponse({
275
+ authorizationRequestPayload,
276
+ authorizationResponsePayload: response.authorizationResponsePayload,
277
+ jarm: response.jarm ? { responseJwt: response.jarm.responseJwt } : undefined,
278
+ });
279
+ const responseText = await result.response
280
+ .clone()
281
+ .text()
282
+ .catch(() => null);
283
+ const responseJson = (await result.response
284
+ .clone()
285
+ .json()
286
+ .catch(() => null));
287
+ if (!result.response.ok) {
288
+ return {
289
+ ok: false,
290
+ serverResponse: {
291
+ status: result.response.status,
292
+ body: responseJson ?? responseText,
293
+ },
294
+ authorizationResponse,
295
+ authorizationResponsePayload,
296
+ };
297
+ }
298
+ return {
299
+ ok: true,
300
+ serverResponse: {
301
+ status: result.response.status,
302
+ body: responseJson ?? {},
303
+ },
304
+ authorizationResponse,
305
+ authorizationResponsePayload,
306
+ redirectUri: responseJson?.redirect_uri,
307
+ presentationDuringIssuanceSession: responseJson?.presentation_during_issuance_session,
308
+ };
309
+ }
310
+ };
311
+ exports.OpenId4VpHolderService = OpenId4VpHolderService;
312
+ exports.OpenId4VpHolderService = OpenId4VpHolderService = __decorate([
313
+ (0, core_1.injectable)(),
314
+ __metadata("design:paramtypes", [core_1.DifPresentationExchangeService,
315
+ core_1.DcqlService])
316
+ ], OpenId4VpHolderService);
317
+ //# sourceMappingURL=OpenId4vpHolderService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpenId4vpHolderService.js","sourceRoot":"","sources":["../../src/openid4vc-holder/OpenId4vpHolderService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAkBA,yCASuB;AACvB,oDAQ6B;AAE7B,mDAAwD;AAGjD,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IACjC,YACU,2BAA2D,EAC3D,WAAwB;QADxB,gCAA2B,GAA3B,2BAA2B,CAAgC;QAC3D,gBAAW,GAAX,WAAW,CAAa;IAC/B,CAAC;IAEI,kBAAkB,CAAC,YAA0B,EAAE,mBAA8C;QACnG,MAAM,SAAS,GAAG,IAAA,8BAAkB,EAAC,YAAY,EAAE,mBAAmB,CAAC,CAAA;QACvE,OAAO,IAAI,2BAAe,CAAC,EAAE,SAAS,EAAE,CAAC,CAAA;IAC3C,CAAC;IAEO,KAAK,CAAC,iCAAiC,CAC7C,YAA0B,EAC1B,uBAAgC,EAChC,eAA8C;QAE9C,MAAM,sBAAsB,GAAG,uBAA4D,CAAA;QAC3F,IAAI,CAAC,2BAA2B,CAAC,8BAA8B,CAAC,sBAAsB,CAAC,CAAA;QAEvF,MAAM,oBAAoB,GAAG;YAC3B,UAAU,EAAE,sBAAsB;YAClC,qBAAqB,EAAE,MAAM,IAAI,CAAC,2BAA2B,CAAC,wBAAwB,CACpF,YAAY,EACZ,sBAAsB,CACvB;SACF,CAAA;QAED,MAAM,sBAAsB,GAAG,oBAAoB,CAAC,qBAAqB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,CAC7G,WAAW,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,CACpE,CAAA;QAED,2GAA2G;QAC3G,MAAM,sBAAsB,GAAG,eAAe,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;Y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,4BAA4B;YACnE,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS;SAC7E,CAAC,CAAA;QAEF,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,QAAQ;aACvC,KAAK,EAAE;aACP,IAAI,EAAE;aACN,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAA;QAEpB,MAAM,YAAY,GAAG,CAAC,MAAM,MAAM,CAAC,QAAQ;aACxC,KAAK,EAAE;aACP,IAAI,EAAE;aACN,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAmC,CAAA;QAEvD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACxB,OAAO;gBACL,EAAE,EAAE,KAAK;gBACT,cAAc,EAAE;oBACd,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM;oBAC9B,IAAI,EAAE,YAAY,IAAI,YAAY;iBACnC;gBACD,qBAAqB;gBACrB,4BAA4B;aACpB,CAAA;QACZ,CAAC;QAED,OAAO;YACL,EAAE,EAAE,IAAI;YACR,cAAc,EAAE;gBACd,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM;gBAC9B,IAAI,EAAE,YAAY,IAAI,EAAE;aACzB;YACD,qBAAqB;YACrB,4BAA4B;YAC5B,WAAW,EAAE,YAAY,EAAE,YAAkC;YAC7D,iCAAiC,EAAE,YAAY,EAAE,oCAA0D;SACnG,CAAA;IACZ,CAAC;CACF,CAAA;AAvaY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,iBAAU,GAAE;qCAG4B,qCAA8B;QAC9C,kBAAW;GAHvB,sBAAsB,CAualC"}
@@ -0,0 +1,81 @@
1
+ import type { DcqlCredentialsForRequest, DcqlQueryResult, DifPexCredentialsForRequest, DifPexInputDescriptorToCredentials, DifPresentationExchangeDefinition, EncodedX509Certificate } from '@credo-ts/core';
2
+ import { ResolvedOpenid4vpAuthorizationRequest } from '@openid4vc/openid4vp';
3
+ import type { OpenId4VpAuthorizationRequestPayload } from '../shared';
4
+ export type ParsedTransactionDataEntry = NonNullable<ResolvedOpenid4vpAuthorizationRequest['transactionData']>[number];
5
+ export interface ResolveOpenId4VpAuthorizationRequestOptions {
6
+ trustedCertificates?: EncodedX509Certificate[];
7
+ origin?: string;
8
+ }
9
+ export interface OpenId4VpResolvedAuthorizationRequest {
10
+ /**
11
+ * Parameters related to DIF Presentation Exchange. Only defined when
12
+ * the request included
13
+ */
14
+ presentationExchange?: {
15
+ definition: DifPresentationExchangeDefinition;
16
+ credentialsForRequest: DifPexCredentialsForRequest;
17
+ };
18
+ dcql?: {
19
+ queryResult: DcqlQueryResult;
20
+ };
21
+ /**
22
+ * The transaction data entries, with the matched credential ids.
23
+ * - For Presentation Exchange the id refers to the presentation exchange id
24
+ * - For DCQL the id refers to the credential query id
25
+ *
26
+ * If no matches were found the `matchedCredentialIds` will be empty and means
27
+ * the presetnation cannot be satisfied.
28
+ *
29
+ * The entries have the same order as the transaction data entries from the request
30
+ */
31
+ transactionData?: Array<{
32
+ entry: ParsedTransactionDataEntry;
33
+ matchedCredentialIds: string[];
34
+ }>;
35
+ /**
36
+ * The authorization request payload
37
+ */
38
+ authorizationRequestPayload: OpenId4VpAuthorizationRequestPayload;
39
+ /**
40
+ * Origin of the request, to be used with Digital Credentials API
41
+ */
42
+ origin?: string;
43
+ }
44
+ export interface OpenId4VpAcceptAuthorizationRequestOptions {
45
+ /**
46
+ * Parameters related to DIF Presentation Exchange. MUST be present when the resolved
47
+ * authorization request included a `presentationExchange` parameter.
48
+ */
49
+ presentationExchange?: {
50
+ credentials: DifPexInputDescriptorToCredentials;
51
+ };
52
+ /**
53
+ * Parameters related to Dcql. MUST be present when the resolved
54
+ * authorization request included a `dcql` parameter.
55
+ */
56
+ dcql?: {
57
+ credentials: DcqlCredentialsForRequest;
58
+ };
59
+ /**
60
+ * The credentials to use for the transaction data hashes in the presentation. The length
61
+ * of the array MUST be the same length as the transaction data entries in the authorization
62
+ * request, and follow the same order (meaning the first entry in this array matches the first
63
+ * entry in the transaction data from the request).
64
+ *
65
+ * - For Presentation Exchange the id refers to the presentation exchange id
66
+ * - For DCQL the id refers to the credential query id
67
+ *
68
+ */
69
+ transactionData?: Array<{
70
+ credentialId: string;
71
+ }>;
72
+ /**
73
+ * The authorization request payload
74
+ */
75
+ authorizationRequestPayload: OpenId4VpAuthorizationRequestPayload;
76
+ /**
77
+ * The origin of the verifier that is making the request.
78
+ * Required in combination with the DC Api
79
+ */
80
+ origin?: string;
81
+ }
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=OpenId4vcSiopHolderServiceOptions.js.map
3
+ //# sourceMappingURL=OpenId4vpHolderServiceOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpenId4vpHolderServiceOptions.js","sourceRoot":"","sources":["../../src/openid4vc-holder/OpenId4vpHolderServiceOptions.ts"],"names":[],"mappings":""}
@@ -2,5 +2,5 @@ export * from './OpenId4VcHolderApi';
2
2
  export * from './OpenId4VcHolderModule';
3
3
  export * from './OpenId4VciHolderService';
4
4
  export * from './OpenId4VciHolderServiceOptions';
5
- export * from './OpenId4vcSiopHolderService';
6
- export * from './OpenId4vcSiopHolderServiceOptions';
5
+ export * from './OpenId4vpHolderService';
6
+ export * from './OpenId4vpHolderServiceOptions';
@@ -18,6 +18,6 @@ __exportStar(require("./OpenId4VcHolderApi"), exports);
18
18
  __exportStar(require("./OpenId4VcHolderModule"), exports);
19
19
  __exportStar(require("./OpenId4VciHolderService"), exports);
20
20
  __exportStar(require("./OpenId4VciHolderServiceOptions"), exports);
21
- __exportStar(require("./OpenId4vcSiopHolderService"), exports);
22
- __exportStar(require("./OpenId4vcSiopHolderServiceOptions"), exports);
21
+ __exportStar(require("./OpenId4vpHolderService"), exports);
22
+ __exportStar(require("./OpenId4vpHolderServiceOptions"), exports);
23
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/openid4vc-holder/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAoC;AACpC,0DAAuC;AACvC,4DAAyC;AACzC,mEAAgD;AAChD,+DAA4C;AAC5C,sEAAmD"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/openid4vc-holder/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAoC;AACpC,0DAAuC;AACvC,4DAAyC;AACzC,mEAAgD;AAChD,2DAAwC;AACxC,kEAA+C"}