@sphereon/oid4vci-client 0.10.3 → 0.10.4-next.119

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 (142) hide show
  1. package/README.md +24 -5
  2. package/dist/AccessTokenClient.d.ts +5 -5
  3. package/dist/AccessTokenClient.d.ts.map +1 -1
  4. package/dist/AccessTokenClient.js +51 -37
  5. package/dist/AccessTokenClient.js.map +1 -1
  6. package/dist/AccessTokenClientV1_0_11.d.ts +29 -0
  7. package/dist/AccessTokenClientV1_0_11.d.ts.map +1 -0
  8. package/dist/AccessTokenClientV1_0_11.js +209 -0
  9. package/dist/AccessTokenClientV1_0_11.js.map +1 -0
  10. package/dist/AuthorizationCodeClient.d.ts +9 -4
  11. package/dist/AuthorizationCodeClient.d.ts.map +1 -1
  12. package/dist/AuthorizationCodeClient.js +102 -18
  13. package/dist/AuthorizationCodeClient.js.map +1 -1
  14. package/dist/AuthorizationCodeClientV1_0_11.d.ts +9 -0
  15. package/dist/AuthorizationCodeClientV1_0_11.d.ts.map +1 -0
  16. package/dist/AuthorizationCodeClientV1_0_11.js +134 -0
  17. package/dist/AuthorizationCodeClientV1_0_11.js.map +1 -0
  18. package/dist/CredentialOfferClient.d.ts.map +1 -1
  19. package/dist/CredentialOfferClient.js +18 -13
  20. package/dist/CredentialOfferClient.js.map +1 -1
  21. package/dist/CredentialOfferClientV1_0_11.d.ts +10 -0
  22. package/dist/CredentialOfferClientV1_0_11.d.ts.map +1 -0
  23. package/dist/CredentialOfferClientV1_0_11.js +101 -0
  24. package/dist/CredentialOfferClientV1_0_11.js.map +1 -0
  25. package/dist/CredentialOfferClientV1_0_13.d.ts +10 -0
  26. package/dist/CredentialOfferClientV1_0_13.d.ts.map +1 -0
  27. package/dist/CredentialOfferClientV1_0_13.js +94 -0
  28. package/dist/CredentialOfferClientV1_0_13.js.map +1 -0
  29. package/dist/CredentialRequestClient.d.ts +20 -7
  30. package/dist/CredentialRequestClient.d.ts.map +1 -1
  31. package/dist/CredentialRequestClient.js +46 -30
  32. package/dist/CredentialRequestClient.js.map +1 -1
  33. package/dist/CredentialRequestClientBuilder.d.ts +11 -6
  34. package/dist/CredentialRequestClientBuilder.d.ts.map +1 -1
  35. package/dist/CredentialRequestClientBuilder.js +22 -9
  36. package/dist/CredentialRequestClientBuilder.js.map +1 -1
  37. package/dist/CredentialRequestClientBuilderV1_0_11.d.ts +48 -0
  38. package/dist/CredentialRequestClientBuilderV1_0_11.d.ts.map +1 -0
  39. package/dist/CredentialRequestClientBuilderV1_0_11.js +121 -0
  40. package/dist/CredentialRequestClientBuilderV1_0_11.js.map +1 -0
  41. package/dist/CredentialRequestClientV1_0_11.d.ts +50 -0
  42. package/dist/CredentialRequestClientV1_0_11.d.ts.map +1 -0
  43. package/dist/CredentialRequestClientV1_0_11.js +151 -0
  44. package/dist/CredentialRequestClientV1_0_11.js.map +1 -0
  45. package/dist/MetadataClient.d.ts +5 -15
  46. package/dist/MetadataClient.d.ts.map +1 -1
  47. package/dist/MetadataClient.js +41 -44
  48. package/dist/MetadataClient.js.map +1 -1
  49. package/dist/MetadataClientV1_0_11.d.ts +31 -0
  50. package/dist/MetadataClientV1_0_11.d.ts.map +1 -0
  51. package/dist/MetadataClientV1_0_11.js +182 -0
  52. package/dist/MetadataClientV1_0_11.js.map +1 -0
  53. package/dist/MetadataClientV1_0_13.d.ts +31 -0
  54. package/dist/MetadataClientV1_0_13.d.ts.map +1 -0
  55. package/dist/MetadataClientV1_0_13.js +181 -0
  56. package/dist/MetadataClientV1_0_13.js.map +1 -0
  57. package/dist/OpenID4VCIClient.d.ts +14 -19
  58. package/dist/OpenID4VCIClient.d.ts.map +1 -1
  59. package/dist/OpenID4VCIClient.js +111 -61
  60. package/dist/OpenID4VCIClient.js.map +1 -1
  61. package/dist/OpenID4VCIClientV1_0_11.d.ts +108 -0
  62. package/dist/OpenID4VCIClientV1_0_11.d.ts.map +1 -0
  63. package/dist/OpenID4VCIClientV1_0_11.js +449 -0
  64. package/dist/OpenID4VCIClientV1_0_11.js.map +1 -0
  65. package/dist/OpenID4VCIClientV1_0_13.d.ts +112 -0
  66. package/dist/OpenID4VCIClientV1_0_13.d.ts.map +1 -0
  67. package/dist/OpenID4VCIClientV1_0_13.js +478 -0
  68. package/dist/OpenID4VCIClientV1_0_13.js.map +1 -0
  69. package/dist/ProofOfPossessionBuilder.d.ts +14 -3
  70. package/dist/ProofOfPossessionBuilder.d.ts.map +1 -1
  71. package/dist/ProofOfPossessionBuilder.js +20 -21
  72. package/dist/ProofOfPossessionBuilder.js.map +1 -1
  73. package/dist/functions/OpenIDUtils.d.ts +12 -0
  74. package/dist/functions/OpenIDUtils.d.ts.map +1 -0
  75. package/dist/functions/OpenIDUtils.js +37 -0
  76. package/dist/functions/OpenIDUtils.js.map +1 -0
  77. package/dist/functions/index.d.ts +2 -3
  78. package/dist/functions/index.d.ts.map +1 -1
  79. package/dist/functions/index.js +2 -3
  80. package/dist/functions/index.js.map +1 -1
  81. package/dist/functions/notifications.d.ts +4 -0
  82. package/dist/functions/notifications.d.ts.map +1 -0
  83. package/dist/functions/notifications.js +39 -0
  84. package/dist/functions/notifications.js.map +1 -0
  85. package/dist/index.d.ts +13 -1
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.js +14 -1
  88. package/dist/index.js.map +1 -1
  89. package/dist/types/index.d.ts +2 -0
  90. package/dist/types/index.d.ts.map +1 -1
  91. package/dist/types/index.js +5 -0
  92. package/dist/types/index.js.map +1 -1
  93. package/lib/AccessTokenClient.ts +59 -34
  94. package/lib/AccessTokenClientV1_0_11.ts +250 -0
  95. package/lib/AuthorizationCodeClient.ts +131 -28
  96. package/lib/AuthorizationCodeClientV1_0_11.ts +170 -0
  97. package/lib/CredentialOfferClient.ts +21 -8
  98. package/lib/CredentialOfferClientV1_0_11.ts +112 -0
  99. package/lib/CredentialOfferClientV1_0_13.ts +103 -0
  100. package/lib/CredentialRequestClient.ts +65 -26
  101. package/lib/CredentialRequestClientBuilder.ts +34 -16
  102. package/lib/CredentialRequestClientBuilderV1_0_11.ts +163 -0
  103. package/lib/CredentialRequestClientV1_0_11.ts +197 -0
  104. package/lib/MetadataClient.ts +64 -49
  105. package/lib/MetadataClientV1_0_11.ts +189 -0
  106. package/lib/MetadataClientV1_0_13.ts +188 -0
  107. package/lib/OpenID4VCIClient.ts +132 -68
  108. package/lib/OpenID4VCIClientV1_0_11.ts +635 -0
  109. package/lib/OpenID4VCIClientV1_0_13.ts +677 -0
  110. package/lib/ProofOfPossessionBuilder.ts +41 -11
  111. package/lib/__tests__/AccessTokenClient.spec.ts +40 -12
  112. package/lib/__tests__/AuthorizationDetailsBuilder.spec.ts +0 -12
  113. package/lib/__tests__/CredentialRequestClient.spec.ts +87 -50
  114. package/lib/__tests__/CredentialRequestClientBuilder.spec.ts +18 -12
  115. package/lib/__tests__/CredentialRequestClientV1_0_11.spec.ts +317 -0
  116. package/lib/__tests__/EBSIE2E.spec.test.ts +2 -2
  117. package/lib/__tests__/HttpUtils.spec.ts +1 -1
  118. package/lib/__tests__/IT.spec.ts +264 -14
  119. package/lib/__tests__/IssuanceInitiation.spec.ts +59 -4
  120. package/lib/__tests__/IssuanceInitiationV1_0_11.spec.ts +62 -0
  121. package/lib/__tests__/MattrE2E.spec.test.ts +2 -2
  122. package/lib/__tests__/MetadataClient.spec.ts +53 -3
  123. package/lib/__tests__/MetadataMocks.ts +42 -2
  124. package/lib/__tests__/OpenID4VCIClient.spec.ts +58 -2
  125. package/lib/__tests__/{OpenID4VCIClientPAR.spec.ts → OpenID4VCIClientPARV1_0_11.spec.ts} +5 -5
  126. package/lib/__tests__/OpenID4VCIClientV1_0_11.spec.ts +226 -0
  127. package/lib/__tests__/OpenID4VCIClientV1_0_13.spec.ts +204 -0
  128. package/lib/__tests__/ProofOfPossessionBuilder.spec.ts +1 -1
  129. package/lib/__tests__/SdJwt.spec.ts +36 -30
  130. package/lib/__tests__/SphereonE2E.spec.test.ts +10 -7
  131. package/lib/__tests__/data/VciDataFixtures.ts +712 -27
  132. package/lib/functions/OpenIDUtils.ts +25 -0
  133. package/lib/functions/index.ts +2 -3
  134. package/lib/functions/notifications.ts +32 -0
  135. package/lib/index.ts +16 -1
  136. package/lib/types/index.ts +6 -0
  137. package/package.json +4 -4
  138. package/dist/functions/ProofUtil.d.ts +0 -30
  139. package/dist/functions/ProofUtil.d.ts.map +0 -1
  140. package/dist/functions/ProofUtil.js +0 -106
  141. package/dist/functions/ProofUtil.js.map +0 -1
  142. package/lib/functions/ProofUtil.ts +0 -128
