@pagopa/io-react-native-wallet 3.8.4 → 3.9.0
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/issuance/v1.0.0/03-complete-user-authorization.js +1 -6
- package/lib/commonjs/credential/issuance/v1.0.0/03-complete-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/v1.4.6/03-complete-user-authorization.js +1 -5
- package/lib/commonjs/credential/issuance/v1.4.6/03-complete-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/presentation/README.md +2 -1
- package/lib/commonjs/credential/presentation/api/types.js.map +1 -1
- package/lib/commonjs/credential/presentation/v1.0.0/07-send-authorization-response.js +2 -2
- package/lib/commonjs/credential/presentation/v1.0.0/07-send-authorization-response.js.map +1 -1
- package/lib/commonjs/credential/presentation/v1.4.6/05-verify-request-object.js +7 -1
- package/lib/commonjs/credential/presentation/v1.4.6/05-verify-request-object.js.map +1 -1
- package/lib/commonjs/credential/presentation/v1.4.6/07-send-authorization-response.js +42 -20
- package/lib/commonjs/credential/presentation/v1.4.6/07-send-authorization-response.js.map +1 -1
- package/lib/commonjs/credentials-catalogue/api/DigitalCredentialsCatalogue.js +2 -0
- package/lib/commonjs/credentials-catalogue/api/DigitalCredentialsCatalogue.js.map +1 -1
- package/lib/commonjs/credentials-catalogue/v1.4.6/mappers.js +2 -0
- package/lib/commonjs/credentials-catalogue/v1.4.6/mappers.js.map +1 -1
- package/lib/commonjs/mdoc/index.js +7 -2
- package/lib/commonjs/mdoc/index.js.map +1 -1
- package/lib/module/credential/issuance/v1.0.0/03-complete-user-authorization.js +1 -6
- package/lib/module/credential/issuance/v1.0.0/03-complete-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/v1.4.6/03-complete-user-authorization.js +1 -5
- package/lib/module/credential/issuance/v1.4.6/03-complete-user-authorization.js.map +1 -1
- package/lib/module/credential/presentation/README.md +2 -1
- package/lib/module/credential/presentation/api/types.js.map +1 -1
- package/lib/module/credential/presentation/v1.0.0/07-send-authorization-response.js +2 -2
- package/lib/module/credential/presentation/v1.0.0/07-send-authorization-response.js.map +1 -1
- package/lib/module/credential/presentation/v1.4.6/05-verify-request-object.js +8 -2
- package/lib/module/credential/presentation/v1.4.6/05-verify-request-object.js.map +1 -1
- package/lib/module/credential/presentation/v1.4.6/07-send-authorization-response.js +44 -22
- package/lib/module/credential/presentation/v1.4.6/07-send-authorization-response.js.map +1 -1
- package/lib/module/credentials-catalogue/api/DigitalCredentialsCatalogue.js +2 -0
- package/lib/module/credentials-catalogue/api/DigitalCredentialsCatalogue.js.map +1 -1
- package/lib/module/credentials-catalogue/v1.4.6/mappers.js +2 -0
- package/lib/module/credentials-catalogue/v1.4.6/mappers.js.map +1 -1
- package/lib/module/mdoc/index.js +7 -2
- package/lib/module/mdoc/index.js.map +1 -1
- package/lib/typescript/commonjs/credential/issuance/v1.0.0/03-complete-user-authorization.d.ts.map +1 -1
- package/lib/typescript/commonjs/credential/presentation/api/07-send-authorization-response.d.ts +5 -8
- package/lib/typescript/commonjs/credential/presentation/api/07-send-authorization-response.d.ts.map +1 -1
- package/lib/typescript/commonjs/credential/presentation/api/types.d.ts +0 -1
- package/lib/typescript/commonjs/credential/presentation/api/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/credential/presentation/v1.4.6/05-verify-request-object.d.ts.map +1 -1
- package/lib/typescript/commonjs/credential/presentation/v1.4.6/07-send-authorization-response.d.ts +4 -3
- package/lib/typescript/commonjs/credential/presentation/v1.4.6/07-send-authorization-response.d.ts.map +1 -1
- package/lib/typescript/commonjs/credentials-catalogue/api/DigitalCredentialsCatalogue.d.ts +6 -0
- package/lib/typescript/commonjs/credentials-catalogue/api/DigitalCredentialsCatalogue.d.ts.map +1 -1
- package/lib/typescript/commonjs/credentials-catalogue/v1.0.0/mappers.d.ts +2 -0
- package/lib/typescript/commonjs/credentials-catalogue/v1.0.0/mappers.d.ts.map +1 -1
- package/lib/typescript/commonjs/credentials-catalogue/v1.4.6/mappers.d.ts +2 -0
- package/lib/typescript/commonjs/credentials-catalogue/v1.4.6/mappers.d.ts.map +1 -1
- package/lib/typescript/commonjs/mdoc/index.d.ts +5 -1
- package/lib/typescript/commonjs/mdoc/index.d.ts.map +1 -1
- package/lib/typescript/module/credential/issuance/v1.0.0/03-complete-user-authorization.d.ts.map +1 -1
- package/lib/typescript/module/credential/presentation/api/07-send-authorization-response.d.ts +5 -8
- package/lib/typescript/module/credential/presentation/api/07-send-authorization-response.d.ts.map +1 -1
- package/lib/typescript/module/credential/presentation/api/types.d.ts +0 -1
- package/lib/typescript/module/credential/presentation/api/types.d.ts.map +1 -1
- package/lib/typescript/module/credential/presentation/v1.4.6/05-verify-request-object.d.ts.map +1 -1
- package/lib/typescript/module/credential/presentation/v1.4.6/07-send-authorization-response.d.ts +4 -3
- package/lib/typescript/module/credential/presentation/v1.4.6/07-send-authorization-response.d.ts.map +1 -1
- package/lib/typescript/module/credentials-catalogue/api/DigitalCredentialsCatalogue.d.ts +6 -0
- package/lib/typescript/module/credentials-catalogue/api/DigitalCredentialsCatalogue.d.ts.map +1 -1
- package/lib/typescript/module/credentials-catalogue/v1.0.0/mappers.d.ts +2 -0
- package/lib/typescript/module/credentials-catalogue/v1.0.0/mappers.d.ts.map +1 -1
- package/lib/typescript/module/credentials-catalogue/v1.4.6/mappers.d.ts +2 -0
- package/lib/typescript/module/credentials-catalogue/v1.4.6/mappers.d.ts.map +1 -1
- package/lib/typescript/module/mdoc/index.d.ts +5 -1
- package/lib/typescript/module/mdoc/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/credential/issuance/v1.0.0/03-complete-user-authorization.ts +1 -7
- package/src/credential/issuance/v1.4.6/03-complete-user-authorization.ts +1 -5
- package/src/credential/presentation/README.md +2 -1
- package/src/credential/presentation/api/07-send-authorization-response.ts +6 -8
- package/src/credential/presentation/api/types.ts +0 -1
- package/src/credential/presentation/v1.0.0/07-send-authorization-response.ts +3 -3
- package/src/credential/presentation/v1.4.6/05-verify-request-object.ts +15 -2
- package/src/credential/presentation/v1.4.6/07-send-authorization-response.ts +61 -37
- package/src/credentials-catalogue/api/DigitalCredentialsCatalogue.ts +2 -0
- package/src/credentials-catalogue/v1.4.6/mappers.ts +2 -0
- package/src/mdoc/index.ts +6 -2
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import { thumbprint } from "@pagopa/io-react-native-jwt";
|
|
1
2
|
import {
|
|
3
|
+
extractEncryptionJwkFromJwks,
|
|
2
4
|
createAuthorizationResponse as sdkCreateAuthorizationResponse,
|
|
3
5
|
fetchAuthorizationResponse as sdkFetchAuthorizationResponse,
|
|
4
6
|
} from "@pagopa/io-wallet-oid4vp";
|
|
5
7
|
|
|
6
|
-
import type {
|
|
8
|
+
import type { JWK } from "../../../utils/jwk";
|
|
9
|
+
import type { RelyingPartyConfig, RemotePresentationApi } from "../api";
|
|
10
|
+
import type { RequestObject } from "../api/types";
|
|
7
11
|
|
|
8
12
|
import { prepareVpTokenMdoc } from "../../../mdoc";
|
|
9
13
|
import { prepareVpToken } from "../../../sd-jwt";
|
|
@@ -14,40 +18,75 @@ import {
|
|
|
14
18
|
IoWalletError,
|
|
15
19
|
RelyingPartyResponseError,
|
|
16
20
|
} from "../../../utils/errors";
|
|
17
|
-
import {
|
|
18
|
-
generateRandomAlphaNumericString,
|
|
19
|
-
hasStatusOrThrow,
|
|
20
|
-
} from "../../../utils/misc";
|
|
21
|
+
import { hasStatusOrThrow } from "../../../utils/misc";
|
|
21
22
|
import { buildDirectPostBody } from "../common/utils/http";
|
|
22
23
|
import { mapSdkAuthorizationResponseError } from "./sdkErrorMapper";
|
|
23
24
|
import { AuthorizationResponse } from "./types";
|
|
24
25
|
|
|
26
|
+
// JWE alg used to encrypt the authorization response
|
|
27
|
+
const RESPONSE_ENCRYPTION_ALG = "ECDH-ES";
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Resolves the JWKS used to encrypt the authorization response.
|
|
31
|
+
* The SDK gives priority to the Request Object's client_metadata, then falls back to the RP configuration
|
|
32
|
+
* (when the RP is not an OpenID Federation client, rpConf is undefined).
|
|
33
|
+
*/
|
|
34
|
+
const getResponseEncryptionJwks = (
|
|
35
|
+
requestObject: RequestObject,
|
|
36
|
+
rpConf?: RelyingPartyConfig,
|
|
37
|
+
) => {
|
|
38
|
+
const jwks = requestObject.client_metadata?.jwks ?? rpConf?.jwks;
|
|
39
|
+
if (!jwks) {
|
|
40
|
+
throw new IoWalletError(
|
|
41
|
+
"Missing jwks in both rpConf and requestObject.client_metadata",
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
return jwks;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Computes the base64url SHA-256 thumbprint (RFC 7638) of the key the SDK will use to encrypt the
|
|
49
|
+
* authorization response. It binds the ISO 18013-7 mdoc DeviceResponse to the encrypted response
|
|
50
|
+
* through the OpenID4VP session transcript.
|
|
51
|
+
*/
|
|
52
|
+
const getResponseEncryptionJwkThumbprint = (
|
|
53
|
+
requestObject: RequestObject,
|
|
54
|
+
rpConf?: RelyingPartyConfig,
|
|
55
|
+
) => {
|
|
56
|
+
const encryptionJwk = extractEncryptionJwkFromJwks(
|
|
57
|
+
getResponseEncryptionJwks(requestObject, rpConf),
|
|
58
|
+
{ supportedAlgValues: [RESPONSE_ENCRYPTION_ALG] },
|
|
59
|
+
);
|
|
60
|
+
if (!encryptionJwk) {
|
|
61
|
+
throw new IoWalletError("No encryption JWK found in metadata");
|
|
62
|
+
}
|
|
63
|
+
return thumbprint(encryptionJwk as JWK);
|
|
64
|
+
};
|
|
65
|
+
|
|
25
66
|
/**
|
|
26
67
|
* Prepares remote presentations for a set of credentials.
|
|
27
68
|
*
|
|
28
69
|
* For each credential, this function:
|
|
29
70
|
* - Validates the credential format (currently supports 'mso_mdoc' or 'dc+sd-jwt').
|
|
30
71
|
* - Generates a verifiable presentation token (vpToken) using the appropriate method.
|
|
31
|
-
* - For ISO 18013-7,
|
|
72
|
+
* - For ISO 18013-7, binds the DeviceResponse to the thumbprint of the response encryption key.
|
|
32
73
|
*
|
|
33
74
|
* @param credentials - An array of credential items containing format, credential data, requested claims, and key information.
|
|
34
|
-
* @param
|
|
35
|
-
* @
|
|
75
|
+
* @param requestObject - The Request Object of the presentation.
|
|
76
|
+
* @param rpConf - Optional Relying Party configuration (OpenID Federation clients only).
|
|
77
|
+
* @returns A promise that resolves to an object containing an array of presentations.
|
|
36
78
|
* @throws {CredentialNotFoundError} When the credential format is unsupported.
|
|
37
79
|
*/
|
|
38
80
|
export const prepareRemotePresentations: RemotePresentationApi["prepareRemotePresentations"] =
|
|
39
|
-
async (credentials,
|
|
40
|
-
// In case of ISO 18013-7 we need a nonce, it shall have a minimum entropy of 16
|
|
41
|
-
const generatedNonce = generateRandomAlphaNumericString(16);
|
|
42
|
-
|
|
81
|
+
async (credentials, requestObject, rpConf) => {
|
|
43
82
|
const presentations = await Promise.all(
|
|
44
83
|
credentials.map(async (item) => {
|
|
45
84
|
const { format } = item;
|
|
46
85
|
|
|
47
86
|
if (format === "dc+sd-jwt") {
|
|
48
87
|
const { vp_token } = await prepareVpToken(
|
|
49
|
-
|
|
50
|
-
|
|
88
|
+
requestObject.nonce,
|
|
89
|
+
requestObject.client_id,
|
|
51
90
|
[
|
|
52
91
|
item.credential,
|
|
53
92
|
item.presentationFrame,
|
|
@@ -65,10 +104,10 @@ export const prepareRemotePresentations: RemotePresentationApi["prepareRemotePre
|
|
|
65
104
|
|
|
66
105
|
if (format === "mso_mdoc") {
|
|
67
106
|
const { vp_token } = await prepareVpTokenMdoc(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
107
|
+
requestObject.nonce,
|
|
108
|
+
await getResponseEncryptionJwkThumbprint(requestObject, rpConf),
|
|
109
|
+
requestObject.client_id,
|
|
110
|
+
requestObject.response_uri,
|
|
72
111
|
item.doctype,
|
|
73
112
|
item.keyTag,
|
|
74
113
|
[
|
|
@@ -90,10 +129,7 @@ export const prepareRemotePresentations: RemotePresentationApi["prepareRemotePre
|
|
|
90
129
|
}),
|
|
91
130
|
);
|
|
92
131
|
|
|
93
|
-
return {
|
|
94
|
-
generatedNonce,
|
|
95
|
-
presentations,
|
|
96
|
-
};
|
|
132
|
+
return { presentations };
|
|
97
133
|
};
|
|
98
134
|
|
|
99
135
|
export const sendAuthorizationResponse: RemotePresentationApi["sendAuthorizationResponse"] =
|
|
@@ -104,26 +140,12 @@ export const sendAuthorizationResponse: RemotePresentationApi["sendAuthorization
|
|
|
104
140
|
{ appFetch = fetch } = {},
|
|
105
141
|
) => {
|
|
106
142
|
try {
|
|
107
|
-
if (!rpConf && !requestObject.client_metadata) {
|
|
108
|
-
throw new IoWalletError(
|
|
109
|
-
"At least one of rpConf or requestObject.client_metadata must be provided to send the authorization response",
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// When the RP is not an OpenID Federation client, rpConf will be undefined
|
|
114
|
-
// so the keys are taken from the Request Object's client_metadata.
|
|
115
143
|
const clientMetadata = requestObject.client_metadata;
|
|
116
|
-
const jwks = rpConf?.jwks ?? clientMetadata?.jwks;
|
|
117
|
-
if (!jwks) {
|
|
118
|
-
throw new IoWalletError(
|
|
119
|
-
"Missing jwks in both rpConf and requestObject.client_metadata",
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
144
|
const rpJwks = {
|
|
123
145
|
encrypted_response_enc_values_supported:
|
|
124
146
|
rpConf?.encrypted_response_enc_values_supported ??
|
|
125
147
|
clientMetadata?.encrypted_response_enc_values_supported,
|
|
126
|
-
jwks,
|
|
148
|
+
jwks: getResponseEncryptionJwks(requestObject, rpConf),
|
|
127
149
|
};
|
|
128
150
|
|
|
129
151
|
const vp_token = remotePresentation.presentations.reduce(
|
|
@@ -135,6 +157,8 @@ export const sendAuthorizationResponse: RemotePresentationApi["sendAuthorization
|
|
|
135
157
|
);
|
|
136
158
|
|
|
137
159
|
const { jarm } = await sdkCreateAuthorizationResponse({
|
|
160
|
+
// Must match the alg used to compute the mdoc jwkThumbprint in prepareRemotePresentations
|
|
161
|
+
authorization_encrypted_response_alg: RESPONSE_ENCRYPTION_ALG,
|
|
138
162
|
callbacks: {
|
|
139
163
|
encryptJwe: partialCallbacks.encryptJwe,
|
|
140
164
|
generateRandom: partialCallbacks.generateRandom,
|
|
@@ -59,6 +59,8 @@ const AuthenticSource = z.object({
|
|
|
59
59
|
.array(z.object({ type: z.string(), value: z.string() }))
|
|
60
60
|
.optional(),
|
|
61
61
|
data_origin_l10n_id: z.string().optional(),
|
|
62
|
+
dataset_logo_uri: z.string().optional(),
|
|
63
|
+
"dataset_logo_uri#integrity": z.string().optional(),
|
|
62
64
|
homepage_uri: z.string().optional(),
|
|
63
65
|
id: z.string(),
|
|
64
66
|
logo_uri: z.string().optional(),
|
|
@@ -58,6 +58,8 @@ export const mapToCredentialsCatalogue = createMapper<
|
|
|
58
58
|
background_color: dataCapability?.background_color,
|
|
59
59
|
contacts: dataCapability?.contacts,
|
|
60
60
|
data_origin_l10n_id: dataCapability?.data_origin_l10n_id,
|
|
61
|
+
dataset_logo_uri: dataCapability?.logo_uri,
|
|
62
|
+
"dataset_logo_uri#integrity": dataCapability?.["logo_uri#integrity"],
|
|
61
63
|
id,
|
|
62
64
|
organization_code: ipa_code,
|
|
63
65
|
organization_name_l10n_id,
|
package/src/mdoc/index.ts
CHANGED
|
@@ -77,9 +77,13 @@ const verifyMdocSignature = async (coseSign1: string, cert: string) => {
|
|
|
77
77
|
if (!signatureCorrect) throw new Error("Invalid mDoc signature");
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
+
/**
|
|
81
|
+
* @param jwkThumbprint - base64url SHA-256 thumbprint (RFC 7638) of the key used to encrypt the authorization response,
|
|
82
|
+
* or null for an unencrypted response. It is part of the OpenID4VP session transcript.
|
|
83
|
+
*/
|
|
80
84
|
export const prepareVpTokenMdoc = async (
|
|
81
85
|
requestNonce: string,
|
|
82
|
-
|
|
86
|
+
jwkThumbprint: null | string,
|
|
83
87
|
clientId: string,
|
|
84
88
|
responseUri: string,
|
|
85
89
|
docType: string,
|
|
@@ -103,7 +107,7 @@ export const prepareVpTokenMdoc = async (
|
|
|
103
107
|
clientId,
|
|
104
108
|
responseUri,
|
|
105
109
|
requestNonce,
|
|
106
|
-
|
|
110
|
+
jwkThumbprint,
|
|
107
111
|
documents,
|
|
108
112
|
presentationFrame as ISO18013_7.AcceptedFields,
|
|
109
113
|
);
|