@pagopa/io-react-native-wallet 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. package/README.md +1 -1
  2. package/lib/commonjs/index.js +12 -5
  3. package/lib/commonjs/index.js.map +1 -1
  4. package/lib/commonjs/pid/index.js +7 -0
  5. package/lib/commonjs/pid/index.js.map +1 -1
  6. package/lib/commonjs/pid/issuing.js +231 -0
  7. package/lib/commonjs/pid/issuing.js.map +1 -0
  8. package/lib/commonjs/rp/__test__/index.test.js +18 -0
  9. package/lib/commonjs/rp/__test__/index.test.js.map +1 -0
  10. package/lib/commonjs/rp/index.js +116 -0
  11. package/lib/commonjs/rp/index.js.map +1 -0
  12. package/lib/commonjs/rp/types.js +72 -0
  13. package/lib/commonjs/rp/types.js.map +1 -0
  14. package/lib/commonjs/sd-jwt/types.js +1 -1
  15. package/lib/commonjs/sd-jwt/types.js.map +1 -1
  16. package/lib/commonjs/utils/dpop.js +27 -0
  17. package/lib/commonjs/utils/dpop.js.map +1 -0
  18. package/lib/commonjs/utils/errors.js +49 -1
  19. package/lib/commonjs/utils/errors.js.map +1 -1
  20. package/lib/commonjs/wallet-instance-attestation/issuing.js +3 -5
  21. package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
  22. package/lib/module/index.js +4 -4
  23. package/lib/module/index.js.map +1 -1
  24. package/lib/module/pid/index.js +2 -1
  25. package/lib/module/pid/index.js.map +1 -1
  26. package/lib/module/pid/issuing.js +225 -0
  27. package/lib/module/pid/issuing.js.map +1 -0
  28. package/lib/module/rp/__test__/index.test.js +16 -0
  29. package/lib/module/rp/__test__/index.test.js.map +1 -0
  30. package/lib/module/rp/index.js +108 -0
  31. package/lib/module/rp/index.js.map +1 -0
  32. package/lib/module/rp/types.js +63 -0
  33. package/lib/module/rp/types.js.map +1 -0
  34. package/lib/module/sd-jwt/types.js +1 -1
  35. package/lib/module/sd-jwt/types.js.map +1 -1
  36. package/lib/module/utils/dpop.js +17 -0
  37. package/lib/module/utils/dpop.js.map +1 -0
  38. package/lib/module/utils/errors.js +46 -0
  39. package/lib/module/utils/errors.js.map +1 -1
  40. package/lib/module/wallet-instance-attestation/issuing.js +3 -5
  41. package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
  42. package/lib/typescript/index.d.ts +4 -2
  43. package/lib/typescript/index.d.ts.map +1 -1
  44. package/lib/typescript/pid/index.d.ts +2 -1
  45. package/lib/typescript/pid/index.d.ts.map +1 -1
  46. package/lib/typescript/pid/issuing.d.ts +93 -0
  47. package/lib/typescript/pid/issuing.d.ts.map +1 -0
  48. package/lib/typescript/rp/__test__/index.test.d.ts +2 -0
  49. package/lib/typescript/rp/__test__/index.test.d.ts.map +1 -0
  50. package/lib/typescript/rp/index.d.ts +43 -0
  51. package/lib/typescript/rp/index.d.ts.map +1 -0
  52. package/lib/typescript/rp/types.d.ts +840 -0
  53. package/lib/typescript/rp/types.d.ts.map +1 -0
  54. package/lib/typescript/sd-jwt/types.d.ts +5 -5
  55. package/lib/typescript/utils/dpop.d.ts +21 -0
  56. package/lib/typescript/utils/dpop.d.ts.map +1 -0
  57. package/lib/typescript/utils/errors.d.ts +26 -0
  58. package/lib/typescript/utils/errors.d.ts.map +1 -1
  59. package/lib/typescript/wallet-instance-attestation/issuing.d.ts +3 -3
  60. package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
  61. package/lib/typescript/wallet-instance-attestation/types.d.ts +4 -4
  62. package/package.json +4 -2
  63. package/src/index.ts +4 -5
  64. package/src/pid/index.ts +2 -1
  65. package/src/pid/issuing.ts +305 -0
  66. package/src/rp/__test__/index.test.ts +23 -0
  67. package/src/rp/index.ts +150 -0
  68. package/src/rp/types.ts +64 -0
  69. package/src/sd-jwt/types.ts +1 -1
  70. package/src/utils/dpop.ts +25 -0
  71. package/src/utils/errors.ts +48 -0
  72. package/src/wallet-instance-attestation/issuing.ts +9 -7
package/README.md CHANGED
@@ -41,7 +41,7 @@ const issuing = new WalletInstanceAttestation.Issuing(
41
41
  yourWalletProviderUrl
42
42
  );
