@pagopa/io-react-native-wallet 2.2.0 → 2.3.0

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 (91) hide show
  1. package/README.md +4 -3
  2. package/lib/commonjs/credential/index.js +3 -1
  3. package/lib/commonjs/credential/index.js.map +1 -1
  4. package/lib/commonjs/credential/offer/01-start-flow.js +75 -0
  5. package/lib/commonjs/credential/offer/01-start-flow.js.map +1 -0
  6. package/lib/commonjs/credential/offer/02-fetch-credential-offer.js +45 -0
  7. package/lib/commonjs/credential/offer/02-fetch-credential-offer.js.map +1 -0
  8. package/lib/commonjs/credential/offer/README.md +174 -0
  9. package/lib/commonjs/credential/offer/errors.js +22 -0
  10. package/lib/commonjs/credential/offer/errors.js.map +1 -0
  11. package/lib/commonjs/credential/offer/index.js +25 -0
  12. package/lib/commonjs/credential/offer/index.js.map +1 -0
  13. package/lib/commonjs/credential/offer/types.js +51 -0
  14. package/lib/commonjs/credential/offer/types.js.map +1 -0
  15. package/lib/commonjs/credential/presentation/01-start-flow.js +1 -1
  16. package/lib/commonjs/credentials-catalogue/README.md +15 -0
  17. package/lib/commonjs/credentials-catalogue/fetch-and-parse-catalogue.js +42 -0
  18. package/lib/commonjs/credentials-catalogue/fetch-and-parse-catalogue.js.map +1 -0
  19. package/lib/commonjs/credentials-catalogue/index.js +13 -0
  20. package/lib/commonjs/credentials-catalogue/index.js.map +1 -0
  21. package/lib/commonjs/credentials-catalogue/types.js +99 -0
  22. package/lib/commonjs/credentials-catalogue/types.js.map +1 -0
  23. package/lib/commonjs/index.js +3 -1
  24. package/lib/commonjs/index.js.map +1 -1
  25. package/lib/commonjs/utils/zod.js +28 -0
  26. package/lib/commonjs/utils/zod.js.map +1 -0
  27. package/lib/module/credential/index.js +2 -1
  28. package/lib/module/credential/index.js.map +1 -1
  29. package/lib/module/credential/offer/01-start-flow.js +66 -0
  30. package/lib/module/credential/offer/01-start-flow.js.map +1 -0
  31. package/lib/module/credential/offer/02-fetch-credential-offer.js +38 -0
  32. package/lib/module/credential/offer/02-fetch-credential-offer.js.map +1 -0
  33. package/lib/module/credential/offer/README.md +174 -0
  34. package/lib/module/credential/offer/errors.js +14 -0
  35. package/lib/module/credential/offer/errors.js.map +1 -0
  36. package/lib/module/credential/offer/index.js +5 -0
  37. package/lib/module/credential/offer/index.js.map +1 -0
  38. package/lib/module/credential/offer/types.js +41 -0
  39. package/lib/module/credential/offer/types.js.map +1 -0
  40. package/lib/module/credential/presentation/01-start-flow.js +1 -1
  41. package/lib/module/credentials-catalogue/README.md +15 -0
  42. package/lib/module/credentials-catalogue/fetch-and-parse-catalogue.js +35 -0
  43. package/lib/module/credentials-catalogue/fetch-and-parse-catalogue.js.map +1 -0
  44. package/lib/module/credentials-catalogue/index.js +2 -0
  45. package/lib/module/credentials-catalogue/index.js.map +1 -0
  46. package/lib/module/credentials-catalogue/types.js +89 -0
  47. package/lib/module/credentials-catalogue/types.js.map +1 -0
  48. package/lib/module/index.js +2 -1
  49. package/lib/module/index.js.map +1 -1
  50. package/lib/module/utils/zod.js +20 -0
  51. package/lib/module/utils/zod.js.map +1 -0
  52. package/lib/typescript/credential/index.d.ts +2 -1
  53. package/lib/typescript/credential/index.d.ts.map +1 -1
  54. package/lib/typescript/credential/issuance/01-start-flow.d.ts +1 -1
  55. package/lib/typescript/credential/offer/01-start-flow.d.ts +172 -0
  56. package/lib/typescript/credential/offer/01-start-flow.d.ts.map +1 -0
  57. package/lib/typescript/credential/offer/02-fetch-credential-offer.d.ts +20 -0
  58. package/lib/typescript/credential/offer/02-fetch-credential-offer.d.ts.map +1 -0
  59. package/lib/typescript/credential/offer/errors.d.ts +10 -0
  60. package/lib/typescript/credential/offer/errors.d.ts.map +1 -0
  61. package/lib/typescript/credential/offer/index.d.ts +7 -0
  62. package/lib/typescript/credential/offer/index.d.ts.map +1 -0
  63. package/lib/typescript/credential/offer/types.d.ts +264 -0
  64. package/lib/typescript/credential/offer/types.d.ts.map +1 -0
  65. package/lib/typescript/credential/presentation/01-start-flow.d.ts +1 -1
  66. package/lib/typescript/credentials-catalogue/fetch-and-parse-catalogue.d.ts +15 -0
  67. package/lib/typescript/credentials-catalogue/fetch-and-parse-catalogue.d.ts.map +1 -0
  68. package/lib/typescript/credentials-catalogue/index.d.ts +3 -0
  69. package/lib/typescript/credentials-catalogue/index.d.ts.map +1 -0
  70. package/lib/typescript/credentials-catalogue/types.d.ts +844 -0
  71. package/lib/typescript/credentials-catalogue/types.d.ts.map +1 -0
  72. package/lib/typescript/index.d.ts +2 -1
  73. package/lib/typescript/index.d.ts.map +1 -1
  74. package/lib/typescript/utils/zod.d.ts +15 -0
  75. package/lib/typescript/utils/zod.d.ts.map +1 -0
  76. package/package.json +21 -2
  77. package/src/credential/index.ts +2 -1
  78. package/src/credential/issuance/01-start-flow.ts +1 -1
  79. package/src/credential/offer/01-start-flow.ts +89 -0
  80. package/src/credential/offer/02-fetch-credential-offer.ts +54 -0
  81. package/src/credential/offer/README.md +174 -0
  82. package/src/credential/offer/errors.ts +17 -0
  83. package/src/credential/offer/index.ts +16 -0
  84. package/src/credential/offer/types.ts +59 -0
  85. package/src/credential/presentation/01-start-flow.ts +1 -1
  86. package/src/credentials-catalogue/README.md +15 -0
  87. package/src/credentials-catalogue/fetch-and-parse-catalogue.ts +54 -0
  88. package/src/credentials-catalogue/index.ts +2 -0
  89. package/src/credentials-catalogue/types.ts +97 -0
  90. package/src/index.ts +2 -0
  91. package/src/utils/zod.ts +28 -0
