@pagopa/io-react-native-wallet 1.2.2 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/credential/presentation/01-start-flow.js +12 -28
- package/lib/commonjs/credential/presentation/01-start-flow.js.map +1 -1
- package/lib/commonjs/credential/presentation/04-retrieve-rp-jwks.js +96 -24
- package/lib/commonjs/credential/presentation/04-retrieve-rp-jwks.js.map +1 -1
- package/lib/commonjs/credential/presentation/05-verify-request-object.js +7 -2
- package/lib/commonjs/credential/presentation/05-verify-request-object.js.map +1 -1
- package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js +9 -5
- package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
- package/lib/commonjs/credential/presentation/08-send-authorization-response.js +2 -2
- package/lib/commonjs/credential/presentation/08-send-authorization-response.js.map +1 -1
- package/lib/commonjs/credential/presentation/README.md +4 -4
- package/lib/commonjs/credential/presentation/errors.js +2 -19
- package/lib/commonjs/credential/presentation/errors.js.map +1 -1
- package/lib/commonjs/credential/presentation/types.js +7 -1
- package/lib/commonjs/credential/presentation/types.js.map +1 -1
- package/lib/commonjs/utils/crypto.js +41 -1
- package/lib/commonjs/utils/crypto.js.map +1 -1
- package/lib/module/credential/presentation/01-start-flow.js +12 -28
- package/lib/module/credential/presentation/01-start-flow.js.map +1 -1
- package/lib/module/credential/presentation/04-retrieve-rp-jwks.js +96 -24
- package/lib/module/credential/presentation/04-retrieve-rp-jwks.js.map +1 -1
- package/lib/module/credential/presentation/05-verify-request-object.js +7 -2
- package/lib/module/credential/presentation/05-verify-request-object.js.map +1 -1
- package/lib/module/credential/presentation/07-evaluate-input-descriptor.js +9 -5
- package/lib/module/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
- package/lib/module/credential/presentation/08-send-authorization-response.js +2 -2
- package/lib/module/credential/presentation/08-send-authorization-response.js.map +1 -1
- package/lib/module/credential/presentation/README.md +4 -4
- package/lib/module/credential/presentation/errors.js +0 -16
- package/lib/module/credential/presentation/errors.js.map +1 -1
- package/lib/module/credential/presentation/types.js +7 -1
- package/lib/module/credential/presentation/types.js.map +1 -1
- package/lib/module/utils/crypto.js +38 -0
- package/lib/module/utils/crypto.js.map +1 -1
- package/lib/typescript/credential/presentation/01-start-flow.d.ts +3 -3
- package/lib/typescript/credential/presentation/01-start-flow.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/03-get-request-object.d.ts +1 -1
- package/lib/typescript/credential/presentation/04-retrieve-rp-jwks.d.ts +16 -9
- package/lib/typescript/credential/presentation/04-retrieve-rp-jwks.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/05-verify-request-object.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts +3 -2
- package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts +1 -1
- package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/errors.d.ts +0 -11
- package/lib/typescript/credential/presentation/errors.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/types.d.ts +242 -3
- package/lib/typescript/credential/presentation/types.d.ts.map +1 -1
- package/lib/typescript/utils/crypto.d.ts +24 -0
- package/lib/typescript/utils/crypto.d.ts.map +1 -1
- package/package.json +3 -1
- package/src/credential/presentation/01-start-flow.ts +16 -32
- package/src/credential/presentation/03-get-request-object.ts +1 -1
- package/src/credential/presentation/04-retrieve-rp-jwks.ts +123 -35
- package/src/credential/presentation/05-verify-request-object.ts +4 -3
- package/src/credential/presentation/07-evaluate-input-descriptor.ts +20 -6
- package/src/credential/presentation/08-send-authorization-response.ts +2 -2
- package/src/credential/presentation/README.md +4 -4
- package/src/credential/presentation/errors.ts +0 -16
- package/src/credential/presentation/types.ts +8 -1
- package/src/utils/crypto.ts +43 -0
@@ -5,15 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.startFlowFromQR = void 0;
|
7
7
|
var z = _interopRequireWildcard(require("zod"));
|
8
|
-
var _errors = require("
|
8
|
+
var _errors = require("../../utils/errors");
|
9
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
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
|
12
|
-
|
13
|
-
|
14
|
-
// TODO: refine to known paths using literals
|
15
|
-
clientId: z.string(),
|
16
|
-
requestURI: z.string()
|
11
|
+
const PresentationParams = z.object({
|
12
|
+
clientId: z.string().nonempty(),
|
13
|
+
requestUri: z.string().url()
|
17
14
|
});
|
18
15
|
|
19
16
|
/**
|
@@ -25,37 +22,24 @@ const QRCodePayload = z.object({
|
|
25
22
|
*/
|
26
23
|
|
27
24
|
/**
|
28
|
-
* Start a presentation flow by decoding
|
25
|
+
* Start a presentation flow by decoding the parameters needed to start the presentation flow.
|
29
26
|
*
|
30
27
|
* @param qrcode The encoded QR-code content
|
31
28
|
* @returns The url for the Relying Party to connect with
|
32
29
|
* @throws If the provided qr code fails to be decoded
|
33
30
|
*/
|
34
|
-
const startFlowFromQR =
|
35
|
-
|
36
|
-
|
37
|
-
var _originalQrCode$;
|
38
|
-
// splitting qrcode to identify which is link format
|
39
|
-
const originalQrCode = qrcode.split("://");
|
40
|
-
const replacedQrcode = (_originalQrCode$ = originalQrCode[1]) !== null && _originalQrCode$ !== void 0 && _originalQrCode$.startsWith("?") ? qrcode.replace(`${originalQrCode[0]}://`, "https://wallet.example/") : qrcode;
|
41
|
-
decodedUrl = new URL(replacedQrcode);
|
42
|
-
} catch (error) {
|
43
|
-
throw new _errors.InvalidQRCodeError(`Failed to decode QR code: ${qrcode}`);
|
44
|
-
}
|
45
|
-
const protocol = decodedUrl.protocol;
|
46
|
-
const resource = decodedUrl.hostname;
|
47
|
-
const requestURI = decodedUrl.searchParams.get("request_uri");
|
48
|
-
const clientId = decodedUrl.searchParams.get("client_id");
|
49
|
-
const result = QRCodePayload.safeParse({
|
50
|
-
protocol,
|
51
|
-
resource,
|
52
|
-
requestURI,
|
31
|
+
const startFlowFromQR = (requestUri, clientId) => {
|
32
|
+
const result = PresentationParams.safeParse({
|
33
|
+
requestUri,
|
53
34
|
clientId
|
54
35
|
});
|
55
36
|
if (result.success) {
|
56
37
|
return result.data;
|
57
38
|
} else {
|
58
|
-
throw new _errors.
|
39
|
+
throw new _errors.ValidationFailed({
|
40
|
+
message: "Invalid parameters provided",
|
41
|
+
reason: result.error.message
|
42
|
+
});
|
59
43
|
}
|
60
44
|
};
|
61
45
|
exports.startFlowFromQR = startFlowFromQR;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["z","_interopRequireWildcard","require","_errors","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","
|
1
|
+
{"version":3,"names":["z","_interopRequireWildcard","require","_errors","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","PresentationParams","object","clientId","string","nonempty","requestUri","url","startFlowFromQR","result","safeParse","success","data","ValidationFailed","message","reason","error","exports"],"sourceRoot":"../../../../src","sources":["credential/presentation/01-start-flow.ts"],"mappings":";;;;;;AAAA,IAAAA,CAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,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,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;AAEtD,MAAMW,kBAAkB,GAAG1B,CAAC,CAAC2B,MAAM,CAAC;EAClCC,QAAQ,EAAE5B,CAAC,CAAC6B,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EAC/BC,UAAU,EAAE/B,CAAC,CAAC6B,MAAM,CAAC,CAAC,CAACG,GAAG,CAAC;AAC7B,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,eAA4C,GAAGA,CAC1DF,UAAkB,EAClBH,QAAgB,KACb;EACH,MAAMM,MAAM,GAAGR,kBAAkB,CAACS,SAAS,CAAC;IAC1CJ,UAAU;IACVH;EACF,CAAC,CAAC;EAEF,IAAIM,MAAM,CAACE,OAAO,EAAE;IAClB,OAAOF,MAAM,CAACG,IAAI;EACpB,CAAC,MAAM;IACL,MAAM,IAAIC,wBAAgB,CAAC;MACzBC,OAAO,EAAE,6BAA6B;MACtCC,MAAM,EAAEN,MAAM,CAACO,KAAK,CAACF;IACvB,CAAC,CAAC;EACJ;AACF,CAAC;AAACG,OAAA,CAAAT,eAAA,GAAAA,eAAA"}
|
@@ -8,6 +8,8 @@ var _jwk = require("../../utils/jwk");
|
|
8
8
|
var _misc = require("../../utils/misc");
|
9
9
|
var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
|
10
10
|
var _errors = require("./errors");
|
11
|
+
var _types = require("./types");
|
12
|
+
var _crypto = require("../../utils/crypto");
|
11
13
|
/**
|
12
14
|
* Defines the signature for a function that retrieves JSON Web Key Sets (JWKS) from a client.
|
13
15
|
*
|
@@ -17,15 +19,68 @@ var _errors = require("./errors");
|
|
17
19
|
*/
|
18
20
|
|
19
21
|
/**
|
20
|
-
*
|
21
|
-
* It is formed using `{issUrl.base}/.well-known/jar-issuer${issUrl.pah}` as explained in SD-JWT VC issuer metadata section
|
22
|
+
* Fetches and parses JWKS from a given URI.
|
22
23
|
*
|
23
|
-
* @param
|
24
|
-
* @param
|
25
|
-
* @
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
* @param jwksUri - The JWKS URI.
|
25
|
+
* @param fetchFn - The fetch function to use.
|
26
|
+
* @returns An array of JWKs.
|
27
|
+
*/
|
28
|
+
const fetchJwksFromUri = async (jwksUri, appFetch) => {
|
29
|
+
const jwks = await appFetch(jwksUri, {
|
30
|
+
method: "GET"
|
31
|
+
}).then((0, _misc.hasStatusOrThrow)(200)).then(raw => raw.json()).then(json => json.jwks ? _jwk.JWKS.parse(json.jwks) : _jwk.JWKS.parse(json));
|
32
|
+
return jwks.keys;
|
33
|
+
};
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Retrieves JWKS when the client ID scheme includes x509 SAN DNS.
|
37
|
+
*
|
38
|
+
* @param decodedJwt - The decoded JWT.
|
39
|
+
* @param fetchFn - The fetch function to use.
|
40
|
+
* @returns An array of JWKs.
|
41
|
+
* @throws Will throw an error if no suitable keys are found.
|
42
|
+
*/
|
43
|
+
const getJwksFromX509Cert = async certChain => {
|
44
|
+
if (!Array.isArray(certChain) || certChain.length === 0 || !certChain[0]) {
|
45
|
+
throw new _errors.NoSuitableKeysFoundInEntityConfiguration("No RP encrypt key found!");
|
46
|
+
}
|
47
|
+
const pemCert = (0, _crypto.convertCertToPem)(certChain[0]);
|
48
|
+
const publicKey = (0, _crypto.parsePublicKey)(pemCert);
|
49
|
+
if (!publicKey) {
|
50
|
+
throw new _errors.NoSuitableKeysFoundInEntityConfiguration("Unsupported public key type.");
|
51
|
+
}
|
52
|
+
const signingJwk = (0, _crypto.getSigningJwk)(publicKey);
|
53
|
+
return [signingJwk];
|
54
|
+
};
|
55
|
+
|
56
|
+
/**
|
57
|
+
* Constructs the well-known JWKS URL based on the issuer claim.
|
58
|
+
*
|
59
|
+
* @param issuer - The issuer URL.
|
60
|
+
* @returns The well-known JWKS URL.
|
61
|
+
*/
|
62
|
+
const constructWellKnownJwksUrl = issuer => {
|
63
|
+
const issuerUrl = new URL(issuer);
|
64
|
+
return new URL(`/.well-known/jar-issuer${issuerUrl.pathname}`, `${issuerUrl.protocol}//${issuerUrl.host}`).toString();
|
65
|
+
};
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Fetches the JSON Web Key Set (JWKS) based on the provided Request Object encoded as a JWT.
|
69
|
+
* The retrieval process follows these steps in order:
|
70
|
+
*
|
71
|
+
* 1. **Direct JWK Retrieval**: If the JWT's protected header contains a `jwk` attribute, it uses this key directly.
|
72
|
+
* 2. **X.509 Certificate Retrieval**: If the protected header includes an `x5c` attribute, it extracts the JWKs from the provided X.509 certificate chain.
|
73
|
+
* 3. **Issuer's Well-Known Endpoint**: If neither `jwk` nor `x5c` are present, it constructs the JWKS URL using the issuer (`iss`) claim and fetches the keys from the issuer's well-known JWKS endpoint.
|
74
|
+
*
|
75
|
+
* The JWKS URL is constructed in the format `{issUrl.base}/.well-known/jar-issuer${issUrl.path}`,
|
76
|
+
* as detailed in the SD-JWT VC issuer metadata specification.
|
77
|
+
*
|
78
|
+
* @param requestObjectEncodedJwt - The Request Object encoded as a JWT.
|
79
|
+
* @param options - Optional parameters for fetching the JWKS.
|
80
|
+
* @param options.context - Optional context providing a custom fetch implementation.
|
81
|
+
* @param options.context.appFetch - A custom fetch function to replace the global `fetch` if provided.
|
82
|
+
* @returns A promise that resolves to an object containing an array of JSON Web Keys (JWKs).
|
83
|
+
* @throws {NoSuitableKeysFoundInEntityConfiguration} Throws an error if JWKS retrieval or key extraction fails.
|
29
84
|
*/
|
30
85
|
const fetchJwksFromRequestObject = async function (requestObjectEncodedJwt) {
|
31
86
|
var _requestObjectJwt$pro, _requestObjectJwt$pay;
|
@@ -36,29 +91,46 @@ const fetchJwksFromRequestObject = async function (requestObjectEncodedJwt) {
|
|
36
91
|
appFetch = fetch
|
37
92
|
} = context;
|
38
93
|
const requestObjectJwt = (0, _ioReactNativeJwt.decode)(requestObjectEncodedJwt);
|
94
|
+
const jwks = [];
|
39
95
|
|
40
96
|
// 1. check if request object jwt contains the 'jwk' attribute
|
41
97
|
if ((_requestObjectJwt$pro = requestObjectJwt.protectedHeader) !== null && _requestObjectJwt$pro !== void 0 && _requestObjectJwt$pro.jwk) {
|
42
|
-
|
43
|
-
|
44
|
-
|
98
|
+
const keys = [_jwk.JWK.parse(requestObjectJwt.protectedHeader.jwk)];
|
99
|
+
jwks.push(...keys);
|
100
|
+
}
|
101
|
+
|
102
|
+
// 2. check if request object jwt contains the 'x5c' attribute
|
103
|
+
if (requestObjectJwt.protectedHeader.x5c) {
|
104
|
+
const keys = await getJwksFromX509Cert(requestObjectJwt.protectedHeader.x5c);
|
105
|
+
jwks.push(...keys);
|
45
106
|
}
|
46
107
|
|
47
|
-
//
|
48
|
-
const
|
49
|
-
|
50
|
-
|
51
|
-
|
108
|
+
// 3. check if client_metadata contains the 'jwks' or 'jwks_uri' attribute
|
109
|
+
const requestObject = _types.RequestObject.parse(requestObjectJwt.payload);
|
110
|
+
const {
|
111
|
+
client_metadata
|
112
|
+
} = requestObject;
|
113
|
+
if (client_metadata !== null && client_metadata !== void 0 && client_metadata.jwks_uri) {
|
114
|
+
const fetchedJwks = await fetchJwksFromUri(new URL(client_metadata.jwks_uri).toString(), appFetch);
|
115
|
+
jwks.push(...fetchedJwks);
|
116
|
+
}
|
117
|
+
if (client_metadata !== null && client_metadata !== void 0 && client_metadata.jwks) {
|
118
|
+
jwks.push(...client_metadata.jwks.keys);
|
119
|
+
}
|
52
120
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
};
|
121
|
+
// 3. According to Potential profile, retrieve from RP endpoint using iss claim
|
122
|
+
const issuer = (_requestObjectJwt$pay = requestObjectJwt.payload) === null || _requestObjectJwt$pay === void 0 ? void 0 : _requestObjectJwt$pay.iss;
|
123
|
+
if (jwks.length === 0 && typeof issuer === "string") {
|
124
|
+
const wellKnownJwksUrl = constructWellKnownJwksUrl(issuer);
|
125
|
+
const jwksKeys = await fetchJwksFromUri(wellKnownJwksUrl, appFetch);
|
126
|
+
jwks.push(...jwksKeys);
|
60
127
|
}
|
61
|
-
|
128
|
+
if (jwks.length === 0) {
|
129
|
+
throw new _errors.NoSuitableKeysFoundInEntityConfiguration("Request Object signature verification");
|
130
|
+
}
|
131
|
+
return {
|
132
|
+
keys: jwks
|
133
|
+
};
|
62
134
|
};
|
63
135
|
|
64
136
|
/**
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_jwk","require","_misc","_ioReactNativeJwt","_errors","
|
1
|
+
{"version":3,"names":["_jwk","require","_misc","_ioReactNativeJwt","_errors","_types","_crypto","fetchJwksFromUri","jwksUri","appFetch","jwks","method","then","hasStatusOrThrow","raw","json","JWKS","parse","keys","getJwksFromX509Cert","certChain","Array","isArray","length","NoSuitableKeysFoundInEntityConfiguration","pemCert","convertCertToPem","publicKey","parsePublicKey","signingJwk","getSigningJwk","constructWellKnownJwksUrl","issuer","issuerUrl","URL","pathname","protocol","host","toString","fetchJwksFromRequestObject","requestObjectEncodedJwt","_requestObjectJwt$pro","_requestObjectJwt$pay","context","arguments","undefined","fetch","requestObjectJwt","decodeJwt","protectedHeader","jwk","JWK","push","x5c","requestObject","RequestObject","payload","client_metadata","jwks_uri","fetchedJwks","iss","wellKnownJwksUrl","jwksKeys","exports","fetchJwksFromConfig","rpConfig","wallet_relying_party","Error"],"sourceRoot":"../../../../src","sources":["credential/presentation/04-retrieve-rp-jwks.ts"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OA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AAGuD,QAAQ,CAACC,oBAAoB,CAACxD,IAAI;EAE/C,IAAI,CAACA,IAAI,IAAI,CAACW,KAAK,CAACC,OAAO,CAACZ,IAAI,CAACQ,IAAI,CAAC,EAAE;IACtC,MAAM,IAAIiD,KAAK,CAAC,gDAAgD,CAAC;EACnE;EAEA,OAAO;IACLjD,IAAI,EAAER,IAAI,CAACQ;EACb,CAAC;AACH,CAAC;AAAC6C,OAAA,CAAAC,mBAAA,GAAAA,mBAAA"}
|
@@ -11,12 +11,17 @@ const verifyRequestObjectSignature = async (requestObjectEncodedJwt, jwkKeys) =>
|
|
11
11
|
const requestObjectJwt = (0, _ioReactNativeJwt.decode)(requestObjectEncodedJwt);
|
12
12
|
|
13
13
|
// verify token signature to ensure the request object is authentic
|
14
|
-
const pubKey = jwkKeys === null || jwkKeys === void 0 ? void 0 : jwkKeys.find(_ref => {
|
14
|
+
const pubKey = (jwkKeys === null || jwkKeys === void 0 ? void 0 : jwkKeys.find(_ref => {
|
15
15
|
let {
|
16
16
|
kid
|
17
17
|
} = _ref;
|
18
18
|
return kid === requestObjectJwt.protectedHeader.kid;
|
19
|
-
})
|
19
|
+
})) || (jwkKeys === null || jwkKeys === void 0 ? void 0 : jwkKeys.find(_ref2 => {
|
20
|
+
let {
|
21
|
+
use
|
22
|
+
} = _ref2;
|
23
|
+
return use === "sig";
|
24
|
+
}));
|
20
25
|
if (!pubKey) {
|
21
26
|
throw new _errors.UnverifiedEntityError("Request Object signature verification!");
|
22
27
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_errors","require","_ioReactNativeJwt","_types","verifyRequestObjectSignature","requestObjectEncodedJwt","jwkKeys","requestObjectJwt","decodeJwt","pubKey","find","_ref","kid","protectedHeader","UnverifiedEntityError","verify","requestObject","RequestObject","parse","payload","exp","Date","now","exports"],"sourceRoot":"../../../../src","sources":["credential/presentation/05-verify-request-object.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AASO,MAAMG,4BAA0D,GACrE,MAAAA,CAAOC,uBAAuB,EAAEC,OAAO,KAAK;EAC1C,MAAMC,gBAAgB,GAAG,IAAAC,wBAAS,EAACH,uBAAuB,CAAC;;EAE3D;EACA,MAAMI,MAAM,
|
1
|
+
{"version":3,"names":["_errors","require","_ioReactNativeJwt","_types","verifyRequestObjectSignature","requestObjectEncodedJwt","jwkKeys","requestObjectJwt","decodeJwt","pubKey","find","_ref","kid","protectedHeader","_ref2","use","UnverifiedEntityError","verify","requestObject","RequestObject","parse","payload","exp","Date","now","exports"],"sourceRoot":"../../../../src","sources":["credential/presentation/05-verify-request-object.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AASO,MAAMG,4BAA0D,GACrE,MAAAA,CAAOC,uBAAuB,EAAEC,OAAO,KAAK;EAC1C,MAAMC,gBAAgB,GAAG,IAAAC,wBAAS,EAACH,uBAAuB,CAAC;;EAE3D;EACA,MAAMI,MAAM,GACV,CAAAH,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEI,IAAI,CACXC,IAAA;IAAA,IAAC;MAAEC;IAAI,CAAC,GAAAD,IAAA;IAAA,OAAKC,GAAG,KAAKL,gBAAgB,CAACM,eAAe,CAACD,GAAG;EAAA,CAC3D,CAAC,MAAIN,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEI,IAAI,CAACI,KAAA;IAAA,IAAC;MAAEC;IAAI,CAAC,GAAAD,KAAA;IAAA,OAAKC,GAAG,KAAK,KAAK;EAAA,EAAC;EAEhD,IAAI,CAACN,MAAM,EAAE;IACX,MAAM,IAAIO,6BAAqB,CAAC,wCAAwC,CAAC;EAC3E;EACA,MAAM,IAAAC,wBAAM,EAACZ,uBAAuB,EAAEI,MAAM,CAAC;EAE7C,MAAMS,aAAa,GAAGC,oBAAa,CAACC,KAAK,CAACb,gBAAgB,CAACc,OAAO,CAAC;EACnE;EACA;EACA,IAAIH,aAAa,CAACI,GAAG,IAAIJ,aAAa,CAACI,GAAG,IAAIC,IAAI,CAACC,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE;IAC/D,MAAM,IAAIR,6BAAqB,CAAC,4BAA4B,CAAC;EAC/D;EAEA,OAAO;IAAEE;EAAc,CAAC;AAC1B,CAAC;AAACO,OAAA,CAAArB,4BAAA,GAAAA,4BAAA"}
|
@@ -89,8 +89,8 @@ const extractClaimName = path => {
|
|
89
89
|
* - Validates whether required fields are present (unless marked optional)
|
90
90
|
* and match any specified JSONPath.
|
91
91
|
* - If a field includes a JSON Schema filter, validates the claim value against that schema.
|
92
|
-
* - Enforces `limit_disclosure` rules by returning only disclosures matching the specified fields
|
93
|
-
* if set to "required". Otherwise return the array
|
92
|
+
* - Enforces `limit_disclosure` rules by returning only disclosures, required and optional, matching the specified fields
|
93
|
+
* if set to "required". Otherwise also return the array unrequestedDisclosures with disclosures which can be passed for a particular use case.
|
94
94
|
* - Throws an error if a required field is invalid or missing.
|
95
95
|
*
|
96
96
|
* @param inputDescriptor - Describes constraints (fields, filters, etc.) that must be satisfied.
|
@@ -105,7 +105,8 @@ const evaluateInputDescriptorForSdJwt4VC = (inputDescriptor, payloadCredential,
|
|
105
105
|
// No validation, all field are optional
|
106
106
|
return {
|
107
107
|
requiredDisclosures: [],
|
108
|
-
optionalDisclosures:
|
108
|
+
optionalDisclosures: [],
|
109
|
+
unrequestedDisclosures: disclosures
|
109
110
|
};
|
110
111
|
}
|
111
112
|
const requiredClaimNames = [];
|
@@ -157,12 +158,15 @@ const evaluateInputDescriptorForSdJwt4VC = (inputDescriptor, payloadCredential,
|
|
157
158
|
}
|
158
159
|
|
159
160
|
// Categorizes disclosures into required and optional based on claim names and disclosure constraints.
|
160
|
-
|
161
|
+
|
161
162
|
const requiredDisclosures = disclosures.filter(disclosure => requiredClaimNames.includes(disclosure.decoded[INDEX_CLAIM_NAME]));
|
162
163
|
const optionalDisclosures = disclosures.filter(disclosure => optionalClaimNames.includes(disclosure.decoded[INDEX_CLAIM_NAME]) || isNotLimitDisclosure && !requiredClaimNames.includes(disclosure.decoded[INDEX_CLAIM_NAME]));
|
164
|
+
const isNotLimitDisclosure = !(inputDescriptor.constraints.limit_disclosure === "required");
|
165
|
+
const unrequestedDisclosures = isNotLimitDisclosure ? disclosures.filter(disclosure => !optionalClaimNames.includes(disclosure.decoded[INDEX_CLAIM_NAME]) && !requiredClaimNames.includes(disclosure.decoded[INDEX_CLAIM_NAME])) : [];
|
163
166
|
return {
|
164
167
|
requiredDisclosures,
|
165
|
-
optionalDisclosures
|
168
|
+
optionalDisclosures,
|
169
|
+
unrequestedDisclosures
|
166
170
|
};
|
167
171
|
};
|
168
172
|
exports.evaluateInputDescriptorForSdJwt4VC = evaluateInputDescriptorForSdJwt4VC;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_jsonpathPlus","require","_errors","_ajv","_interopRequireDefault","obj","__esModule","default","ajv","Ajv","allErrors","INDEX_CLAIM_NAME","mapDisclosuresToObject","disclosures","reduce","_ref","decoded","claimName","claimValue","findMatchedClaim","paths","payload","matchedPath","matchedValue","some","singlePath","result","JSONPath","path","json","length","error","MissingDataError","extractClaimName","regex","match","Error","evaluateInputDescriptorForSdJwt4VC","inputDescriptor","payloadCredential","_inputDescriptor$cons","constraints","fields","requiredDisclosures","optionalDisclosures","requiredClaimNames","optionalClaimNames","disclosuresAsPayload","allFieldsValid","every","field","optional","push","filter","validateSchema","compile","
|
1
|
+
{"version":3,"names":["_jsonpathPlus","require","_errors","_ajv","_interopRequireDefault","obj","__esModule","default","ajv","Ajv","allErrors","INDEX_CLAIM_NAME","mapDisclosuresToObject","disclosures","reduce","_ref","decoded","claimName","claimValue","findMatchedClaim","paths","payload","matchedPath","matchedValue","some","singlePath","result","JSONPath","path","json","length","error","MissingDataError","extractClaimName","regex","match","Error","evaluateInputDescriptorForSdJwt4VC","inputDescriptor","payloadCredential","_inputDescriptor$cons","constraints","fields","requiredDisclosures","optionalDisclosures","unrequestedDisclosures","requiredClaimNames","optionalClaimNames","disclosuresAsPayload","allFieldsValid","every","field","optional","push","filter","validateSchema","compile","disclosure","includes","isNotLimitDisclosure","limit_disclosure","exports"],"sourceRoot":"../../../../src","sources":["credential/presentation/07-evaluate-input-descriptor.ts"],"mappings":";;;;;;AAEA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,IAAA,GAAAC,sBAAA,CAAAH,OAAA;AAAsB,SAAAG,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AACtB,MAAMG,GAAG,GAAG,IAAIC,YAAG,CAAC;EAAEC,SAAS,EAAE;AAAK,CAAC,CAAC;AACxC,MAAMC,gBAAgB,GAAG,CAAC;AAc1B;AACA;AACA;AACA;AACA;AACA,MAAMC,sBAAsB,GAC1BC,WAAoC,IACR;EAC5B,OAAOA,WAAW,CAACC,MAAM,CAAC,CAACT,GAAG,EAAAU,IAAA,KAAkB;IAAA,IAAhB;MAAEC;IAAQ,CAAC,GAAAD,IAAA;IACzC,MAAM,GAAGE,SAAS,EAAEC,UAAU,CAAC,GAAGF,OAAO;IACzCX,GAAG,CAACY,SAAS,CAAC,GAAGC,UAAU;IAC3B,OAAOb,GAAG;EACZ,CAAC,EAAE,CAAC,CAA4B,CAAC;AACnC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,MAAMc,gBAAgB,GAAGA,CACvBC,KAAe,EACfC,OAAY,KACW;EACvB,IAAIC,WAAW;EACf,IAAIC,YAAY;EAChBH,KAAK,CAACI,IAAI,CAAEC,UAAU,IAAK;IACzB,IAAI;MACF,MAAMC,MAAM,GAAG,IAAAC,sBAAQ,EAAC;QAAEC,IAAI,EAAEH,UAAU;QAAEI,IAAI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;;EAEA,MAAMW,mBAAmB,GAAG9B,WAAW,CAACyC,MAAM,CAAEG,UAAU,IACxDX,kBAAkB,CAACY,QAAQ,CAACD,UAAU,CAACzC,OAAO,CAACL,gBAAgB,CAAC,CAClE,CAAC;EAED,MAAMiC,mBAAmB,GAAG/B,WAAW,CAACyC,MAAM,CAC3CG,UAAU,IACTV,kBAAkB,CAACW,QAAQ,CAACD,UAAU,CAACzC,OAAO,CAACL,gBAAgB,CAAC,CAAC,IAChEgD,oBAAoB,IACnB,CAACb,kBAAkB,CAACY,QAAQ,CAACD,UAAU,CAACzC,OAAO,CAACL,gBAAgB,CAAC,CACvE,CAAC;EAED,MAAMgD,oBAAoB,GAAG,EAC3BrB,eAAe,CAACG,WAAW,CAACmB,gBAAgB,KAAK,UAAU,CAC5D;EAED,MAAMf,sBAAsB,GAAGc,oBAAoB,GAC/C9C,WAAW,CAACyC,MAAM,CACfG,UAAU,IACT,CAACV,kBAAkB,CAACW,QAAQ,CAC1BD,UAAU,CAACzC,OAAO,CAACL,gBAAgB,CACrC,CAAC,IACD,CAACmC,kBAAkB,CAACY,QAAQ,CAACD,UAAU,CAACzC,OAAO,CAACL,gBAAgB,CAAC,CACrE,CAAC,GACD,EAAE;EAEN,OAAO;IACLgC,mBAAmB;IACnBC,mBAAmB;IACnBC;EACF,CAAC;AACH,CAAC;AAACgB,OAAA,CAAAxB,kCAAA,GAAAA,kCAAA"}
|
@@ -176,10 +176,10 @@ exports.buildDirectPostJwtBody = buildDirectPostJwtBody;
|
|
176
176
|
* @param context - Contains optional custom fetch implementation.
|
177
177
|
* @returns Parsed and validated authorization response from the Relying Party.
|
178
178
|
*/
|
179
|
-
const sendAuthorizationResponse = async (requestObject, presentationDefinition, jwkKeys, presentation
|
179
|
+
const sendAuthorizationResponse = async function (requestObject, presentationDefinition, jwkKeys, presentation) {
|
180
180
|
let {
|
181
181
|
appFetch = fetch
|
182
|
-
} =
|
182
|
+
} = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
183
183
|
// 1. Create the VP token and associated submission mapping
|
184
184
|
const {
|
185
185
|
vp_token,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_ioReactNativeJwt","require","_reactNativeUuid","_interopRequireDefault","_errors","_misc","_sdJwt","z","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","AuthorizationResponse","object","status","string","optional","response_code","redirect_uri","exports","chooseRSAPublicKeyToEncrypt","rpJwkKeys","rsaEncKey","filter","jwk","use","kty","NoSuitableKeysFoundInEntityConfiguration","prepareVpToken","requestObject","presentationDefinition","_ref","_presentationDefiniti","verifiableCredential","requestedClaims","cryptoContext","token","vp","disclose","sd_hash","sha256ToBase64","kbJwt","SignJWT","setProtectedHeader","typ","alg","setPayload","nonce","setAudience","client_id","setIssuedAt","sign","vp_token","join","presentation_submission","id","uuid","v4","definition_id","descriptor_map","input_descriptors","path","format","buildDirectPostBody","vpToken","presentationSubmission","formUrlEncodedBody","URLSearchParams","state","JSON","stringify","toString","buildDirectPostJwtBody","jwkKeys","authzResponsePayload","rsaPublicJwk","encryptedResponse","EncryptJwe","enc","kid","encrypt","formBody","response","sendAuthorizationResponse","presentation","
|
1
|
+
{"version":3,"names":["_ioReactNativeJwt","require","_reactNativeUuid","_interopRequireDefault","_errors","_misc","_sdJwt","z","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","AuthorizationResponse","object","status","string","optional","response_code","redirect_uri","exports","chooseRSAPublicKeyToEncrypt","rpJwkKeys","rsaEncKey","filter","jwk","use","kty","NoSuitableKeysFoundInEntityConfiguration","prepareVpToken","requestObject","presentationDefinition","_ref","_presentationDefiniti","verifiableCredential","requestedClaims","cryptoContext","token","vp","disclose","sd_hash","sha256ToBase64","kbJwt","SignJWT","setProtectedHeader","typ","alg","setPayload","nonce","setAudience","client_id","setIssuedAt","sign","vp_token","join","presentation_submission","id","uuid","v4","definition_id","descriptor_map","input_descriptors","path","format","buildDirectPostBody","vpToken","presentationSubmission","formUrlEncodedBody","URLSearchParams","state","JSON","stringify","toString","buildDirectPostJwtBody","jwkKeys","authzResponsePayload","rsaPublicJwk","encryptedResponse","EncryptJwe","enc","kid","encrypt","formBody","response","sendAuthorizationResponse","presentation","appFetch","fetch","arguments","length","undefined","requestBody","response_mode","response_uri","method","headers","body","then","hasStatusOrThrow","res","json","parse"],"sourceRoot":"../../../../src","sources":["credential/presentation/08-send-authorization-response.ts"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAKA,IAAAC,gBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAIA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAEA,IAAAM,CAAA,GAAAC,uBAAA,CAAAP,OAAA;AAAyB,SAAAQ,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,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,CAA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AC,IAAAC,sBAAgB,EAAC,GAAG,CAAC,CAAC,CAC3BD,IAAI,CAAEE,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBH,IAAI,CAACpF,qBAAqB,CAACwF,KAAK,CAAC;AACtC,CAAC;AAACjF,OAAA,CAAAgE,yBAAA,GAAAA,yBAAA"}
|
@@ -29,8 +29,8 @@ sequenceDiagram
|
|
29
29
|
<summary>Remote Presentation flow</summary>
|
30
30
|
|
31
31
|
```ts
|
32
|
-
// Scan e retrive qr-code
|
33
|
-
const
|
32
|
+
// Scan e retrive qr-code, decode it and get its parameters
|
33
|
+
const {requestUri, clientId} = ...
|
34
34
|
|
35
35
|
// Retrieve the integrity key tag from the store and create its context
|
36
36
|
const integrityKeyTag = "example"; // Let's assume this is the key tag used to create the wallet instance
|
@@ -55,7 +55,7 @@ const walletInstanceAttestation =
|
|
55
55
|
});
|
56
56
|
|
57
57
|
// Start the issuance flow
|
58
|
-
const { requestURI, clientId } = Credential.Presentation.startFlowFromQR(
|
58
|
+
const { requestURI, clientId } = Credential.Presentation.startFlowFromQR(requestUri, clientId);
|
59
59
|
|
60
60
|
// If use trust federation: Evaluate issuer trust
|
61
61
|
const { rpConf } = await Credential.Presentation.evaluateRelyingPartyTrust(clientId);
|
@@ -111,4 +111,4 @@ const { presentationDefinition } = await Credential.Presentation.fetchPresentDef
|
|
111
111
|
|
112
112
|
```
|
113
113
|
|
114
|
-
</details>
|
114
|
+
</details>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.UnverifiedEntityError = exports.NoSuitableKeysFoundInEntityConfiguration = exports.MissingDataError = exports.
|
6
|
+
exports.UnverifiedEntityError = exports.NoSuitableKeysFoundInEntityConfiguration = exports.MissingDataError = exports.AuthRequestDecodeError = void 0;
|
7
7
|
var _errors = require("../../utils/errors");
|
8
8
|
/**
|
9
9
|
* An error subclass thrown when auth request decode fail
|
@@ -46,28 +46,11 @@ class NoSuitableKeysFoundInEntityConfiguration extends _errors.IoWalletError {
|
|
46
46
|
}
|
47
47
|
}
|
48
48
|
|
49
|
-
/**
|
50
|
-
* When a QR code is not valid.
|
51
|
-
*
|
52
|
-
*/
|
53
|
-
exports.NoSuitableKeysFoundInEntityConfiguration = NoSuitableKeysFoundInEntityConfiguration;
|
54
|
-
class InvalidQRCodeError extends _errors.IoWalletError {
|
55
|
-
code = "ERR_INVALID_QR_CODE";
|
56
|
-
|
57
|
-
/**
|
58
|
-
* @param detail A description of why the QR code is considered invalid.
|
59
|
-
*/
|
60
|
-
constructor(detail) {
|
61
|
-
const message = `QR code is not valid: ${detail}.`;
|
62
|
-
super(message);
|
63
|
-
}
|
64
|
-
}
|
65
|
-
|
66
49
|
/**
|
67
50
|
* When the entity is unverified because the Relying Party is not trusted.
|
68
51
|
*
|
69
52
|
*/
|
70
|
-
exports.
|
53
|
+
exports.NoSuitableKeysFoundInEntityConfiguration = NoSuitableKeysFoundInEntityConfiguration;
|
71
54
|
class UnverifiedEntityError extends _errors.IoWalletError {
|
72
55
|
code = "ERR_UNVERIFIED_RP_ENTITY";
|
73
56
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_errors","require","AuthRequestDecodeError","IoWalletError","code","constructor","message","claim","arguments","length","undefined","reason","serializeAttrs","exports","NoSuitableKeysFoundInEntityConfiguration","scenario","
|
1
|
+
{"version":3,"names":["_errors","require","AuthRequestDecodeError","IoWalletError","code","constructor","message","claim","arguments","length","undefined","reason","serializeAttrs","exports","NoSuitableKeysFoundInEntityConfiguration","scenario","UnverifiedEntityError","MissingDataError","missingAttributes"],"sourceRoot":"../../../../src","sources":["credential/presentation/errors.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACO,MAAMC,sBAAsB,SAASC,qBAAa,CAAC;EACxDC,IAAI,GAAG,oDAAoD;;EAE3D;;EAGA;;EAGA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,OAAA,CAAAI,gBAAA,GAAAA,gBAAA"}
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
exports.RequestObject = exports.PresentationDefinition = exports.InputDescriptor = void 0;
|
7
7
|
var _types = require("../../sd-jwt/types");
|
8
8
|
var z = _interopRequireWildcard(require("zod"));
|
9
|
+
var _jwk = require("../../utils/jwk");
|
9
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); }
|
10
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; }
|
11
12
|
/**
|
@@ -87,7 +88,12 @@ const RequestObject = z.object({
|
|
87
88
|
response_type: z.literal("vp_token"),
|
88
89
|
response_mode: z.enum(["direct_post.jwt", "direct_post"]),
|
89
90
|
client_id: z.string(),
|
90
|
-
client_id_scheme: z.string(),
|
91
|
+
client_id_scheme: z.string().optional(),
|
92
|
+
// previous z.literal("entity_id"),
|
93
|
+
client_metadata: z.object({
|
94
|
+
jwks_uri: z.string().optional(),
|
95
|
+
jwks: _jwk.JWKS.optional()
|
96
|
+
}).optional(),
|
91
97
|
// previous z.literal("entity_id"),
|
92
98
|
scope: z.string().optional(),
|
93
99
|
presentation_definition: PresentationDefinition.optional()
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_types","require","z","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","Fields","object","path","array","string","min","id","optional","purpose","name","filter","any","boolean","intent_to_retain","Constraints","fields","limit_disclosure","enum","InputDescriptor","format","record","constraints","group","exports","SubmissionRequirement","rule","from","from_nested","count","number","PresentationDefinition","input_descriptors","submission_requirements","RequestObject","iss","iat","UnixTime","exp","state","nonce","response_uri","response_type","literal","response_mode","client_id","client_id_scheme","scope","presentation_definition"],"sourceRoot":"../../../../src","sources":["credential/presentation/types.ts"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,CAAA,GAAAC,uBAAA,CAAAF,OAAA;
|
1
|
+
{"version":3,"names":["_types","require","z","_interopRequireWildcard","_jwk","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","Fields","object","path","array","string","min","id","optional","purpose","name","filter","any","boolean","intent_to_retain","Constraints","fields","limit_disclosure","enum","InputDescriptor","format","record","constraints","group","exports","SubmissionRequirement","rule","from","from_nested","count","number","PresentationDefinition","input_descriptors","submission_requirements","RequestObject","iss","iat","UnixTime","exp","state","nonce","response_uri","response_type","literal","response_mode","client_id","client_id_scheme","client_metadata","jwks_uri","jwks","JWKS","scope","presentation_definition"],"sourceRoot":"../../../../src","sources":["credential/presentation/types.ts"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,CAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,IAAA,GAAAH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,CAACG,QAAQ,CAAC,CAAC;IAC/ByC,IAAI,EAAEC,SAAI,CAAC1C,QAAQ,CAAC;EACtB,CAAC,CAAC,CACDA,QAAQ,CAAC,CAAC;EAAE;EACf2C,KAAK,EAAE3E,CAAC,CAAC6B,MAAM,CAAC,CAAC,CAACG,QAAQ,CAAC,CAAC;EAC5B4C,uBAAuB,EAAErB,sBAAsB,CAACvB,QAAQ,CAAC;AAC3D,CAAC,CAAC;AAACgB,OAAA,CAAAU,aAAA,GAAAA,aAAA"}
|
@@ -3,11 +3,12 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.withEphemeralKey = exports.createCryptoContextFor = void 0;
|
6
|
+
exports.withEphemeralKey = exports.parsePublicKey = exports.getSigningJwk = exports.createCryptoContextFor = exports.convertCertToPem = void 0;
|
7
7
|
var _ioReactNativeCrypto = require("@pagopa/io-react-native-crypto");
|
8
8
|
var _reactNativeUuid = _interopRequireDefault(require("react-native-uuid"));
|
9
9
|
var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
|
10
10
|
var _jwk = require("./jwk");
|
11
|
+
var _jsrsasign = require("jsrsasign");
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
12
13
|
/**
|
13
14
|
* Create a CryptoContext bound to a key pair.
|
@@ -61,5 +62,44 @@ const withEphemeralKey = async fn => {
|
|
61
62
|
const ephemeralContext = createCryptoContextFor(keytag);
|
62
63
|
return fn(ephemeralContext).finally(() => (0, _ioReactNativeCrypto.deleteKey)(keytag));
|
63
64
|
};
|
65
|
+
|
66
|
+
/**
|
67
|
+
* Converts a certificate string to PEM format.
|
68
|
+
*
|
69
|
+
* @param certificate - The certificate string.
|
70
|
+
* @returns The PEM-formatted certificate.
|
71
|
+
*/
|
64
72
|
exports.withEphemeralKey = withEphemeralKey;
|
73
|
+
const convertCertToPem = certificate => `-----BEGIN CERTIFICATE-----\n${certificate}\n-----END CERTIFICATE-----`;
|
74
|
+
|
75
|
+
/**
|
76
|
+
* Parses the public key from a PEM-formatted certificate.
|
77
|
+
*
|
78
|
+
* @param pemCert - The PEM-formatted certificate.
|
79
|
+
* @returns The public key object.
|
80
|
+
* @throws Will throw an error if the public key is unsupported.
|
81
|
+
*/
|
82
|
+
exports.convertCertToPem = convertCertToPem;
|
83
|
+
const parsePublicKey = pemCert => {
|
84
|
+
const x509 = new _jsrsasign.X509();
|
85
|
+
x509.readCertPEM(pemCert);
|
86
|
+
const publicKey = x509.getPublicKey();
|
87
|
+
if (publicKey instanceof _jsrsasign.RSAKey || publicKey instanceof _jsrsasign.KJUR.crypto.ECDSA) {
|
88
|
+
return publicKey;
|
89
|
+
}
|
90
|
+
return undefined;
|
91
|
+
};
|
92
|
+
|
93
|
+
/**
|
94
|
+
* Retrieves the signing JWK from the public key.
|
95
|
+
*
|
96
|
+
* @param publicKey - The public key object.
|
97
|
+
* @returns The signing JWK.
|
98
|
+
*/
|
99
|
+
exports.parsePublicKey = parsePublicKey;
|
100
|
+
const getSigningJwk = publicKey => ({
|
101
|
+
..._jwk.JWK.parse(_jsrsasign.KEYUTIL.getJWKFromKey(publicKey)),
|
102
|
+
use: "sig"
|
103
|
+
});
|
104
|
+
exports.getSigningJwk = getSigningJwk;
|
65
105
|
//# sourceMappingURL=crypto.js.map
|