@pagopa/io-react-native-wallet 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. package/lib/commonjs/pid/issuing.js +28 -0
  2. package/lib/commonjs/pid/issuing.js.map +1 -1
  3. package/lib/commonjs/pid/metadata.js +51 -0
  4. package/lib/commonjs/pid/metadata.js.map +1 -0
  5. package/lib/commonjs/pid/sd-jwt/index.js +2 -1
  6. package/lib/commonjs/pid/sd-jwt/index.js.map +1 -1
  7. package/lib/commonjs/rp/index.js +148 -3
  8. package/lib/commonjs/rp/index.js.map +1 -1
  9. package/lib/commonjs/rp/types.js +4 -0
  10. package/lib/commonjs/rp/types.js.map +1 -1
  11. package/lib/commonjs/sd-jwt/__test__/index.test.js +119 -0
  12. package/lib/commonjs/sd-jwt/__test__/index.test.js.map +1 -0
  13. package/lib/commonjs/sd-jwt/index.js +84 -4
  14. package/lib/commonjs/sd-jwt/index.js.map +1 -1
  15. package/lib/commonjs/sd-jwt/types.js +9 -0
  16. package/lib/commonjs/sd-jwt/types.js.map +1 -1
  17. package/lib/commonjs/sd-jwt/verifier.js +7 -5
  18. package/lib/commonjs/sd-jwt/verifier.js.map +1 -1
  19. package/lib/commonjs/utils/errors.js +76 -1
  20. package/lib/commonjs/utils/errors.js.map +1 -1
  21. package/lib/module/pid/issuing.js +30 -2
  22. package/lib/module/pid/issuing.js.map +1 -1
  23. package/lib/module/pid/metadata.js +43 -0
  24. package/lib/module/pid/metadata.js.map +1 -0
  25. package/lib/module/pid/sd-jwt/index.js +3 -3
  26. package/lib/module/pid/sd-jwt/index.js.map +1 -1
  27. package/lib/module/rp/index.js +150 -5
  28. package/lib/module/rp/index.js.map +1 -1
  29. package/lib/module/rp/types.js +4 -0
  30. package/lib/module/rp/types.js.map +1 -1
  31. package/lib/module/sd-jwt/__test__/index.test.js +118 -0
  32. package/lib/module/sd-jwt/__test__/index.test.js.map +1 -0
  33. package/lib/module/sd-jwt/index.js +83 -3
  34. package/lib/module/sd-jwt/index.js.map +1 -1
  35. package/lib/module/sd-jwt/types.js +10 -0
  36. package/lib/module/sd-jwt/types.js.map +1 -1
  37. package/lib/module/sd-jwt/verifier.js +8 -6
  38. package/lib/module/sd-jwt/verifier.js.map +1 -1
  39. package/lib/module/utils/errors.js +71 -0
  40. package/lib/module/utils/errors.js.map +1 -1
  41. package/lib/typescript/src/index.d.ts.map +1 -0
  42. package/lib/typescript/src/pid/index.d.ts.map +1 -0
  43. package/lib/typescript/{pid → src/pid}/issuing.d.ts +9 -0
  44. package/lib/typescript/src/pid/issuing.d.ts.map +1 -0
  45. package/lib/typescript/src/pid/metadata.d.ts +528 -0
  46. package/lib/typescript/src/pid/metadata.d.ts.map +1 -0
  47. package/lib/typescript/src/pid/sd-jwt/converters.d.ts.map +1 -0
  48. package/lib/typescript/src/pid/sd-jwt/index.d.ts.map +1 -0
  49. package/lib/typescript/src/pid/sd-jwt/types.d.ts.map +1 -0
  50. package/lib/typescript/src/rp/__test__/index.test.d.ts.map +1 -0
  51. package/lib/typescript/src/rp/index.d.ts +89 -0
  52. package/lib/typescript/src/rp/index.d.ts.map +1 -0
  53. package/lib/typescript/{rp → src/rp}/types.d.ts +54 -47
  54. package/lib/typescript/{rp → src/rp}/types.d.ts.map +1 -1
  55. package/lib/typescript/src/sd-jwt/__test__/converters.test.d.ts.map +1 -0
  56. package/lib/typescript/src/sd-jwt/__test__/index.test.d.ts +2 -0
  57. package/lib/typescript/src/sd-jwt/__test__/index.test.d.ts.map +1 -0
  58. package/lib/typescript/src/sd-jwt/__test__/types.test.d.ts.map +1 -0
  59. package/lib/typescript/src/sd-jwt/converters.d.ts.map +1 -0
  60. package/lib/typescript/{sd-jwt → src/sd-jwt}/index.d.ts +22 -2
  61. package/lib/typescript/src/sd-jwt/index.d.ts.map +1 -0
  62. package/lib/typescript/{sd-jwt → src/sd-jwt}/types.d.ts +12 -0
  63. package/lib/typescript/src/sd-jwt/types.d.ts.map +1 -0
  64. package/lib/typescript/src/sd-jwt/verifier.d.ts +3 -0
  65. package/lib/typescript/src/sd-jwt/verifier.d.ts.map +1 -0
  66. package/lib/typescript/src/utils/dpop.d.ts.map +1 -0
  67. package/lib/typescript/{utils → src/utils}/errors.d.ts +41 -0
  68. package/lib/typescript/src/utils/errors.d.ts.map +1 -0
  69. package/lib/typescript/src/utils/jwk.d.ts.map +1 -0
  70. package/lib/typescript/src/wallet-instance-attestation/index.d.ts.map +1 -0
  71. package/lib/typescript/src/wallet-instance-attestation/issuing.d.ts.map +1 -0
  72. package/lib/typescript/{wallet-instance-attestation → src/wallet-instance-attestation}/types.d.ts +8 -8
  73. package/lib/typescript/{wallet-instance-attestation → src/wallet-instance-attestation}/types.d.ts.map +1 -1
  74. package/package.json +4 -3
  75. package/src/pid/issuing.ts +38 -1
  76. package/src/pid/metadata.ts +46 -0
  77. package/src/pid/sd-jwt/index.ts +6 -3
  78. package/src/rp/index.ts +189 -5
  79. package/src/rp/types.ts +8 -0
  80. package/src/sd-jwt/__test__/index.test.ts +171 -0
  81. package/src/sd-jwt/index.ts +84 -7
  82. package/src/sd-jwt/types.ts +13 -0
  83. package/src/sd-jwt/verifier.ts +5 -7
  84. package/src/utils/errors.ts +81 -0
  85. package/lib/typescript/index.d.ts.map +0 -1
  86. package/lib/typescript/pid/index.d.ts.map +0 -1
  87. package/lib/typescript/pid/issuing.d.ts.map +0 -1
  88. package/lib/typescript/pid/sd-jwt/converters.d.ts.map +0 -1
  89. package/lib/typescript/pid/sd-jwt/index.d.ts.map +0 -1
  90. package/lib/typescript/pid/sd-jwt/types.d.ts.map +0 -1
  91. package/lib/typescript/rp/__test__/index.test.d.ts.map +0 -1
  92. package/lib/typescript/rp/index.d.ts +0 -43
  93. package/lib/typescript/rp/index.d.ts.map +0 -1
  94. package/lib/typescript/sd-jwt/__test__/converters.test.d.ts.map +0 -1
  95. package/lib/typescript/sd-jwt/__test__/types.test.d.ts.map +0 -1
  96. package/lib/typescript/sd-jwt/converters.d.ts.map +0 -1
  97. package/lib/typescript/sd-jwt/index.d.ts.map +0 -1
  98. package/lib/typescript/sd-jwt/types.d.ts.map +0 -1
  99. package/lib/typescript/sd-jwt/verifier.d.ts +0 -3
  100. package/lib/typescript/sd-jwt/verifier.d.ts.map +0 -1
  101. package/lib/typescript/utils/dpop.d.ts.map +0 -1
  102. package/lib/typescript/utils/errors.d.ts.map +0 -1
  103. package/lib/typescript/utils/jwk.d.ts.map +0 -1
  104. package/lib/typescript/wallet-instance-attestation/index.d.ts.map +0 -1
  105. package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +0 -1
  106. /package/lib/typescript/{index.d.ts → src/index.d.ts} +0 -0
  107. /package/lib/typescript/{pid → src/pid}/index.d.ts +0 -0
  108. /package/lib/typescript/{pid → src/pid}/sd-jwt/converters.d.ts +0 -0
  109. /package/lib/typescript/{pid → src/pid}/sd-jwt/index.d.ts +0 -0
  110. /package/lib/typescript/{pid → src/pid}/sd-jwt/types.d.ts +0 -0
  111. /package/lib/typescript/{rp → src/rp}/__test__/index.test.d.ts +0 -0
  112. /package/lib/typescript/{sd-jwt → src/sd-jwt}/__test__/converters.test.d.ts +0 -0
  113. /package/lib/typescript/{sd-jwt → src/sd-jwt}/__test__/types.test.d.ts +0 -0
  114. /package/lib/typescript/{sd-jwt → src/sd-jwt}/converters.d.ts +0 -0
  115. /package/lib/typescript/{utils → src/utils}/dpop.d.ts +0 -0
  116. /package/lib/typescript/{utils → src/utils}/jwk.d.ts +0 -0
  117. /package/lib/typescript/{wallet-instance-attestation → src/wallet-instance-attestation}/index.d.ts +0 -0
  118. /package/lib/typescript/{wallet-instance-attestation → src/wallet-instance-attestation}/issuing.d.ts +0 -0