43
43
 
44
- // Genrate keys
44
+ // Generate keys
45
45
  const publicKey = await yourCustomPublicKey("TEE_KEY_TAG");
46
46
 
47
47
  const walletInstanceAttestationRequest =
@@ -3,15 +3,22 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.WalletInstanceAttestation = exports.PID = void 0;
7
- exports.multiply = multiply;
6
+ exports.WalletInstanceAttestation = exports.RP = exports.PID = exports.Errors = void 0;
7
+ Object.defineProperty(exports, "getUnsignedDPop", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _dpop.getUnsignedDPop;
11
+ }
12
+ });
8
13
  var PID = _interopRequireWildcard(require("./pid"));
9
14
  exports.PID = PID;
15
+ var RP = _interopRequireWildcard(require("./rp"));
16
+ exports.RP = RP;
17
+ var Errors = _interopRequireWildcard(require("./utils/errors"));
18
+ exports.Errors = Errors;
10
19
  var WalletInstanceAttestation = _interopRequireWildcard(require("./wallet-instance-attestation"));
11
20
  exports.WalletInstanceAttestation = WalletInstanceAttestation;
21
+ var _dpop = require("./utils/dpop");
12
22
  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); }
13
23
  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; }
14
- function multiply(a, b) {
15
- return Promise.resolve(a * b);
16
- }
17
24
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["PID","_interopRequireWildcard","require","exports","WalletInstanceAttestation","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","multiply","a","b","Promise","resolve"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;AAAA,IAAAA,GAAA,GAAAC,uBAAA,CAAAC,OAAA;AAA6BC,OAAA,CAAAH,GAAA,GAAAA,GAAA;AAC7B,IAAAI,yBAAA,GAAAH,uBAAA,CAAAC,OAAA;AAA2EC,OAAA,CAAAC,yBAAA,GAAAA,yBAAA;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;AAEpE,SAASW,QAAQA,CAACC,CAAS,EAAEC,CAAS,EAAmB;EAC9D,OAAOC,OAAO,CAACC,OAAO,CAACH,CAAC,GAAGC,CAAC,CAAC;AAC/B"}
1
+ {"version":3,"names":["PID","_interopRequireWildcard","require","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":";;;;;;;;;;;;AAAA,IAAAA,GAAA,GAAAC,uBAAA,CAAAC,OAAA;AAA6BC,OAAA,CAAAH,GAAA,GAAAA,GAAA;AAC7B,IAAAI,EAAA,GAAAH,uBAAA,CAAAC,OAAA;AAA2BC,OAAA,CAAAC,EAAA,GAAAA,EAAA;AAC3B,IAAAC,MAAA,GAAAJ,uBAAA,CAAAC,OAAA;AAAyCC,OAAA,CAAAE,MAAA,GAAAA,MAAA;AACzC,IAAAC,yBAAA,GAAAL,uBAAA,CAAAC,OAAA;AAA2EC,OAAA,CAAAG,yBAAA,GAAAA,yBAAA;AAC3E,IAAAC,KAAA,GAAAL,OAAA;A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uing;
10
+ }
11
+ });
6
12
  exports.SdJwt = void 0;
7
13
  var SdJwt = _interopRequireWildcard(require("./sd-jwt"));
8
14
  exports.SdJwt = SdJwt;
15
+ var _issuing = require("./issuing");
9
16
  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); }
10
17
  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; }
