@credo-ts/openid4vc 0.6.0-pr-2134-20241217213340 → 0.6.0-pr-2195-20250217170804

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 (85) hide show
  1. package/build/openid4vc-holder/OpenId4VcHolderApi.d.ts +61 -11
  2. package/build/openid4vc-holder/OpenId4VcHolderApi.js +17 -19
  3. package/build/openid4vc-holder/OpenId4VcHolderApi.js.map +1 -1
  4. package/build/openid4vc-holder/OpenId4VcHolderModule.js +1 -1
  5. package/build/openid4vc-holder/OpenId4VcHolderModule.js.map +1 -1
  6. package/build/openid4vc-holder/OpenId4VciHolderService.d.ts +7 -8
  7. package/build/openid4vc-holder/OpenId4VciHolderService.js +60 -45
  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 +1 -1
  11. package/build/openid4vc-holder/OpenId4VciHolderServiceOptions.js.map +1 -1
  12. package/build/openid4vc-holder/OpenId4vcSiopHolderService.d.ts +59 -13
  13. package/build/openid4vc-holder/OpenId4vcSiopHolderService.js +232 -172
  14. package/build/openid4vc-holder/OpenId4vcSiopHolderService.js.map +1 -1
  15. package/build/openid4vc-holder/OpenId4vcSiopHolderServiceOptions.d.ts +18 -1
  16. package/build/openid4vc-issuer/OpenId4VcIssuerApi.d.ts +196 -46
  17. package/build/openid4vc-issuer/OpenId4VcIssuerApi.js +8 -19
  18. package/build/openid4vc-issuer/OpenId4VcIssuerApi.js.map +1 -1
  19. package/build/openid4vc-issuer/OpenId4VcIssuerModule.js +3 -3
  20. package/build/openid4vc-issuer/OpenId4VcIssuerModule.js.map +1 -1
  21. package/build/openid4vc-issuer/OpenId4VcIssuerModuleConfig.d.ts +13 -13
  22. package/build/openid4vc-issuer/OpenId4VcIssuerModuleConfig.js +19 -40
  23. package/build/openid4vc-issuer/OpenId4VcIssuerModuleConfig.js.map +1 -1
  24. package/build/openid4vc-issuer/OpenId4VcIssuerService.d.ts +198 -48
  25. package/build/openid4vc-issuer/OpenId4VcIssuerService.js +45 -37
  26. package/build/openid4vc-issuer/OpenId4VcIssuerService.js.map +1 -1
  27. package/build/openid4vc-issuer/OpenId4VcIssuerServiceOptions.d.ts +8 -3
  28. package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRecord.d.ts +1 -1
  29. package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRecord.js +26 -12
  30. package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRecord.js.map +1 -1
  31. package/build/openid4vc-issuer/repository/OpenId4VcIssuerRecord.js +19 -22
  32. package/build/openid4vc-issuer/repository/OpenId4VcIssuerRecord.js.map +1 -1
  33. package/build/openid4vc-issuer/router/accessTokenEndpoint.js +11 -9
  34. package/build/openid4vc-issuer/router/accessTokenEndpoint.js.map +1 -1
  35. package/build/openid4vc-issuer/router/authorizationChallengeEndpoint.js +17 -6
  36. package/build/openid4vc-issuer/router/authorizationChallengeEndpoint.js.map +1 -1
  37. package/build/openid4vc-issuer/router/authorizationServerMetadataEndpoint.js +1 -1
  38. package/build/openid4vc-issuer/router/authorizationServerMetadataEndpoint.js.map +1 -1
  39. package/build/openid4vc-issuer/router/credentialEndpoint.js +11 -9
  40. package/build/openid4vc-issuer/router/credentialEndpoint.js.map +1 -1
  41. package/build/openid4vc-issuer/router/issuerMetadataEndpoint.js +7 -3
  42. package/build/openid4vc-issuer/router/issuerMetadataEndpoint.js.map +1 -1
  43. package/build/openid4vc-issuer/util/txCode.js +2 -3
  44. package/build/openid4vc-issuer/util/txCode.js.map +1 -1
  45. package/build/openid4vc-verifier/OpenId4VcSiopVerifierService.d.ts +21 -7
  46. package/build/openid4vc-verifier/OpenId4VcSiopVerifierService.js +499 -263
  47. package/build/openid4vc-verifier/OpenId4VcSiopVerifierService.js.map +1 -1
  48. package/build/openid4vc-verifier/OpenId4VcSiopVerifierServiceOptions.d.ts +23 -3
  49. package/build/openid4vc-verifier/OpenId4VcVerifierApi.d.ts +3 -3
  50. package/build/openid4vc-verifier/OpenId4VcVerifierApi.js +11 -18
  51. package/build/openid4vc-verifier/OpenId4VcVerifierApi.js.map +1 -1
  52. package/build/openid4vc-verifier/OpenId4VcVerifierModule.js +3 -3
  53. package/build/openid4vc-verifier/OpenId4VcVerifierModule.js.map +1 -1
  54. package/build/openid4vc-verifier/OpenId4VcVerifierModuleConfig.js +11 -8
  55. package/build/openid4vc-verifier/OpenId4VcVerifierModuleConfig.js.map +1 -1
  56. package/build/openid4vc-verifier/repository/OpenId4VcRelyingPartyEventEmitter.d.ts +23 -4
  57. package/build/openid4vc-verifier/repository/OpenId4VcRelyingPartyEventEmitter.js +25 -29
  58. package/build/openid4vc-verifier/repository/OpenId4VcRelyingPartyEventEmitter.js.map +1 -1
  59. package/build/openid4vc-verifier/repository/OpenId4VcRelyingPartySessionManager.js +4 -6
  60. package/build/openid4vc-verifier/repository/OpenId4VcRelyingPartySessionManager.js.map +1 -1
  61. package/build/openid4vc-verifier/repository/OpenId4VcVerificationSessionRecord.js +11 -6
  62. package/build/openid4vc-verifier/repository/OpenId4VcVerificationSessionRecord.js.map +1 -1
  63. package/build/openid4vc-verifier/repository/OpenId4VcVerifierRecord.js +7 -5
  64. package/build/openid4vc-verifier/repository/OpenId4VcVerifierRecord.js.map +1 -1
  65. package/build/openid4vc-verifier/router/authorizationEndpoint.js +5 -104
  66. package/build/openid4vc-verifier/router/authorizationEndpoint.js.map +1 -1
  67. package/build/shared/callbacks.d.ts +16 -5
  68. package/build/shared/callbacks.js +120 -24
  69. package/build/shared/callbacks.js.map +1 -1
  70. package/build/shared/issuerMetadataUtils.d.ts +102 -144
  71. package/build/shared/models/index.d.ts +10 -8
  72. package/build/shared/models/index.js +5 -5
  73. package/build/shared/models/index.js.map +1 -1
  74. package/build/shared/router/context.d.ts +2 -2
  75. package/build/shared/router/context.js +5 -5
  76. package/build/shared/router/context.js.map +1 -1
  77. package/build/shared/router/tenants.js +1 -2
  78. package/build/shared/router/tenants.js.map +1 -1
  79. package/build/shared/utils.d.ts +6 -6
  80. package/build/shared/utils.js +22 -61
  81. package/build/shared/utils.js.map +1 -1
  82. package/package.json +7 -6
  83. package/build/shared/transform.d.ts +0 -5
  84. package/build/shared/transform.js +0 -73
  85. package/build/shared/transform.js.map +0 -1
