@pagopa/io-react-native-wallet 0.11.1 → 0.13.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/client/generated/wallet-provider.js +126 -0
- package/lib/commonjs/client/generated/wallet-provider.js.map +1 -0
- package/lib/commonjs/client/index.js +40 -0
- package/lib/commonjs/client/index.js.map +1 -0
- package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js +2 -1
- package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js.map +1 -1
- package/lib/commonjs/credential/issuance/03-start-credential-issuance.js +287 -0
- package/lib/commonjs/credential/issuance/03-start-credential-issuance.js.map +1 -0
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js +56 -83
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +88 -0
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/05-authorize-access.js +56 -33
- package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/commonjs/credential/issuance/06-obtain-credential.js +51 -78
- package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +21 -44
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/index.js +7 -0
- package/lib/commonjs/credential/issuance/index.js.map +1 -1
- package/lib/commonjs/credential/issuance/types.js +28 -0
- package/lib/commonjs/credential/issuance/types.js.map +1 -0
- package/lib/commonjs/index.js +10 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/pid/sd-jwt/converters.js +5 -9
- package/lib/commonjs/pid/sd-jwt/converters.js.map +1 -1
- package/lib/commonjs/pid/sd-jwt/types.js +3 -3
- package/lib/commonjs/pid/sd-jwt/types.js.map +1 -1
- package/lib/commonjs/sd-jwt/__test__/converters.test.js +1 -1
- package/lib/commonjs/sd-jwt/__test__/converters.test.js.map +1 -1
- package/lib/commonjs/sd-jwt/__test__/index.test.js +30 -43
- package/lib/commonjs/sd-jwt/__test__/index.test.js.map +1 -1
- package/lib/commonjs/sd-jwt/__test__/types.test.js +16 -24
- package/lib/commonjs/sd-jwt/__test__/types.test.js.map +1 -1
- package/lib/commonjs/sd-jwt/index.js +3 -9
- package/lib/commonjs/sd-jwt/index.js.map +1 -1
- package/lib/commonjs/sd-jwt/types.js +11 -16
- package/lib/commonjs/sd-jwt/types.js.map +1 -1
- package/lib/commonjs/trust/types.js +70 -29
- package/lib/commonjs/trust/types.js.map +1 -1
- package/lib/commonjs/utils/auth.js +44 -0
- package/lib/commonjs/utils/auth.js.map +1 -0
- package/lib/commonjs/utils/errors.js +104 -1
- package/lib/commonjs/utils/errors.js.map +1 -1
- package/lib/commonjs/utils/integrity.js +2 -0
- package/lib/commonjs/utils/integrity.js.map +1 -0
- package/lib/commonjs/utils/misc.js +34 -1
- package/lib/commonjs/utils/misc.js.map +1 -1
- package/lib/commonjs/utils/par.js +23 -15
- package/lib/commonjs/utils/par.js.map +1 -1
- package/lib/commonjs/utils/pop.js +33 -0
- package/lib/commonjs/utils/pop.js.map +1 -0
- package/lib/commonjs/wallet-instance/index.js +29 -0
- package/lib/commonjs/wallet-instance/index.js.map +1 -0
- package/lib/commonjs/wallet-instance-attestation/issuing.js +62 -65
- package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/commonjs/wallet-instance-attestation/types.js +8 -8
- package/lib/commonjs/wallet-instance-attestation/types.js.map +1 -1
- package/lib/module/client/generated/wallet-provider.js +102 -0
- package/lib/module/client/generated/wallet-provider.js.map +1 -0
- package/lib/module/client/index.js +33 -0
- package/lib/module/client/index.js.map +1 -0
- package/lib/module/credential/issuance/02-evaluate-issuer-trust.js +2 -1
- package/lib/module/credential/issuance/02-evaluate-issuer-trust.js.map +1 -1
- package/lib/module/credential/issuance/03-start-credential-issuance.js +276 -0
- package/lib/module/credential/issuance/03-start-credential-issuance.js.map +1 -0
- package/lib/module/credential/issuance/03-start-user-authorization.js +56 -80
- package/lib/module/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/04-complete-user-authorization.js +85 -1
- package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/05-authorize-access.js +54 -33
- package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/module/credential/issuance/06-obtain-credential.js +50 -75
- package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js +21 -44
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/module/credential/issuance/index.js +2 -1
- package/lib/module/credential/issuance/index.js.map +1 -1
- package/lib/module/credential/issuance/types.js +18 -0
- package/lib/module/credential/issuance/types.js.map +1 -0
- package/lib/module/index.js +3 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/pid/sd-jwt/converters.js +5 -9
- package/lib/module/pid/sd-jwt/converters.js.map +1 -1
- package/lib/module/pid/sd-jwt/types.js +3 -3
- package/lib/module/pid/sd-jwt/types.js.map +1 -1
- package/lib/module/sd-jwt/__test__/converters.test.js +1 -1
- package/lib/module/sd-jwt/__test__/converters.test.js.map +1 -1
- package/lib/module/sd-jwt/__test__/index.test.js +30 -43
- package/lib/module/sd-jwt/__test__/index.test.js.map +1 -1
- package/lib/module/sd-jwt/__test__/types.test.js +16 -24
- package/lib/module/sd-jwt/__test__/types.test.js.map +1 -1
- package/lib/module/sd-jwt/index.js +3 -9
- package/lib/module/sd-jwt/index.js.map +1 -1
- package/lib/module/sd-jwt/types.js +11 -16
- package/lib/module/sd-jwt/types.js.map +1 -1
- package/lib/module/trust/types.js +70 -29
- package/lib/module/trust/types.js.map +1 -1
- package/lib/module/utils/auth.js +35 -0
- package/lib/module/utils/auth.js.map +1 -0
- package/lib/module/utils/errors.js +98 -0
- package/lib/module/utils/errors.js.map +1 -1
- package/lib/module/utils/integrity.js +2 -0
- package/lib/module/utils/integrity.js.map +1 -0
- package/lib/module/utils/misc.js +31 -0
- package/lib/module/utils/misc.js.map +1 -1
- package/lib/module/utils/par.js +24 -16
- package/lib/module/utils/par.js.map +1 -1
- package/lib/module/utils/pop.js +24 -0
- package/lib/module/utils/pop.js.map +1 -0
- package/lib/module/wallet-instance/index.js +23 -0
- package/lib/module/wallet-instance/index.js.map +1 -0
- package/lib/module/wallet-instance-attestation/issuing.js +63 -67
- package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/module/wallet-instance-attestation/types.js +8 -8
- package/lib/module/wallet-instance-attestation/types.js.map +1 -1
- package/lib/typescript/client/generated/wallet-provider.d.ts +264 -0
- package/lib/typescript/client/generated/wallet-provider.d.ts.map +1 -0
- package/lib/typescript/client/index.d.ts +7 -0
- package/lib/typescript/client/index.d.ts.map +1 -0
- package/lib/typescript/credential/issuance/01-start-flow.d.ts +1 -0
- package/lib/typescript/credential/issuance/01-start-flow.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts +2 -1
- package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/03-start-credential-issuance.d.ts +41 -0
- package/lib/typescript/credential/issuance/03-start-credential-issuance.d.ts.map +1 -0
- package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts +23 -18
- package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts +24 -12
- package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/05-authorize-access.d.ts +22 -16
- package/lib/typescript/credential/issuance/05-authorize-access.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/06-obtain-credential.d.ts +19 -26
- package/lib/typescript/credential/issuance/06-obtain-credential.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts +10 -15
- package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/index.d.ts +3 -4
- package/lib/typescript/credential/issuance/index.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/types.d.ts +63 -0
- package/lib/typescript/credential/issuance/types.d.ts.map +1 -0
- package/lib/typescript/credential/presentation/types.d.ts +6 -6
- package/lib/typescript/index.d.ts +6 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/pid/sd-jwt/converters.d.ts.map +1 -1
- package/lib/typescript/pid/sd-jwt/types.d.ts +36 -36
- package/lib/typescript/pid/sd-jwt/types.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/index.d.ts +40 -68
- package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/types.d.ts +64 -121
- package/lib/typescript/sd-jwt/types.d.ts.map +1 -1
- package/lib/typescript/trust/index.d.ts +150 -48
- package/lib/typescript/trust/index.d.ts.map +1 -1
- package/lib/typescript/trust/types.d.ts +2838 -1740
- package/lib/typescript/trust/types.d.ts.map +1 -1
- package/lib/typescript/utils/auth.d.ts +52 -0
- package/lib/typescript/utils/auth.d.ts.map +1 -0
- package/lib/typescript/utils/errors.d.ts +48 -0
- package/lib/typescript/utils/errors.d.ts.map +1 -1
- package/lib/typescript/utils/integrity.d.ts +21 -0
- package/lib/typescript/utils/integrity.d.ts.map +1 -0
- package/lib/typescript/utils/misc.d.ts +18 -0
- package/lib/typescript/utils/misc.d.ts.map +1 -1
- package/lib/typescript/utils/par.d.ts +8 -31
- package/lib/typescript/utils/par.d.ts.map +1 -1
- package/lib/typescript/utils/pop.d.ts +26 -0
- package/lib/typescript/utils/pop.d.ts.map +1 -0
- package/lib/typescript/wallet-instance/index.d.ts +7 -0
- package/lib/typescript/wallet-instance/index.d.ts.map +1 -0
- package/lib/typescript/wallet-instance-attestation/issuing.d.ts +17 -4
- package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/types.d.ts +64 -64
- package/lib/typescript/wallet-instance-attestation/types.d.ts.map +1 -1
- package/package.json +9 -5
- package/src/client/generated/wallet-provider.ts +173 -0
- package/src/client/index.ts +53 -0
- package/src/credential/issuance/01-start-flow.ts +1 -0
- package/src/credential/issuance/02-evaluate-issuer-trust.ts +2 -1
- package/src/credential/issuance/03-start-credential-issuance.ts +407 -0
- package/src/credential/issuance/03-start-user-authorization.ts +91 -92
- package/src/credential/issuance/04-complete-user-authorization.ts +114 -13
- package/src/credential/issuance/05-authorize-access.ts +74 -49
- package/src/credential/issuance/06-obtain-credential.ts +77 -111
- package/src/credential/issuance/07-verify-and-parse-credential.ts +30 -67
- package/src/credential/issuance/index.ts +6 -4
- package/src/credential/issuance/types.ts +25 -0
- package/src/index.ts +8 -0
- package/src/pid/sd-jwt/converters.ts +5 -11
- package/src/pid/sd-jwt/types.ts +8 -6
- package/src/sd-jwt/__test__/converters.test.ts +1 -1
- package/src/sd-jwt/__test__/index.test.ts +45 -74
- package/src/sd-jwt/__test__/types.test.ts +21 -33
- package/src/sd-jwt/index.ts +3 -12
- package/src/sd-jwt/types.ts +17 -22
- package/src/trust/types.ts +64 -32
- package/src/utils/auth.ts +37 -0
- package/src/utils/errors.ts +112 -0
- package/src/utils/integrity.ts +23 -0
- package/src/utils/misc.ts +43 -0
- package/src/utils/par.ts +29 -17
- package/src/utils/pop.ts +34 -0
- package/src/wallet-instance/index.ts +29 -0
- package/src/wallet-instance-attestation/issuing.ts +101 -97
- package/src/wallet-instance-attestation/types.ts +12 -8
- package/lib/commonjs/credential/issuance/07-confirm-credential.js +0 -6
- package/lib/commonjs/credential/issuance/07-confirm-credential.js.map +0 -1
- package/lib/commonjs/credential/issuance/08-confirm-credential.js +0 -6
- package/lib/commonjs/credential/issuance/08-confirm-credential.js.map +0 -1
- package/lib/module/credential/issuance/07-confirm-credential.js +0 -2
- package/lib/module/credential/issuance/07-confirm-credential.js.map +0 -1
- package/lib/module/credential/issuance/08-confirm-credential.js +0 -2
- package/lib/module/credential/issuance/08-confirm-credential.js.map +0 -1
- package/lib/typescript/credential/issuance/07-confirm-credential.d.ts +0 -11
- package/lib/typescript/credential/issuance/07-confirm-credential.d.ts.map +0 -1
- package/lib/typescript/credential/issuance/08-confirm-credential.d.ts +0 -11
- package/lib/typescript/credential/issuance/08-confirm-credential.d.ts.map +0 -1
- package/src/credential/issuance/07-confirm-credential.ts +0 -14
- package/src/credential/issuance/08-confirm-credential.ts +0 -14
|
@@ -1,77 +1,68 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type CryptoContext,
|
|
3
|
-
decode as decodeJwt,
|
|
4
|
-
} from "@pagopa/io-react-native-jwt";
|
|
5
|
-
import { verify as verifyJwt } from "@pagopa/io-react-native-jwt";
|
|
1
|
+
import { type CryptoContext } from "@pagopa/io-react-native-jwt";
|
|
6
2
|
import { SignJWT, thumbprint } from "@pagopa/io-react-native-jwt";
|
|
3
|
+
import { z } from "zod";
|
|
7
4
|
import { JWK, fixBase64EncodingOnKey } from "../utils/jwk";
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
|
|
5
|
+
import { getWalletProviderClient } from "../client";
|
|
6
|
+
import type { IntegrityContext } from "..";
|
|
7
|
+
import {
|
|
8
|
+
WalletProviderResponseError,
|
|
9
|
+
WalletInstanceRevokedError,
|
|
10
|
+
WalletInstanceNotFoundError,
|
|
11
|
+
WalletInstanceAttestationIssuingError,
|
|
12
|
+
} from "../utils/errors";
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Getter for an attestation request. The attestation request is a JWT that will be sent to the Wallet Provider to request a Wallet Instance Attestation.
|
|
16
|
+
*
|
|
17
|
+
* @param challenge - The nonce received from the Wallet Provider which is part of the signed clientData
|
|
18
|
+
* @param wiaCryptoContext - The key pair associated with the WIA. Will be use to prove the ownership of the attestation
|
|
19
|
+
* @param integrityContext - The integrity context which exposes a set of functions to interact with the device integrity service
|
|
20
|
+
* @param walletProviderBaseUrl - Base url for the Wallet Provider
|
|
21
|
+
* @returns A JWT containing the attestation request
|
|
22
|
+
*/
|
|
23
|
+
export async function getAttestationRequest(
|
|
24
|
+
challenge: string,
|
|
14
25
|
wiaCryptoContext: CryptoContext,
|
|
15
|
-
|
|
26
|
+
integrityContext: IntegrityContext,
|
|
27
|
+
walletProviderBaseUrl: string
|
|
16
28
|
): Promise<string> {
|
|
17
29
|
const jwk = await wiaCryptoContext.getPublicKey();
|
|
18
30
|
const parsedJwk = JWK.parse(jwk);
|
|
19
31
|
const keyThumbprint = await thumbprint(parsedJwk);
|
|
20
32
|
const publicKey = { ...parsedJwk, kid: keyThumbprint };
|
|
21
33
|
|
|
34
|
+
const clientData = {
|
|
35
|
+
challenge,
|
|
36
|
+
jwk_thumbprint: keyThumbprint,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const hardwareKeyTag = integrityContext.getHardwareKeyTag();
|
|
40
|
+
const { signature, authenticatorData } =
|
|
41
|
+
await integrityContext.getHardwareSignatureWithAuthData(
|
|
42
|
+
JSON.stringify(clientData)
|
|
43
|
+
);
|
|
44
|
+
|
|
22
45
|
return new SignJWT(wiaCryptoContext)
|
|
23
46
|
.setPayload({
|
|
24
47
|
iss: keyThumbprint,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
48
|
+
sub: walletProviderBaseUrl,
|
|
49
|
+
challenge,
|
|
50
|
+
hardware_signature: signature,
|
|
51
|
+
integrity_assertion: authenticatorData,
|
|
52
|
+
hardware_key_tag: hardwareKeyTag,
|
|
28
53
|
cnf: {
|
|
29
54
|
jwk: fixBase64EncodingOnKey(publicKey),
|
|
30
55
|
},
|
|
31
56
|
})
|
|
32
57
|
.setProtectedHeader({
|
|
33
58
|
kid: publicKey.kid,
|
|
34
|
-
typ: "
|
|
59
|
+
typ: "war+jwt",
|
|
35
60
|
})
|
|
36
61
|
.setIssuedAt()
|
|
37
62
|
.setExpirationTime("1h")
|
|
38
63
|
.sign();
|
|
39
64
|
}
|
|
40
65
|
|
|
41
|
-
/**
|
|
42
|
-
* Validate a Wallet Instance Attestation token.
|
|
43
|
-
* Either return true or throw an exception.
|
|
44
|
-
*
|
|
45
|
-
* @param wia Signed Wallet Instance Attestation token
|
|
46
|
-
* @param walletProviderEntityConfiguration Entity Configuration object for the issuing Wallet Provider
|
|
47
|
-
* @returns The token is valid
|
|
48
|
-
* @throws {WalletInstanceAttestationIssuingError} When the received token fails to validate. This can happen due to invalid signature, expired token or malformed JWT token.
|
|
49
|
-
*/
|
|
50
|
-
async function verifyWalletInstanceAttestation(
|
|
51
|
-
wia: string,
|
|
52
|
-
walletProviderEntityConfiguration: WalletProviderEntityConfiguration
|
|
53
|
-
): Promise<true> {
|
|
54
|
-
const {
|
|
55
|
-
payload: {
|
|
56
|
-
sub,
|
|
57
|
-
metadata: {
|
|
58
|
-
wallet_provider: {
|
|
59
|
-
jwks: { keys },
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
} = walletProviderEntityConfiguration;
|
|
64
|
-
return verifyJwt(wia, keys, { issuer: sub })
|
|
65
|
-
.then((_) => true as const)
|
|
66
|
-
.catch((ex) => {
|
|
67
|
-
const reason = ex && ex instanceof Error ? ex.message : "unknown reason";
|
|
68
|
-
throw new WalletInstanceAttestationIssuingError(
|
|
69
|
-
"Unable to validate received wallet instance attestation",
|
|
70
|
-
reason
|
|
71
|
-
);
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
66
|
/**
|
|
76
67
|
* Request a Wallet Instance Attestation (WIA) to the Wallet provider
|
|
77
68
|
*
|
|
@@ -79,61 +70,74 @@ async function verifyWalletInstanceAttestation(
|
|
|
79
70
|
* @param params.appFetch (optional) Http client
|
|
80
71
|
* @param walletProviderBaseUrl Base url for the Wallet Provider
|
|
81
72
|
* @returns The retrieved Wallet Instance Attestation token
|
|
73
|
+
* @throws {WalletInstanceRevokedError} The Wallet Instance was revoked
|
|
74
|
+
* @throws {WalletInstanceNotFoundError} The Wallet Instance does not exist
|
|
82
75
|
*/
|
|
83
|
-
export const getAttestation =
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
76
|
+
export const getAttestation = async ({
|
|
77
|
+
wiaCryptoContext,
|
|
78
|
+
integrityContext,
|
|
79
|
+
walletProviderBaseUrl,
|
|
80
|
+
appFetch = fetch,
|
|
81
|
+
}: {
|
|
82
|
+
wiaCryptoContext: CryptoContext;
|
|
83
|
+
integrityContext: IntegrityContext;
|
|
84
|
+
walletProviderBaseUrl: string;
|
|
85
|
+
appFetch?: GlobalFetch["fetch"];
|
|
86
|
+
}): Promise<string> => {
|
|
87
|
+
const api = getWalletProviderClient({
|
|
88
|
+
walletProviderBaseUrl,
|
|
89
|
+
appFetch,
|
|
90
|
+
});
|
|
98
91
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
payload: decodedRequest.payload,
|
|
102
|
-
header: decodedRequest.protectedHeader,
|
|
103
|
-
});
|
|
104
|
-
const publicKey = parsedRequest.payload.cnf.jwk;
|
|
92
|
+
// 1. Get nonce from backend
|
|
93
|
+
const challenge = await api.get("/nonce").then((response) => response.nonce);
|
|
105
94
|
|
|
106
|
-
|
|
95
|
+
// 2. Get a signed attestation request
|
|
96
|
+
const signedAttestationRequest = await getAttestationRequest(
|
|
97
|
+
challenge,
|
|
98
|
+
wiaCryptoContext,
|
|
99
|
+
integrityContext,
|
|
100
|
+
walletProviderBaseUrl
|
|
101
|
+
);
|
|
107
102
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
assertion: signedAttestationRequest,
|
|
115
|
-
};
|
|
116
|
-
const response = await appFetch(tokenUrl, {
|
|
117
|
-
method: "POST",
|
|
118
|
-
headers: {
|
|
119
|
-
"Content-Type": "application/json",
|
|
103
|
+
// 3. Request WIA
|
|
104
|
+
const wia = await api
|
|
105
|
+
.post("/token", {
|
|
106
|
+
body: {
|
|
107
|
+
grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
|
|
108
|
+
assertion: signedAttestationRequest,
|
|
120
109
|
},
|
|
121
|
-
|
|
122
|
-
|
|
110
|
+
})
|
|
111
|
+
.then((result) => z.string().parse(result))
|
|
112
|
+
.catch(handleAttestationCreationError);
|
|
123
113
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
"Unable to obtain wallet instance attestation from wallet provider",
|
|
127
|
-
`Response code: ${response.status}`
|
|
128
|
-
);
|
|
129
|
-
}
|
|
114
|
+
return wia;
|
|
115
|
+
};
|
|
130
116
|
|
|
131
|
-
|
|
117
|
+
const handleAttestationCreationError = (e: unknown) => {
|
|
118
|
+
if (!(e instanceof WalletProviderResponseError)) {
|
|
119
|
+
throw e;
|
|
120
|
+
}
|
|
132
121
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
122
|
+
if (e.statusCode === 403) {
|
|
123
|
+
throw new WalletInstanceRevokedError(
|
|
124
|
+
"Unable to get an attestation for a revoked Wallet Instance",
|
|
125
|
+
e.claim,
|
|
126
|
+
e.reason
|
|
136
127
|
);
|
|
128
|
+
}
|
|
137
129
|
|
|
138
|
-
|
|
139
|
-
|
|
130
|
+
if (e.statusCode === 404) {
|
|
131
|
+
throw new WalletInstanceNotFoundError(
|
|
132
|
+
"Unable to get an attestation for a Wallet Instance that does not exist",
|
|
133
|
+
e.claim,
|
|
134
|
+
e.reason
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
throw new WalletInstanceAttestationIssuingError(
|
|
139
|
+
`Unable to obtain wallet instance attestation [response status code: ${e.statusCode}]`,
|
|
140
|
+
e.claim,
|
|
141
|
+
e.reason
|
|
142
|
+
);
|
|
143
|
+
};
|
|
@@ -33,7 +33,7 @@ export const WalletInstanceAttestationRequestJwt = z.object({
|
|
|
33
33
|
header: z.intersection(
|
|
34
34
|
Jwt.shape.header,
|
|
35
35
|
z.object({
|
|
36
|
-
typ: z.literal("
|
|
36
|
+
typ: z.literal("war+jwt"),
|
|
37
37
|
})
|
|
38
38
|
),
|
|
39
39
|
payload: z.intersection(
|
|
@@ -60,16 +60,20 @@ export const WalletInstanceAttestationJwt = z.object({
|
|
|
60
60
|
Jwt.shape.payload,
|
|
61
61
|
z.object({
|
|
62
62
|
sub: z.string(),
|
|
63
|
-
|
|
63
|
+
aal: z.string(),
|
|
64
64
|
authorization_endpoint: z.string(),
|
|
65
65
|
response_types_supported: z.array(z.string()),
|
|
66
66
|
vp_formats_supported: z.object({
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
67
|
+
"vc+sd-jwt": z
|
|
68
|
+
.object({
|
|
69
|
+
"sd-jwt_alg_values": z.array(z.string()),
|
|
70
|
+
})
|
|
71
|
+
.optional(),
|
|
72
|
+
"vp+sd-jwt": z
|
|
73
|
+
.object({
|
|
74
|
+
"sd-jwt_alg_values": z.array(z.string()),
|
|
75
|
+
})
|
|
76
|
+
.optional(),
|
|
73
77
|
}),
|
|
74
78
|
request_object_signing_alg_values_supported: z.array(z.string()),
|
|
75
79
|
presentation_definition_uri_supported: z.boolean(),
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["credential/issuance/07-confirm-credential.ts"],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["credential/issuance/08-confirm-credential.ts"],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["credential/issuance/07-confirm-credential.ts"],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["credential/issuance/08-confirm-credential.ts"],"mappings":""}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ObtainCredential } from "./06-obtain-credential";
|
|
2
|
-
import type { Out } from "../../utils/misc";
|
|
3
|
-
/**
|
|
4
|
-
* The end of the issuing flow.
|
|
5
|
-
* The User accepted the Credential and it can be stored in the device according to the app implementation preferences.
|
|
6
|
-
* To be implemented.
|
|
7
|
-
*
|
|
8
|
-
* @returns The type of the Credential to be issued and the url of the Issuer
|
|
9
|
-
*/
|
|
10
|
-
export type ConfirmCredential = (credential: Out<ObtainCredential>["credential"], format: Out<ObtainCredential>["format"]) => Promise<void>;
|
|
11
|
-
//# sourceMappingURL=07-confirm-credential.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"07-confirm-credential.d.ts","sourceRoot":"","sources":["../../../../src/credential/issuance/07-confirm-credential.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAC9B,UAAU,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC,YAAY,CAAC,EAC/C,MAAM,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,KACpC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ObtainCredential } from "./06-obtain-credential";
|
|
2
|
-
import type { Out } from "../../utils/misc";
|
|
3
|
-
/**
|
|
4
|
-
* The end of the issuing flow.
|
|
5
|
-
* The User accepted the Credential and it can be stored in the device according to the app implementation preferences.
|
|
6
|
-
* To be implemented.
|
|
7
|
-
*
|
|
8
|
-
* @returns The type of the Credential to be issued and the url of the Issuer
|
|
9
|
-
*/
|
|
10
|
-
export type ConfirmCredential = (credential: Out<ObtainCredential>["credential"], format: Out<ObtainCredential>["format"]) => Promise<void>;
|
|
11
|
-
//# sourceMappingURL=08-confirm-credential.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"08-confirm-credential.d.ts","sourceRoot":"","sources":["../../../../src/credential/issuance/08-confirm-credential.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAC9B,UAAU,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC,YAAY,CAAC,EAC/C,MAAM,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,KACpC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { ObtainCredential } from "./06-obtain-credential";
|
|
2
|
-
import type { Out } from "../../utils/misc";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* The end of the issuing flow.
|
|
6
|
-
* The User accepted the Credential and it can be stored in the device according to the app implementation preferences.
|
|
7
|
-
* To be implemented.
|
|
8
|
-
*
|
|
9
|
-
* @returns The type of the Credential to be issued and the url of the Issuer
|
|
10
|
-
*/
|
|
11
|
-
export type ConfirmCredential = (
|
|
12
|
-
credential: Out<ObtainCredential>["credential"],
|
|
13
|
-
format: Out<ObtainCredential>["format"]
|
|
14
|
-
) => Promise<void>;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { ObtainCredential } from "./06-obtain-credential";
|
|
2
|
-
import type { Out } from "../../utils/misc";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* The end of the issuing flow.
|
|
6
|
-
* The User accepted the Credential and it can be stored in the device according to the app implementation preferences.
|
|
7
|
-
* To be implemented.
|
|
8
|
-
*
|
|
9
|
-
* @returns The type of the Credential to be issued and the url of the Issuer
|
|
10
|
-
*/
|
|
11
|
-
export type ConfirmCredential = (
|
|
12
|
-
credential: Out<ObtainCredential>["credential"],
|
|
13
|
-
format: Out<ObtainCredential>["format"]
|
|
14
|
-
) => Promise<void>;
|