@@ -10,6 +10,7 @@ var _reactNativeUuid = _interopRequireDefault(require("react-native-uuid"));
10
10
  var _errors = require("../utils/errors");
11
11
  var _dpop = require("../utils/dpop");
12
12
  var _ioReactNativeCrypto = require("@pagopa/io-react-native-crypto");
13
+ var _metadata = require("./metadata");
13
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
15
  // This is a temporary type that will be used for demo purposes only
15
16
 
@@ -226,6 +227,33 @@ class Issuing {
226
227
  }
227
228
  throw new _errors.PidIssuingError(`Unable to obtain credential!`);
228
229
  }
230
+
231
+ /**
232
+ * Obtain the PID issuer metadata
233
+ *
234
+ * @function
235
+ * @returns PID issuer metadata
236
+ *
237
+ */
238
+ async getEntityConfiguration() {
239
+ const metadataUrl = new URL(".well-known/openid-federation", this.pidProviderBaseUrl).href;
240
+ const response = await this.appFetch(metadataUrl);
241
+ if (response.status === 200) {
242
+ const jwtMetadata = await response.text();
243
+ const {
244
+ payload
245
+ } = (0, _ioReactNativeJwt.decode)(jwtMetadata);
246
+ const result = _metadata.PidIssuerEntityConfiguration.safeParse(payload);
247
+ if (result.success) {
248
+ const parsedMetadata = result.data;
249
+ await (0, _ioReactNativeJwt.verify)(jwtMetadata, parsedMetadata.jwks.keys);
250
+ return parsedMetadata;
251
+ } else {
252
+ throw new _errors.PidMetadataError(result.error.message);
253
+ }
254
+ }
255
+ throw new _errors.PidMetadataError(`Unable to obtain PID metadata. Response: ${await response.text()} with status: ${response.status}`);
256
+ }
229
257
  }
230
258
  exports.Issuing = Issuing;
231
259
  //# sourceMappingURL=issuing.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_ioReactNativeJwt","require","_jwk","_reactNativeUuid","_interopRequireDefault","_errors","_dpop","_ioReactNativeCrypto","obj","__esModule","default","Issuing","constructor","pidProviderBaseUrl","walletProviderBaseUrl","walletInstanceAttestation","clientId","appFetch","arguments","length","undefined","fetch","state","uuid","v4","codeVerifier","authorizationCode","getUnsignedJwtForPar","jwk","parsedJwk","JWK","parse","keyThumbprint","thumbprint","publicKey","kid","codeChallenge","sha256ToBase64","unsignedJwtForPar","SignJWT","client_assertion_type","authorization_details","credentialDefinition","type","format","response_type","code_challenge_method","redirect_uri","client_id","code_challenge","setProtectedHeader","alg","setIssuedAt","setExpirationTime","toSign","getPar","signature","signedJwtForPar","appendSignature","parUrl","URL","href","requestBody","client_assertion","request","formBody","URLSearchParams","response","method","headers","body","toString","status","result","json","request_uri","PidIssuingError","text","getUnsignedDPoP","tokenUrl","dPop","getUnsignedDPop","htm","htu","jti","getAuthToken","dPopKeyTag","dPopKey","generate","unsignedDPopForToken","dPopTokenSignature","sign","deleteKey","signedDPop","decodedJwtDPop","decodeJwt","payload","grant_type","code","code_verifier","DPoP","getUnsignedNonceProof","nonce","unsignedProof","setAudience","setIssuer","getCredential","unsignedDPopForPid","dPopPidSignature","unsignedNonceProof","nonceProofSignature","accessToken","cieData","signedDPopForPid","signedNonceProof","credentialUrl","credential_definition","JSON","stringify","proof","jwt","proof_type","Authorization","exports"],"sourceRoot":"../../../src","sources":["pid/issuing.ts"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAMA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,oBAAA,GAAAN,OAAA;AAA2E,SAAAG,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE3E;;AAgBO,MAAMG,OAAO,CAAC;EAUnBC,WAAWA,CACTC,kBAA0B,EAC1BC,qBAA6B,EAC7BC,yBAAiC,EACjCC,QAAgB,EAEhB;IAAA,IADAC,QAA8B,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGG,KAAK;IAEtC,IAAI,CAACR,kBAAkB,GAAGA,kBAAkB;IAC5C,IAAI,CAACC,qBAAqB,GAAGA,qBAAqB;IAClD,IAAI,CAACQ,KAAK,GAAI,GAAEC,wBAAI,CAACC,EAAE,CAAC,CAAE,EAAC;IAC3B,IAAI,CAACC,YAAY,GAAI,GAAEF,wBAAI,CAACC,EAAE,CAAC,CAA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pDiD,kBAAkB,EAClBC,gBACF,CAAC;IACD,MAAMM,gBAAgB,GAAG,MAAM3E,yBAAO,CAACmB,eAAe,CACpDmD,kBAAkB,EAClBC,mBACF,CAAC;IACD,MAAMK,aAAa,GAAG,IAAIvD,GAAG,CAAC,aAAa,EAAE,IAAI,CAAC/C,kBAAkB,CAAC,CAACgD,IAAI;IAE1E,MAAMC,WAAW,GAAG;MAClBsD,qBAAqB,EAAEC,IAAI,CAACC,SAAS,CAAC;QAAE3E,IAAI,EAAE,CAAC,iBAAiB;MAAE,CAAC,CAAC;MACpEC,MAAM,EAAE,WAAW;MACnB2E,KAAK,EAAEF,IAAI,CAACC,SAAS,CAAC;QACpBE,GAAG,EAAEN,gBAAgB;QACrBF,OAAO;QACPS,UAAU,EAAE;MACd,CAAC;IACH,CAAC;IACD,MAAMxD,QAAQ,GAAG,IAAIC,eAAe,CAACJ,WAAW,CAAC;IAEjD,MAAMK,QAAQ,GAAG,MAAM,IAAI,CAAClD,QAAQ,CAACkG,aAAa,EAAE;MAClD/C,MAAM,EAAE,MAAM;MACdC,OAAO,EAAE;QACP,cAAc,EAAE,mCAAmC;QACnD+B,IAAI,EAAEa,gBAAgB;QACtBS,aAAa,EAAEX;MACjB,CAAC;MACDzC,IAAI,EAAEL,QAAQ,CAACM,QAAQ,CAAC;IAC1B,CAAC,CAAC;IAEF,IAAIJ,QAAQ,CAACK,MAAM,KAAK,GAAG,EAAE;MAC3B,OAAO,MAAML,QAAQ,CAACO,IAAI,CAAC,CAAC;IAC9B;IAEA,MAAM,IAAIE,uBAAe,CAAE,8BAA6B,CAAC;EAC3D;AACF;AAAC+C,OAAA,CAAAhH,OAAA,GAAAA,OAAA"}
