@pagopa/io-react-native-wallet 0.4.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. package/README.md +98 -22
  2. package/lib/commonjs/index.js +12 -8
  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 +152 -169
  7. package/lib/commonjs/pid/issuing.js.map +1 -1
  8. package/lib/commonjs/pid/metadata.js +28 -25
  9. package/lib/commonjs/pid/metadata.js.map +1 -1
  10. package/lib/commonjs/rp/__test__/index.test.js +5 -3
  11. package/lib/commonjs/rp/__test__/index.test.js.map +1 -1
  12. package/lib/commonjs/rp/index.js +158 -154
  13. package/lib/commonjs/rp/index.js.map +1 -1
  14. package/lib/commonjs/trust/types.js +9 -7
  15. package/lib/commonjs/trust/types.js.map +1 -1
  16. package/lib/commonjs/utils/crypto.js +46 -0
  17. package/lib/commonjs/utils/crypto.js.map +1 -0
  18. package/lib/commonjs/utils/dpop.js +14 -7
  19. package/lib/commonjs/utils/dpop.js.map +1 -1
  20. package/lib/commonjs/wallet-instance-attestation/index.js +3 -3
  21. package/lib/commonjs/wallet-instance-attestation/issuing.js +50 -60
  22. package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
  23. package/lib/module/index.js +4 -3
  24. package/lib/module/index.js.map +1 -1
  25. package/lib/module/pid/index.js +1 -1
  26. package/lib/module/pid/index.js.map +1 -1
  27. package/lib/module/pid/issuing.js +151 -172
  28. package/lib/module/pid/issuing.js.map +1 -1
  29. package/lib/module/pid/metadata.js +28 -25
  30. package/lib/module/pid/metadata.js.map +1 -1
  31. package/lib/module/rp/__test__/index.test.js +1 -1
  32. package/lib/module/rp/__test__/index.test.js.map +1 -1
  33. package/lib/module/rp/index.js +155 -153
  34. package/lib/module/rp/index.js.map +1 -1
  35. package/lib/module/trust/types.js +7 -6
  36. package/lib/module/trust/types.js.map +1 -1
  37. package/lib/module/utils/crypto.js +40 -0
  38. package/lib/module/utils/crypto.js.map +1 -0
  39. package/lib/module/utils/dpop.js +13 -5
  40. package/lib/module/utils/dpop.js.map +1 -1
  41. package/lib/module/wallet-instance-attestation/index.js +2 -2
  42. package/lib/module/wallet-instance-attestation/index.js.map +1 -1
  43. package/lib/module/wallet-instance-attestation/issuing.js +48 -58
  44. package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
  45. package/lib/typescript/index.d.ts +4 -3
  46. package/lib/typescript/index.d.ts.map +1 -1
  47. package/lib/typescript/pid/index.d.ts +1 -1
  48. package/lib/typescript/pid/index.d.ts.map +1 -1
  49. package/lib/typescript/pid/issuing.d.ts +51 -87
  50. package/lib/typescript/pid/issuing.d.ts.map +1 -1
  51. package/lib/typescript/pid/metadata.d.ts +1338 -408
  52. package/lib/typescript/pid/metadata.d.ts.map +1 -1
  53. package/lib/typescript/rp/index.d.ts +48 -86
  54. package/lib/typescript/rp/index.d.ts.map +1 -1
  55. package/lib/typescript/rp/types.d.ts +413 -57
  56. package/lib/typescript/rp/types.d.ts.map +1 -1
  57. package/lib/typescript/sd-jwt/index.d.ts +1 -1
  58. package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
  59. package/lib/typescript/trust/types.d.ts +1000 -274
  60. package/lib/typescript/trust/types.d.ts.map +1 -1
  61. package/lib/typescript/utils/crypto.d.ts +10 -0
  62. package/lib/typescript/utils/crypto.d.ts.map +1 -0
  63. package/lib/typescript/utils/dpop.d.ts +10 -2
  64. package/lib/typescript/utils/dpop.d.ts.map +1 -1
  65. package/lib/typescript/wallet-instance-attestation/index.d.ts +2 -2
  66. package/lib/typescript/wallet-instance-attestation/index.d.ts.map +1 -1
  67. package/lib/typescript/wallet-instance-attestation/issuing.d.ts +17 -31
  68. package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
  69. package/package.json +2 -2
  70. package/src/index.ts +5 -3
  71. package/src/pid/index.ts +1 -1
  72. package/src/pid/issuing.ts +233 -226
  73. package/src/pid/metadata.ts +32 -27
  74. package/src/rp/__test__/index.test.ts +1 -1
  75. package/src/rp/index.ts +180 -188
  76. package/src/sd-jwt/index.ts +1 -1
  77. package/src/trust/types.ts +39 -32
  78. package/src/utils/crypto.ts +41 -0
  79. package/src/utils/dpop.ts +17 -7
  80. package/src/wallet-instance-attestation/index.ts +2 -2
  81. package/src/wallet-instance-attestation/issuing.ts +55 -62
