@pagopa/io-react-native-wallet 0.24.1 → 0.25.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. package/lib/commonjs/client/generated/wallet-provider.js +39 -16
  2. package/lib/commonjs/client/generated/wallet-provider.js.map +1 -1
  3. package/lib/commonjs/client/index.js +25 -10
  4. package/lib/commonjs/client/index.js.map +1 -1
  5. package/lib/commonjs/credential/issuance/03-start-user-authorization.js +1 -1
  6. package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +21 -14
  7. package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
  8. package/lib/commonjs/credential/issuance/05-authorize-access.js +5 -2
  9. package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -1
  10. package/lib/commonjs/credential/issuance/06-obtain-credential.js +26 -17
  11. package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
  12. package/lib/commonjs/credential/issuance/README.md +8 -14
  13. package/lib/commonjs/credential/issuance/errors.js +52 -0
  14. package/lib/commonjs/credential/issuance/errors.js.map +1 -0
  15. package/lib/commonjs/credential/issuance/index.js +7 -2
  16. package/lib/commonjs/credential/issuance/index.js.map +1 -1
  17. package/lib/commonjs/credential/issuance/types.js +1 -5
  18. package/lib/commonjs/credential/issuance/types.js.map +1 -1
  19. package/lib/commonjs/credential/presentation/01-start-flow.js +1 -1
  20. package/lib/commonjs/credential/presentation/01-start-flow.js.map +1 -1
  21. package/lib/commonjs/credential/presentation/03-get-request-object.js +2 -2
  22. package/lib/commonjs/credential/presentation/03-get-request-object.js.map +1 -1
  23. package/lib/commonjs/credential/presentation/04-send-authorization-response.js +2 -2
  24. package/lib/commonjs/credential/presentation/04-send-authorization-response.js.map +1 -1
  25. package/lib/commonjs/credential/presentation/errors.js +49 -0
  26. package/lib/commonjs/credential/presentation/errors.js.map +1 -0
  27. package/lib/commonjs/credential/presentation/index.js +5 -0
  28. package/lib/commonjs/credential/presentation/index.js.map +1 -1
  29. package/lib/commonjs/credential/status/02-status-attestation.js +8 -6
  30. package/lib/commonjs/credential/status/02-status-attestation.js.map +1 -1
  31. package/lib/commonjs/credential/status/README.md +5 -2
  32. package/lib/commonjs/credential/status/types.js +1 -14
  33. package/lib/commonjs/credential/status/types.js.map +1 -1
  34. package/lib/commonjs/sd-jwt/errors.js +40 -0
  35. package/lib/commonjs/sd-jwt/errors.js.map +1 -0
  36. package/lib/commonjs/sd-jwt/index.js +8 -4
  37. package/lib/commonjs/sd-jwt/index.js.map +1 -1
  38. package/lib/commonjs/sd-jwt/verifier.js +5 -1
  39. package/lib/commonjs/sd-jwt/verifier.js.map +1 -1
  40. package/lib/commonjs/trust/index.js +2 -2
  41. package/lib/commonjs/trust/index.js.map +1 -1
  42. package/lib/commonjs/utils/decoder.js +3 -1
  43. package/lib/commonjs/utils/decoder.js.map +1 -1
  44. package/lib/commonjs/utils/error-codes.js +51 -0
  45. package/lib/commonjs/utils/error-codes.js.map +1 -0
  46. package/lib/commonjs/utils/errors.js +119 -463
  47. package/lib/commonjs/utils/errors.js.map +1 -1
  48. package/lib/commonjs/utils/misc.js +21 -14
  49. package/lib/commonjs/utils/misc.js.map +1 -1
  50. package/lib/commonjs/utils/par.js +2 -1
  51. package/lib/commonjs/utils/par.js.map +1 -1
  52. package/lib/commonjs/wallet-instance/README.md +26 -5
  53. package/lib/commonjs/wallet-instance/index.js +33 -7
  54. package/lib/commonjs/wallet-instance/index.js.map +1 -1
  55. package/lib/commonjs/wallet-instance-attestation/README.md +8 -2
  56. package/lib/commonjs/wallet-instance-attestation/issuing.js +13 -10
  57. package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
  58. package/lib/module/client/generated/wallet-provider.js +31 -11
  59. package/lib/module/client/generated/wallet-provider.js.map +1 -1
  60. package/lib/module/client/index.js +22 -8
  61. package/lib/module/client/index.js.map +1 -1
  62. package/lib/module/credential/issuance/03-start-user-authorization.js +1 -1
  63. package/lib/module/credential/issuance/04-complete-user-authorization.js +16 -9
  64. package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
  65. package/lib/module/credential/issuance/05-authorize-access.js +7 -4
  66. package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
  67. package/lib/module/credential/issuance/06-obtain-credential.js +29 -20
  68. package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
  69. package/lib/module/credential/issuance/README.md +8 -14
  70. package/lib/module/credential/issuance/errors.js +44 -0
  71. package/lib/module/credential/issuance/errors.js.map +1 -0
  72. package/lib/module/credential/issuance/index.js +3 -2
  73. package/lib/module/credential/issuance/index.js.map +1 -1
  74. package/lib/module/credential/issuance/types.js +0 -3
  75. package/lib/module/credential/issuance/types.js.map +1 -1
  76. package/lib/module/credential/presentation/01-start-flow.js +1 -1
  77. package/lib/module/credential/presentation/01-start-flow.js.map +1 -1
  78. package/lib/module/credential/presentation/03-get-request-object.js +3 -3
  79. package/lib/module/credential/presentation/03-get-request-object.js.map +1 -1
  80. package/lib/module/credential/presentation/04-send-authorization-response.js +3 -3
  81. package/lib/module/credential/presentation/04-send-authorization-response.js.map +1 -1
  82. package/lib/module/credential/presentation/errors.js +42 -0
  83. package/lib/module/credential/presentation/errors.js.map +1 -0
  84. package/lib/module/credential/presentation/index.js +2 -1
  85. package/lib/module/credential/presentation/index.js.map +1 -1
  86. package/lib/module/credential/status/02-status-attestation.js +11 -9
  87. package/lib/module/credential/status/02-status-attestation.js.map +1 -1
  88. package/lib/module/credential/status/README.md +5 -2
  89. package/lib/module/credential/status/types.js +0 -12
  90. package/lib/module/credential/status/types.js.map +1 -1
  91. package/lib/module/sd-jwt/errors.js +32 -0
  92. package/lib/module/sd-jwt/errors.js.map +1 -0
  93. package/lib/module/sd-jwt/index.js +5 -5
  94. package/lib/module/sd-jwt/index.js.map +1 -1
  95. package/lib/module/sd-jwt/verifier.js +5 -1
  96. package/lib/module/sd-jwt/verifier.js.map +1 -1
  97. package/lib/module/trust/index.js +3 -3
  98. package/lib/module/trust/index.js.map +1 -1
  99. package/lib/module/utils/decoder.js +3 -1
  100. package/lib/module/utils/decoder.js.map +1 -1
  101. package/lib/module/utils/error-codes.js +43 -0
  102. package/lib/module/utils/error-codes.js.map +1 -0
  103. package/lib/module/utils/errors.js +98 -438
  104. package/lib/module/utils/errors.js.map +1 -1
  105. package/lib/module/utils/misc.js +18 -11
  106. package/lib/module/utils/misc.js.map +1 -1
  107. package/lib/module/utils/par.js +3 -2
  108. package/lib/module/utils/par.js.map +1 -1
  109. package/lib/module/wallet-instance/README.md +26 -5
  110. package/lib/module/wallet-instance/index.js +32 -7
  111. package/lib/module/wallet-instance/index.js.map +1 -1
  112. package/lib/module/wallet-instance-attestation/README.md +8 -2
  113. package/lib/module/wallet-instance-attestation/issuing.js +15 -12
  114. package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
  115. package/lib/typescript/client/generated/wallet-provider.d.ts +138 -27
  116. package/lib/typescript/client/generated/wallet-provider.d.ts.map +1 -1
  117. package/lib/typescript/client/index.d.ts +7 -1
  118. package/lib/typescript/client/index.d.ts.map +1 -1
  119. package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts +1 -1
  120. package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts +1 -1
  121. package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts.map +1 -1
  122. package/lib/typescript/credential/issuance/05-authorize-access.d.ts.map +1 -1
  123. package/lib/typescript/credential/issuance/06-obtain-credential.d.ts.map +1 -1
  124. package/lib/typescript/credential/issuance/errors.d.ts +28 -0
  125. package/lib/typescript/credential/issuance/errors.d.ts.map +1 -0
  126. package/lib/typescript/credential/issuance/index.d.ts +3 -2
  127. package/lib/typescript/credential/issuance/index.d.ts.map +1 -1
  128. package/lib/typescript/credential/issuance/types.d.ts +0 -8
  129. package/lib/typescript/credential/issuance/types.d.ts.map +1 -1
  130. package/lib/typescript/credential/presentation/03-get-request-object.d.ts.map +1 -1
  131. package/lib/typescript/credential/presentation/04-send-authorization-response.d.ts.map +1 -1
  132. package/lib/typescript/credential/presentation/errors.d.ts +25 -0
  133. package/lib/typescript/credential/presentation/errors.d.ts.map +1 -0
  134. package/lib/typescript/credential/presentation/index.d.ts +2 -1
  135. package/lib/typescript/credential/presentation/index.d.ts.map +1 -1
  136. package/lib/typescript/credential/status/02-status-attestation.d.ts.map +1 -1
  137. package/lib/typescript/credential/status/types.d.ts +0 -15
  138. package/lib/typescript/credential/status/types.d.ts.map +1 -1
  139. package/lib/typescript/sd-jwt/errors.d.ts +20 -0
  140. package/lib/typescript/sd-jwt/errors.d.ts.map +1 -0
  141. package/lib/typescript/sd-jwt/index.d.ts +3 -2
  142. package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
  143. package/lib/typescript/utils/error-codes.d.ts +45 -0
  144. package/lib/typescript/utils/error-codes.d.ts.map +1 -0
  145. package/lib/typescript/utils/errors.d.ts +88 -225
  146. package/lib/typescript/utils/errors.d.ts.map +1 -1
  147. package/lib/typescript/utils/misc.d.ts +9 -4
  148. package/lib/typescript/utils/misc.d.ts.map +1 -1
  149. package/lib/typescript/utils/par.d.ts.map +1 -1
  150. package/lib/typescript/wallet-instance/index.d.ts +17 -1
  151. package/lib/typescript/wallet-instance/index.d.ts.map +1 -1
  152. package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
  153. package/lib/typescript/wallet-instance-attestation/types.d.ts +4 -4
  154. package/package.json +1 -1
  155. package/src/client/generated/wallet-provider.ts +43 -13
  156. package/src/client/index.ts +28 -15
  157. package/src/credential/issuance/03-start-user-authorization.ts +1 -1
  158. package/src/credential/issuance/04-complete-user-authorization.ts +21 -21
  159. package/src/credential/issuance/05-authorize-access.ts +7 -4
  160. package/src/credential/issuance/06-obtain-credential.ts +39 -39
  161. package/src/credential/issuance/README.md +8 -14
  162. package/src/credential/issuance/errors.ts +44 -0
  163. package/src/credential/issuance/index.ts +4 -2
  164. package/src/credential/issuance/types.ts +0 -8
  165. package/src/credential/presentation/01-start-flow.ts +1 -1
  166. package/src/credential/presentation/03-get-request-object.ts +3 -3
  167. package/src/credential/presentation/04-send-authorization-response.ts +3 -3
  168. package/src/credential/presentation/errors.ts +41 -0
  169. package/src/credential/presentation/index.ts +2 -0
  170. package/src/credential/status/02-status-attestation.ts +17 -25
  171. package/src/credential/status/README.md +5 -2
  172. package/src/credential/status/types.ts +0 -15
  173. package/src/sd-jwt/errors.ts +39 -0
  174. package/src/sd-jwt/index.ts +5 -8
  175. package/src/sd-jwt/verifier.ts +5 -5
  176. package/src/trust/index.ts +3 -3
  177. package/src/utils/decoder.ts +3 -3
  178. package/src/utils/error-codes.ts +50 -0
  179. package/src/utils/errors.ts +152 -476
  180. package/src/utils/misc.ts +20 -17
  181. package/src/utils/par.ts +3 -2
  182. package/src/wallet-instance/README.md +26 -5
  183. package/src/wallet-instance/index.ts +40 -18
  184. package/src/wallet-instance-attestation/README.md +8 -2
  185. package/src/wallet-instance-attestation/issuing.ts +28 -36
