@pagopa/io-react-native-wallet 0.4.3 → 0.6.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 (94) hide show
  1. package/README.md +128 -19
  2. package/lib/commonjs/index.js +16 -23
  3. package/lib/commonjs/index.js.map +1 -1
  4. package/lib/commonjs/pid/index.js +3 -8
  5. package/lib/commonjs/pid/index.js.map +1 -1
  6. package/lib/commonjs/pid/issuing.js +153 -176
  7. package/lib/commonjs/pid/issuing.js.map +1 -1
  8. package/lib/commonjs/rp/__test__/index.test.js +7 -5
  9. package/lib/commonjs/rp/__test__/index.test.js.map +1 -1
  10. package/lib/commonjs/rp/index.js +145 -155
  11. package/lib/commonjs/rp/index.js.map +1 -1
  12. package/lib/commonjs/rp/types.js +1 -21
  13. package/lib/commonjs/rp/types.js.map +1 -1
  14. package/lib/commonjs/trust/index.js +24 -5
  15. package/lib/commonjs/trust/index.js.map +1 -1
  16. package/lib/commonjs/trust/types.js +102 -9
  17. package/lib/commonjs/trust/types.js.map +1 -1
  18. package/lib/commonjs/utils/crypto.js +46 -0
  19. package/lib/commonjs/utils/crypto.js.map +1 -0
  20. package/lib/commonjs/utils/dpop.js +14 -7
  21. package/lib/commonjs/utils/dpop.js.map +1 -1
  22. package/lib/commonjs/wallet-instance-attestation/index.js +3 -3
  23. package/lib/commonjs/wallet-instance-attestation/issuing.js +42 -60
  24. package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
  25. package/lib/module/index.js +4 -6
  26. package/lib/module/index.js.map +1 -1
  27. package/lib/module/pid/index.js +1 -1
  28. package/lib/module/pid/index.js.map +1 -1
  29. package/lib/module/pid/issuing.js +152 -180
  30. package/lib/module/pid/issuing.js.map +1 -1
  31. package/lib/module/rp/__test__/index.test.js +3 -3
  32. package/lib/module/rp/__test__/index.test.js.map +1 -1
  33. package/lib/module/rp/index.js +141 -154
  34. package/lib/module/rp/index.js.map +1 -1
  35. package/lib/module/rp/types.js +0 -20
  36. package/lib/module/rp/types.js.map +1 -1
  37. package/lib/module/trust/index.js +19 -5
  38. package/lib/module/trust/index.js.map +1 -1
  39. package/lib/module/trust/types.js +100 -7
  40. package/lib/module/trust/types.js.map +1 -1
  41. package/lib/module/utils/crypto.js +40 -0
  42. package/lib/module/utils/crypto.js.map +1 -0
  43. package/lib/module/utils/dpop.js +13 -5
  44. package/lib/module/utils/dpop.js.map +1 -1
  45. package/lib/module/wallet-instance-attestation/index.js +2 -2
  46. package/lib/module/wallet-instance-attestation/index.js.map +1 -1
  47. package/lib/module/wallet-instance-attestation/issuing.js +40 -58
  48. package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
  49. package/lib/typescript/index.d.ts +4 -6
  50. package/lib/typescript/index.d.ts.map +1 -1
  51. package/lib/typescript/pid/index.d.ts +1 -1
  52. package/lib/typescript/pid/index.d.ts.map +1 -1
  53. package/lib/typescript/pid/issuing.d.ts +43 -88
  54. package/lib/typescript/pid/issuing.d.ts.map +1 -1
  55. package/lib/typescript/rp/index.d.ts +41 -87
  56. package/lib/typescript/rp/index.d.ts.map +1 -1
  57. package/lib/typescript/rp/types.d.ts +10 -906
  58. package/lib/typescript/rp/types.d.ts.map +1 -1
  59. package/lib/typescript/sd-jwt/index.d.ts +1 -1
  60. package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
  61. package/lib/typescript/trust/index.d.ts +806 -3
  62. package/lib/typescript/trust/index.d.ts.map +1 -1
  63. package/lib/typescript/trust/types.d.ts +9655 -297
  64. package/lib/typescript/trust/types.d.ts.map +1 -1
  65. package/lib/typescript/utils/crypto.d.ts +10 -0
  66. package/lib/typescript/utils/crypto.d.ts.map +1 -0
  67. package/lib/typescript/utils/dpop.d.ts +10 -2
  68. package/lib/typescript/utils/dpop.d.ts.map +1 -1
  69. package/lib/typescript/wallet-instance-attestation/index.d.ts +2 -2
  70. package/lib/typescript/wallet-instance-attestation/index.d.ts.map +1 -1
  71. package/lib/typescript/wallet-instance-attestation/issuing.d.ts +18 -31
  72. package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
  73. package/lib/typescript/wallet-instance-attestation/types.d.ts +4 -4
  74. package/package.json +2 -2
  75. package/src/index.ts +14 -13
  76. package/src/pid/index.ts +1 -1
  77. package/src/pid/issuing.ts +233 -232
  78. package/src/rp/__test__/index.test.ts +3 -3
  79. package/src/rp/index.ts +172 -194
  80. package/src/rp/types.ts +0 -24
  81. package/src/sd-jwt/index.ts +1 -1
  82. package/src/trust/index.ts +106 -5
  83. package/src/trust/types.ts +152 -34
  84. package/src/utils/crypto.ts +41 -0
  85. package/src/utils/dpop.ts +17 -7
  86. package/src/wallet-instance-attestation/index.ts +2 -2
  87. package/src/wallet-instance-attestation/issuing.ts +51 -63
  88. package/lib/commonjs/pid/metadata.js +0 -49
  89. package/lib/commonjs/pid/metadata.js.map +0 -1
  90. package/lib/module/pid/metadata.js +0 -41
  91. package/lib/module/pid/metadata.js.map +0 -1
  92. package/lib/typescript/pid/metadata.d.ts +0 -482
  93. package/lib/typescript/pid/metadata.d.ts.map +0 -1
  94. package/src/pid/metadata.ts +0 -46
