@pagopa/io-react-native-wallet 0.7.3 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (211) hide show
  1. package/README.md +49 -31
  2. package/lib/commonjs/credential/index.js +13 -0
  3. package/lib/commonjs/credential/index.js.map +1 -0
  4. package/lib/commonjs/credential/issuance/01-start-flow.js +2 -0
  5. package/lib/commonjs/credential/issuance/01-start-flow.js.map +1 -0
  6. package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js +26 -0
  7. package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js.map +1 -0
  8. package/lib/commonjs/credential/issuance/03-start-user-authorization.js +119 -0
  9. package/lib/commonjs/credential/issuance/03-start-user-authorization.js.map +1 -0
  10. package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +6 -0
  11. package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -0
  12. package/lib/commonjs/credential/issuance/05-authorize-access.js +63 -0
  13. package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -0
  14. package/lib/commonjs/credential/issuance/06-obtain-credential.js +128 -0
  15. package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -0
  16. package/lib/commonjs/credential/issuance/07-confirm-credential.js +6 -0
  17. package/lib/commonjs/credential/issuance/07-confirm-credential.js.map +1 -0
  18. package/lib/commonjs/credential/issuance/const.js +9 -0
  19. package/lib/commonjs/credential/issuance/const.js.map +1 -0
  20. package/lib/commonjs/credential/issuance/index.js +34 -0
  21. package/lib/commonjs/credential/issuance/index.js.map +1 -0
  22. package/lib/commonjs/credential/presentation/01-start-flow.js +55 -0
  23. package/lib/commonjs/credential/presentation/01-start-flow.js.map +1 -0
  24. package/lib/commonjs/credential/presentation/02-evaluate-rp-trust.js +32 -0
  25. package/lib/commonjs/credential/presentation/02-evaluate-rp-trust.js.map +1 -0
  26. package/lib/commonjs/credential/presentation/03-get-request-object.js +68 -0
  27. package/lib/commonjs/credential/presentation/03-get-request-object.js.map +1 -0
  28. package/lib/commonjs/credential/presentation/04-send-authorization-response.js +139 -0
  29. package/lib/commonjs/credential/presentation/04-send-authorization-response.js.map +1 -0
  30. package/lib/commonjs/credential/presentation/index.js +34 -0
  31. package/lib/commonjs/credential/presentation/index.js.map +1 -0
  32. package/lib/commonjs/{rp → credential/presentation}/types.js +17 -34
  33. package/lib/commonjs/credential/presentation/types.js.map +1 -0
  34. package/lib/commonjs/index.js +10 -61
  35. package/lib/commonjs/index.js.map +1 -1
  36. package/lib/commonjs/pid/index.js +1 -3
  37. package/lib/commonjs/pid/index.js.map +1 -1
  38. package/lib/commonjs/sd-jwt/index.js +1 -1
  39. package/lib/commonjs/sd-jwt/index.js.map +1 -1
  40. package/lib/commonjs/sd-jwt/types.js +1 -1
  41. package/lib/commonjs/sd-jwt/types.js.map +1 -1
  42. package/lib/commonjs/trust/chain.js +32 -4
  43. package/lib/commonjs/trust/chain.js.map +1 -1
  44. package/lib/commonjs/trust/index.js +105 -20
  45. package/lib/commonjs/trust/index.js.map +1 -1
  46. package/lib/commonjs/trust/types.js +54 -35
  47. package/lib/commonjs/trust/types.js.map +1 -1
  48. package/lib/commonjs/utils/crypto.js +4 -10
  49. package/lib/commonjs/utils/crypto.js.map +1 -1
  50. package/lib/commonjs/utils/misc.js +23 -0
  51. package/lib/commonjs/utils/misc.js.map +1 -0
  52. package/lib/commonjs/utils/par.js +86 -0
  53. package/lib/commonjs/utils/par.js.map +1 -0
  54. package/lib/module/credential/index.js +4 -0
  55. package/lib/module/credential/index.js.map +1 -0
  56. package/lib/module/credential/issuance/01-start-flow.js +2 -0
  57. package/lib/module/credential/issuance/01-start-flow.js.map +1 -0
  58. package/lib/module/credential/issuance/02-evaluate-issuer-trust.js +19 -0
  59. package/lib/module/credential/issuance/02-evaluate-issuer-trust.js.map +1 -0
  60. package/lib/module/credential/issuance/03-start-user-authorization.js +109 -0
  61. package/lib/module/credential/issuance/03-start-user-authorization.js.map +1 -0
  62. package/lib/module/credential/issuance/04-complete-user-authorization.js +2 -0
  63. package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -0
  64. package/lib/module/credential/issuance/05-authorize-access.js +55 -0
  65. package/lib/module/credential/issuance/05-authorize-access.js.map +1 -0
  66. package/lib/module/credential/issuance/06-obtain-credential.js +117 -0
  67. package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -0
  68. package/lib/module/credential/issuance/07-confirm-credential.js +2 -0
  69. package/lib/module/credential/issuance/07-confirm-credential.js.map +1 -0
  70. package/lib/module/credential/issuance/const.js +2 -0
  71. package/lib/module/credential/issuance/const.js.map +1 -0
  72. package/lib/module/credential/issuance/index.js +6 -0
  73. package/lib/module/credential/issuance/index.js.map +1 -0
  74. package/lib/module/credential/presentation/01-start-flow.js +46 -0
  75. package/lib/module/credential/presentation/01-start-flow.js.map +1 -0
  76. package/lib/module/credential/presentation/02-evaluate-rp-trust.js +25 -0
  77. package/lib/module/credential/presentation/02-evaluate-rp-trust.js.map +1 -0
  78. package/lib/module/credential/presentation/03-get-request-object.js +60 -0
  79. package/lib/module/credential/presentation/03-get-request-object.js.map +1 -0
  80. package/lib/module/credential/presentation/04-send-authorization-response.js +128 -0
  81. package/lib/module/credential/presentation/04-send-authorization-response.js.map +1 -0
  82. package/lib/module/credential/presentation/index.js +6 -0
  83. package/lib/module/credential/presentation/index.js.map +1 -0
  84. package/lib/module/credential/presentation/types.js +21 -0
  85. package/lib/module/credential/presentation/types.js.map +1 -0
  86. package/lib/module/index.js +4 -5
  87. package/lib/module/index.js.map +1 -1
  88. package/lib/module/pid/index.js +1 -2
  89. package/lib/module/pid/index.js.map +1 -1
  90. package/lib/module/sd-jwt/index.js +1 -1
  91. package/lib/module/sd-jwt/index.js.map +1 -1
  92. package/lib/module/sd-jwt/types.js +1 -1
  93. package/lib/module/sd-jwt/types.js.map +1 -1
  94. package/lib/module/trust/chain.js +30 -3
  95. package/lib/module/trust/chain.js.map +1 -1
  96. package/lib/module/trust/index.js +99 -16
  97. package/lib/module/trust/index.js.map +1 -1
  98. package/lib/module/trust/types.js +50 -31
  99. package/lib/module/trust/types.js.map +1 -1
  100. package/lib/module/utils/crypto.js +2 -8
  101. package/lib/module/utils/crypto.js.map +1 -1
  102. package/lib/module/utils/misc.js +17 -0
  103. package/lib/module/utils/misc.js.map +1 -0
  104. package/lib/module/utils/par.js +74 -0
  105. package/lib/module/utils/par.js.map +1 -0
  106. package/lib/typescript/credential/index.d.ts +4 -0
  107. package/lib/typescript/credential/index.d.ts.map +1 -0
  108. package/lib/typescript/credential/issuance/01-start-flow.d.ts +11 -0
  109. package/lib/typescript/credential/issuance/01-start-flow.d.ts.map +1 -0
  110. package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts +18 -0
  111. package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts.map +1 -0
  112. package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts +31 -0
  113. package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts.map +1 -0
  114. package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts +16 -0
  115. package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts.map +1 -0
  116. package/lib/typescript/credential/issuance/05-authorize-access.d.ts +26 -0
  117. package/lib/typescript/credential/issuance/05-authorize-access.d.ts.map +1 -0
  118. package/lib/typescript/credential/issuance/06-obtain-credential.d.ts +32 -0
  119. package/lib/typescript/credential/issuance/06-obtain-credential.d.ts.map +1 -0
  120. package/lib/typescript/credential/issuance/07-confirm-credential.d.ts +11 -0
  121. package/lib/typescript/credential/issuance/07-confirm-credential.d.ts.map +1 -0
  122. package/lib/typescript/credential/issuance/const.d.ts +2 -0
  123. package/lib/typescript/credential/issuance/const.d.ts.map +1 -0
  124. package/lib/typescript/credential/issuance/index.d.ts +10 -0
  125. package/lib/typescript/credential/issuance/index.d.ts.map +1 -0
  126. package/lib/typescript/credential/presentation/01-start-flow.d.ts +20 -0
  127. package/lib/typescript/credential/presentation/01-start-flow.d.ts.map +1 -0
  128. package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts +18 -0
  129. package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts.map +1 -0
  130. package/lib/typescript/credential/presentation/03-get-request-object.d.ts +25 -0
  131. package/lib/typescript/credential/presentation/03-get-request-object.d.ts.map +1 -0
  132. package/lib/typescript/credential/presentation/04-send-authorization-response.d.ts +34 -0
  133. package/lib/typescript/credential/presentation/04-send-authorization-response.d.ts.map +1 -0
  134. package/lib/typescript/credential/presentation/index.d.ts +7 -0
  135. package/lib/typescript/credential/presentation/index.d.ts.map +1 -0
  136. package/lib/typescript/credential/presentation/types.d.ts +49 -0
  137. package/lib/typescript/credential/presentation/types.d.ts.map +1 -0
  138. package/lib/typescript/index.d.ts +4 -5
  139. package/lib/typescript/index.d.ts.map +1 -1
  140. package/lib/typescript/pid/index.d.ts +1 -2
  141. package/lib/typescript/pid/index.d.ts.map +1 -1
  142. package/lib/typescript/sd-jwt/index.d.ts +2 -2
  143. package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
  144. package/lib/typescript/sd-jwt/types.d.ts +5 -5
  145. package/lib/typescript/trust/chain.d.ts +12 -3
  146. package/lib/typescript/trust/chain.d.ts.map +1 -1
  147. package/lib/typescript/trust/index.d.ts +198 -24
  148. package/lib/typescript/trust/index.d.ts.map +1 -1
  149. package/lib/typescript/trust/types.d.ts +1299 -623
  150. package/lib/typescript/trust/types.d.ts.map +1 -1
  151. package/lib/typescript/utils/crypto.d.ts +1 -1
  152. package/lib/typescript/utils/crypto.d.ts.map +1 -1
  153. package/lib/typescript/utils/dpop.d.ts +2 -2
  154. package/lib/typescript/utils/misc.d.ts +8 -0
  155. package/lib/typescript/utils/misc.d.ts.map +1 -0
  156. package/lib/typescript/utils/par.d.ts +68 -0
  157. package/lib/typescript/utils/par.d.ts.map +1 -0
  158. package/package.json +2 -2
  159. package/src/credential/index.ts +4 -0
  160. package/src/credential/issuance/01-start-flow.ts +10 -0
  161. package/src/credential/issuance/02-evaluate-issuer-trust.ts +31 -0
  162. package/src/credential/issuance/03-start-user-authorization.ts +138 -0
  163. package/src/credential/issuance/04-complete-user-authorization.ts +17 -0
  164. package/src/credential/issuance/05-authorize-access.ts +92 -0
  165. package/src/credential/issuance/06-obtain-credential.ts +179 -0
  166. package/src/credential/issuance/07-confirm-credential.ts +14 -0
  167. package/src/credential/issuance/const.ts +2 -0
  168. package/src/credential/issuance/index.ts +32 -0
  169. package/src/credential/presentation/01-start-flow.ts +51 -0
  170. package/src/credential/presentation/02-evaluate-rp-trust.ts +33 -0
  171. package/src/credential/presentation/03-get-request-object.ts +85 -0
  172. package/src/credential/presentation/04-send-authorization-response.ts +168 -0
  173. package/src/credential/presentation/index.ts +26 -0
  174. package/src/credential/presentation/types.ts +27 -0
  175. package/src/index.ts +7 -28
  176. package/src/pid/index.ts +1 -2
  177. package/src/sd-jwt/index.ts +2 -2
  178. package/src/sd-jwt/types.ts +1 -1
  179. package/src/trust/chain.ts +45 -3
  180. package/src/trust/index.ts +136 -19
  181. package/src/trust/types.ts +57 -35
  182. package/src/utils/crypto.ts +2 -8
  183. package/src/utils/misc.ts +23 -0
  184. package/src/utils/par.ts +103 -0
  185. package/lib/commonjs/pid/issuing.js +0 -276
  186. package/lib/commonjs/pid/issuing.js.map +0 -1
  187. package/lib/commonjs/rp/__test__/index.test.js +0 -172
  188. package/lib/commonjs/rp/__test__/index.test.js.map +0 -1
  189. package/lib/commonjs/rp/index.js +0 -239
  190. package/lib/commonjs/rp/index.js.map +0 -1
  191. package/lib/commonjs/rp/types.js.map +0 -1
  192. package/lib/module/pid/issuing.js +0 -266
  193. package/lib/module/pid/issuing.js.map +0 -1
  194. package/lib/module/rp/__test__/index.test.js +0 -168
  195. package/lib/module/rp/__test__/index.test.js.map +0 -1
  196. package/lib/module/rp/index.js +0 -228
  197. package/lib/module/rp/index.js.map +0 -1
  198. package/lib/module/rp/types.js +0 -36
  199. package/lib/module/rp/types.js.map +0 -1
  200. package/lib/typescript/pid/issuing.d.ts +0 -57
  201. package/lib/typescript/pid/issuing.d.ts.map +0 -1
  202. package/lib/typescript/rp/__test__/index.test.d.ts +0 -2
  203. package/lib/typescript/rp/__test__/index.test.d.ts.map +0 -1
  204. package/lib/typescript/rp/index.d.ts +0 -43
  205. package/lib/typescript/rp/index.d.ts.map +0 -1
  206. package/lib/typescript/rp/types.d.ts +0 -122
  207. package/lib/typescript/rp/types.d.ts.map +0 -1
  208. package/src/pid/issuing.ts +0 -405
  209. package/src/rp/__test__/index.test.ts +0 -250
  210. package/src/rp/index.ts +0 -287
  211. package/src/rp/types.ts +0 -42