@@ -3,9 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.WalletAttestationView = exports.SetCurrentWalletInstanceStatusBody = exports.ProblemDetail = exports.NonceDetailView = exports.EndpointByMethod = exports.CreateWalletInstanceBody = exports.CreateWalletAttestationBody = exports.ApiClient = void 0;
6
+ exports.WalletInstanceData = exports.WalletAttestationView = exports.SetWalletInstanceStatusBody = exports.RevocationReason = exports.ProblemDetail = exports.NonceDetailView = exports.EndpointByMethod = exports.CreateWalletInstanceBody = exports.CreateWalletAttestationBody = exports.ApiClient = void 0;
7
7
  exports.createApiClient = createApiClient;
8
- exports.put_SetCurrentWalletInstanceStatus = exports.post_CreateWalletInstance = exports.post_CreateWalletAttestation = exports.get_GetNonce = void 0;
8
+ exports.put_SetWalletInstanceStatus = exports.post_CreateWalletInstance = exports.post_CreateWalletAttestation = exports.get_GetWalletInstanceStatus = exports.get_GetNonce = void 0;
9
9
  var _zod = _interopRequireDefault(require("zod"));
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
11
  const NonceDetailView = _zod.default.object({
@@ -35,10 +35,18 @@ const ProblemDetail = _zod.default.object({
35
35
  instance: _zod.default.string().optional()
36
36
  });
37
37
  exports.ProblemDetail = ProblemDetail;
38
- const SetCurrentWalletInstanceStatusBody = _zod.default.object({
38
+ const SetWalletInstanceStatusBody = _zod.default.object({
39
39
  status: _zod.default.literal("REVOKED")
40
40
  });
41
- exports.SetCurrentWalletInstanceStatusBody = SetCurrentWalletInstanceStatusBody;
41
+ exports.SetWalletInstanceStatusBody = SetWalletInstanceStatusBody;
42
+ const RevocationReason = _zod.default.union([_zod.default.literal("CERTIFICATE_REVOKED_BY_ISSUER"), _zod.default.literal("NEW_WALLET_INSTANCE_CREATED"), _zod.default.literal("REVOKED_BY_USER")]);
43
+ exports.RevocationReason = RevocationReason;
44
+ const WalletInstanceData = _zod.default.object({
45
+ id: _zod.default.string(),
46
+ is_revoked: _zod.default.boolean(),
47
+ revocation_reason: _zod.default.union([RevocationReason, _zod.default.undefined()]).optional()
48
+ });
49
+ exports.WalletInstanceData = WalletInstanceData;
42
50
  const get_GetNonce = {
43
51
  method: _zod.default.literal("GET"),
44
52
  path: _zod.default.literal("/nonce"),
@@ -55,36 +63,51 @@ const post_CreateWalletInstance = {
55
63
  response: _zod.default.unknown()
56
64
  };
57
65
  exports.post_CreateWalletInstance = post_CreateWalletInstance;
58
- const post_CreateWalletAttestation = {
59
- method: _zod.default.literal("POST"),
60
- path: _zod.default.literal("/token"),
66
+ const get_GetWalletInstanceStatus = {
67
+ method: _zod.default.literal("GET"),
68
+ path: _zod.default.literal("/wallet-instances/{id}/status"),
61
69
  parameters: _zod.default.object({
62
- body: CreateWalletAttestationBody
70
+ path: _zod.default.object({
71
+ id: _zod.default.string()
72
+ })
63
73
  }),
64
- response: WalletAttestationView
74
+ response: WalletInstanceData
65
75
  };
66
- exports.post_CreateWalletAttestation = post_CreateWalletAttestation;
67
- const put_SetCurrentWalletInstanceStatus = {
76
+ exports.get_GetWalletInstanceStatus = get_GetWalletInstanceStatus;
77
+ const put_SetWalletInstanceStatus = {
68
78
  method: _zod.default.literal("PUT"),
69
- path: _zod.default.literal("/wallet-instances/current/status"),
79
+ path: _zod.default.literal("/wallet-instances/{id}/status"),
70
80
  parameters: _zod.default.object({
71
- body: SetCurrentWalletInstanceStatusBody
81
+ path: _zod.default.object({
82
+ id: _zod.default.string()
83
+ }),
84
+ body: SetWalletInstanceStatusBody
72
85
  }),
73
86
  response: _zod.default.unknown()
74
87
  };
88
+ exports.put_SetWalletInstanceStatus = put_SetWalletInstanceStatus;
89
+ const post_CreateWalletAttestation = {
90
+ method: _zod.default.literal("POST"),
91
+ path: _zod.default.literal("/token"),
92
+ parameters: _zod.default.object({
93
+ body: CreateWalletAttestationBody
94
+ }),
95
+ response: WalletAttestationView
96
+ };
75
97
 
76
98
  // <EndpointByMethod>
77
- exports.put_SetCurrentWalletInstanceStatus = put_SetCurrentWalletInstanceStatus;
99
+ exports.post_CreateWalletAttestation = post_CreateWalletAttestation;
78
100
  const EndpointByMethod = {
79
101
  get: {
80
- "/nonce": get_GetNonce
102
+ "/nonce": get_GetNonce,
103
+ "/wallet-instances/{id}/status": get_GetWalletInstanceStatus
81
104
  },
82
105
  post: {
83
106
  "/wallet-instances": post_CreateWalletInstance,
84
107
  "/token": post_CreateWalletAttestation
85
108
  },
86
109
  put: {
87
- "/wallet-instances/current/status": put_SetCurrentWalletInstanceStatus
110
+ "/wallet-instances/{id}/status": put_SetWalletInstanceStatus
88
111
  }
89
112
  };
90
113
 
@@ -1 +1 @@
1
- {"version":3,"names":["_zod","_interopRequireDefault","require","obj","__esModule","default","NonceDetailView","z","object","nonce","string","exports","WalletAttestationView","wallet_attestation","CreateWalletInstanceBody","challenge","key_attestation","hardware_key_tag","CreateWalletAttestationBody","grant_type","literal","assertion","ProblemDetail","type","optional","title","status","number","detail","instance","SetCurrentWalletInstanceStatusBody","get_GetNonce","method","path","parameters","never","response","post_CreateWalletInstance","body","unknown","post_CreateWalletAttestation","put_SetCurrentWalletInstanceStatus","EndpointByMethod","get","post","put","ApiClient","baseUrl","constructor","fetcher","setBaseUrl","arguments","length","undefined","createApiClient"],"sourceRoot":"../../../../src","sources":["client/generated/wallet-provider.ts"],"mappings":";;;;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAoB,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAGb,MAAMG,eAAe,GAAGC,YAAC,CAACC,MAAM,CAAC;EACtCC,KAAK,EAAEF,YAAC,CAACG,MAAM,CAAC;AAClB,CAAC,CAAC;AAACC,OAAA,CAAAL,eAAA,GAAAA,eAAA;AAGI,MAAMM,qBAAqB,GAAGL,YAAC,CAACC,MAAM,CAAC;EAC5CK,kBAAkB,EAAEN,YAAC,CAACG,MAAM,CAAC;AAC/B,CAAC,CAAC;AAACC,OAAA,CAAAC,qBAAA,GAAAA,qBAAA;AAGI,MAAME,wBAAwB,GAAGP,YAAC,CAACC,MAAM,CAAC;EAC/CO,SAAS,EAAER,YAAC,CAACG,MAAM,CAAC,CAAC;EACrBM,eAAe,EAAET,YAAC,CAACG,MAAM,CAAC,CAAC;EAC3BO,gBAAgB,EAAEV,YAAC,CAACG,MAAM,CAAC;AAC7B,CAAC,CAAC;AAACC,OAAA,CAAAG,wBAAA,GAAAA,wBAAA;AAGI,MAAMI,2BAA2B,GAAGX,YAAC,CAACC,MAAM,CAAC;EAClDW,UAAU,EAAEZ,YAAC,CAACa,OAAO,CAAC,6CAA6C,CAAC;EACpEC,SAAS,EAAEd,YAAC,CAACG,MAAM,CAAC;AACtB,CAAC,CAAC;AAACC,OAAA,CAAAO,2BAAA,GAAAA,2BAAA;AAGI,MAAMI,aAAa,GAAGf,YAAC,CAACC,MAAM,CAAC;EACpCe,IAAI,EAAEhB,YAAC,CAACG,MAAM,CAAC,CAAC,CAACc,QAAQ,CAAC,CAAC;EAC3BC,KAAK,EAAElB,YAAC,CAAC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AAC;EAC5D;EACA;;EAEA;EACAP,IAAIA,CACFX,IAAU,EAE+B;IACzC,OAAO,IAAI,CAACgB,OAAO,CAAC,MAAM,EAAE,IAAI,CAACF,OAAO,GAAGd,IAAI,EAAAkB,SAAA,CAAAC,MAAA,QAAAC,SAAA,GAAAF,SAAA,GAAW,CAAC;EAC7D;EACA;;EAEA;EACAN,GAAGA,CACDZ,IAAU,EAE+B;IACzC,OAAO,IAAI,CAACgB,OAAO,CAAC,KAAK,EAAE,IAAI,CAACF,OAAO,GAAGd,IAAI,EAAAkB,SAAA,CAAAC,MAAA,QAAAC,SAAA,GAAAF,SAAA,GAAW,CAAC;EAC5D;EACA;AACF;AAACxC,OAAA,CAAAmC,SAAA,GAAAA,SAAA;AAEM,SAASQ,eAAeA,CAACL,OAAgB,EAAEF,OAAgB,EAAE;EAClE,OAAO,IAAID,SAAS,CAACG,OAAO,CAAC,CAACC,UAAU,CAACH,OAAO,IAAI,EAAE,CAAC;AACzD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA"}
1
+ {"version":3,"names":["_zod","_interopRequireDefault","require","obj","__esModule","default","NonceDetailView","z","object","nonce","string","exports","WalletAttestationView","wallet_attestation","CreateWalletInstanceBody","challenge","key_attestation","hardware_key_tag","CreateWalletAttestationBody","grant_type","literal","assertion","ProblemDetail","type","optional","title","status","number","detail","instance","SetWalletInstanceStatusBody","RevocationReason","union","WalletInstanceData","id","is_revoked","boolean","revocation_reason","undefined","get_GetNonce","method","path","parameters","never","response","post_CreateWalletInstance","body","unknown","get_GetWalletInstanceStatus","put_SetWalletInstanceStatus","post_CreateWalletAttestation","EndpointByMethod","get","post","put","ApiClient","baseUrl","constructor","fetcher","setBaseUrl","arguments","length","createApiClient"],"sourceRoot":"../../../../src","sources":["client/generated/wallet-provider.ts"],"mappings":";;;;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAoB,SAAAD,uBAAAE,GAAA,WAAAA,GAAA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ACF,OAAO,GAAGf,IAAI,EAAAmB,SAAA,CAAAC,MAAA,QAAAvB,SAAA,GAAAsB,SAAA,GAAW,CAAC;EAC5D;EACA;AACF;AAACjD,OAAA,CAAA4C,SAAA,GAAAA,SAAA;AAEM,SAASO,eAAeA,CAACJ,OAAgB,EAAEF,OAAgB,EAAE;EAClE,OAAO,IAAID,SAAS,CAACG,OAAO,CAAC,CAACC,UAAU,CAACH,OAAO,IAAI,EAAE,CAAC;AACzD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA"}
@@ -3,7 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getWalletProviderClient = void 0;
6
+ exports.interpolateUrl = exports.getWalletProviderClient = void 0;
7
+ var _misc = require("../utils/misc");
7
8
  var _errors = require("../utils/errors");
8
9
  var _walletProvider = require("./generated/wallet-provider");
9
10
  const validateResponse = async response => {
@@ -16,7 +17,11 @@ const validateResponse = async response => {
16
17
  title: "Invalid response from Wallet Provider"
17
18
  };
18
19
  }
19
- throw new _errors.WalletProviderResponseError(problemDetail.title ?? "Invalid response from Wallet Provider", problemDetail.type, problemDetail.detail, response.status);
20
+ throw new _errors.WalletProviderResponseError({
21
+ message: problemDetail.title ?? "Invalid response from Wallet Provider",
22
+ reason: problemDetail,
23
+ statusCode: response.status
24
+ });
20
25
  }
21
26
  return response;
22
27
  };
@@ -25,19 +30,29 @@ const getWalletProviderClient = context => {
25
30
  walletProviderBaseUrl,
26
31
  appFetch = fetch
27
32
  } = context;
28
- return (0, _walletProvider.createApiClient)((method, url, params) => appFetch(url, {
33
+ return (0, _walletProvider.createApiClient)((method, url, params) => appFetch(interpolateUrl(url, params), {
29
34
  method,
30
35
  body: params ? JSON.stringify(params.body) : undefined,
31
36
  headers: {
32
37
  "Content-Type": "application/json"
33
38
  }
34
- }).then(validateResponse).then(res => {
35
- const contentType = res.headers.get("content-type");
36
- if (contentType !== null && contentType !== void 0 && contentType.includes("application/json")) {
37
- return res.json();
38
- }
39
- return res.text();
40
- }), walletProviderBaseUrl);
39
+ }).then(validateResponse).then(_misc.parseRawHttpResponse), walletProviderBaseUrl);
41
40
  };
41
+
42
+ /**
43
+ * Function to interpolate the url when the request includes path params.
44
+ * The client generator expects the literal name of the param in the url
45
+ * and passes the actual values in a separate object.
46
+ */
42
47
  exports.getWalletProviderClient = getWalletProviderClient;
48
+ const interpolateUrl = (url, params) => {
49
+ if (!(params !== null && params !== void 0 && params.path)) return url;
50
+ for (const [key, value] of Object.entries(params.path)) {
51
+ if (typeof value === "string") {
52
+ url = url.replace(`{${key}}`, value);
53
+ }
54
+ }
55
+ return url;
56
+ };
57
+ exports.interpolateUrl = interpolateUrl;
43
58
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_errors","require","_walletProvider","validateResponse","response","ok","problemDetail","ProblemDetail","parse","json","title","WalletProviderResponseError","type","detail","status","getWalletProviderClient","context","walletProviderBaseUrl","appFetch","fetch","createWalletProviderApiClient","method","url","params","body","JSON","stringify","undefined","headers","then","res","contentType","get","includes","text","exports"],"sourceRoot":"../../../src","sources":["client/index.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAQA,MAAME,gBAAgB,GAAG,MAAOC,QAAkB,IAAK;EACrD,IAAI,CAACA,QAAQ,CAACC,EAAE,EAAE;IAChB,IAAIC,aAA4B,GAAG,CAAC,CAAC;IACrC,IAAI;MACFA,aAAa,GAAGC,6BAAa,CAACC,KAAK,CAAC,MAAMJ,QAAQ,CAACK,IAAI,CAAC,CAAC,CAAC;IAC5D,CAAC,CAAC,MAAM;MACNH,aAAa,GAAG;QACdI,KAAK,EAAE;MACT,CAAC;IACH;IAEA,MAAM,IAAIC,mCAA2B,CACnCL,aAAa,CAACI,KAAK,IAAI,uCAAuC,EAC9DJ,aAAa,CAACM,IAAI,EAClBN,aAAa,CAACO,MAAM,EACpBT,QAAQ,CAACU,MACX,CAAC;EACH;EACA,OAAOV,QAAQ;AACjB,CAAC;AAEM,MAAMW,uBAAuB,GAAIC,OAGvC,IAAK;EACJ,MAAM;IAAEC,qBAAqB;IAAEC,QAAQ,GAAGC;EAAM,CAAC,GAAGH,OAAO;EAE3D,OAAO,IAAAI,+BAA6B,EAClC,CAACC,MAAM,EAAEC,GAAG,EAAEC,MAAM,KAClBL,QAAQ,CAACI,GAAG,EAAE;IACZD,MAAM;IACNG,IAAI,EAAED,MAAM,GAAGE,IAAI,CAACC,SAAS,CAACH,MAAM,CAACC,IAAI,CAAC,GAAGG,SAAS;IACtDC,OAAO,EAAE;MACP,cAAc,EAAE;IAClB;EACF,CAAC,CAAC,CACCC,IAAI,CAAC1B,gBAAgB,CAAC,CACtB0B,IAAI,CAAEC,GAAG,IAAK;IACb,MAAMC,WAAW,GAAGD,GAAG,CAACF,OAAO,CAACI,GAAG,CAAC,cAAc,CAAC;IACnD,IAAID,WAAW,aAAXA,WAAW,eAAXA,WAAW,CAAEE,QAAQ,CAAC,kBAAkB,CAAC,EAAE;MAC7C,OAAOH,GAAG,CAACrB,IAAI,CAAC,CAAC;IACnB;IACA,OAAOqB,GAAG,CAACI,IAAI,CAAC,CAAC;EACnB,CAAC,CAAC,EACNjB,qBACF,CAAC;AACH,CAAC;AAACkB,OAAA,CAAApB,uBAAA,GAAAA,uBAAA"}
1
+ {"version":3,"names":["_misc","require","_errors","_walletProvider","validateResponse","response","ok","problemDetail","ProblemDetail","parse","json","title","WalletProviderResponseError","message","reason","statusCode","status","getWalletProviderClient","context","walletProviderBaseUrl","appFetch","fetch","createWalletProviderApiClient","method","url","params","interpolateUrl","body","JSON","stringify","undefined","headers","then","parseRawHttpResponse","exports","path","key","value","Object","entries","replace"],"sourceRoot":"../../../src","sources":["client/index.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAA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E,OAAOX,GAAG;EAE7B,KAAK,MAAM,CAACY,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACd,MAAM,CAACU,IAAI,CAAC,EAAE;IACtD,IAAI,OAAOE,KAAK,KAAK,QAAQ,EAAE;MAC7Bb,GAAG,GAAGA,GAAG,CAACgB,OAAO,CAAE,IAAGJ,GAAI,GAAE,EAAEC,KAAK,CAAC;IACtC;EACF;EACA,OAAOb,GAAG;AACZ,CAAC;AAACU,OAAA,CAAAR,cAAA,GAAAA,cAAA"}
@@ -48,7 +48,7 @@ const selectResponseMode = (issuerConf, credentialType) => {
48
48
 
49
49
  /**
50
50
  * WARNING: This function must be called after {@link evaluateIssuerTrust} and {@link startFlow}. The next steam is {@link compeUserAuthorizationWithQueryMode} or {@link compeUserAuthorizationWithFormPostJwtMode}
51
- * Creates and sends a PAR request to the /as/par endpoint of the authroization server.
51
+ * Creates and sends a PAR request to the /as/par endpoint of the authorization server.
52
52
  * This starts the authentication flow to obtain an access token.
53
53
  * This token enables the Wallet Instance to request a digital credential from the Credential Endpoint of the Credential Issuer.
54
54
  * This is an HTTP POST request containing the Wallet Instance identifier (client id), the code challenge and challenge method as specified by PKCE according to RFC 9126
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.parseAuthroizationResponse = exports.getRequestedCredentialToBePresented = exports.completeUserAuthorizationWithQueryMode = exports.completeUserAuthorizationWithFormPostJwtMode = void 0;
6
+ exports.parseAuthorizationResponse = exports.getRequestedCredentialToBePresented = exports.completeUserAuthorizationWithQueryMode = exports.completeUserAuthorizationWithFormPostJwtMode = void 0;
7
7
  var _auth = require("../../utils/auth");
8
8
  var _misc = require("../../utils/misc");
9
9
  var _parseUrl = _interopRequireDefault(require("parse-url"));
@@ -14,6 +14,7 @@ var _types = require("../presentation/types");
14
14
  var _reactNativeUuid = _interopRequireDefault(require("react-native-uuid"));
15
15
  var _types2 = require("./types");
16
16
  var _decoder = require("../../utils/decoder");
17
+ var _errors2 = require("./errors");
17
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
19
  /**
19
20
  * The interface of the phase to complete User authorization via strong identification when the response mode is "query" and the request credential is a PersonIdentificationData.
@@ -50,7 +51,7 @@ const completeUserAuthorizationWithQueryMode = async (issuerRequestUri, clientId
50
51
  if (authorizationContext) {
51
52
  const redirectSchema = new URL(redirectUri).protocol.replace(":", "");
52
53
  authRedirectUrl = await authorizationContext.authorize(authUrl, redirectSchema).catch(e => {
53
- throw new _errors.AuthorizationError(e.message);
54
+ throw new _errors2.AuthorizationError(e.message);
54
55
  });
55
56
  } else {
56
57
  // handler for redirectUri
@@ -81,14 +82,14 @@ const completeUserAuthorizationWithQueryMode = async (issuerRequestUri, clientId
81
82
  operationIsAborted === null || operationIsAborted === void 0 ? void 0 : operationIsAborted.remove();
82
83
  });
83
84
  if (winner === "OPERATION_ABORTED") {
84
- throw new _errors.OperationAbortedError("DefaultQueryModeAuthorization");
85
+ throw new _errors2.OperationAbortedError("DefaultQueryModeAuthorization");
85
86
  }
86
87
  if (authRedirectUrl === undefined) {
87
- throw new _errors.AuthorizationError("Invalid authentication redirect url");
88
+ throw new _errors2.AuthorizationError("Invalid authentication redirect url");
88
89
  }
89
90
  }
90
91
  const query = (0, _parseUrl.default)(authRedirectUrl).query;
91
- return parseAuthroizationResponse(query);
92
+ return parseAuthorizationResponse(query);
92
93
  };
93
94
 
94
95
  /**
@@ -113,9 +114,12 @@ const getRequestedCredentialToBePresented = async function (issuerRequestUri, cl
113
114
  });
114
115
  const requestObject = await appFetch(`${authzRequestEndpoint}?${params.toString()}`, {
115
116
  method: "GET"
116
- }).then((0, _misc.hasStatus)(200)).then(res => res.text()).then(jws => (0, _ioReactNativeJwt.decode)(jws)).then(reqObj => _types.RequestObject.safeParse(reqObj.payload));
117
+ }).then((0, _misc.hasStatusOrThrow)(200, _errors.IssuerResponseError)).then(res => res.text()).then(jws => (0, _ioReactNativeJwt.decode)(jws)).then(reqObj => _types.RequestObject.safeParse(reqObj.payload));
117
118
  if (!requestObject.success) {
118
- throw new _errors.ValidationFailed("Request Object validation failed", requestObject.error.message);
119
+ throw new _errors.ValidationFailed({
120
+ message: "Request Object validation failed",
121
+ reason: requestObject.error.message
122
+ });
119
123
  }
120
124
  return requestObject.data;
121
125
  };
@@ -202,12 +206,15 @@ const completeUserAuthorizationWithFormPostJwtMode = async (requestObject, ctx)
202
206
  "Content-Type": "application/x-www-form-urlencoded"
203
207
  },
204
208
  body
205
- }).then((0, _misc.hasStatus)(200)).then(reqUri => reqUri.json());
209
+ }).then((0, _misc.hasStatusOrThrow)(200, _errors.IssuerResponseError)).then(reqUri => reqUri.json());
206
210
  const responseUri = _types2.ResponseUriResultShape.safeParse(resUriRes);
207
211
  if (!responseUri.success) {
208
- throw new _errors.ValidationFailed("Response Uri validation failed", responseUri.error.message);
212
+ throw new _errors.ValidationFailed({
213
+ message: "Response Uri validation failed",
214
+ reason: responseUri.error.message
215
+ });
209
216
  }
210
- return await appFetch(responseUri.data.redirect_uri).then((0, _misc.hasStatus)(200)).then(res => res.text()).then(_decoder.getJwtFromFormPost).then(cbRes => parseAuthroizationResponse(cbRes.decodedJwt.payload));
217
+ return await appFetch(responseUri.data.redirect_uri).then((0, _misc.hasStatusOrThrow)(200, _errors.IssuerResponseError)).then(res => res.text()).then(_decoder.getJwtFromFormPost).then(cbRes => parseAuthorizationResponse(cbRes.decodedJwt.payload));
211
218
  };
212
219
 
213
220
  /**
@@ -218,17 +225,17 @@ const completeUserAuthorizationWithFormPostJwtMode = async (requestObject, ctx)
218
225
  * @returns the authorization result which contains code, state and iss
219
226
  */
220
227
  exports.completeUserAuthorizationWithFormPostJwtMode = completeUserAuthorizationWithFormPostJwtMode;
221
- const parseAuthroizationResponse = authRes => {
228
+ const parseAuthorizationResponse = authRes => {
222
229
  const authResParsed = _auth.AuthorizationResultShape.safeParse(authRes);
223
230
  if (!authResParsed.success) {
224
231
  const authErr = _auth.AuthorizationErrorShape.safeParse(authRes);
225
232
  if (!authErr.success) {
226
- throw new _errors.AuthorizationError(authResParsed.error.message); // an error occured while parsing the result and the error
233
+ throw new _errors2.AuthorizationError(authResParsed.error.message); // an error occured while parsing the result and the error
227
234
  }
228
235
 
229
- throw new _errors.AuthorizationIdpError(authErr.data.error, authErr.data.error_description);
236
+ throw new _errors2.AuthorizationIdpError(authErr.data.error, authErr.data.error_description);
230
237
  }
231
238
  return authResParsed.data;
232
239
  };
233
- exports.parseAuthroizationResponse = parseAuthroizationResponse;
240
+ exports.parseAuthorizationResponse = parseAuthorizationResponse;
234
241
  //# sourceMappingURL=04-complete-user-authorization.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_auth","require","_misc","_parseUrl","_interopRequireDefault","_errors","_reactNative","_ioReactNativeJwt","_types","_reactNativeUuid","_types2","_decoder","obj","__esModule","default","completeUserAuthorizationWithQueryMode","issuerRequestUri","clientId","issuerConf","idpHint","redirectUri","authorizationContext","signal","authzRequestEndpoint","oauth_authorization_server","authorization_endpoint","params","URLSearchParams","client_id","request_uri","idphint","authUrl","authRedirectUrl","redirectSchema","URL","protocol","replace","authorize","catch","e","AuthorizationError","message","urlEventListener","Linking","addEventListener","_ref","url","includes","operationIsAborted","createAbortPromiseFromSignal","undefined","openURL","unitAuthRedirectIsNotUndefined","until","winner","Promise","race","listen","filter","isDefined","finally","remove","OperationAbortedError","query","parseUrl","parseAuthroizationResponse","exports","getRequestedCredentialToBePresented","appFetch","arguments","length","fetch","requestObject","toString","method","then","hasStatus","res","text","jws","decode","reqObj","RequestObject","safeParse","payload","success","ValidationFailed","error","data","completeUserAuthorizationWithFormPostJwtMode","ctx","wiaCryptoContext","pidCryptoContext","pid","walletInstanceAttestation","wiaWpToken","SignJWT","setProtectedHeader","alg","typ","setPayload","vp","jti","uuid","v4","nonce","setIssuedAt","setExpirationTime","setAudience","response_uri","sign","pidWpToken","presentationSubmission","definition_id","id","descriptor_map","path","format","authzResponsePayload","encodeBase64","JSON","stringify","state","presentation_submission","vp_token","body","response","resUriRes","headers","reqUri","json","responseUri","ResponseUriResultShape","redirect_uri","getJwtFromFormPost","cbRes","decodedJwt","authRes","authResParsed","AuthorizationResultShape","authErr","AuthorizationErrorShape","AuthorizationIdpError","error_description"],"sourceRoot":"../../../../src","sources":["credential/issuance/04-complete-user-authorization.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAMA,IAAAC,KAAA,GAAAD,OAAA;AAQA,IAAAE,SAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAOA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,iBAAA,GAAAN,OAAA;AAMA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,gBAAA,GAAAL,sBAAA,CAAAH,OAAA;AACA,IAAAS,OAAA,GAAAT,OAAA;AACA,IAAAU,QAAA,GAAAV,OAAA;AAAyD,SAAAG,uBAAAQ,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEzD;AACA;AACA;;AA6BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,sCAA8E,GACzF,MAAAA,CACEC,gBAAgB,EAChBC,QAAQ,EACRC,UAAU,EACVC,OAAO,EACPC,WAAW,EACXC,oBAAoB,EACpBC,MAAM,KACH;EACH,MAAMC,oBAAoB,GACxBL,UAAU,CAACM,0BAA0B,CAACC,sBAAsB;EAC9D,MAAMC,MAAM,GAAG,IAAIC,eAAe,CAAC;IACjCC,SAAS,EAAEX,QAAQ;IACnBY,WAAW,EAAEb,gBAAgB;IAC7Bc,OAAO,EAAEX;EACX,CAAC,CAAC;EACF,MAAMY,OAAO,GAAI,GAAER,oBAAqB,IAAGG,MAAO,EAAC;EACnD,IAAIM,eAA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","_misc","_parseUrl","_interopRequireDefault","_errors","_reactNative","_ioReactNativeJwt","_types","_reactNativeUuid","_types2","_decoder","_errors2","obj","__esModule","default","completeUserAuthorizationWithQueryMode","issuerRequestUri","clientId","issuerConf","idpHint","redirectUri","authorizationContext","signal","authzRequestEndpoint","oauth_authorization_server","authorization_endpoint","params","URLSearchParams","client_id","request_uri","idphint","authUrl","authRedirectUrl","redirectSchema","URL","protocol","replace","authorize","catch","e","AuthorizationError","message","urlEventListener","Linking","addEventListener","_ref","url","includes","operationIsAborted","createAbortPromiseFromSignal","undefined","openURL","unitAuthRedirectIsNotUndefined","until","winner","Promise","race","listen","filter","isDefined","finally","remove","OperationAbortedError","query","parseUrl","parseAuthorizationResponse","exports","getRequestedCredentialToBePresented","appFetch","arguments","length","fetch","requestObject","toString","method","then","hasStatusOrThrow","IssuerResponseError","res","text","jws","decode","reqObj","RequestObject","safeParse","payload","success","ValidationFailed","reason","error","data","completeUserAuthorizationWithFormPostJwtMode","ctx","wiaCryptoContext","pidCryptoContext","pid","walletInstanceAttestation","wiaWpToken","SignJWT","setProtectedHeader","alg","typ","setPayload","vp","jti","uuid","v4","nonce","setIssuedAt","setExpirationTime","setAudience","response_uri","sign","pidWpToken","presentationSubmission","definition_id","id","descriptor_map","path","format","authzResponsePayload","encodeBase64","JSON","stringify","state","presentation_submission","vp_token","body","response","resUriRes","headers","reqUri","json","responseUri","ResponseUriResultShape","redirect_uri","getJwtFromFormPost","cbRes","decodedJwt","authRes","authResParsed","AuthorizationResultShape","authErr","AuthorizationErrorShape","AuthorizationIdpError","error_description"],"sourceRoot":"../../../../src","sources":["credential/issuance/04-complete-user-authorization.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAMA,IAAAC,KAAA,GAAAD,OAAA;AAQA,IAAAE,SAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAEA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,iB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,IAAI,CAAC,IAAAC,sBAAgB,EAAC,GAAG,EAAEC,2BAAmB,CAAC,CAAC,CAChDF,IAAI,CAAEG,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBJ,IAAI,CAAC6D,2BAAkB,CAAC,CACxB7D,IAAI,CAAE8D,KAAK,IAAKxE,0BAA0B,CAACwE,KAAK,CAACC,UAAU,CAACrD,OAAO,CAAC,CAAC;AAC1E,CAAC;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AANAnB,OAAA,CAAAyB,4CAAA,GAAAA,4CAAA;AAOO,MAAM1B,0BAA0B,GACrC0E,OAAgB,IACQ;EACxB,MAAMC,aAAa,GAAGC,8BAAwB,CAACzD,SAAS,CAACuD,OAAO,CAAC;EACjE,IAAI,CAACC,aAAa,CAACtD,OAAO,EAAE;IAC1B,MAAMwD,OAAO,GAAGC,6BAAuB,CAAC3D,SAAS,CAACuD,OAAO,CAAC;IAC1D,IAAI,CAACG,OAAO,CAACxD,OAAO,EAAE;MACpB,MAAM,IAAI9C,2BAAkB,CAACoG,aAAa,CAACnD,KAAK,CAAChD,OAAO,CAAC,CAAC,CAAC;IAC7D;;IACA,MAAM,IAAIuG,8BAAqB,CAC7BF,OAAO,CAACpD,IAAI,CAACD,KAAK,EAClBqD,OAAO,CAACpD,IAAI,CAACuD,iBACf,CAAC;EACH;EACA,OAAOL,aAAa,CAAClD,IAAI;AAC3B,CAAC;AAACxB,OAAA,CAAAD,0BAAA,GAAAA,0BAAA"}
@@ -71,9 +71,12 @@ const authorizeAccess = async (issuerConf, code, clientId, redirectUri, codeVeri
71
71
  DPoP: tokenRequestSignedDPop
72
72
  },
73
73
  body: authorizationRequestFormBody.toString()
74
- }).then((0, _misc.hasStatus)(200)).then(res => res.json()).then(body => _types.TokenResponse.safeParse(body));
74
+ }).then((0, _misc.hasStatusOrThrow)(200, _errors.IssuerResponseError)).then(res => res.json()).then(body => _types.TokenResponse.safeParse(body));
75
75
  if (!tokenRes.success) {
76
- throw new _errors.ValidationFailed(tokenRes.error.message);
76
+ throw new _errors.ValidationFailed({
77
+ message: "Token Response validation failed",
78
+ reason: tokenRes.error.message
79
+ });
77
80
  }
78
81
  return {
79
82
  accessToken: tokenRes.data
@@ -1 +1 @@
1
- {"version":3,"names":["_misc","require","_dpop","_reactNativeUuid","_interopRequireDefault","_pop","WalletInstanceAttestation","_interopRequireWildcard","_const","_types","_errors","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","authorizeAccess","issuerConf","code","clientId","redirectUri","codeVerifier","context","appFetch","fetch","walletInstanceAttestation","wiaCryptoContext","dPopCryptoContext","parEndpoint","oauth_authorization_server","pushed_authorization_request_endpoint","parUrl","URL","aud","protocol","hostname","iss","decode","payload","cnf","jwk","kid","tokenUrl","token_endpoint","tokenRequestSignedDPop","createDPopToken","htm","htu","jti","uuid","v4","signedWiaPoP","createPopToken","requestBody","grant_type","client_id","redirect_uri","code_verifier","client_assertion_type","ASSERTION_TYPE","client_assertion","authorizationRequestFormBody","URLSearchParams","tokenRes","method","headers","DPoP","body","toString","then","hasStatus","res","json","TokenResponse","safeParse","success","ValidationFailed","error","message","accessToken","data","exports"],"sourceRoot":"../../../../src","sources":["credential/issuance/05-authorize-access.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAGA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,IAAA,GAAAJ,OAAA;AACA,IAAAK,yBAAA,GAAAC,uBAAA,CAAAN,OAAA;AAEA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,OAAA,GAAAT,OAAA;AAAsD,SAAAU,yBAAAC,WAAA,eAAAC,OAAA,kCAA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,GAAG,IAAIC,eAAe,CAACT,WAAW,CAAC;EACrE,MAAMU,QAAQ,GAAG,MAAMxC,QAAQ,CAACmB,QAAQ,EAAE;IACxCsB,MAAM,EAAE,MAAM;IACdC,OAAO,EAAE;MACP,cAAc,EAAE,mCAAmC;MACnDC,IAAI,EAAEtB;IACR,CAAC;IACDuB,IAAI,EAAEN,4BAA4B,CAACO,QAAQ,CAAC;EAC9C,CAAC,CAAC,CACCC,IAAI,CAAC,IAAAC,eAAS,EAAC,GAAG,CAAC,CAAC,CACpBD,IAAI,CAAEE,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBH,IAAI,CAAEF,IAAI,IAAKM,oBAAa,CAACC,SAAS,CAACP,IAAI,CAAC,CAAC;EAEhD,IAAI,CAACJ,QAAQ,CAACY,OAAO,EAAE;IACrB,MAAM,IAAIC,wBAAgB,CAACb,QAAQ,CAACc,KAAK,CAACC,OAAO,CAAC;EACpD;EAEA,OAAO;IAAEC,WAAW,EAAEhB,QAAQ,CAACiB;EAAK,CAAC;AACvC,CAAC;AAACC,OAAA,CAAAjE,eAAA,GAAAA,eAAA"}
1
+ {"version":3,"names":["_misc","require","_dpop","_reactNativeUuid","_interopRequireDefault","_pop","WalletInstanceAttestation","_interopRequireWildcard","_const","_types","_errors","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","authorizeAccess","issuerConf","code","clientId","redirectUri","codeVerifier","context","appFetch","fetch","walletInstanceAttestation","wiaCryptoContext","dPopCryptoContext","parEndpoint","oauth_authorization_server","pushed_authorization_request_endpoint","parUrl","URL","aud","protocol","hostname","iss","decode","payload","cnf","jwk","kid","tokenUrl","token_endpoint","tokenRequestSignedDPop","createDPopToken","htm","htu","jti","uuid","v4","signedWiaPoP","createPopToken","requestBody","grant_type","client_id","redirect_uri","code_verifier","client_assertion_type","ASSERTION_TYPE","client_assertion","authorizationRequestFormBody","URLSearchParams","tokenRes","method","headers","DPoP","body","toString","then","hasStatusOrThrow","IssuerResponseError","res","json","TokenResponse","safeParse","success","ValidationFailed","message","reason","error","accessToken","data","exports"],"sourceRoot":"../../../../src","sources":["credential/issuance/05-authorize-access.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAGA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,IAAA,GAAAJ,OAAA;AACA,IAAAK,yBAAA,GAAAC,uBAAA,CAAAN,OAAA;AAEA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,OAAA,GAAAT,OAAA;AAA2E,SAAAU,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,SAAAL,wBAAAS,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAA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ACJ;EAEA,OAAO;IAAEG,WAAW,EAAElB,QAAQ,CAACmB;EAAK,CAAC;AACvC,CAAC;AAACC,OAAA,CAAAnE,eAAA,GAAAA,eAAA"}
@@ -54,9 +54,11 @@ const obtainCredential = async (issuerConf, accessToken, clientId, credentialDef
54
54
  const signedNonceProof = await createNonceProof(accessToken.c_nonce, clientId, credentialUrl, credentialCryptoContext);
55
55
 
56
56
  // Validation of accessTokenResponse.authorization_details if contain credentialDefinition
57
- const constainsCredentialDefinition = accessToken.authorization_details.some(c => c.credential_configuration_id === credentialDefinition.credential_configuration_id && c.format === credentialDefinition.format && c.type === credentialDefinition.type);
58
- if (!constainsCredentialDefinition) {
59
- throw new _errors.ValidationFailed("The access token response does not contain the requested credential");
57
+ const containsCredentialDefinition = accessToken.authorization_details.some(c => c.credential_configuration_id === credentialDefinition.credential_configuration_id && c.format === credentialDefinition.format && c.type === credentialDefinition.type);
58
+ if (!containsCredentialDefinition) {
59
+ throw new _errors.ValidationFailed({
60
+ message: "The access token response does not contain the requested credential"
61
+ });
60
62
  }
61
63
 
62
64
  /** The credential request body */
@@ -70,7 +72,7 @@ const obtainCredential = async (issuerConf, accessToken, clientId, credentialDef
70
72
  proof_type: "jwt"
71
73
  }
72
74
  };
73
- const tokenRequestSignedDPop = await await (0, _dpop.createDPopToken)({
75
+ const tokenRequestSignedDPop = await (0, _dpop.createDPopToken)({
74
76
  htm: "POST",
75
77
  htu: credentialUrl,
76
78
  jti: `${_reactNativeUuid.default.v4()}`,
@@ -84,9 +86,12 @@ const obtainCredential = async (issuerConf, accessToken, clientId, credentialDef
84
86
  Authorization: `${accessToken.token_type} ${accessToken.access_token}`
85
87
  },
86
88
  body: JSON.stringify(credentialRequestFormBody)
87
- }).then((0, _misc.hasStatus)(200)).then(res => res.json()).then(body => _types.CredentialResponse.safeParse(body)).catch(handleObtainCredentialError);
89
+ }).then((0, _misc.hasStatusOrThrow)(200)).then(res => res.json()).then(body => _types.CredentialResponse.safeParse(body)).catch(handleObtainCredentialError);
88
90
  if (!credentialRes.success) {
89
- throw new _errors.ValidationFailed(credentialRes.error.message);
91
+ throw new _errors.ValidationFailed({
92
+ message: "Credential Response validation failed",
93
+ reason: credentialRes.error.message
94
+ });
90
95
  }
91
96
  return credentialRes.data;
92
97
  };
@@ -103,16 +108,20 @@ const handleObtainCredentialError = e => {
103
108
  if (!(e instanceof _errors.UnexpectedStatusCodeError)) {
104
109
  throw e;
105
110
  }
106
-
107
- // Although it is technically not an error, we handle it as such to avoid
108
- // changing the return type of `obtainCredential` and introduce a breaking change.
109
- if (e.statusCode === 201) {
110
- throw new _errors.CredentialIssuingNotSynchronousError("This credential cannot be issued synchronously. It will be available at a later time.", e.message);
111
- }
112
- if ([403, 404].includes(e.statusCode)) {
113
- const maybeError = _types.CredentialIssuanceFailureResponse.safeParse((0, _misc.safeJsonParse)(e.responseBody));
114
- throw new _errors.CredentialInvalidStatusError("Invalid status found for the given credential", maybeError.success ? maybeError.data.error : "unknown", e.message);
115
- }
116
- throw new _errors.CredentialRequestError(`Unable to obtain the requested credential [response status code: ${e.statusCode}]`, e.message);
111
+ throw new _errors.ResponseErrorBuilder(_errors.IssuerResponseError).handle(201, {
112
+ // Although it is technically not an error, we handle it as such to avoid
113
+ // changing the return type of `obtainCredential` and introduce a breaking change.
114
+ code: _errors.IssuerResponseErrorCodes.CredentialIssuingNotSynchronous,
115
+ message: "This credential cannot be issued synchronously. It will be available at a later time."
116
+ }).handle(403, {
117
+ code: _errors.IssuerResponseErrorCodes.CredentialInvalidStatus,
118
+ message: "Invalid status found for the given credential"
119
+ }).handle(404, {
120
+ code: _errors.IssuerResponseErrorCodes.CredentialInvalidStatus,
121
+ message: "Invalid status found for the given credential"
122
+ }).handle("*", {
123
+ code: _errors.IssuerResponseErrorCodes.CredentialRequestFailed,
124
+ message: "Unable to obtain the requested credential"
125
+ }).buildFrom(e);
117
126
  };
118
127
  //# sourceMappingURL=06-obtain-credential.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_ioReactNativeJwt","require","_misc","_errors","_types","_dpop","_reactNativeUuid","_interopRequireDefault","obj","__esModule","default","createNonceProof","nonce","issuer","audience","ctx","jwk","getPublicKey","SignJWT","setPayload","setProtectedHeader","typ","setAudience","setIssuer","setIssuedAt","setExpirationTime","sign","exports","obtainCredential","issuerConf","accessToken","clientId","credentialDefinition","context","credentialCryptoContext","appFetch","fetch","dPopCryptoContext","credentialUrl","openid_credential_issuer","credential_endpoint","signedNonceProof","c_nonce","constainsCredentialDefinition","authorization_details","some","c","credential_configuration_id","format","type","ValidationFailed","credentialRequestFormBody","credential_definition","proof","jwt","proof_type","tokenRequestSignedDPop","createDPopToken","htm","htu","jti","uuid","v4","ath","sha256ToBase64","access_token","credentialRes","method","headers","DPoP","Authorization","token_type","body","JSON","stringify","then","hasStatus","res","json","CredentialResponse","safeParse","catch","handleObtainCredentialError","success","error","message","data","e","UnexpectedStatusCodeError","statusCode","CredentialIssuingNotSynchronousError","includes","maybeError","CredentialIssuanceFailureResponse","safeJsonParse","responseBody","CredentialInvalidStatusError","CredentialRequestError"],"sourceRoot":"../../../../src","sources":["credential/issuance/06-obtain-credential.ts"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAOA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AAOA,IAAAG,MAAA,GAAAH,OAAA;AAEA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,gBAAA,GAAAC,sBAAA,CAAAN,OAAA;AAAqC,SAAAM,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAc9B,MAAMG,gBAAgB,GAAG,MAAAA,CAC9BC,KAAa,EACbC,MAAc,EACdC,QAAgB,EAChBC,GAAkB,KACE;EACpB,MAAMC,GAAG,GAAG,MAAMD,GAAG,CAACE,YAAY,CAAC,CAAC;EACpC,OAAO,IAAIC,yBAAO,CA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AOA,MAAMsD,2BAA2B,GAAIK,CAAU,IAAK;EAClD,IAAI,EAAEA,CAAC,YAAYC,iCAAyB,CAAC,EAAE;IAC7C,MAAMD,CAAC;EACT;;EAEA;EACA;EACA,IAAIA,CAAC,CAACE,UAAU,KAAK,GAAG,EAAE;IACxB,MAAM,IAAIC,4CAAoC,CAC5C,uFAAuF,EACvFH,CAAC,CAACF,OACJ,CAAC;EACH;EAEA,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAACM,QAAQ,CAACJ,CAAC,CAACE,UAAU,CAAC,EAAE;IACrC,MAAMG,UAAU,GAAGC,wCAAiC,CAACb,SAAS,CAC5D,IAAAc,mBAAa,EAACP,CAAC,CAACQ,YAAY,CAC9B,CAAC;IACD,MAAM,IAAIC,oCAA4B,CACpC,+CAA+C,EAC/CJ,UAAU,CAACT,OAAO,GAAGS,UAAU,CAACN,IAAI,CAACF,KAAK,GAAG,SAAS,EACtDG,CAAC,CAACF,OACJ,CAAC;EACH;EAEA,MAAM,IAAIY,8BAAsB,CAC7B,oEAAmEV,CAAC,CAACE,UAAW,GAAE,EACnFF,CAAC,CAACF,OACJ,CAAC;AACH,CAAC"}
1
+ {"version":3,"names":["_ioReactNativeJwt","require","_misc","_errors","_types","_dpop","_reactNativeUuid","_interopRequireDefault","obj","__esModule","default","createNonceProof","nonce","issuer","audience","ctx","jwk","getPublicKey","SignJWT","setPayload","setProtectedHeader","typ","setAudience","setIssuer","setIssuedAt","setExpirationTime","sign","exports","obtainCredential","issuerConf","accessToken","clientId","credentialDefinition","context","credentialCryptoContext","appFetch","fetch","dPopCryptoContext","credentialUrl","openid_credential_issuer","credential_endpoint","signedNonceProof","c_nonce","containsCredentialDefinition","authorization_details","some","c","credential_configuration_id","format","type","ValidationFailed","message","credentialRequestFormBody","credential_definition","proof","jwt","proof_type","tokenRequestSignedDPop","createDPopToken","htm","htu","jti","uuid","v4","ath","sha256ToBase64","access_token","credentialRes","method","headers","DPoP","Authorization","token_type","body","JSON","stringify","then","hasStatusOrThrow","res","json","CredentialResponse","safeParse","catch","handleObtainCredentialError","success","reason","error","data","e","UnexpectedStatusCodeError","ResponseErrorBuilder","IssuerResponseError","handle","code","IssuerResponseErrorCodes","CredentialIssuingNotSynchronous","CredentialInvalidStatus","CredentialRequestFailed","buildFrom"],"sourceRoot":"../../../../src","sources":["credential/issuance/06-obtain-credential.ts"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAOA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AAOA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,gBAAA,GAAAC,sBAAA,CAAAN,OAAA;AAAqC,SAAAM,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAc9B,MAAMG,gBAAgB,GAAG,MAAAA,CAC9BC,KAAa,EACbC,MAAc,EACdC,QAAgB,EAChBC,GAAkB,KACE;EACpB,MAAMC,GAAG,GAAG,MAAMD,GAAG,CAACE,YAAY,CAAC,CAAC;EACpC,OAAO,IAAIC,yBAAO,CAACH,GAAG,CAAC,CACpBI,UAAU,CAAC;IACVP;EACF,CAAC,CAAC,CACDQ,kBAAkB,CAAC;IAClBC,GAAG,EAAE,sBAAsB;IAC3BL;EACF,CAAC,CAAC,CACDM,WAAW,CAACR,QAAQ,CAAC,CACrBS,SAAS,CAACV,MAAM,CAAC,CACjBW,WAAW,CAAC,CAAC,CACbC,iBAAiB,CAAC,MAAM,CAAC,CACzBC,IAAI,CAAC,CAAC;AACX,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAfAC,OAAA,CAAAhB,gBAAA,GAAAA,gBAAA;AAgBO,MAAMiB,gBAAkC,GAAG,MAAAA,CAChDC,UAAU,EACVC,WAAW,EACXC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CAAC,CACDyC,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEC,gCAAwB,CAACE,uBAAuB;IACtD7C,OAAO,EAAE;EACX,CAAC,CAAC,CACDyC,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEC,gCAAwB,CAACG,uBAAuB;IACtD9C,OAAO,EAAE;EACX,CAAC,CAAC,CACD+C,SAAS,CAACV,CAAC,CAAC;AACjB,CAAC"}
@@ -39,20 +39,14 @@ graph TD;
39
39
 
40
40
  ## Mapped results
41
41
 
42
- ### 201 Created (CredentialIssuingNotSynchronousError)
42
+ The following errors are mapped to a `IssuerResponseError` with specific codes.
43
43
 
44
- A `201 Created` response is returned by the credential issuer when the request has been queued because the credential cannot be issued synchronously. The consumer should try to obtain the credential at a later time.
45
-
46
- Although `201 Created` is not considered an error, it is mapped as an error in this context in order to handle the case where the credential issuance is not synchronous.
47
- This allows keeping the flow consistent and handle the case where the credential is not immediately available.
48
-
49
- ### 403 Forbidden (CredentialInvalidStatusError)
50
-
51
- A `403 Forbidden` response is returned by the credential issuer when the requested credential has an invalid status. It might contain more details in the `errorCode` property.
52
-
53
- ### 404 Not Found (CredentialInvalidStatusError)
54
-
55
- A `404 Not Found` response is returned by the credential issuer when the authenticated user is not entitled to receive the requested credential. It might contain more details in the `errorCode` property.
44
+ |HTTP Status|Error Code|Description|
45
+ |-----------|----------|-----------|
46
+ |`201 Created`|`ERR_CREDENTIAL_ISSUING_NOT_SYNCHRONOUS`| This response is returned by the credential issuer when the request has been queued because the credential cannot be issued synchronously. The consumer should try to obtain the credential at a later time. Although `201 Created` is not considered an error, it is mapped as an error in this context in order to handle the case where the credential issuance is not synchronous. This allows keeping the flow consistent and handle the case where the credential is not immediately available.|
47
+ |`403 Forbidden`|`ERR_CREDENTIAL_INVALID_STATUS`|This response is returned by the credential issuer when the requested credential has an invalid status. It might contain more details in the `reason` property.|
48
+ |`404 Not Found`|`ERR_CREDENTIAL_INVALID_STATUS`| This response is returned by the credential issuer when the authenticated user is not entitled to receive the requested credential. It might contain more details in the `reason` property.|
49
+ |`*`|`ERR_ISSUER_GENERIC_ERROR`|This is a generic error code to map unexpected errors that occurred when interacting with the Issuer.|
56
50
 
57
51
  ## Strong authentication for eID issuance (Query Mode)
58
52
 
@@ -278,7 +272,7 @@ const { issuerRequestUri, clientId, codeVerifier, credentialDefinition } =
278
272
  appFetch,
279
273
  });
280
274
 
281
- // Complete the authroization process with query mode with the authorizationContext which opens the browser
275
+ // Complete the authorization process with query mode with the authorizationContext which opens the browser
282
276
  const { code } =
283
277
  await Credential.Issuance.completeUserAuthorizationWithQueryMode(
284
278
  issuerRequestUri,
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.OperationAbortedError = exports.AuthorizationIdpError = exports.AuthorizationError = void 0;
7
+ var _errors = require("../../utils/errors");
8
+ /**
9
+ * An error subclass thrown when an error occurs during the authorization process.
10
+ */
11
+ class AuthorizationError extends _errors.IoWalletError {
12
+ code = "ERR_IO_WALLET_AUTHORIZATION_ERROR";
13
+ constructor(message) {
14
+ super(message);
15
+ }
16
+ }
17
+
18
+ /**
19
+ * An error subclass thrown when an error occurs during the authorization process with the IDP.
20
+ * It contains the error and error description returned by the IDP.
21
+ */
22
+ exports.AuthorizationError = AuthorizationError;
23
+ class AuthorizationIdpError extends _errors.IoWalletError {
24
+ code = "ERR_IO_WALLET_IDENTIFICATION_RESPONSE_PARSING_FAILED";
25
+ constructor(error, errorDescription) {
26
+ super((0, _errors.serializeAttrs)({
27
+ error,
28
+ errorDescription
29
+ }));
30
+ this.error = error;
31
+ this.errorDescription = errorDescription;
32
+ }
33
+ }
34
+
35
+ /**
36
+ * Error subclass thrown when an operation has been aborted.
37
+ */
38
+ exports.AuthorizationIdpError = AuthorizationIdpError;
39
+ class OperationAbortedError extends _errors.IoWalletError {
40
+ code = "ERR_IO_WALLET_OPERATION_ABORTED";
41
+
42
+ /** The aborted operation */
43
+
44
+ constructor(operation) {
45
+ super((0, _errors.serializeAttrs)({
46
+ operation
47
+ }));
48
+ this.operation = operation;
49
+ }
50
+ }
51
+ exports.OperationAbortedError = OperationAbortedError;
52
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_errors","require","AuthorizationError","IoWalletError","code","constructor","message","exports","AuthorizationIdpError","error","errorDescription","serializeAttrs","OperationAbortedError","operation"],"sourceRoot":"../../../../src","sources":["credential/issuance/errors.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACO,MAAMC,kBAAkB,SAASC,qBAAa,CAAC;EACpDC,IAAI,GAAG,mCAAmC;EAE1CC,WAAWA,CAACC,OAAgB,EAAE;IAC5B,KAAK,CAACA,OAAO,CAAC;EAChB;AACF;;AAEA;AACA;AACA;AACA;AAHAC,OAAA,CAAAL,kBAAA,GAAAA,kBAAA;AAIO,MAAMM,qBAAqB,SAASL,qBAAa,CAAC;EACvDC,IAAI,GAAG,sDAAsD;EAK7DC,WAAWA,CAACI,KAAa,EAAEC,gBAAyB,EAAE;IACpD,KAAK,CAAC,IAAAC,sBAAc,EAAC;MAAEF,KAAK;MAAEC;IAAiB,CAAC,CAAC,CAAC;IAClD,IAAI,CAACD,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACC,gBAAgB,GAAGA,gBAAgB;EAC1C;AACF;;AAEA;AACA;AACA;AAFAH,OAAA,CAAAC,qBAAA,GAAAA,qBAAA;AAGO,MAAMI,qBAAqB,SAAST,qBAAa,CAAC;EACvDC,IAAI,GAAG,iCAAiC;;EAExC;;EAGAC,WAAWA,CAACQ,SAAiB,EAAE;IAC7B,KAAK,CAAC,IAAAF,sBAAc,EAAC;MAAEE;IAAU,CAAC,CAAC,CAAC;IACpC,IAAI,CAACA,SAAS,GAAGA,SAAS;EAC5B;AACF;AAACN,OAAA,CAAAK,qBAAA,GAAAA,qBAAA"}