@@ -1,6 +1,6 @@
1
- import type { OpenId4VciResolvedCredentialOffer, OpenId4VciAuthCodeFlowOptions, OpenId4VciTokenRequestOptions as OpenId4VciRequestTokenOptions, OpenId4VciCredentialRequestOptions as OpenId4VciRequestCredentialOptions, OpenId4VciSendNotificationOptions, OpenId4VciRequestTokenResponse, OpenId4VciRetrieveAuthorizationCodeUsingPresentationOptions } from './OpenId4VciHolderServiceOptions';
1
+ import type { OpenId4VciAuthCodeFlowOptions, OpenId4VciCredentialRequestOptions as OpenId4VciRequestCredentialOptions, OpenId4VciTokenRequestOptions as OpenId4VciRequestTokenOptions, OpenId4VciRequestTokenResponse, OpenId4VciResolvedCredentialOffer, OpenId4VciRetrieveAuthorizationCodeUsingPresentationOptions, OpenId4VciSendNotificationOptions } from './OpenId4VciHolderServiceOptions';
2
2
  import type { OpenId4VcSiopAcceptAuthorizationRequestOptions } from './OpenId4vcSiopHolderServiceOptions';
3
- import { AgentContext, DifPresentationExchangeService, DifPexCredentialsForRequest } from '@credo-ts/core';
3
+ import { AgentContext, DcqlQueryResult, DcqlService, DifPexCredentialsForRequest, DifPresentationExchangeService, TransactionDataRequest } from '@credo-ts/core';
4
4
  import { OpenId4VciMetadata } from '../shared';
5
5
  import { OpenId4VciHolderService } from './OpenId4VciHolderService';
6
6
  import { OpenId4VcSiopHolderService } from './OpenId4vcSiopHolderService';
