@pagopa/io-react-native-wallet 0.7.2 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/commonjs/pid/issuing.js +4 -11
- package/lib/commonjs/pid/issuing.js.map +1 -1
- package/lib/commonjs/utils/crypto.js +26 -1
- package/lib/commonjs/utils/crypto.js.map +1 -1
- package/lib/module/pid/issuing.js +5 -12
- package/lib/module/pid/issuing.js.map +1 -1
- package/lib/module/utils/crypto.js +24 -1
- package/lib/module/utils/crypto.js.map +1 -1
- package/lib/typescript/pid/issuing.d.ts.map +1 -1
- package/lib/typescript/utils/crypto.d.ts +9 -0
- package/lib/typescript/utils/crypto.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/pid/issuing.ts +16 -22
- package/src/utils/crypto.ts +31 -1
@@ -10,7 +10,6 @@ var _reactNativeUuid = _interopRequireDefault(require("react-native-uuid"));
|
|
10
10
|
var _errors = require("../utils/errors");
|
11
11
|
var _dpop = require("../utils/dpop");
|
12
12
|
var WalletInstanceAttestation = _interopRequireWildcard(require("../wallet-instance-attestation"));
|
13
|
-
var _ioReactNativeCrypto = require("@pagopa/io-react-native-crypto");
|
14
13
|
var _2 = require(".");
|
15
14
|
var _crypto = require("../utils/crypto");
|
16
15
|
var z = _interopRequireWildcard(require("zod"));
|
@@ -156,17 +155,11 @@ const authorizeIssuing = _ref3 => {
|
|
156
155
|
})(clientId, codeVerifier, walletProviderBaseUrl, pidProviderEntityConfiguration, walletInstanceAttestation);
|
157
156
|
const authenticationRequest = await getAuthenticationRequest({})(clientId, requestUri, pidProviderEntityConfiguration, cieData);
|
158
157
|
const authorizationCode = authenticationRequest.code;
|
159
|
-
|
160
|
-
// Use an ephemeral key to be destroyed after use
|
161
|
-
const keytag = `ephemeral-${_reactNativeUuid.default.v4()}`;
|
162
|
-
await (0, _ioReactNativeCrypto.generate)(keytag);
|
163
|
-
const ephemeralContext = (0, _crypto.createCryptoContextFor)(keytag);
|
164
|
-
const signedDPop = await (0, _dpop.createDPopToken)({
|
158
|
+
const signedDPop = await (0, _crypto.useEphemeralKey)(ctx => (0, _dpop.createDPopToken)({
|
165
159
|
htm: "POST",
|
166
160
|
htu: tokenUrl,
|
167
161
|
jti: `${_reactNativeUuid.default.v4()}`
|
168
|
-
},
|
169
|
-
await (0, _ioReactNativeCrypto.deleteKey)(keytag);
|
162
|
+
}, ctx));
|
170
163
|
const requestBody = {
|
171
164
|
grant_type: "authorization code",
|
172
165
|
client_id: clientId,
|
@@ -236,13 +229,13 @@ const getCredential = _ref4 => {
|
|
236
229
|
clientId,
|
237
230
|
walletProviderBaseUrl
|
238
231
|
} = _ref5;
|
232
|
+
const credentialUrl = pidProviderEntityConfiguration.payload.metadata.openid_credential_issuer.credential_endpoint;
|
239
233
|
const signedDPopForPid = await (0, _dpop.createDPopToken)({
|
240
234
|
htm: "POST",
|
241
|
-
htu:
|
235
|
+
htu: credentialUrl,
|
242
236
|
jti: `${_reactNativeUuid.default.v4()}`
|
243
237
|
}, pidCryptoContext);
|
244
238
|
const signedNonceProof = await createNonceProof(nonce, clientId, walletProviderBaseUrl, pidCryptoContext);
|
245
|
-
const credentialUrl = pidProviderEntityConfiguration.payload.metadata.openid_credential_issuer.credential_endpoint;
|
246
239
|
const requestBody = {
|
247
240
|
credential_definition: JSON.stringify({
|
248
241
|
type: ["PersonIdentificationData"]
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_ioReactNativeJwt","require","_jwk","_reactNativeUuid","_interopRequireDefault","_errors","_dpop","WalletInstanceAttestation","_interopRequireWildcard","_ioReactNativeCrypto","_2","_crypto","z","_decoder","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","AuthenticationRequestResponse","object","code","string","state","iss","assertionType","getPar","_ref","wiaCryptoContext","appFetch","fetch","clientId","codeVerifier","walletProviderBaseUrl","pidProviderEntityConfiguration","walletInstanceAttestation","keyThumbprint","getPublicKey","then","JWK","parse","thumbprint","decode","payload","cnf","jwk","kid","codeChallenge","sha256ToBase64","signedJwtForPar","SignJWT","setProtectedHeader","setPayload","aud","jti","uuid","v4","client_assertion_type","authorization_details","credential_definition","type","format","response_type","code_challenge_method","redirect_uri","client_id","code_challenge","setIssuedAt","setExpirationTime","sign","parUrl","metadata","openid_credential_issuer","pushed_authorization_request_endpoint","requestBody","client_assertion","request","formBody","URLSearchParams","response","method","headers","body","toString","status","result","json","request_uri","PidIssuingError","text","getAuthenticationRequest","_ref2","requestUri","cieData","authzRequestEndpoint","authorization_endpoint","params","name","surname","birth_date","birthDate","fiscal_code","fiscalCode","formData","decodedJwt","getJwtFromFormPost","parsed","authorizeIssuing","_ref3","_","tokenUrl","token_endpoint","authenticationRequest","authorizationCode","keytag","generate","ephemeralContext","createCryptoContextFor","signedDPop","createDPopToken","htm","htu","deleteKey","grant_type","code_verifier","DPoP","c_nonce","access_token","accessToken","nonce","exports","createNonceProof","issuer","audience","ctx","setAudience","setIssuer","getCredential","_ref4","pidCryptoContext","_ref5","signedDPopForPid","signedNonceProof","credentialUrl","credential_endpoint","JSON","stringify","proof","jwt","proof_type","Authorization","pidResponse","validatePid","credential","pidJwt","decoded","SdJwt","pidKey","holderBindedKey","sdJwt"],"sourceRoot":"../../../src","sources":["pid/issuing.ts"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAOA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAEA,IAAAM,yBAAA,GAAAC,uBAAA,CAAAP,OAAA;AACA,IAAAQ,oBAAA,GAAAR,OAAA;AACA,IAAAS,EAAA,GAAAT,OAAA;AACA,IAAAU,OAAA,GAAAV,OAAA;AAEA,IAAAW,CAAA,GAAAJ,uBAAA,CAAAP,OAAA;AACA,IAA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F,CAAC"}
|
1
|
+
{"version":3,"names":["_ioReactNativeJwt","require","_jwk","_reactNativeUuid","_interopRequireDefault","_errors","_dpop","WalletInstanceAttestation","_interopRequireWildcard","_2","_crypto","z","_decoder","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","AuthenticationRequestResponse","object","code","string","state","iss","assertionType","getPar","_ref","wiaCryptoContext","appFetch","fetch","clientId","codeVerifier","walletProviderBaseUrl","pidProviderEntityConfiguration","walletInstanceAttestation","keyThumbprint","getPublicKey","then","JWK","parse","thumbprint","decode","payload","cnf","jwk","kid","codeChallenge","sha256ToBase64","signedJwtForPar","SignJWT","setProtectedHeader","setPayload","aud","jti","uuid","v4","client_assertion_type","authorization_details","credential_definition","type","format","response_type","code_challenge_method","redirect_uri","client_id","code_challenge","setIssuedAt","setExpirationTime","sign","parUrl","metadata","openid_credential_issuer","pushed_authorization_request_endpoint","requestBody","client_assertion","request","formBody","URLSearchParams","response","method","headers","body","toString","status","result","json","request_uri","PidIssuingError","text","getAuthenticationRequest","_ref2","requestUri","cieData","authzRequestEndpoint","authorization_endpoint","params","name","surname","birth_date","birthDate","fiscal_code","fiscalCode","formData","decodedJwt","getJwtFromFormPost","parsed","authorizeIssuing","_ref3","_","tokenUrl","token_endpoint","authenticationRequest","authorizationCode","signedDPop","useEphemeralKey","ctx","createDPopToken","htm","htu","grant_type","code_verifier","DPoP","c_nonce","access_token","accessToken","nonce","exports","createNonceProof","issuer","audience","setAudience","setIssuer","getCredential","_ref4","pidCryptoContext","_ref5","credentialUrl","credential_endpoint","signedDPopForPid","signedNonceProof","JSON","stringify","proof","jwt","proof_type","Authorization","pidResponse","validatePid","credential","pidJwt","decoded","SdJwt","pidKey","holderBindedKey","sdJwt"],"sourceRoot":"../../../src","sources":["pid/issuing.ts"],"mappings":";;;;;;AAA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AAS,CACnHW,MACF,CAAE,kCAAiCZ,IAAI,CAACC,SAAS,CAACY,eAAe,CAAE,EACrE,CAAC;EACH;AACF,CAAC"}
|
@@ -3,10 +3,12 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.createCryptoContextFor = void 0;
|
6
|
+
exports.useEphemeralKey = exports.createCryptoContextFor = void 0;
|
7
7
|
var _ioReactNativeCrypto = require("@pagopa/io-react-native-crypto");
|
8
|
+
var _reactNativeUuid = _interopRequireDefault(require("react-native-uuid"));
|
8
9
|
var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
|
9
10
|
var _jwk = require("./jwk");
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
10
12
|
/**
|
11
13
|
* Create a CryptoContext bound to a key pair.
|
12
14
|
* Key pair is supposed to exist already in the device's keychain.
|
@@ -42,5 +44,28 @@ const createCryptoContextFor = keytag => {
|
|
42
44
|
}
|
43
45
|
};
|
44
46
|
};
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Executes the input function injecting an ephemeral crypto context.
|
50
|
+
* An ephemeral crypto context is a context which is bound to a key
|
51
|
+
* that is just created and is deleted after use.
|
52
|
+
*
|
53
|
+
* @param fn The procedure to be executed
|
54
|
+
* @returns The returned value of the input procedure.
|
55
|
+
*/
|
45
56
|
exports.createCryptoContextFor = createCryptoContextFor;
|
57
|
+
const useEphemeralKey = async fn => {
|
58
|
+
// Use an ephemeral key to be destroyed after use
|
59
|
+
const keytag = `ephemeral-${_reactNativeUuid.default.v4()}`;
|
60
|
+
await (0, _ioReactNativeCrypto.generate)(keytag);
|
61
|
+
const ephemeralContext = createCryptoContextFor(keytag);
|
62
|
+
try {
|
63
|
+
return fn(ephemeralContext);
|
64
|
+
} catch (error) {
|
65
|
+
throw error;
|
66
|
+
} finally {
|
67
|
+
await (0, _ioReactNativeCrypto.deleteKey)(keytag);
|
68
|
+
}
|
69
|
+
};
|
70
|
+
exports.useEphemeralKey = useEphemeralKey;
|
46
71
|
//# sourceMappingURL=crypto.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_ioReactNativeCrypto","require","_ioReactNativeJwt","_jwk","createCryptoContextFor","keytag","getPublicKey","then","fixBase64EncodingOnKey","jwk","kid","thumbprint","getSignature","value","sign","exports"],"sourceRoot":"../../../src","sources":["utils/crypto.ts"],"mappings":";;;;;;AAAA,IAAAA,oBAAA,GAAAC,OAAA;
|
1
|
+
{"version":3,"names":["_ioReactNativeCrypto","require","_reactNativeUuid","_interopRequireDefault","_ioReactNativeJwt","_jwk","obj","__esModule","default","createCryptoContextFor","keytag","getPublicKey","then","fixBase64EncodingOnKey","jwk","kid","thumbprint","getSignature","value","sign","exports","useEphemeralKey","fn","uuid","v4","generate","ephemeralContext","error","deleteKey"],"sourceRoot":"../../../src","sources":["utils/crypto.ts"],"mappings":";;;;;;AAAA,IAAAA,oBAAA,GAAAC,OAAA;AAMA,IAAAC,gBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AACA,IAAAI,IAAA,GAAAJ,OAAA;AAA+C,SAAAE,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,sBAAsB,GAAIC,MAAc,IAAoB;EACvE,OAAO;IACL;AACJ;AACA;AACA;AACA;IACI,MAAMC,YAAYA,CAAA,EAAG;MACnB,OAAO,IAAAA,iCAAY,EAACD,MAAM,CAAC,CACxBE,IAAI,CAACC,2BAAsB,CAAC,CAC5BD,IAAI,CAAC,MAAOE,GAAG,KAAM;QACpB,GAAGA,GAAG;QACN;QACA;QACA;QACA;QACAC,GAAG,EAAE,MAAM,IAAAC,4BAAU,EAACF,GAAG;MAC3B,CAAC,CAAC,CAAC;IACP,CAAC;IACD;AACJ;AACA;AACA;AACA;AACA;IACI,MAAMG,YAAYA,CAACC,KAAa,EAAE;MAChC,OAAO,IAAAC,yBAAI,EAACD,KAAK,EAAER,MAAM,CAAC;IAC5B;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPAU,OAAA,CAAAX,sBAAA,GAAAA,sBAAA;AAQO,MAAMY,eAAe,GAAG,MAC7BC,EAAmD,IACpC;EACf;EACA,MAAMZ,MAAM,GAAI,aAAYa,wBAAI,CAACC,EAAE,CAAC,CAAE,EAAC;EACvC,MAAM,IAAAC,6BAAQ,EAACf,MAAM,CAAC;EACtB,MAAMgB,gBAAgB,GAAGjB,sBAAsB,CAACC,MAAM,CAAC;EACvD,IAAI;IACF,OAAOY,EAAE,CAACI,gBAAgB,CAAC;EAC7B,CAAC,CAAC,OAAOC,KAAK,EAAE;IACd,MAAMA,KAAK;EACb,CAAC,SAAS;IACR,MAAM,IAAAC,8BAAS,EAAClB,MAAM,CAAC;EACzB;AACF,CAAC;AAACU,OAAA,CAAAC,eAAA,GAAAA,eAAA"}
|
@@ -4,9 +4,8 @@ import uuid from "react-native-uuid";
|
|
4
4
|
import { PidIssuingError } from "../utils/errors";
|
5
5
|
import { createDPopToken } from "../utils/dpop";
|
6
6
|
import * as WalletInstanceAttestation from "../wallet-instance-attestation";
|
7
|
-
import { generate, deleteKey } from "@pagopa/io-react-native-crypto";
|
8
7
|
import { SdJwt } from ".";
|
9
|
-
import {
|
8
|
+
import { useEphemeralKey } from "../utils/crypto";
|
10
9
|
import * as z from "zod";
|
11
10
|
import { getJwtFromFormPost } from "../utils/decoder";
|
12
11
|
|
@@ -148,17 +147,11 @@ export const authorizeIssuing = _ref3 => {
|
|
148
147
|
})(clientId, codeVerifier, walletProviderBaseUrl, pidProviderEntityConfiguration, walletInstanceAttestation);
|
149
148
|
const authenticationRequest = await getAuthenticationRequest({})(clientId, requestUri, pidProviderEntityConfiguration, cieData);
|
150
149
|
const authorizationCode = authenticationRequest.code;
|
151
|
-
|
152
|
-
// Use an ephemeral key to be destroyed after use
|
153
|
-
const keytag = `ephemeral-${uuid.v4()}`;
|
154
|
-
await generate(keytag);
|
155
|
-
const ephemeralContext = createCryptoContextFor(keytag);
|
156
|
-
const signedDPop = await createDPopToken({
|
150
|
+
const signedDPop = await useEphemeralKey(ctx => createDPopToken({
|
157
151
|
htm: "POST",
|
158
152
|
htu: tokenUrl,
|
159
153
|
jti: `${uuid.v4()}`
|
160
|
-
},
|
161
|
-
await deleteKey(keytag);
|
154
|
+
}, ctx));
|
162
155
|
const requestBody = {
|
163
156
|
grant_type: "authorization code",
|
164
157
|
client_id: clientId,
|
@@ -227,13 +220,13 @@ export const getCredential = _ref4 => {
|
|
227
220
|
clientId,
|
228
221
|
walletProviderBaseUrl
|
229
222
|
} = _ref5;
|
223
|
+
const credentialUrl = pidProviderEntityConfiguration.payload.metadata.openid_credential_issuer.credential_endpoint;
|
230
224
|
const signedDPopForPid = await createDPopToken({
|
231
225
|
htm: "POST",
|
232
|
-
htu:
|
226
|
+
htu: credentialUrl,
|
233
227
|
jti: `${uuid.v4()}`
|
234
228
|
}, pidCryptoContext);
|
235
229
|
const signedNonceProof = await createNonceProof(nonce, clientId, walletProviderBaseUrl, pidCryptoContext);
|
236
|
-
const credentialUrl = pidProviderEntityConfiguration.payload.metadata.openid_credential_issuer.credential_endpoint;
|
237
230
|
const requestBody = {
|
238
231
|
credential_definition: JSON.stringify({
|
239
232
|
type: ["PersonIdentificationData"]
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["sha256ToBase64","SignJWT","thumbprint","JWK","uuid","PidIssuingError","createDPopToken","WalletInstanceAttestation","
|
1
|
+
{"version":3,"names":["sha256ToBase64","SignJWT","thumbprint","JWK","uuid","PidIssuingError","createDPopToken","WalletInstanceAttestation","SdJwt","useEphemeralKey","z","getJwtFromFormPost","AuthenticationRequestResponse","object","code","string","state","iss","assertionType","getPar","_ref","wiaCryptoContext","appFetch","fetch","clientId","codeVerifier","walletProviderBaseUrl","pidProviderEntityConfiguration","walletInstanceAttestation","keyThumbprint","getPublicKey","then","parse","decode","payload","cnf","jwk","kid","codeChallenge","signedJwtForPar","setProtectedHeader","setPayload","aud","jti","v4","client_assertion_type","authorization_details","credential_definition","type","format","response_type","code_challenge_method","redirect_uri","client_id","code_challenge","setIssuedAt","setExpirationTime","sign","parUrl","metadata","openid_credential_issuer","pushed_authorization_request_endpoint","requestBody","client_assertion","request","formBody","URLSearchParams","response","method","headers","body","toString","status","result","json","request_uri","text","getAuthenticationRequest","_ref2","requestUri","cieData","authzRequestEndpoint","authorization_endpoint","params","name","surname","birth_date","birthDate","fiscal_code","fiscalCode","formData","decodedJwt","parsed","authorizeIssuing","_ref3","_","tokenUrl","token_endpoint","authenticationRequest","authorizationCode","signedDPop","ctx","htm","htu","grant_type","code_verifier","DPoP","c_nonce","access_token","accessToken","nonce","createNonceProof","issuer","audience","setAudience","setIssuer","getCredential","_ref4","pidCryptoContext","_ref5","credentialUrl","credential_endpoint","signedDPopForPid","signedNonceProof","JSON","stringify","proof","jwt","proof_type","Authorization","pidResponse","validatePid","credential","pidJwt","decoded","pidKey","holderBindedKey","sdJwt"],"sourceRoot":"../../../src","sources":["pid/issuing.ts"],"mappings":"AAAA,SACEA,cAAc,EAEdC,OAAO,EACPC,UAAU,QACL,6BAA6B;AAEpC,SAASC,GAAG,QAAQ,cAAc;AAClC,OAAOC,IAAI,MAAM,mBAAmB;AACpC,SAASC,eAAe,QAAQ,iBAAiB;AACjD,SAASC,eAAe,QAAQ,eAAe;AAE/C,OAAO,KAAKC,yBAAyB,MAAM,gCAAgC;AAC3E,SAASC,KAAK,QAAQ,GAAG;AACzB,SAASC,eAAe,QAAQ,iBAAiB;AAEjD,OAAO,KAAKC,CAAC,MAAM,KAAK;AACxB,SAASC,kBAAkB,QAAQ,kBAAkB;;AAErD;;AA2BA,MAAMC,6BAA6B,GAAGF,CAAC,CAACG,MAAM,CAAC;EAC7CC,IAA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AC,CAAiB;MAC1D,MAAMyD,WAAW,CAACD,WAAW,CAACE,UAAU,EAAEd,gBAAgB,CAAC;MAC3D,OAAOY,WAAW;IACpB;IAEA,MAAM,IAAI7H,eAAe,CACtB,oCAAmCmH,aAAc,WAChDrD,QAAQ,CAACK,MACV,SAAQ,MAAML,QAAQ,CAACS,IAAI,CAAC,CAAE,EACjC,CAAC;EACH,CAAC;AAAA;AAEH,MAAMuD,WAAW,GAAG,MAAAA,CAAOE,MAAc,EAAEf,gBAA+B,KAAK;EAC7E,MAAMgB,OAAO,GAAG9H,KAAK,CAACyB,MAAM,CAACoG,MAAM,CAAC;EACpC,MAAME,MAAM,GAAG,MAAMjB,gBAAgB,CAACxF,YAAY,CAAC,CAAC;EACpD,MAAM0G,eAAe,GAAGF,OAAO,CAACG,KAAK,CAACvG,OAAO,CAACC,GAAG,CAACC,GAAG;EAErD,IAAI,CAAC,MAAMlC,UAAU,CAACqI,MAAM,CAAC,OAAO,MAAMrI,UAAU,CAACsI,eAAe,CAAC,CAAC,EAAE;IACtE,MAAM,IAAInI,eAAe,CACtB,uGAAsGuH,IAAI,CAACC,SAAS,CACnHU,MACF,CAAE,kCAAiCX,IAAI,CAACC,SAAS,CAACW,eAAe,CAAE,EACrE,CAAC;EACH;AACF,CAAC"}
|
@@ -1,4 +1,5 @@
|
|
1
|
-
import { getPublicKey, sign } from "@pagopa/io-react-native-crypto";
|
1
|
+
import { getPublicKey, sign, generate, deleteKey } from "@pagopa/io-react-native-crypto";
|
2
|
+
import uuid from "react-native-uuid";
|
2
3
|
import { thumbprint } from "@pagopa/io-react-native-jwt";
|
3
4
|
import { fixBase64EncodingOnKey } from "./jwk";
|
4
5
|
|
@@ -37,4 +38,26 @@ export const createCryptoContextFor = keytag => {
|
|
37
38
|
}
|
38
39
|
};
|
39
40
|
};
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Executes the input function injecting an ephemeral crypto context.
|
44
|
+
* An ephemeral crypto context is a context which is bound to a key
|
45
|
+
* that is just created and is deleted after use.
|
46
|
+
*
|
47
|
+
* @param fn The procedure to be executed
|
48
|
+
* @returns The returned value of the input procedure.
|
49
|
+
*/
|
50
|
+
export const useEphemeralKey = async fn => {
|
51
|
+
// Use an ephemeral key to be destroyed after use
|
52
|
+
const keytag = `ephemeral-${uuid.v4()}`;
|
53
|
+
await generate(keytag);
|
54
|
+
const ephemeralContext = createCryptoContextFor(keytag);
|
55
|
+
try {
|
56
|
+
return fn(ephemeralContext);
|
57
|
+
} catch (error) {
|
58
|
+
throw error;
|
59
|
+
} finally {
|
60
|
+
await deleteKey(keytag);
|
61
|
+
}
|
62
|
+
};
|
40
63
|
//# sourceMappingURL=crypto.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["getPublicKey","sign","thumbprint","fixBase64EncodingOnKey","createCryptoContextFor","keytag","then","jwk","kid","getSignature","value"],"sourceRoot":"../../../src","sources":["utils/crypto.ts"],"mappings":"AAAA,
|
1
|
+
{"version":3,"names":["getPublicKey","sign","generate","deleteKey","uuid","thumbprint","fixBase64EncodingOnKey","createCryptoContextFor","keytag","then","jwk","kid","getSignature","value","useEphemeralKey","fn","v4","ephemeralContext","error"],"sourceRoot":"../../../src","sources":["utils/crypto.ts"],"mappings":"AAAA,SACEA,YAAY,EACZC,IAAI,EACJC,QAAQ,EACRC,SAAS,QACJ,gCAAgC;AACvC,OAAOC,IAAI,MAAM,mBAAmB;AACpC,SAASC,UAAU,QAA4B,6BAA6B;AAC5E,SAASC,sBAAsB,QAAQ,OAAO;;AAE9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,GAAIC,MAAc,IAAoB;EACvE,OAAO;IACL;AACJ;AACA;AACA;AACA;IACI,MAAMR,YAAYA,CAAA,EAAG;MACnB,OAAOA,YAAY,CAACQ,MAAM,CAAC,CACxBC,IAAI,CAACH,sBAAsB,CAAC,CAC5BG,IAAI,CAAC,MAAOC,GAAG,KAAM;QACpB,GAAGA,GAAG;QACN;QACA;QACA;QACA;QACAC,GAAG,EAAE,MAAMN,UAAU,CAACK,GAAG;MAC3B,CAAC,CAAC,CAAC;IACP,CAAC;IACD;AACJ;AACA;AACA;AACA;AACA;IACI,MAAME,YAAYA,CAACC,KAAa,EAAE;MAChC,OAAOZ,IAAI,CAACY,KAAK,EAAEL,MAAM,CAAC;IAC5B;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMM,eAAe,GAAG,MAC7BC,EAAmD,IACpC;EACf;EACA,MAAMP,MAAM,GAAI,aAAYJ,IAAI,CAACY,EAAE,CAAC,CAAE,EAAC;EACvC,MAAMd,QAAQ,CAACM,MAAM,CAAC;EACtB,MAAMS,gBAAgB,GAAGV,sBAAsB,CAACC,MAAM,CAAC;EACvD,IAAI;IACF,OAAOO,EAAE,CAACE,gBAAgB,CAAC;EAC7B,CAAC,CAAC,OAAOC,KAAK,EAAE;IACd,MAAMA,KAAK;EACb,CAAC,SAAS;IACR,MAAMf,SAAS,CAACK,MAAM,CAAC;EACzB;AACF,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"issuing.d.ts","sourceRoot":"","sources":["../../../src/pid/issuing.ts"],"names":[],"mappings":";AAAA,OAAO,EAEL,KAAK,aAAa,EAGnB,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EAAE,mCAAmC,EAAE,MAAM,gBAAgB,CAAC;
|
1
|
+
{"version":3,"file":"issuing.d.ts","sourceRoot":"","sources":["../../../src/pid/issuing.ts"],"names":[],"mappings":";AAAA,OAAO,EAEL,KAAK,aAAa,EAGnB,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EAAE,mCAAmC,EAAE,MAAM,gBAAgB,CAAC;AASrE,MAAM,MAAM,OAAO,GAAG;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,qBAAqB,EAAE,MAAM,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AA0JF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB;sBAKP,aAAa;;;;;kCAIJ,MAAM,yBACV,MAAM,kCACG,mCAAmC,WAC1D,OAAO,KACf,QAAQ,iBAAiB,CAwE3B,CAAC;AA0BJ;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa;sBAKJ,aAAa;;;;;gEAI0B,iBAAiB,kCAC1C,mCAAmC,KAClE,QAAQ,WAAW,CAsDrB,CAAC"}
|
@@ -7,4 +7,13 @@ import { type CryptoContext } from "@pagopa/io-react-native-jwt";
|
|
7
7
|
* @returns the crypto context
|
8
8
|
*/
|
9
9
|
export declare const createCryptoContextFor: (keytag: string) => CryptoContext;
|
10
|
+
/**
|
11
|
+
* Executes the input function injecting an ephemeral crypto context.
|
12
|
+
* An ephemeral crypto context is a context which is bound to a key
|
13
|
+
* that is just created and is deleted after use.
|
14
|
+
*
|
15
|
+
* @param fn The procedure to be executed
|
16
|
+
* @returns The returned value of the input procedure.
|
17
|
+
*/
|
18
|
+
export declare const useEphemeralKey: <R>(fn: (ephemeralContext: CryptoContext) => Promise<R>) => Promise<R>;
|
10
19
|
//# sourceMappingURL=crypto.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../../src/utils/crypto.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../../src/utils/crypto.ts"],"names":[],"mappings":"AAOA,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAG7E;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,WAAY,MAAM,KAAG,aA6BvD,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,6BACH,aAAa,8BAarC,CAAC"}
|
package/package.json
CHANGED
package/src/pid/issuing.ts
CHANGED
@@ -11,9 +11,8 @@ import { PidIssuingError } from "../utils/errors";
|
|
11
11
|
import { createDPopToken } from "../utils/dpop";
|
12
12
|
import { CredentialIssuerEntityConfiguration } from "../trust/types";
|
13
13
|
import * as WalletInstanceAttestation from "../wallet-instance-attestation";
|
14
|
-
import { generate, deleteKey } from "@pagopa/io-react-native-crypto";
|
15
14
|
import { SdJwt } from ".";
|
16
|
-
import {
|
15
|
+
import { useEphemeralKey } from "../utils/crypto";
|
17
16
|
|
18
17
|
import * as z from "zod";
|
19
18
|
import { getJwtFromFormPost } from "../utils/decoder";
|
@@ -244,22 +243,17 @@ export const authorizeIssuing =
|
|
244
243
|
|
245
244
|
const authorizationCode = authenticationRequest.code;
|
246
245
|
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
jti: `${uuid.v4()}`,
|
257
|
-
},
|
258
|
-
ephemeralContext
|
246
|
+
const signedDPop = await useEphemeralKey((ctx) =>
|
247
|
+
createDPopToken(
|
248
|
+
{
|
249
|
+
htm: "POST",
|
250
|
+
htu: tokenUrl,
|
251
|
+
jti: `${uuid.v4()}`,
|
252
|
+
},
|
253
|
+
ctx
|
254
|
+
)
|
259
255
|
);
|
260
256
|
|
261
|
-
await deleteKey(keytag);
|
262
|
-
|
263
257
|
const requestBody = {
|
264
258
|
grant_type: "authorization code",
|
265
259
|
client_id: clientId,
|
@@ -341,15 +335,19 @@ export const getCredential =
|
|
341
335
|
{ nonce, accessToken, clientId, walletProviderBaseUrl }: AuthorizationConf,
|
342
336
|
pidProviderEntityConfiguration: CredentialIssuerEntityConfiguration
|
343
337
|
): Promise<PidResponse> => {
|
338
|
+
const credentialUrl =
|
339
|
+
pidProviderEntityConfiguration.payload.metadata.openid_credential_issuer
|
340
|
+
.credential_endpoint;
|
341
|
+
|
344
342
|
const signedDPopForPid = await createDPopToken(
|
345
343
|
{
|
346
344
|
htm: "POST",
|
347
|
-
htu:
|
348
|
-
.openid_credential_issuer.token_endpoint,
|
345
|
+
htu: credentialUrl,
|
349
346
|
jti: `${uuid.v4()}`,
|
350
347
|
},
|
351
348
|
pidCryptoContext
|
352
349
|
);
|
350
|
+
|
353
351
|
const signedNonceProof = await createNonceProof(
|
354
352
|
nonce,
|
355
353
|
clientId,
|
@@ -357,10 +355,6 @@ export const getCredential =
|
|
357
355
|
pidCryptoContext
|
358
356
|
);
|
359
357
|
|
360
|
-
const credentialUrl =
|
361
|
-
pidProviderEntityConfiguration.payload.metadata.openid_credential_issuer
|
362
|
-
.credential_endpoint;
|
363
|
-
|
364
358
|
const requestBody = {
|
365
359
|
credential_definition: JSON.stringify({
|
366
360
|
type: ["PersonIdentificationData"],
|
package/src/utils/crypto.ts
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
-
import {
|
1
|
+
import {
|
2
|
+
getPublicKey,
|
3
|
+
sign,
|
4
|
+
generate,
|
5
|
+
deleteKey,
|
6
|
+
} from "@pagopa/io-react-native-crypto";
|
7
|
+
import uuid from "react-native-uuid";
|
2
8
|
import { thumbprint, type CryptoContext } from "@pagopa/io-react-native-jwt";
|
3
9
|
import { fixBase64EncodingOnKey } from "./jwk";
|
4
10
|
|
@@ -39,3 +45,27 @@ export const createCryptoContextFor = (keytag: string): CryptoContext => {
|
|
39
45
|
},
|
40
46
|
};
|
41
47
|
};
|
48
|
+
|
49
|
+
/**
|
50
|
+
* Executes the input function injecting an ephemeral crypto context.
|
51
|
+
* An ephemeral crypto context is a context which is bound to a key
|
52
|
+
* that is just created and is deleted after use.
|
53
|
+
*
|
54
|
+
* @param fn The procedure to be executed
|
55
|
+
* @returns The returned value of the input procedure.
|
56
|
+
*/
|
57
|
+
export const useEphemeralKey = async <R>(
|
58
|
+
fn: (ephemeralContext: CryptoContext) => Promise<R>
|
59
|
+
): Promise<R> => {
|
60
|
+
// Use an ephemeral key to be destroyed after use
|
61
|
+
const keytag = `ephemeral-${uuid.v4()}`;
|
62
|
+
await generate(keytag);
|
63
|
+
const ephemeralContext = createCryptoContextFor(keytag);
|
64
|
+
try {
|
65
|
+
return fn(ephemeralContext);
|
66
|
+
} catch (error) {
|
67
|
+
throw error;
|
68
|
+
} finally {
|
69
|
+
await deleteKey(keytag);
|
70
|
+
}
|
71
|
+
};
|