@pagopa/io-react-native-wallet 1.0.0 → 1.1.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 (289) hide show
  1. package/lib/commonjs/credential/index.js +1 -5
  2. package/lib/commonjs/credential/index.js.map +1 -1
  3. package/lib/commonjs/credential/issuance/02-get-issuer-config.js +48 -0
  4. package/lib/commonjs/credential/issuance/02-get-issuer-config.js.map +1 -0
  5. package/lib/commonjs/credential/issuance/03-start-user-authorization.js +16 -20
  6. package/lib/commonjs/credential/issuance/03-start-user-authorization.js.map +1 -1
  7. package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +8 -8
  8. package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
  9. package/lib/commonjs/credential/issuance/05-authorize-access.js +8 -9
  10. package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -1
  11. package/lib/commonjs/credential/issuance/06-obtain-credential.js +18 -21
  12. package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
  13. package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +3 -3
  14. package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  15. package/lib/commonjs/credential/issuance/README.md +18 -21
  16. package/lib/commonjs/credential/issuance/index.js +3 -3
  17. package/lib/commonjs/credential/issuance/index.js.map +1 -1
  18. package/lib/commonjs/credential/issuance/types.js +1 -1
  19. package/lib/commonjs/credential/issuance/types.js.map +1 -1
  20. package/lib/commonjs/credential/presentation/01-start-flow.js +7 -2
  21. package/lib/commonjs/credential/presentation/01-start-flow.js.map +1 -1
  22. package/lib/commonjs/credential/presentation/02-evaluate-rp-trust.js +2 -2
  23. package/lib/commonjs/credential/presentation/02-evaluate-rp-trust.js.map +1 -1
  24. package/lib/commonjs/credential/presentation/03-retrieve-jwks.js +68 -0
  25. package/lib/commonjs/credential/presentation/03-retrieve-jwks.js.map +1 -0
  26. package/lib/commonjs/credential/presentation/{03-get-request-object.js → 04-get-request-object.js} +27 -13
  27. package/lib/commonjs/credential/presentation/04-get-request-object.js.map +1 -0
  28. package/lib/commonjs/credential/presentation/{04-send-authorization-response.js → 05-send-authorization-response.js} +1 -1
  29. package/lib/commonjs/credential/presentation/{04-send-authorization-response.js.map → 05-send-authorization-response.js.map} +1 -1
  30. package/lib/commonjs/credential/presentation/README.md +74 -2
  31. package/lib/commonjs/credential/presentation/index.js +15 -2
  32. package/lib/commonjs/credential/presentation/index.js.map +1 -1
  33. package/lib/commonjs/credential/presentation/types.js +5 -3
  34. package/lib/commonjs/credential/presentation/types.js.map +1 -1
  35. package/lib/commonjs/entity/openid-connect/issuer/index.js +25 -0
  36. package/lib/commonjs/entity/openid-connect/issuer/index.js.map +1 -0
  37. package/lib/commonjs/entity/openid-connect/issuer/types.js +61 -0
  38. package/lib/commonjs/entity/openid-connect/issuer/types.js.map +1 -0
  39. package/lib/commonjs/{trust → entity/trust}/chain.js +1 -1
  40. package/lib/commonjs/entity/trust/chain.js.map +1 -0
  41. package/lib/commonjs/{trust → entity/trust}/index.js +1 -1
  42. package/lib/commonjs/entity/trust/index.js.map +1 -0
  43. package/lib/commonjs/{trust → entity/trust}/types.js +2 -2
  44. package/lib/commonjs/entity/trust/types.js.map +1 -0
  45. package/lib/commonjs/index.js +1 -3
  46. package/lib/commonjs/index.js.map +1 -1
  47. package/lib/commonjs/pid/sd-jwt/types.js +2 -18
  48. package/lib/commonjs/pid/sd-jwt/types.js.map +1 -1
  49. package/lib/commonjs/sd-jwt/__test__/index.test.js +32 -23
  50. package/lib/commonjs/sd-jwt/__test__/index.test.js.map +1 -1
  51. package/lib/commonjs/sd-jwt/__test__/types.test.js +20 -11
  52. package/lib/commonjs/sd-jwt/__test__/types.test.js.map +1 -1
  53. package/lib/commonjs/sd-jwt/types.js +18 -5
  54. package/lib/commonjs/sd-jwt/types.js.map +1 -1
  55. package/lib/commonjs/utils/error-codes.js +1 -13
  56. package/lib/commonjs/utils/error-codes.js.map +1 -1
  57. package/lib/commonjs/utils/errors.js +2 -53
  58. package/lib/commonjs/utils/errors.js.map +1 -1
  59. package/lib/commonjs/utils/jwk.js +5 -1
  60. package/lib/commonjs/utils/jwk.js.map +1 -1
  61. package/lib/commonjs/utils/par.js +6 -12
  62. package/lib/commonjs/utils/par.js.map +1 -1
  63. package/lib/module/credential/index.js +1 -3
  64. package/lib/module/credential/index.js.map +1 -1
  65. package/lib/module/credential/issuance/02-get-issuer-config.js +42 -0
  66. package/lib/module/credential/issuance/02-get-issuer-config.js.map +1 -0
  67. package/lib/module/credential/issuance/03-start-user-authorization.js +16 -20
  68. package/lib/module/credential/issuance/03-start-user-authorization.js.map +1 -1
  69. package/lib/module/credential/issuance/04-complete-user-authorization.js +8 -8
  70. package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
  71. package/lib/module/credential/issuance/05-authorize-access.js +8 -9
  72. package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
  73. package/lib/module/credential/issuance/06-obtain-credential.js +18 -21
  74. package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
  75. package/lib/module/credential/issuance/07-verify-and-parse-credential.js +3 -3
  76. package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  77. package/lib/module/credential/issuance/README.md +18 -21
  78. package/lib/module/credential/issuance/index.js +2 -2
  79. package/lib/module/credential/issuance/index.js.map +1 -1
  80. package/lib/module/credential/issuance/types.js +1 -1
  81. package/lib/module/credential/issuance/types.js.map +1 -1
  82. package/lib/module/credential/presentation/01-start-flow.js +7 -2
  83. package/lib/module/credential/presentation/01-start-flow.js.map +1 -1
  84. package/lib/module/credential/presentation/02-evaluate-rp-trust.js +1 -1
  85. package/lib/module/credential/presentation/02-evaluate-rp-trust.js.map +1 -1
  86. package/lib/module/credential/presentation/03-retrieve-jwks.js +61 -0
  87. package/lib/module/credential/presentation/03-retrieve-jwks.js.map +1 -0
  88. package/lib/module/credential/presentation/{03-get-request-object.js → 04-get-request-object.js} +26 -12
  89. package/lib/module/credential/presentation/04-get-request-object.js.map +1 -0
  90. package/lib/module/credential/presentation/{04-send-authorization-response.js → 05-send-authorization-response.js} +1 -1
  91. package/lib/module/credential/presentation/{04-send-authorization-response.js.map → 05-send-authorization-response.js.map} +1 -1
  92. package/lib/module/credential/presentation/README.md +74 -2
  93. package/lib/module/credential/presentation/index.js +4 -3
  94. package/lib/module/credential/presentation/index.js.map +1 -1
  95. package/lib/module/credential/presentation/types.js +5 -3
  96. package/lib/module/credential/presentation/types.js.map +1 -1
  97. package/lib/module/entity/openid-connect/issuer/index.js +20 -0
  98. package/lib/module/entity/openid-connect/issuer/index.js.map +1 -0
  99. package/lib/module/entity/openid-connect/issuer/types.js +47 -0
  100. package/lib/module/entity/openid-connect/issuer/types.js.map +1 -0
  101. package/lib/module/{trust → entity/trust}/chain.js +1 -1
  102. package/lib/module/entity/trust/chain.js.map +1 -0
  103. package/lib/module/{trust → entity/trust}/index.js +1 -1
  104. package/lib/module/entity/trust/index.js.map +1 -0
  105. package/lib/module/{trust → entity/trust}/types.js +2 -2
  106. package/lib/module/entity/trust/types.js.map +1 -0
  107. package/lib/module/index.js +1 -2
  108. package/lib/module/index.js.map +1 -1
  109. package/lib/module/pid/sd-jwt/types.js +1 -16
  110. package/lib/module/pid/sd-jwt/types.js.map +1 -1
  111. package/lib/module/sd-jwt/__test__/index.test.js +32 -23
  112. package/lib/module/sd-jwt/__test__/index.test.js.map +1 -1
  113. package/lib/module/sd-jwt/__test__/types.test.js +20 -11
  114. package/lib/module/sd-jwt/__test__/types.test.js.map +1 -1
  115. package/lib/module/sd-jwt/types.js +16 -4
  116. package/lib/module/sd-jwt/types.js.map +1 -1
  117. package/lib/module/utils/error-codes.js +1 -13
  118. package/lib/module/utils/error-codes.js.map +1 -1
  119. package/lib/module/utils/errors.js +0 -48
  120. package/lib/module/utils/errors.js.map +1 -1
  121. package/lib/module/utils/jwk.js +3 -0
  122. package/lib/module/utils/jwk.js.map +1 -1
  123. package/lib/module/utils/par.js +6 -12
  124. package/lib/module/utils/par.js.map +1 -1
  125. package/lib/typescript/credential/index.d.ts +1 -3
  126. package/lib/typescript/credential/index.d.ts.map +1 -1
  127. package/lib/typescript/credential/issuance/01-start-flow.d.ts +1 -1
  128. package/lib/typescript/credential/issuance/02-get-issuer-config.d.ts +32 -0
  129. package/lib/typescript/credential/issuance/02-get-issuer-config.d.ts.map +1 -0
  130. package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts +3 -3
  131. package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts.map +1 -1
  132. package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts +8 -8
  133. package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts.map +1 -1
  134. package/lib/typescript/credential/issuance/05-authorize-access.d.ts +3 -3
  135. package/lib/typescript/credential/issuance/05-authorize-access.d.ts.map +1 -1
  136. package/lib/typescript/credential/issuance/06-obtain-credential.d.ts +3 -3
  137. package/lib/typescript/credential/issuance/06-obtain-credential.d.ts.map +1 -1
  138. package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts +3 -3
  139. package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
  140. package/lib/typescript/credential/issuance/index.d.ts +3 -3
  141. package/lib/typescript/credential/issuance/index.d.ts.map +1 -1
  142. package/lib/typescript/credential/issuance/types.d.ts +4 -9
  143. package/lib/typescript/credential/issuance/types.d.ts.map +1 -1
  144. package/lib/typescript/credential/presentation/01-start-flow.d.ts.map +1 -1
  145. package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts +1 -1
  146. package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts.map +1 -1
  147. package/lib/typescript/credential/presentation/03-retrieve-jwks.d.ts +41 -0
  148. package/lib/typescript/credential/presentation/03-retrieve-jwks.d.ts.map +1 -0
  149. package/lib/typescript/credential/presentation/{03-get-request-object.d.ts → 04-get-request-object.d.ts} +4 -4
  150. package/lib/typescript/credential/presentation/04-get-request-object.d.ts.map +1 -0
  151. package/lib/typescript/credential/presentation/{04-send-authorization-response.d.ts → 05-send-authorization-response.d.ts} +2 -2
  152. package/lib/typescript/credential/presentation/{04-send-authorization-response.d.ts.map → 05-send-authorization-response.d.ts.map} +1 -1
  153. package/lib/typescript/credential/presentation/index.d.ts +5 -4
  154. package/lib/typescript/credential/presentation/index.d.ts.map +1 -1
  155. package/lib/typescript/credential/presentation/types.d.ts +15 -15
  156. package/lib/typescript/entity/openid-connect/issuer/index.d.ts +12 -0
  157. package/lib/typescript/entity/openid-connect/issuer/index.d.ts.map +1 -0
  158. package/lib/typescript/entity/openid-connect/issuer/types.d.ts +641 -0
  159. package/lib/typescript/entity/openid-connect/issuer/types.d.ts.map +1 -0
  160. package/lib/typescript/entity/trust/chain.d.ts.map +1 -0
  161. package/lib/typescript/{trust → entity/trust}/index.d.ts +97 -97
  162. package/lib/typescript/entity/trust/index.d.ts.map +1 -0
  163. package/lib/typescript/{trust → entity/trust}/types.d.ts +597 -597
  164. package/lib/typescript/{trust → entity/trust}/types.d.ts.map +1 -1
  165. package/lib/typescript/index.d.ts +1 -2
  166. package/lib/typescript/index.d.ts.map +1 -1
  167. package/lib/typescript/pid/sd-jwt/types.d.ts +25 -103
  168. package/lib/typescript/pid/sd-jwt/types.d.ts.map +1 -1
  169. package/lib/typescript/sd-jwt/index.d.ts +60 -20
  170. package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
  171. package/lib/typescript/sd-jwt/types.d.ts +114 -24
  172. package/lib/typescript/sd-jwt/types.d.ts.map +1 -1
  173. package/lib/typescript/utils/error-codes.d.ts +0 -12
  174. package/lib/typescript/utils/error-codes.d.ts.map +1 -1
  175. package/lib/typescript/utils/errors.d.ts +6 -37
  176. package/lib/typescript/utils/errors.d.ts.map +1 -1
  177. package/lib/typescript/utils/jwk.d.ts +135 -0
  178. package/lib/typescript/utils/jwk.d.ts.map +1 -1
  179. package/lib/typescript/utils/par.d.ts +1 -8
  180. package/lib/typescript/utils/par.d.ts.map +1 -1
  181. package/lib/typescript/wallet-instance-attestation/types.d.ts +12 -12
  182. package/package.json +1 -1
  183. package/src/credential/index.ts +1 -4
  184. package/src/credential/issuance/01-start-flow.ts +1 -1
  185. package/src/credential/issuance/02-get-issuer-config.ts +67 -0
  186. package/src/credential/issuance/03-start-user-authorization.ts +22 -30
  187. package/src/credential/issuance/04-complete-user-authorization.ts +11 -13
  188. package/src/credential/issuance/05-authorize-access.ts +8 -10
  189. package/src/credential/issuance/06-obtain-credential.ts +30 -31
  190. package/src/credential/issuance/07-verify-and-parse-credential.ts +6 -6
  191. package/src/credential/issuance/README.md +18 -21
  192. package/src/credential/issuance/index.ts +3 -6
  193. package/src/credential/issuance/types.ts +1 -1
  194. package/src/credential/presentation/01-start-flow.ts +8 -2
  195. package/src/credential/presentation/02-evaluate-rp-trust.ts +2 -2
  196. package/src/credential/presentation/03-retrieve-jwks.ts +73 -0
  197. package/src/credential/presentation/{03-get-request-object.ts → 04-get-request-object.ts} +33 -15
  198. package/src/credential/presentation/{04-send-authorization-response.ts → 05-send-authorization-response.ts} +1 -1
  199. package/src/credential/presentation/README.md +74 -2
  200. package/src/credential/presentation/index.ts +10 -2
  201. package/src/credential/presentation/types.ts +3 -3
  202. package/src/entity/openid-connect/issuer/index.ts +27 -0
  203. package/src/entity/openid-connect/issuer/types.ts +68 -0
  204. package/src/{trust → entity/trust}/chain.ts +2 -2
  205. package/src/{trust → entity/trust}/index.ts +1 -1
  206. package/src/{trust → entity/trust}/types.ts +2 -2
  207. package/src/index.ts +0 -2
  208. package/src/pid/sd-jwt/types.ts +1 -18
  209. package/src/sd-jwt/__test__/index.test.ts +47 -37
  210. package/src/sd-jwt/__test__/types.test.ts +26 -16
  211. package/src/sd-jwt/types.ts +16 -2
  212. package/src/utils/error-codes.ts +0 -12
  213. package/src/utils/errors.ts +12 -86
  214. package/src/utils/jwk.ts +5 -0
  215. package/src/utils/par.ts +3 -10
  216. package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js +0 -27
  217. package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js.map +0 -1
  218. package/lib/commonjs/credential/presentation/03-get-request-object.js.map +0 -1
  219. package/lib/commonjs/credential/status/01-start-flow.js +0 -2
  220. package/lib/commonjs/credential/status/01-start-flow.js.map +0 -1
  221. package/lib/commonjs/credential/status/02-status-attestation.js +0 -72
  222. package/lib/commonjs/credential/status/02-status-attestation.js.map +0 -1
  223. package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js +0 -52
  224. package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js.map +0 -1
  225. package/lib/commonjs/credential/status/README.md +0 -67
  226. package/lib/commonjs/credential/status/index.js +0 -27
  227. package/lib/commonjs/credential/status/index.js.map +0 -1
  228. package/lib/commonjs/credential/status/types.js +0 -48
  229. package/lib/commonjs/credential/status/types.js.map +0 -1
  230. package/lib/commonjs/credential/trustmark/README.md +0 -62
  231. package/lib/commonjs/credential/trustmark/get-credential-trustmark.js +0 -81
  232. package/lib/commonjs/credential/trustmark/get-credential-trustmark.js.map +0 -1
  233. package/lib/commonjs/credential/trustmark/index.js +0 -13
  234. package/lib/commonjs/credential/trustmark/index.js.map +0 -1
  235. package/lib/commonjs/trust/chain.js.map +0 -1
  236. package/lib/commonjs/trust/index.js.map +0 -1
  237. package/lib/commonjs/trust/types.js.map +0 -1
  238. package/lib/module/credential/issuance/02-evaluate-issuer-trust.js +0 -20
  239. package/lib/module/credential/issuance/02-evaluate-issuer-trust.js.map +0 -1
  240. package/lib/module/credential/presentation/03-get-request-object.js.map +0 -1
  241. package/lib/module/credential/status/01-start-flow.js +0 -2
  242. package/lib/module/credential/status/01-start-flow.js.map +0 -1
  243. package/lib/module/credential/status/02-status-attestation.js +0 -64
  244. package/lib/module/credential/status/02-status-attestation.js.map +0 -1
  245. package/lib/module/credential/status/03-verify-and-parse-status-attestation.js +0 -46
  246. package/lib/module/credential/status/03-verify-and-parse-status-attestation.js.map +0 -1
  247. package/lib/module/credential/status/README.md +0 -67
  248. package/lib/module/credential/status/index.js +0 -5
  249. package/lib/module/credential/status/index.js.map +0 -1
  250. package/lib/module/credential/status/types.js +0 -40
  251. package/lib/module/credential/status/types.js.map +0 -1
  252. package/lib/module/credential/trustmark/README.md +0 -62
  253. package/lib/module/credential/trustmark/get-credential-trustmark.js +0 -72
  254. package/lib/module/credential/trustmark/get-credential-trustmark.js.map +0 -1
  255. package/lib/module/credential/trustmark/index.js +0 -3
  256. package/lib/module/credential/trustmark/index.js.map +0 -1
  257. package/lib/module/trust/chain.js.map +0 -1
  258. package/lib/module/trust/index.js.map +0 -1
  259. package/lib/module/trust/types.js.map +0 -1
  260. package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts +0 -19
  261. package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts.map +0 -1
  262. package/lib/typescript/credential/presentation/03-get-request-object.d.ts.map +0 -1
  263. package/lib/typescript/credential/status/01-start-flow.d.ts +0 -10
  264. package/lib/typescript/credential/status/01-start-flow.d.ts.map +0 -1
  265. package/lib/typescript/credential/status/02-status-attestation.d.ts +0 -19
  266. package/lib/typescript/credential/status/02-status-attestation.d.ts.map +0 -1
  267. package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts +0 -24
  268. package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts.map +0 -1
  269. package/lib/typescript/credential/status/index.d.ts +0 -7
  270. package/lib/typescript/credential/status/index.d.ts.map +0 -1
  271. package/lib/typescript/credential/status/types.d.ts +0 -305
  272. package/lib/typescript/credential/status/types.d.ts.map +0 -1
  273. package/lib/typescript/credential/trustmark/get-credential-trustmark.d.ts +0 -52
  274. package/lib/typescript/credential/trustmark/get-credential-trustmark.d.ts.map +0 -1
  275. package/lib/typescript/credential/trustmark/index.d.ts +0 -4
  276. package/lib/typescript/credential/trustmark/index.d.ts.map +0 -1
  277. package/lib/typescript/trust/chain.d.ts.map +0 -1
  278. package/lib/typescript/trust/index.d.ts.map +0 -1
  279. package/src/credential/issuance/02-evaluate-issuer-trust.ts +0 -32
  280. package/src/credential/status/01-start-flow.ts +0 -9
  281. package/src/credential/status/02-status-attestation.ts +0 -102
  282. package/src/credential/status/03-verify-and-parse-status-attestation.ts +0 -60
  283. package/src/credential/status/README.md +0 -67
  284. package/src/credential/status/index.ts +0 -22
  285. package/src/credential/status/types.ts +0 -43
  286. package/src/credential/trustmark/README.md +0 -62
  287. package/src/credential/trustmark/get-credential-trustmark.ts +0 -120
  288. package/src/credential/trustmark/index.ts +0 -8
  289. /package/lib/typescript/{trust → entity/trust}/chain.d.ts +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/trust/index.ts"],"names":[],"mappings":"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"}