@@ -12,7 +12,8 @@ export declare class OpenId4VcHolderApi {
12
12
  private openId4VciHolderService;
13
13
  private openId4VcSiopHolderService;
14
14
  private difPresentationExchangeService;
15
- constructor(agentContext: AgentContext, openId4VciHolderService: OpenId4VciHolderService, openId4VcSiopHolderService: OpenId4VcSiopHolderService, difPresentationExchangeService: DifPresentationExchangeService);
15
+ private dcqlService;
16
+ constructor(agentContext: AgentContext, openId4VciHolderService: OpenId4VciHolderService, openId4VcSiopHolderService: OpenId4VcSiopHolderService, difPresentationExchangeService: DifPresentationExchangeService, dcqlService: DcqlService);
16
17
  /**
17
18
  * Resolves the authentication request given as URI or JWT to a unified format, and
18
19
  * verifies the validity of the request.
@@ -27,7 +28,7 @@ export declare class OpenId4VcHolderApi {
27
28
  * @param requestJwtOrUri JWT or an SIOPv2 request URI
28
29
  * @returns the resolved and verified authentication request.
29
30
  */
30
- resolveSiopAuthorizationRequest(requestJwtOrUri: string): Promise<import("./OpenId4vcSiopHolderServiceOptions").OpenId4VcSiopResolvedAuthorizationRequest>;
31
+ resolveSiopAuthorizationRequest(requestJwtOrUri: string, origin?: string): Promise<import("./OpenId4vcSiopHolderServiceOptions").OpenId4VcSiopResolvedAuthorizationRequest>;
31
32
  /**
32
33
  * Accepts the authentication request after it has been resolved and verified with {@link resolveSiopAuthorizationRequest}.
33
34
  *
@@ -39,27 +40,76 @@ export declare class OpenId4VcHolderApi {
39
40
  acceptSiopAuthorizationRequest(options: OpenId4VcSiopAcceptAuthorizationRequestOptions): Promise<{
40
41
  readonly ok: false;
41
42
  readonly serverResponse: {
42
- readonly status: number;
43
- readonly body: string | Record<string, unknown> | null;
43
+ readonly status: any;
44
+ readonly body: any;
45
+ };
46
+ readonly submittedResponse: (import("zod").objectOutputType<{
47
+ state: import("zod").ZodOptional<import("zod").ZodString>;
48
+ id_token: import("zod").ZodOptional<import("zod").ZodString>;
49
+ vp_token: import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString, "many">, import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>]>;
50
+ presentation_submission: import("zod").ZodOptional<import("zod").ZodUnknown>;
51
+ refresh_token: import("zod").ZodOptional<import("zod").ZodString>;
52
+ token_type: import("zod").ZodOptional<import("zod").ZodString>;
53
+ access_token: import("zod").ZodOptional<import("zod").ZodString>;
54
+ expires_in: import("zod").ZodOptional<import("zod").ZodNumber>;
55
+ }, import("zod").ZodTypeAny, "passthrough"> | ({
56
+ vp_token: string | string[] | Record<string, unknown>;
57
+ presentation_submission?: unknown;
58
+ access_token?: string | undefined;
59
+ token_type?: string | undefined;
60
+ expires_in?: number | undefined;
61
+ state?: string | undefined;
62
+ refresh_token?: string | undefined;
63
+ id_token?: string | undefined;
64
+ } & {
65
+ [k: string]: unknown;
66
+ })) & {
67
+ presentation_submission?: import("@credo-ts/core").DifPresentationExchangeSubmission;
44
68
  };
45
- readonly submittedResponse: import("@sphereon/did-auth-siop").AuthorizationResponsePayload;
46
69
  readonly redirectUri?: undefined;
47
70
  readonly presentationDuringIssuanceSession?: undefined;
48
71
  } | {
49
72
  readonly ok: true;
50
73
  readonly serverResponse: {
51
- readonly status: number;
74
+ readonly status: any;
52
75
  readonly body: Record<string, unknown>;
53
76
  };
54
- readonly submittedResponse: import("@sphereon/did-auth-siop").AuthorizationResponsePayload;
77
+ readonly submittedResponse: (import("zod").objectOutputType<{
78
+ state: import("zod").ZodOptional<import("zod").ZodString>;
79
+ id_token: import("zod").ZodOptional<import("zod").ZodString>;
80
+ vp_token: import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString, "many">, import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>]>;
81
+ presentation_submission: import("zod").ZodOptional<import("zod").ZodUnknown>;
82
+ refresh_token: import("zod").ZodOptional<import("zod").ZodString>;
83
+ token_type: import("zod").ZodOptional<import("zod").ZodString>;
84
+ access_token: import("zod").ZodOptional<import("zod").ZodString>;
85
+ expires_in: import("zod").ZodOptional<import("zod").ZodNumber>;
86
+ }, import("zod").ZodTypeAny, "passthrough"> | ({
87
+ vp_token: string | string[] | Record<string, unknown>;
88
+ presentation_submission?: unknown;
89
+ access_token?: string | undefined;
90
+ token_type?: string | undefined;
91
+ expires_in?: number | undefined;
92
+ state?: string | undefined;
93
+ refresh_token?: string | undefined;
94
+ id_token?: string | undefined;
95
+ } & {
96
+ [k: string]: unknown;
97
+ })) & {
98
+ presentation_submission?: import("@credo-ts/core").DifPresentationExchangeSubmission;
99
+ };
55
100
  readonly redirectUri: string | undefined;
56
101
  readonly presentationDuringIssuanceSession: string | undefined;
57
102
  }>;
58
103
  /**
59
- * Automatically select credentials from available credentials for a request. Can be called after calling
104
+ * Automatically select credentials from available credentials for a presentation exchange request. Can be called after calling
105
+ * @see resolveSiopAuthorizationRequest.
106
+ */
107
+ selectCredentialsForPresentationExchangeRequest(credentialsForRequest: DifPexCredentialsForRequest, transactionData?: TransactionDataRequest): import("@credo-ts/core").DifPexInputDescriptorToCredentials;
108
+ /**
109
+ * Automatically select credentials from available credentials for a dcql request. Can be called after calling
60
110
  * @see resolveSiopAuthorizationRequest.
61
111
  */
62
- selectCredentialsForRequest(credentialsForRequest: DifPexCredentialsForRequest): import("@credo-ts/core").DifPexInputDescriptorToCredentials;
112
+ selectCredentialsForDcqlRequest(dcqlQueryResult: DcqlQueryResult): import("@credo-ts/core").DcqlCredentialsForRequest;
63
113
  resolveIssuerMetadata(credentialIssuer: string): Promise<OpenId4VciMetadata>;
64
114
  /**
65
115
  * Resolves a credential offer given as credential offer URL, or issuance initiation URL,
@@ -8,17 +8,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
8
8
  var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
- var __rest = (this && this.__rest) || function (s, e) {
12
- var t = {};
13
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
- t[p] = s[p];
15
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
- t[p[i]] = s[p[i]];
19
- }
20
- return t;
21
- };
22
11
  Object.defineProperty(exports, "__esModule", { value: true });
23
12
  exports.OpenId4VcHolderApi = void 0;
24
13
  const core_1 = require("@credo-ts/core");
@@ -28,11 +17,12 @@ const OpenId4vcSiopHolderService_1 = require("./OpenId4vcSiopHolderService");
28
17
  * @public
29
18
  */
30
19
  let OpenId4VcHolderApi = class OpenId4VcHolderApi {
31
- constructor(agentContext, openId4VciHolderService, openId4VcSiopHolderService, difPresentationExchangeService) {
20
+ constructor(agentContext, openId4VciHolderService, openId4VcSiopHolderService, difPresentationExchangeService, dcqlService) {
32
21
  this.agentContext = agentContext;
33
22
  this.openId4VciHolderService = openId4VciHolderService;
34
23
  this.openId4VcSiopHolderService = openId4VcSiopHolderService;
35
24
  this.difPresentationExchangeService = difPresentationExchangeService;
25
+ this.dcqlService = dcqlService;
36
26
  }
37
27
  /**
38
28
  * Resolves the authentication request given as URI or JWT to a unified format, and
@@ -48,8 +38,8 @@ let OpenId4VcHolderApi = class OpenId4VcHolderApi {
48
38
  * @param requestJwtOrUri JWT or an SIOPv2 request URI
49
39
  * @returns the resolved and verified authentication request.
50
40
  */
51
- async resolveSiopAuthorizationRequest(requestJwtOrUri) {
52
- return this.openId4VcSiopHolderService.resolveAuthorizationRequest(this.agentContext, requestJwtOrUri);
41
+ async resolveSiopAuthorizationRequest(requestJwtOrUri, origin) {
42
+ return this.openId4VcSiopHolderService.resolveAuthorizationRequest(this.agentContext, requestJwtOrUri, undefined, origin);
53
43
  }
54
44
  /**
55
45
  * Accepts the authentication request after it has been resolved and verified with {@link resolveSiopAuthorizationRequest}.
@@ -63,11 +53,18 @@ let OpenId4VcHolderApi = class OpenId4VcHolderApi {
63
53
  return await this.openId4VcSiopHolderService.acceptAuthorizationRequest(this.agentContext, options);
64
54
  }
65
55
  /**
66
- * Automatically select credentials from available credentials for a request. Can be called after calling
56
+ * Automatically select credentials from available credentials for a presentation exchange request. Can be called after calling
57
+ * @see resolveSiopAuthorizationRequest.
58
+ */
59
+ selectCredentialsForPresentationExchangeRequest(credentialsForRequest, transactionData) {
60
+ return this.difPresentationExchangeService.selectCredentialsForRequest(credentialsForRequest, transactionData);
61
+ }
62
+ /**
63
+ * Automatically select credentials from available credentials for a dcql request. Can be called after calling
67
64
  * @see resolveSiopAuthorizationRequest.
68
65
  */
69
- selectCredentialsForRequest(credentialsForRequest) {
70
- return this.difPresentationExchangeService.selectCredentialsForRequest(credentialsForRequest);
66
+ selectCredentialsForDcqlRequest(dcqlQueryResult) {
67
+ return this.dcqlService.selectCredentialsForRequest(dcqlQueryResult);
71
68
  }
72
69
  async resolveIssuerMetadata(credentialIssuer) {
73
70
  return await this.openId4VciHolderService.resolveIssuerMetadata(this.agentContext, credentialIssuer);
@@ -132,7 +129,7 @@ let OpenId4VcHolderApi = class OpenId4VcHolderApi {
132
129
  * Can be used with both the pre-authorized code flow and the authorization code flow.
133
130
  */
134
131
  async requestCredentials(options) {
135
- const { resolvedCredentialOffer, cNonce, accessToken, dpop, clientId } = options, credentialRequestOptions = __rest(options, ["resolvedCredentialOffer", "cNonce", "accessToken", "dpop", "clientId"]);
132
+ const { resolvedCredentialOffer, cNonce, accessToken, dpop, clientId, ...credentialRequestOptions } = options;
136
133
  return this.openId4VciHolderService.acceptCredentialOffer(this.agentContext, {
137
134
  resolvedCredentialOffer,
138
135
  acceptCredentialOfferOptions: credentialRequestOptions,
@@ -155,6 +152,7 @@ exports.OpenId4VcHolderApi = OpenId4VcHolderApi = __decorate([
155
152
  __metadata("design:paramtypes", [core_1.AgentContext,
156
153
  OpenId4VciHolderService_1.OpenId4VciHolderService,
157
154
  OpenId4vcSiopHolderService_1.OpenId4VcSiopHolderService,
158
- core_1.DifPresentationExchangeService])
155
+ core_1.DifPresentationExchangeService,
156
+ core_1.DcqlService])
159
157
  ], OpenId4VcHolderApi);
160
158
  //# sourceMappingURL=OpenId4VcHolderApi.js.map
@@ -1 +1 @@
1
- {"version":3,"file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AE,IAAI,EAAE,QAAQ,EAAE,GAAG,wBAAwB,EAAE,GAAG,OAAO,CAAA;QAE7G,OAAO,IAAI,CAAC,uBAAuB,CAAC,qBAAqB,CAAC,IAAI,CAAC,YAAY,EAAE;YAC3E,uBAAuB;YACvB,4BAA4B,EAAE,wBAAwB;YACtD,WAAW;YACX,MAAM;YACN,IAAI;YACJ,QAAQ;SACT,CAAC,CAAA;IACJ,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,gBAAgB,CAAC,OAA0C;QACtE,OAAO,IAAI,CAAC,uBAAuB,CAAC,gBAAgB,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;IAClF,CAAC;CACF,CAAA;AA7JY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,iBAAU,GAAE;qCAGa,mBAAY;QACD,iDAAuB;QACpB,uDAA0B;QACtB,qCAA8B;QACjD,kBAAW;GANvB,kBAAkB,CA6J9B"}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OpenId4VcHolderModule = void 0;
4
- const oauth2_1 = require("@animo-id/oauth2");
4
+ const oauth2_1 = require("@openid4vc/oauth2");
5
5
  const core_1 = require("@credo-ts/core");
6
6
  const OpenId4VcHolderApi_1 = require("./OpenId4VcHolderApi");
7
7
  const OpenId4VciHolderService_1 = require("./OpenId4VciHolderService");
@@ -1 +1 @@
1
- {"version":3,"file":"OpenId4VcHolderModule.js","sourceRoot":"","sources":["../../src/openid4vc-holder/OpenId4VcHolderModule.ts"],"names":[],"mappings":";;;AAEA,6CAAkD;AAClD,yCAA4C;AAE5C,6DAAyD;AACzD,uEAAmE;AACnE,6EAAyE;AAEzE;;;GAGG;AACH,MAAa,qBAAqB;IAAlC;QACkB,QAAG,GAAG,uCAAkB,CAAA;IAuB1C,CAAC;IArBC;;OAEG;IACI,QAAQ,CAAC,iBAAoC;QAClD,MAAM,WAAW,GAAG,iBAAiB,CAAC,OAAO,CAAC,kBAAW,CAAC,CAAA;QAE1D,iCAAiC;QACjC,WAAW,CAAC,MAAM,CAAC,IAAI,CACrB,0LAA0L,CAC3L,CAAA;QAED,IAAI,WAAW,CAAC,qBAAqB,EAAE,CAAC;YACtC,IAAA,wBAAe,EAAC;gBACd,iBAAiB,EAAE,IAAI;aACxB,CAAC,CAAA;QACJ,CAAC;QAED,WAAW;QACX,iBAAiB,CAAC,iBAAiB,CAAC,iDAAuB,CAAC,CAAA;QAC5D,iBAAiB,CAAC,iBAAiB,CAAC,uDAA0B,CAAC,CAAA;IACjE,CAAC;CACF;AAxBD,sDAwBC"}
1
+ {"version":3,"file":"OpenId4VcHolderModule.js","sourceRoot":"","sources":["../../src/openid4vc-holder/OpenId4VcHolderModule.ts"],"names":[],"mappings":";;;AAEA,8CAAmD;AACnD,yCAA4C;AAE5C,6DAAyD;AACzD,uEAAmE;AACnE,6EAAyE;AAEzE;;;GAGG;AACH,MAAa,qBAAqB;IAAlC;QACkB,QAAG,GAAG,uCAAkB,CAAA;IAuB1C,CAAC;IArBC;;OAEG;IACI,QAAQ,CAAC,iBAAoC;QAClD,MAAM,WAAW,GAAG,iBAAiB,CAAC,OAAO,CAAC,kBAAW,CAAC,CAAA;QAE1D,iCAAiC;QACjC,WAAW,CAAC,MAAM,CAAC,IAAI,CACrB,0LAA0L,CAC3L,CAAA;QAED,IAAI,WAAW,CAAC,qBAAqB,EAAE,CAAC;YACtC,IAAA,wBAAe,EAAC;gBACd,iBAAiB,EAAE,IAAI;aACxB,CAAC,CAAA;QACJ,CAAC;QAED,WAAW;QACX,iBAAiB,CAAC,iBAAiB,CAAC,iDAAuB,CAAC,CAAA;QAC5D,iBAAiB,CAAC,iBAAiB,CAAC,uDAA0B,CAAC,CAAA;IACjE,CAAC;CACF;AAxBD,sDAwBC"}
@@ -1,13 +1,12 @@
1
- import type { OpenId4VciAcceptCredentialOfferOptions, OpenId4VciAuthCodeFlowOptions, OpenId4VciCredentialResponse, OpenId4VciDpopRequestOptions, OpenId4VciNotificationEvent, OpenId4VciResolvedAuthorizationRequest, OpenId4VciResolvedCredentialOffer, OpenId4VciRetrieveAuthorizationCodeUsingPresentationOptions, OpenId4VciTokenRequestOptions } from './OpenId4VciHolderServiceOptions';
2
- import type { OpenId4VciMetadata } from '../shared';
3
1
  import type { AgentContext, JwaSignatureAlgorithm } from '@credo-ts/core';
4
- import { IssuerMetadataResult } from '@animo-id/oid4vci';
5
- import { Jwk, JwsService, Logger, W3cCredentialService } from '@credo-ts/core';
2
+ import type { OpenId4VciMetadata } from '../shared';
3
+ import type { OpenId4VciAcceptCredentialOfferOptions, OpenId4VciAuthCodeFlowOptions, OpenId4VciCredentialResponse, OpenId4VciDpopRequestOptions, OpenId4VciNotificationEvent, OpenId4VciResolvedAuthorizationRequest, OpenId4VciResolvedCredentialOffer, OpenId4VciRetrieveAuthorizationCodeUsingPresentationOptions, OpenId4VciTokenRequestOptions } from './OpenId4VciHolderServiceOptions';
4
+ import { IssuerMetadataResult } from '@openid4vc/oid4vci';
5
+ import { Jwk, Logger, W3cCredentialService } from '@credo-ts/core';
6
6
  export declare class OpenId4VciHolderService {
7
7
  private logger;
8
8
  private w3cCredentialService;
9
- private jwsService;
10
- constructor(logger: Logger, w3cCredentialService: W3cCredentialService, jwsService: JwsService);
9
+ constructor(logger: Logger, w3cCredentialService: W3cCredentialService);
11
10
  resolveIssuerMetadata(agentContext: AgentContext, credentialIssuer: string): Promise<OpenId4VciMetadata>;
12
11
  resolveCredentialOffer(agentContext: AgentContext, credentialOffer: string): Promise<OpenId4VciResolvedCredentialOffer>;
13
12
  resolveAuthorizationRequest(agentContext: AgentContext, resolvedCredentialOffer: OpenId4VciResolvedCredentialOffer, authCodeFlowOptions: OpenId4VciAuthCodeFlowOptions): Promise<OpenId4VciResolvedAuthorizationRequest>;
@@ -31,10 +30,10 @@ export declare class OpenId4VciHolderService {
31
30
  alg: JwaSignatureAlgorithm;
32
31
  jwk: Jwk;
33
32
  nonce?: string;
34
- signer?: import("@animo-id/oauth2").JwtSignerJwk | undefined;
33
+ signer?: import("@openid4vc/oauth2").JwtSignerJwk | undefined;
35
34
  } | undefined;
36
35
  authorizationServer: string;
37
- accessTokenResponse: import("@animo-id/oauth2").AccessTokenResponse;
36
+ accessTokenResponse: import("@openid4vc/oauth2").AccessTokenResponse;
38
37
  }>;
39
38
  acceptCredentialOffer(agentContext: AgentContext, options: {
40
39
  resolvedCredentialOffer: OpenId4VciResolvedCredentialOffer;
@@ -13,8 +13,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.OpenId4VciHolderService = void 0;
16
- const oauth2_1 = require("@animo-id/oauth2");
17
- const oid4vci_1 = require("@animo-id/oid4vci");
16
+ const oauth2_1 = require("@openid4vc/oauth2");
17
+ const oid4vci_1 = require("@openid4vc/oid4vci");
18
18
  const core_1 = require("@credo-ts/core");
19
19
  const shared_1 = require("../shared");
20
20
  const callbacks_1 = require("../shared/callbacks");
@@ -22,9 +22,8 @@ const issuerMetadataUtils_1 = require("../shared/issuerMetadataUtils");
22
22
  const utils_1 = require("../shared/utils");
23
23
  const OpenId4VciHolderServiceOptions_1 = require("./OpenId4VciHolderServiceOptions");
24
24
  let OpenId4VciHolderService = class OpenId4VciHolderService {
25
- constructor(logger, w3cCredentialService, jwsService) {
25
+ constructor(logger, w3cCredentialService) {
26
26
  this.w3cCredentialService = w3cCredentialService;
27
- this.jwsService = jwsService;
28
27
  this.logger = logger;
29
28
  }
30
29
  async resolveIssuerMetadata(agentContext, credentialIssuer) {
@@ -48,12 +47,11 @@ let OpenId4VciHolderService = class OpenId4VciHolderService {
48
47
  };
49
48
  }
50
49
  async resolveAuthorizationRequest(agentContext, resolvedCredentialOffer, authCodeFlowOptions) {
51
- var _a, _b;
52
50
  const { clientId, redirectUri } = authCodeFlowOptions;
53
51
  const { metadata, credentialOfferPayload, offeredCredentialConfigurations } = resolvedCredentialOffer;
54
52
  const client = this.getClient(agentContext);
55
53
  // If scope is not provided, we request scope for all offered credentials
56
- const scope = (_a = authCodeFlowOptions.scope) !== null && _a !== void 0 ? _a : (0, issuerMetadataUtils_1.getScopesFromCredentialConfigurationsSupported)(offeredCredentialConfigurations);
54
+ const scope = authCodeFlowOptions.scope ?? (0, issuerMetadataUtils_1.getScopesFromCredentialConfigurationsSupported)(offeredCredentialConfigurations);
57
55
  const authorizationResult = await client.initiateAuthorization({
58
56
  clientId,
59
57
  issuerMetadata: metadata,
@@ -71,7 +69,7 @@ let OpenId4VciHolderService = class OpenId4VciHolderService {
71
69
  // Normal Oauth2Redirect flow
72
70
  return {
73
71
  authorizationFlow: oid4vci_1.AuthorizationFlow.Oauth2Redirect,
74
- codeVerifier: (_b = authorizationResult.pkce) === null || _b === void 0 ? void 0 : _b.codeVerifier,
72
+ codeVerifier: authorizationResult.pkce?.codeVerifier,
75
73
  authorizationRequestUrl: authorizationResult.authorizationRequestUrl,
76
74
  };
77
75
  }
@@ -80,7 +78,10 @@ let OpenId4VciHolderService = class OpenId4VciHolderService {
80
78
  await client.sendNotification({
81
79
  accessToken: options.accessToken,
82
80
  dpop: options.dpop
83
- ? await this.getDpopOptions(agentContext, Object.assign(Object.assign({}, options.dpop), { dpopSigningAlgValuesSupported: [options.dpop.alg] }))
81
+ ? await this.getDpopOptions(agentContext, {
82
+ ...options.dpop,
83
+ dpopSigningAlgValuesSupported: [options.dpop.alg],
84
+ })
84
85
  : undefined,
85
86
  issuerMetadata: options.metadata,
86
87
  notification: {
@@ -141,14 +142,13 @@ let OpenId4VciHolderService = class OpenId4VciHolderService {
141
142
  };
142
143
  }
143
144
  async requestAccessToken(agentContext, options) {
144
- var _a, _b, _c, _d;
145
145
  const { metadata, credentialOfferPayload } = options.resolvedCredentialOffer;
146
146
  const client = this.getClient(agentContext);
147
147
  const oauth2Client = this.getOauth2Client(agentContext);
148
148
  const authorizationServer = options.code
149
- ? (_b = (_a = credentialOfferPayload.grants) === null || _a === void 0 ? void 0 : _a.authorization_code) === null || _b === void 0 ? void 0 : _b.authorization_server
150
- : (_d = (_c = credentialOfferPayload.grants) === null || _c === void 0 ? void 0 : _c[oauth2_1.preAuthorizedCodeGrantIdentifier]) === null || _d === void 0 ? void 0 : _d.authorization_server;
151
- const authorizationServerMetadata = (0, oauth2_1.getAuthorizationServerMetadataFromList)(metadata.authorizationServers, authorizationServer !== null && authorizationServer !== void 0 ? authorizationServer : metadata.authorizationServers[0].issuer);
149
+ ? credentialOfferPayload.grants?.authorization_code?.authorization_server
150
+ : credentialOfferPayload.grants?.[oauth2_1.preAuthorizedCodeGrantIdentifier]?.authorization_server;
151
+ const authorizationServerMetadata = (0, oauth2_1.getAuthorizationServerMetadataFromList)(metadata.authorizationServers, authorizationServer ?? metadata.authorizationServers[0].issuer);
152
152
  // TODO: should allow dpop input parameter for if it was already bound earlier
153
153
  const isDpopSupported = oauth2Client.isDpopSupported({
154
154
  authorizationServerMetadata,
@@ -178,16 +178,23 @@ let OpenId4VciHolderService = class OpenId4VciHolderService {
178
178
  dpop,
179
179
  txCode: options.txCode,
180
180
  });
181
- return Object.assign(Object.assign({}, result), { dpop: dpop
182
- ? Object.assign(Object.assign({}, result.dpop), { alg: dpop.signer.alg, jwk: (0, core_1.getJwkFromJson)(dpop.signer.publicJwk) }) : undefined });
181
+ return {
182
+ ...result,
183
+ dpop: dpop
184
+ ? {
185
+ ...result.dpop,
186
+ alg: dpop.signer.alg,
187
+ jwk: (0, core_1.getJwkFromJson)(dpop.signer.publicJwk),
188
+ }
189
+ : undefined,
190
+ };
183
191
  }
184
192
  async acceptCredentialOffer(agentContext, options) {
185
- var _a, _b, _c, _d;
186
193
  const { resolvedCredentialOffer, acceptCredentialOfferOptions } = options;
187
194
  const { metadata, offeredCredentialConfigurations } = resolvedCredentialOffer;
188
195
  const { credentialConfigurationIds, credentialBindingResolver, verifyCredentialStatus, requestBatch } = acceptCredentialOfferOptions;
189
196
  const client = this.getClient(agentContext);
190
- if ((credentialConfigurationIds === null || credentialConfigurationIds === void 0 ? void 0 : credentialConfigurationIds.length) === 0) {
197
+ if (credentialConfigurationIds?.length === 0) {
191
198
  throw new core_1.CredoError(`'credentialConfigurationIds' may not be empty`);
192
199
  }
193
200
  const supportedJwaSignatureAlgorithms = (0, utils_1.getSupportedJwaSignatureAlgorithms)(agentContext);
@@ -199,19 +206,19 @@ let OpenId4VciHolderService = class OpenId4VciHolderService {
199
206
  throw new core_1.CredoError([
200
207
  `No possible proof of possession signature algorithm found.`,
201
208
  `Signature algorithms supported by the Agent '${supportedJwaSignatureAlgorithms.join(', ')}'`,
202
- `Allowed Signature algorithms '${allowedProofOfPossessionSigAlgs === null || allowedProofOfPossessionSigAlgs === void 0 ? void 0 : allowedProofOfPossessionSigAlgs.join(', ')}'`,
209
+ `Allowed Signature algorithms '${allowedProofOfPossessionSigAlgs?.join(', ')}'`,
203
210
  ].join('\n'));
204
211
  }
205
212
  const receivedCredentials = [];
206
213
  let cNonce = options.cNonce;
207
- let dpopNonce = (_a = options.dpop) === null || _a === void 0 ? void 0 : _a.nonce;
208
- const credentialConfigurationsToRequest = (_b = credentialConfigurationIds === null || credentialConfigurationIds === void 0 ? void 0 : credentialConfigurationIds.map((id) => {
214
+ let dpopNonce = options.dpop?.nonce;
215
+ const credentialConfigurationsToRequest = credentialConfigurationIds?.map((id) => {
209
216
  if (!offeredCredentialConfigurations[id]) {
210
217
  const offeredCredentialIds = Object.keys(offeredCredentialConfigurations).join(', ');
211
218
  throw new core_1.CredoError(`Credential to request '${id}' is not present in offered credentials. Offered credentials are ${offeredCredentialIds}`);
212
219
  }
213
220
  return [id, offeredCredentialConfigurations[id]];
214
- })) !== null && _b !== void 0 ? _b : Object.entries(offeredCredentialConfigurations);
221
+ }) ?? Object.entries(offeredCredentialConfigurations);
215
222
  // If we don't have a nonce yet, we need to first get one
216
223
  if (!cNonce) {
217
224
  // Best option is to use nonce endpoint (draft 14+)
@@ -227,13 +234,16 @@ let OpenId4VciHolderService = class OpenId4VciHolderService {
227
234
  accessToken: options.accessToken,
228
235
  credentialConfigurationId: credentialConfigurationsToRequest[0][0],
229
236
  dpop: options.dpop
230
- ? await this.getDpopOptions(agentContext, Object.assign(Object.assign({}, options.dpop), { nonce: dpopNonce, dpopSigningAlgValuesSupported: [options.dpop.alg] }))
237
+ ? await this.getDpopOptions(agentContext, {
238
+ ...options.dpop,
239
+ nonce: dpopNonce,
240
+ dpopSigningAlgValuesSupported: [options.dpop.alg],
241
+ })
231
242
  : undefined,
232
243
  })
233
244
  .catch((e) => {
234
- var _a;
235
- if (e instanceof oid4vci_1.Oid4vciRetrieveCredentialsError && ((_a = e.response.credentialErrorResponseResult) === null || _a === void 0 ? void 0 : _a.success)) {
236
- cNonce = e.response.credentialErrorResponseResult.output.c_nonce;
245
+ if (e instanceof oid4vci_1.Oid4vciRetrieveCredentialsError && e.response.credentialErrorResponseResult?.success) {
246
+ cNonce = e.response.credentialErrorResponseResult.data.c_nonce;
237
247
  }
238
248
  });
239
249
  }
@@ -244,7 +254,7 @@ let OpenId4VciHolderService = class OpenId4VciHolderService {
244
254
  // If true: use max from issuer or otherwise 1
245
255
  // If number not 0: use the number
246
256
  // Else: use 1
247
- const batchSize = requestBatch === true ? (_d = (_c = metadata.credentialIssuer.batch_credential_issuance) === null || _c === void 0 ? void 0 : _c.batch_size) !== null && _d !== void 0 ? _d : 1 : requestBatch || 1;
257
+ const batchSize = requestBatch === true ? metadata.credentialIssuer.batch_credential_issuance?.batch_size ?? 1 : requestBatch || 1;
248
258
  if (typeof requestBatch === 'number' && requestBatch > 1 && !metadata.credentialIssuer.batch_credential_issuance) {
249
259
  throw new core_1.CredoError(`Credential issuer '${metadata.credentialIssuer.credential_issuer}' does not support batch credential issuance using the 'proofs' request property. Onlt 'proof' supported.`);
250
260
  }
@@ -277,7 +287,11 @@ let OpenId4VciHolderService = class OpenId4VciHolderService {
277
287
  accessToken: options.accessToken,
278
288
  credentialConfigurationId: offeredCredentialId,
279
289
  dpop: options.dpop
280
- ? await this.getDpopOptions(agentContext, Object.assign(Object.assign({}, options.dpop), { nonce: dpopNonce, dpopSigningAlgValuesSupported: [options.dpop.alg] }))
290
+ ? await this.getDpopOptions(agentContext, {
291
+ ...options.dpop,
292
+ nonce: dpopNonce,
293
+ dpopSigningAlgValuesSupported: [options.dpop.alg],
294
+ })
281
295
  : undefined,
282
296
  proofs: batchSize > 1 ? { jwt: jwts } : undefined,
283
297
  proof: batchSize === 1
@@ -289,21 +303,25 @@ let OpenId4VciHolderService = class OpenId4VciHolderService {
289
303
  });
290
304
  // Set new nonce values
291
305
  cNonce = credentialResponse.c_nonce;
292
- dpopNonce = dpop === null || dpop === void 0 ? void 0 : dpop.nonce;
306
+ dpopNonce = dpop?.nonce;
293
307
  // Create credential, but we don't store it yet (only after the user has accepted the credential)
294
308
  const credential = await this.handleCredentialResponse(agentContext, credentialResponse, {
295
- verifyCredentialStatus: verifyCredentialStatus !== null && verifyCredentialStatus !== void 0 ? verifyCredentialStatus : false,
309
+ verifyCredentialStatus: verifyCredentialStatus ?? false,
296
310
  credentialIssuerMetadata: metadata.credentialIssuer,
297
311
  format: offeredCredentialConfiguration.format,
298
312
  credentialConfigurationId: offeredCredentialId,
299
313
  });
300
314
  this.logger.debug('received credential', credential.credentials.map((c) => c instanceof core_1.Mdoc ? { issuerSignedNamespaces: c.issuerSignedNamespaces, base64Url: c.base64Url } : c));
301
- receivedCredentials.push(Object.assign(Object.assign({}, credential), { credentialConfigurationId: offeredCredentialId }));
315
+ receivedCredentials.push({ ...credential, credentialConfigurationId: offeredCredentialId });
302
316
  }
303
317
  return {
304
318
  credentials: receivedCredentials,
305
319
  dpop: options.dpop
306
- ? Object.assign(Object.assign({}, options.dpop), { nonce: dpopNonce }) : undefined,
320
+ ? {
321
+ ...options.dpop,
322
+ nonce: dpopNonce,
323
+ }
324
+ : undefined,
307
325
  cNonce,
308
326
  };
309
327
  }
@@ -398,7 +416,6 @@ let OpenId4VciHolderService = class OpenId4VciHolderService {
398
416
  * algorithm to use, based on the order of preference.
399
417
  */
400
418
  getProofOfPossessionRequirements(agentContext, options) {
401
- var _a, _b, _c, _d, _e;
402
419
  const { credentialToRequest } = options;
403
420
  if (!OpenId4VciHolderServiceOptions_1.openId4VciSupportedCredentialFormats.includes(credentialToRequest.configuration.format)) {
404
421
  throw new core_1.CredoError([
@@ -415,7 +432,7 @@ let OpenId4VciHolderService = class OpenId4VciHolderService {
415
432
  throw new core_1.CredoError(`Unsupported proof type(s) ${Object.keys(credentialToRequest.configuration.proof_types_supported).join(', ')}. Supported proof type(s) are: jwt`);
416
433
  }
417
434
  }
418
- const proofSigningAlgsSupported = (_b = (_a = credentialToRequest.configuration.proof_types_supported) === null || _a === void 0 ? void 0 : _a.jwt) === null || _b === void 0 ? void 0 : _b.proof_signing_alg_values_supported;
435
+ const proofSigningAlgsSupported = credentialToRequest.configuration.proof_types_supported?.jwt?.proof_signing_alg_values_supported;
419
436
  // If undefined, it means the issuer didn't include the cryptographic suites in the metadata
420
437
  // We just guess that the first one is supported
421
438
  if (proofSigningAlgsSupported === undefined) {
@@ -445,14 +462,14 @@ let OpenId4VciHolderService = class OpenId4VciHolderService {
445
462
  }
446
463
  }
447
464
  if (signatureAlgorithms.length === 0) {
448
- throw new core_1.CredoError(`Could not establish signature algorithm for format ${credentialToRequest.configuration.format} and id ${credentialToRequest.id}. Server supported signature algorithms are '${(_c = proofSigningAlgsSupported === null || proofSigningAlgsSupported === void 0 ? void 0 : proofSigningAlgsSupported.join(', ')) !== null && _c !== void 0 ? _c : 'Not defined'}', available are '${options.possibleProofOfPossessionSignatureAlgorithms.join(', ')}'`);
465
+ throw new core_1.CredoError(`Could not establish signature algorithm for format ${credentialToRequest.configuration.format} and id ${credentialToRequest.id}. Server supported signature algorithms are '${proofSigningAlgsSupported?.join(', ') ?? 'Not defined'}', available are '${options.possibleProofOfPossessionSignatureAlgorithms.join(', ')}'`);
449
466
  }
450
467
  const issuerSupportedBindingMethods = credentialToRequest.configuration.cryptographic_binding_methods_supported;
451
- const supportsAllDidMethods = (_d = issuerSupportedBindingMethods === null || issuerSupportedBindingMethods === void 0 ? void 0 : issuerSupportedBindingMethods.includes('did')) !== null && _d !== void 0 ? _d : false;
452
- const supportedDidMethods = issuerSupportedBindingMethods === null || issuerSupportedBindingMethods === void 0 ? void 0 : issuerSupportedBindingMethods.filter((method) => method.startsWith('did:'));
468
+ const supportsAllDidMethods = issuerSupportedBindingMethods?.includes('did') ?? false;
469
+ const supportedDidMethods = issuerSupportedBindingMethods?.filter((method) => method.startsWith('did:'));
453
470
  // The cryptographic_binding_methods_supported describe the cryptographic key material that the issued Credential is bound to.
454
- const supportsCoseKey = (_e = issuerSupportedBindingMethods === null || issuerSupportedBindingMethods === void 0 ? void 0 : issuerSupportedBindingMethods.includes('cose_key')) !== null && _e !== void 0 ? _e : false;
455
- const supportsJwk = (issuerSupportedBindingMethods === null || issuerSupportedBindingMethods === void 0 ? void 0 : issuerSupportedBindingMethods.includes('jwk')) || supportsCoseKey;
471
+ const supportsCoseKey = issuerSupportedBindingMethods?.includes('cose_key') ?? false;
472
+ const supportsJwk = issuerSupportedBindingMethods?.includes('jwk') || supportsCoseKey;
456
473
  return {
457
474
  signatureAlgorithms,
458
475
  supportedDidMethods,
@@ -461,10 +478,9 @@ let OpenId4VciHolderService = class OpenId4VciHolderService {
461
478
  };
462
479
  }
463
480
  async handleCredentialResponse(agentContext, credentialResponse, options) {
464
- var _a;
465
481
  const { verifyCredentialStatus, credentialConfigurationId } = options;
466
482
  this.logger.debug('Credential response', credentialResponse);
467
- const credentials = (_a = credentialResponse.credentials) !== null && _a !== void 0 ? _a : (credentialResponse.credential ? [credentialResponse.credential] : undefined);
483
+ const credentials = credentialResponse.credentials ?? (credentialResponse.credential ? [credentialResponse.credential] : undefined);
468
484
  if (!credentials) {
469
485
  throw new core_1.CredoError(`Credential response returned neither 'credentials' nor 'credential' parameter.`);
470
486
  }
@@ -506,7 +522,7 @@ let OpenId4VciHolderService = class OpenId4VciHolderService {
506
522
  if (!result.every((c) => c.result.isValid)) {
507
523
  agentContext.config.logger.error('Failed to validate credentials', { result });
508
524
  throw new core_1.CredoError(`Failed to validate credential, error = ${result
509
- .map((e) => { var _a; return (_a = e.result.error) === null || _a === void 0 ? void 0 : _a.message; })
525
+ .map((e) => e.result.error?.message)
510
526
  .filter(Boolean)
511
527
  .join(', ')}`);
512
528
  }
@@ -527,7 +543,7 @@ let OpenId4VciHolderService = class OpenId4VciHolderService {
527
543
  if (!result.every((c) => c.result.isValid)) {
528
544
  agentContext.config.logger.error('Failed to validate credentials', { result });
529
545
  throw new core_1.CredoError(`Failed to validate credential, error = ${result
530
- .map((e) => { var _a; return (_a = e.result.error) === null || _a === void 0 ? void 0 : _a.message; })
546
+ .map((e) => e.result.error?.message)
531
547
  .filter(Boolean)
532
548
  .join(', ')}`);
533
549
  }
@@ -559,12 +575,12 @@ let OpenId4VciHolderService = class OpenId4VciHolderService {
559
575
  }
560
576
  getClient(agentContext) {
561
577
  return new oid4vci_1.Oid4vciClient({
562
- callbacks: (0, callbacks_1.getOid4vciCallbacks)(agentContext),
578
+ callbacks: (0, callbacks_1.getOid4vcCallbacks)(agentContext),
563
579
  });
564
580
  }
565
581
  getOauth2Client(agentContext) {
566
582
  return new oauth2_1.Oauth2Client({
567
- callbacks: (0, callbacks_1.getOid4vciCallbacks)(agentContext),
583
+ callbacks: (0, callbacks_1.getOid4vcCallbacks)(agentContext),
568
584
  });
569
585
  }
570
586
  };
@@ -572,7 +588,6 @@ exports.OpenId4VciHolderService = OpenId4VciHolderService;
572
588
  exports.OpenId4VciHolderService = OpenId4VciHolderService = __decorate([
573
589
  (0, core_1.injectable)(),
574
590
  __param(0, (0, core_1.inject)(core_1.InjectionSymbols.Logger)),
575
- __metadata("design:paramtypes", [Object, core_1.W3cCredentialService,
576
- core_1.JwsService])
591
+ __metadata("design:paramtypes", [Object, core_1.W3cCredentialService])
577
592
  ], OpenId4VciHolderService);
578
593
  //# sourceMappingURL=OpenId4VciHolderService.js.map