@@ -11,9 +11,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ProofOfPossessionBuilder = void 0;
13
13
  const oid4vci_common_1 = require("@sphereon/oid4vci-common");
14
- const functions_1 = require("./functions");
15
14
  class ProofOfPossessionBuilder {
16
- constructor({ proof, callbacks, jwt, accessTokenResponse, version, }) {
15
+ constructor({ proof, callbacks, jwt, accessTokenResponse, version, mode = 'pop', }) {
16
+ this.mode = 'pop';
17
+ this.mode = mode;
17
18
  this.proof = proof;
18
19
  this.callbacks = callbacks;
19
20
  this.version = version;
@@ -21,21 +22,28 @@ class ProofOfPossessionBuilder {
21
22
  this.withJwt(jwt);
22
23
  }
23
24
  else {
24
- this.withTyp(version < oid4vci_common_1.OpenId4VCIVersion.VER_1_0_11 ? 'jwt' : 'openid4vci-proof+jwt');
25
+ this.withTyp(version < oid4vci_common_1.OpenId4VCIVersion.VER_1_0_11 || mode === 'jwt' ? 'jwt' : 'openid4vci-proof+jwt');
25
26
  }
26
27
  if (accessTokenResponse) {
27
28
  this.withAccessTokenResponse(accessTokenResponse);
28
29
  }
29
30
  }
30
- static fromJwt({ jwt, callbacks, version, }) {
31
- return new ProofOfPossessionBuilder({ callbacks, jwt, version });
31
+ static manual({ jwt, callbacks, version, mode = 'jwt', }) {
32
+ return new ProofOfPossessionBuilder({ callbacks, jwt, version, mode });
32
33
  }
33
- static fromAccessTokenResponse({ accessTokenResponse, callbacks, version, }) {
34
- return new ProofOfPossessionBuilder({ callbacks, accessTokenResponse, version });
34
+ static fromJwt({ jwt, callbacks, version, mode = 'pop', }) {
35
+ return new ProofOfPossessionBuilder({ callbacks, jwt, version, mode });
36
+ }
37
+ static fromAccessTokenResponse({ accessTokenResponse, callbacks, version, mode = 'pop', }) {
38
+ return new ProofOfPossessionBuilder({ callbacks, accessTokenResponse, version, mode });
35
39
  }
36
40
  static fromProof(proof, version) {
37
41
  return new ProofOfPossessionBuilder({ proof, version });
38
42
  }
43
+ withAud(aud) {
44
+ this.aud = aud;
45
+ return this;
46
+ }
39
47
  withClientId(clientId) {
40
48
  this.clientId = clientId;
41
49
  return this;
@@ -61,7 +69,7 @@ class ProofOfPossessionBuilder {
61
69
  return this;
62
70
  }
63
71
  withTyp(typ) {
64
- if (this.version >= oid4vci_common_1.OpenId4VCIVersion.VER_1_0_11) {
72
+ if (this.mode === 'pop' && this.version >= oid4vci_common_1.OpenId4VCIVersion.VER_1_0_11) {
65
73
  if (!!typ && typ !== 'openid4vci-proof+jwt') {
66
74
  throw Error('typ must be openid4vci-proof+jwt for version 1.0.11 and up');
67
75
  }
@@ -105,7 +113,7 @@ class ProofOfPossessionBuilder {
105
113
  if (jwt.header.typ) {
106
114
  this.withTyp(jwt.header.typ);
107
115
  }
108
- if (this.version >= oid4vci_common_1.OpenId4VCIVersion.VER_1_0_11) {
116
+ if (!this.typ && this.version >= oid4vci_common_1.OpenId4VCIVersion.VER_1_0_11) {
109
117
  this.withTyp('openid4vci-proof+jwt');
110
118
  }
111
119
  this.withAlg(jwt.header.alg);
@@ -115,9 +123,9 @@ class ProofOfPossessionBuilder {
115
123
  }
116
124
  if (jwt.payload) {
117
125
  if (jwt.payload.iss)
118
- this.withClientId(jwt.payload.iss);
126
+ this.mode === 'pop' ? this.withClientId(jwt.payload.iss) : this.withIssuer(jwt.payload.iss);
119
127
  if (jwt.payload.aud)
120
- this.withIssuer(jwt.payload.aud);
128
+ this.mode === 'pop' ? this.withIssuer(jwt.payload.aud) : this.withAud(jwt.payload.aud);
121
129
  if (jwt.payload.jti)
122
130
  this.withJti(jwt.payload.jti);
123
131
  if (jwt.payload.nonce)
@@ -132,16 +140,7 @@ class ProofOfPossessionBuilder {
132
140
  return Promise.resolve(this.proof);
133
141
  }
134
142
  else if (this.callbacks) {
135
- return yield (0, functions_1.createProofOfPossession)(this.callbacks, {
136
- typ: (_a = this.typ) !== null && _a !== void 0 ? _a : (this.version < oid4vci_common_1.OpenId4VCIVersion.VER_1_0_11 ? 'jwt' : 'openid4vci-proof+jwt'),
137
- kid: this.kid,
138
- jwk: this.jwk,
139
- jti: this.jti,
140
- alg: this.alg,
141
- issuer: this.issuer,
142
- clientId: this.clientId,
143
- nonce: this.cNonce,
144
- }, this.jwt);
143
+ return yield (0, oid4vci_common_1.createProofOfPossession)(this.mode, this.callbacks, Object.assign({ typ: (_a = this.typ) !== null && _a !== void 0 ? _a : (this.version < oid4vci_common_1.OpenId4VCIVersion.VER_1_0_11 || this.mode === 'jwt' ? 'jwt' : 'openid4vci-proof+jwt'), kid: this.kid, jwk: this.jwk, jti: this.jti, alg: this.alg, aud: this.aud, issuer: this.issuer, clientId: this.clientId }, (this.cNonce && { nonce: this.cNonce })), this.jwt);
145
144
  }
146
145
  throw new Error(oid4vci_common_1.PROOF_CANT_BE_CONSTRUCTED);
147
146
  });
@@ -1 +1 @@
1
- {"version":3,"file":"ProofOfPossessionBuilder.js","sourceRoot":"","sources":["../lib/ProofOfPossessionBuilder.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6DAYkC;AAElC,2CAAsD;AAEtD,MAAa,wBAAwB;IAenC,YAAoB,EAClB,KAAK,EACL,SAAS,EACT,GAAG,EACH,mBAAmB,EACnB,OAAO,GAOR;QACC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAA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C,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,SAAS,kBAEZ,GAAG,EAAE,MAAA,IAAI,CAAC,GAAG,mCAAI,CAAC,IAAI,CAAC,OAAO,GAAG,kCAAiB,CAAC,UAAU,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,sBAAsB,CAAC,EACtH,GAAG,EAAE,IAAI,CAAC,GAAG,EACb,GAAG,EAAE,IAAI,CAAC,GAAG,EACb,GAAG,EAAE,IAAI,CAAC,GAAG,EACb,GAAG,EAAE,IAAI,CAAC,GAAG,EACb,GAAG,EAAE,IAAI,CAAC,GAAG,EACb,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ,IACpB,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,GAE5C,IAAI,CAAC,GAAG,CACT,CAAC;YACJ,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,0CAAyB,CAAC,CAAC;;KAC5C;CACF;AAzND,4DAyNC"}
@@ -0,0 +1,12 @@
1
+ import { OpenIDResponse, WellKnownEndpoints } from '@sphereon/oid4vci-common';
2
+ /**
3
+ * Allows to retrieve information from a well-known location
4
+ *
5
+ * @param host The host
6
+ * @param endpointType The endpoint type, currently supports OID4VCI, OIDC and OAuth2 endpoint types
7
+ * @param opts Options, like for instance whether an error should be thrown in case the endpoint doesn't exist
8
+ */
9
+ export declare const retrieveWellknown: <T>(host: string, endpointType: WellKnownEndpoints, opts?: {
10
+ errorOnNotFound?: boolean;
11
+ }) => Promise<OpenIDResponse<T>>;
12
+ //# sourceMappingURL=OpenIDUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpenIDUtils.d.ts","sourceRoot":"","sources":["../../lib/functions/OpenIDUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,cAAc,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAIvF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,YACtB,MAAM,gBACE,kBAAkB,SACzB;IAAE,eAAe,CAAC,EAAE,OAAO,CAAA;CAAE,+BAUrC,CAAC"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.retrieveWellknown = void 0;
16
+ const oid4vci_common_1 = require("@sphereon/oid4vci-common");
17
+ const debug_1 = __importDefault(require("debug"));
18
+ const debug = (0, debug_1.default)('sphereon:openid4vci:openid-utils');
19
+ /**
20
+ * Allows to retrieve information from a well-known location
21
+ *
22
+ * @param host The host
23
+ * @param endpointType The endpoint type, currently supports OID4VCI, OIDC and OAuth2 endpoint types
24
+ * @param opts Options, like for instance whether an error should be thrown in case the endpoint doesn't exist
25
+ */
26
+ const retrieveWellknown = (host, endpointType, opts) => __awaiter(void 0, void 0, void 0, function* () {
27
+ const result = yield (0, oid4vci_common_1.getJson)(`${host.endsWith('/') ? host.slice(0, -1) : host}${endpointType}`, {
28
+ exceptionOnHttpErrorStatus: opts === null || opts === void 0 ? void 0 : opts.errorOnNotFound,
29
+ });
30
+ if (result.origResponse.status >= 400) {
31
+ // We only get here when error on not found is false
32
+ debug(`host ${host} with endpoint type ${endpointType} status: ${result.origResponse.status}, ${result.origResponse.statusText}`);
33
+ }
34
+ return result;
35
+ });
36
+ exports.retrieveWellknown = retrieveWellknown;
37
+ //# sourceMappingURL=OpenIDUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpenIDUtils.js","sourceRoot":"","sources":["../../lib/functions/OpenIDUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DAAuF;AACvF,kDAA0B;AAE1B,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,kCAAkC,CAAC,CAAC;AACxD;;;;;;GAMG;AACI,MAAM,iBAAiB,GAAG,CAC/B,IAAY,EACZ,YAAgC,EAChC,IAAoC,EACR,EAAE;IAC9B,MAAM,MAAM,GAAsB,MAAM,IAAA,wBAAO,EAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,YAAY,EAAE,EAAE;QACjH,0BAA0B,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,eAAe;KAClD,CAAC,CAAC;IACH,IAAI,MAAM,CAAC,YAAY,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC;QACtC,oDAAoD;QACpD,KAAK,CAAC,QAAQ,IAAI,uBAAuB,YAAY,YAAY,MAAM,CAAC,YAAY,CAAC,MAAM,KAAK,MAAM,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC,CAAC;IACpI,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAA,CAAC;AAbW,QAAA,iBAAiB,qBAa5B"}
@@ -1,4 +1,3 @@
1
- export * from '@sphereon/oid4vci-common/dist/functions/Encoding';
2
- export * from '@sphereon/oid4vci-common/dist/functions/HttpUtils';
3
- export * from './ProofUtil';
1
+ export * from './AuthorizationUtil';
2
+ export * from './notifications';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/functions/index.ts"],"names":[],"mappings":"AAAA,cAAc,kDAAkD,CAAC;AACjE,cAAc,mDAAmD,CAAC;AAClE,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/functions/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC"}
@@ -14,7 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("@sphereon/oid4vci-common/dist/functions/Encoding"), exports);
18
- __exportStar(require("@sphereon/oid4vci-common/dist/functions/HttpUtils"), exports);
19
- __exportStar(require("./ProofUtil"), exports);
17
+ __exportStar(require("./AuthorizationUtil"), exports);
18
+ __exportStar(require("./notifications"), exports);
20
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/functions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mFAAiE;AACjE,oFAAkE;AAClE,8CAA4B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/functions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,kDAAgC"}
@@ -0,0 +1,4 @@
1
+ import { NotificationRequest, NotificationResult } from '@sphereon/oid4vci-common';
2
+ import { CredentialRequestOpts } from '../CredentialRequestClient';
3
+ export declare function sendNotification(credentialRequestOpts: Partial<CredentialRequestOpts>, request: NotificationRequest, accessToken?: string): Promise<NotificationResult>;
4
+ //# sourceMappingURL=notifications.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notifications.d.ts","sourceRoot":"","sources":["../../lib/functions/notifications.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,mBAAmB,EAAE,kBAAkB,EAAQ,MAAM,0BAA0B,CAAC;AAEpH,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAGnE,wBAAsB,gBAAgB,CACpC,qBAAqB,EAAE,OAAO,CAAC,qBAAqB,CAAC,EACrD,OAAO,EAAE,mBAAmB,EAC5B,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,kBAAkB,CAAC,CAsB7B"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.sendNotification = void 0;
13
+ const oid4vci_common_1 = require("@sphereon/oid4vci-common");
14
+ const types_1 = require("../types");
15
+ function sendNotification(credentialRequestOpts, request, accessToken) {
16
+ var _a, _b, _c;
17
+ return __awaiter(this, void 0, void 0, function* () {
18
+ types_1.LOG.info(`Sending status notification event '${request.event}' for id ${request.notification_id}`);
19
+ if (!credentialRequestOpts.notificationEndpoint) {
20
+ throw Error(`Cannot send notification when no notification endpoint is provided`);
21
+ }
22
+ const token = accessToken !== null && accessToken !== void 0 ? accessToken : credentialRequestOpts.token;
23
+ const response = yield (0, oid4vci_common_1.post)(credentialRequestOpts.notificationEndpoint, JSON.stringify(request), Object.assign({}, (token && { bearerToken: token })));
24
+ const error = ((_a = response.errorBody) === null || _a === void 0 ? void 0 : _a.error) !== undefined;
25
+ const result = {
26
+ error,
27
+ response: error ? yield ((_b = response.errorBody) === null || _b === void 0 ? void 0 : _b.json()) : undefined,
28
+ };
29
+ if (error) {
30
+ types_1.LOG.warning(`Notification endpoint returned an error for event '${request.event}' and id ${request.notification_id}: ${yield ((_c = response.errorBody) === null || _c === void 0 ? void 0 : _c.json())}`);
31
+ }
32
+ else {
33
+ types_1.LOG.debug(`Notification endpoint returned success for event '${request.event}' and id ${request.notification_id}`);
34
+ }
35
+ return result;
36
+ });
37
+ }
38
+ exports.sendNotification = sendNotification;
39
+ //# sourceMappingURL=notifications.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notifications.js","sourceRoot":"","sources":["../../lib/functions/notifications.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6DAAoH;AAGpH,oCAA+B;AAE/B,SAAsB,gBAAgB,CACpC,qBAAqD,EACrD,OAA4B,EAC5B,WAAoB;;;QAEpB,WAAG,CAAC,IAAI,CAAC,sCAAsC,OAAO,CAAC,KAAK,YAAY,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;QACnG,IAAI,CAAC,qBAAqB,CAAC,oBAAoB,EAAE,CAAC;YAChD,MAAM,KAAK,CAAC,oEAAoE,CAAC,CAAC;QACpF,CAAC;QACD,MAAM,KAAK,GAAG,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,qBAAqB,CAAC,KAAK,CAAC;QACzD,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAI,EAA4B,qBAAqB,CAAC,oBAAoB,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,oBACrH,CAAC,KAAK,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,EACpC,CAAC;QACH,MAAM,KAAK,GAAG,CAAA,MAAA,QAAQ,CAAC,SAAS,0CAAE,KAAK,MAAK,SAAS,CAAC;QACtD,MAAM,MAAM,GAAG;YACb,KAAK;YACL,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,MAAM,CAAA,MAAA,QAAQ,CAAC,SAAS,0CAAE,IAAI,EAAE,CAAA,CAAC,CAAC,CAAC,SAAS;SAC/D,CAAC;QACF,IAAI,KAAK,EAAE,CAAC;YACV,WAAG,CAAC,OAAO,CACT,sDAAsD,OAAO,CAAC,KAAK,YAAY,OAAO,CAAC,eAAe,KAAK,MAAM,CAAA,MAAA,QAAQ,CAAC,SAAS,0CAAE,IAAI,EAAE,CAAA,EAAE,CAC9I,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,WAAG,CAAC,KAAK,CAAC,qDAAqD,OAAO,CAAC,KAAK,YAAY,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;QACrH,CAAC;QACD,OAAO,MAAM,CAAC;;CACf;AA1BD,4CA0BC"}
package/dist/index.d.ts CHANGED
@@ -1,10 +1,22 @@
1
+ import { ISimpleLogger } from '@sphereon/ssi-types';
2
+ export declare const LOG: ISimpleLogger<string>;
1
3
  export * from './AccessTokenClient';
4
+ export * from './AccessTokenClientV1_0_11';
5
+ export * from './AuthorizationCodeClient';
6
+ export * from './AuthorizationCodeClientV1_0_11';
2
7
  export * from './CredentialRequestClient';
3
8
  export * from './CredentialOfferClient';
4
- export * from './CredentialRequestClient';
9
+ export * from './CredentialOfferClientV1_0_11';
10
+ export * from './CredentialOfferClientV1_0_13';
11
+ export * from './CredentialRequestClientV1_0_11';
5
12
  export * from './CredentialRequestClientBuilder';
13
+ export * from './CredentialRequestClientBuilderV1_0_11';
6
14
  export * from './functions';
7
15
  export * from './MetadataClient';
16
+ export * from './MetadataClientV1_0_13';
17
+ export * from './MetadataClientV1_0_11';
8
18
  export * from './OpenID4VCIClient';
19
+ export * from './OpenID4VCIClientV1_0_13';
20
+ export * from './OpenID4VCIClientV1_0_11';
9
21
  export * from './ProofOfPossessionBuilder';
10
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kCAAkC,CAAC;AACjD,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,eAAO,MAAM,GAAG,EAAE,aAAa,CAAC,MAAM,CAA8C,CAAC;AAErF,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kCAAkC,CAAC;AACjD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,yCAAyC,CAAC;AACxD,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC"}
package/dist/index.js CHANGED
@@ -14,13 +14,26 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.LOG = void 0;
18
+ const oid4vci_common_1 = require("@sphereon/oid4vci-common");
19
+ exports.LOG = oid4vci_common_1.VCI_LOGGERS.get('sphereon:oid4vci:client');
17
20
  __exportStar(require("./AccessTokenClient"), exports);
21
+ __exportStar(require("./AccessTokenClientV1_0_11"), exports);
22
+ __exportStar(require("./AuthorizationCodeClient"), exports);
23
+ __exportStar(require("./AuthorizationCodeClientV1_0_11"), exports);
18
24
  __exportStar(require("./CredentialRequestClient"), exports);
19
25
  __exportStar(require("./CredentialOfferClient"), exports);
20
- __exportStar(require("./CredentialRequestClient"), exports);
26
+ __exportStar(require("./CredentialOfferClientV1_0_11"), exports);
27
+ __exportStar(require("./CredentialOfferClientV1_0_13"), exports);
28
+ __exportStar(require("./CredentialRequestClientV1_0_11"), exports);
21
29
  __exportStar(require("./CredentialRequestClientBuilder"), exports);
30
+ __exportStar(require("./CredentialRequestClientBuilderV1_0_11"), exports);
22
31
  __exportStar(require("./functions"), exports);
23
32
  __exportStar(require("./MetadataClient"), exports);
33
+ __exportStar(require("./MetadataClientV1_0_13"), exports);
34
+ __exportStar(require("./MetadataClientV1_0_11"), exports);
24
35
  __exportStar(require("./OpenID4VCIClient"), exports);
36
+ __exportStar(require("./OpenID4VCIClientV1_0_13"), exports);
37
+ __exportStar(require("./OpenID4VCIClientV1_0_11"), exports);
25
38
  __exportStar(require("./ProofOfPossessionBuilder"), exports);
26
39
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,4DAA0C;AAC1C,0DAAwC;AACxC,4DAA0C;AAC1C,mEAAiD;AACjD,8CAA4B;AAC5B,mDAAiC;AACjC,qDAAmC;AACnC,6DAA2C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,6DAAuD;AAG1C,QAAA,GAAG,GAA0B,4BAAW,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;AAErF,sDAAoC;AACpC,6DAA2C;AAC3C,4DAA0C;AAC1C,mEAAiD;AACjD,4DAA0C;AAC1C,0DAAwC;AACxC,iEAA+C;AAC/C,iEAA+C;AAC/C,mEAAiD;AACjD,mEAAiD;AACjD,0EAAwD;AACxD,8CAA4B;AAC5B,mDAAiC;AACjC,0DAAwC;AACxC,0DAAwC;AACxC,qDAAmC;AACnC,4DAA0C;AAC1C,4DAA0C;AAC1C,6DAA2C"}
@@ -1 +1,3 @@
1
+ import { ISimpleLogger } from '@sphereon/ssi-types';
2
+ export declare const LOG: ISimpleLogger<string>;
1
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/types/index.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/types/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAa,MAAM,qBAAqB,CAAC;AAE/D,eAAO,MAAM,GAAG,EAAE,aAAa,CAAC,MAAM,CAErC,CAAC"}
@@ -1,2 +1,7 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LOG = void 0;
4
+ const oid4vci_common_1 = require("@sphereon/oid4vci-common");
5
+ const ssi_types_1 = require("@sphereon/ssi-types");
6
+ exports.LOG = oid4vci_common_1.VCI_LOGGERS.options('sphereon:oid4vci:client', { methods: [ssi_types_1.LogMethod.EVENT, ssi_types_1.LogMethod.DEBUG_PKG] }).get('sphereon:oid4vci:client');
2
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/types/index.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/types/index.ts"],"names":[],"mappings":";;;AAAA,6DAAuD;AACvD,mDAA+D;AAElD,QAAA,GAAG,GAA0B,4BAAW,CAAC,OAAO,CAAC,yBAAyB,EAAE,EAAE,OAAO,EAAE,CAAC,qBAAS,CAAC,KAAK,EAAE,qBAAS,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,GAAG,CAC/I,yBAAyB,CAC1B,CAAC"}
@@ -5,7 +5,9 @@ import {
5
5
  assertedUniformCredentialOffer,
6
6
  AuthorizationServerOpts,
7
7
  AuthzFlowType,
8
+ convertJsonToURI,
8
9
  EndpointMetadata,
10
+ formPost,
9
11
  getIssuerFromCredentialOfferPayload,
10
12
  GrantTypes,
11
13
  IssuerOpts,
@@ -14,22 +16,20 @@ import {
14
16
  PRE_AUTH_CODE_LITERAL,
15
17
  TokenErrorResponse,
16
18
  toUniformCredentialOfferRequest,
19
+ TxCodeAndPinRequired,
17
20
  UniformCredentialOfferPayload,
18
21
  } from '@sphereon/oid4vci-common';
19
22
  import { ObjectUtils } from '@sphereon/ssi-types';
20
- import Debug from 'debug';
21
23
 
22
- import { MetadataClient } from './MetadataClient';
23
- import { convertJsonToURI, formPost } from './functions';
24
-
25
- const debug = Debug('sphereon:oid4vci:token');
24
+ import { MetadataClientV1_0_13 } from './MetadataClientV1_0_13';
25
+ import { LOG } from './types';
26
26
 
27
27
  export class AccessTokenClient {
28
28
  public async acquireAccessToken(opts: AccessTokenRequestOpts): Promise<OpenIDResponse<AccessTokenResponse>> {
29
29
  const { asOpts, pin, codeVerifier, code, redirectUri, metadata } = opts;
30
30
 
31
31
  const credentialOffer = opts.credentialOffer ? await assertedUniformCredentialOffer(opts.credentialOffer) : undefined;
32
- const isPinRequired = credentialOffer && this.isPinRequiredValue(credentialOffer.credential_offer);
32
+ const pinMetadata: TxCodeAndPinRequired | undefined = credentialOffer && this.getPinMetadata(credentialOffer.credential_offer);
33
33
  const issuer =
34
34
  opts.credentialIssuer ??
35
35
  (credentialOffer ? getIssuerFromCredentialOfferPayload(credentialOffer.credential_offer) : (metadata?.issuer as string));
@@ -48,8 +48,9 @@ export class AccessTokenClient {
48
48
  code,
49
49
  redirectUri,
50
50
  pin,
51
+ pinMetadata,
51
52
  }),
52
- isPinRequired,
53
+ pinMetadata,
53
54
  metadata,
54
55
  asOpts,
55
56
  issuerOpts,
@@ -58,18 +59,18 @@ export class AccessTokenClient {
58
59
 
59
60
  public async acquireAccessTokenUsingRequest({
60
61
  accessTokenRequest,
61
- isPinRequired,
62
+ pinMetadata,
62
63
  metadata,
63
64
  asOpts,
64
65
  issuerOpts,
65
66
  }: {
66
67
  accessTokenRequest: AccessTokenRequest;
67
- isPinRequired?: boolean;
68
+ pinMetadata?: TxCodeAndPinRequired;
68
69
  metadata?: EndpointMetadata;
69
70
  asOpts?: AuthorizationServerOpts;
70
71
  issuerOpts?: IssuerOpts;
71
72
  }): Promise<OpenIDResponse<AccessTokenResponse>> {
72
- this.validate(accessTokenRequest, isPinRequired);
73
+ this.validate(accessTokenRequest, pinMetadata);
73
74
 
74
75
  const requestTokenURL = AccessTokenClient.determineTokenURL({
75
76
  asOpts,
@@ -77,7 +78,7 @@ export class AccessTokenClient {
77
78
  metadata: metadata
78
79
  ? metadata
79
80
  : issuerOpts?.fetchMetadata
80
- ? await MetadataClient.retrieveAllMetadata(issuerOpts.issuer, { errorOnNotFound: false })
81
+ ? await MetadataClientV1_0_13.retrieveAllMetadata(issuerOpts.issuer, { errorOnNotFound: false })
81
82
  : undefined,
82
83
  });
83
84
 
@@ -86,6 +87,8 @@ export class AccessTokenClient {
86
87
 
87
88
  public async createAccessTokenRequest(opts: AccessTokenRequestOpts): Promise<AccessTokenRequest> {
88
89
  const { asOpts, pin, codeVerifier, code, redirectUri } = opts;
90
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
91
+ // @ts-ignore
89
92
  const credentialOfferRequest = opts.credentialOffer ? await toUniformCredentialOfferRequest(opts.credentialOffer) : undefined;
90
93
  const request: Partial<AccessTokenRequest> = {};
91
94
 
@@ -94,7 +97,7 @@ export class AccessTokenClient {
94
97
  }
95
98
 
96
99
  if (credentialOfferRequest?.supportedFlows.includes(AuthzFlowType.PRE_AUTHORIZED_CODE_FLOW)) {
97
- this.assertNumericPin(this.isPinRequiredValue(credentialOfferRequest.credential_offer), pin);
100
+ this.assertAlphanumericPin(opts.pinMetadata, pin);
98
101
  request.user_pin = pin;
99
102
 
100
103
  request.grant_type = GrantTypes.PRE_AUTHORIZED_CODE;
@@ -117,7 +120,7 @@ export class AccessTokenClient {
117
120
  return request as AccessTokenRequest;
118
121
  }
119
122
 
120
- throw new Error('Credential offer request does not follow neither pre-authorized code nor authorization code flow requirements.');
123
+ throw new Error('Credential offer request follows neither pre-authorized code nor authorization code flow requirements.');
121
124
  }
122
125
 
123
126
  private assertPreAuthorizedGrantType(grantType: GrantTypes): void {
@@ -132,56 +135,78 @@ export class AccessTokenClient {
132
135
  }
133
136
  }
134
137
 
135
- private isPinRequiredValue(requestPayload: UniformCredentialOfferPayload): boolean {
136
- let isPinRequired = false;
138
+ private getPinMetadata(requestPayload: UniformCredentialOfferPayload): TxCodeAndPinRequired {
137
139
  if (!requestPayload) {
138
140
  throw new Error(TokenErrorResponse.invalid_request);
139
141
  }
140
142
  const issuer = getIssuerFromCredentialOfferPayload(requestPayload);
141
- if (requestPayload.grants?.['urn:ietf:params:oauth:grant-type:pre-authorized_code']) {
142
- isPinRequired = requestPayload.grants['urn:ietf:params:oauth:grant-type:pre-authorized_code']?.user_pin_required ?? false;
143
- }
144
- debug(`Pin required for issuer ${issuer}: ${isPinRequired}`);
145
- return isPinRequired;
143
+
144
+ const grantDetails = requestPayload.grants?.['urn:ietf:params:oauth:grant-type:pre-authorized_code'];
145
+ const isPinRequired = !!grantDetails?.tx_code ?? false;
146
+
147
+ LOG.warning(`Pin required for issuer ${issuer}: ${isPinRequired}`);
148
+ return {
149
+ txCode: grantDetails?.tx_code,
150
+ isPinRequired,
151
+ };
146
152
  }
147
153
 
148
- private assertNumericPin(isPinRequired?: boolean, pin?: string): void {
149
- if (isPinRequired) {
150
- if (!pin || !/^\d{1,8}$/.test(pin)) {
151
- debug(`Pin is not 1 to 8 digits long`);
152
- throw new Error('A valid pin consisting of maximal 8 numeric characters must be present.');
154
+ private assertAlphanumericPin(pinMeta?: TxCodeAndPinRequired, pin?: string): void {
155
+ if (pinMeta && pinMeta.isPinRequired) {
156
+ let regex;
157
+
158
+ if (pinMeta.txCode) {
159
+ const { input_mode, length } = pinMeta.txCode;
160
+
161
+ if (input_mode === 'numeric') {
162
+ // Create a regex for numeric input. If no length specified, allow any length of numeric input.
163
+ regex = length ? new RegExp(`^\\d{1,${length}}$`) : /^\d+$/;
164
+ } else if (input_mode === 'text') {
165
+ // Create a regex for text input. If no length specified, allow any length of alphanumeric input.
166
+ regex = length ? new RegExp(`^[a-zA-Z0-9]{1,${length}}$`) : /^[a-zA-Z0-9]+$/;
167
+ }
168
+ }
169
+
170
+ // Default regex for alphanumeric with no specific length limit if no input_mode is specified.
171
+ regex = regex || /^[a-zA-Z0-9]+$|^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+$/;
172
+
173
+ if (!pin || !regex.test(pin)) {
174
+ LOG.warning(
175
+ `Pin is not valid. Expected format: ${pinMeta?.txCode?.input_mode || 'alphanumeric'}, Length: up to ${pinMeta?.txCode?.length || 'any number of'} characters`,
176
+ );
177
+ throw new Error('A valid pin must be present according to the specified transaction code requirements.');
153
178
  }
154
179
  } else if (pin) {
155
- debug(`Pin set, whilst not required`);
156
- throw new Error('Cannot set a pin, when the pin is not required.');
180
+ LOG.warning('Pin set, whilst not required');
181
+ throw new Error('Cannot set a pin when the pin is not required.');
157
182
  }
158
183
  }
159
184
 
160
185
  private assertNonEmptyPreAuthorizedCode(accessTokenRequest: AccessTokenRequest): void {
161
186
  if (!accessTokenRequest[PRE_AUTH_CODE_LITERAL]) {
162
- debug(`No pre-authorized code present, whilst it is required`);
187
+ LOG.warning(`No pre-authorized code present, whilst it is required`, accessTokenRequest);
163
188
  throw new Error('Pre-authorization must be proven by presenting the pre-authorized code. Code must be present.');
164
189
  }
165
190
  }
166
191
 
167
192
  private assertNonEmptyCodeVerifier(accessTokenRequest: AccessTokenRequest): void {
168
193
  if (!accessTokenRequest.code_verifier) {
169
- debug('No code_verifier present, whilst it is required');
194
+ LOG.warning('No code_verifier present, whilst it is required', accessTokenRequest);
170
195
  throw new Error('Authorization flow requires the code_verifier to be present');
171
196
  }
172
197
  }
173
198
 
174
199
  private assertNonEmptyCode(accessTokenRequest: AccessTokenRequest): void {
175
200
  if (!accessTokenRequest.code) {
176
- debug('No code present, whilst it is required');
201
+ LOG.warning('No code present, whilst it is required');
177
202
  throw new Error('Authorization flow requires the code to be present');
178
203
  }
179
204
  }
180
- private validate(accessTokenRequest: AccessTokenRequest, isPinRequired?: boolean): void {
205
+ private validate(accessTokenRequest: AccessTokenRequest, pinMeta?: TxCodeAndPinRequired): void {
181
206
  if (accessTokenRequest.grant_type === GrantTypes.PRE_AUTHORIZED_CODE) {
182
207
  this.assertPreAuthorizedGrantType(accessTokenRequest.grant_type);
183
208
  this.assertNonEmptyPreAuthorizedCode(accessTokenRequest);
184
- this.assertNumericPin(isPinRequired, accessTokenRequest.user_pin);
209
+ this.assertAlphanumericPin(pinMeta, accessTokenRequest.user_pin);
185
210
  } else if (accessTokenRequest.grant_type === GrantTypes.AUTHORIZATION_CODE) {
186
211
  this.assertAuthorizationGrantType(accessTokenRequest.grant_type);
187
212
  this.assertNonEmptyCodeVerifier(accessTokenRequest);
@@ -222,7 +247,7 @@ export class AccessTokenClient {
222
247
  if (!url || !ObjectUtils.isString(url)) {
223
248
  throw new Error('No authorization server token URL present. Cannot acquire access token');
224
249
  }
225
- debug(`Token endpoint determined to be ${url}`);
250
+ LOG.debug(`Token endpoint determined to be ${url}`);
226
251
  return url;
227
252
  }
228
253
 
@@ -239,7 +264,7 @@ export class AccessTokenClient {
239
264
  }
240
265
 
241
266
  private throwNotSupportedFlow(): void {
242
- debug(`Only pre-authorized or authorization code flows supported.`);
267
+ LOG.warning(`Only pre-authorized or authorization code flows supported.`);
243
268
  throw new Error('Only pre-authorized-code or authorization code flows are supported');
244
269
  }
245
270
  }