@pagopa/io-react-native-wallet 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. package/README.md +57 -24
  2. package/lib/commonjs/index.js +13 -0
  3. package/lib/commonjs/index.js.map +1 -1
  4. package/lib/commonjs/rp/__test__/index.test.js +8 -1
  5. package/lib/commonjs/rp/__test__/index.test.js.map +1 -1
  6. package/lib/commonjs/rp/index.js +5 -14
  7. package/lib/commonjs/rp/index.js.map +1 -1
  8. package/lib/commonjs/rp/types.js +7 -27
  9. package/lib/commonjs/rp/types.js.map +1 -1
  10. package/lib/commonjs/trust/chain.js +94 -0
  11. package/lib/commonjs/trust/chain.js.map +1 -0
  12. package/lib/commonjs/trust/index.js +44 -0
  13. package/lib/commonjs/trust/index.js.map +1 -0
  14. package/lib/commonjs/trust/types.js +64 -0
  15. package/lib/commonjs/trust/types.js.map +1 -0
  16. package/lib/commonjs/wallet-instance-attestation/issuing.js +4 -4
  17. package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
  18. package/lib/commonjs/wallet-instance-attestation/types.js +6 -9
  19. package/lib/commonjs/wallet-instance-attestation/types.js.map +1 -1
  20. package/lib/module/index.js +2 -1
  21. package/lib/module/index.js.map +1 -1
  22. package/lib/module/rp/__test__/index.test.js +8 -1
  23. package/lib/module/rp/__test__/index.test.js.map +1 -1
  24. package/lib/module/rp/index.js +5 -14
  25. package/lib/module/rp/index.js.map +1 -1
  26. package/lib/module/rp/types.js +7 -27
  27. package/lib/module/rp/types.js.map +1 -1
  28. package/lib/module/trust/chain.js +86 -0
  29. package/lib/module/trust/chain.js.map +1 -0
  30. package/lib/module/trust/index.js +34 -0
  31. package/lib/module/trust/index.js.map +1 -0
  32. package/lib/module/trust/types.js +52 -0
  33. package/lib/module/trust/types.js.map +1 -0
  34. package/lib/module/wallet-instance-attestation/issuing.js +4 -4
  35. package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
  36. package/lib/module/wallet-instance-attestation/types.js +6 -9
  37. package/lib/module/wallet-instance-attestation/types.js.map +1 -1
  38. package/lib/typescript/index.d.ts +2 -1
  39. package/lib/typescript/index.d.ts.map +1 -1
  40. package/lib/typescript/rp/index.d.ts.map +1 -1
  41. package/lib/typescript/rp/types.d.ts +232 -145
  42. package/lib/typescript/rp/types.d.ts.map +1 -1
  43. package/lib/typescript/trust/chain.d.ts +17 -0
  44. package/lib/typescript/trust/chain.d.ts.map +1 -0
  45. package/lib/typescript/trust/index.d.ts +16 -0
  46. package/lib/typescript/trust/index.d.ts.map +1 -0
  47. package/lib/typescript/trust/types.d.ts +1041 -0
  48. package/lib/typescript/trust/types.d.ts.map +1 -0
  49. package/lib/typescript/wallet-instance-attestation/types.d.ts +30 -50
  50. package/lib/typescript/wallet-instance-attestation/types.d.ts.map +1 -1
  51. package/package.json +1 -1
  52. package/src/index.ts +3 -0
  53. package/src/rp/__test__/index.test.ts +8 -1
  54. package/src/rp/index.ts +5 -20
  55. package/src/rp/types.ts +17 -34
  56. package/src/trust/chain.ts +109 -0
  57. package/src/trust/index.ts +43 -0
  58. package/src/trust/types.ts +56 -0
  59. package/src/wallet-instance-attestation/issuing.ts +4 -4
  60. package/src/wallet-instance-attestation/types.ts +6 -9
package/README.md CHANGED
@@ -27,7 +27,6 @@ PID.SdJwt.decode("<token>");
27
27
 
28
28
  //Decode and verification
29
29
  PID.SdJwt.verify("<token>");
30
-
31
30
  ```
32
31
 
33
32
  ### Wallet Instance Attestation
@@ -37,32 +36,26 @@ PID.SdJwt.verify("<token>");
37
36
  ```ts
38
37
  import { WalletInstanceAttestation } from "@pagopa/io-react-native-wallet";
39
38
 
40
- const issuing = new WalletInstanceAttestation.Issuing(
41
- yourWalletProviderUrl
42
- );
39
+ const issuing = new WalletInstanceAttestation.Issuing(yourWalletProviderUrl);
43
40
 
44
41
  // Generate keys
45
42
  const publicKey = await yourCustomPublicKey("TEE_KEY_TAG");
46
43
 