package/README.md CHANGED
@@ -154,6 +154,7 @@ Different flows are provided to perform common operations. Each flow is a set of
154
154
  - [Attestation](./src/wallet-instance-attestation/README.md)
155
155
  - Credentail
156
156
  - [Issuance](./src/credential/issuance/README.md)
157
+ - [Offer](./src/credential/offer/README.md)
157
158
  - [Presentation](./src/credential/presentation/README.md) (TODO)
158
159
  - [Status](./src/credential/status/README.md)
159
160
  - [Trustmark](./src/credential/trustmark/README.md)
@@ -183,12 +184,12 @@ graph TD;
183
184
  iorni[io-react-native-integrity]
184
185
  iornss[io-react-native-secure-storage]
185
186
  iornjwt[io-react-native-jwt]
186
- rncie[react-native-cie]
187
+ iorncie[io-react-native-cie]
187
188
  rnw(react-native-webview)
188
189
 
189
190
  ioa --> iornw
190
191
  iornw --> iornjwt
191
- iornw --> rncie
192
+ iornw --> iorncie
192
193
  iornw --> rnw
193
194
 
194
195
  subgraph IoApp Deps
@@ -201,7 +202,7 @@ graph TD;
201
202
 
202
203
  subgraph IoRnWallet Deps
203
204
  iornjwt
204
- rncie
205
+ iorncie
205
206
  rnw
206
207
  end
207
208
 
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Trustmark = exports.Status = exports.Presentation = exports.Issuance = void 0;
6
+ exports.Trustmark = exports.Status = exports.Presentation = exports.Offer = exports.Issuance = void 0;
7
7
  var Issuance = _interopRequireWildcard(require("./issuance"));
8
8
  exports.Issuance = Issuance;
9
9
  var Presentation = _interopRequireWildcard(require("./presentation"));
@@ -12,6 +12,8 @@ var Status = _interopRequireWildcard(require("./status"));
12
12
  exports.Status = Status;
13
13
  var Trustmark = _interopRequireWildcard(require("./trustmark"));
14
14
  exports.Trustmark = Trustmark;