1
+ {"version":3,"names":["_ioReactNativeJwt","require","_jwk","_reactNativeUuid","_interopRequireDefault","_errors","_dpop","_ioReactNativeCrypto","_metadata","obj","__esModule","default","Issuing","constructor","pidProviderBaseUrl","walletProviderBaseUrl","walletInstanceAttestation","clientId","appFetch","arguments","length","undefined","fetch","state","uuid","v4","codeVerifier","authorizationCode","getUnsignedJwtForPar","jwk","parsedJwk","JWK","parse","keyThumbprint","thumbprint","publicKey","kid","codeChallenge","sha256ToBase64","unsignedJwtForPar","SignJWT","client_assertion_type","authorization_details","credentialDefinition","type","format","response_type","code_challenge_method","redirect_uri","client_id","code_challenge","setProtectedHeader","alg","setIssuedAt","setExpirationTime","toSign","getPar","signature","signedJwtForPar","appendSignature","parUrl","URL","href","requestBody","client_assertion","request","formBody","URLSearchParams","response","method","headers","body","toString","status","result","json","request_uri","PidIssuingError","text","getUnsignedDPoP","tokenUrl","dPop","getUnsignedDPop","htm","htu","jti","getAuthToken","dPopKeyTag","dPopKey","generate","unsignedDPopForToken","dPopTokenSignature","sign","deleteKey","signedDPop","decodedJwtDPop","decodeJwt","payload","grant_type","code","code_verifier","DPoP","getUnsignedNonceProof","nonce","unsignedProof","setAudience","setIssuer","getCredential","unsignedDPopForPid","dPopPidSignature","unsignedNonceProof","nonceProofSignature","accessToken","cieData","signedDPopForPid","signedNonceProof","credentialUrl","credential_definition","JSON","stringify","proof","jwt","proof_type","Authorization","getEntityConfiguration","metadataUrl","jwtMetadata","PidIssuerEntityConfiguration","safeParse","success","parsedMetadata","data","verifyJwt","jwks","keys","PidMetadataError","error","message","exports"],"sourceRoot":"../../../src","sources":["pid/issuing.ts"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAOA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,oBAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AAA0D,SAAAG,uBAAAK,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE1D;;AAgBO,MAAMG,OAAO,CAAC;EAUnBC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6
+ exports.PidIssuerEntityConfiguration = exports.PidDisplayMetadata = void 0;
7
+ var _jwk = require("../utils/jwk");
8
+ var _zod = require("zod");
9
+ const PidDisplayMetadata = _zod.z.object({
10
+ name: _zod.z.string(),
11
+ locale: _zod.z.string(),
12
+ logo: _zod.z.object({
13
+ url: _zod.z.string(),
14
+ alt_text: _zod.z.string()
15
+ }),
16
+ background_color: _zod.z.string(),
17
+ text_color: _zod.z.string()
18
+ });
19
+ exports.PidDisplayMetadata = PidDisplayMetadata;
20
+ const PidIssuerEntityConfiguration = _zod.z.object({
21
+ jwks: _zod.z.object({
22
+ keys: _zod.z.array(_jwk.JWK)
23
+ }),
24
+ metadata: _zod.z.object({
25
+ openid_credential_issuer: _zod.z.object({
26
+ credential_issuer: _zod.z.string(),
27
+ authorization_endpoint: _zod.z.string(),
28
+ token_endpoint: _zod.z.string(),
29
+ pushed_authorization_request_endpoint: _zod.z.string(),
30
+ dpop_signing_alg_values_supported: _zod.z.array(_zod.z.string()),
31
+ credential_endpoint: _zod.z.string(),
32
+ credentials_supported: _zod.z.object({
33
+ "eu.eudiw.pid.it": _zod.z.object({
34
+ format: _zod.z.literal("vc+sd-jwt"),
35
+ cryptographic_binding_methods_supported: _zod.z.array(_zod.z.string()),
36
+ cryptographic_suites_supported: _zod.z.array(_zod.z.string()),
37
+ display: _zod.z.array(PidDisplayMetadata)
38
+ })
39
+ })
40
+ }),
41
+ federation_entity: _zod.z.object({
42
+ organization_name: _zod.z.string(),
43
+ homepage_uri: _zod.z.string(),
44
+ policy_uri: _zod.z.string(),
45
+ tos_uri: _zod.z.string(),
46
+ logo_uri: _zod.z.string()
47
+ })
48
+ })
49
+ });
50
+ exports.PidIssuerEntityConfiguration = PidIssuerEntityConfiguration;
51
+ //# sourceMappingURL=metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_jwk","require","_zod","PidDisplayMetadata","z","object","name","string","locale","logo","url","alt_text","background_color","text_color","exports","PidIssuerEntityConfiguration","jwks","keys","array","JWK","metadata","openid_credential_issuer","credential_issuer","authorization_endpoint","token_endpoint","pushed_authorization_request_endpoint","dpop_signing_alg_values_supported","credential_endpoint","credentials_supported","format","literal","cryptographic_binding_methods_supported","cryptographic_suites_supported","display","federation_entity","organization_name","homepage_uri","policy_uri","tos_uri","logo_uri"],"sourceRoot":"../../../src","sources":["pid/metadata.ts"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AAGO,MAAME,kBAAkB,GAAGC,MAAC,CAACC,MAAM,CAAC;EACzCC,IAAI,EAAEF,MAAC,CAACG,MAAM,CAAC,CAAC;EAChBC,MAAM,EAAEJ,MAAC,CAACG,MAAM,CAAC,CAAC;EAClBE,IAAI,EAAEL,MAAC,CAACC,MAAM,CAAC;IACbK,GAAG,EAAEN,MAAC,CAACG,MAAM,CAAC,CAAC;IACfI,QAAQ,EAAEP,MAAC,CAACG,MAAM,CAAC;EACrB,CAAC,CAAC;EACFK,gBAAgB,EAAER,MAAC,CAACG,MAAM,CAAC,CAAC;EAC5BM,UAAU,EAAET,MAAC,CAACG,MAAM,CAAC;AACvB,CAAC,CAAC;AAACO,OAAA,CAAAX,kBAAA,GAAAA,kBAAA;AAKI,MAAMY,4BAA4B,GAAGX,MAAC,CAACC,MAAM,CAAC;EACnDW,IAAI,EAAEZ,MAAC,CAACC,MAAM,CAAC;IAAEY,IAAI,EAAEb,MAAC,CAACc,KAAK,CAACC,QAAG;EAAE,CAAC,CAAC;EACtCC,QAAQ,EAAEhB,MAAC,CAACC,MAAM,CAAC;IACjBgB,wBAAwB,EAAEjB,MAAC,CAACC,MAAM,CAAC;MACjCiB,iBAAiB,EAAElB,MAAC,CAACG,MAAM,CAAC,CAAC;MAC7BgB,sBAAsB,EAAEnB,MAAC,CAACG,MAAM,CAAC,CAAC;MAClCiB,cAAc,EAAEpB,MAAC,CAACG,MAAM,CAAC,CAAC;MAC1BkB,qCAAqC,EAAErB,MAAC,CAACG,MAAM,CAAC,CAAC;MACjDmB,iCAAiC,EAAEtB,MAAC,CAACc,KAAK,CAACd,MAAC,CAACG,MAAM,CAAC,CAAC,CAAC;MACtDoB,mBAAmB,EAAEvB,MAAC,CAACG,MAAM,CAAC,CAAC;MAC/BqB,qBAAqB,EAAExB,MAAC,CAACC,MAAM,CAAC;QAC9B,iBAAiB,EAAED,MAAC,CAACC,MAAM,CAAC;UAC1BwB,MAAM,EAAEzB,MAAC,CAAC0B,OAAO,CAAC,WAAW,CAAC;UAC9BC,uCAAuC,EAAE3B,MAAC,CAACc,KAAK,CAACd,MAAC,CAACG,MAAM,CAAC,CAAC,CAAC;UAC5DyB,8BAA8B,EAAE5B,MAAC,CAACc,KAAK,CAACd,MAAC,CAACG,MAAM,CAAC,CAAC,CAAC;UACnD0B,OAAO,EAAE7B,MAAC,CAACc,KAAK,CAACf,kBAAkB;QACrC,CAAC;MACH,CAAC;IACH,CAAC,CAAC;IACF+B,iBAAiB,EAAE9B,MAAC,CAACC,MAAM,CAAC;MAC1B8B,iBAAiB,EAAE/B,MAAC,CAACG,MAAM,CAAC,CAAC;MAC7B6B,YAAY,EAAEhC,MAAC,CAACG,MAAM,CAAC,CAAC;MACxB8B,UAAU,EAAEjC,MAAC,CAACG,MAAM,CAAC,CAAC;MACtB+B,OAAO,EAAElC,MAAC,CAACG,MAAM,CAAC,CAAC;MACnBgC,QAAQ,EAAEnC,MAAC,CAACG,MAAM,CAAC;IACrB,CAAC;EACH,CAAC;AACH,CAAC,CAAC;AAACO,OAAA,CAAAC,4BAAA,GAAAA,4BAAA"}
@@ -33,8 +33,9 @@ var _types2 = require("./types");
33
33
  function decode(token) {
34
34
  let {
35
35
  sdJwt,
36
- disclosures
36
+ disclosures: disclosuresWithOriginal
37
37
  } = (0, _sdJwt.decode)(token, _types.SdJwt4VC);
38
+ const disclosures = disclosuresWithOriginal.map(d => d.decoded);
38
39
  const pid = (0, _converters.pidFromToken)(sdJwt, disclosures);
39
40
  return {
40
41
  pid,
@@ -1 +1 @@
1
- {"version":3,"names":["_sdJwt","require","_converters","_types","_types2","decode","token","sdJwt","disclosures","decodeJwt","SdJwt4VC","pid","pidFromToken","verify","decoded","publicKey","payload","cnf","jwk","verifyJwt"],"sourceRoot":"../../../../src","sources":["pid/sd-jwt/index.ts"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAkEA,IAAAG,OAAA,GAAAH,OAAA;AAhEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,MAAMA,CAACC,KAAa,EAAgB;EAClD,IAAI;IAAEC,KAAK;IAAEC;EAAY,CAAC,GAAG,IAAAC,aAAS,EAACH,KAAK,EAAEI,eAAQ,CAAC;EACvD,MAAMC,GAAG,GAAG,IAAAC,wBAAY,EAACL,KAAK,EAAEC,WAAW,CAAC;EAE5C,OAAO;IAAEG,GAAG;IAAEJ,KAAK;IAAEC;EAAY,CAAC;AACpC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeK,MAAMA,CAACP,KAAa,EAAyB;EACjE,MAAMQ,OAAO,GAAGT,MAAM,CAACC,KAAK,CAAC;EAC7B,MAAMS,SAAS,GAAGD,OAAO,CAACP,KAAK,CAACS,OAAO,CAACC,GAAG,CAACC,GAAG;EAC/C,MAAM,IAAAC,aAAS,EAACb,KAAK,EAAES,SAAS,EAAEL,eAAQ,CAAC;EAE3C,OAAOI,OAAO;AAChB;;AAWA;AACA;AACA"}
1
+ {"version":3,"names":["_sdJwt","require","_converters","_types","_types2","decode","token","sdJwt","disclosures","disclosuresWithOriginal","decodeJwt","SdJwt4VC","map","d","decoded","pid","pidFromToken","verify","publicKey","payload","cnf","jwk","verifyJwt"],"sourceRoot":"../../../../src","sources":["pid/sd-jwt/index.ts"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAsEA,IAAAG,OAAA,GAAAH,OAAA;AApEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,MAAMA,CAACC,KAAa,EAAgB;EAClD,IAAI;IAAEC,KAAK;IAAEC,WAAW,EAAEC;EAAwB,CAAC,GAAG,IAAAC,aAAS,EAC7DJ,KAAK,EACLK,eACF,CAAC;EACD,MAAMH,WAAW,GAAGC,uBAAuB,CAACG,GAAG,CAAEC,CAAC,IAAKA,CAAC,CAACC,OAAO,CAAC;EACjE,MAAMC,GAAG,GAAG,IAAAC,wBAAY,EAACT,KAAK,EAAEC,WAAW,CAAC;EAE5C,OAAO;IAAEO,GAAG;IAAER,KAAK;IAAEC;EAAY,CAAC;AACpC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeS,MAAMA,CAACX,KAAa,EAAyB;EACjE,MAAMQ,OAAO,GAAGT,MAAM,CAACC,KAAK,CAAC;EAC7B,MAAMY,SAAS,GAAGJ,OAAO,CAACP,KAAK,CAACY,OAAO,CAACC,GAAG,CAACC,GAAG;EAC/C,MAAM,IAAAC,aAAS,EAAChB,KAAK,EAAEY,SAAS,EAAEP,eAAQ,CAAC;EAE3C,OAAOG,OAAO;AAChB;;AAWA;AACA;AACA"}
@@ -8,6 +8,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
+ var _sdJwt = require("../sd-jwt");
11
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
13
  class RelyingPartySolution {
13
14
  constructor(relyingPartyBaseUrl, walletInstanceAttestation) {
@@ -69,14 +70,16 @@ class RelyingPartySolution {
69
70
 
70
71
  /**
71
72
  * Obtain the Request Object for RP authentication
73
+ * @see https://italia.github.io/eudi-wallet-it-docs/versione-corrente/en/relying-party-solution.html
72
74
  *
73
- * @function
75
+ * @async @function
74
76
  * @param signedWalletInstanceDPoP JWT of the Wallet Instance Attestation DPoP
75
77
  *
76
78
  * @returns The Request Object JWT
79
+ * @throws {NoSuitableKeysFoundInEntityConfiguration} When the Request Object is signed with a key not listed in RP's entity configuration
77
80
  *
78
81
  */
79
- async getRequestObject(signedWalletInstanceDPoP) {
82
+ async getRequestObject(signedWalletInstanceDPoP, entity) {
80
83
  const decodedJwtDPop = await (0, _ioReactNativeJwt.decode)(signedWalletInstanceDPoP);
81
84
  const requestUri = decodedJwtDPop.payload.htu;
82
85
  const response = await this.appFetch(requestUri, {
@@ -88,7 +91,24 @@ class RelyingPartySolution {
88
91
  });
89
92
  if (response.status === 200) {
90
93
  const responseText = await response.text();
91
- const responseJwt = await (0, _ioReactNativeJwt.decode)(responseText);
94
+ const responseJwt = (0, _ioReactNativeJwt.decode)(responseText);
95
+
96
+ // verify token signature according to RP's entity configuration
97
+ // to ensure the request object is authentic
98
+ {
99
+ const pubKey = entity.payload.jwks.keys.find(_ref => {
100
+ let {
101
+ kid
102
+ } = _ref;
103
+ return kid === responseJwt.protectedHeader.kid;
104
+ });
105
+ if (!pubKey) {
106
+ throw new _errors.NoSuitableKeysFoundInEntityConfiguration("Request Object signature verification");
107
+ }
108
+ await (0, _ioReactNativeJwt.verify)(responseText, pubKey);
109
+ }
110
+
111
+ // parse request object it has the expected shape by specification
92
112
  const requestObj = _types.RequestObject.parse({
93
113
  header: responseJwt.protectedHeader,
94
114
  payload: responseJwt.payload
@@ -98,6 +118,131 @@ class RelyingPartySolution {
98
118
  throw new _errors.IoWalletError(`Unable to obtain Request Object. Response code: ${response.status}`);
99
119
  }
100
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 presentation The Verified Credential containing user data along with the list of claims to be disclosed.
132
+ * @returns The unsigned Verified Presentation token
133
+ * @throws {ClaimsNotFoundBetweenDislosures} If the Verified Credential does not contain one or more requested claims.
134
+ *
135
+ */
136
+ async prepareVpToken(requestObj, _ref2) {
137
+ let [vc, claims] = _ref2;
138
+ // this throws if vc cannot satisfy all the requested claims
139
+ const {
140
+ token: vp,
141
+ paths
142
+ } = await (0, _sdJwt.disclose)(vc, claims);
143
+
144
+ // TODO: [SIW-359] check all requeste claims of the requestedObj are satisfied
145
+
146
+ const vp_token = new _ioReactNativeJwt.SignJWT({
147
+ vp
148
+ }).setAudience(requestObj.payload.response_uri).setExpirationTime("1h").setProtectedHeader({
149
+ typ: "JWT",
150
+ alg: "ES256"
151
+ }).toSign();
152
+ const [definition_id, vc_scope] = requestObj.payload.scope;
153
+ const presentation_submission = {
154
+ definition_id,
155
+ id: `${_reactNativeUuid.default.v4()}`,
156
+ descriptor_map: paths.map(p => ({
157
+ id: vc_scope,
158
+ path: `$.vp_token.${p.path}`,
159
+ format: "vc+sd-jwt"
160
+ }))
161
+ };
162
+ return {
163
+ vp_token,
164
+ presentation_submission
165
+ };
166
+ }
167
+
168
+ /**
169
+ * Compose and send an Authorization Response in the context of an authorization request flow.
170
+ *
171
+ * @todo MUST add presentation_submission
172
+ *
173
+ * @param requestObj The incoming request object, which the requirements for the requested authorization
174
+ * @param vp_token The signed Verified Presentation token with data to send.
175
+ * @param presentation_submission
176
+ * @param entity The RP entity configuration
177
+ * @returns The response from the RP
178
+ * @throws {IoWalletError} if the submission fails.
179
+ * @throws {NoSuitableKeysFoundInEntityConfiguration} If entity do not contain any public key
180
+ *
181
+ */
182
+ async sendAuthorizationResponse(requestObj, vp_token, presentation_submission, entity) {
183
+ // the request is an unsigned jws without iss, aud, exp
184
+ // https://openid.net/specs/openid-4-verifiable-presentations-1_0.html#name-signed-and-encrypted-respon
185
+ const jwk = this.choosePublicKeyToEncrypt(entity);
186
+ const enc = this.getEncryptionAlgByJwk(jwk);
187
+ const authzResponsePayload = JSON.stringify({
188
+ state: requestObj.payload.state,
189
+ presentation_submission,
190
+ vp_token
191
+ });
192
+ const encrypted = await new _ioReactNativeJwt.EncryptJwe(authzResponsePayload, {
193
+ alg: jwk.alg,
194
+ enc
195
+ }).encrypt(jwk);
196
+ const formBody = new URLSearchParams({
197
+ response: encrypted
198
+ });
199
+ const response = await this.appFetch(requestObj.payload.response_uri, {
200
+ method: "POST",
201
+ headers: {
202
+ "Content-Type": "application/x-www-form-urlencoded"
203
+ },
204
+ body: formBody.toString()
205
+ });
206
+ if (response.status === 200) {
207
+ return response.text();
208
+ }
209
+ throw new _errors.IoWalletError(`Unable to send Authorization Response. Response code: ${response.status}`);
210
+ }
211
+
212
+ /**
213
+ * Select a public key from those provided by the RP.
214
+ * Keys with algorithm "RSA-OAEP-256" or "RSA-OAEP" are expected, the firsts to be preferred.
215
+ *
216
+ * @param entity The RP entity configuration
217
+ * @returns A suitable public key with its compatible encryption algorithm
218
+ * @throws {NoSuitableKeysFoundInEntityConfiguration} If entity do not contain any public key suitable for encrypting
219
+ */
220
+ choosePublicKeyToEncrypt(entity) {
221
+ // Look for keys using "RSA-OAEP-256", and pick a random one
222
+ const [usingRsa256] = entity.payload.jwks.keys.filter(k => typeof k.alg === "string" && k.alg === "RSA-OAEP-256");
223
+ if (usingRsa256) {
224
+ return usingRsa256;
225
+ }
226
+
227
+ // Look for keys using "RSA-OAEP", and pick a random one
228
+ const [usingRsa] = entity.payload.jwks.keys.filter(k => typeof k.alg === "string" && k.alg === "RSA-OAEP");
229
+ if (usingRsa) {
230
+ return usingRsa;
231
+ }
232
+
233
+ // No suitable key has been found
234
+ throw new _errors.NoSuitableKeysFoundInEntityConfiguration("Encrypt with RP public key");
235
+ }
236
+ getEncryptionAlgByJwk(_ref3) {
237
+ let {
238
+ alg
239
+ } = _ref3;
240
+ if (alg === "RSA-OAEP-256") return "A256CBC-HS512";
241
+ if (alg === "RSA-OAEP") return "A128CBC-HS256";
242
+ const _ = alg;
243
+ throw new Error(`Invalid jwk algorithm: ${_}`);
244
+ }
245
+
101
246
  /**
102
247
  * Obtain the relying party entity configuration.
103
248
  */
@@ -1 +1 @@
1
- {"version":3,"names":["_errors","require","_ioReactNativeJwt","_types","_reactNativeUuid","_interopRequireDefault","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","decodedJwtDPop","decodeJwt","requestUri","payload","response","method","headers","Authorization","DPoP","status","responseText","text","responseJwt","requestObj","RequestObject","parse","header","protectedHeader","IoWalletError","getEntityConfiguration","wellKnownUrl","href","RpEntityConfiguration","exports"],"sourceRoot":"../../../src","sources":["rp/index.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AAMA,IAAAE,MAAA,GAAAF,OAAA;AAEA,IAAAG,gBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAAqC,SAAAI,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAA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Q,CAACK,MAAO,EACrE,CAAC;EACH;;EAEA;AACF;AACA;EACE,MAAMU,sBAAsBA,CAAA,EAAmC;IAC7D,MAAMC,YAAY,GAAG,IAAIxD,GAAG,CAC1B,gCAAgC,EAChC,IAAI,CAACZ,mBACP,CAAC,CAACqE,IAAI;IAEN,MAAMjB,QAAQ,GAAG,MAAM,IAAI,CAAClD,QAAQ,CAACkE,YAAY,EAAE;MACjDf,MAAM,EAAE;IACV,CAAC,CAAC;IAEF,IAAID,QAAQ,CAACK,MAAM,KAAK,GAAG,EAAE;MAC3B,MAAMC,YAAY,GAAG,MAAMN,QAAQ,CAACO,IAAI,CAAC,CAAC;MAC1C,MAAMC,WAAW,GAAG,MAAM,IAAAX,wBAAS,EAACS,YAAY,CAAC;MACjD,OAAOY,4BAAqB,CAACP,KAAK,CAAC;QACjCC,MAAM,EAAEJ,WAAW,CAACK,eAAe;QACnCd,OAAO,EAAES,WAAW,CAACT;MACvB,CAAC,CAAC;IACJ;IAEA,MAAM,IAAIe,qBAAa,CACpB,4DAA2Dd,QAAQ,CAACK,MAAO,EAC9E,CAAC;EACH;AACF;AAACc,OAAA,CAAAzE,oBAAA,GAAAA,oBAAA"}
1
+ {"version":3,"names":["_errors","require","_ioReactNativeJwt","_types","_reactNativeUuid","_interopRequireDefault","_sdJwt","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","entity","decodedJwtDPop","decodeJwt","requestUri","payload","response","method","headers","Authorization","DPoP","status","responseText","text","responseJwt","pubKey","jwks","keys","find","_ref","kid","protectedHeader","NoSuitableKeysFoundInEntityConfiguration","verify","requestObj","RequestObject","parse","header","IoWalletError","prepareVpToken","_ref2","vc","claims","token","vp","paths","disclose","vp_token","setAudience","response_uri","definition_id","vc_scope","scope","presentation_submission","id","descriptor_map","map","p","path","format","sendAuthorizationResponse","choosePublicKeyToEncrypt","enc","getEncryptionAlgByJwk","authzResponsePayload","JSON","stringify","state","encrypted","EncryptJwe","encrypt","formBody","URLSearchParams","body","toString","usingRsa256","filter","k","usingRsa","_ref3","_","Error","getEntityConfiguration","wellKnownUrl","href","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;AAAqC,SAAAI,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE9B,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;IAC1D,IAAI,CAACC,QAAQ,GAAGA,QAAQ;EAC1B;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE,OAAOK,mBAAmBA,CAACC,MAAc,EAAiB;IACxD,MAAMC,OAAO,GAAG,IAAAC,8BAAY,EAACF,MAAM,CAAC;IACpC,MAAMG,UAAU,GAAG,IAAIC,GAAG,C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,oBAAA,GAAAA,oBAAA"}
@@ -76,5 +76,9 @@ const QRCodePayload = z.object({
76
76
  clientId: z.string(),
77
77
  requestURI: z.string()
78
78
  });
79
+
80
+ /**
81
+ * A pair that associate a tokenized Verified Credential with the claims presented or requested to present.
82
+ */
79
83
  exports.QRCodePayload = QRCodePayload;
80
84
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_jwk","require","_types","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","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","sub","jwks","keys","JWK","metadata","wallet_relying_party","application_type","client_name","contacts","federation_entity","organization_name","homepage_uri","policy_uri","logo_uri","authority_hints","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;AAAyB,SAAAI,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAF,wBAAAM,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA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GAAAA,aAAA"}
1
+ {"version":3,"names":["_jwk","require","_types","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","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","sub","jwks","keys","JWK","metadata","wallet_relying_party","application_type","client_name","contacts","federation_entity","organization_name","homepage_uri","policy_uri","logo_uri","authority_hints","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;AAAyB,SAAAI,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAF,wBAAAM,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,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,kBAAA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AAK,CAACmB,QAAG;QACnB,CAAC,CAAC;QACFK,QAAQ,EAAEzD,CAAC,CAACiC,KAAK,CAACjC,CAAC,CAAC8B,MAAM,CAAC,CAAC;MAC9B,CAAC,CAAC;MACF4B,iBAAiB,EAAE1D,CAAC,CAACyB,MAAM,CAAC;QAC1BkC,iBAAiB,EAAE3D,CAAC,CAAC8B,MAAM,CAAC,CAAC;QAC7B8B,YAAY,EAAE5D,CAAC,CAAC8B,MAAM,CAAC,CAAC;QACxB+B,UAAU,EAAE7D,CAAC,CAAC8B,MAAM,CAAC,CAAC;QACtBgC,QAAQ,EAAE9D,CAAC,CAAC8B,MAAM,CAAC,CAAC;QACpB2B,QAAQ,EAAEzD,CAAC,CAACiC,KAAK,CAACjC,CAAC,CAAC8B,MAAM,CAAC,CAAC;MAC9B,CAAC;IACH,CAAC,CAAC;IACFiC,eAAe,EAAE/D,CAAC,CAACiC,KAAK,CAACjC,CAAC,CAAC8B,MAAM,CAAC,CAAC;EACrC,CAAC;AACH,CAAC,CAAC;AAACiB,OAAA,CAAAC,qBAAA,GAAAA,qBAAA;AAGI,MAAMgB,aAAa,GAAGhE,CAAC,CAACyB,MAAM,CAAC;EACpCwC,QAAQ,EAAEjE,CAAC,CAAC4B,OAAO,CAAC,QAAQ,CAAC;EAC7BsC,QAAQ,EAAElE,CAAC,CAAC8B,MAAM,CAAC,CAAC;EAAE;EACtBqC,QAAQ,EAAEnE,CAAC,CAAC8B,MAAM,CAAC,CAAC;EACpBsC,UAAU,EAAEpE,CAAC,CAAC8B,MAAM,CAAC;AACvB,CAAC,CAAC;;AAEF;AACA;AACA;AAFAiB,OAAA,CAAAiB,aAAA,GAAAA,aAAA"}
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+
3
+ var _index = require("../index");
4
+ var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
5
+ var _types = require("../types");
6
+ // Examples from https://www.ietf.org/id/draft-terbu-sd-jwt-vc-02.html#name-example-4
7
+ // but adapted to adhere to format declared in https://italia.github.io/eudi-wallet-it-docs/versione-corrente/en/pid-eaa-data-model.html#id2
8
+ // In short, the token is a Frankenstein composed as follows:
9
+ // - the header is taken from the italian specification, with kid and alg valued according to the signing keys
10
+ // - disclosures are taken from the SD-JWT-4-VC standard
11
+ // - payload is taken from the italian specification, but _sd are compiled with:
12
+ // - "address" is used as verification._sd
13
+ // - all others disclosures are in claims._sd
14
+ const token = "eyJ0eXAiOiJ2YytzZC1qd3QiLCJhbGciOiJFUzI1NiIsImtpZCI6ImIxODZlYTBjMTkyNTc5MzA5N2JmMDFiOGEyODlhNDVmIiwidHJ1c3RfY2hhaW4iOlsiTkVoUmRFUnBZbmxIWTNNNVdsZFdUV1oyYVVobSAuLi4iLCJleUpoYkdjaU9pSlNVekkxTmlJc0ltdHBaQ0k2IC4uLiIsIklrSllkbVp5Ykc1b1FVMTFTRkl3TjJGcVZXMUIgLi4uIl19.eyJpc3MiOiJodHRwczovL2V4YW1wbGUuY29tL2lzc3VlciIsInN1YiI6Ik56YkxzWGg4dURDY2Q3bm9XWEZaQWZIa3hac1JHQzlYcy4uLiIsImp0aSI6InVybjp1dWlkOjZjNWMwYTQ5LWI1ODktNDMxZC1iYWU3LTIxOTEyMmE5ZWMyYyIsImlhdCI6MTU0MTQ5MzcyNCwiZXhwIjoxNTQxNDkzNzI0LCJzdGF0dXMiOiJodHRwczovL2V4YW1wbGUuY29tL3N0YXR1cyIsImNuZiI6eyJqd2siOnsia3R5IjoiUlNBIiwidXNlIjoic2lnIiwibiI6IjFUYS1zRSIsImUiOiJBUUFCIiwia2lkIjoiWWhORlMzWW5DOXRqaUNhaXZoV0xWVUozQXh3R0d6Xzk4dVJGYXFNRUVzIn19LCJ0eXBlIjoiUGVyc29uSWRlbnRpZmljYXRpb25EYXRhIiwidmVyaWZpZWRfY2xhaW1zIjp7InZlcmlmaWNhdGlvbiI6eyJfc2QiOlsiSnpZakg0c3ZsaUgwUjNQeUVNZmVadTZKdDY5dTVxZWhabzdGN0VQWW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IiwgImZhbWlseV9uYW1lIiwgIkRvZSJd", "WyI2SWo3dE0tYTVpVlBHYm9TNXRtdlZBIiwgImVtYWlsIiwgImpvaG5kb2VAZXhhbXBsZS5jb20iXQ", "WyJlSThaV205UW5LUHBOUGVOZW5IZGhRIiwgInBob25lX251bWJlciIsICIrMS0yMDItNTU1LTAxMDEiXQ", "WyJBSngtMDk1VlBycFR0TjRRTU9xUk9BIiwgImJpcnRoZGF0ZSIsICIxOTQwLTAxLTAxIl0", "WyJQYzMzSk0yTGNoY1VfbEhnZ3ZfdWZRIiwgImlzX292ZXJfMTgiLCB0cnVlXQ", "WyJHMDJOU3JRZmpGWFE3SW8wOXN5YWpBIiwgImlzX292ZXJfMjEiLCB0cnVlXQ", "WyJsa2x4RjVqTVlsR1RQVW92TU5JdkNBIiwgImlzX292ZXJfNjUiLCB0cnVlXQ", "WyJRZ19PNjR6cUF4ZTQxMmExMDhpcm9BIiwgImFkZHJlc3MiLCB7InN0cmVldF9hZGRyZXNzIjogIjEyMyBNYWluIFN0IiwgImxvY2FsaXR5IjogIkFueXRvd24iLCAicmVnaW9uIjogIkFueXN0YXRlIiwgImNvdW50cnkiOiAiVVMifV0"];
19
+ const sdJwt = {
20
+ header: {
21
+ typ: "vc+sd-jwt",
22
+ alg: "ES256",
23
+ kid: "b186ea0c1925793097bf01b8a289a45f",
24
+ trust_chain: ["NEhRdERpYnlHY3M5WldWTWZ2aUhm ...", "eyJhbGciOiJSUzI1NiIsImtpZCI6 ...", "IkJYdmZybG5oQU11SFIwN2FqVW1B ..."]
25
+ },
26
+ payload: {
27
+ iss: "https://example.com/issuer",
28
+ sub: "NzbLsXh8uDCcd7noWXFZAfHkxZsRGC9Xs...",
29
+ jti: "urn:uuid:6c5c0a49-b589-431d-bae7-219122a9ec2c",
30
+ iat: 1541493724,
31
+ exp: 1541493724,
32
+ status: "https://example.com/status",
33
+ cnf: {
34
+ jwk: {
35
+ kty: "RSA",
36
+ use: "sig",
37
+ n: "1Ta-sE",
38
+ e: "AQAB",
39
+ kid: "YhNFS3YnC9tjiCaivhWLVUJ3AxwGGz_98uRFaqMEEs"
40
+ }
41
+ },
42
+ type: "PersonIdentificationData",
43
+ verified_claims: {
44
+ verification: {
45
+ _sd: ["JzYjH4svliH0R3PyEMfeZu6Jt69u5qehZo7F7EPYlSE"],
46
+ trust_framework: "eidas",
47
+ assurance_level: "high"
48
+ },
49
+ claims: {
50
+ _sd: ["09vKrJMOlyTWM0sjpu_pdOBVBQ2M1y3KhpH515nXkpY", "2rsjGbaC0ky8mT0pJrPioWTq0_daw1sX76poUlgCwbI", "EkO8dhW0dHEJbvUHlE_VCeuC9uRELOieLZhh7XbUTtA", "IlDzIKeiZdDwpqpK6ZfbyphFvz5FgnWa-sN6wqQXCiw", "PorFbpKuVu6xymJagvkFsFXAbRoc2JGlAUA2BA4o7cI", "TGf4oLbgwd5JQaHyKVQZU9UdGE0w5rtDsrZzfUaomLo", "jdrTE8YcbY4EifugihiAe_BPekxJQZICeiUQwY9QqxI", "jsu9yVulwQQlhFlM_3JlzMaSFzglhQG0DpfayQwLUK4"]
51
+ }
52
+ },
53
+ _sd_alg: "sha-256"
54
+ }
55
+ };
56
+
57
+ // In the very same order than tokenizedDisclosures
58
+ const disclosures = [["2GLC42sKQveCfGfryNRN9w", "given_name", "John"], ["eluV5Og3gSNII8EYnsxA_A", "family_name", "Doe"], ["6Ij7tM-a5iVPGboS5tmvVA", "email", "johndoe@example.com"], ["eI8ZWm9QnKPpNPeNenHdhQ", "phone_number", "+1-202-555-0101"], ["AJx-095VPrpTtN4QMOqROA", "birthdate", "1940-01-01"], ["Pc33JM2LchcU_lHggv_ufQ", "is_over_18", true], ["G02NSrQfjFXQ7Io09syajA", "is_over_21", true], ["lklxF5jMYlGTPUovMNIvCA", "is_over_65", true], ["Qg_O64zqAxe412a108iroA", "address", {
59
+ street_address: "123 Main St",
60
+ locality: "Anytown",
61
+ region: "Anystate",
62
+ country: "US"
63
+ }]];
64
+ it("Ensures example data correctness", () => {
65
+ expect(JSON.parse((0, _ioReactNativeJwt.decodeBase64)((0, _ioReactNativeJwt.encodeBase64)(JSON.stringify(sdJwt.header))))).toEqual(sdJwt.header);
66
+ expect([signed, ...tokenizedDisclosures].join("~")).toBe(token);
67
+ });
68
+ describe("decode", () => {
69
+ it("should decode a valid token", () => {
70
+ const result = (0, _index.decode)(token, _types.SdJwt4VC);
71
+ expect(result).toEqual({
72
+ sdJwt,
73
+ disclosures: disclosures.map((decoded, i) => ({
74
+ decoded,
75
+ encoded: tokenizedDisclosures[i]
76
+ }))
77
+ });
78
+ });
79
+ });
80
+ describe("disclose", () => {
81
+ it("should encode a valid sdjwt (one claim)", async () => {
82
+ const result = await (0, _index.disclose)(token, ["given_name"]);
83
+ const expected = {
84
+ token: `${signed}~WyIyR0xDNDJzS1F2ZUNmR2ZyeU5STjl3IiwgImdpdmVuX25hbWUiLCAiSm9obiJd`,
85
+ paths: [{
86
+ claim: "given_name",
87
+ path: "verified_claims.claims._sd[7]"
88
+ }]
89
+ };
90
+ expect(result).toEqual(expected);
91
+ });
92
+ it("should encode a valid sdjwt (no claims)", async () => {
93
+ const result = await (0, _index.disclose)(token, []);
94
+ const expected = {
95
+ token: `${signed}`,
96
+ paths: []
97
+ };
98
+ expect(result).toEqual(expected);
99
+ });
100
+ it("should encode a valid sdjwt (multiple claims)", async () => {
101
+ const result = await (0, _index.disclose)(token, ["given_name", "email"]);
102
+ const expected = {
103
+ token: `${signed}~WyIyR0xDNDJzS1F2ZUNmR2ZyeU5STjl3IiwgImdpdmVuX25hbWUiLCAiSm9obiJd~WyI2SWo3dE0tYTVpVlBHYm9TNXRtdlZBIiwgImVtYWlsIiwgImpvaG5kb2VAZXhhbXBsZS5jb20iXQ`,
104
+ paths: [{
105
+ claim: "given_name",
106
+ path: "verified_claims.claims._sd[7]"
107
+ }, {
108
+ claim: "email",
109
+ path: "verified_claims.verification._sd[0]"
110
+ }]
111
+ };
112
+ expect(result).toEqual(expected);
113
+ });
114
+ it("should fail on unknown claim", async () => {
115
+ const fn = async () => (0, _index.disclose)(token, ["unknown"]);
116
+ await expect(fn()).rejects.toEqual(expect.any(Error));
117
+ });
118
+ });
119
+ //# sourceMappingURL=index.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_index","require","_ioReactNativeJwt","_types","token","unsigned","signature","signed","tokenizedDisclosures","sdJwt","header","typ","alg","kid","trust_chain","payload","iss","sub","jti","iat","exp","status","cnf","jwk","kty","use","n","e","type","verified_claims","verification","_sd","trust_framework","assurance_level","claims","_sd_alg","disclosures","street_address","locality","region","country","it","expect","JSON","parse","decodeBase64","encodeBase64","stringify","toEqual","join","toBe","describe","result","decode","SdJwt4VC","map","decoded","i","encoded","disclose","expected","paths","claim","path","fn","rejects","any","Error"],"sourceRoot":"../../../../src","sources":["sd-jwt/__test__/index.test.ts"],"mappings":";;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,KAAK,GACT,kvEAAkvE;AAEpvE,MAAMC,QAAQ,GACZ,87CAA87C;AAEh8C,MAAMC,SAAS,GACb,wFAAwF;AAE1F,MAAMC,MAAM,GAAI,GAAEF,QAAS,IAAGC,SAAU,EAAC;AAEzC,MAAME,oBAAoB,GAAG,CAC3B,kEAAkE,EAClE,kEAAkE,EAClE,gFAAgF,EAChF,oFAAoF,EACpF,yEAAyE,EACzE,gEAAgE,EAChE,gEAAgE,EAChE,gEAAgE,EAChE,qLAAqL,CACtL;AAED,MAAMC,KAAK,GAAG;EACZC,MAAM,EAAE;IACNC,GAAG,EAAE,WAAW;IAChBC,GAAG,EAAE,OAAO;IACZC,GAAG,EAAE,kCAAkC;IACvCC,WAAW,EAAE,CACX,kCAAkC,EAClC,kCAAkC,EAClC,kCAAkC;EAEtC,CAAC;EACDC,OAAO,EAAE;IACPC,GAAG,EAAE,4BAA4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