package/README.md CHANGED
@@ -15,8 +15,67 @@ npm install @pagopa/io-react-native-wallet
15
15
 
16
16
  ## Usage
17
17
 
18
+ Refer to Example App for actual usages.
19
+
20
+ <details>
21
+ <summary>Handling cryptographic assets</summary>
22
+
23
+ User flows implementions make use of tokens signed using asymmetric key pairs. Such cryptographic keys are managed by the device according to its specifications. It's not the intention of this package to handle such cryptographic assets and their peculiarities; instead, an handy interface is used to provide the right abstraction to allow responsibilities segregation:
24
+
25
+ - the application knows who to generate/store/delete keys;
26
+ - the package knows when and where to use them.
27
+
28
+ The interface is `CryptoContext` inherited from the `@pagopa/io-react-native-jwt` package.
29
+
30
+ This package provides an helper to build a `CryptoContext` object bound to a given key tag
31
+
32
+ ```ts
33
+ import { createCryptoContextFor } from "@pagopa/io-react-native-wallet";
34
+
35
+ const ctx = createCryptoContextFor("my-tag");
36
+ ```
37
+
38
+ Be sure the key for `my-tag` already exists.
39
+
40
+ </details>
41
+
42
+ <details>
43
+ <summary>Making HTTP requests</summary>
44
+
45
+ This package is compatibile with any http client which implements [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). Functions that makes http requests allow for an optional `appFetch` parameter to provide a custom http client implementation. If not provided, the built-in implementation on the runtime is used.
46
+
47
+ </details>
48
+
18
49
  ### PID
19
50
 
51
+ #### Issuing
52
+
53
+ ```ts
54
+ import { PID, createCryptoContextFor } from "@pagopa/io-react-native-wallet";
55
+
56
+ // Obtain PID metadata
57
+ const pidEntityConfiguration = await PID.Issuing.getEntityConfiguration()(
58
+ pidProviderBaseUrl
59
+ );
60
+
61
+ // Auth Token request
62
+ const authRequest = PID.Issuing.authorizeIssuing({ wiaCryptoContext });
63
+ const authConf = await authRequest(
64
+ instanceAttestation,
65
+ walletProviderBaseUrl,
66
+ pidEntityConfiguration
67
+ );
68
+
69
+ // Credential request
70
+ const credentialRequest = PID.Issuing.getCredential({ pidCryptoContext });
71
+ const pid = await credentialRequest(authConf, pidEntityConfiguration, {
72
+ birthDate: "01/01/1990",
73
+ fiscalCode: "AAABBB00A00A000A",
74
+ name: "NAME",
75
+ surname: "SURNAME",
76
+ });
77
+ ```
78
+
20
79
  #### Encode and Decode
21
80
 
22
81
  ```ts
@@ -34,28 +93,20 @@ PID.SdJwt.verify("<token>");
34
93
  #### Issuing
35
94
 
36
95
  ```ts
37
- import { WalletInstanceAttestation } from "@pagopa/io-react-native-wallet";
38
-
39
- const issuing = new WalletInstanceAttestation.Issuing(yourWalletProviderUrl);
40
-
41
- // Generate keys
42
- const publicKey = await yourCustomPublicKey("TEE_KEY_TAG");
43
-
44
- const walletInstanceAttestationRequest =
45
- await issuing.getAttestationRequestToSign(publicKey);
46
-
47
- //Sign with TEE
48
- const signature = await yourCustomSignatureFunction(
49
- walletInstanceAttestationRequest,
50
- "TEE_KEY_TAG"
51
- );
52
-
53
- const walletInstanceAttestation = await issuing.getAttestation(
54
- walletInstanceAttestationRequest,
55
- signature
56
- );
57
-
58
- console.log(walletInstanceAttestation);
96
+ import {
97
+ WalletInstanceAttestation,
98
+ createCryptoContextFor,
99
+ } from "@pagopa/io-react-native-wallet";
100
+ // create crypto contet
101
+ const wiaCryptoContext = createCryptoContextFor("wia-keytag");
102
+
103
+ // prepare the request
104
+ const wiaRequest = WalletInstanceAttestation.getAttestation({
105
+ wiaCryptoContext,
106
+ });
107
+
108
+ // request
109
+ const instanceAttestation = await wiaRequest("https://wallet-provider.example");
59
110
  ```
60
111
 
61
112
  #### Encode and Decode
@@ -66,6 +117,31 @@ import { WalletInstanceAttestation } from "io-react-native-wallet";
66
117
  WalletInstanceAttestation.decode("<token>");
67
118
  ```