@@ -3,11 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.verifyTrustChain = verifyTrustChain;
6
+ exports.renewTrustChain = renewTrustChain;
7
+ exports.validateTrustChain = validateTrustChain;
7
8
  var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
8
9
  var _types = require("./types");
9
10
  var _errors = require("../utils/errors");
10
11
  var z = _interopRequireWildcard(require("zod"));
12
+ var _ = require(".");
11
13
  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); }
12
14
  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; }
13
15
  // Verify a token signature
@@ -48,12 +50,12 @@ const LastElementShape = z.union([_types.EntityStatement, _types.TrustAnchorEnti
48
50
  /**
49
51
  * Validates a provided trust chain against a known trust
50
52
  *
51
- * @param trustAnchorEntity
52
- * @param chain
53
+ * @param trustAnchorEntity The entity configuration of the known trust anchor
54
+ * @param chain The chain of statements to be validate
53
55
  * @returns The list of parsed token representing the chain
54
56
  * @throws {IoWalletError} If the chain is not valid
55
57
  */
56
- async function verifyTrustChain(trustAnchorEntity, chain) {
58
+ async function validateTrustChain(trustAnchorEntity, chain) {
57
59
  // If the chain is empty, fail
58
60
  if (chain.length === 0) {
59
61
  throw new _errors.IoWalletError("Cannot verify empty trust chain");
@@ -91,4 +93,30 @@ async function verifyTrustChain(trustAnchorEntity, chain) {
91
93
  // If there is no next, hence it's the end of the chain and it must be verified by the Trust Anchor
92
94
  return Promise.all(chain.map((token, i) => [token, selectKid(i), selectKeys(i)]).map(args => verify(...args)));
93
95
  }
96
+
97
+ /**
98
+ * Given a trust chain, obtain a new trust chain by fetching each element's fresh version
99
+ *
100
+ * @param chain The original chain
101
+ * @param appFetch (optional) fetch api implementation
102
+ * @returns A list of signed token that reprensent the trust chain, in the same order of the provided chain
103
+ * @throws When an element of the chain fails to parse
104
+ */
105
+ function renewTrustChain(chain) {
106
+ let appFetch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : fetch;
107
+ return Promise.all(chain
108
+ // Decode each item to determine its shape
109
+ .map(decode).map(e => [_types.EntityStatement.safeParse(e), _types.EntityConfiguration.safeParse(e)])
110
+ // fetch the element according to its shape
111
+ .map((_ref, i) => {
112
+ let [es, ec] = _ref;
113
+ return ec.success ? (0, _.getSignedEntityConfiguration)(ec.data.payload.iss, {
114
+ appFetch
115
+ }) : es.success ? (0, _.getSignedEntityStatement)(es.data.payload.iss, es.data.payload.sub, {
116
+ appFetch
117
+ }) :
118
+ // if the element fail to parse in both EntityStatement and EntityConfiguration, raise an error
119
+ Promise.reject(new _errors.IoWalletError(`Cannot renew trust chain because the element #${i} failed to be parsed.`));
120
+ }));
121
+ }
94
122
  //# sourceMappingURL=chain.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_ioReactNativeJwt","require","_types","_errors","z","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","verify","token","kid","jwks","jwk","find","k","Error","protectedHeader","header","payload","verifyJwt","decode","decodeJwt","FirstElementShape","EntityConfiguration","MiddleElementShape","EntityStatement","LastElementShape","union","TrustAnchorEntityConfiguration","verifyTrustChain","trustAnchorEntity","chain","length","IoWalletError","selectTokenShape","elementIndex","selectKid","currentIndex","shape","parse","selectKeys","keys","nextIndex","nextToken","Promise","all","map","i","args"],"sourceRoot":"../../../src","sources":["trust/chain.ts"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAIA,IAAAC,MAAA,GAAAD,OAAA;AAMA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,CAAA,GAAAC,uBAAA,CAAAJ,OAAA;AAAyB,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,SAAAF,wBAAAM,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,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CAACC,SAAS,EAAE;MACd,MAAM,IAAIV,qBAAa,CAAE,qCAAoC,CAAC;IAChE;IACA,MAAMK,KAAK,GAAGJ,gBAAgB,CAACQ,SAAS,CAAC;IACzC,OAAOJ,KAAK,CAACC,KAAK,CAACnB,MAAM,CAACuB,SAAS,CAAC,CAAC,CAACzB,OAAO,CAACP,IAAI,CAAC8B,IAAI;EACzD,CAAC;;EAED;EACA;EACA,OAAOG,OAAO,CAACC,GAAG,CAChBd,KAAK,CACFe,GAAG,CAAC,CAACrC,KAAK,EAAEsC,CAAC,KAAK,CAACtC,KAAK,EAAE2B,SAAS,CAACW,CAAC,CAAC,EAAEP,UAAU,CAACO,CAAC,CAAC,CAAU,CAAC,CAChED,GAAG,CAAEE,IAAI,IAAKxC,MAAM,CAAC,GAAGwC,IAAI,CAAC,CAClC,CAAC;AACH"}
1
+ {"version":3,"names":["_ioReactNativeJwt","require","_types","_errors","z","_interopRequireWildcard","_","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","verify","token","kid","jwks","jwk","find","k","Error","protectedHeader","header","payload","verifyJwt","decode","decodeJwt","FirstElementShape","EntityConfiguration","MiddleElementShape","EntityStatement","LastElementShape","union","TrustAnchorEntityConfiguration","validateTrustChain","trustAnchorEntity","chain","length","IoWalletError","selectTokenShape","elementIndex","selectKid","currentIndex","shape","parse","selectKeys","keys","nextIndex","nextToken","Promise","all","map","i","args","renewTrustChain","appFetch","arguments","undefined","fetch","e","safeParse","_ref","es","ec","success","getSignedEntityConfiguration","data","iss","getSignedEntityStatement","sub","reject"],"sourceRoot":"../../../src","sources":["trust/chain.ts"],"mappings":";;;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAIA,IAAAC,MAAA,GAAAD,OAAA;AAMA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG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QAAAC,SAAA,GAAAD,SAAA,MAAGE,KAAK;EAEtC,OAAOT,OAAO,CAACC,GAAG,CAChBd;EACE;EAAA,CACCe,GAAG,CAAC1B,MAAM,CAAC,CACX0B,GAAG,CACDQ,CAAC,IACA,CACE7B,sBAAe,CAAC8B,SAAS,CAACD,CAAC,CAAC,EAC5B/B,0BAAmB,CAACgC,SAAS,CAACD,CAAC,CAAC,CAEtC;EACA;EAAA,CACCR,GAAG,CAAC,CAAAU,IAAA,EAAWT,CAAC;IAAA,IAAX,CAACU,EAAE,EAAEC,EAAE,CAAC,GAAAF,IAAA;IAAA,OACZE,EAAE,CAACC,OAAO,GACN,IAAAC,8BAA4B,EAACF,EAAE,CAACG,IAAI,CAAC3C,OAAO,CAAC4C,GAAG,EAAE;MAAEZ;IAAS,CAAC,CAAC,GAC/DO,EAAE,CAACE,OAAO,GACV,IAAAI,0BAAwB,EAACN,EAAE,CAACI,IAAI,CAAC3C,OAAO,CAAC4C,GAAG,EAAEL,EAAE,CAACI,IAAI,CAAC3C,OAAO,CAAC8C,GAAG,EAAE;MACjEd;IACF,CAAC,CAAC;IACF;IACAN,OAAO,CAACqB,MAAM,CACZ,IAAIhC,qBAAa,CACd,iDAAgDc,CAAE,uBACrD,CACF,CAAC;EAAA,CACP,CACJ,CAAC;AACH"}
@@ -3,17 +3,62 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getWalletProviderEntityConfiguration = exports.getTrustAnchorEntityConfiguration = exports.getRelyingPartyEntityConfiguration = exports.getEntityConfiguration = exports.getCredentialIssuerEntityConfiguration = void 0;
7
- Object.defineProperty(exports, "verifyTrustChain", {
8
- enumerable: true,
9
- get: function () {
10
- return _chain.verifyTrustChain;
11
- }
12
- });
6
+ exports.getEntityConfiguration = exports.getCredentialIssuerEntityConfiguration = void 0;
7
+ exports.getEntityStatement = getEntityStatement;
8
+ exports.getRelyingPartyEntityConfiguration = void 0;
9
+ exports.getSignedEntityConfiguration = getSignedEntityConfiguration;
10
+ exports.getSignedEntityStatement = getSignedEntityStatement;
11
+ exports.getWalletProviderEntityConfiguration = exports.getTrustAnchorEntityConfiguration = void 0;
12
+ exports.verifyTrustChain = verifyTrustChain;
13
13
  var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
14
14
  var _types = require("./types");
15
- var _errors = require("../utils/errors");
16
15
  var _chain = require("./chain");
16
+ var _misc = require("../utils/misc");
17
+ /**
18
+ * Verify a given trust chain is actually valid.
19
+ * It can handle fast chain renewal, which means we try to fetch a fresh version of each statement.
20
+ *
21
+ * @param trustAnchorEntity The entity configuration of the known trust anchor
22
+ * @param chain The chain of statements to be validate
23
+ * @param options.renewOnFail Whether to renew the provided chain if the validation fails at first. Default: true
24
+ * @param options.appFetch Fetch api implementation. Default: the built-in implementation
25
+ * @returns The result of the chain validation
26
+ * @throws {IoWalletError} When either validation or renewal fail
27
+ */
28
+ async function verifyTrustChain(trustAnchorEntity, chain) {
29
+ let {
30
+ appFetch = fetch,
31
+ renewOnFail = true
32
+ } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
33
+ try {
34
+ return (0, _chain.validateTrustChain)(trustAnchorEntity, chain);
35
+ } catch (error) {
36
+ if (renewOnFail) {
37
+ const renewedChain = await (0, _chain.renewTrustChain)(chain, appFetch);
38
+ return (0, _chain.validateTrustChain)(trustAnchorEntity, renewedChain);
39
+ } else {
40
+ throw error;
41
+ }
42
+ }
43
+ }
44
+
45
+ /**
46
+ * Fetch the signed entity configuration token for an entity
47
+ *
48
+ * @param entityBaseUrl The url of the entity to fetch
49
+ * @param param.appFetch (optional) fetch api implemention
50
+ * @returns The signed Entity Configuration token
51
+ */
52
+ async function getSignedEntityConfiguration(entityBaseUrl) {
53
+ let {
54
+ appFetch = fetch
55
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
56
+ const wellKnownUrl = `${entityBaseUrl}/.well-known/openid-federation`;
57
+ return await appFetch(wellKnownUrl, {
58
+ method: "GET"
59
+ }).then((0, _misc.hasStatus)(200)).then(res => res.text());
60
+ }
61
+
17
62
  /**
18
63
  * Fetch and parse the entity configuration document for a given federation entity.
19
64
  * This is an inner method to serve public interfaces.
@@ -36,19 +81,14 @@ async function fetchAndParseEntityConfiguration(entityBaseUrl, schema) {
36
81
  let {
37
82
  appFetch = fetch
38
83
  } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
39
- const wellKnownUrl = `${entityBaseUrl}/.well-known/openid-federation`;
40
- const response = await appFetch(wellKnownUrl, {
41
- method: "GET"
84
+ const responseText = await getSignedEntityConfiguration(entityBaseUrl, {
85
+ appFetch
86
+ });
87
+ const responseJwt = (0, _ioReactNativeJwt.decode)(responseText);
88
+ return schema.parse({
89
+ header: responseJwt.protectedHeader,
90
+ payload: responseJwt.payload
42
91
  });
43
- if (response.status === 200) {
44
- const responseText = await response.text();
45
- const responseJwt = (0, _ioReactNativeJwt.decode)(responseText);
46
- return schema.parse({
47
- header: responseJwt.protectedHeader,
48
- payload: responseJwt.payload
49
- });
50
- }
51
- throw new _errors.IoWalletError(`Unable to obtain Entity Configuration at ${wellKnownUrl}. Response code: ${response.status}`);
52
92
  }
53
93
  const getWalletProviderEntityConfiguration = (entityBaseUrl, options) => fetchAndParseEntityConfiguration(entityBaseUrl, _types.WalletProviderEntityConfiguration, options);
54
94
  exports.getWalletProviderEntityConfiguration = getWalletProviderEntityConfiguration;
@@ -59,5 +99,50 @@ exports.getTrustAnchorEntityConfiguration = getTrustAnchorEntityConfiguration;
59
99
  const getRelyingPartyEntityConfiguration = (entityBaseUrl, options) => fetchAndParseEntityConfiguration(entityBaseUrl, _types.RelyingPartyEntityConfiguration, options);
60
100
  exports.getRelyingPartyEntityConfiguration = getRelyingPartyEntityConfiguration;
61
101
  const getEntityConfiguration = (entityBaseUrl, options) => fetchAndParseEntityConfiguration(entityBaseUrl, _types.EntityConfiguration, options);
102
+
103
+ /**
104
+ * Fetch and parse the entity statement document for a given federation entity.
105
+ *
106
+ * @param accreditationBodyBaseUrl The base url of the accreditaion body which holds and signs the required entity statement
107
+ * @param subordinatedEntityBaseUrl The url that identifies the subordinate entity
108
+ * @param options.appFetch An optional instance of the http client to be used.
109
+ * @returns The parsed entity configuration object
110
+ * @throws {IoWalletError} If the http request fails
111
+ * @throws Parse error if the document is not in the expected shape.
112
+ */
62
113
  exports.getEntityConfiguration = getEntityConfiguration;
114
+ async function getEntityStatement(accreditationBodyBaseUrl, subordinatedEntityBaseUrl) {
115
+ let {
116
+ appFetch = fetch
117
+ } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
118
+ const responseText = await getSignedEntityStatement(accreditationBodyBaseUrl, subordinatedEntityBaseUrl, {
119
+ appFetch
120
+ });
121
+ const responseJwt = (0, _ioReactNativeJwt.decode)(responseText);
122
+ return _types.EntityStatement.parse({
123
+ header: responseJwt.protectedHeader,
124
+ payload: responseJwt.payload
125
+ });
126
+ }
127
+
128
+ /**
129
+ * Fetch the entity statement document for a given federation entity.
130
+ *
131
+ * @param accreditationBodyBaseUrl The base url of the accreditaion body which holds and signs the required entity statement
132
+ * @param subordinatedEntityBaseUrl The url that identifies the subordinate entity
133
+ * @param options.appFetch An optional instance of the http client to be used.
134
+ * @returns The signed entity statement token
135
+ * @throws {IoWalletError} If the http request fails
136
+ */
137
+ async function getSignedEntityStatement(accreditationBodyBaseUrl, subordinatedEntityBaseUrl) {
138
+ let {
139
+ appFetch = fetch
140
+ } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
141
+ const url = `${accreditationBodyBaseUrl}/fetch?${new URLSearchParams({
142
+ sub: subordinatedEntityBaseUrl
143
+ })}`;
144
+ return await appFetch(url, {
145
+ method: "GET"
146
+ }).then((0, _misc.hasStatus)(200)).then(res => res.text());
147
+ }
63
148
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_ioReactNativeJwt","require","_types","_errors","_chain","fetchAndParseEntityConfiguration","entityBaseUrl","schema","appFetch","fetch","arguments","length","undefined","wellKnownUrl","response","method","status","responseText","text","responseJwt","decodeJwt","parse","header","protectedHeader","payload","IoWalletError","getWalletProviderEntityConfiguration","options","WalletProviderEntityConfiguration","exports","getCredentialIssuerEntityConfiguration","CredentialIssuerEntityConfiguration","getTrustAnchorEntityConfiguration","TrustAnchorEntityConfiguration","getRelyingPartyEntityConfiguration","RelyingPartyEntityConfiguration","getEntityConfiguration","EntityConfiguration"],"sourceRoot":"../../../src","sources":["trust/index.ts"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAOA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAoCA,eAAeI,gCAAgCA,CAC7CC,aAAqB,EACrBC,MAK8B,EAM9B;EAAA,IALA;IACEC,QAAQ,GAAGC;EAGb,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAEN,MAAMG,YAAY,GAAI,GAAEP,aAAc,gCAA+B;EAErE,MAAMQ,QAAQ,GAAG,MAAMN,QAAQ,CAACK,YAAY,EAAE;IAC5CE,MAAM,EAAE;EACV,CAAC,CAAC;EAEF,IAAID,QAAQ,CAACE,MAAM,KAAK,GAAG,EAAE;IAC3B,MAAMC,YAAY,GAAG,MAAMH,QAAQ,CAACI,IAAI,CAAC,CAAC;IAC1C,MAAMC,WAAW,GAAG,IAAAC,wBAAS,EAACH,YAAY,CAAC;IAC3C,OAAOV,MAAM,CAACc,KAAK,CAAC;MAClBC,MAAM,EAAEH,WAAW,CAACI,eAAe;MACnCC,OAAO,EAAEL,WAAW,CAACK;IACvB,CAAC,CAAC;EACJ;EAEA,MAAM,IAAIC,qBAAa,CACpB,4CAA2CZ,YAAa,oBAAmBC,QAAQ,CAACE,MAAO,EAC9F,CAAC;AACH;AAEO,MAAMU,oCAAoC,GAAGA,CAClDpB,aAAqE,EACrEqB,OAAgE,KAEhEtB,gCAAgC,CAC9BC,aAAa,EACbsB,wCAAiC,EACjCD,OACF,CAAC;AAACE,OAAA,CAAAH,oCAAA,GAAAA,oCAAA;AAEG,MAAMI,sCAAsC,GAAGA,CACpDxB,aAAqE,EACrEqB,OAAgE,KAEhEtB,gCAAgC,CAC9BC,aAAa,EACbyB,0CAAmC,EACnCJ,OACF,CAAC;AAACE,OAAA,CAAAC,sCAAA,GAAAA,sCAAA;AAEG,MAAME,iCAAiC,GAAGA,CAC/C1B,aAAqE,EACrEqB,OAAgE,KAEhEtB,gCAAgC,CAC9BC,aAAa,EACb2B,qCAA8B,EAC9BN,OACF,CAAC;AAACE,OAAA,CAAAG,iCAAA,GAAAA,iCAAA;AAEG,MAAME,kCAAkC,GAAGA,CAChD5B,aAAqE,EACrEqB,OAAgE,KAEhEtB,gCAAgC,CAC9BC,aAAa,EACb6B,sCAA+B,EAC/BR,OACF,CAAC;AAACE,OAAA,CAAAK,kCAAA,GAAAA,kCAAA;AAEG,MAAME,sBAAsB,GAAGA,CACpC9B,aAAqE,EACrEqB,OAAgE,KAEhEtB,gCAAgC,CAACC,aAAa,EAAE+B,0BAAmB,EAAEV,OAAO,CAAC;AAACE,OAAA,CAAAO,sBAAA,GAAAA,sBAAA"}
1
+ {"version":3,"names":["_ioReactNativeJwt","require","_types","_chain","_misc","verifyTrustChain","trustAnchorEntity","chain","appFetch","fetch","renewOnFail","arguments","length","undefined","validateTrustChain","error","renewedChain","renewTrustChain","getSignedEntityConfiguration","entityBaseUrl","wellKnownUrl","method","then","hasStatus","res","text","fetchAndParseEntityConfiguration","schema","responseText","responseJwt","decodeJwt","parse","header","protectedHeader","payload","getWalletProviderEntityConfiguration","options","WalletProviderEntityConfiguration","exports","getCredentialIssuerEntityConfiguration","CredentialIssuerEntityConfiguration","getTrustAnchorEntityConfiguration","TrustAnchorEntityConfiguration","getRelyingPartyEntityConfiguration","RelyingPartyEntityConfiguration","getEntityConfiguration","EntityConfiguration","getEntityStatement","accreditationBodyBaseUrl","subordinatedEntityBaseUrl","getSignedEntityStatement","EntityStatement","url","URLSearchParams","sub"],"sourceRoot":"../../../src","sources":["trust/index.ts"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAQA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeI,gBAAgBA,CACpCC,iBAAiD,EACjDC,KAAe,EAKiC;EAAA,IAJhD;IACEC,QAAQ,GAAGC,KAAK;IAChBC,WAAW,GAAG;EAC4C,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAElE,IAAI;IACF,OAAO,IAAAG,yBAAkB,EAACR,iBAAiB,EAAEC,KAAK,CAAC;EACrD,CAAC,CAAC,OAAOQ,KAAK,EAAE;IACd,IAAIL,WAAW,EAAE;MACf,MAAMM,YAAY,GAAG,MAAM,IAAAC,sBAAe,EAACV,KAAK,EAAEC,QAAQ,CAAC;MAC3D,OAAO,IAAAM,yBAAkB,EAACR,iBAAiB,EAAEU,YAAY,CAAC;IAC5D,CAAC,MAAM;MACL,MAAMD,KAAK;IACb;EACF;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeG,4BAA4BA,CAChDC,aAAqB,EAMJ;EAAA,IALjB;IACEX,QAAQ,GAAGC;EAGb,CAAC,GAAAE,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAEN,MAAMS,YAAY,GAAI,GAAED,aAAc,gCAA+B;EAErE,OAAO,MAAMX,QAAQ,CAACY,YAAY,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AMzC,QAAQ,CAAC4C,GAAG,EAAE;IACzB/B,MAAM,EAAE;EACV,CAAC,CAAC,CACCC,IAAI,CAAC,IAAAC,eAAS,EAAC,GAAG,CAAC,CAAC,CACpBD,IAAI,CAAEE,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC;AAC9B"}
@@ -13,10 +13,20 @@ const TrustMark = z.object({
13
13
  id: z.string(),
14
14
  trust_mark: z.string()
15
15
  });
16
+ exports.TrustMark = TrustMark;
17
+ const RelyingPartyMetadata = z.object({
18
+ application_type: z.string().optional(),
19
+ client_id: z.string().optional(),
20
+ client_name: z.string().optional(),
21
+ jwks: z.object({
22
+ keys: z.array(_jwk.JWK)
23
+ }),
24
+ contacts: z.array(z.string()).optional()
25
+ });
26
+ //.passthrough();
16
27
 
17
28
  // Display metadata for a credential, used by the issuer to
18
29
  // instruct the Wallet Solution on how to render the credential correctly
19
- exports.TrustMark = TrustMark;
20
30
  const CredentialDisplayMetadata = z.object({
21
31
  name: z.string(),
22
32
  locale: z.string(),
@@ -27,14 +37,26 @@ const CredentialDisplayMetadata = z.object({
27
37
  background_color: z.string(),
28
38
  text_color: z.string()
29
39
  });
40
+ const CredentialDefinitionMetadata = z.object({
41
+ type: z.array(z.string()),
42
+ credentialSubject: z.record(z.object({
43
+ mandatory: z.boolean(),
44
+ display: z.array(z.object({
45
+ name: z.string(),
46
+ locale: z.string()
47
+ }))
48
+ }))
49
+ });
30
50
 
31
51
  // Metadata for a credentia which i supported by a Issuer
32
52
 
33
53
  const SupportedCredentialMetadata = z.object({
54
+ id: z.string(),
34
55
  format: z.literal("vc+sd-jwt"),
35
56
  cryptographic_binding_methods_supported: z.array(z.string()),
36
57
  cryptographic_suites_supported: z.array(z.string()),
37
- display: z.array(CredentialDisplayMetadata)
58
+ display: z.array(CredentialDisplayMetadata),
59
+ credential_definition: CredentialDefinitionMetadata
38
60
  });
39
61
  const EntityStatement = z.object({
40
62
  header: z.object({
@@ -59,9 +81,20 @@ const EntityConfigurationHeader = z.object({
59
81
  alg: z.string(),
60
82
  kid: z.string()
61
83
  });
84
+ exports.EntityConfigurationHeader = EntityConfigurationHeader;
85
+ const FederationEntityMetadata = z.object({
86
+ federation_fetch_endpoint: z.string().optional(),
87
+ federation_list_endpoint: z.string().optional(),
88
+ federation_resolve_endpoint: z.string().optional(),
89
+ federation_trust_mark_status_endpoint: z.string().optional(),
90
+ federation_trust_mark_list_endpoint: z.string().optional(),
91
+ homepage_uri: z.string().optional(),
92
+ policy_uri: z.string().optional(),
93
+ logo_uri: z.string().optional(),
94
+ contacts: z.array(z.string()).optional()
95
+ }).passthrough();
62
96
 
63
97
  // Structuire common to every Entity Configuration document
64
- exports.EntityConfigurationHeader = EntityConfigurationHeader;
65
98
  const BaseEntityConfiguration = z.object({
66
99
  header: EntityConfigurationHeader,
67
100
  payload: z.object({
@@ -73,17 +106,7 @@ const BaseEntityConfiguration = z.object({
73
106
  keys: z.array(_jwk.JWK)
74
107
  }),
75
108
  metadata: z.object({
76
- federation_entity: z.object({
77
- federation_fetch_endpoint: z.string().optional(),
78
- federation_list_endpoint: z.string().optional(),
79
- federation_resolve_endpoint: z.string().optional(),
80
- federation_trust_mark_status_endpoint: z.string().optional(),
81
- federation_trust_mark_list_endpoint: z.string().optional(),
82
- homepage_uri: z.string().optional(),
83
- policy_uri: z.string().optional(),
84
- logo_uri: z.string().optional(),
85
- contacts: z.array(z.string()).optional()
86
- }).passthrough()
109
+ federation_entity: FederationEntityMetadata
87
110
  }).passthrough(),
88
111
  authority_hints: z.array(z.string()).optional()
89
112
  }).passthrough()
@@ -112,13 +135,27 @@ const CredentialIssuerEntityConfiguration = BaseEntityConfiguration.and(z.object
112
135
  jwks: z.object({
113
136
  keys: z.array(_jwk.JWK)
114
137
  })
115
- })
138
+ }),
139
+ /** Credential Issuers act as Relying Party
140
+ when they require the presentation of other credentials.
141
+ This does not apply for PID issuance, which requires CIE authz. */
142
+ wallet_relying_party: RelyingPartyMetadata.optional()
116
143
  })
117
144
  })
118
145
  }));
119
146
 
120
- // Entity configuration for a Wallet Provider
147
+ // Entity configuration for a Relying Party
121
148
  exports.CredentialIssuerEntityConfiguration = CredentialIssuerEntityConfiguration;
149
+ const RelyingPartyEntityConfiguration = BaseEntityConfiguration.and(z.object({
150
+ payload: z.object({
151
+ metadata: z.object({
152
+ wallet_relying_party: RelyingPartyMetadata
153
+ })
154
+ })
155
+ }));
156
+
157
+ // Entity configuration for a Wallet Provider
158
+ exports.RelyingPartyEntityConfiguration = RelyingPartyEntityConfiguration;
122
159
  const WalletProviderEntityConfiguration = BaseEntityConfiguration.and(z.object({
123
160
  payload: z.object({
124
161
  metadata: z.object({
@@ -136,26 +173,8 @@ const WalletProviderEntityConfiguration = BaseEntityConfiguration.and(z.object({
136
173
  })
137
174
  }));
138
175
 
139
- // Entity configuration for a Relying Party
140
- exports.WalletProviderEntityConfiguration = WalletProviderEntityConfiguration;
141
- const RelyingPartyEntityConfiguration = BaseEntityConfiguration.and(z.object({
142
- payload: z.object({
143
- metadata: z.object({
144
- wallet_relying_party: z.object({
145
- application_type: z.string().optional(),
146
- client_id: z.string().optional(),
147
- client_name: z.string().optional(),
148
- jwks: z.object({
149
- keys: z.array(_jwk.JWK)
150
- }),
151
- contacts: z.array(z.string()).optional()
152
- }).passthrough()
153
- })
154
- })
155
- }));
156
-
157
176
  // Maps any entity configuration by the union of every possible shapes
158
- exports.RelyingPartyEntityConfiguration = RelyingPartyEntityConfiguration;
177
+ exports.WalletProviderEntityConfiguration = WalletProviderEntityConfiguration;
159
178
  const EntityConfiguration = z.union([WalletProviderEntityConfiguration, CredentialIssuerEntityConfiguration, TrustAnchorEntityConfiguration, RelyingPartyEntityConfiguration], {
160
179
  description: "Any kind of Entity Configuration allowed in the ecosystem"
161
180
  });
@@ -1 +1 @@
1
- {"version":3,"names":["_types","require","_jwk","z","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","TrustMark","object","id","string","trust_mark","exports","CredentialDisplayMetadata","name","locale","logo","url","alt_text","background_color","text_color","SupportedCredentialMetadata","format","literal","cryptographic_binding_methods_supported","array","cryptographic_suites_supported","display","EntityStatement","header","typ","alg","kid","payload","iss","sub","jwks","keys","JWK","trust_marks","iat","number","exp","EntityConfigurationHeader","BaseEntityConfiguration","UnixTime","metadata","federation_entity","federation_fetch_endpoint","optional","federation_list_endpoint","federation_resolve_endpoint","federation_trust_mark_status_endpoint","federation_trust_mark_list_endpoint","homepage_uri","policy_uri","logo_uri","contacts","passthrough","authority_hints","TrustAnchorEntityConfiguration","CredentialIssuerEntityConfiguration","and","openid_credential_issuer","credential_issuer","authorization_endpoint","token_endpoint","pushed_authorization_request_endpoint","dpop_signing_alg_values_supported","credential_endpoint","credentials_supported","WalletProviderEntityConfiguration","wallet_provider","attested_security_context_values_supported","grant_types_supported","token_endpoint_auth_methods_supported","token_endpoint_auth_signing_alg_values_supported","RelyingPartyEntityConfiguration","wallet_relying_party","application_type","client_id","client_name","EntityConfiguration","union","description"],"sourceRoot":"../../../src","sources":["trust/types.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,CAAA,GAAAC,uBAAA,CAAAH,OAAA;AAAyB,SAAAI,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,SAAAF,wBAAAM,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,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D,8BAA8B,EAC9BiB,+BAA+B,CAChC,EACD;EACEO,WAAW,EAAE;AACf,CACF,CAAC;AAACxE,OAAA,CAAAsE,mBAAA,GAAAA,mBAAA"}
1
+ {"version":3,"names":["_types","require","_jwk","z","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","TrustMark","object","id","string","trust_mark","exports","RelyingPartyMetadata","application_type","optional","client_id","client_name","jwks","keys","array","JWK","contacts","CredentialDisplayMetadata","name","locale","logo","url","alt_text","background_color","text_color","CredentialDefinitionMetadata","type","credentialSubject","record","mandatory","boolean","display","SupportedCredentialMetadata","format","literal","cryptographic_binding_methods_supported","cryptographic_suites_supported","credential_definition","EntityStatement","header","typ","alg","kid","payload","iss","sub","trust_marks","iat","number","exp","EntityConfigurationHeader","FederationEntityMetadata","federation_fetch_endpoint","federation_list_endpoint","federation_resolve_endpoint","federation_trust_mark_status_endpoint","federation_trust_mark_list_endpoint","homepage_uri","policy_uri","logo_uri","passthrough","BaseEntityConfiguration","UnixTime","metadata","federation_entity","authority_hints","TrustAnchorEntityConfiguration","CredentialIssuerEntityConfiguration","and","openid_credential_issuer","credential_issuer","authorization_endpoint","token_endpoint","pushed_authorization_request_endpoint","dpop_signing_alg_values_supported","credential_endpoint","credentials_supported","wallet_relying_party","RelyingPartyEntityConfiguration","WalletProviderEntityConfiguration","wallet_provider","attested_security_context_values_supported","grant_types_supported","token_endpoint_auth_methods_supported","token_endpoint_auth_signing_alg_values_supported","EntityConfiguration","union","description"],"sourceRoot":"../../../src","sources":["trust/types.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,CAAA,GAAAC,uBAAA,CAAAH,OAAA;AAAyB,SAAAI,yBAAAC,WAAA,eAAAC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,uBAAuB,CAACO,GAAG,CAC1E3F,CAAC,CAACyB,MAAM,CAAC;EACPyC,OAAO,EAAElE,CAAC,CAACyB,MAAM,CAAC;IAChB6D,QAAQ,EAAEtF,CAAC,CAACyB,MAAM,CAAC;MACjB8E,eAAe,EAAEvG,CAAC,CACfyB,MAAM,CAAC;QACNsE,cAAc,EAAE/F,CAAC,CAAC2B,MAAM,CAAC,CAAC;QAC1B6E,0CAA0C,EAAExG,CAAC,CAC1CqC,KAAK,CAACrC,CAAC,CAAC2B,MAAM,CAAC,CAAC,CAAC,CACjBK,QAAQ,CAAC,CAAC;QACbyE,qBAAqB,EAAEzG,CAAC,CAACqC,KAAK,CAACrC,CAAC,CAAC2B,MAAM,CAAC,CAAC,CAAC;QAC1C+E,qCAAqC,EAAE1G,CAAC,CAACqC,KAAK,CAACrC,CAAC,CAAC2B,MAAM,CAAC,CAAC,CAAC;QAC1DgF,gDAAgD,EAAE3G,CAAC,CAACqC,KAAK,CACvDrC,CAAC,CAAC2B,MAAM,CAAC,CACX,CAAC;QACDQ,IAAI,EAAEnC,CAAC,CAACyB,MAAM,CAAC;UAAEW,IAAI,EAAEpC,CAAC,CAACqC,KAAK,CAACC,QAAG;QAAE,CAAC;MACvC,CAAC,CAAC,CACD6C,WAAW,CAAC;IACjB,CAAC;EACH,CAAC;AACH,CAAC,CACH,CAAC;;AAED;AAAAtD,OAAA,CAAAyE,iCAAA,GAAAA,iCAAA;AAEO,MAAMM,mBAAmB,GAAG5G,CAAC,CAAC6G,KAAK,CACxC,CACEP,iCAAiC,EACjCZ,mCAAmC,EACnCD,8BAA8B,EAC9BY,+BAA+B,CAChC,EACD;EACES,WAAW,EAAE;AACf,CACF,CAAC;AAACjF,OAAA,CAAA+E,mBAAA,GAAAA,mBAAA"}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useEphemeralKey = exports.createCryptoContextFor = void 0;
6
+ exports.withEphemeralKey = exports.createCryptoContextFor = void 0;
7
7
  var _ioReactNativeCrypto = require("@pagopa/io-react-native-crypto");
8
8
  var _reactNativeUuid = _interopRequireDefault(require("react-native-uuid"));
9
9
  var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
@@ -54,18 +54,12 @@ const createCryptoContextFor = keytag => {
54
54
  * @returns The returned value of the input procedure.
55
55
  */
56
56
  exports.createCryptoContextFor = createCryptoContextFor;
57
- const useEphemeralKey = async fn => {
57
+ const withEphemeralKey = async fn => {
58
58
  // Use an ephemeral key to be destroyed after use
59
59
  const keytag = `ephemeral-${_reactNativeUuid.default.v4()}`;
60
60
  await (0, _ioReactNativeCrypto.generate)(keytag);
61
61
  const ephemeralContext = createCryptoContextFor(keytag);
62
- try {
63
- return fn(ephemeralContext);
64
- } catch (error) {
65
- throw error;
66
- } finally {
67
- await (0, _ioReactNativeCrypto.deleteKey)(keytag);
68
- }
62
+ return fn(ephemeralContext).finally(() => (0, _ioReactNativeCrypto.deleteKey)(keytag));
69
63
  };
70
- exports.useEphemeralKey = useEphemeralKey;
64
+ exports.withEphemeralKey = withEphemeralKey;
71
65
  //# sourceMappingURL=crypto.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_ioReactNativeCrypto","require","_reactNativeUuid","_interopRequireDefault","_ioReactNativeJwt","_jwk","obj","__esModule","default","createCryptoContextFor","keytag","getPublicKey","then","fixBase64EncodingOnKey","jwk","kid","thumbprint","getSignature","value","sign","exports","useEphemeralKey","fn","uuid","v4","generate","ephemeralContext","error","deleteKey"],"sourceRoot":"../../../src","sources":["utils/crypto.ts"],"mappings":";;;;;;AAAA,IAAAA,oBAAA,GAAAC,OAAA;AAMA,IAAAC,gBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AACA,IAAAI,IAAA,GAAAJ,OAAA;AAA+C,SAAAE,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,sBAAsB,GAAIC,MAAc,IAAoB;EACvE,OAAO;IACL;AACJ;AACA;AACA;AACA;IACI,MAAMC,YAAYA,CAAA,EAAG;MACnB,OAAO,IAAAA,iCAAY,EAACD,MAAM,CAAC,CACxBE,IAAI,CAACC,2BAAsB,CAAC,CAC5BD,IAAI,CAAC,MAAOE,GAAG,KAAM;QACpB,GAAGA,GAAG;QACN;QACA;QACA;QACA;QACAC,GAAG,EAAE,MAAM,IAAAC,4BAAU,EAACF,GAAG;MAC3B,CAAC,CAAC,CAAC;IACP,CAAC;IACD;AACJ;AACA;AACA;AACA;AACA;IACI,MAAMG,YAAYA,CAACC,KAAa,EAAE;MAChC,OAAO,IAAAC,yBAAI,EAACD,KAAK,EAAER,MAAM,CAAC;IAC5B;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPAU,OAAA,CAAAX,sBAAA,GAAAA,sBAAA;AAQO,MAAMY,eAAe,GAAG,MAC7BC,EAAmD,IACpC;EACf;EACA,MAAMZ,MAAM,GAAI,aAAYa,wBAAI,CAACC,EAAE,CAAC,CAAE,EAAC;EACvC,MAAM,IAAAC,6BAAQ,EAACf,MAAM,CAAC;EACtB,MAAMgB,gBAAgB,GAAGjB,sBAAsB,CAACC,MAAM,CAAC;EACvD,IAAI;IACF,OAAOY,EAAE,CAACI,gBAAgB,CAAC;EAC7B,CAAC,CAAC,OAAOC,KAAK,EAAE;IACd,MAAMA,KAAK;EACb,CAAC,SAAS;IACR,MAAM,IAAAC,8BAAS,EAAClB,MAAM,CAAC;EACzB;AACF,CAAC;AAACU,OAAA,CAAAC,eAAA,GAAAA,eAAA"}
1
+ {"version":3,"names":["_ioReactNativeCrypto","require","_reactNativeUuid","_interopRequireDefault","_ioReactNativeJwt","_jwk","obj","__esModule","default","createCryptoContextFor","keytag","getPublicKey","then","fixBase64EncodingOnKey","jwk","kid","thumbprint","getSignature","value","sign","exports","withEphemeralKey","fn","uuid","v4","generate","ephemeralContext","finally","deleteKey"],"sourceRoot":"../../../src","sources":["utils/crypto.ts"],"mappings":";;;;;;AAAA,IAAAA,oBAAA,GAAAC,OAAA;AAMA,IAAAC,gBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AACA,IAAAI,IAAA,GAAAJ,OAAA;AAA+C,SAAAE,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,sBAAsB,GAAIC,MAAc,IAAoB;EACvE,OAAO;IACL;AACJ;AACA;AACA;AACA;IACI,MAAMC,YAAYA,CAAA,EAAG;MACnB,OAAO,IAAAA,iCAAY,EAACD,MAAM,CAAC,CACxBE,IAAI,CAACC,2BAAsB,CAAC,CAC5BD,IAAI,CAAC,MAAOE,GAAG,KAAM;QACpB,GAAGA,GAAG;QACN;QACA;QACA;QACA;QACAC,GAAG,EAAE,MAAM,IAAAC,4BAAU,EAACF,GAAG;MAC3B,CAAC,CAAC,CAAC;IACP,CAAC;IACD;AACJ;AACA;AACA;AACA;AACA;IACI,MAAMG,YAAYA,CAACC,KAAa,EAAE;MAChC,OAAO,IAAAC,yBAAI,EAACD,KAAK,EAAER,MAAM,CAAC;IAC5B;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPAU,OAAA,CAAAX,sBAAA,GAAAA,sBAAA;AAQO,MAAMY,gBAAgB,GAAG,MAC9BC,EAAmD,IACpC;EACf;EACA,MAAMZ,MAAM,GAAI,aAAYa,wBAAI,CAACC,EAAE,CAAC,CAAE,EAAC;EACvC,MAAM,IAAAC,6BAAQ,EAACf,MAAM,CAAC;EACtB,MAAMgB,gBAAgB,GAAGjB,sBAAsB,CAACC,MAAM,CAAC;EACvD,OAAOY,EAAE,CAACI,gBAAgB,CAAC,CAACC,OAAO,CAAC,MAAM,IAAAC,8BAAS,EAAClB,MAAM,CAAC,CAAC;AAC9D,CAAC;AAACU,OAAA,CAAAC,gBAAA,GAAAA,gBAAA"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.hasStatus = void 0;
7
+ var _errors = require("./errors");
8
+ /**
9
+ * Check if a response is in the expected status, other
10
+ * @param status The expected status
11
+ * @returns The given response object
12
+ */
13
+ const hasStatus = status => res => {
14
+ if (res.status !== status) {
15
+ throw new _errors.IoWalletError(`Http request failed. Expected ${status}, got ${res.status}, url: ${res.url}`);
16
+ }
17
+ return res;
18
+ };
19
+
20
+ // extract a type from an async function output
21
+ // helpful to bind the input of a function to the output of another
22
+ exports.hasStatus = hasStatus;
23
+ //# sourceMappingURL=misc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_errors","require","hasStatus","status","res","IoWalletError","url","exports"],"sourceRoot":"../../../src","sources":["utils/misc.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACO,MAAMC,SAAS,GACnBC,MAAc,IACdC,GAAa,IAAe;EAC3B,IAAIA,GAAG,CAACD,MAAM,KAAKA,MAAM,EAAE;IACzB,MAAM,IAAIE,qBAAa,CACpB,iCAAgCF,MAAO,SAAQC,GAAG,CAACD,MAAO,UAASC,GAAG,CAACE,GAAI,EAC9E,CAAC;EACH;EACA,OAAOF,GAAG;AACZ,CAAC;;AAEH;AACA;AAAAG,OAAA,CAAAL,SAAA,GAAAA,SAAA"}
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.makeParRequest = exports.AuthorizationDetails = exports.AuthorizationDetail = void 0;
7
+ var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
8
+ var _reactNativeUuid = _interopRequireDefault(require("react-native-uuid"));
9
+ var z = _interopRequireWildcard(require("zod"));
10
+ var WalletInstanceAttestation = _interopRequireWildcard(require("../wallet-instance-attestation"));
11
+ var _misc = require("./misc");
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
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+ const AuthorizationDetail = z.object({
16
+ credential_definition: z.object({
17
+ type: z.string()
18
+ }),
19
+ format: z.literal("vc+sd-jwt"),
20
+ type: z.literal("openid_credential")
21
+ });
22
+ exports.AuthorizationDetail = AuthorizationDetail;
23
+ const AuthorizationDetails = z.array(AuthorizationDetail);
24
+
25
+ /**
26
+ * Make a PAR request to the issuer and return the response url
27
+ */
28
+ exports.AuthorizationDetails = AuthorizationDetails;
29
+ const makeParRequest = _ref => {
30
+ let {
31
+ wiaCryptoContext,
32
+ appFetch = fetch
33
+ } = _ref;
34
+ return async (clientId, codeVerifier, walletProviderBaseUrl, parEndpoint, walletInstanceAttestation, authorizationDetails, assertionType) => {
35
+ const wiaPublicKey = await wiaCryptoContext.getPublicKey();
36
+ const parUrl = new URL(parEndpoint);
37
+ const aud = `${parUrl.protocol}//${parUrl.hostname}`;
38
+ const iss = WalletInstanceAttestation.decode(walletInstanceAttestation).payload.cnf.jwk.kid;
39
+
40
+ /** A code challenge is provided so that the PAR is bound
41
+ to the subsequent authorization code request
42
+ @see https://datatracker.ietf.org/doc/html/rfc9126#name-request */
43
+ const codeChallengeMethod = "s256";
44
+ const codeChallenge = await (0, _ioReactNativeJwt.sha256ToBase64)(codeVerifier);
45
+
46
+ /** The PAR request token is signed used the Wallet Instance Attestation key.
47
+ The signature can be verified by reading the public key from the key set shippet
48
+ with the it will ship the Wallet Instance Attestation.
49
+ The key is matched by its kid */
50
+ const signedJwtForPar = await new _ioReactNativeJwt.SignJWT(wiaCryptoContext).setProtectedHeader({
51
+ kid: wiaPublicKey.kid
52
+ }).setPayload({
53
+ iss,
54
+ aud,
55
+ jti: `${_reactNativeUuid.default.v4()}`,
56
+ client_assertion_type: assertionType,
57
+ authorization_details: authorizationDetails,
58
+ response_type: "code",
59
+ redirect_uri: walletProviderBaseUrl,
60
+ state: `${_reactNativeUuid.default.v4()}`,
61
+ client_id: clientId,
62
+ code_challenge_method: codeChallengeMethod,
63
+ code_challenge: codeChallenge
64
+ }).setIssuedAt().setExpirationTime("1h").sign();
65
+
66
+ /** The request body for the Pushed Authorization Request */
67
+ var formBody = new URLSearchParams({
68
+ response_type: "code",
69
+ client_id: clientId,
70
+ code_challenge: codeChallenge,
71
+ code_challenge_method: "S256",
72
+ client_assertion_type: assertionType,
73
+ client_assertion: walletInstanceAttestation,
74
+ request: signedJwtForPar
75
+ });
76
+ return await appFetch(parEndpoint, {
77
+ method: "POST",
78
+ headers: {
79
+ "Content-Type": "application/x-www-form-urlencoded"
80
+ },
81
+ body: formBody.toString()
82
+ }).then((0, _misc.hasStatus)(201)).then(res => res.json()).then(result => result.request_uri);
83
+ };
84
+ };
85
+ exports.makeParRequest = makeParRequest;
86
+ //# sourceMappingURL=par.js.map