@pagopa/io-react-native-wallet 3.8.3 → 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/key-attestation/v1.4.6/issuing.js +14 -1
- package/lib/commonjs/key-attestation/v1.4.6/issuing.js.map +1 -1
- package/lib/commonjs/mdoc/index.js +7 -2
- package/lib/commonjs/mdoc/index.js.map +1 -1
- package/lib/commonjs/utils/error-codes.js +5 -1
- package/lib/commonjs/utils/error-codes.js.map +1 -1
- package/lib/commonjs/wallet-instance-attestation/common/errors.js +32 -0
- package/lib/commonjs/wallet-instance-attestation/common/errors.js.map +1 -0
- package/lib/commonjs/wallet-instance-attestation/v1.0.0/issuing.js +2 -21
- package/lib/commonjs/wallet-instance-attestation/v1.0.0/issuing.js.map +1 -1
- package/lib/commonjs/wallet-instance-attestation/v1.4.6/issuing.js +2 -1
- package/lib/commonjs/wallet-instance-attestation/v1.4.6/issuing.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/key-attestation/v1.4.6/issuing.js +15 -2
- package/lib/module/key-attestation/v1.4.6/issuing.js.map +1 -1
- package/lib/module/mdoc/index.js +7 -2
- package/lib/module/mdoc/index.js.map +1 -1
- package/lib/module/utils/error-codes.js +5 -1
- package/lib/module/utils/error-codes.js.map +1 -1
- package/lib/module/wallet-instance-attestation/common/errors.js +28 -0
- package/lib/module/wallet-instance-attestation/common/errors.js.map +1 -0
- package/lib/module/wallet-instance-attestation/v1.0.0/issuing.js +1 -20
- package/lib/module/wallet-instance-attestation/v1.0.0/issuing.js.map +1 -1
- package/lib/module/wallet-instance-attestation/v1.4.6/issuing.js +2 -1
- package/lib/module/wallet-instance-attestation/v1.4.6/issuing.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/key-attestation/v1.4.6/issuing.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/commonjs/utils/error-codes.d.ts +5 -1
- package/lib/typescript/commonjs/utils/error-codes.d.ts.map +1 -1
- package/lib/typescript/commonjs/wallet-instance-attestation/common/errors.d.ts +5 -0
- package/lib/typescript/commonjs/wallet-instance-attestation/common/errors.d.ts.map +1 -0
- package/lib/typescript/commonjs/wallet-instance-attestation/v1.0.0/issuing.d.ts.map +1 -1
- package/lib/typescript/commonjs/wallet-instance-attestation/v1.4.6/issuing.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/key-attestation/v1.4.6/issuing.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/lib/typescript/module/utils/error-codes.d.ts +5 -1
- package/lib/typescript/module/utils/error-codes.d.ts.map +1 -1
- package/lib/typescript/module/wallet-instance-attestation/common/errors.d.ts +5 -0
- package/lib/typescript/module/wallet-instance-attestation/common/errors.d.ts.map +1 -0
- package/lib/typescript/module/wallet-instance-attestation/v1.0.0/issuing.d.ts.map +1 -1
- package/lib/typescript/module/wallet-instance-attestation/v1.4.6/issuing.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/key-attestation/v1.4.6/issuing.ts +31 -2
- package/src/mdoc/index.ts +6 -2
- package/src/utils/error-codes.ts +5 -1
- package/src/wallet-instance-attestation/common/errors.ts +41 -0
- package/src/wallet-instance-attestation/v1.0.0/issuing.ts +1 -37
- package/src/wallet-instance-attestation/v1.4.6/issuing.ts +3 -1
|
@@ -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,
|
|
@@ -5,7 +5,12 @@ import type { KeyAttestationCryptoContext } from "../../utils/crypto";
|
|
|
5
5
|
import type { KeyAttestationSupportedApi } from "../api";
|
|
6
6
|
|
|
7
7
|
import { getWalletProviderClient } from "../../client";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
IoWalletError,
|
|
10
|
+
ResponseErrorBuilder,
|
|
11
|
+
WalletProviderResponseError,
|
|
12
|
+
WalletProviderResponseErrorCodes,
|
|
13
|
+
} from "../../utils/errors";
|
|
9
14
|
import { fixBase64EncodingOnKey, JWK } from "../../utils/jwk";
|
|
10
15
|
import { Logger, LogLevel } from "../../utils/logging";
|
|
11
16
|
import { KeyAttestationResponse } from "./types";
|
|
@@ -141,7 +146,8 @@ export const getAttestation: KeyAttestationSupportedApi["getAttestation"] =
|
|
|
141
146
|
"Content-Type": "text/plain",
|
|
142
147
|
},
|
|
143
148
|
})
|
|
144
|
-
.then(KeyAttestationResponse.parse)
|
|
149
|
+
.then(KeyAttestationResponse.parse)
|
|
150
|
+
.catch(handleKeyAttestationCreationError);
|
|
145
151
|
|
|
146
152
|
Logger.log(
|
|
147
153
|
LogLevel.DEBUG,
|
|
@@ -153,3 +159,26 @@ export const getAttestation: KeyAttestationSupportedApi["getAttestation"] =
|
|
|
153
159
|
format: "jwt",
|
|
154
160
|
};
|
|
155
161
|
};
|
|
162
|
+
|
|
163
|
+
const handleKeyAttestationCreationError = (e: unknown) => {
|
|
164
|
+
Logger.log(
|
|
165
|
+
LogLevel.ERROR,
|
|
166
|
+
`An error occurred while calling the Key Attestation endpoint: ${e}`,
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
if (!(e instanceof WalletProviderResponseError)) {
|
|
170
|
+
throw e;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
throw new ResponseErrorBuilder(WalletProviderResponseError)
|
|
174
|
+
.handle(409, {
|
|
175
|
+
code: WalletProviderResponseErrorCodes.WalletInstanceIntegrityFailed,
|
|
176
|
+
message:
|
|
177
|
+
"Unable to get a key attestation for a Wallet Instance that failed the integrity check",
|
|
178
|
+
})
|
|
179
|
+
.handle("*", {
|
|
180
|
+
code: WalletProviderResponseErrorCodes.KeyAttestationIssuingFailed,
|
|
181
|
+
message: "Unable to obtain key attestation",
|
|
182
|
+
})
|
|
183
|
+
.buildFrom(e);
|
|
184
|
+
};
|
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
|
);
|
package/src/utils/error-codes.ts
CHANGED
|
@@ -24,7 +24,11 @@ export const IssuerResponseErrorCodes = {
|
|
|
24
24
|
|
|
25
25
|
export const WalletProviderResponseErrorCodes = {
|
|
26
26
|
/**
|
|
27
|
-
* An error code thrown when
|
|
27
|
+
* An error code thrown when an error occurs during the key attestation issuance.
|
|
28
|
+
*/
|
|
29
|
+
KeyAttestationIssuingFailed: "ERR_IO_KEY_ATTESTATION_ISSUING_FAILED",
|
|
30
|
+
/**
|
|
31
|
+
* An error code thrown when an error occurs during the wallet attestation issuance.
|
|
28
32
|
*/
|
|
29
33
|
WalletInstanceAttestationIssuingFailed:
|
|
30
34
|
"ERR_IO_WALLET_INSTANCE_ATTESTATION_ISSUING_FAILED",
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ResponseErrorBuilder,
|
|
3
|
+
WalletProviderResponseError,
|
|
4
|
+
WalletProviderResponseErrorCodes,
|
|
5
|
+
} from "../../utils/errors";
|
|
6
|
+
import { Logger, LogLevel } from "../../utils/logging";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Shared handler for errors that occur during Wallet Instance Attestation issuance.
|
|
10
|
+
*/
|
|
11
|
+
export const handleAttestationCreationError = (e: unknown) => {
|
|
12
|
+
Logger.log(
|
|
13
|
+
LogLevel.ERROR,
|
|
14
|
+
`An error occurred while calling the Wallet Attestation endpoint: ${e}`,
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
if (!(e instanceof WalletProviderResponseError)) {
|
|
18
|
+
throw e;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
throw new ResponseErrorBuilder(WalletProviderResponseError)
|
|
22
|
+
.handle(403, {
|
|
23
|
+
code: WalletProviderResponseErrorCodes.WalletInstanceRevoked,
|
|
24
|
+
message: "Unable to get an attestation for a revoked Wallet Instance",
|
|
25
|
+
})
|
|
26
|
+
.handle(404, {
|
|
27
|
+
code: WalletProviderResponseErrorCodes.WalletInstanceNotFound,
|
|
28
|
+
message:
|
|
29
|
+
"Unable to get an attestation for a Wallet Instance that does not exist",
|
|
30
|
+
})
|
|
31
|
+
.handle(409, {
|
|
32
|
+
code: WalletProviderResponseErrorCodes.WalletInstanceIntegrityFailed,
|
|
33
|
+
message:
|
|
34
|
+
"Unable to get an attestation for a Wallet Instance that failed the integrity check",
|
|
35
|
+
})
|
|
36
|
+
.handle("*", {
|
|
37
|
+
code: WalletProviderResponseErrorCodes.WalletInstanceAttestationIssuingFailed,
|
|
38
|
+
message: "Unable to obtain wallet instance attestation",
|
|
39
|
+
})
|
|
40
|
+
.buildFrom(e);
|
|
41
|
+
};
|
|
@@ -8,13 +8,9 @@ import type { IntegrityContext } from "../../utils/integrity";
|
|
|
8
8
|
import type { WalletInstanceAttestationApi } from "../api";
|
|
9
9
|
|
|
10
10
|
import { getWalletProviderClient } from "../../client";
|
|
11
|
-
import {
|
|
12
|
-
ResponseErrorBuilder,
|
|
13
|
-
WalletProviderResponseError,
|
|
14
|
-
WalletProviderResponseErrorCodes,
|
|
15
|
-
} from "../../utils/errors";
|
|
16
11
|
import { fixBase64EncodingOnKey, JWK } from "../../utils/jwk";
|
|
17
12
|
import { Logger, LogLevel } from "../../utils/logging";
|
|
13
|
+
import { handleAttestationCreationError } from "../common/errors";
|
|
18
14
|
import { mapToWalletAttestations } from "./mappers";
|
|
19
15
|
import { WalletAttestationResponse } from "./types";
|
|
20
16
|
|
|
@@ -120,35 +116,3 @@ export const getAttestation: WalletInstanceAttestationApi["getAttestation"] =
|
|
|
120
116
|
|
|
121
117
|
return mapToWalletAttestations(response);
|
|
122
118
|
};
|
|
123
|
-
|
|
124
|
-
const handleAttestationCreationError = (e: unknown) => {
|
|
125
|
-
Logger.log(
|
|
126
|
-
LogLevel.ERROR,
|
|
127
|
-
`An error occurred while calling /wallet-attestation endpoint: ${e}`,
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
if (!(e instanceof WalletProviderResponseError)) {
|
|
131
|
-
throw e;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
throw new ResponseErrorBuilder(WalletProviderResponseError)
|
|
135
|
-
.handle(403, {
|
|
136
|
-
code: WalletProviderResponseErrorCodes.WalletInstanceRevoked,
|
|
137
|
-
message: "Unable to get an attestation for a revoked Wallet Instance",
|
|
138
|
-
})
|
|
139
|
-
.handle(404, {
|
|
140
|
-
code: WalletProviderResponseErrorCodes.WalletInstanceNotFound,
|
|
141
|
-
message:
|
|
142
|
-
"Unable to get an attestation for a Wallet Instance that does not exist",
|
|
143
|
-
})
|
|
144
|
-
.handle(409, {
|
|
145
|
-
code: WalletProviderResponseErrorCodes.WalletInstanceIntegrityFailed,
|
|
146
|
-
message:
|
|
147
|
-
"Unable to get an attestation for a Wallet Instance that failed the integrity check",
|
|
148
|
-
})
|
|
149
|
-
.handle("*", {
|
|
150
|
-
code: WalletProviderResponseErrorCodes.WalletInstanceAttestationIssuingFailed,
|
|
151
|
-
message: "Unable to obtain wallet instance attestation",
|
|
152
|
-
})
|
|
153
|
-
.buildFrom(e);
|
|
154
|
-
};
|
|
@@ -12,6 +12,7 @@ import type { WalletAttestationRequestParams } from "../api/types";
|
|
|
12
12
|
import { getWalletProviderClient } from "../../client";
|
|
13
13
|
import { fixBase64EncodingOnKey, JWK } from "../../utils/jwk";
|
|
14
14
|
import { Logger, LogLevel } from "../../utils/logging";
|
|
15
|
+
import { handleAttestationCreationError } from "../common/errors";
|
|
15
16
|
import { WalletInstanceAttestationResponse } from "./types";
|
|
16
17
|
|
|
17
18
|
async function getAttestationRequest(
|
|
@@ -97,7 +98,8 @@ export const getAttestation: WalletInstanceAttestationApi["getAttestation"] =
|
|
|
97
98
|
"Content-Type": "text/plain",
|
|
98
99
|
},
|
|
99
100
|
})
|
|
100
|
-
.then(WalletInstanceAttestationResponse.parse)
|
|
101
|
+
.then(WalletInstanceAttestationResponse.parse)
|
|
102
|
+
.catch(handleAttestationCreationError);
|
|
101
103
|
|
|
102
104
|
Logger.log(
|
|
103
105
|
LogLevel.DEBUG,
|