@@ -3,88 +3,82 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.RelyingPartySolution = void 0;
6
+ exports.sendAuthorizationResponse = exports.getRequestObject = exports.decodeAuthRequestQR = void 0;
7
7
  var _errors = require("../utils/errors");
8
8
  var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
9
9
  var _types = require("./types");
10
10
  var _reactNativeUuid = _interopRequireDefault(require("react-native-uuid"));
11
11
  var _sdJwt = require("../sd-jwt");
12
- var _trust = require("../trust");
12
+ var _dpop = require("../utils/dpop");
13
+ var WalletInstanceAttestation = _interopRequireWildcard(require("../wallet-instance-attestation"));
14
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
- class RelyingPartySolution {
15
- constructor(relyingPartyBaseUrl, walletInstanceAttestation) {
16
- let appFetch = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : fetch;
17
- this.relyingPartyBaseUrl = relyingPartyBaseUrl;
18
- this.walletInstanceAttestation = walletInstanceAttestation;
19
- this.appFetch = appFetch;
17
+ /**
18
+ * Select a RSA public key from those provided by the RP to encrypt.
19
+ *
20
+ * @param entity The RP entity configuration
21
+ * @returns A suitable public key with its compatible encryption algorithm
22
+ * @throws {NoSuitableKeysFoundInEntityConfiguration} If entity do not contain any public key suitable for encrypting
23
+ */
24
+ const chooseRSAPublicKeyToEncrypt = entity => {
25
+ const [usingRsa256] = entity.payload.metadata.wallet_relying_party.jwks.filter(jwk => jwk.use === "enc" && jwk.kty === "RSA");
26
+ if (usingRsa256) {
27
+ return usingRsa256;
20
28
  }
21
29
 
22
- /**
23
- * Decode a QR code content to an authentication request url.
24
- * @function
25
- * @param qrcode QR code content
26
- *
27
- * @returns The authentication request url
28
- *
29
- */
30
- static decodeAuthRequestQR(qrcode) {
31
- const decoded = (0, _ioReactNativeJwt.decodeBase64)(qrcode);
32
- const decodedUrl = new URL(decoded);
33
- const protocol = decodedUrl.protocol;
34
- const resource = decodedUrl.hostname;
35
- const requestURI = decodedUrl.searchParams.get("request_uri");
36
- const clientId = decodedUrl.searchParams.get("client_id");
37
- const result = _types.QRCodePayload.safeParse({
38
- protocol,
39
- resource,
40
- requestURI,
41
- clientId
42
- });
43
- if (result.success) {
44
- return result.data;
45
- } else {
46
- throw new _errors.AuthRequestDecodeError(result.error.message, `${decodedUrl}`);
47
- }
30
+ // No suitable key has been found
31
+ throw new _errors.NoSuitableKeysFoundInEntityConfiguration("Encrypt with RP public key");
32
+ };
33
+
34
+ /**
35
+ * Decode a QR code content to an authentication request url.
36
+ * @function
37
+ * @param qrcode QR code content
38
+ *
39
+ * @returns The authentication request url
40
+ *
41
+ */
42
+ const decodeAuthRequestQR = qrcode => {
43
+ const decoded = (0, _ioReactNativeJwt.decodeBase64)(qrcode);
44
+ const decodedUrl = new URL(decoded);
45
+ const protocol = decodedUrl.protocol;
46
+ const resource = decodedUrl.hostname;
47
+ const requestURI = decodedUrl.searchParams.get("request_uri");
48
+ const clientId = decodedUrl.searchParams.get("client_id");
49
+ const result = _types.QRCodePayload.safeParse({
50
+ protocol,
51
+ resource,
52
+ requestURI,
53
+ clientId
54
+ });
55
+ if (result.success) {
56
+ return result.data;
57
+ } else {
58
+ throw new _errors.AuthRequestDecodeError(result.error.message, `${decodedUrl}`);
48
59
  }
49
- /**
50
- * Obtain the unsigned wallet instance DPoP for authentication request
51
- *
52
- * @function
53
- * @param walletInstanceAttestationJwk JWT of the Wallet Instance Attestation
54
- * @param authRequestUrl authentication request url
55
- *
56
- * @returns The unsigned wallet instance DPoP
57
- *
58
- */
59
- async getUnsignedWalletInstanceDPoP(walletInstanceAttestationJwk, authRequestUrl) {
60
- return await new _ioReactNativeJwt.SignJWT({
60
+ };
61
+ exports.decodeAuthRequestQR = decodeAuthRequestQR;
62
+ /**
63
+ * Obtain the Request Object for RP authentication
64
+ * @see https://italia.github.io/eudi-wallet-it-docs/versione-corrente/en/relying-party-solution.html
65
+ */
66
+ const getRequestObject = _ref => {
67
+ let {
68
+ wiaCryptoContext,
69
+ appFetch = fetch
70
+ } = _ref;
71
+ return async (walletInstanceAttestation, requestUri, rpEntityConfiguration) => {
72
+ const signedWalletInstanceDPoP = await (0, _dpop.createDPopToken)({
61
73
  jti: `${_reactNativeUuid.default.v4()}`,
62
74
  htm: "GET",
63
- htu: authRequestUrl,
64
- ath: await (0, _ioReactNativeJwt.sha256ToBase64)(this.walletInstanceAttestation)
65
- }).setProtectedHeader({
66
- alg: "ES256",
67
- jwk: walletInstanceAttestationJwk,
68
- typ: "dpop+jwt"
69
- }).setIssuedAt().setExpirationTime("1h").toSign();
70
- }
71
-
72
- /**
73
- * Obtain the Request Object for RP authentication
74
- * @see https://italia.github.io/eudi-wallet-it-docs/versione-corrente/en/relying-party-solution.html
75
- *
76
- * @async @function
77
- * @param signedWalletInstanceDPoP JWT of the Wallet Instance Attestation DPoP
78
- *
79
- * @returns The Request Object JWT
80
- * @throws {NoSuitableKeysFoundInEntityConfiguration} When the Request Object is signed with a key not listed in RP's entity configuration
81
- *
82
- */
83
- async getRequestObject(signedWalletInstanceDPoP, requestUri, entity) {
84
- const response = await this.appFetch(requestUri, {
75
+ htu: requestUri,
76
+ ath: await (0, _ioReactNativeJwt.sha256ToBase64)(walletInstanceAttestation)
77
+ }, wiaCryptoContext);
78
+ const response = await appFetch(requestUri, {
85
79
  method: "GET",
86
80
  headers: {
87
- Authorization: `DPoP ${this.walletInstanceAttestation}`,
81
+ Authorization: `DPoP ${walletInstanceAttestation}`,
88
82
  DPoP: signedWalletInstanceDPoP
89
83
  }
90
84
  });
@@ -96,10 +90,10 @@ class RelyingPartySolution {
96
90
  // verify token signature according to RP's entity configuration
97
91
  // to ensure the request object is authentic
98
92
  {
99
- const pubKey = entity.payload.metadata.wallet_relying_party.jwks.find(_ref => {
93
+ const pubKey = rpEntityConfiguration.payload.metadata.wallet_relying_party.jwks.find(_ref2 => {
100
94
  let {
101
95
  kid
102
- } = _ref;
96
+ } = _ref2;
103
97
  return kid === responseJwt.protectedHeader.kid;
104
98
  });
105
99
  if (!pubKey) {
@@ -109,55 +103,64 @@ class RelyingPartySolution {
109
103
  }
110
104
 
111
105
  // parse request object it has the expected shape by specification
112
- const requestObj = _types.RequestObject.parse({
106
+ const requestObject = _types.RequestObject.parse({
113
107
  header: responseJwt.protectedHeader,
114
108
  payload: responseJwt.payload
115
109
  });
116
- return requestObj;
110
+ return {
111
+ requestObject,
112
+ rpEntityConfiguration,
113
+ walletInstanceAttestation
114
+ };
117
115
  }
118
- throw new _errors.IoWalletError(`Unable to obtain Request Object. Response code: ${response.status}`);
119
- }
116
+ throw new _errors.IoWalletError(`Unable to obtain Request Object. Response code: ${response.status}
117
+ ${await response.text()}`);
118
+ };
119
+ };
120
120
 
121
- /**
122
- * Prepare the Verified Presentation token for a received request object in the context of an authorization request flow.
123
- * The presentation is prepared by disclosing data from provided credentials, according to requested claims
124
- * Each Verified Credential come along with the claims the user accepts to disclose from it.
125
- *
126
- * The returned token is unsigned (sign should be apply by the caller).
127
- *
128
- * @todo accept more than a Verified Credential
129
- *
130
- * @param requestObj The incoming request object, which the requirements for the requested authorization
131
- * @param walletInstanceIdentifier The identifies of the wallt instance that is presenting
132
- * @param presentation The Verified Credential containing user data along with the list of claims to be disclosed.
133
- * @param signKeyId The kid of the key that will be used to sign
134
- * @returns The unsigned Verified Presentation token
135
- * @throws {ClaimsNotFoundBetweenDislosures} If the Verified Credential does not contain one or more requested claims.
136
- *
137
- */
138
- async prepareVpToken(requestObj, walletInstanceIdentifier, _ref2,
139
- // TODO: [SIW-353] support multiple presentations,
140
- signKeyId) {
141
- let [vc, claims] = _ref2;
121
+ /**
122
+ * Prepare the Verified Presentation token for a received request object in the context of an authorization request flow.
123
+ * The presentation is prepared by disclosing data from provided credentials, according to requested claims
124
+ * Each Verified Credential come along with the claims the user accepts to disclose from it.
125
+ *
126
+ * @todo accept more than a Verified Credential
127
+ */
128
+ exports.getRequestObject = getRequestObject;
129
+ const prepareVpToken = _ref3 => {
130
+ let {
131
+ pidCryptoContext
132
+ } = _ref3;
133
+ return async (_ref4, _ref5) => {
134
+ let {
135
+ requestObject,
136
+ walletInstanceAttestation
137
+ } = _ref4;
138
+ let [vc, claims] = _ref5;
142
139
  // this throws if vc cannot satisfy all the requested claims
143
140
  const {
144
141
  token: vp,
145
142
  paths
146
143
  } = await (0, _sdJwt.disclose)(vc, claims);
147
144
 
148
- // TODO: [SIW-359] check all requeste claims of the requestedObj are satisfied
145
+ // obtain issuer from Wallet Instance
146
+ const {
147
+ payload: {
148
+ iss
149
+ }
150
+ } = WalletInstanceAttestation.decode(walletInstanceAttestation);
151
+ const pidKid = await pidCryptoContext.getPublicKey().then(_ => _.kid);
149
152
 
150
- const vp_token = new _ioReactNativeJwt.SignJWT({
153
+ // TODO: [SIW-359] check all requeste claims of the requestedObj are satisfied
154
+ const vp_token = await new _ioReactNativeJwt.SignJWT(pidCryptoContext).setProtectedHeader({
155
+ typ: "JWT",
156
+ kid: pidKid
157
+ }).setPayload({
151
158
  vp: vp,
152
159
  jti: `${_reactNativeUuid.default.v4()}`,
153
- iss: walletInstanceIdentifier,
154
- nonce: requestObj.payload.nonce
155
- }).setAudience(requestObj.payload.response_uri).setIssuedAt().setExpirationTime("1h").setProtectedHeader({
156
- typ: "JWT",
157
- alg: "ES256",
158
- kid: signKeyId
159
- }).toSign();
160
- const vc_scope = requestObj.payload.scope;
160
+ iss,
161
+ nonce: requestObject.payload.nonce
162
+ }).setAudience(requestObject.payload.response_uri).setIssuedAt().setExpirationTime("1h").sign();
163
+ const vc_scope = requestObject.payload.scope;
161
164
  const presentation_submission = {
162
165
  definition_id: `${_reactNativeUuid.default.v4()}`,
163
166
  id: `${_reactNativeUuid.default.v4()}`,
@@ -171,30 +174,43 @@ class RelyingPartySolution {
171
174
  vp_token,
172
175
  presentation_submission
173
176
  };
174
- }
177
+ };
178
+ };
175
179
 
176
- /**
177
- * Compose and send an Authorization Response in the context of an authorization request flow.
178
- *
179
- * @todo MUST add presentation_submission
180
- *
181
- * @param requestObj The incoming request object, which the requirements for the requested authorization
182
- * @param vp_token The signed Verified Presentation token with data to send.
183
- * @param presentation_submission
184
- * @param entity The RP entity configuration
185
- * @returns The response from the RP
186
- * @throws {IoWalletError} if the submission fails.
187
- * @throws {NoSuitableKeysFoundInEntityConfiguration} If entity do not contain any public key
188
- *
189
- */
190
- async sendAuthorizationResponse(requestObj, vp_token, presentation_submission, entity) {
180
+ /**
181
+ * Compose and send an Authorization Response in the context of an authorization request flow.
182
+ *
183
+ * @todo MUST add presentation_submission
184
+ *
185
+ */
186
+ const sendAuthorizationResponse = _ref6 => {
187
+ let {
188
+ pidCryptoContext,
189
+ appFetch = fetch
190
+ } = _ref6;
191
+ return async (_ref7, presentation) => {
192
+ let {
193
+ requestObject,
194
+ rpEntityConfiguration,
195
+ walletInstanceAttestation
196
+ } = _ref7;
191
197
  // the request is an unsigned jws without iss, aud, exp
192
198
  // https://openid.net/specs/openid-4-verifiable-presentations-1_0.html#name-signed-and-encrypted-respon
193
- const jwk = this.chooseRSAPublicKeyToEncrypt(entity);
199
+ const jwk = chooseRSAPublicKeyToEncrypt(rpEntityConfiguration);
200
+ const {
201
+ vp_token,
202
+ presentation_submission
203
+ } = await prepareVpToken({
204
+ pidCryptoContext
205
+ })({
206
+ requestObject,
207
+ rpEntityConfiguration,
208
+ walletInstanceAttestation
209
+ }, presentation);
194
210
  const authzResponsePayload = JSON.stringify({
195
- state: requestObj.payload.state,
211
+ state: requestObject.payload.state,
196
212
  presentation_submission,
197
- nonce: requestObj.payload.nonce,
213
+ nonce: requestObject.payload.nonce,
198
214
  vp_token
199
215
  });
200
216
  const encrypted = await new _ioReactNativeJwt.EncryptJwe(authzResponsePayload, {
@@ -206,7 +222,7 @@ class RelyingPartySolution {
206
222
  response: encrypted
207
223
  });
208
224
  const body = formBody.toString();
209
- const response = await this.appFetch(requestObj.payload.response_uri, {
225
+ const response = await appFetch(requestObject.payload.response_uri, {
210
226
  method: "POST",
211
227
  headers: {
212
228
  "Content-Type": "application/x-www-form-urlencoded"
@@ -217,33 +233,7 @@ class RelyingPartySolution {
217
233
  return await response.json();
218
234
  }
219
235
  throw new _errors.IoWalletError(`Unable to send Authorization Response. Response: ${await response.text()} with code: ${response.status}`);
220
- }
221
-
222
- /**
223
- * Select a RSA public key from those provided by the RP to encrypt.
224
- *
225
- * @param entity The RP entity configuration
226
- * @returns A suitable public key with its compatible encryption algorithm
227
- * @throws {NoSuitableKeysFoundInEntityConfiguration} If entity do not contain any public key suitable for encrypting
228
- */
229
- chooseRSAPublicKeyToEncrypt(entity) {
230
- const [usingRsa256] = entity.payload.metadata.wallet_relying_party.jwks.filter(jwk => jwk.use === "enc" && jwk.kty === "RSA");
231
- if (usingRsa256) {
232
- return usingRsa256;
233
- }
234
-
235
- // No suitable key has been found
236
- throw new _errors.NoSuitableKeysFoundInEntityConfiguration("Encrypt with RP public key");
237
- }
238
-
239
- /**
240
- * Obtain the relying party entity configuration.
241
- */
242
- async getEntityConfiguration() {
243
- return (0, _trust.getEntityConfiguration)(this.relyingPartyBaseUrl, {
244
- appFetch: this.appFetch
245
- }).then(_types.RpEntityConfiguration.parse);
246
- }
247
- }
248
- exports.RelyingPartySolution = RelyingPartySolution;
236
+ };
237
+ };
238
+ exports.sendAuthorizationResponse = sendAuthorizationResponse;
249
239
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_errors","require","_ioReactNativeJwt","_types","_reactNativeUuid","_interopRequireDefault","_sdJwt","_trust","obj","__esModule","default","RelyingPartySolution","constructor","relyingPartyBaseUrl","walletInstanceAttestation","appFetch","arguments","length","undefined","fetch","decodeAuthRequestQR","qrcode","decoded","decodeBase64","decodedUrl","URL","protocol","resource","hostname","requestURI","searchParams","get","clientId","result","QRCodePayload","safeParse","success","data","AuthRequestDecodeError","error","message","getUnsignedWalletInstanceDPoP","walletInstanceAttestationJwk","authRequestUrl","SignJWT","jti","uuid","v4","htm","htu","ath","sha256ToBase64","setProtectedHeader","alg","jwk","typ","setIssuedAt","setExpirationTime","toSign","getRequestObject","signedWalletInstanceDPoP","requestUri","entity","response","method","headers","Authorization","DPoP","status","responseJson","json","responseEncodedJwt","responseJwt","decodeJwt","pubKey","payload","metadata","wallet_relying_party","jwks","find","_ref","kid","protectedHeader","NoSuitableKeysFoundInEntityConfiguration","verify","requestObj","RequestObject","parse","header","IoWalletError","prepareVpToken","walletInstanceIdentifier","_ref2","signKeyId","vc","claims","token","vp","paths","disclose","vp_token","iss","nonce","setAudience","response_uri","vc_scope","scope","presentation_submission","definition_id","id","descriptor_map","map","p","path","format","sendAuthorizationResponse","chooseRSAPublicKeyToEncrypt","authzResponsePayload","JSON","stringify","state","encrypted","EncryptJwe","enc","encrypt","formBody","URLSearchParams","body","toString","text","usingRsa256","filter","use","kty","getEntityConfiguration","then","RpEntityConfiguration","exports"],"sourceRoot":"../../../src","sources":["rp/index.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAKA,IAAAC,iBAAA,GAAAD,OAAA;AAQA,IAAAE,MAAA,GAAAF,OAAA;AAOA,IAAAG,gBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAAkD,SAAAI,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE3C,MAAMG,oBAAoB,CAAC;EAKhCC,WAAWA,CACTC,mBAA2B,EAC3BC,yBAAiC,EAEjC;IAAA,IADAC,QAA8B,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGG,KAAK;IAEtC,IAAI,CAACN,mBAAmB,GAAGA,mBAAmB;IAC9C,IAAI,CAACC,yBAAyB,GAAGA,yBAAyB;IAC1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AO,MAAML,QAAQ,CAACO,IAAI,CAAC,CAAC;IAC9B;IAEA,MAAM,IAAImB,qBAAa,CACpB,oDAAmD,MAAM1B,QAAQ,CAACkE,IAAI,CAAC,CAAE,eACxElE,QAAQ,CAACK,MACV,EACH,CAAC;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACUgD,2BAA2BA,CAACtD,MAA6B,EAAO;IACtE,MAAM,CAACoE,WAAW,CAAC,GACjBpE,MAAM,CAACa,OAAO,CAACC,QAAQ,CAACC,oBAAoB,CAACC,IAAI,CAACqD,MAAM,CACrD7E,GAAG,IAAKA,GAAG,CAAC8E,GAAG,KAAK,KAAK,IAAI9E,GAAG,CAAC+E,GAAG,KAAK,KAC5C,CAAC;IAEH,IAAIH,WAAW,EAAE;MACf,OAAOA,WAAW;IACpB;;IAEA;IACA,MAAM,IAAI/C,gDAAwC,CAChD,4BACF,CAAC;EACH;;EAEA;AACF;AACA;EACE,MAAMmD,sBAAsBA,CAAA,EAAmC;IAC7D,OAAO,IAAAA,6BAAsB,EAAC,IAAI,CAACzH,mBAAmB,EAAE;MACtDE,QAAQ,EAAE,IAAI,CAACA;IACjB,CAAC,CAAC,CAACwH,IAAI,CAACC,4BAAqB,CAACjD,KAAK,CAAC;EACtC;AACF;AAACkD,OAAA,CAAA9H,oBAAA,GAAAA,oBAAA"}
1
+ {"version":3,"names":["_errors","require","_ioReactNativeJwt","_types","_reactNativeUuid","_interopRequireDefault","_sdJwt","_dpop","WalletInstanceAttestation","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","chooseRSAPublicKeyToEncrypt","entity","usingRsa256","payload","metadata","wallet_relying_party","jwks","filter","jwk","use","kty","NoSuitableKeysFoundInEntityConfiguration","decodeAuthRequestQR","qrcode","decoded","decodeBase64","decodedUrl","URL","protocol","resource","hostname","requestURI","searchParams","clientId","result","QRCodePayload","safeParse","success","data","AuthRequestDecodeError","error","message","exports","getRequestObject","_ref","wiaCryptoContext","appFetch","fetch","walletInstanceAttestation","requestUri","rpEntityConfiguration","signedWalletInstanceDPoP","createDPopToken","jti","uuid","v4","htm","htu","ath","sha256ToBase64","response","method","headers","Authorization","DPoP","status","responseJson","json","responseEncodedJwt","responseJwt","decodeJwt","pubKey","find","_ref2","kid","protectedHeader","verify","requestObject","RequestObject","parse","header","IoWalletError","text","prepareVpToken","_ref3","pidCryptoContext","_ref4","_ref5","vc","claims","token","vp","paths","disclose","iss","decode","pidKid","getPublicKey","then","_","vp_token","SignJWT","setProtectedHeader","typ","setPayload","nonce","setAudience","response_uri","setIssuedAt","setExpirationTime","sign","vc_scope","scope","presentation_submission","definition_id","id","descriptor_map","map","p","path","format","sendAuthorizationResponse","_ref6","_ref7","presentation","authzResponsePayload","JSON","stringify","state","encrypted","EncryptJwe","alg","enc","encrypt","formBody","URLSearchParams","body","toString"],"sourceRoot":"../../../src","sources":["rp/index.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAKA,IAAAC,iBAAA,GAAAD,OAAA;AASA,IAAAE,MAAA,GAAAF,OAAA;AAEA,IAAAG,gBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AAEA,IAAAO,yBAAA,GAAAC,uBAAA,CAAAR,OAAA;AAA4E,SAAAS,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAF,wBAAAM,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,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AE,cAAc;MACnBC,GAAG,EAAE,eAAe;MACpB1D,GAAG,EAAExD,GAAG,CAACwD;IACX,CAAC,CAAC,CAAC2D,OAAO,CAACnH,GAAG,CAAC;IAEf,MAAMoH,QAAQ,GAAG,IAAIC,eAAe,CAAC;MAAE3E,QAAQ,EAAEqE;IAAU,CAAC,CAAC;IAC7D,MAAMO,IAAI,GAAGF,QAAQ,CAACG,QAAQ,CAAC,CAAC;IAEhC,MAAM7E,QAAQ,GAAG,MAAMd,QAAQ,CAAC+B,aAAa,CAAChE,OAAO,CAAC8F,YAAY,EAAE;MAClE9C,MAAM,EAAE,MAAM;MACdC,OAAO,EAAE;QACP,cAAc,EAAE;MAClB,CAAC;MACD0E;IACF,CAAC,CAAC;IAEF,IAAI5E,QAAQ,CAACK,MAAM,KAAK,GAAG,EAAE;MAC3B,OAAO,MAAML,QAAQ,CAACO,IAAI,CAAC,CAAC;IAC9B;IAEA,MAAM,IAAIc,qBAAa,CACpB,oDAAmD,MAAMrB,QAAQ,CAACsB,IAAI,CAAC,CAAE,eACxEtB,QAAQ,CAACK,MACV,EACH,CAAC;EACH,CAAC;AAAA;AAACvB,OAAA,CAAA+E,yBAAA,GAAAA,yBAAA"}
@@ -3,11 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.RpEntityConfiguration = exports.RequestObject = exports.QRCodePayload = void 0;
7
- var _jwk = require("../utils/jwk");
6
+ exports.RequestObject = exports.QRCodePayload = void 0;
8
7
  var _types = require("../sd-jwt/types");
9
8
  var z = _interopRequireWildcard(require("zod"));
10
- var _types2 = require("../trust/types");
11
9
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
10
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
11
  const RequestObject = z.object({
@@ -32,25 +30,7 @@ const RequestObject = z.object({
32
30
  scope: z.string()
33
31
  })
34
32
  });
35
-
36
- /**
37
- * EntityConfiguration plus the metadata specific for a Relying Party entity.
38
- */
39
33
  exports.RequestObject = RequestObject;
40
- const RpEntityConfiguration = _types2.EntityConfiguration.and(z.object({
41
- payload: z.object({
42
- metadata: z.object({
43
- wallet_relying_party: z.object({
44
- application_type: z.string().optional(),
45
- client_id: z.string().optional(),
46
- client_name: z.string().optional(),
47
- jwks: z.array(_jwk.JWK),
48
- contacts: z.array(z.string()).optional()
49
- }).passthrough()
50
- })
51
- })
52
- }));
53
- exports.RpEntityConfiguration = RpEntityConfiguration;
54
34
  const QRCodePayload = z.object({
55
35
  protocol: z.string(),
56
36
  resource: z.string(),
@@ -1 +1 @@
1
- {"version":3,"names":["_jwk","require","_types","z","_interopRequireWildcard","_types2","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","RequestObject","object","header","typ","literal","optional","alg","string","kid","trust_chain","array","payload","iss","iat","UnixTime","exp","state","nonce","response_uri","response_type","response_mode","client_id","client_id_scheme","scope","exports","RpEntityConfiguration","EntityConfiguration","and","metadata","wallet_relying_party","application_type","client_name","jwks","JWK","contacts","passthrough","QRCodePayload","protocol","resource","clientId","requestURI"],"sourceRoot":"../../../src","sources":["rp/types.ts"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,CAAA,GAAAC,uBAAA,CAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAAqD,SAAAK,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAH,wBAAAO,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,EAAAW,GAAA,cAAAI,IAAA,KAAAA,IAAA,CAAAV,GAAA,IAAAU,IAAA,CAAAC,GAAA,KAAAR,MAAA,CAAAC,cAAA,CAAAH,MAAA,EAAAK,GAAA,EAAAI,IAAA,YAAAT,MAAA,CAAAK,GAAA,IAAAX,GAAA,CAAAW,GAAA,SAAAL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CAACC,GAAG,CAC1DpD,CAAC,CAAC0B,MAAM,CAAC;EACPU,OAAO,EAAEpC,CAAC,CAAC0B,MAAM,CAAC;IAChB2B,QAAQ,EAAErD,CAAC,CAAC0B,MAAM,CAAC;MACjB4B,oBAAoB,EAAEtD,CAAC,CACpB0B,MAAM,CAAC;QACN6B,gBAAgB,EAAEvD,CAAC,CAACgC,MAAM,CAAC,CAAC,CAACF,QAAQ,CAAC,CAAC;QACvCgB,SAAS,EAAE9C,CAAC,CAACgC,MAAM,CAAC,CAAC,CAACF,QAAQ,CAAC,CAAC;QAChC0B,WAAW,EAAExD,CAAC,CAACgC,MAAM,CAAC,CAAC,CAACF,QAAQ,CAAC,CAAC;QAClC2B,IAAI,EAAEzD,CAAC,CAACmC,KAAK,CAACuB,QAAG,CAAC;QAClBC,QAAQ,EAAE3D,CAAC,CAACmC,KAAK,CAACnC,CAAC,CAACgC,MAAM,CAAC,CAAC,CAAC,CAACF,QAAQ,CAAC;MACzC,CAAC,CAAC,CACD8B,WAAW,CAAC;IACjB,CAAC;EACH,CAAC;AACH,CAAC,CACH,CAAC;AAACX,OAAA,CAAAC,qBAAA,GAAAA,qBAAA;AAGK,MAAMW,aAAa,GAAG7D,CAAC,CAAC0B,MAAM,CAAC;EACpCoC,QAAQ,EAAE9D,CAAC,CAACgC,MAAM,CAAC,CAAC;EACpB+B,QAAQ,EAAE/D,CAAC,CAACgC,MAAM,CAAC,CAAC;EAAE;EACtBgC,QAAQ,EAAEhE,CAAC,CAACgC,MAAM,CAAC,CAAC;EACpBiC,UAAU,EAAEjE,CAAC,CAACgC,MAAM,CAAC;AACvB,CAAC,CAAC;;AAEF;AACA;AACA;AAFAiB,OAAA,CAAAY,aAAA,GAAAA,aAAA"}
1
+ {"version":3,"names":["_types","require","z","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","RequestObject","object","header","typ","literal","optional","alg","string","kid","trust_chain","array","payload","iss","iat","UnixTime","exp","state","nonce","response_uri","response_type","response_mode","client_id","client_id_scheme","scope","exports","QRCodePayload","protocol","resource","clientId","requestURI"],"sourceRoot":"../../../src","sources":["rp/types.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,CAAA,GAAAC,uBAAA,CAAAF,OAAA;AAAyB,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAF,wBAAAM,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,EAAAW,GAAA,cAAAI,IAAA,KAAAA,IAAA,CAAAV,GAAA,IAAAU,IAAA,CAAAC,GAAA,KAAAR,MAAA,CAAAC,cAAA,CAAAH,MAAA,EAAAK,GAAA,EAAAI,IAAA,YAAAT,MAAA,CAAAK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AMyB,aAAa,GAAGjD,CAAC,CAACyB,MAAM,CAAC;EACpCyB,QAAQ,EAAElD,CAAC,CAAC+B,MAAM,CAAC,CAAC;EACpBoB,QAAQ,EAAEnD,CAAC,CAAC+B,MAAM,CAAC,CAAC;EAAE;EACtBqB,QAAQ,EAAEpD,CAAC,CAAC+B,MAAM,CAAC,CAAC;EACpBsB,UAAU,EAAErD,CAAC,CAAC+B,MAAM,CAAC;AACvB,CAAC,CAAC;;AAEF;AACA;AACA;AAFAiB,OAAA,CAAAC,aAAA,GAAAA,aAAA"}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getEntityConfiguration = getEntityConfiguration;
6
+ exports.getWalletProviderEntityConfiguration = exports.getTrustAnchorEntityConfiguration = exports.getRelyingPartyEntityConfiguration = exports.getEntityConfiguration = exports.getCredentialIssuerEntityConfiguration = void 0;
7
7
  Object.defineProperty(exports, "verifyTrustChain", {
8
8
  enumerable: true,
9
9
  get: function () {
@@ -15,18 +15,27 @@ var _types = require("./types");
15
15
  var _errors = require("../utils/errors");
16
16
  var _chain = require("./chain");
17
17
  /**
18
- * Fetch and parse teh entity configuration document for a given federation entity
18
+ * Fetch and parse the entity configuration document for a given federation entity.
19
+ * This is an inner method to serve public interfaces.
20
+ *
21
+ * To add another entity configuration type (example: Foo entity type):
22
+ * - create its zod schema and type by inherit from the base type (example: FooEntityConfiguration = BaseEntityConfiguration.and(...))
23
+ * - add such type to EntityConfiguration union
24
+ * - add an overload to this function
25
+ * - create a public function which use such type (example: getFooEntityConfiguration = (url, options) => Promise<FooEntityConfiguration>)
19
26
  *
20
27
  * @param entityBaseUrl The base url of the entity.
28
+ * @param schema The expected schema of the entity configuration, according to the kind of entity we are fetching from.
21
29
  * @param options.appFetch An optional instance of the http client to be used.
22
30
  * @returns The parsed entity configuration object
23
31
  * @throws {IoWalletError} If the http request fails
24
32
  * @throws Parse error if the document is not in the expected shape.
25
33
  */
26
- async function getEntityConfiguration(entityBaseUrl) {
34
+
35
+ async function fetchAndParseEntityConfiguration(entityBaseUrl, schema) {
27
36
  let {
28
37
  appFetch = fetch
29
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
38
+ } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
30
39
  const wellKnownUrl = `${entityBaseUrl}/.well-known/openid-federation`;
31
40
  const response = await appFetch(wellKnownUrl, {
32
41
  method: "GET"
@@ -34,11 +43,21 @@ async function getEntityConfiguration(entityBaseUrl) {
34
43
  if (response.status === 200) {
35
44
  const responseText = await response.text();
36
45
  const responseJwt = (0, _ioReactNativeJwt.decode)(responseText);
37
- return _types.EntityConfiguration.parse({
46
+ return schema.parse({
38
47
  header: responseJwt.protectedHeader,
39
48
  payload: responseJwt.payload
40
49
  });
41
50
  }
42
51
  throw new _errors.IoWalletError(`Unable to obtain Entity Configuration at ${wellKnownUrl}. Response code: ${response.status}`);
43
52
  }
53
+ const getWalletProviderEntityConfiguration = (entityBaseUrl, options) => fetchAndParseEntityConfiguration(entityBaseUrl, _types.WalletProviderEntityConfiguration, options);
54
+ exports.getWalletProviderEntityConfiguration = getWalletProviderEntityConfiguration;
55
+ const getCredentialIssuerEntityConfiguration = (entityBaseUrl, options) => fetchAndParseEntityConfiguration(entityBaseUrl, _types.CredentialIssuerEntityConfiguration, options);
56
+ exports.getCredentialIssuerEntityConfiguration = getCredentialIssuerEntityConfiguration;
57
+ const getTrustAnchorEntityConfiguration = (entityBaseUrl, options) => fetchAndParseEntityConfiguration(entityBaseUrl, _types.TrustAnchorEntityConfiguration, options);
58
+ exports.getTrustAnchorEntityConfiguration = getTrustAnchorEntityConfiguration;
59
+ const getRelyingPartyEntityConfiguration = (entityBaseUrl, options) => fetchAndParseEntityConfiguration(entityBaseUrl, _types.RelyingPartyEntityConfiguration, options);
60
+ exports.getRelyingPartyEntityConfiguration = getRelyingPartyEntityConfiguration;
61
+ const getEntityConfiguration = (entityBaseUrl, options) => fetchAndParseEntityConfiguration(entityBaseUrl, _types.EntityConfiguration, options);
62
+ exports.getEntityConfiguration = getEntityConfiguration;
44
63
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_ioReactNativeJwt","require","_types","_errors","_chain","getEntityConfiguration","entityBaseUrl","appFetch","fetch","arguments","length","undefined","wellKnownUrl","response","method","status","responseText","text","responseJwt","decodeJwt","EntityConfiguration","parse","header","protectedHeader","payload","IoWalletError"],"sourceRoot":"../../../src","sources":["trust/index.ts"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeI,sBAAsBA,CAC1CC,aAAqB,EAMS;EAAA,IAL9B;IACEC,QAAQ,GAAGC;EAGb,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAEN,MAAMG,YAAY,GAAI,GAAEN,aAAc,gCAA+B;EAErE,MAAMO,QAAQ,GAAG,MAAMN,QAAQ,CAACK,YAAY,EAAE;IAC5CE,MAAM,EAAE;EACV,CAAC,CAAC;EAEF,IAAID,QAAQ,CAACE,MAAM,KAAK,GAAG,EAAE;IAC3B,MAAMC,YAAY,GAAG,MAAMH,QAAQ,CAACI,IAAI,CAAC,CAAC;IAC1C,MAAMC,WAAW,GAAG,IAAAC,wBAAS,EAACH,YAAY,CAAC;IAC3C,OAAOI,0BAAmB,CAACC,KAAK,CAAC;MAC/BC,MAAM,EAAEJ,WAAW,CAACK,eAAe;MACnCC,OAAO,EAAEN,WAAW,CAACM;IACvB,CAAC,CAAC;EACJ;EAEA,MAAM,IAAIC,qBAAa,CACpB,4CAA2Cb,YAAa,oBAAmBC,QAAQ,CAACE,MAAO,EAC9F,CAAC;AACH"}
1
+ {"version":3,"names":["_ioReactNativeJwt","require","_types","_errors","_chain","fetchAndParseEntityConfiguration","entityBaseUrl","schema","appFetch","fetch","arguments","length","undefined","wellKnownUrl","response","method","status","responseText","text","responseJwt","decodeJwt","parse","header","protectedHeader","payload","IoWalletError","getWalletProviderEntityConfiguration","options","WalletProviderEntityConfiguration","exports","getCredentialIssuerEntityConfiguration","CredentialIssuerEntityConfiguration","getTrustAnchorEntityConfiguration","TrustAnchorEntityConfiguration","getRelyingPartyEntityConfiguration","RelyingPartyEntityConfiguration","getEntityConfiguration","EntityConfiguration"],"sourceRoot":"../../../src","sources":["trust/index.ts"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAOA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAoCA,eAAeI,gCAAgCA,CAC7CC,aAAqB,EACrBC,MAK8B,EAM9B;EAAA,IALA;IACEC,QAAQ,GAAGC;EAGb,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAEN,MAAMG,YAAY,GAAI,GAAEP,aAAc,gCAA+B;EAErE,MAAMQ,QAAQ,GAAG,MAAMN,QAAQ,CAACK,YAAY,EAAE;IAC5CE,MAAM,EAAE;EACV,CAAC,CAAC;EAEF,IAAID,QAAQ,CAACE,MAAM,KAAK,GAAG,EAAE;IAC3B,MAAMC,YAAY,GAAG,MAAMH,QAAQ,CAACI,IAAI,CAAC,CAAC;IAC1C,MAAMC,WAAW,GAAG,IAAAC,wBAAS,EAACH,YAAY,CAAC;IAC3C,OAAOV,MAAM,CAACc,KAAK,CAAC;MAClBC,MAAM,EAAEH,WAAW,CAACI,eAAe;MACnCC,OAAO,EA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