68
119
 
120
+ ### Relying Party
121
+
122
+ #### Credential presentation
123
+
124
+ ```ts
125
+ import { PID, createCryptoContextFor } from "@pagopa/io-react-native-wallet";
126
+
127
+ // get request object
128
+ const getRequestObject = RelyingPartySolution.getRequestObject({
129
+ wiaCryptoContext,
130
+ });
131
+ const requestObj = await getRequestObject(
132
+ walletInstanceAttestation,
133
+ authRequestUrl,
134
+ entityConfiguration
135
+ );
136
+
137
+ // Submit authorization response
138
+ const sendAuthorizationResponse =
139
+ RelyingPartySolution.sendAuthorizationResponse({
140
+ pidCryptoContext,
141
+ });
142
+ const result = await sendAuthorizationResponse(requestObj, [pidToken, claims]);
143
+ ```
144
+
69
145
  ## Example
70
146
 
71
147
  ### NodeJS and Ruby
@@ -15,13 +15,14 @@ Object.defineProperty(exports, "EntityStatement", {
15
15
  return _types2.EntityStatement;
16
16
  }
17
17
  });
18
- exports.RP = exports.PID = exports.Errors = void 0;
19
- Object.defineProperty(exports, "RelyingPartySolution", {
18
+ exports.PID = exports.Errors = void 0;
19
+ Object.defineProperty(exports, "PidIssuerEntityConfiguration", {
20
20
  enumerable: true,
21
21
  get: function () {
22
- return RP.RelyingPartySolution;
22
+ return _metadata.PidIssuerEntityConfiguration;
23
23
  }
24
24
  });
25
+ exports.RelyingPartySolution = exports.RP = void 0;
25
26
  Object.defineProperty(exports, "RpEntityConfiguration", {
26
27
  enumerable: true,
27
28
  get: function () {
@@ -35,16 +36,16 @@ Object.defineProperty(exports, "TrustAnchorEntityConfiguration", {
35
36
  }
36
37
  });
37
38
  exports.WalletInstanceAttestation = void 0;
38
- Object.defineProperty(exports, "getEntityConfiguration", {
39
+ Object.defineProperty(exports, "createCryptoContextFor", {
39
40
  enumerable: true,
40
41
  get: function () {
41
- return _trust.getEntityConfiguration;
42
+ return _crypto.createCryptoContextFor;
42
43
  }
43
44
  });
44
- Object.defineProperty(exports, "getUnsignedDPop", {
45
+ Object.defineProperty(exports, "getEntityConfiguration", {
45
46
  enumerable: true,
46
47
  get: function () {
47
- return _dpop.getUnsignedDPop;
48
+ return _trust.getEntityConfiguration;
48
49
  }
49
50
  });
50
51
  Object.defineProperty(exports, "verifyTrustChain", {
@@ -57,15 +58,18 @@ require("react-native-url-polyfill/auto");
57
58
  var PID = _interopRequireWildcard(require("./pid"));
58
59
  exports.PID = PID;
59
60
  var RP = _interopRequireWildcard(require("./rp"));
61
+ var RelyingPartySolution = RP;
60
62
  exports.RP = RP;
63
+ exports.RelyingPartySolution = RP;
61
64
  var Errors = _interopRequireWildcard(require("./utils/errors"));
62
65
  exports.Errors = Errors;
63
66
  var WalletInstanceAttestation = _interopRequireWildcard(require("./wallet-instance-attestation"));
64
67
  exports.WalletInstanceAttestation = WalletInstanceAttestation;
65
- var _dpop = require("./utils/dpop");
66
68
  var _types = require("./rp/types");
67
69
  var _trust = require("./trust");
68
70
  var _types2 = require("./trust/types");
71
+ var _crypto = require("./utils/crypto");
72
+ var _metadata = require("./pid/metadata");
69
73
  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); }
70
74
  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; }
71
75
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["require","PID","_interopRequireWildcard","exports","RP","Errors","WalletInstanceAttestation","_dpop","_types","_trust","_types2","_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;AACA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,OAAA,GAAAV,OAAA;AAIuB,SAAAW,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,SAAAV,wBAAAc,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","RelyingPartySolution","Errors","WalletInstanceAttestation","_types","_trust","_types2","_crypto","_metadata","_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;AAA2B,IAAAK,oBAAA,GAAAD,EAAA;AAAAD,OAAA,CAAAC,EAAA,GAAAA,EAAA;AAAAD,OAAA,CAAAE,oBAAA,GAAAD,EAAA;AAC3B,IAAAE,MAAA,GAAAJ,uBAAA,CAAAF,OAAA;AAAyCG,OAAA,CAAAG,MAAA,GAAAA,MAAA;AACzC,IAAAC,yBAAA,GAAAL,uBAAA,CAAAF,OAAA;AAA2EG,OAAA,CAAAI,yBAAA,GAAAA,yBAAA;AAE3E,IAAAC,MAAA,GAAAR,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,OAAA,GAAAV,OAAA;AAKA,IAAAW,OAAA,GAAAX,OAAA;AACA,IAAAY,SAAA,GAAAZ,OAAA;AAA8D,SAAAa,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,SAAAZ,wBAAAgB,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"}
@@ -3,16 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "Issuing", {
7
- enumerable: true,
8
- get: function () {
9
- return _issuing.Issuing;
10
- }
11
- });
12
- exports.SdJwt = void 0;
6
+ exports.SdJwt = exports.Issuing = void 0;
13
7
  var SdJwt = _interopRequireWildcard(require("./sd-jwt"));
14
8
  exports.SdJwt = SdJwt;
15
- var _issuing = require("./issuing");
9
+ var Issuing = _interopRequireWildcard(require("./issuing"));
10
+ exports.Issuing = Issuing;
16
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); }
17
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; }
18
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["SdJwt","_interopRequireWildcard","require","exports","_issuing","_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":["pid/index.ts"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAkCC,OAAA,CAAAH,KAAA,GAAAA,KAAA;AAClC,IAAAI,QAAA,GAAAF,OAAA;AAAoC,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,SAAAL,wBAAAS,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,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":["SdJwt","_interopRequireWildcard","require","exports","Issuing","_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":["pid/index.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAkCC,OAAA,CAAAH,KAAA,GAAAA,KAAA;AAClC,IAAAI,OAAA,GAAAH,uBAAA,CAAAC,OAAA;AAAqCC,OAAA,CAAAC,OAAA,GAAAA,OAAA;AAAA,SAAAC,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAL,wBAAAS,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,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"}
@@ -3,49 +3,52 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Issuing = void 0;
6
+ exports.getEntityConfiguration = exports.getCredential = exports.authorizeIssuing = void 0;
7
7
  var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
8
8
  var _jwk = require("../utils/jwk");
9
9
  var _reactNativeUuid = _interopRequireDefault(require("react-native-uuid"));
10
10
  var _errors = require("../utils/errors");
11
11
  var _dpop = require("../utils/dpop");
12
- var _ioReactNativeCrypto = require("@pagopa/io-react-native-crypto");
13
12
  var _metadata = require("./metadata");
14
- var _jwk2 = require("./../utils/jwk");
13
+ var _2 = require("..");
14
+ var _ioReactNativeCrypto = require("@pagopa/io-react-native-crypto");
15
+ var _3 = require(".");
15
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
17
  // This is a temporary type that will be used for demo purposes only
17
18
 
18
- class Issuing {
19
- constructor(pidProviderBaseUrl, walletProviderBaseUrl, walletInstanceAttestation, clientId) {
20
- let appFetch = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : fetch;
21
- this.pidProviderBaseUrl = pidProviderBaseUrl;
22
- this.walletProviderBaseUrl = walletProviderBaseUrl;
23
- this.state = `${_reactNativeUuid.default.v4()}`;
24
- this.codeVerifier = `${_reactNativeUuid.default.v4()}`;
25
- this.authorizationCode = `${_reactNativeUuid.default.v4()}`;
26
- this.walletInstanceAttestation = walletInstanceAttestation;
27
- this.clientId = clientId;
28
- this.appFetch = appFetch;
29
- }
19
+ /**
20
+ * Obtain the PID provider entity configuration.
21
+ */
22
+ const getEntityConfiguration = function () {
23
+ let {
24
+ appFetch = fetch
25
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
26
+ return async relyingPartyBaseUrl => {
27
+ return (0, _2.getEntityConfiguration)(relyingPartyBaseUrl, {
28
+ appFetch: appFetch
29
+ }).then(_metadata.PidIssuerEntityConfiguration.parse);
30
+ };
31
+ };
30
32
 
31
- /**
32
- * Return the unsigned jwt to call the PAR request.
33
- *
34
- * @function
35
- * @param jwk The wallet instance attestation public JWK
36
- *
37
- * @returns Unsigned jwt
38
- *
39
- */
40
- async getUnsignedJwtForPar(jwk) {
41
- const parsedJwk = _jwk.JWK.parse(jwk);
42
- const keyThumbprint = await (0, _ioReactNativeJwt.thumbprint)(parsedJwk);
43
- const publicKey = {
44
- ...parsedJwk,
33
+ /**
34
+ * Make a PAR request to the PID issuer and return the response url
35
+ */
36
+ exports.getEntityConfiguration = getEntityConfiguration;
37
+ const getPar = _ref => {
38
+ let {
39
+ wiaCryptoContext,
40
+ appFetch = fetch
41
+ } = _ref;
42
+ return async (clientId, codeVerifier, walletProviderBaseUrl, pidProviderEntityConfiguration, walletInstanceAttestation) => {
43
+ // Calculate the thumbprint of the public key of the Wallet Instance Attestation.
44
+ // The PAR request token is signed used the Wallet Instance Attestation key.
45
+ // The signature can be verified by reading the public key from the key set shippet with the it will ship the Wallet Instance Attestation;
46
+ // key is matched by its kid, which is supposed to be the thumbprint of its public key.
47
+ const keyThumbprint = await wiaCryptoContext.getPublicKey().then(_jwk.JWK.parse).then(_ioReactNativeJwt.thumbprint);
48
+ const codeChallenge = await (0, _ioReactNativeJwt.sha256ToBase64)(codeVerifier);
49
+ const signedJwtForPar = await new _ioReactNativeJwt.SignJWT(wiaCryptoContext).setProtectedHeader({
45
50
  kid: keyThumbprint
46
- };
47
- const codeChallenge = await (0, _ioReactNativeJwt.sha256ToBase64)(this.codeVerifier);
48
- const unsignedJwtForPar = new _ioReactNativeJwt.SignJWT({
51
+ }).setPayload({
49
52
  client_assertion_type: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
50
53
  authorization_details: [{
51
54
  credentialDefinition: {
@@ -56,42 +59,23 @@ class Issuing {
56
59
  }],
57
60
  response_type: "code",
58
61
  code_challenge_method: "s256",
59
- redirect_uri: this.walletProviderBaseUrl,
60
- state: this.state,
61
- client_id: this.clientId,
62
+ redirect_uri: walletProviderBaseUrl,
63
+ state: `${_reactNativeUuid.default.v4()}`,
64
+ client_id: clientId,
62
65
  code_challenge: codeChallenge
63
- }).setProtectedHeader({
64
- alg: "ES256",
65
- kid: publicKey.kid
66
- }).setIssuedAt().setExpirationTime("1h").toSign();
67
- return unsignedJwtForPar;
68
- }
69
-
70
- /**
71
- * Make a PAR request to the PID issuer and return the response url
72
- *
73
- * @function
74
- * @param unsignedJwtForPar The unsigned JWT for PAR
75
- * @param signature The JWT for PAR signature
76
- *
77
- * @returns Unsigned PAR url
78
- *
79
- */
80
- async getPar(unsignedJwtForPar, signature) {
81
- const codeChallenge = await (0, _ioReactNativeJwt.sha256ToBase64)(this.codeVerifier);
82
- const signedJwtForPar = await _ioReactNativeJwt.SignJWT.appendSignature(unsignedJwtForPar, signature);
83
- const parUrl = new URL("/as/par", this.pidProviderBaseUrl).href;
66
+ }).setIssuedAt().setExpirationTime("1h").sign();
67
+ const parUrl = pidProviderEntityConfiguration.payload.metadata.openid_credential_issuer.pushed_authorization_request_endpoint;
84
68
  const requestBody = {
85
69
  response_type: "code",
86
- client_id: this.clientId,
70
+ client_id: clientId,
87
71
  code_challenge: codeChallenge,
88
72
  code_challenge_method: "S256",
89
73
  client_assertion_type: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
90
- client_assertion: this.walletInstanceAttestation,
74
+ client_assertion: walletInstanceAttestation,
91
75
  request: signedJwtForPar
92
76
  };
93
77
  var formBody = new URLSearchParams(requestBody);
94
- const response = await this.appFetch(parUrl, {
78
+ const response = await appFetch(parUrl, {
95
79
  method: "POST",
96
80
  headers: {
97
81
  "Content-Type": "application/x-www-form-urlencoded"
@@ -103,55 +87,56 @@ class Issuing {
103
87
  return result.request_uri;
104
88
  }
105
89
  throw new _errors.PidIssuingError(`Unable to obtain PAR. Response code: ${await response.text()}`);
106
- }
90
+ };
91
+ };
92
+
93
+ /**
94
+ * Start the issuing flow by generating an authorization request to the PID Provider. Obtain from the PID Provider an access token to be used to complete the issuing flow.
95
+ *
96
+ * @param params.wiaCryptoContext The key pair associated with the WIA. Will be use to prove the ownership of the attestation.
97
+ * @param params.appFetch (optional) Http client
98
+ * @param walletInstanceAttestation Wallet Instance Attestation token.
99
+ * @param walletProviderBaseUrl Base url for the Wallet Provider
100
+ * @param pidProviderEntityConfiguration The Entity Configuration of the PID Provider, from which discover public endooints.
101
+ * @returns The access token along with the values that identify the issuing session.
102
+ */
103
+ const authorizeIssuing = _ref2 => {
104
+ let {
105
+ wiaCryptoContext,
106
+ appFetch = fetch
107
+ } = _ref2;
108
+ return async (walletInstanceAttestation, walletProviderBaseUrl, pidProviderEntityConfiguration) => {
109
+ // FIXME: do better
110
+ const clientId = await wiaCryptoContext.getPublicKey().then(_ => _.kid);
111
+ const codeVerifier = `${_reactNativeUuid.default.v4()}`;
112
+ const authorizationCode = `${_reactNativeUuid.default.v4()}`;
113
+ const tokenUrl = pidProviderEntityConfiguration.payload.metadata.openid_credential_issuer.token_endpoint;
114
+ await getPar({
115
+ wiaCryptoContext,
116
+ appFetch
117
+ })(clientId, codeVerifier, walletProviderBaseUrl, pidProviderEntityConfiguration, walletInstanceAttestation);
107
118
 
108
- /**
109
- * Return the unsigned jwt for a generic DPoP
110
- *
111
- * @function
112
- * @param jwk the public key for which the DPoP is to be created
113
- *
114
- * @returns Unsigned JWT for DPoP
115
- *
116
- */
117
- async getUnsignedDPoP(jwk) {
118
- const tokenUrl = new URL("/token", this.pidProviderBaseUrl).href;
119
- const dPop = (0, _dpop.getUnsignedDPop)((0, _jwk2.fixBase64EncodingOnKey)(jwk), {
119
+ // Use an ephemeral key to be destroyed after use
120
+ const keytag = `ephemeral-${_reactNativeUuid.default.v4()}`;
121
+ await (0, _ioReactNativeCrypto.generate)(keytag);
122
+ const ephemeralContext = (0, _2.createCryptoContextFor)(keytag);
123
+ const signedDPop = await (0, _dpop.createDPopToken)({
120
124
  htm: "POST",
121
125
  htu: tokenUrl,
122
126
  jti: `${_reactNativeUuid.default.v4()}`
123
- });
124
- return dPop;
125
- }
126
-
127
- /**
128
- * Make an auth token request to the PID issuer
129
- *
130
- * @function
131
- * @returns a token response
132
- *
133
- */
134
- async getAuthToken() {
135
- //Generate fresh keys for DPoP
136
- const dPopKeyTag = `${_reactNativeUuid.default.v4()}`;
137
- const dPopKey = await (0, _ioReactNativeCrypto.generate)(dPopKeyTag);
138
- const unsignedDPopForToken = await this.getUnsignedDPoP(dPopKey);
139
- const dPopTokenSignature = await (0, _ioReactNativeCrypto.sign)(unsignedDPopForToken, dPopKeyTag);
140
- await (0, _ioReactNativeCrypto.deleteKey)(dPopKeyTag);
141
- const signedDPop = await _ioReactNativeJwt.SignJWT.appendSignature(unsignedDPopForToken, dPopTokenSignature);
142
- const decodedJwtDPop = (0, _ioReactNativeJwt.decode)(signedDPop);
143
- const tokenUrl = decodedJwtDPop.payload.htu;
127
+ }, ephemeralContext);
128
+ await (0, _ioReactNativeCrypto.deleteKey)(keytag);
144
129
  const requestBody = {
145
130
  grant_type: "authorization code",
146
- client_id: this.clientId,
147
- code: this.authorizationCode,
148
- code_verifier: this.codeVerifier,
131
+ client_id: clientId,
132
+ code: authorizationCode,
133
+ code_verifier: codeVerifier,
149
134
  client_assertion_type: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
150
- client_assertion: this.walletInstanceAttestation,
151
- redirect_uri: this.walletProviderBaseUrl
135
+ client_assertion: walletInstanceAttestation,
136
+ redirect_uri: walletProviderBaseUrl
152
137
  };
153
138
  var formBody = new URLSearchParams(requestBody);
154
- const response = await this.appFetch(tokenUrl, {
139
+ const response = await appFetch(tokenUrl, {
155
140
  method: "POST",
156
141
  headers: {
157
142
  "Content-Type": "application/x-www-form-urlencoded",
@@ -160,48 +145,63 @@ class Issuing {
160
145
  body: formBody.toString()
161
146
  });
162
147
  if (response.status === 200) {
163
- return await response.json();
148
+ const {
149
+ c_nonce,
150
+ access_token
151
+ } = await response.json();
152
+ return {
153
+ accessToken: access_token,
154
+ nonce: c_nonce,
155
+ clientId,
156
+ codeVerifier,
157
+ authorizationCode,
158
+ walletProviderBaseUrl
159
+ };
164
160
  }
165
161
  throw new _errors.PidIssuingError(`Unable to obtain token. Response code: ${await response.text()}`);
166
- }
162
+ };
163
+ };
167
164
 
168
- /**
169
- * Return the unsigned jwt for nonce proof of possession
170
- *
171
- * @function
172
- * @param nonce the nonce
173
- *
174
- * @returns Unsigned JWT for nonce proof
175
- *
176
- */
177
- async getUnsignedNonceProof(nonce) {
178
- const unsignedProof = new _ioReactNativeJwt.SignJWT({
179
- nonce
180
- }).setProtectedHeader({
181
- alg: "ES256",
182
- type: "openid4vci-proof+jwt"
183
- }).setAudience(this.walletProviderBaseUrl).setIssuer(this.clientId).setIssuedAt().setExpirationTime("1h").toSign();
184
- return unsignedProof;
185
- }
165
+ /**
166
+ * Return the signed jwt for nonce proof of possession
167
+ */
168
+ exports.authorizeIssuing = authorizeIssuing;
169
+ const createNonceProof = async (nonce, issuer, audience, ctx) => {
170
+ return new _ioReactNativeJwt.SignJWT(ctx).setPayload({
171
+ nonce
172
+ }).setProtectedHeader({
173
+ type: "openid4vci-proof+jwt"
174
+ }).setAudience(audience).setIssuer(issuer).setIssuedAt().setExpirationTime("1h").sign();
175
+ };
186
176
 
187
- /**
188
- * Make the credential issuing request to the PID issuer
189
- *
190
- * @function
191
- * @param unsignedDPopForPid The unsigned JWT for PID DPoP
192
- * @param dPopPidSignature The JWT for PID DPoP signature
193
- * @param unsignedNonceProof The unsigned JWT for nonce proof
194
- * @param nonceProofSignature The JWT for nonce proof signature
195
- * @param accessToken The access token obtained with getAuthToken
196
- * @param cieData Personal data read by the CIE
197
- *
198
- * @returns a credential
199
- *
200
- */
201
- async getCredential(unsignedDPopForPid, dPopPidSignature, unsignedNonceProof, nonceProofSignature, accessToken, cieData) {
202
- const signedDPopForPid = await _ioReactNativeJwt.SignJWT.appendSignature(unsignedDPopForPid, dPopPidSignature);
203
- const signedNonceProof = await _ioReactNativeJwt.SignJWT.appendSignature(unsignedNonceProof, nonceProofSignature);
204
- const credentialUrl = new URL("/credential", this.pidProviderBaseUrl).href;
177
+ /**
178
+ * Complete the issuing flow and get the PID credential.
179
+ *
180
+ * @param params.pidCryptoContext The key pair associated with the PID. Will be use to prove the ownership of the credential.
181
+ * @param params.appFetch (optional) Http client
182
+ * @param authConf The authorization configuration retrieved with the access token
183
+ * @param cieData Data red from the CIE login process
184
+ * @returns The PID credential token
185
+ */
186
+ const getCredential = _ref3 => {
187
+ let {
188
+ pidCryptoContext,
189
+ appFetch = fetch
190
+ } = _ref3;
191
+ return async (_ref4, pidProviderEntityConfiguration, cieData) => {
192
+ let {
193
+ nonce,
194
+ accessToken,
195
+ clientId,
196
+ walletProviderBaseUrl
197
+ } = _ref4;
198
+ const signedDPopForPid = await (0, _dpop.createDPopToken)({
199
+ htm: "POST",
200
+ htu: pidProviderEntityConfiguration.payload.metadata.openid_credential_issuer.token_endpoint,
201
+ jti: `${_reactNativeUuid.default.v4()}`
202
+ }, pidCryptoContext);
203
+ const signedNonceProof = await createNonceProof(nonce, clientId, walletProviderBaseUrl, pidCryptoContext);
204
+ const credentialUrl = pidProviderEntityConfiguration.payload.metadata.openid_credential_issuer.credential_endpoint;
205
205
  const requestBody = {
206
206
  credential_definition: JSON.stringify({
207
207
  type: ["eu.eudiw.pid.it"]
@@ -214,7 +214,7 @@ class Issuing {
214
214
  })
215
215
  };
216
216
  const formBody = new URLSearchParams(requestBody);
217
- const response = await this.appFetch(credentialUrl, {
217
+ const response = await appFetch(credentialUrl, {
218
218
  method: "POST",
219
219
  headers: {
220
220
  "Content-Type": "application/x-www-form-urlencoded",
@@ -224,37 +224,20 @@ class Issuing {
224
224
  body: formBody.toString()
225
225
  });
226
226
  if (response.status === 200) {
227
- return await response.json();
228
- }
229
- throw new _errors.PidIssuingError(`Unable to obtain credential!`);
230
- }
231
-
232
- /**
233
- * Obtain the PID issuer metadata
234
- *
235
- * @function
236
- * @returns PID issuer metadata
237
- *
238
- */
239
- async getEntityConfiguration() {
240
- const metadataUrl = new URL("ci/.well-known/openid-federation", this.pidProviderBaseUrl).href;
241
- const response = await this.appFetch(metadataUrl);
242
- if (response.status === 200) {
243
- const jwtMetadata = await response.text();
244
- const {
245
- payload
246
- } = (0, _ioReactNativeJwt.decode)(jwtMetadata);
247
- const result = _metadata.PidIssuerEntityConfiguration.safeParse(payload);
248
- if (result.success) {
249
- const parsedMetadata = result.data;
250
- await (0, _ioReactNativeJwt.verify)(jwtMetadata, parsedMetadata.jwks.keys);
251
- return parsedMetadata;
252
- } else {
253
- throw new _errors.PidMetadataError(result.error.message);
254
- }
227
+ const pidResponse = await response.json();
228
+ await validatePid(pidResponse.credential, pidCryptoContext);
229
+ return pidResponse;
255
230
  }
256
- throw new _errors.PidMetadataError(`Unable to obtain PID metadata. Response: ${await response.text()} with status: ${response.status}`);
231
+ throw new _errors.PidIssuingError(`Unable to obtain credential! url=${credentialUrl} status=${response.status} body=${await response.text()}`);
232
+ };
233
+ };
234
+ exports.getCredential = getCredential;
235
+ const validatePid = async (pidJwt, pidCryptoContext) => {
236
+ const decoded = _3.SdJwt.decode(pidJwt);
237
+ const pidKey = await pidCryptoContext.getPublicKey();
238
+ const holderBindedKey = decoded.sdJwt.payload.cnf.jwk;
239
+ if ((await (0, _ioReactNativeJwt.thumbprint)(pidKey)) !== (await (0, _ioReactNativeJwt.thumbprint)(holderBindedKey))) {
240
+ throw new _errors.PidIssuingError(`The obtained pid does not seem to be valid according to your configuration. Your PID public key is: ${JSON.stringify(pidKey)} but PID holder binded key is: ${JSON.stringify(holderBindedKey)}`);
257
241
  }
258
- }
259
- exports.Issuing = Issuing;
242
+ };
260
243
  //# sourceMappingURL=issuing.js.map