11
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["SdJwt","_interopRequireWildcard","require","exports","_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;AAAA,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,SAAAJ,wBAAAQ,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,I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"use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Issuing = void 0;
7
+ var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
8
+ var _jwk = require("../utils/jwk");
9
+ var _reactNativeUuid = _interopRequireDefault(require("react-native-uuid"));
10
+ var _errors = require("../utils/errors");
11
+ var _dpop = require("../utils/dpop");
12
+ var _ioReactNativeCrypto = require("@pagopa/io-react-native-crypto");
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+ // This is a temporary type that will be used for demo purposes only
15
+
16
+ class Issuing {
17
+ constructor(pidProviderBaseUrl, walletProviderBaseUrl, walletInstanceAttestation, clientId) {
18
+ let appFetch = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : fetch;
19
+ this.pidProviderBaseUrl = pidProviderBaseUrl;
20
+ this.walletProviderBaseUrl = walletProviderBaseUrl;
21
+ this.state = `${_reactNativeUuid.default.v4()}`;
22
+ this.codeVerifier = `${_reactNativeUuid.default.v4()}`;
23
+ this.authorizationCode = `${_reactNativeUuid.default.v4()}`;
24
+ this.walletInstanceAttestation = walletInstanceAttestation;
25
+ this.clientId = clientId;
26
+ this.appFetch = appFetch;
27
+ }
28
+
29
+ /**
30
+ * Return the unsigned jwt to call the PAR request.
31
+ *
32
+ * @function
33
+ * @param jwk The wallet instance attestation public JWK
34
+ *
35
+ * @returns Unsigned jwt
36
+ *
37
+ */
38
+ async getUnsignedJwtForPar(jwk) {
39
+ const parsedJwk = _jwk.JWK.parse(jwk);
40
+ const keyThumbprint = await (0, _ioReactNativeJwt.thumbprint)(parsedJwk);
41
+ const publicKey = {
42
+ ...parsedJwk,
43
+ kid: keyThumbprint
44
+ };
45
+ const codeChallenge = await (0, _ioReactNativeJwt.sha256ToBase64)(this.codeVerifier);
46
+ const unsignedJwtForPar = new _ioReactNativeJwt.SignJWT({
47
+ client_assertion_type: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
48
+ authorization_details: [{
49
+ credentialDefinition: {
50
+ type: ["eu.eudiw.pid.it"]
51
+ },
52
+ format: "vc+sd-jwt",
53
+ type: "type"
54
+ }],
55
+ response_type: "code",
56
+ code_challenge_method: "s256",
57
+ redirect_uri: this.walletProviderBaseUrl,
58
+ state: this.state,
59
+ client_id: this.clientId,
60
+ code_challenge: codeChallenge
61
+ }).setProtectedHeader({
62
+ alg: "ES256",
63
+ kid: publicKey.kid
64
+ }).setIssuedAt().setExpirationTime("1h").toSign();
65
+ return unsignedJwtForPar;
66
+ }
67
+
68
+ /**
69
+ * Make a PAR request to the PID issuer and return the response url
70
+ *
71
+ * @function
72
+ * @param unsignedJwtForPar The unsigned JWT for PAR
73
+ * @param signature The JWT for PAR signature
74
+ *
75
+ * @returns Unsigned PAR url
76
+ *
77
+ */
78
+ async getPar(unsignedJwtForPar, signature) {
79
+ const codeChallenge = await (0, _ioReactNativeJwt.sha256ToBase64)(this.codeVerifier);
80
+ const signedJwtForPar = await _ioReactNativeJwt.SignJWT.appendSignature(unsignedJwtForPar, signature);
81
+ const parUrl = new URL("/as/par", this.pidProviderBaseUrl).href;
82
+ const requestBody = {
83
+ response_type: "code",
84
+ client_id: this.clientId,
85
+ code_challenge: codeChallenge,
86
+ code_challenge_method: "S256",
87
+ client_assertion_type: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
88
+ client_assertion: this.walletInstanceAttestation,
89
+ request: signedJwtForPar
90
+ };
91
+ var formBody = new URLSearchParams(requestBody);
92
+ const response = await this.appFetch(parUrl, {
93
+ method: "POST",
94
+ headers: {
95
+ "Content-Type": "application/x-www-form-urlencoded"
96
+ },
97
+ body: formBody.toString()
98
+ });
99
+ if (response.status === 201) {
100
+ const result = await response.json();
101
+ return result.request_uri;
102
+ }
103
+ throw new _errors.PidIssuingError(`Unable to obtain PAR. Response code: ${await response.text()}`);
104
+ }
105
+
106
+ /**
107
+ * Return the unsigned jwt for a generic DPoP
108
+ *
109
+ * @function
110
+ * @param jwk the public key for which the DPoP is to be created
111
+ *
112
+ * @returns Unsigned JWT for DPoP
113
+ *
114
+ */
115
+ async getUnsignedDPoP(jwk) {
116
+ const tokenUrl = new URL("/token", this.pidProviderBaseUrl).href;
117
+ const dPop = (0, _dpop.getUnsignedDPop)(jwk, {
118
+ htm: "POST",
119
+ htu: tokenUrl,
120
+ jti: `${_reactNativeUuid.default.v4()}`
121
+ });
122
+ return dPop;
123
+ }
124
+
125
+ /**
126
+ * Make an auth token request to the PID issuer
127
+ *
128
+ * @function
129
+ * @returns a token response
130
+ *
131
+ */
132
+ async getAuthToken() {
133
+ //Generate fresh keys for DPoP
134
+ const dPopKeyTag = `${_reactNativeUuid.default.v4()}`;
135
+ const dPopKey = await (0, _ioReactNativeCrypto.generate)(dPopKeyTag);
136
+ const unsignedDPopForToken = await this.getUnsignedDPoP(dPopKey);
137
+ const dPopTokenSignature = await (0, _ioReactNativeCrypto.sign)(unsignedDPopForToken, dPopKeyTag);
138
+ await (0, _ioReactNativeCrypto.deleteKey)(dPopKeyTag);
139
+ const signedDPop = await _ioReactNativeJwt.SignJWT.appendSignature(unsignedDPopForToken, dPopTokenSignature);
140
+ const decodedJwtDPop = (0, _ioReactNativeJwt.decode)(signedDPop);
141
+ const tokenUrl = decodedJwtDPop.payload.htu;
142
+ const requestBody = {
143
+ grant_type: "authorization code",
144
+ client_id: this.clientId,
145
+ code: this.authorizationCode,
146
+ code_verifier: this.codeVerifier,
147
+ client_assertion_type: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
148
+ client_assertion: this.walletInstanceAttestation,
149
+ redirect_uri: this.walletProviderBaseUrl
150
+ };
151
+ var formBody = new URLSearchParams(requestBody);
152
+ const response = await this.appFetch(tokenUrl, {
153
+ method: "POST",
154
+ headers: {
155
+ "Content-Type": "application/x-www-form-urlencoded",
156
+ DPoP: signedDPop
157
+ },
158
+ body: formBody.toString()
159
+ });
160
+ if (response.status === 200) {
161
+ return await response.json();
162
+ }
163
+ throw new _errors.PidIssuingError(`Unable to obtain token. Response code: ${await response.text()}`);
164
+ }
165
+
166
+ /**
167
+ * Return the unsigned jwt for nonce proof of possession
168
+ *
169
+ * @function
170
+ * @param nonce the nonce
171
+ *
172
+ * @returns Unsigned JWT for nonce proof
173
+ *
174
+ */
175
+ async getUnsignedNonceProof(nonce) {
176
+ const unsignedProof = new _ioReactNativeJwt.SignJWT({
177
+ nonce
178
+ }).setProtectedHeader({
179
+ alg: "ES256",
180
+ type: "openid4vci-proof+jwt"
181
+ }).setAudience(this.walletProviderBaseUrl).setIssuer(this.clientId).setIssuedAt().setExpirationTime("1h").toSign();
182
+ return unsignedProof;
183
+ }
184
+
185
+ /**
186
+ * Make the credential issuing request to the PID issuer
187
+ *
188
+ * @function
189
+ * @param unsignedDPopForPid The unsigned JWT for PID DPoP
190
+ * @param dPopPidSignature The JWT for PID DPoP signature
191
+ * @param unsignedNonceProof The unsigned JWT for nonce proof
192
+ * @param nonceProofSignature The JWT for nonce proof signature
193
+ * @param accessToken The access token obtained with getAuthToken
194
+ * @param cieData Personal data read by the CIE
195
+ *
196
+ * @returns a credential
197
+ *
198
+ */
199
+ async getCredential(unsignedDPopForPid, dPopPidSignature, unsignedNonceProof, nonceProofSignature, accessToken, cieData) {
200
+ const signedDPopForPid = await _ioReactNativeJwt.SignJWT.appendSignature(unsignedDPopForPid, dPopPidSignature);
201
+ const signedNonceProof = await _ioReactNativeJwt.SignJWT.appendSignature(unsignedNonceProof, nonceProofSignature);
202
+ const credentialUrl = new URL("/credential", this.pidProviderBaseUrl).href;
203
+ const requestBody = {
204
+ credential_definition: JSON.stringify({
205
+ type: ["eu.eudiw.pid.it"]
206
+ }),
207
+ format: "vc+sd-jwt",
208
+ proof: JSON.stringify({
209
+ jwt: signedNonceProof,
210
+ cieData,
211
+ proof_type: "jwt"
212
+ })
213
+ };
214
+ const formBody = new URLSearchParams(requestBody);
215
+ const response = await this.appFetch(credentialUrl, {
216
+ method: "POST",
217
+ headers: {
218
+ "Content-Type": "application/x-www-form-urlencoded",
219
+ DPoP: signedDPopForPid,
220
+ Authorization: accessToken
221
+ },
222
+ body: formBody.toString()
223
+ });
224
+ if (response.status === 200) {
225
+ return await response.json();
226
+ }
227
+ throw new _errors.PidIssuingError(`Unable to obtain credential!`);
228
+ }
229
+ }
230
+ exports.Issuing = Issuing;
231
+ //# sourceMappingURL=issuing.js.map
@@ -0,0 +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,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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"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ var _ = require("..");
4
+ var _errors = require("../../utils/errors");
5
+ const walletInstanceAttestation = "eyJhbGciOiJFUzI1NiIsImtpZCI6IjV0NVlZcEJoTi1FZ0lFRUk1aVV6cjZyME1SMDJMblZRME9tZWttTktjalkiLCJ0cnVzdF9jaGFpbiI6WyJleUpoYkdjaU9pSkZVei4uLjZTMEEiLCJleUpoYkdjaU9pSkZVei4uLmpKTEEiLCJleUpoYkdjaU9pSkZVei4uLkg5Z3ciXSwidHlwIjoidmErand0IiwieDVjIjpbIk1JSUJqRENDIC4uLiBYRmVoZ0tRQT09Il19.eyJpc3MiOiJodHRwczovL3dhbGxldC1wcm92aWRlci5leGFtcGxlLm9yZyIsInN1YiI6InZiZVhKa3NNNDV4cGh0QU5uQ2lHNm1DeXVVNGpmR056b3BHdUt2b2dnOWMiLCJ0eXBlIjoiV2FsbGV0SW5zdGFuY2VBdHRlc3RhdGlvbiIsInBvbGljeV91cmkiOiJodHRwczovL3dhbGxldC1wcm92aWRlci5leGFtcGxlLm9yZy9wcml2YWN5X3BvbGljeSIsInRvc191cmkiOiJodHRwczovL3dhbGxldC1wcm92aWRlci5leGFtcGxlLm9yZy9pbmZvX3BvbGljeSIsImxvZ29fdXJpIjoiaHR0cHM6Ly93YWxsZXQtcHJvdmlkZXIuZXhhbXBsZS5vcmcvbG9nby5zdmciLCJhc2MiOiJodHRwczovL3dhbGxldC1wcm92aWRlci5leGFtcGxlLm9yZy9Mb0EvYmFzaWMiLCJjbmYiOnsiandrIjp7ImNydiI6IlAtMjU2Iiwia3R5IjoiRUMiLCJ4IjoiNEhOcHRJLXhyMnBqeVJKS0dNbno0V21kblFEX3VKU3E0Ujk1Tmo5OGI0NCIsInkiOiJMSVpuU0IzOXZGSmhZZ1MzazdqWEU0cjMtQ29HRlF3WnRQQklScXBObHJnIiwia2lkIjoidmJlWEprc000NXhwaHRBTm5DaUc2bUN5dVU0amZHTnpvcEd1S3ZvZ2c5YyJ9fSwiYXV0aG9yaXphdGlvbl9lbmRwb2ludCI6ImV1ZGl3OiIsInJlc3BvbnNlX3R5cGVzX3N1cHBvcnRlZCI6WyJ2cF90b2tlbiJdLCJ2cF9mb3JtYXRzX3N1cHBvcnRlZCI6eyJqd3RfdnBfanNvbiI6eyJhbGdfdmFsdWVzX3N1cHBvcnRlZCI6WyJFUzI1NiJdfSwiand0X3ZjX2pzb24iOnsiYWxnX3ZhbHVlc19zdXBwb3J0ZWQiOlsiRVMyNTYiXX19LCJyZXF1ZXN0X29iamVjdF9zaWduaW5nX2FsZ192YWx1ZXNfc3VwcG9ydGVkIjpbIkVTMjU2Il0sInByZXNlbnRhdGlvbl9kZWZpbml0aW9uX3VyaV9zdXBwb3J0ZWQiOmZhbHNlLCJpYXQiOjE2ODcyODExOTUsImV4cCI6MTY4NzI4ODM5NX0.OTuPik6p3o9j6VOx-uCyxRvHwoh1pDiiZcBQFNQt2uE3dK-8izGNflJVETi_uhGSZOf25Enkq-UvEin9NrbJNw";
6
+ const rp = new _.RelyingPartySolution("http://rp.example", walletInstanceAttestation);
7
+ describe("decodeAuthRequestQR", () => {
8
+ it("should return authentication request URL", async () => {
9
+ const qrcode = "ZXVkaXc6Ly9hdXRob3JpemU/Y2xpZW50X2lkPWh0dHBzOi8vdmVyaWZpZXIuZXhhbXBsZS5vcmcmcmVxdWVzdF91cmk9aHR0cHM6Ly92ZXJpZmllci5leGFtcGxlLm9yZy9yZXF1ZXN0X3VyaQ==";
10
+ const result = rp.decodeAuthRequestQR(qrcode);
11
+ expect(result).toEqual("https://verifier.example.org/request_uri");
12
+ });
13
+ it("should throw exception with invalid QR", async () => {
14
+ const qrcode = "aHR0cDovL2dvb2dsZS5pdA==";
15
+ expect(() => rp.decodeAuthRequestQR(qrcode)).toThrowError(_errors.AuthRequestDecodeError);
16
+ });
17
+ });
18
+ //# sourceMappingURL=index.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_","require","_errors","walletInstanceAttestation","rp","RelyingPartySolution","describe","it","qrcode","result","decodeAuthRequestQR","expect","toEqual","toThrowError","AuthRequestDecodeError"],"sourceRoot":"../../../../src","sources":["rp/__test__/index.test.ts"],"mappings":";;AAAA,IAAAA,CAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEA,MAAME,yBAAyB,GAC7B,qhDAAqhD;AACvhD,MAAMC,EAAE,GAAG,IAAIC,sBAAoB,CACjC,mBAAmB,EACnBF,yBACF,CAAC;AACDG,QAAQ,CAAC,qBAAqB,EAAE,MAAM;EACpCC,EAAE,CAAC,0CAA0C,EAAE,YAAY;IACzD,MAAMC,MAAM,GACV,sJAAsJ;IACxJ,MAAMC,MAAM,GAAGL,EAAE,CAACM,mBAAmB,CAACF,MAAM,CAAC;IAC7CG,MAAM,CAACF,MAAM,CAAC,CAACG,OAAO,CAAC,0CAA0C,CAAC;EACpE,CAAC,CAAC;EACFL,EAAE,CAAC,wCAAwC,EAAE,YAAY;IACvD,MAAMC,MAAM,GAAG,0BAA0B;IACzCG,MAAM,CAAC,MAAMP,EAAE,CAACM,mBAAmB,CAACF,MAAM,CAAC,CAAC,CAACK,YAAY,CACvDC,8BACF,CAAC;EACH,CAAC,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.RelyingPartySolution = void 0;
7
+ var _errors = require("../utils/errors");
8
+ var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
9
+ var _types = require("./types");
10
+ var _reactNativeUuid = _interopRequireDefault(require("react-native-uuid"));
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ class RelyingPartySolution {
13
+ constructor(relyingPartyBaseUrl, walletInstanceAttestation) {
14
+ let appFetch = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : fetch;
15
+ this.relyingPartyBaseUrl = relyingPartyBaseUrl;
16
+ this.walletInstanceAttestation = walletInstanceAttestation;
17
+ this.appFetch = appFetch;
18
+ }
19
+
20
+ /**
21
+ * Decode a QR code content to an authentication request url.
22
+ * @function
23
+ * @param qrcode QR code content
24
+ *
25
+ * @returns The authentication request url
26
+ *
27
+ */
28
+ decodeAuthRequestQR(qrcode) {
29
+ try {
30
+ const decoded = (0, _ioReactNativeJwt.decodeBase64)(qrcode);
31
+ const decodedUrl = new URL(decoded);
32
+ const requestUri = decodedUrl.searchParams.get("request_uri");
33
+ if (requestUri) {
34
+ return requestUri;
35
+ } else {
36
+ throw new _errors.AuthRequestDecodeError("Unable to obtain request_uri from QR code", `${decodedUrl}`);
37
+ }
38
+ } catch {
39
+ throw new _errors.AuthRequestDecodeError("Unable to decode QR code authentication request url", qrcode);
40
+ }
41
+ }
42
+ /**
43
+ * Obtain the unsigned wallet instance DPoP for authentication request
44
+ *
45
+ * @function
46
+ * @param walletInstanceAttestationJwk JWT of the Wallet Instance Attestation
47
+ * @param authRequestUrl authentication request url
48
+ *
49
+ * @returns The unsigned wallet instance DPoP
50
+ *
51
+ */
52
+ async getUnsignedWalletInstanceDPoP(walletInstanceAttestationJwk, authRequestUrl) {
53
+ return await new _ioReactNativeJwt.SignJWT({
54
+ jti: `${_reactNativeUuid.default.v4()}`,
55
+ htm: "GET",
56
+ htu: authRequestUrl,
57
+ ath: await (0, _ioReactNativeJwt.sha256ToBase64)(this.walletInstanceAttestation)
58
+ }).setProtectedHeader({
59
+ alg: "ES256",
60
+ jwk: walletInstanceAttestationJwk,
61
+ typ: "dpop+jwt"
62
+ }).setIssuedAt().setExpirationTime("1h").toSign();
63
+ }
64
+
65
+ /**
66
+ * Obtain the Request Object for RP authentication
67
+ *
68
+ * @function
69
+ * @param signedWalletInstanceDPoP JWT of the Wallet Instance Attestation DPoP
70
+ *
71
+ * @returns The Request Object JWT
72
+ *
73
+ */
74
+ async getRequestObject(signedWalletInstanceDPoP) {
75
+ const decodedJwtDPop = await (0, _ioReactNativeJwt.decode)(signedWalletInstanceDPoP);
76
+ const requestUri = decodedJwtDPop.payload.htu;
77
+ const response = await this.appFetch(requestUri, {
78
+ method: "GET",
79
+ headers: {
80
+ Authorization: `DPoP ${this.walletInstanceAttestation}`,
81
+ DPoP: signedWalletInstanceDPoP
82
+ }
83
+ });
84
+ if (response.status === 200) {
85
+ const responseText = await response.text();
86
+ const responseJwt = await (0, _ioReactNativeJwt.decode)(responseText);
87
+ const requestObj = _types.RequestObject.parse({
88
+ header: responseJwt.protectedHeader,
89
+ payload: responseJwt.payload
90
+ });
91
+ return requestObj;
92
+ }
93
+ throw new _errors.IoWalletError(`Unable to obtain Request Object. Response code: ${response.status}`);
94
+ }
95
+
96
+ /**
97
+ * Obtain the relying party entity configuration.
98
+ */
99
+ async getEntityConfiguration() {
100
+ const wellKnownUrl = new URL("/.well-known/openid-federation", this.relyingPartyBaseUrl).href;
101
+ const response = await this.appFetch(wellKnownUrl, {
102
+ method: "GET"
103
+ });
104
+ if (response.status === 200) {
105
+ const responseText = await response.text();
106
+ const responseJwt = await (0, _ioReactNativeJwt.decode)(responseText);
107
+ return _types.RpEntityConfiguration.parse({
108
+ header: responseJwt.protectedHeader,
109
+ payload: responseJwt.payload
110
+ });
111
+ }
112
+ throw new _errors.IoWalletError(`Unable to obtain RP Entity Configuration. Response code: ${response.status}`);
113
+ }
114
+ }
115
+ exports.RelyingPartySolution = RelyingPartySolution;
116
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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","requestUri","searchParams","get","AuthRequestDecodeError","getUnsignedWalletInstanceDPoP","walletInstanceAttestationJwk","authRequestUrl","SignJWT","jti","uuid","v4","htm","htu","ath","sha256ToBase64","setProtectedHeader","alg","jwk","typ","setIssuedAt","setExpirationTime","toSign","getRequestObject","signedWalletInstanceDPoP","decodedJwtDPop","decodeJwt","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,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAG9B,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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,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,CAAA7D,oBAAA,GAAAA,oBAAA"}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.RpEntityConfiguration = exports.RequestObject = void 0;
7
+ var _jwk = require("../utils/jwk");
8
+ var _types = require("../sd-jwt/types");
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 RequestObject = z.object({
13
+ header: z.object({
14
+ typ: z.literal("JWT"),
15
+ alg: z.string(),
16
+ kid: z.string(),
17
+ trust_chain: z.array(z.string())
18
+ }),
19
+ payload: z.object({
20
+ iss: z.string(),
21
+ iat: _types.UnixTime,
22
+ exp: _types.UnixTime,
23
+ state: z.string(),
24
+ nonce: z.string(),
25
+ response_uri: z.string(),
26
+ response_type: z.literal("vp_token"),
27
+ response_mode: z.literal("direct_post.jwt"),
28
+ client_id: z.string(),
29
+ client_id_scheme: z.literal("entity_id"),
30
+ scope: z.string()
31
+ })
32
+ });
33
+
34
+ // TODO: This types is WIP in technical rules
35
+ exports.RequestObject = RequestObject;
36
+ const RpEntityConfiguration = z.object({
37
+ header: z.object({
38
+ typ: z.literal("entity-statement+jwt"),
39
+ alg: z.string(),
40
+ kid: z.string()
41
+ }),
42
+ payload: z.object({
43
+ exp: _types.UnixTime,
44
+ iat: _types.UnixTime,
45
+ iss: z.string(),
46
+ sub: z.string(),
47
+ jwks: z.object({
48
+ keys: z.array(_jwk.JWK)
49
+ }),
50
+ metadata: z.object({
51
+ wallet_relying_party: z.object({
52
+ application_type: z.string(),
53
+ client_id: z.string(),
54
+ client_name: z.string(),
55
+ jwks: z.object({
56
+ keys: z.array(_jwk.JWK)
57
+ }),
58
+ contacts: z.array(z.string())
59
+ }),
60
+ federation_entity: z.object({
61
+ organization_name: z.string(),
62
+ homepage_uri: z.string(),
63
+ policy_uri: z.string(),
64
+ logo_uri: z.string(),
65
+ contacts: z.array(z.string())
66
+ })
67
+ }),
68
+ authority_hints: z.array(z.string())
69
+ })
70
+ });
71
+ exports.RpEntityConfiguration = RpEntityConfiguration;
72
+ //# sourceMappingURL=types.js.map
@@ -0,0 +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"],"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,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,K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8B,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"}
@@ -25,7 +25,7 @@ const SdJwt4VC = _zod.z.object({
25
25
  header: _zod.z.object({
26
26
  typ: _zod.z.literal("vc+sd-jwt"),
27
27
  alg: _zod.z.string(),
28
- kid: _zod.z.string(),
28
+ kid: _zod.z.string().optional(),
29
29
  trust_chain: _zod.z.array(_zod.z.string())
30
30
  }),
31
31
  payload: _zod.z.object({
@@ -1 +1 @@
1
- {"version":3,"names":["_jwk","require","_zod","UnixTime","z","number","min","max","exports","ObfuscatedDisclosures","object","_sd","array","string","Disclosure","tuple","unknown","SdJwt4VC","header","typ","literal","alg","kid","trust_chain","payload","iss","sub","jti","iat","exp","status","cnf","jwk","JWK","type","verified_claims","verification","intersection","trust_framework","assurance_level","claims","_sd_alg"],"sourceRoot":"../../../src","sources":["sd-jwt/types.ts"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AAEO,MAAME,QAAQ,GAAGC,MAAC,CAACC,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAAC,CAACC,GAAG,CAAC,aAAa,CAAC;AAACC,OAAA,CAAAL,QAAA,GAAAA,QAAA;AAItD,MAAMM,qBAAqB,GAAGL,MAAC,CAACM,MAAM,CAAC;EAAEC,GAAG,EAAEP,MAAC,CAACQ,KAAK,CAACR,MAAC,CAACS,MAAM,CAAC,CAAC;AAAE,CAAC,CAAC;;AAE3E;AACA;AACA;AACA;AACA;AACA;AALAL,OAAA,CAAAC,qBAAA,GAAAA,qBAAA;A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,EAAEnC,MAAC,CAACS,MAAM,CAAC;MAC5B,CAAC,CAAC,EACFJ,qBACF,CAAC;MACD+B,MAAM,EAAE/B;IACV,CAAC,CAAC;IACFgC,OAAO,EAAErC,MAAC,CAACgB,OAAO,CAAC,SAAS;EAC9B,CAAC;AACH,CAAC,CAAC;AAACZ,OAAA,CAAAS,QAAA,GAAAA,QAAA"}
1
+ {"version":3,"names":["_jwk","require","_zod","UnixTime","z","number","min","max","exports","ObfuscatedDisclosures","object","_sd","array","string","Disclosure","tuple","unknown","SdJwt4VC","header","typ","literal","alg","kid","optional","trust_chain","payload","iss","sub","jti","iat","exp","status","cnf","jwk","JWK","type","verified_claims","verification","intersection","trust_framework","assurance_level","claims","_sd_alg"],"sourceRoot":"../../../src","sources":["sd-jwt/types.ts"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AAEO,MAAME,QAAQ,GAAGC,MAAC,CAACC,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAAC,CAACC,GAAG,CAAC,aAAa,CAAC;AAACC,OAAA,CAAAL,QAAA,GAAAA,QAAA;AAItD,MAAMM,qBAAqB,GAAGL,MAAC,CAACM,MAAM,CAAC;EAAEC,GAAG,EAAEP,MAAC,CAACQ,KAAK,CAACR,MAAC,CAACS,MAAM,CAAC,CAAC;AAAE,CAAC,CAAC;;AAE3E;AACA;AACA;AACA;AACA;AACA;AALAL,OAAA,CAAAC,qBAAA,GAAAA,qBAAA;AAOO,MAAMK,UAAU,GAAGV,MAAC,CAACW,KAAK,CAAC,CAChC,UAAWX,MAAC,CAACS,MAAM,CAAC,CAAC,EACrB,gBAAiBT,MAAC,CAACS,MAAM,CAAC,CAAC,EAC3B,iBAAkBT,MAAC,CAACY,OAAO,CAAC,CAAC,CAC9B,CAAC;AAACR,OAAA,CAAAM,UAAA,GAAAA,UAAA;AAGI,MAAMG,QAAQ,GAAGb,MAAC,CAACM,MAAM,CAAC;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 "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getUnsignedDPop = exports.DPoPPayload = void 0;
7
+ var z = _interopRequireWildcard(require("zod"));
8
+ var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
9
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
10
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
11
+ const getUnsignedDPop = (jwk, payload) => {
12
+ const dPop = new _ioReactNativeJwt.SignJWT(payload).setProtectedHeader({
13
+ alg: "ES256",
14
+ typ: "dpop+jwt",
15
+ jwk
16
+ }).setIssuedAt().setExpirationTime("1h").toSign();
17
+ return dPop;
18
+ };
19
+ exports.getUnsignedDPop = getUnsignedDPop;
20
+ const DPoPPayload = z.object({
21
+ jti: z.string(),
22
+ htm: z.union([z.literal("POST"), z.literal("GET")]),
23
+ htu: z.string(),
24
+ ath: z.string().optional()
25
+ });
26
+ exports.DPoPPayload = DPoPPayload;
27
+ //# sourceMappingURL=dpop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["z","_interopRequireWildcard","require","_ioReactNativeJwt","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","getUnsignedDPop","jwk","payload","dPop","SignJWT","setProtectedHeader","alg","typ","setIssuedAt","setExpirationTime","toSign","exports","DPoPPayload","object","jti","string","htm","union","literal","htu","ath","optional"],"sourceRoot":"../../../src","sources":["utils/dpop.ts"],"mappings":";;;;;;AAAA,IAAAA,CAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAD,OAAA;AAAsD,SAAAE,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,SAAAJ,wBAAAQ,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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