15
+ var Offer = _interopRequireWildcard(require("./offer"));
16
+ exports.Offer = Offer;
15
17
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
16
18
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Issuance","_interopRequireWildcard","require","exports","Presentation","Status","Trustmark","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set"],"sourceRoot":"../../../src","sources":["credential/index.ts"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAuCC,OAAA,CAAAH,QAAA,GAAAA,QAAA;AACvC,IAAAI,YAAA,GAAAH,uBAAA,CAAAC,OAAA;AAA+CC,OAAA,CAAAC,YAAA,GAAAA,YAAA;AAC/C,IAAAC,MAAA,GAAAJ,uBAAA,CAAAC,OAAA;AAAmCC,OAAA,CAAAE,MAAA,GAAAA,MAAA;AACnC,IAAAC,SAAA,GAAAL,uBAAA,CAAAC,OAAA;AAAyCC,OAAA,CAAAG,SAAA,GAAAA,SAAA;AAAA,SAAAC,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAP,wBAAAW,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,EAAAW,GAAA,cAAAI,IAAA,KAAAA,IAAA,CAAAV,GAAA,IAAAU,IAAA,CAAAC,GAAA,KAAAR,MAAA,CAAAC,cAAA,CAAAH,MAAA,EAAAK,GAAA,EAAAI,IAAA,YAAAT,MAAA,CAAAK,GAAA,IAAAX,GAAA,CAAAW,GAAA,SAAAL,MAAA,CAAAJ,OAAA,GAAAF,GAAA,MAAAG,KAAA,IAAAA,KAAA,CAAAa,GAAA,CAAAhB,GAAA,EAAAM,MAAA,YAAAA,MAAA"}
1
+ {"version":3,"names":["Issuance","_interopRequireWildcard","require","exports","Presentation","Status","Trustmark","Offer","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set"],"sourceRoot":"../../../src","sources":["credential/index.ts"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAuCC,OAAA,CAAAH,QAAA,GAAAA,QAAA;AACvC,IAAAI,YAAA,GAAAH,uBAAA,CAAAC,OAAA;AAA+CC,OAAA,CAAAC,YAAA,GAAAA,YAAA;AAC/C,IAAAC,MAAA,GAAAJ,uBAAA,CAAAC,OAAA;AAAmCC,OAAA,CAAAE,MAAA,GAAAA,MAA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AhB,GAAA,EAAAM,MAAA,YAAAA,MAAA"}
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.startFlowFromQR = void 0;
7
+ var z = _interopRequireWildcard(require("zod"));
8
+ var _logging = require("../../utils/logging");
9
+ var _zod2 = require("../../utils/zod");
10
+ var _errors = require("./errors");
11
+ var _types = require("./types");
12
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
14
+ const CREDENTIAL_OFFER_SCHEMES = ["openid-credential-offer://", "haip://"];
15
+ const CREDENTIAL_OFFER_PARAM = "credential_offer";
16
+ const CREDENTIAL_OFFER_URI_PARAM = "credential_offer_uri";
17
+ const CredentialOfferParams = z.union([z.object({
18
+ credential_offer: _zod2.stringToJSONSchema.pipe(_types.CredentialOfferSchema),
19
+ credential_offer_uri: z.undefined()
20
+ }), z.object({
21
+ credential_offer: z.undefined(),
22
+ credential_offer_uri: z.string().url()
23
+ })]);
24
+
25
+ /**
26
+ * The beginning of the credential offer flow.
27
+ * To be implemented according to the user touchpoint
28
+ *
29
+ * @param params Credential offer encoded url
30
+ * @returns Object containing the credential offer by reference or by value
31
+ */
32
+
33
+ /**
34
+ * Start a credential offer flow by validating and parse an encoded url
35
+ * extracted from a QR code or a deep link.
36
+ *
37
+ * @param params The encoded url to be validated and parsed
38
+ * @returns Object containing the credential offer by reference or by value
39
+ * @throws If the provided encoded url is not valid
40
+ */
41
+ const startFlowFromQR = encodedUrl => {
42
+ const hasValidScheme = CREDENTIAL_OFFER_SCHEMES.some(prefix => encodedUrl.startsWith(prefix));
43
+ if (!hasValidScheme) {
44
+ throw new _errors.InvalidQRCodeError("Url must have one of the supported schemes");
45
+ }
46
+ const url = new URL(encodedUrl);
47
+ const offerParam = url.searchParams.get(CREDENTIAL_OFFER_PARAM);
48
+ const offerUriParam = url.searchParams.get(CREDENTIAL_OFFER_URI_PARAM);
49
+ if (offerParam) {
50
+ const decoded = decodeURIComponent(offerParam);
51
+ const result = CredentialOfferParams.safeParse({
52
+ credential_offer: decoded
53
+ });
54
+ if (result.success) {
55
+ return result.data;
56
+ }
57
+ _logging.Logger.log(_logging.LogLevel.ERROR, `Invalid credential offer object found in QR Code: ${result.error.message}`);
58
+ throw new _errors.InvalidQRCodeError(result.error.message);
59
+ }
60
+ if (offerUriParam) {
61
+ const decoded = decodeURIComponent(offerUriParam);
62
+ const result = CredentialOfferParams.safeParse({
63
+ credential_offer_uri: decoded
64
+ });
65
+ if (result.success) {
66
+ return result.data;
67
+ }
68
+ _logging.Logger.log(_logging.LogLevel.ERROR, `Invalid credential offer URI found in QR Code: ${result.error.message}`);
69
+ throw new _errors.InvalidQRCodeError(result.error.message);
70
+ }
71
+ _logging.Logger.log(_logging.LogLevel.ERROR, `Invalid credential offer QR Code:`);
72
+ throw new _errors.InvalidQRCodeError("QR Code does not contain valid params");
73
+ };
74
+ exports.startFlowFromQR = startFlowFromQR;
75
+ //# sourceMappingURL=01-start-flow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["z","_interopRequireWildcard","require","_logging","_zod2","_errors","_types","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","CREDENTIAL_OFFER_SCHEMES","CREDENTIAL_OFFER_PARAM","CREDENTIAL_OFFER_URI_PARAM","CredentialOfferParams","union","object","credential_offer","stringToJSONSchema","pipe","CredentialOfferSchema","credential_offer_uri","undefined","string","url","startFlowFromQR","encodedUrl","hasValidScheme","some","prefix","startsWith","InvalidQRCodeError","URL","offerParam","searchParams","offerUriParam","decoded","decodeURIComponent","result","safeParse","success","data","Logger","log","LogLevel","ERROR","error","message","exports"],"sourceRoot":"../../../../src","sources":["credential/offer/01-start-flow.ts"],"mappings":";;;;;;AAAA,IAAAA,CAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAAgD,SAAAK,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAP,wBAAAW,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,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kB,CAACO,MAAM,CAACQ,KAAK,CAACC,OAAO,CAAC;EACpD;EAEAL,eAAM,CAACC,GAAG,CAACC,iBAAQ,CAACC,KAAK,EAAG,mCAAkC,CAAC;EAC/D,MAAM,IAAId,0BAAkB,CAAC,uCAAuC,CAAC;AACvE,CAAC;AAACiB,OAAA,CAAAvB,eAAA,GAAAA,eAAA"}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.fetchCredentialOffer = void 0;
7
+ var _errors = require("../../utils/errors");
8
+ var _logging = require("../../utils/logging");
9
+ var _misc = require("../../utils/misc");
10
+ var _errors2 = require("./errors");
11
+ var _types = require("./types");
12
+ /**
13
+ * Fetches and validates a credential offer from a given URI.
14
+ *
15
+ * This function performs an HTTP GET request to the specified `credentialOfferUri`,
16
+ * expecting a JSON response that matches the `CredentialOfferSchema`. If the response
17
+ * is invalid or does not conform to the schema, an error is logged and an
18
+ * `InvalidCredentialOfferError` is thrown.
19
+ *
20
+ * @param credentialOfferUri - The URI from which to fetch the credential offer.
21
+ * @param context - Optional context object that may provide a custom `appFetch` implementation.
22
+ * @returns The validated credential offer data.
23
+ * @throws {IssuerResponseError} If the HTTP response status is not 200.
24
+ * @throws {InvalidCredentialOfferError} If the response does not match the expected schema.
25
+ */
26
+ const fetchCredentialOffer = async function (uri) {
27
+ let context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
28
+ const {
29
+ appFetch = fetch
30
+ } = context;
31
+ const response = await appFetch(uri, {
32
+ method: "GET",
33
+ headers: {
34
+ Accept: "application/json"
35
+ }
36
+ }).then((0, _misc.hasStatusOrThrow)(200, _errors.IssuerResponseError)).then(reqUri => reqUri.json());
37
+ const credentialOffer = _types.CredentialOfferSchema.safeParse(response);
38
+ if (!credentialOffer.success) {
39
+ _logging.Logger.log(_logging.LogLevel.ERROR, `Invalid credential offer fetched from URI: ${uri} - ${credentialOffer.error.message}`);
40
+ throw new _errors2.InvalidCredentialOfferError(`Invalid credential offer fetched from URI: ${uri} - ${credentialOffer.error.message}`);
41
+ }
42
+ return credentialOffer.data;
43
+ };
44
+ exports.fetchCredentialOffer = fetchCredentialOffer;
45
+ //# sourceMappingURL=02-fetch-credential-offer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_errors","require","_logging","_misc","_errors2","_types","fetchCredentialOffer","uri","context","arguments","length","undefined","appFetch","fetch","response","method","headers","Accept","then","hasStatusOrThrow","IssuerResponseError","reqUri","json","credentialOffer","CredentialOfferSchema","safeParse","success","Logger","log","LogLevel","ERROR","error","message","InvalidCredentialOfferError","data","exports"],"sourceRoot":"../../../../src","sources":["credential/offer/02-fetch-credential-offer.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAJ,OAAA;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMK,oBAAwC,GAAG,eAAAA,CACtDC,GAAW,EAER;EAAA,IADHC,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAEZ,MAAM;IAAEG,QAAQ,GAAGC;EAAM,CAAC,GAAGL,OAAO;EAEpC,MAAMM,QAAQ,GAAG,MAAMF,QAAQ,CAACL,GAAG,EAAE;IACnCQ,MAAM,EAAE,KAAK;IACbC,OAAO,EAAE;MAAEC,MAAM,EAAE;IAAmB;EACxC,CAAC,CAAC,CACCC,IAAI,CAAC,IAAAC,sBAAgB,EAAC,GAAG,EAAEC,2BAAmB,CAAC,CAAC,CAChDF,IAAI,CAAEG,MAAM,IAAKA,MAAM,CAACC,IAAI,CAAC,CAAC,CAAC;EAElC,MAAMC,eAAe,GAAGC,4BAAqB,CAACC,SAAS,CAACX,QAAQ,CAAC;EACjE,IAAI,CAACS,eAAe,CAACG,OAAO,EAAE;IAC5BC,eAAM,CAACC,GAAG,CACRC,iBAAQ,CAACC,KAAK,EACb,8CAA6CvB,GAAI,MAAKgB,eAAe,CAACQ,KAAK,CAACC,OAAQ,EACvF,CAAC;IACD,MAAM,IAAIC,oCAA2B,CAClC,8CAA6C1B,GAAI,MAAKgB,eAAe,CAACQ,KAAK,CAACC,OAAQ,EACvF,CAAC;EACH;EAEA,OAAOT,eAAe,CAACW,IAAI;AAC7B,CAAC;AAACC,OAAA,CAAA7B,oBAAA,GAAAA,oBAAA"}
@@ -0,0 +1,174 @@
1
+ # Credential Offer
2
+
3
+ This flow handles the initial step of credential issuance by processing Credential Offers from Credential Issuers. The Credential Offer contains information about what credentials are available and how they can be obtained. Each step in the flow is imported from the related file which is named with a sequential number.
4
+
5
+ A Credential Offer can be received by the Wallet in two ways: **by value** (complete offer embedded in the URL) or **by reference** (URL pointing to the offer endpoint). The offer specifies which credentials are available and what authorization flows are supported by the issuer.
6
+
7
+ The implementation follows the [OpenID for Verifiable Credential Issuance 1.0](https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html#name-credential-offer-endpoint) specification and supports both Authorization Code flow and Pre-Authorized Code flow.
8
+
9
+ ## Sequence Diagram
10
+
11
+ ```mermaid
12
+ sequenceDiagram
13
+ autonumber
14
+ participant U as User
15
+ participant W as Wallet
16
+ participant CI as Credential Issuer
17
+
18
+ CI->>U: QR Code / Deep Link with Credential Offer
19
+ U->>W: Scan QR / Click Link
20
+ W->>W: startFlowFromQR: Parse offer parameters
21
+ alt Credential Offer by Reference
22
+ W->>CI: fetchCredentialOffer: Fetch offer from URI
23
+ CI->>W: Return Credential Offer JSON
24
+ end
25
+ W->>W: Validate Credential Offer schema
26
+ W->>W: Determine available grant types
27
+ Note over W: Flow continues with credential issuance
28
+ ```
29
+
30
+ ## Grant Types
31
+
32
+ The Credential Offer supports two OAuth 2.0 grant types that determine how authorization is handled:
33
+
34
+ ### Authorization Code Flow
35
+
36
+ Used for interactive flows where user authentication and consent are required at the Authorization Server.
37
+
38
+ - **`issuer_state`** (optional): Binds the authorization request to a specific issuer context
39
+ - **`authorization_server`** (optional): Identifies which authorization server to use when multiple are available
40
+
41
+ ### Pre-Authorized Code Flow
42
+
43
+ Used when the user has already been authenticated and authorized out-of-band. The issuer provides a pre-authorized code that can be exchanged directly for credentials.
44
+
45
+ - **`pre-authorized_code`**: Short-lived single-use authorization code
46
+ - **`tx_code`** (optional): Additional transaction code requirements for security
47
+ - **`authorization_server`** (optional): Identifies which authorization server to use
48
+
49
+ ## Transaction Code Requirements
50
+
51
+ When a transaction code is required for Pre-Authorized Code flow, the following parameters control the user experience:
52
+
53
+ | Parameter | Type | Description |
54
+ | ------------- | ----------------------- | ---------------------------------------------------- |
55
+ | `input_mode` | `"numeric"` \| `"text"` | Character set for the code (default: `"numeric"`) |
56
+ | `length` | number | Expected code length to optimize input UI |
57
+ | `description` | string | User guidance (max 300 chars) for obtaining the code |
58
+
59
+ ## Credential Offer Transmission
60
+
61
+ ### By Value
62
+
63
+ The complete Credential Offer is embedded in the URL parameter:
64
+
65
+ ```
66
+ openid-credential-offer://?credential_offer=%7B%22credential_issuer%22...
67
+ ```
68
+
69
+ ### By Reference
70
+
71
+ A URL points to an endpoint serving the Credential Offer:
72
+
73
+ ```
74
+ openid-credential-offer://?credential_offer_uri=https%3A%2F%2Fserver.example.com%2Foffer
75
+ ```
76
+
77
+ When using by reference, the Wallet fetches the offer via HTTP GET with `Accept: application/json`.
78
+
79
+ ## Mapped Results
80
+
81
+ The following errors are mapped during credential offer processing:
82
+
83
+ | Error | Description |
84
+ | ----------------------------- | ---------------------------------------------------------------------------------- |
85
+ | `InvalidQRCodeError` | The QR code format is invalid or doesn't contain valid credential offer parameters |
86
+ | `InvalidCredentialOfferError` | The credential offer schema validation failed or contains invalid data |
87
+
88
+ ## Examples
89
+
90
+ <details>
91
+ <summary>Credential Offer processing flow</summary>
92
+
93
+ ```ts
94
+ // Parse QR code or deep link
95
+ const qrCode =
96
+ "openid-credential-offer://?credential_offer_uri=https%3A%2F%2Fissuer.example.com%2Foffer";
97
+ const { credential_offer_uri } = startFlowFromQR(qrCode);
98
+
99
+ // Fetch the credential offer if by reference
100
+ const offer = await fetchCredentialOffer(credential_offer_uri, { appFetch });
101
+
102
+ console.log(offer);
103
+ // {
104
+ // credential_issuer: "https://issuer.example.com",
105
+ // credential_configuration_ids: ["UniversityDegree", "DriverLicense"],
106
+ // grants: {
107
+ // authorization_code: {
108
+ // issuer_state: "xyz123"
109
+ // },
110
+ // "urn:ietf:params:oauth:grant-type:pre-authorized_code": {
111
+ // "pre-authorized_code": "SplxlOBeZQQYbYS6WxSbIA",
112
+ // tx_code: {
113
+ // length: 6,
114
+ // input_mode: "numeric",
115
+ // description: "Enter the code sent to your email"
116
+ // }
117
+ // }
118
+ // }
119
+ // }
120
+ ```
121
+
122
+ </details>
123
+
124
+ <details>
125
+ <summary>Pre-Authorized Code with Transaction Code</summary>
126
+
127
+ ```ts
128
+ const offer: CredentialOffer = {
129
+ credential_issuer: "https://university.example.edu",
130
+ credential_configuration_ids: ["DiplomaCredential"],
131
+ grants: {
132
+ "urn:ietf:params:oauth:grant-type:pre-authorized_code": {
133
+ "pre-authorized_code": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9",
134
+ tx_code: {
135
+ length: 4,
136
+ input_mode: "numeric",
137
+ description: "Check your email for the verification code",
138
+ },
139
+ },
140
+ },
141
+ };
142
+
143
+ // The user would need to:
144
+ // 1. Check their email for a 4-digit numeric code
145
+ // 2. Enter it in the wallet when prompted
146
+ // 3. The wallet uses both pre-authorized_code and tx_code in the token request
147
+ ```
148
+
149
+ </details>
150
+
151
+ <details>
152
+ <summary>Authorization Code Flow</summary>
153
+
154
+ ```ts
155
+ const offer: CredentialOffer = {
156
+ credential_issuer: "https://dmv.example.gov",
157
+ credential_configuration_ids: ["org.iso.18013.5.1.mDL"],
158
+ grants: {
159
+ authorization_code: {
160
+ issuer_state: "af0ifjsldkj",
161
+ authorization_server: "https://auth.dmv.example.gov",
162
+ },
163
+ },
164
+ };
165
+
166
+ // This would lead to:
167
+ // 1. User authentication at the authorization server
168
+ // 2. User consent for credential issuance
169
+ // 3. Authorization code returned to wallet
170
+ // 4. Wallet exchanges code for access token
171
+ // 5. Wallet uses access token to request credential
172
+ ```
173
+
174
+ </details>
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.InvalidQRCodeError = exports.InvalidCredentialOfferError = void 0;
7
+ var _errors = require("../../utils/errors");
8
+ class InvalidCredentialOfferError extends _errors.IoWalletError {
9
+ code = "ERR_INVALID_CREDENTIAL_OFFER";
10
+ constructor(message) {
11
+ super(message);
12
+ }
13
+ }
14
+ exports.InvalidCredentialOfferError = InvalidCredentialOfferError;
15
+ class InvalidQRCodeError extends _errors.IoWalletError {
16
+ code = "ERR_INVALID_QR_CODE";
17
+ constructor(message) {
18
+ super(message);
19
+ }
20
+ }
21
+ exports.InvalidQRCodeError = InvalidQRCodeError;
22
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_errors","require","InvalidCredentialOfferError","IoWalletError","code","constructor","message","exports","InvalidQRCodeError"],"sourceRoot":"../../../../src","sources":["credential/offer/errors.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEO,MAAMC,2BAA2B,SAASC,qBAAa,CAAC;EAC7DC,IAAI,GAAG,8BAA8B;EAErCC,WAAWA,CAACC,OAAgB,EAAE;IAC5B,KAAK,CAACA,OAAO,CAAC;EAChB;AACF;AAACC,OAAA,CAAAL,2BAAA,GAAAA,2BAAA;AAEM,MAAMM,kBAAkB,SAASL,qBAAa,CAAC;EACpDC,IAAI,GAAG,qBAAqB;EAE5BC,WAAWA,CAACC,OAAgB,EAAE;IAC5B,KAAK,CAACA,OAAO,CAAC;EAChB;AACF;AAACC,OAAA,CAAAC,kBAAA,GAAAA,kBAAA"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Errors = void 0;
7
+ Object.defineProperty(exports, "fetchCredentialOffer", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _fetchCredentialOffer.fetchCredentialOffer;
11
+ }
12
+ });
13
+ Object.defineProperty(exports, "startFlowFromQR", {
14
+ enumerable: true,
15
+ get: function () {
16
+ return _startFlow.startFlowFromQR;
17
+ }
18
+ });
19
+ var _startFlow = require("./01-start-flow");
20
+ var _fetchCredentialOffer = require("./02-fetch-credential-offer");
21
+ var Errors = _interopRequireWildcard(require("./errors"));
22
+ exports.Errors = Errors;
23
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
24
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_startFlow","require","_fetchCredentialOffer","Errors","_interopRequireWildcard","exports","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set"],"sourceRoot":"../../../../src","sources":["credential/offer/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AAIA,IAAAE,MAAA,GAAAC,uBAAA,CAAAH,OAAA;AAAmCI,OAAA,CAAAF,MAAA,GAAAA,MAAA;AAAA,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAH,wBAAAO,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,EAAAW,GAAA,cAAAI,IAAA,KAAAA,IAAA,CAAAV,GAAA,IAAAU,IAAA,CAAAC,GAAA,KAAAR,MAAA,CAAAC,cAAA,CAAAH,MAAA,EAAAK,GAAA,EAAAI,IAAA,YAAAT,MAAA,CAAAK,GAAA,IAAAX,GAAA,CAAAW,GAAA,SAAAL,MAAA,CAAAJ,OAAA,GAAAF,GAAA,MAAAG,KAAA,IAAAA,KAAA,CAAAa,GAAA,CAAAhB,GAAA,EAAAM,MAAA,YAAAA,MAAA"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.TransactionCodeSchema = exports.PreAuthorizedCodeGrantSchema = exports.GrantsSchema = exports.CredentialOfferSchema = exports.AuthorizationCodeGrantSchema = void 0;
7
+ var _zod = require("zod");
8
+ /**
9
+ * OAuth 2.0 Authorization Code flow parameters.
10
+ */
11
+ const AuthorizationCodeGrantSchema = _zod.z.object({
12
+ issuer_state: _zod.z.string().optional(),
13
+ authorization_server: _zod.z.string().url().optional()
14
+ });
15
+ exports.AuthorizationCodeGrantSchema = AuthorizationCodeGrantSchema;
16
+ /**
17
+ * Transaction Code requirements for Pre-Authorized Code flow.
18
+ */
19
+ const TransactionCodeSchema = _zod.z.object({
20
+ input_mode: _zod.z.enum(["numeric", "text"]).optional(),
21
+ length: _zod.z.number().int().positive().optional(),
22
+ description: _zod.z.string().max(300).optional()
23
+ });
24
+ exports.TransactionCodeSchema = TransactionCodeSchema;
25
+ /**
26
+ * Pre-Authorized Code flow parameters.
27
+ */
28
+ const PreAuthorizedCodeGrantSchema = _zod.z.object({
29
+ "pre-authorized_code": _zod.z.string(),
30
+ tx_code: TransactionCodeSchema.optional(),
31
+ authorization_server: _zod.z.string().url().optional()
32
+ });
33
+ exports.PreAuthorizedCodeGrantSchema = PreAuthorizedCodeGrantSchema;
34
+ /**
35
+ * Supported grant types for Credential Offer.
36
+ */
37
+ const GrantsSchema = _zod.z.object({
38
+ authorization_code: AuthorizationCodeGrantSchema.optional(),
39
+ "urn:ietf:params:oauth:grant-type:pre-authorized_code": PreAuthorizedCodeGrantSchema.optional()
40
+ });
41
+ exports.GrantsSchema = GrantsSchema;
42
+ /**
43
+ * Credential Offer object as defined in OpenID4VCI Section 4.1.1.
44
+ */
45
+ const CredentialOfferSchema = _zod.z.object({
46
+ credential_issuer: _zod.z.string().url(),
47
+ credential_configuration_ids: _zod.z.array(_zod.z.string()).min(1),
48
+ grants: GrantsSchema.optional()
49
+ });
50
+ exports.CredentialOfferSchema = CredentialOfferSchema;
51
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_zod","require","AuthorizationCodeGrantSchema","z","object","issuer_state","string","optional","authorization_server","url","exports","TransactionCodeSchema","input_mode","enum","length","number","int","positive","description","max","PreAuthorizedCodeGrantSchema","tx_code","GrantsSchema","authorization_code","CredentialOfferSchema","credential_issuer","credential_configuration_ids","array","min","grants"],"sourceRoot":"../../../../src","sources":["credential/offer/types.ts"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACO,MAAMC,4BAA4B,GAAGC,MAAC,CAACC,MAAM,CAAC;EACnDC,YAAY,EAAEF,MAAC,CAACG,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EACnCC,oBAAoB,EAAEL,MAAC,CAACG,MAAM,CAAC,CAAC,CAACG,GAAG,CAAC,CAAC,CAACF,QAAQ,CAAC;AAClD,CAAC,CAAC;AAACG,OAAA,CAAAR,4BAAA,GAAAA,4BAAA;AAMH;AACA;AACA;AACO,MAAMS,qBAAqB,GAAGR,MAAC,CAACC,MAAM,CAAC;EAC5CQ,UAAU,EAAET,MAAC,CAACU,IAAI,CAAC,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAACN,QAAQ,CAAC,CAAC;EAClDO,MAAM,EAAEX,MAAC,CAACY,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC,CAACV,QAAQ,CAAC,CAAC;EAC9CW,WAAW,EAAEf,MAAC,CAACG,MAAM,CAAC,CAAC,CAACa,GAAG,CAAC,GAAG,CAAC,CAACZ,QAAQ,CAAC;AAC5C,CAAC,CAAC;AAACG,OAAA,CAAAC,qBAAA,GAAAA,qBAAA;AAIH;AACA;AACA;AACO,MAAMS,4BAA4B,GAAGjB,MAAC,CAACC,MAAM,CAAC;EACnD,qBAAqB,EAAED,MAAC,CAACG,MAAM,CAAC,CAAC;EACjCe,OAAO,EAAEV,qBAAqB,CAACJ,QAAQ,CAAC,CAAC;EACzCC,oBAAoB,EAAEL,MAAC,CAACG,MAAM,CAAC,CAAC,CAACG,GAAG,CAAC,CAAC,CAACF,QAAQ,CAAC;AAClD,CAAC,CAAC;AAACG,OAAA,CAAAU,4BAAA,GAAAA,4BAAA;AAMH;AACA;AACA;AACO,MAAME,YAAY,GAAGnB,MAAC,CAACC,MAAM,CAAC;EACnCmB,kBAAkB,EAAErB,4BAA4B,CAACK,QAAQ,CAAC,CAAC;EAC3D,sDAAsD,EACpDa,4BAA4B,CAACb,QAAQ,CAAC;AAC1C,CAAC,CAAC;AAACG,OAAA,CAAAY,YAAA,GAAAA,YAAA;AAIH;AACA;AACA;AACO,MAAME,qBAAqB,GAAGrB,MAAC,CAACC,MAAM,CAAC;EAC5CqB,iBAAiB,EAAEtB,MAAC,CAACG,MAAM,CAAC,CAAC,CAACG,GAAG,CAAC,CAAC;EACnCiB,4BAA4B,EAAEvB,MAAC,CAACwB,KAAK,CAACxB,MAAC,CAACG,MAAM,CAAC,CAAC,CAAC,CAACsB,GAAG,CAAC,CAAC,CAAC;EACxDC,MAAM,EAAEP,YAAY,CAACf,QAAQ,CAAC;AAChC,CAAC,CAAC;AAACG,OAAA,CAAAc,qBAAA,GAAAA,qBAAA"}
@@ -17,7 +17,7 @@ const PresentationParams = z.object({
17
17
 
18
18
  /**
19
19
  * The beginning of the presentation flow.
20
- * To be implemented accordind to the user touchpoint
20
+ * To be implemented according to the user touchpoint
21
21
  *
22
22
  * @param params Presentation parameters, depending on the starting touchpoint
23
23
  * @returns The url for the Relying Party to connect with
@@ -0,0 +1,15 @@
1
+ # Digital Credentials Catalogue
2
+
3
+ Module that manages the [**Digital Credentials Catalogue**](https://italia.github.io/eid-wallet-it-docs/releases/1.1.0/en/registry-catalogue.html) published by the Trust Anchor.
4
+
5
+ The module allows:
6
+ - Fetching, verifying and parsing the catalogue's JWT.
7
+
8
+ ## Usage
9
+
10
+ ```ts
11
+ // Fetch the catalogue
12
+ const TRUST_ANCHOR_BASE_URL = "https://pre.ta.wallet.ipzs.it";
13
+ const credentialsCatalogue =
14
+ await CredentialsCatalogue.fetchAndParseCatalogue(TRUST_ANCHOR_BASE_URL);
15
+ ```
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.fetchAndParseCatalogue = void 0;
7
+ var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
8
+ var _misc = require("../utils/misc");
9
+ var _errors = require("../utils/errors");
10
+ var _types = require("./types");
11
+ var _buildChain = require("../trust/build-chain");
12
+ /**
13
+ * Fetch and parse the Digital Credential Catalogue from the Trust Anchor.
14
+ * The catalogue's JWT signature is verified against the Trust Anchor's JWKs.
15
+ *
16
+ * @param trustAnchorUrl Base URL of the Trust Anchor
17
+ * @param context.appFetch (optional) fetch API implementation. Default: built-in fetch
18
+ * @returns The Digital Credential Catalogue payload
19
+ */
20
+ const fetchAndParseCatalogue = async function (trustAnchorBaseUrl) {
21
+ let {
22
+ appFetch = fetch
23
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
24
+ const trustAnchorConfig = await (0, _buildChain.getTrustAnchorEntityConfiguration)(trustAnchorBaseUrl);
25
+ const responseText = await appFetch(`${trustAnchorConfig.payload.sub}/.well-known/credential-catalogue`, {
26
+ method: "GET"
27
+ }).then((0, _misc.hasStatusOrThrow)(200)).then(res => res.text());
28
+ const responseJwt = (0, _ioReactNativeJwt.decode)(responseText);
29
+ const catalogueKid = responseJwt.protectedHeader.kid;
30
+ const trustAnchorJwk = trustAnchorConfig.payload.jwks.keys.find(jwk => jwk.kid === catalogueKid);
31
+ if (!trustAnchorJwk) {
32
+ throw new _errors.IoWalletError(`Could not find JWK with kid ${catalogueKid} in Trust Anchor's Entity Configuration`);
33
+ }
34
+ await (0, _ioReactNativeJwt.verify)(responseText, trustAnchorJwk);
35
+ const parsedDigitalCredentialsCatalogue = _types.DigitalCredentialsCatalogue.parse({
36
+ header: responseJwt.protectedHeader,
37
+ payload: responseJwt.payload
38
+ });
39
+ return parsedDigitalCredentialsCatalogue.payload;
40
+ };
41
+ exports.fetchAndParseCatalogue = fetchAndParseCatalogue;
42
+ //# sourceMappingURL=fetch-and-parse-catalogue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_ioReactNativeJwt","require","_misc","_errors","_types","_buildChain","fetchAndParseCatalogue","trustAnchorBaseUrl","appFetch","fetch","arguments","length","undefined","trustAnchorConfig","getTrustAnchorEntityConfiguration","responseText","payload","sub","method","then","hasStatusOrThrow","res","text","responseJwt","decodeJwt","catalogueKid","protectedHeader","kid","trustAnchorJwk","jwks","keys","find","jwk","IoWalletError","verify","parsedDigitalCredentialsCatalogue","DigitalCredentialsCatalogue","parse","header","exports"],"sourceRoot":"../../../src","sources":["credentials-catalogue/fetch-and-parse-catalogue.ts"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMK,sBAAsB,GAAG,eAAAA,CACpCC,kBAA0B,EAE0B;EAAA,IADpD;IAAEC,QAAQ,GAAGC;EAA2B,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAE9C,MAAMG,iBAAiB,GACrB,MAAM,IAAAC,6CAAiC,EAACP,kBAAkB,CAAC;EAE7D,MAAMQ,YAAY,GAAG,MAAMP,QAAQ,CAChC,GAAEK,iBAAiB,CAACG,OAAO,CAACC,GAAI,mCAAkC,EACnE;IAAEC,MAAM,EAAE;EAAM,CAClB,CAAC,CACEC,IAAI,CAAC,IAAAC,sBAAgB,EAAC,GAAG,CAAC,CAAC,CAC3BD,IAAI,CAAEE,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC;EAE5B,MAAMC,WAAW,GAAG,IAAAC,wBAAS,EAACT,YAAY,CAAC;EAC3C,MAAMU,YAAY,GAAGF,WAAW,CAACG,eAAe,CAACC,GAAG;EAEpD,MAAMC,cAAc,GAAGf,iBAAiB,CAACG,OAAO,CAACa,IAAI,CAACC,IAAI,CAACC,IAAI,CAC5DC,GAAG,IAAKA,GAAG,CAACL,GAAG,KAAKF,YACvB,CAAC;EAED,IAAI,CAACG,cAAc,EAAE;IACnB,MAAM,IAAIK,qBAAa,CACpB,+BAA8BR,YAAa,yCAC9C,CAAC;EACH;EAEA,MAAM,IAAAS,wBAAM,EAACnB,YAAY,EAAEa,cAAc,CAAC;EAE1C,MAAMO,iCAAiC,GAAGC,kCAA2B,CAACC,KAAK,CAAC;IAC1EC,MAAM,EAAEf,WAAW,CAACG,eAAe;IACnCV,OAAO,EAAEO,WAAW,CAACP;EACvB,CAAC,CAAC;EAEF,OAAOmB,iCAAiC,CAACnB,OAAO;AAClD,CAAC;AAACuB,OAAA,CAAAjC,sBAAA,GAAAA,sBAAA"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "fetchAndParseCatalogue", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _fetchAndParseCatalogue.fetchAndParseCatalogue;
10
+ }
11
+ });
12
+ var _fetchAndParseCatalogue = require("./fetch-and-parse-catalogue");
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_fetchAndParseCatalogue","require"],"sourceRoot":"../../../src","sources":["credentials-catalogue/index.ts"],"mappings":";;;;;;;;;;;AAAA,IAAAA,uBAAA,GAAAC,OAAA"}