47
44
  const walletInstanceAttestationRequest =
48
- await issuing.getAttestationRequestToSign(
49
- publicKey
50
- );
45
+ await issuing.getAttestationRequestToSign(publicKey);
51
46
 
52
47
  //Sign with TEE
53
48
  const signature = await yourCustomSignatureFunction(
54
- walletInstanceAttestationRequest,
55
- "TEE_KEY_TAG"
56
- );
57
-
58
- const walletInstanceAttestation =
59
- await issuing.getAttestation(
60
- walletInstanceAttestationRequest,
61
- signature
49
+ walletInstanceAttestationRequest,
50
+ "TEE_KEY_TAG"
62
51
  );
63
52
 
64
- console.log(walletInstanceAttestation);
53
+ const walletInstanceAttestation = await issuing.getAttestation(
54
+ walletInstanceAttestationRequest,
55
+ signature
56
+ );
65
57
 
58
+ console.log(walletInstanceAttestation);
66
59
  ```
67
60
 
68
61
  #### Encode and Decode
@@ -75,17 +68,57 @@ WalletInstanceAttestation.decode("<token>");
75
68
 
76
69
  ## Example
77
70
 
78
- You can use the [sample app](example) to test and understand how to use the library.
71
+ ### NodeJS and Ruby
79
72
 
80
- ```sh
81
- cd example
73
+ To run the example project you need to install the correct version of NodeJS and Ruby.
74
+ We recommend the use of a virtual environment of your choice. For ease of use, this guide adopts [nodenv](https://github.com/nodenv/nodenv) or [nvm](https://github.com/nvm-sh/nvm) for NodeJS and [rbenv](https://github.com/rbenv/rbenv) for Ruby.
75
+ [Yarn](https://yarnpkg.com/) is the package manager of choice.
76
+
77
+ The node version used in this project is stored in [example/.node-version](example/.node-version) and [example/.nvmrc],
78
+ while the version of Ruby is stored in [example/.ruby-version](.ruby-version).
79
+
80
+ ### React Native
81
+
82
+ Follow the [official tutorial](https://reactnative.dev/docs/environment-setup?guide=native) for installing the `React Native CLI` for your operating system.
83
+
84
+ If you have a macOS system, you can follow both the tutorial for iOS and for Android. If you have a Linux or Windows system, you only need to install the development environment for Android.
85
+
86
+ ### Build the app
87
+
88
+ In order to build the app,
89
+ As stated [previously](#nodejs-and-ruby), we also use `nodenv` and `rbenv` for managing the environment:
90
+
91
+ ```bash
92
+ # Clone the repository
93
+ $ git clone https://github.com/pagopa/io-react-native-wallet
94
+
95
+ # CD into the repository
96
+ $ cd io-react-native-wallet
97
+
98
+ # Install library dependencies
99
+ $ yarn install
100
+
101
+ # CD into the example folder
102
+ $ cd example
103
+
104
+ # Install bundle
105
+ $ gem install bundle
106
+
107
+ # Install the required Gems from the Gemfile
108
+ # Run this only during the first setup and when Gems dependencies change
109
+ $ bundle install
82
110
 
83
- yarn install
111
+ # Install example dependencies
112
+ # Run this only during the first setup and when JS dependencies change
113
+ $ yarn install
84
114
 
85
- # To use iOS
86
- yarn ios
115
+ # Install podfiles when targeting iOS (ignore this step for Android)
116
+ # Run this only during the first setup and when Pods dependencies change
117
+ $ cd ios && bundle exec pod install && cd ..
87
118
 
88
- # To use Android
89
- yarn android
119
+ # Run the app on iOS
120
+ $ yarn ios
90
121
 
122
+ # Run the app on Android
123
+ $ yarn android
91
124
  ```
@@ -11,12 +11,24 @@ Object.defineProperty(exports, "RelyingPartySolution", {
11
11
  }
12
12
  });
13
13
  exports.WalletInstanceAttestation = void 0;
14
+ Object.defineProperty(exports, "getEntityConfiguration", {
15
+ enumerable: true,
16
+ get: function () {
17
+ return _trust.getEntityConfiguration;
18
+ }
19
+ });
14
20
  Object.defineProperty(exports, "getUnsignedDPop", {
15
21
  enumerable: true,
16
22
  get: function () {
17
23
  return _dpop.getUnsignedDPop;
18
24
  }
19
25
  });
26
+ Object.defineProperty(exports, "verifyTrustChain", {
27
+ enumerable: true,
28
+ get: function () {
29
+ return _trust.verifyTrustChain;
30
+ }
31
+ });
20
32
  require("react-native-url-polyfill/auto");
21
33
  var PID = _interopRequireWildcard(require("./pid"));
22
34
  exports.PID = PID;
@@ -27,6 +39,7 @@ exports.Errors = Errors;
27
39
  var WalletInstanceAttestation = _interopRequireWildcard(require("./wallet-instance-attestation"));
28
40
  exports.WalletInstanceAttestation = WalletInstanceAttestation;
29
41
  var _dpop = require("./utils/dpop");
42
+ var _trust = require("./trust");
30
43
  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); }
31
44
  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; }