@@ -1,32 +0,0 @@
1
- import { getCredentialIssuerEntityConfiguration } from "../../trust";
2
- import { CredentialIssuerEntityConfiguration } from "../../trust/types";
3
- import type { StartFlow } from "./01-start-flow";
4
- import type { Out } from "../../utils/misc";
5
-
6
- export type EvaluateIssuerTrust = (
7
- issuerUrl: Out<StartFlow>["issuerUrl"],
8
- context?: {
9
- appFetch?: GlobalFetch["fetch"];
10
- }
11
- ) => Promise<{
12
- issuerConf: CredentialIssuerEntityConfiguration["payload"]["metadata"];
13
- }>;
14
-
15
- /**
16
- * WARNING: This function must be called after {@link startFlow}. The next function to be called is {@link startUserAuthorization}.
17
- * The Issuer trust evaluation phase.
18
- * Fetch the Issuer's configuration and verify trust.
19
- *
20
- * @param issuerUrl The base url of the Issuer returned by {@link startFlow}
21
- * @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
22
- * @returns The Issuer's configuration
23
- */
24
- export const evaluateIssuerTrust: EvaluateIssuerTrust = async (
25
- issuerUrl,
26
- context = {}
27
- ) => {
28
- const issuerConf = await getCredentialIssuerEntityConfiguration(issuerUrl, {
29
- appFetch: context.appFetch,
30
- }).then((_) => _.payload.metadata);
31
- return { issuerConf };
32
- };
@@ -1,9 +0,0 @@
1
- /**
2
- * WARNING: This is the first function to be called in the status attestation flow. The next function to be called is {@link statusAttestation}.
3
- * The beginning of the status attestation flow.
4
- *
5
- * @returns The url of the credential issuer to be used in the next function.
6
- */
7
- export type StartFlow = () => {
8
- issuerUrl: string;
9
- };
@@ -1,102 +0,0 @@
1
- import {
2
- getCredentialHashWithouDiscloures,
3
- hasStatusOrThrow,
4
- type Out,
5
- } from "../../utils/misc";
6
- import type { EvaluateIssuerTrust, ObtainCredential } from "../issuance";
7
- import { type CryptoContext, SignJWT } from "@pagopa/io-react-native-jwt";
8
- import uuid from "react-native-uuid";
9
- import { StatusAttestationResponse } from "./types";
10
- import {
11
- IssuerResponseError,
12
- IssuerResponseErrorCodes,
13
- ResponseErrorBuilder,
14
- UnexpectedStatusCodeError,
15
- } from "../../utils/errors";
16
-
17
- export type StatusAttestation = (
18
- issuerConf: Out<EvaluateIssuerTrust>["issuerConf"],
19
- credential: Out<ObtainCredential>["credential"],
20
- credentialCryptoContext: CryptoContext,
21
- appFetch?: GlobalFetch["fetch"]
22
- ) => Promise<{
23
- statusAttestation: StatusAttestationResponse["status_attestation"];
24
- }>;
25
-
26
- /**
27
- * WARNING: This function must be called after {@link startFlow}.
28
- * Verify the status of the credential attestation.
29
- * @param issuerConf - The issuer's configuration
30
- * @param credential - The credential to be verified
31
- * @param credentialCryptoContext - The credential's crypto context
32
- * @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
33
- * @throws {IssuerResponseError} with a specific code for more context
34
- * @returns The credential status attestation
35
- */
36
- export const statusAttestation: StatusAttestation = async (
37
- issuerConf,
38
- credential,
39
- credentialCryptoContext,
40
- appFetch: GlobalFetch["fetch"] = fetch
41
- ) => {
42
- const jwk = await credentialCryptoContext.getPublicKey();
43
- const credentialHash = await getCredentialHashWithouDiscloures(credential);
44
- const statusAttUrl =
45
- issuerConf.openid_credential_issuer.status_attestation_endpoint;
46
- const credentialPop = await new SignJWT(credentialCryptoContext)
47
- .setPayload({
48
- aud: statusAttUrl,
49
- jti: uuid.v4().toString(),
50
- credential_hash: credentialHash,
51
- credential_hash_alg: "S256",
52
- })
53
- .setProtectedHeader({
54
- alg: "ES256",
55
- typ: "status-attestation-request+jwt",
56
- kid: jwk.kid,
57
- })
58
- .setIssuedAt()
59
- .setExpirationTime("5m")
60
- .sign();
61
-
62
- const body = {
63
- credential_pop: credentialPop,
64
- };
65
-
66
- const result = await appFetch(statusAttUrl, {
67
- method: "POST",
68
- headers: {
69
- "Content-Type": "application/json",
70
- },
71
- body: JSON.stringify(body),
72
- })
73
- .then(hasStatusOrThrow(201))
74
- .then((raw) => raw.json())
75
- .then((json) => StatusAttestationResponse.parse(json))
76
- .catch(handleStatusAttestationError);
77
-
78
- return { statusAttestation: result.status_attestation };
79
- };
80
-
81
- /**
82
- * Handle the status attestation error by mapping it to a custom exception.
83
- * If the error is not an instance of {@link UnexpectedStatusCodeError}, it is thrown as is.
84
- * @param e - The error to be handled
85
- * @throws {IssuerResponseError} with a specific code for more context
86
- */
87
- const handleStatusAttestationError = (e: unknown) => {
88
- if (!(e instanceof UnexpectedStatusCodeError)) {
89
- throw e;
90
- }
91
-
92
- throw new ResponseErrorBuilder(IssuerResponseError)
93
- .handle(404, {
94
- code: IssuerResponseErrorCodes.CredentialInvalidStatus,
95
- message: "Invalid status found for the given credential",
96
- })
97
- .handle("*", {
98
- code: IssuerResponseErrorCodes.StatusAttestationRequestFailed,
99
- message: `Unable to obtain the status attestation for the given credential`,
100
- })
101
- .buildFrom(e);
102
- };
@@ -1,60 +0,0 @@
1
- import type { Out } from "../../utils/misc";
2
- import { IoWalletError } from "../../utils/errors";
3
- import { verify, type CryptoContext } from "@pagopa/io-react-native-jwt";
4
- import type { EvaluateIssuerTrust, StatusAttestation } from "../status";
5
- import { ParsedStatusAttestation } from "./types";
6
- import { decode as decodeJwt } from "@pagopa/io-react-native-jwt";
7
-
8
- export type VerifyAndParseStatusAttestation = (
9
- issuerConf: Out<EvaluateIssuerTrust>["issuerConf"],
10
- statusAttestation: Out<StatusAttestation>,
11
- context: {
12
- credentialCryptoContext: CryptoContext;
13
- }
14
- ) => Promise<{ parsedStatusAttestation: ParsedStatusAttestation }>;
15
-
16
- /**
17
- * Given a status attestation, verifies that:
18
- * - It's in the supported format;
19
- * - The attestation is correctly signed;
20
- * - It's bound to the given key.
21
- * @param issuerConf The Issuer configuration returned by {@link evaluateIssuerTrust}
22
- * @param statusAttestation The encoded status attestation returned by {@link statusAttestation}
23
- * @param context.credentialCryptoContext The crypto context used to obtain the credential in {@link obtainCredential}
24
- * @returns A parsed status attestation
25
- * @throws {IoWalletError} If the credential signature is not verified with the Issuer key set
26
- * @throws {IoWalletError} If the credential is not bound to the provided user key
27
- * @throws {IoWalletError} If the credential data fail to parse
28
- */
29
- export const verifyAndParseStatusAttestation: VerifyAndParseStatusAttestation =
30
- async (issuerConf, rawStatusAttestation, context) => {
31
- try {
32
- const { statusAttestation } = rawStatusAttestation;
33
- const { credentialCryptoContext } = context;
34
-
35
- await verify(
36
- statusAttestation,
37
- issuerConf.openid_credential_issuer.jwks.keys
38
- );
39
-
40
- const decodedJwt = decodeJwt(statusAttestation);
41
- const parsedStatusAttestation = ParsedStatusAttestation.parse({
42
- header: decodedJwt.protectedHeader,
43
- payload: decodedJwt.payload,
44
- });
45
-
46
- const holderBindingKey = await credentialCryptoContext.getPublicKey();
47
- const { cnf } = parsedStatusAttestation.payload;
48
- if (!cnf.jwk.kid || cnf.jwk.kid !== holderBindingKey.kid) {
49
- throw new IoWalletError(
50
- `Failed to verify holder binding for status attestation, expected kid: ${holderBindingKey.kid}, got: ${parsedStatusAttestation.payload.cnf.jwk.kid}`
51
- );
52
- }
53
-
54
- return { parsedStatusAttestation };
55
- } catch (e) {
56
- throw new IoWalletError(
57
- `Failed to verify status attestation: ${JSON.stringify(e)}`
58
- );
59
- }
60
- };
@@ -1,67 +0,0 @@
1
- # Credential Status Attestation
2
-
3
- This flow is used to obtain a credential status attestation from its credential issuer. Each step in the flow is imported from the related file which is named with a sequential number.
4
- The credential status attestation is a JWT which contains the credential status which indicates if the credential is valid or not.
5
- The status attestation is supposed to be stored securely along with the credential. It has a limited lifetime and should be refreshed periodically according to the `exp` field in the JWT payload.
6
-
7
- ## Sequence Diagram
8
-
9
- ```mermaid
10
- graph TD;
11
- 0[startFlow]
12
- 1[statusAttestation]
13
- 2[verifyAndParseStatusAttestation]
14
-
15
- 0 --> 1
16
- 1 --> 2
17
- ```
18
-
19
-
20
- ## Mapped results
21
-
22
- The following errors are mapped to a `IssuerResponseError` with specific codes.
23
-
24
- |HTTP Status|Error Code|Description|
25
- |-----------|----------|-----------|
26
- |`404 Not Found`|`ERR_CREDENTIAL_INVALID_STATUS`|This response is returned by the credential issuer when the status attestation is invalid. It might contain more details in the `reason` property.|
27
-
28
- ## Example
29
-
30
- <details>
31
- <summary>Credential status attestation flow</summary>
32
-
33
- ```ts
34
- // Start the issuance flow
35
- const credentialIssuerUrl = "https://issuer.example.com";
36
- const startFlow: Credential.Status.StartFlow = () => ({
37
- issuerUrl: credentialIssuerUrl, // Let's assum
38
- });
39
-
40
- const { issuerUrl } = startFlow();
41
-
42
- // Evaluate issuer trust
43
- const { issuerConf } = await Credential.Status.evaluateIssuerTrust(issuerUrl);
44
-
45
- // Get the credential attestation
46
- const res = await Credential.Status.statusAttestation(
47
- issuerConf,
48
- credential,
49
- credentialCryptoContext
50
- );
51
-
52
- // Verify and parse the status attestation
53
- const { parsedStatusAttestation } =
54
- await Credential.Status.verifyAndParseStatusAttestation(
55
- issuerConf,
56
- res.statusAttestation,
57
- { credentialCryptoContext }
58
- );
59
-
60
- return {
61
- statusAttestation: res.statusAttestation,
62
- parsedStatusAttestation,
63
- credentialType,
64
- };
65
- ```
66
-
67
- </details>
@@ -1,22 +0,0 @@
1
- import { type StartFlow } from "./01-start-flow";
2
- import {
3
- statusAttestation,
4
- type StatusAttestation,
5
- } from "./02-status-attestation";
6
- import { evaluateIssuerTrust, type EvaluateIssuerTrust } from "../issuance";
7
- import {
8
- verifyAndParseStatusAttestation,
9
- type VerifyAndParseStatusAttestation,
10
- } from "./03-verify-and-parse-status-attestation";
11
-
12
- export {
13
- evaluateIssuerTrust,
14
- statusAttestation,
15
- verifyAndParseStatusAttestation,
16
- };
17
- export type {
18
- StartFlow,
19
- EvaluateIssuerTrust,
20
- StatusAttestation,
21
- VerifyAndParseStatusAttestation,
22
- };
@@ -1,43 +0,0 @@
1
- import { UnixTime } from "../../sd-jwt/types";
2
- import { JWK } from "../../utils/jwk";
3
- import * as z from "zod";
4
-
5
- /**
6
- * Shape from parsing a status attestation response in case of 201.
7
- */
8
- export const StatusAttestationResponse = z.object({
9
- status_attestation: z.string(),
10
- });
11
-
12
- /**
13
- * Type from parsing a status attestation response in case of 201.
14
- * Inferred from {@link StatusAttestationResponse}.
15
- */
16
- export type StatusAttestationResponse = z.infer<
17
- typeof StatusAttestationResponse
18
- >;
19
-
20
- /**
21
- * Type for a parsed status attestation.
22
- */
23
- export type ParsedStatusAttestation = z.infer<typeof ParsedStatusAttestation>;
24
-
25
- /**
26
- * Shape for parsing a status attestation in a JWT.
27
- */
28
- export const ParsedStatusAttestation = z.object({
29
- header: z.object({
30
- typ: z.literal("status-attestation+jwt"),
31
- alg: z.string(),
32
- kid: z.string().optional(),
33
- }),
34
- payload: z.object({
35
- credential_hash_alg: z.string(),
36
- credential_hash: z.string(),
37
- cnf: z.object({
38
- jwk: JWK,
39
- }),
40
- exp: UnixTime,
41
- iat: UnixTime,
42
- }),
43
- });
@@ -1,62 +0,0 @@
1
- # Credential Trustmark
2
-
3
- A credential TrustMark is a signed JWT that verifies the authenticity of a credential issued by a trusted source. It serves as proof that a credential is valid and linked to a specific wallet instance.
4
- The TrustMark is often presented as a QR code, containing cryptographic data to ensure it hasn't been tampered with. It includes fields like issuer, issuance and expiration timestamps, and credential-specific details. TrustMarks have a short validity period and are used to enhance security and prevent misuse, such as QR code swapping.
5
-
6
- ### getCredentialTrustmark
7
-
8
- A function that generates a signed JWT Trustmark to verify the authenticity of a digital credential. The Trustmark serves as a cryptographic proof linking a credential to a specific wallet instance, ensuring the credential's validity and preventing unauthorized modifications or misuse.
9
-
10
- #### Signature
11
-
12
- ```typescript
13
- function getCredentialTrustmark({
14
- walletInstanceAttestation: string,
15
- wiaCryptoContext: CryptoContext,
16
- credentialType: string,
17
- docNumber?: string,
18
- expirationTime?: number | string
19
- }): Promise<{
20
- jwt: string,
21
- expirationTime: number
22
- }>
23
- ```
24
-
25
- #### Parameters
26
- | Parameter | Type | Required | Description |
27
- |-----------|------|----------|-------------|
28
- | walletInstanceAttestation | string | Yes | A base64-encoded string containing the Wallet Instance Attestation (WIA). This attestation proves the authenticity of the wallet instance. |
29
- | wiaCryptoContext | CryptoContext | Yes | The cryptographic context associated with the wallet instance. Must contain the same key pair used to generate the WIA. |
30
- | credentialType | string | Yes | Identifier for the type of credential (e.g., "MDL" for Mobile Driver's License). |
31
- | docNumber | string | No | The document number of the credential. If provided, it will be obfuscated in the Trustmark for privacy. |
32
- | expirationTime | number \| string | No | Specifies when the Trustmark expires. Can be either:<br>- A timestamp in seconds<br>- A time span string (e.g., "2m" for 2 minutes)<br>Default: "2m" |
33
-
34
- #### Return Value
35
-
36
- Returns a Promise that resolves to an object containing:
37
- | Property | Type | Description |
38
- |----------|------|-------------|
39
- | jwt | string | The signed trustmark JWT string |
40
- | expirationTime | number | The expiration timestamp of the JWT in seconds |
41
-
42
- ## Example
43
-
44
- ```typescript
45
- // Required inputs
46
- const walletInstanceAttestation = "base64AttestationString";
47
- const credentialType = "MDL"; // Credential type (e.g., Mobile Driver's License)
48
- const documentNumber = "AB123456"; // Optional document number
49
- const cryptoContext = createCryptoContextFor("wiaKeyTag"); // Sample crypto context
50
-
51
- // Generate the TrustMark JWT
52
- const { jwt, expirationTime } = await getCredentialTrustmark({
53
- walletInstanceAttestation: "eyJ0eXAi...", // WIA JWT
54
- wiaCryptoContext: cryptoContext,
55
- credentialType: "IdentityCard",
56
- docNumber: "AB123456",
57
- expirationTime: "5m", // 5 minutes
58
- });
59
-
60
- console.log("Generated TrustMark JWT:", jwt);
61
- console.log("Expires at:", new Date(expirationTime * 1000));
62
- ```
@@ -1,120 +0,0 @@
1
- import {
2
- SignJWT,
3
- thumbprint,
4
- type CryptoContext,
5
- decode as decodeJwt,
6
- } from "@pagopa/io-react-native-jwt";
7
- import * as WalletInstanceAttestation from "../../wallet-instance-attestation";
8
- import { IoWalletError } from "../../utils/errors";
9
- import { obfuscateString } from "../../utils/string";
10
-
11
- export type GetCredentialTrustmarkJwt = (params: {
12
- /**
13
- * The Wallet Instance's attestation
14
- */
15
- walletInstanceAttestation: string;
16
- /**
17
- * The Wallet Instance's crypto context associated with the walletInstanceAttestation parameter
18
- */
19
- wiaCryptoContext: CryptoContext;
20
- /**
21
- * The type of credential for which the trustmark is generated
22
- */
23
- credentialType: string;
24
- /**
25
- * (Optional) Document number contained in the credential, if applicable
26
- */
27
- docNumber?: string;
28
- /**
29
- * (Optional) Expiration time for the trustmark, default is 2 minutes.
30
- * If a number is provided, it is interpreted as a timestamp in seconds.
31
- * If a string is provided, it is interpreted as a time span and added to the current timestamp.
32
- */
33
- expirationTime?: number | string;
34
- }) => Promise<{
35
- /**
36
- * The signed JWT
37
- */
38
- jwt: string;
39
- /**
40
- * The expiration time of the JWT in seconds
41
- */
42
- expirationTime: number;
43
- }>;
44
-
45
- /**
46
- * Generates a trustmark signed JWT, which is used to verify the authenticity of a credential.
47
- * The public key used to sign the trustmark must the same used for the Wallet Instance Attestation.
48
- *
49
- * @param walletInstanceAttestation the Wallet Instance's attestation
50
- * @param wiaCryptoContext The Wallet Instance's crypto context associated with the walletInstanceAttestation parameter
51
- * @param credentialType The type of credential for which the trustmark is generated
52
- * @param docNumber (Optional) Document number contained in the credential, if applicable
53
- * @param expirationTime (Optional) Expiration time for the trustmark, default is 2 minutes.
54
- * If a number is provided, it is interpreted as a timestamp in seconds.
55
- * If a string is provided, it is interpreted as a time span and added to the current timestamp.
56
- * @throws {IoWalletError} If the WIA is expired
57
- * @throws {IoWalletError} If the public key associated to the WIA is not the same for the CryptoContext
58
- * @throws {JWSSignatureVerificationFailed} If the WIA signature is not valid
59
- * @returns A promise containing the signed JWT and its expiration time in seconds
60
- */
61
- export const getCredentialTrustmark: GetCredentialTrustmarkJwt = async ({
62
- walletInstanceAttestation,
63
- wiaCryptoContext,
64
- credentialType,
65
- docNumber,
66
- expirationTime = "2m",
67
- }) => {
68
- /**
69
- * Check that the public key used to sign the trustmark is the one used for the WIA
70
- */
71
- const holderBindingKey = await wiaCryptoContext.getPublicKey();
72
- const decodedWia = WalletInstanceAttestation.decode(
73
- walletInstanceAttestation
74
- );
75
-
76
- /**
77
- * Check that the WIA is not expired
78
- */
79
- if (decodedWia.payload.exp * 1000 < Date.now()) {
80
- throw new IoWalletError("Wallet Instance Attestation expired");
81
- }
82
-
83
- /**
84
- * Verify holder binding by comparing thumbprints of the WIA and the CryptoContext key
85
- */
86
- const wiaThumbprint = await thumbprint(decodedWia.payload.cnf.jwk);
87
- const cryptoContextThumbprint = await thumbprint(holderBindingKey);
88
-
89
- if (wiaThumbprint !== cryptoContextThumbprint) {
90
- throw new IoWalletError(
91
- `Failed to verify holder binding for status attestation, expected thumbprint: ${cryptoContextThumbprint}, got: ${wiaThumbprint}`
92
- );
93
- }
94
-
95
- /**
96
- * Generate Trustmark signed JWT
97
- */
98
- const signedTrustmarkJwt = await new SignJWT(wiaCryptoContext)
99
- .setProtectedHeader({
100
- alg: "ES256",
101
- })
102
- .setPayload({
103
- iss: walletInstanceAttestation,
104
- /**
105
- * If present, the document number is obfuscated before adding it to the payload
106
- */
107
- ...(docNumber ? { sub: obfuscateString(docNumber) } : {}),
108
- subtyp: credentialType,
109
- })
110
- .setIssuedAt()
111
- .setExpirationTime(expirationTime)
112
- .sign();
113
-
114
- const decodedTrustmark = decodeJwt(signedTrustmarkJwt);
115
-
116
- return {
117
- jwt: signedTrustmarkJwt,
118
- expirationTime: decodedTrustmark.payload.exp ?? 0,
119
- };
120
- };
@@ -1,8 +0,0 @@
1
- import {
2
- type GetCredentialTrustmarkJwt,
3
- getCredentialTrustmark,
4
- } from "./get-credential-trustmark";
5
-
6
- export { getCredentialTrustmark };
7
-
8
- export type { GetCredentialTrustmarkJwt };