32
45
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["require","PID","_interopRequireWildcard","exports","RP","Errors","WalletInstanceAttestation","_dpop","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;AAEAA,OAAA;AAEA,IAAAC,GAAA,GAAAC,uBAAA,CAAAF,OAAA;AAA6BG,OAAA,CAAAF,GAAA,GAAAA,GAAA;AAC7B,IAAAG,EAAA,GAAAF,uBAAA,CAAAF,OAAA;AAA2BG,OAAA,CAAAC,EAAA,GAAAA,EAAA;AAC3B,IAAAC,MAAA,GAAAH,uBAAA,CAAAF,OAAA;AAAyCG,OAAA,CAAAE,MAAA,GAAAA,MAAA;AACzC,IAAAC,yBAAA,GAAAJ,uBAAA,CAAAF,OAAA;AAA2EG,OAAA,CAAAG,yBAAA,GAAAA,yBAAA;AAC3E,IAAAC,KAAA,GAAAP,OAAA;AAA+C,SAAAQ,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,SAAAP,wBAAAW,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,MAAA,CAAAJ,OAAA,GAAAF,GAAA,MAAAG,KAAA,IAAAA,KAAA,CAAAa,GAAA,CAAAhB,GAAA,EAAAM,MAAA,YAAAA,MAAA"}
1
+ {"version":3,"names":["require","PID","_interopRequireWildcard","exports","RP","Errors","WalletInstanceAttestation","_dpop","_trust","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEAA,OAAA;AAEA,IAAAC,GAAA,GAAAC,uBAAA,CAAAF,OAAA;AAA6BG,OAAA,CAAAF,GAAA,GAAAA,GAAA;AAC7B,IAAAG,EAAA,GAAAF,uBAAA,CAAAF,OAAA;AAA2BG,OAAA,CAAAC,EAAA,GAAAA,EAAA;AAC3B,IAAAC,MAAA,GAAAH,uBAAA,CAAAF,OAAA;AAAyCG,OAAA,CAAAE,MAAA,GAAAA,MAAA;AACzC,IAAAC,yBAAA,GAAAJ,uBAAA,CAAAF,OAAA;AAA2EG,OAAA,CAAAG,yBAAA,GAAAA,yBAAA;AAC3E,IAAAC,KAAA,GAAAP,OAAA;AAEA,IAAAQ,MAAA,GAAAR,OAAA;AAAmE,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,SAAAR,wBAAAY,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,MAAA,CAAAJ,OAAA,GAAAF,GAAA,MAAAG,KAAA,IAAAA,KAAA,CAAAa,GAAA,CAAAhB,GAAA,EAAAM,MAAA,YAAAA,MAAA"}
@@ -15,7 +15,7 @@ describe("decodeAuthRequestQR", () => {
15
15
  });
16
16
  });
17
17
  describe("RpEntityConfiguration", () => {
18
- it("should parse a valid confdsfashdhasd", async () => {
18
+ it("should parse a valid conf", async () => {
19
19
  const pp = {
20
20
  header: {
21
21
  alg: "RS256",
@@ -36,6 +36,13 @@ describe("RpEntityConfiguration", () => {
36
36
  }]
37
37
  },
38
38
  metadata: {
39
+ federation_entity: {
40
+ organization_name: "wallet-provider",
41
+ homepage_uri: "https://wallet-provider.example",
42
+ policy_uri: "https://wallet-provider.example",
43
+ logo_uri: "https://wallet-provider.example",
44
+ contacts: ["https://wallet-provider.example"]
45
+ },
39
46
  wallet_relying_party: {
40
47
  application_type: "web",
41
48
  authorization_encrypted_response_alg: ["RSA-OAEP", "RSA-OAEP-256", "ECDH-ES", "ECDH-ES+A128KW", "ECDH-ES+A192KW", "ECDH-ES+A256KW"],
@@ -1 +1 @@
1
- {"version":3,"names":["_","require","_errors","_types","describe","it","qrcode","result","RelyingPartySolution","decodeAuthRequestQR","expect","requestURI","toEqual","toThrowError","AuthRequestDecodeError","pp","header","alg","kid","typ","payload","exp","iat","iss","sub","jwks","keys","kty","e","n","metadata","wallet_relying_party","application_type","authorization_encrypted_response_alg","authorization_encrypted_response_enc","authorization_signed_response_alg","client_id","client_name","contacts","default_acr_values","default_max_age","id_token_encrypted_response_alg","id_token_encrypted_response_enc","id_token_signed_response_alg","presentation_definitions","id","input_descriptors","format","constraints","fields","filter","const","type","path","intent_to_retain","limit_disclosure","jwt","mso_mdoc","redirect_uris","request_uris","require_auth_time","subject_type","vp_formats","jwt_vp_json","crv","d","use","x","y","p","q","authority_hints","RpEntityConfiguration","safeParse","success","error","toBe"],"sourceRoot":"../../../../src","sources":["rp/__test__/index.test.ts"],"mappings":";;AAAA,IAAAA,CAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEAG,QAAQ,CAAC,qBAAqB,EAAE,MAAM;EACpCC,EAAE,CAAC,0CAA0C,EAAE,YAAY;IACzD,MAAMC,MAAM,GACV,sJAAsJ;IACxJ,MAAMC,MAAM,GAAGC,sBAAoB,CAACC,mBAAmB,CAACH,MAAM,CAAC;IAC/DI,MAAM,CAACH,MAAM,CAACI,UAAU,CAAC,CAACC,OAAO,CAC/B,0CACF,CAAC;EACH,CAAC,CAAC;EACFP,EAAE,CAAC,wCAAwC,EAAE,YAAY;IACvD,MAAMC,MAAM,GAAG,0BAA0B;IACzCI,MAAM,CAAC,MAAMF,sBAAoB,CAACC,mBAAmB,CAACH,MAAM,CAAC,CAAC,CAACO,YAAY,CACzEC,8BACF,CAAC;EACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAEFV,QAAQ,CAAC,uBAAuB,EAAE,MAAM;EACtCC,EAAE,CAAC,sCAAsC,EAAE,YAAY;IACrD,MAAMU,EAAE,GAAG;MACTC,MAAM,EAAE;QACNC,GAAG,EAAE,OAAO;QACZC,GAAG,EAAE,6CAA6C;QAClDC,GAAG,EAAE;MACP,CAAC;MACDC,OAAO,EAAE;QACPC,GAAG,EAAE,UAAU;QACfC,GAAG,EAAE,UAAU;QACfC,GAAG,EAAE,+DAA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,QAAQ,EAAE;oBACRxC,GAAG,EAAE,CAAC,OAAO,EAAE,OAAO;kBACxB;gBACF,CAAC;gBACD4B,EAAE,EAAE;cACN,CAAC;YAEL,CAAC,CACF;YACDa,aAAa,EAAE,CACb,4EAA4E,CAC7E;YACDC,YAAY,EAAE,CACZ,2EAA2E,CAC5E;YACDC,iBAAiB,EAAE,IAAI;YACvBC,YAAY,EAAE,UAAU;YACxBC,UAAU,EAAE;cACVC,WAAW,EAAE;gBACX9C,GAAG,EAAE,CAAC,OAAO,EAAE,QAAQ;cACzB;YACF,CAAC;YACDQ,IAAI,EAAE,CACJ;cACEuC,GAAG,EAAE,OAAO;cACZC,CAAC,EAAE,6CAA6C;cAChD/C,GAAG,EAAE,6CAA6C;cAClDgD,GAAG,EAAE,KAAK;cACVvC,GAAG,EAAE,IAAI;cACTwC,CAAC,EAAE,6CAA6C;cAChDC,CAAC,EAAE;YACL,CAAC,EACD;cACEzC,GAAG,EAAE,KAAK;cACVsC,CAAC,EAAE,wVAAwV;cAC3VrC,CAAC,EAAE,MAAM;cACTsC,GAAG,EAAE,KAAK;cACVhD,GAAG,EAAE,6CAA6C;cAClDW,CAAC,EAAE,wVAAwV;cAC3VwC,CAAC,EAAE,6KAA6K;cAChLC,CAAC,EAAE;YACL,CAAC;UAEL;QACF,CAAC;QACDC,eAAe,EAAE,CACf,0DAA0D;MAE9D;IACF,CAAC;IACD,MAAMhE,MAAM,GAAGiE,4BAAqB,CAACC,SAAS,CAAC1D,EAAE,CAAC;IAClD,IAAIR,MAAM,CAACmE,OAAO,KAAK,KAAK,EAAE;MAC5B,MAAMnE,MAAM,CAACoE,KAAK;IACpB;IACAjE,MAAM,CAACH,MAAM,CAACmE,OAAO,CAAC,CAACE,IAAI,CAAC,IAAI,CAAC;EACnC,CAAC,CAAC;AACJ,CAAC,CAAC"}
1
+ {"version":3,"names":["_","require","_errors","_types","describe","it","qrcode","result","RelyingPartySolution","decodeAuthRequestQR","expect","requestURI","toEqual","toThrowError","AuthRequestDecodeError","pp","header","alg","kid","typ","payload","exp","iat","iss","sub","jwks","keys","kty","e","n","metadata","federation_entity","organization_name","homepage_uri","policy_uri","logo_uri","contacts","wallet_relying_party","application_type","authorization_encrypted_response_alg","authorization_encrypted_response_enc","authorization_signed_response_alg","client_id","client_name","default_acr_values","default_max_age","id_token_encrypted_response_alg","id_token_encrypted_response_enc","id_token_signed_response_alg","presentation_definitions","id","input_descriptors","format","constraints","fields","filter","const","type","path","intent_to_retain","limit_disclosure","jwt","mso_mdoc","redirect_uris","request_uris","require_auth_time","subject_type","vp_formats","jwt_vp_json","crv","d","use","x","y","p","q","authority_hints","RpEntityConfiguration","safeParse","success","error","toBe"],"sourceRoot":"../../../../src","sources":["rp/__test__/index.test.ts"],"mappings":";;AAAA,IAAAA,CAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEAG,QAAQ,CAAC,qBAAqB,EAAE,MAAM;EACpCC,EAAE,CAAC,0CAA0C,EAAE,YAAY;IACzD,MAAMC,MAAM,GACV,sJAAsJ;IACxJ,MAAMC,MAAM,GAAGC,sBAAoB,CAACC,mBAAmB,CAACH,MAAM,CAAC;IAC/DI,MAAM,CAACH,MAAM,CAACI,UAAU,CAAC,CAACC,OAAO,CAC/B,0CACF,CAAC;EACH,CAAC,CAAC;EACFP,EAAE,CAAC,wCAAwC,EAAE,YAAY;IACvD,MAAMC,MAAM,GAAG,0BAA0B;IACzCI,MAAM,CAAC,MAAMF,sBAAoB,CAACC,mBAAmB,CAACH,MAAM,CAAC,CAAC,CAACO,YAAY,CACzEC,8BACF,CAAC;EACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAEFV,QAAQ,CAAC,uBAAuB,EAAE,MAAM;EACtCC,EAAE,CAAC,2BAA2B,EAAE,YAAY;IAC1C,MAAMU,EAAE,GAAG;MACTC,MAAM,EAAE;QACNC,GAAG,EAAE,OAAO;QACZC,GAAG,EAAE,6CAA6C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E,CAAC;IAClD,IAAIR,MAAM,CAACwE,OAAO,KAAK,KAAK,EAAE;MAC5B,MAAMxE,MAAM,CAACyE,KAAK;IACpB;IACAtE,MAAM,CAACH,MAAM,CAACwE,OAAO,CAAC,CAACE,IAAI,CAAC,IAAI,CAAC;EACnC,CAAC,CAAC;AACJ,CAAC,CAAC"}
@@ -9,6 +9,7 @@ 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
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
14
  class RelyingPartySolution {
14
15
  constructor(relyingPartyBaseUrl, walletInstanceAttestation) {
@@ -213,7 +214,7 @@ class RelyingPartySolution {
213
214
  body
214
215
  });
215
216
  if (response.status === 200) {
216
- return await response.text();
217
+ return await response.json();
217
218
  }
218
219
  throw new _errors.IoWalletError(`Unable to send Authorization Response. Response: ${await response.text()} with code: ${response.status}`);
219
220
  }
@@ -239,19 +240,9 @@ class RelyingPartySolution {
239
240
  * Obtain the relying party entity configuration.
240
241
  */
241
242
  async getEntityConfiguration() {
242
- const wellKnownUrl = this.relyingPartyBaseUrl + "/.well-known/openid-federation";
243
- const response = await this.appFetch(wellKnownUrl, {
244
- method: "GET"
245
- });
246
- if (response.status === 200) {
247
- const responseText = await response.text();
248
- const responseJwt = await (0, _ioReactNativeJwt.decode)(responseText);
249
- return _types.RpEntityConfiguration.parse({
250
- header: responseJwt.protectedHeader,
251
- payload: responseJwt.payload
252
- });
253
- }
254
- throw new _errors.IoWalletError(`Unable to obtain RP Entity Configuration. Response code: ${response.status}`);
243
+ return (0, _trust.getEntityConfiguration)(this.relyingPartyBaseUrl, {
244
+ appFetch: this.appFetch
245
+ }).then(_types.RpEntityConfiguration.parse);
255
246
  }
256
247
  }
257
248
  exports.RelyingPartySolution = RelyingPartySolution;
@@ -1 +1 @@
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","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","wellKnownUrl","responseText","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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AW,GAAG,MAAM,IAAAC,wBAAS,EAAC+D,YAAY,CAAC;MACjD,OAAOC,4BAAqB,CAAClD,KAAK,CAAC;QACjCC,MAAM,EAAEhB,WAAW,CAACU,eAAe;QACnCP,OAAO,EAAEH,WAAW,CAACG;MACvB,CAAC,CAAC;IACJ;IAEA,MAAM,IAAIc,qBAAa,CACpB,4DAA2D1B,QAAQ,CAACK,MAAO,EAC9E,CAAC;EACH;AACF;AAACsE,OAAA,CAAA/H,oBAAA,GAAAA,oBAAA"}
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"],"sourceR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sBA,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"}
@@ -7,6 +7,7 @@ exports.RpEntityConfiguration = exports.RequestObject = exports.QRCodePayload =
7
7
  var _jwk = require("../utils/jwk");
8
8
  var _types = require("../sd-jwt/types");
9
9
  var z = _interopRequireWildcard(require("zod"));
10
+ var _types2 = require("../trust/types");
10
11
  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); }
11
12
  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; }
12
13
  const RequestObject = z.object({
@@ -32,22 +33,12 @@ const RequestObject = z.object({
32
33
  })
33
34
  });
34
35
 
35
- // TODO: This types is WIP in technical rules
36
+ /**
37
+ * EntityConfiguration plus the metadata specific for a Relying Party entity.
38
+ */
36
39
  exports.RequestObject = RequestObject;
37
- const RpEntityConfiguration = z.object({
38
- header: z.object({
39
- typ: z.literal("entity-statement+jwt"),
40
- alg: z.string(),
41
- kid: z.string()
42
- }),
40
+ const RpEntityConfiguration = _types2.EntityConfiguration.and(z.object({
43
41
  payload: z.object({
44
- exp: _types.UnixTime,
45
- iat: _types.UnixTime,
46
- iss: z.string(),
47
- sub: z.string(),
48
- jwks: z.object({
49
- keys: z.array(_jwk.JWK)
50
- }),
51
42
  metadata: z.object({
52
43
  wallet_relying_party: z.object({
53
44
  application_type: z.string(),
@@ -56,20 +47,9 @@ const RpEntityConfiguration = z.object({
56
47
  jwks: z.array(_jwk.JWK),
57
48
  contacts: z.array(z.string())
58
49
  })
59
- // FIXME: SIW-422 require federation_metadata field
60
- // Actual RP implementation does not comply with the spec
61
- /* federation_entity: z.object({
62
- organization_name: z.string(),
63
- homepage_uri: z.string(),
64
- policy_uri: z.string(),
65
- logo_uri: z.string(),
66
- contacts: z.array(z.string()),
67
- }), */
68
- }),
69
-
70
- authority_hints: z.array(z.string())
50
+ })
71
51
  })
72
- });
52
+ }));
73
53
  exports.RpEntityConfiguration = RpEntityConfiguration;
74
54
  const QRCodePayload = z.object({
75
55
  protocol: z.string(),
@@ -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","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","sub","jwks","keys","JWK","metadata","wallet_relying_party","application_type","client_name","contacts","authority_hints","QRCodePayload","protocol","resource","clientId","requestURI"],"sourceRoot":"../../../src","sources":["rp/types.ts"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAC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AAU,EAAEhE,CAAC,CAAC+B,MAAM,CAAC;AACvB,CAAC,CAAC;;AAEF;AACA;AACA;AAFAiB,OAAA,CAAAY,aAAA,GAAAA,aAAA"}
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","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,q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B,QAAQ,EAAE/D,CAAC,CAACgC,MAAM,CAAC,CAAC;EACpBgC,UAAU,EAAEhE,CAAC,CAACgC,MAAM,CAAC;AACvB,CAAC,CAAC;;AAEF;AACA;AACA;AAFAiB,OAAA,CAAAW,aAAA,GAAAA,aAAA"}
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.verifyTrustChain = verifyTrustChain;
7
+ var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
8
+ var _types = require("./types");
9
+ var _errors = require("../utils/errors");
10
+ var z = _interopRequireWildcard(require("zod"));
11
+ 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
+ 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
+ // Verify a token signature
14
+ // The kid is extracted from the token header
15
+ const verify = async (token, kid, jwks) => {
16
+ const jwk = jwks.find(k => k.kid === kid);
17
+ if (!jwk) {
18
+ throw new Error(`Invalid kid: ${kid}, token: ${token}`);
19
+ }
20
+ const {
21
+ protectedHeader: header,
22
+ payload
23
+ } = await (0, _ioReactNativeJwt.verify)(token, jwk);
24
+ return {
25
+ header,
26
+ payload
27
+ };
28
+ };
29
+ const decode = token => {
30
+ const {
31
+ protectedHeader: header,
32
+ payload
33
+ } = (0, _ioReactNativeJwt.decode)(token);
34
+ return {
35
+ header,
36
+ payload
37
+ };
38
+ };
39
+
40
+ // The first element of the chain is supposed to be the Entity Configuration for the document issuer
41
+ const FirstElementShape = _types.EntityConfiguration;
42
+ // Each element but the first is supposed to be an Entity Statement
43
+ const MiddleElementShape = _types.EntityStatement;
44
+ // The last element of the chain can either be an Entity Statement
45
+ // or the Entity Configuration for the known Trust Anchor
46
+ const LastElementShape = z.union([_types.EntityStatement, _types.TrustAnchorEntityConfiguration]);
47
+
48
+ /**
49
+ * Validates a provided trust chain against a known trust
50
+ *
51
+ * @param trustAnchorEntity
52
+ * @param chain
53
+ * @returns The list of parsed token representing the chain
54
+ * @throws {IoWalletError} If the chain is not valid
55
+ */
56
+ async function verifyTrustChain(trustAnchorEntity, chain) {
57
+ // If the chain is empty, fail
58
+ if (chain.length === 0) {
59
+ throw new _errors.IoWalletError("Cannot verify empty trust chain");
60
+ }
61
+
62
+ // Select the expected token shape
63
+ const selectTokenShape = elementIndex => elementIndex === 0 ? FirstElementShape : elementIndex === chain.length - 1 ? LastElementShape : MiddleElementShape;
64
+
65
+ // select the kid from the current index
66
+ const selectKid = currentIndex => {
67
+ const token = chain[currentIndex];
68
+ if (!token) {
69
+ throw new _errors.IoWalletError(`Cannot select kid: empty token`);
70
+ }
71
+ const shape = selectTokenShape(currentIndex);
72
+ return shape.parse(decode(token)).header.kid;
73
+ };
74
+
75
+ // select keys from the next token
76
+ // if the current token is the last, keys fro trust anchor will be used
77
+ const selectKeys = currentIndex => {
78
+ if (currentIndex === chain.length - 1) {
79
+ return trustAnchorEntity.payload.jwks.keys;
80
+ }
81
+ const nextIndex = currentIndex + 1;
82
+ const nextToken = chain[nextIndex];
83
+ if (!nextToken) {
84
+ throw new _errors.IoWalletError(`Cannot select keys: empty nextToken`);
85
+ }
86
+ const shape = selectTokenShape(nextIndex);
87
+ return shape.parse(decode(nextToken)).payload.jwks.keys;
88
+ };
89
+
90
+ // Iterate the chain and validate each element's signature against the public keys of its next
91
+ // If there is no next, hence it's the end of the chain and it must be verified by the Trust Anchor
92
+ return Promise.all(chain.map((token, i) => [token, selectKid(i), selectKeys(i)]).map(args => verify(...args)));
93
+ }
94
+ //# sourceMappingURL=chain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_ioReactNativeJwt","require","_types","_errors","z","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","verify","token","kid","jwks","jwk","find","k","Error","protectedHeader","header","payload","verifyJwt","decode","decodeJwt","FirstElementShape","EntityConfiguration","MiddleElementShape","EntityStatement","LastElementShape","union","TrustAnchorEntityConfiguration","verifyTrustChain","trustAnchorEntity","chain","length","IoWalletError","selectTokenShape","elementIndex","selectKid","currentIndex","shape","parse","selectKeys","keys","nextIndex","nextToken","Promise","all","map","i","args"],"sourceRoot":"../../../src","sources":["trust/chain.ts"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAIA,IAAAC,MAAA,GAAAD,OAAA;AAMA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,CAAA,GAAAC,uBAAA,CAAAJ,OAAA;AAAyB,SAAAK,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAF,wBAAAM,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAA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E;MACrC,OAAOF,iBAAiB,CAACZ,OAAO,CAACP,IAAI,CAAC8B,IAAI;IAC5C;IAEA,MAAMC,SAAS,GAAGL,YAAY,GAAG,CAAC;IAClC,MAAMM,SAAS,GAAGZ,KAAK,CAACW,SAAS,CAAC;IAClC,IAAI,CAACC,SAAS,EAAE;MACd,MAAM,IAAIV,qBAAa,CAAE,qCAAoC,CAAC;IAChE;IACA,MAAMK,KAAK,GAAGJ,gBAAgB,CAACQ,SAAS,CAAC;IACzC,OAAOJ,KAAK,CAACC,KAAK,CAACnB,MAAM,CAACuB,SAAS,CAAC,CAAC,CAACzB,OAAO,CAACP,IAAI,CAAC8B,IAAI;EACzD,CAAC;;EAED;EACA;EACA,OAAOG,OAAO,CAACC,GAAG,CAChBd,KAAK,CACFe,GAAG,CAAC,CAACrC,KAAK,EAAEsC,CAAC,KAAK,CAACtC,KAAK,EAAE2B,SAAS,CAACW,CAAC,CAAC,EAAEP,UAAU,CAACO,CAAC,CAAC,CAAU,CAAC,CAChED,GAAG,CAAEE,IAAI,IAAKxC,MAAM,CAAC,GAAGwC,IAAI,CAAC,CAClC,CAAC;AACH"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getEntityConfiguration = getEntityConfiguration;
7
+ Object.defineProperty(exports, "verifyTrustChain", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _chain.verifyTrustChain;
11
+ }
12
+ });
13
+ var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
14
+ var _types = require("./types");
15
+ var _errors = require("../utils/errors");
16
+ var _chain = require("./chain");
17
+ /**
18
+ * Fetch and parse teh entity configuration document for a given federation entity
19
+ *
20
+ * @param entityBaseUrl The base url of the entity.
21
+ * @param options.appFetch An optional instance of the http client to be used.
22
+ * @returns The parsed entity configuration object
23
+ * @throws {IoWalletError} If the http request fails
24
+ * @throws Parse error if the document is not in the expected shape.
25
+ */
26
+ async function getEntityConfiguration(entityBaseUrl) {
27
+ let {
28
+ appFetch = fetch
29
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
30
+ const wellKnownUrl = `${entityBaseUrl}/.well-known/openid-federation`;
31
+ const response = await appFetch(wellKnownUrl, {
32
+ method: "GET"
33
+ });
34
+ if (response.status === 200) {
35
+ const responseText = await response.text();
36
+ const responseJwt = (0, _ioReactNativeJwt.decode)(responseText);
37
+ return _types.EntityConfiguration.parse({
38
+ header: responseJwt.protectedHeader,
39
+ payload: responseJwt.payload
40
+ });
41
+ }
42
+ throw new _errors.IoWalletError(`Unable to obtain Entity Configuration at ${wellKnownUrl}. Response code: ${response.status}`);
43
+ }
44
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.TrustMark = exports.TrustAnchorEntityConfiguration = exports.EntityStatement = exports.EntityConfiguration = void 0;
7
+ var _types = require("../sd-jwt/types");
8
+ var _jwk = require("../utils/jwk");
9
+ var z = _interopRequireWildcard(require("zod"));
10
+ 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); }
11
+ 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; }
12
+ const TrustMark = z.object({
13
+ id: z.string(),
14
+ trust_mark: z.string()
15
+ });
16
+ exports.TrustMark = TrustMark;
17
+ const EntityStatement = z.object({
18
+ header: z.object({
19
+ typ: z.literal("entity-statement+jwt"),
20
+ alg: z.string(),
21
+ kid: z.string()
22
+ }),
23
+ payload: z.object({
24
+ iss: z.string(),
25
+ sub: z.string(),
26
+ jwks: z.object({
27
+ keys: z.array(_jwk.JWK)
28
+ }),
29
+ trust_marks: z.array(TrustMark),
30
+ iat: z.number(),
31
+ exp: z.number()
32
+ })
33
+ });
34
+ exports.EntityStatement = EntityStatement;
35
+ const EntityConfiguration = z.object({
36
+ header: z.object({
37
+ typ: z.literal("entity-statement+jwt"),
38
+ alg: z.string(),
39
+ kid: z.string()
40
+ }),
41
+ payload: z.object({
42
+ exp: _types.UnixTime,
43
+ iat: _types.UnixTime,
44
+ iss: z.string(),
45
+ sub: z.string(),
46
+ jwks: z.object({
47
+ keys: z.array(_jwk.JWK)
48
+ }),
49
+ metadata: z.object({
50
+ federation_entity: z.object({
51
+ organization_name: z.string(),
52
+ homepage_uri: z.string(),
53
+ policy_uri: z.string(),
54
+ logo_uri: z.string(),
55
+ contacts: z.array(z.string())
56
+ })
57
+ }),
58
+ authority_hints: z.array(z.string())
59
+ })
60
+ });
61
+ exports.EntityConfiguration = EntityConfiguration;
62
+ const TrustAnchorEntityConfiguration = EntityConfiguration;
63
+ exports.TrustAnchorEntityConfiguration = TrustAnchorEntityConfiguration;
64
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_types","require","_jwk","z","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","TrustMark","object","id","string","trust_mark","exports","EntityStatement","header","typ","literal","alg","kid","payload","iss","sub","jwks","keys","array","JWK","trust_marks","iat","number","exp","EntityConfiguration","UnixTime","metadata","federation_entity","organization_name","homepage_uri","policy_uri","logo_uri","contacts","authority_hints","TrustAnchorEntityConfiguration"],"sourceRoot":"../../../src","sources":["trust/types.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,CAAA,GAAAC,uBAAA,CAAAH,OAAA;AAAyB,SAAAI,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAF,wBAAAM,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,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,MAAA,CAAAJ,OAAA,GA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