@pagopa/io-react-native-wallet 0.12.0 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/commonjs/client/generated/wallet-provider.js +22 -22
- package/lib/commonjs/client/generated/wallet-provider.js.map +1 -1
- package/lib/commonjs/client/index.js +1 -2
- package/lib/commonjs/client/index.js.map +1 -1
- 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.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 +77 -2
- package/lib/commonjs/utils/errors.js.map +1 -1
- 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-attestation/issuing.js +17 -2
- package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/commonjs/wallet-instance-attestation/types.js +7 -7
- package/lib/commonjs/wallet-instance-attestation/types.js.map +1 -1
- package/lib/module/client/generated/wallet-provider.js +16 -19
- package/lib/module/client/generated/wallet-provider.js.map +1 -1
- package/lib/module/client/index.js +1 -2
- package/lib/module/client/index.js.map +1 -1
- 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.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/sd-jwt/verifier.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 +71 -0
- package/lib/module/utils/errors.js.map +1 -1
- 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-attestation/issuing.js +17 -2
- package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/module/wallet-instance-attestation/types.js +7 -7
- package/lib/module/wallet-instance-attestation/types.js.map +1 -1
- package/lib/typescript/client/generated/wallet-provider.d.ts +35 -13
- package/lib/typescript/client/generated/wallet-provider.d.ts.map +1 -1
- package/lib/typescript/client/index.d.ts.map +1 -1
- 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 +2 -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 +36 -1
- package/lib/typescript/utils/errors.d.ts.map +1 -1
- package/lib/typescript/utils/integrity.d.ts +1 -1
- 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-attestation/issuing.d.ts +2 -1
- package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/types.d.ts +59 -59
- package/lib/typescript/wallet-instance-attestation/types.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/client/generated/wallet-provider.ts +24 -21
- package/src/client/index.ts +3 -8
- 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 +2 -1
- 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 +85 -1
- package/src/utils/integrity.ts +1 -1
- 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-attestation/issuing.ts +39 -2
- package/src/wallet-instance-attestation/types.ts +11 -7
- 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
- package/src/sd-jwt/__test__/converters.test.js +0 -24
- package/src/sd-jwt/verifier.js +0 -12
@@ -4,24 +4,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.startUserAuthorization = void 0;
|
7
|
-
var
|
8
|
-
var
|
9
|
-
var _par = require("../../utils/par");
|
10
|
-
var _decoder = require("../../utils/decoder");
|
11
|
-
var _misc = require("../../utils/misc");
|
7
|
+
var _misc = require("../../../src/utils/misc");
|
8
|
+
var _par = require("../../../src/utils/par");
|
12
9
|
var _const = require("./const");
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
/**
|
11
|
+
* Ensures that the credential type requested is supported by the issuer and contained in the
|
12
|
+
* issuer configuration.
|
13
|
+
* @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
|
14
|
+
* @param credentialType The type of the credential to be requested returned by {@link startFlow}
|
15
|
+
* @param context.wiaCryptoContext The Wallet Instance's crypto context
|
16
|
+
* @param context.walletInstanceAttestation The Wallet Instance's attestation
|
17
|
+
* @param context.redirectUri The redirect URI which is the custom URL scheme that the Wallet Instance is registered to handle
|
18
|
+
* @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
|
19
|
+
* @returns The credential definition to be used in the request which includes the format and the type and its type
|
20
|
+
*/
|
16
21
|
const selectCredentialDefinition = (issuerConf, credentialType) => {
|
17
|
-
const
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
credential_definition: {
|
22
|
-
type: credentialType
|
23
|
-
},
|
24
|
-
format: e.format,
|
22
|
+
const credential_configurations_supported = issuerConf.openid_credential_issuer.credential_configurations_supported;
|
23
|
+
const [result] = Object.keys(credential_configurations_supported).filter(e => e.includes(credentialType)).map(e => ({
|
24
|
+
credential_configuration_id: credentialType,
|
25
|
+
format: credential_configurations_supported[e].format,
|
25
26
|
type: "openid_credential"
|
26
27
|
}));
|
27
28
|
if (!result) {
|
@@ -29,90 +30,62 @@ const selectCredentialDefinition = (issuerConf, credentialType) => {
|
|
29
30
|
}
|
30
31
|
return result;
|
31
32
|
};
|
32
|
-
const decodeAuthorizationResponse = async raw => {
|
33
|
-
const {
|
34
|
-
decodedJwt: {
|
35
|
-
payload
|
36
|
-
}
|
37
|
-
} = await (0, _decoder.getJwtFromFormPost)(raw);
|
38
33
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
*
|
51
|
-
* This workaround will be obsolete once the PID issuer fixes its implementation
|
52
|
-
*/
|
53
|
-
const CorrectShape = z.object({
|
54
|
-
request_uri: z.string()
|
55
|
-
});
|
56
|
-
const WrongShapeForPID = z.object({
|
57
|
-
code: z.string(),
|
58
|
-
state: z.string()
|
59
|
-
});
|
60
|
-
const [correct, wrong] = [CorrectShape.safeParse(payload), WrongShapeForPID.safeParse(payload)];
|
61
|
-
if (correct.success) {
|
62
|
-
return correct.data;
|
63
|
-
} else if (wrong.success) {
|
64
|
-
return {
|
65
|
-
request_uri: "https://fake-request-uri"
|
66
|
-
};
|
34
|
+
/**
|
35
|
+
* Ensures that the response mode requested is supported by the issuer and contained in the issuer configuration.
|
36
|
+
* @param issuerConf The issuer configuration
|
37
|
+
* @param credentialType The type of the credential to be requested
|
38
|
+
* @returns The response mode to be used in the request, "query" for PersonIdentificationData and "form_post.jwt" for all other types.
|
39
|
+
*/
|
40
|
+
const selectResponseMode = (issuerConf, credentialType) => {
|
41
|
+
const responseModeSupported = issuerConf.oauth_authorization_server.response_modes_supported;
|
42
|
+
const responseMode = credentialType === "PersonIdentificationData" ? "query" : "form_post.jwt";
|
43
|
+
if (!responseModeSupported.includes(responseMode)) {
|
44
|
+
throw new Error(`No response mode support the type '${credentialType}'`);
|
67
45
|
}
|
68
|
-
|
46
|
+
return responseMode;
|
69
47
|
};
|
48
|
+
|
70
49
|
/**
|
71
|
-
*
|
72
|
-
*
|
73
|
-
*
|
74
|
-
*
|
75
|
-
*
|
76
|
-
*
|
77
|
-
*
|
78
|
-
*
|
79
|
-
*
|
80
|
-
*
|
81
|
-
*
|
82
|
-
*
|
83
|
-
* @
|
50
|
+
* WARNING: This function must be called after {@link evaluateIssuerTrust} and {@link startFlow}. The next steam is {@link compeUserAuthorizationWithQueryMode} or {@link compeUserAuthorizationWithFormPostJwtMode}
|
51
|
+
* Creates and sends a PAR request to the /as/par endpoint of the authroization server.
|
52
|
+
* This starts the authentication flow to obtain an access token.
|
53
|
+
* This token enables the Wallet Instance to request a digital credential from the Credential Endpoint of the Credential Issuer.
|
54
|
+
* This is an HTTP POST request containing the Wallet Instance identifier (client id), the code challenge and challenge method as specified by PKCE according to RFC 9126
|
55
|
+
* along with the WTE and its proof of possession (WTE-PoP).
|
56
|
+
* Additionally, it includes a request object, which is a signed JWT encapsulating the type of digital credential requested (authorization_details),
|
57
|
+
* the application session identifier on the Wallet Instance side (state),
|
58
|
+
* the method (query or form_post.jwt) by which the Authorization Server
|
59
|
+
* should transmit the Authorization Response containing the authorization code issued upon the end user's authentication (response_mode)
|
60
|
+
* to the Wallet Instance's Token Endpoint to obtain the Access Token, and the redirect_uri of the Wallet Instance where the Authorization Response
|
61
|
+
* should be delivered. The redirect is achived by using a custom URL scheme that the Wallet Instance is registered to handle.
|
62
|
+
* @param issuerConf The issuer configuration
|
63
|
+
* @param credentialType The type of the credential to be requested returned by {@link selectCredentialDefinition}
|
64
|
+
* @param ctx The context object containing the Wallet Instance's cryptographic context, the Wallet Instance's attestation, the redirect URI and the fetch implementation
|
65
|
+
* @returns The URI to which the end user should be redirected to start the authentication flow, along with the client id, the code verifier and the credential definition
|
84
66
|
*/
|
85
67
|
const startUserAuthorization = async (issuerConf, credentialType, ctx) => {
|
86
68
|
const {
|
87
69
|
wiaCryptoContext,
|
88
70
|
walletInstanceAttestation,
|
89
|
-
|
90
|
-
additionalParams = {},
|
71
|
+
redirectUri,
|
91
72
|
appFetch = fetch
|
92
73
|
} = ctx;
|
93
74
|
const clientId = await wiaCryptoContext.getPublicKey().then(_ => _.kid);
|
94
|
-
const codeVerifier =
|
95
|
-
|
96
|
-
const
|
75
|
+
const codeVerifier = (0, _misc.generateRandomAlphaNumericString)(64);
|
76
|
+
const parEndpoint = issuerConf.oauth_authorization_server.pushed_authorization_request_endpoint;
|
77
|
+
const credentialDefinition = selectCredentialDefinition(issuerConf, credentialType);
|
78
|
+
const responseMode = selectResponseMode(issuerConf, credentialType);
|
97
79
|
const getPar = (0, _par.makeParRequest)({
|
98
80
|
wiaCryptoContext,
|
99
81
|
appFetch
|
100
82
|
});
|
101
|
-
const issuerRequestUri = await getPar(clientId, codeVerifier,
|
102
|
-
|
103
|
-
// Initialize authorization by requesting the authz request uri
|
104
|
-
const authzRequestEndpoint = issuerConf.openid_credential_issuer.authorization_endpoint;
|
105
|
-
const params = new URLSearchParams({
|
106
|
-
client_id: clientId,
|
107
|
-
request_uri: issuerRequestUri,
|
108
|
-
...additionalParams
|
109
|
-
});
|
110
|
-
const {
|
111
|
-
request_uri
|
112
|
-
} = await appFetch(`${authzRequestEndpoint}?${params}`).then((0, _misc.hasStatus)(200)).then(res => res.text()).then(decodeAuthorizationResponse);
|
83
|
+
const issuerRequestUri = await getPar(clientId, codeVerifier, redirectUri, responseMode, parEndpoint, walletInstanceAttestation, [credentialDefinition], _const.ASSERTION_TYPE);
|
113
84
|
return {
|
114
|
-
|
115
|
-
clientId
|
85
|
+
issuerRequestUri,
|
86
|
+
clientId,
|
87
|
+
codeVerifier,
|
88
|
+
credentialDefinition
|
116
89
|
};
|
117
90
|
};
|
118
91
|
exports.startUserAuthorization = startUserAuthorization;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["_misc","require","_par","_const","selectCredentialDefinition","issuerConf","credentialType","credential_configurations_supported","openid_credential_issuer","result","Object","keys","filter","e","includes","map","credential_configuration_id","format","type","Error","selectResponseMode","responseModeSupported","oauth_authorization_server","response_modes_supported","responseMode","startUserAuthorization","ctx","wiaCryptoContext","walletInstanceAttestation","redirectUri","appFetch","fetch","clientId","getPublicKey","then","_","kid","codeVerifier","generateRandomAlphaNumericString","parEndpoint","pushed_authorization_request_endpoint","credentialDefinition","getPar","makeParRequest","issuerRequestUri","ASSERTION_TYPE","exports"],"sourceRoot":"../../../../src","sources":["credential/issuance/03-start-user-authorization.ts"],"mappings":";;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AAOA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAkBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,0BAA0B,GAAGA,CACjCC,UAAkD,EAClDC,cAAgD,KACxB;EACxB,MAAMC,mCAAmC,GACvCF,UAAU,CAACG,wBAAwB,CAACD,mCAAmC;EAEzE,MAAM,CAACE,MAAM,CAAC,GAAGC,MAAM,CAACC,IAAI,CAACJ,mCAAmC,CAAC,CAC9DK,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAACC,QAAQ,CAACR,cAAc,CAAC,CAAC,CACzCS,GAAG,CAAEF,CAAC,KAAM;IACXG,2BAA2B,EAAEV,cAAc;IAC3CW,MAAM,EAAEV,mCAAmC,CAACM,CAAC,CAAC,CAAEI,MAAM;IACtDC,IAAI,EAAE;EACR,CAAC,CAAC,CAAC;EAEL,IAAI,CAACT,MAAM,EAAE;IACX,MAAM,IAAIU,KAAK,CAAE,mCAAkCb,cAAe,GAAE,CAAC;EACvE;EACA,OAAOG,MAAM;AACf,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,MAAMW,kBAAkB,GAAGA,CACzBf,UAAkD,EAClDC,cAAgD,KAC/B;EACjB,MAAMe,qBAAqB,GACzBhB,UAAU,CAACiB,0BAA0B,CAACC,wBAAwB;EAEhE,MAAMC,YAAY,GAChBlB,cAAc,KAAK,0BAA0B,GAAG,OAAO,GAAG,eAAe;EAE3E,IAAI,CAACe,qBAAqB,CAACP,QAAQ,CAACU,YAAY,CAAC,EAAE;IACjD,MAAM,IAAIL,KAAK,CAAE,sCAAqCb,cAAe,GAAE,CAAC;EAC1E;EAEA,OAAOkB,YAAY;AACrB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,sBAA8C,GAAG,MAAAA,CAC5DpB,UAAU,EACVC,cAAc,EACdoB,GAAG,KACA;EACH,MAAM;IACJC,gBAAgB;IAChBC,yBAAyB;IACzBC,WAAW;IACXC,QAAQ,GAAGC;EACb,CAAC,GAAGL,GAAG;EAEP,MAAMM,QAAQ,GAAG,MAAML,gBAAgB,CAACM,YAAY,CAAC,CAAC,CAACC,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACC,GAAG,CAAC;EACzE,MAAMC,YAAY,GAAG,IAAAC,sCAAgC,EAAC,EAAE,CAAC;EACzD,MAAMC,WAAW,GACflC,UAAU,CAACiB,0BAA0B,CAACkB,qCAAqC;EAC7E,MAAMC,oBAAoB,GAAGrC,0BAA0B,CACrDC,UAAU,EACVC,cACF,CAAC;EACD,MAAMkB,YAAY,GAAGJ,kBAAkB,CAACf,UAAU,EAAEC,cAAc,CAAC;EAEnE,MAAMoC,MAAM,GAAG,IAAAC,mBAAc,EAAC;IAAEhB,gBAAgB;IAAEG;EAAS,CAAC,CAAC;EAC7D,MAAMc,gBAAgB,GAAG,MAAMF,MAAM,CACnCV,QAAQ,EACRK,YAAY,EACZR,WAAW,EACXL,YAAY,EACZe,WAAW,EACXX,yBAAyB,EACzB,CAACa,oBAAoB,CAAC,EACtBI,qBACF,CAAC;EAED,OAAO;IAAED,gBAAgB;IAAEZ,QAAQ;IAAEK,YAAY;IAAEI;EAAqB,CAAC;AAC3E,CAAC;AAACK,OAAA,CAAArB,sBAAA,GAAAA,sBAAA"}
|
@@ -3,4 +3,92 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
+
exports.completeUserAuthorizationWithQueryMode = exports.completeUserAuthorizationWithFormPostJwtMode = void 0;
|
7
|
+
var _auth = require("../../../src/utils/auth");
|
8
|
+
var _misc = require("../../utils/misc");
|
9
|
+
var _parseUrl = _interopRequireDefault(require("parse-url"));
|
10
|
+
var _errors = require("../../utils/errors");
|
11
|
+
var _reactNative = require("react-native");
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
+
/**
|
14
|
+
* The interface of the phase to complete User authorization via strong identification when the response mode is "query" and the request credential is a PersonIdentificationData.
|
15
|
+
*/
|
16
|
+
|
17
|
+
/**
|
18
|
+
* WARNING: This function must be called after {@link startUserAuthorization}. The next function to be called is {@link authorizeAccess}.
|
19
|
+
* The interface of the phase to complete User authorization via strong identification when the response mode is "query" and the request credential is a PersonIdentificationData.
|
20
|
+
* It is used to complete the user authorization by catching the redirectSchema from the authorization server which then contains the authorization response.
|
21
|
+
* This function utilizes the authorization context to open an in-app browser capable of catching the redirectSchema to perform a get request to the authorization endpoint.
|
22
|
+
* If the 302 redirect happens and the redirectSchema is caught, the function will return the authorization response after parsing it from the query string.
|
23
|
+
* @param issuerRequestUri the URI of the issuer where the request is sent
|
24
|
+
* @param clientId Identifies the current client across all the requests of the issuing flow returned by {@link startUserAuthorization}
|
25
|
+
* @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
|
26
|
+
* @param authorizationContext The context to identify the user which will be used to start the authorization. It's needed only when requesting a PersonalIdentificationData credential. The implementantion should open an in-app browser capable of catching the redirectSchema.
|
27
|
+
* If not specified, the default browser is used
|
28
|
+
* @param idphint Unique identifier of the SPID IDP selected by the user
|
29
|
+
* @param redirectUri The url to reach to complete the user authorization which is the custom URL scheme that the Wallet Instance is registered to handle, usually a custom URL or deeplink
|
30
|
+
* @throws {AuthorizationError} if an error occurs during the authorization process
|
31
|
+
* @throws {AuthorizationIdpError} if an error occurs during the authorization process and the error is related to the IDP
|
32
|
+
* @returns the authorization response which contains code, state and iss
|
33
|
+
*/
|
34
|
+
const completeUserAuthorizationWithQueryMode = async (issuerRequestUri, clientId, issuerConf, idpHint, redirectUri, authorizationContext) => {
|
35
|
+
/**
|
36
|
+
* Starts the authorization flow which dependes on the response mode and the request credential.
|
37
|
+
* If the response mode is "query" the authorization flow is handled differently via the authorization context which opens an in-app browser capable of catching the redirectSchema.
|
38
|
+
* The form_post.jwt mode is not currently supported.
|
39
|
+
*/
|
40
|
+
const authzRequestEndpoint = issuerConf.oauth_authorization_server.authorization_endpoint;
|
41
|
+
const params = new URLSearchParams({
|
42
|
+
client_id: clientId,
|
43
|
+
request_uri: issuerRequestUri,
|
44
|
+
idphint: idpHint
|
45
|
+
});
|
46
|
+
const authUrl = `${authzRequestEndpoint}?${params}`;
|
47
|
+
var authRedirectUrl;
|
48
|
+
if (authorizationContext) {
|
49
|
+
const redirectSchema = new URL(redirectUri).protocol.replace(":", "");
|
50
|
+
authRedirectUrl = await authorizationContext.authorize(authUrl, redirectSchema).catch(e => {
|
51
|
+
throw new _errors.AuthorizationError(e.message);
|
52
|
+
});
|
53
|
+
} else {
|
54
|
+
// handler for redirectUri
|
55
|
+
_reactNative.Linking.addEventListener("url", _ref => {
|
56
|
+
let {
|
57
|
+
url
|
58
|
+
} = _ref;
|
59
|
+
if (url.includes(redirectUri)) {
|
60
|
+
authRedirectUrl = url;
|
61
|
+
}
|
62
|
+
});
|
63
|
+
const openAuthUrlInBrowser = _reactNative.Linking.openURL(authUrl);
|
64
|
+
|
65
|
+
/*
|
66
|
+
* Waits for 120 seconds for the identificationRedirectUrl variable to be set
|
67
|
+
* by the custom url handler. If the timeout is exceeded, throw an exception
|
68
|
+
*/
|
69
|
+
const unitAuthRedirectIsNotUndefined = (0, _misc.until)(() => authRedirectUrl !== undefined, 120);
|
70
|
+
await Promise.all([openAuthUrlInBrowser, unitAuthRedirectIsNotUndefined]);
|
71
|
+
if (authRedirectUrl === undefined) {
|
72
|
+
throw new _errors.AuthorizationError("Invalid authentication redirect url");
|
73
|
+
}
|
74
|
+
}
|
75
|
+
const urlParse = (0, _parseUrl.default)(authRedirectUrl);
|
76
|
+
const authRes = _auth.AuthorizationResultShape.safeParse(urlParse.query);
|
77
|
+
if (!authRes.success) {
|
78
|
+
const authErr = _auth.AuthorizationErrorShape.safeParse(urlParse.query);
|
79
|
+
if (!authErr.success) {
|
80
|
+
throw new _errors.AuthorizationError(authRes.error.message); // an error occured while parsing the result and the error
|
81
|
+
}
|
82
|
+
|
83
|
+
throw new _errors.AuthorizationIdpError(authErr.data.error, authErr.data.error_description);
|
84
|
+
}
|
85
|
+
return authRes.data;
|
86
|
+
};
|
87
|
+
|
88
|
+
// TODO: SIW-1120 implement generic credential issuance flow
|
89
|
+
exports.completeUserAuthorizationWithQueryMode = completeUserAuthorizationWithQueryMode;
|
90
|
+
const completeUserAuthorizationWithFormPostJwtMode = () => {
|
91
|
+
throw new Error("Not implemented");
|
92
|
+
};
|
93
|
+
exports.completeUserAuthorizationWithFormPostJwtMode = completeUserAuthorizationWithFormPostJwtMode;
|
6
94
|
//# sourceMappingURL=04-complete-user-authorization.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["credential/issuance/04-complete-user-authorization.ts"],"mappings":""}
|
1
|
+
{"version":3,"names":["_auth","require","_misc","_parseUrl","_interopRequireDefault","_errors","_reactNative","obj","__esModule","default","completeUserAuthorizationWithQueryMode","issuerRequestUri","clientId","issuerConf","idpHint","redirectUri","authorizationContext","authzRequestEndpoint","oauth_authorization_server","authorization_endpoint","params","URLSearchParams","client_id","request_uri","idphint","authUrl","authRedirectUrl","redirectSchema","URL","protocol","replace","authorize","catch","e","AuthorizationError","message","Linking","addEventListener","_ref","url","includes","openAuthUrlInBrowser","openURL","unitAuthRedirectIsNotUndefined","until","undefined","Promise","all","urlParse","parseUrl","authRes","AuthorizationResultShape","safeParse","query","success","authErr","AuthorizationErrorShape","error","AuthorizationIdpError","data","error_description","exports","completeUserAuthorizationWithFormPostJwtMode","Error"],"sourceRoot":"../../../../src","sources":["credential/issuance/04-complete-user-authorization.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,G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AA"}
|
@@ -4,60 +4,83 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.authorizeAccess = void 0;
|
7
|
+
var _misc = require("../../../src/utils/misc");
|
8
|
+
var _crypto = require("../../../src/utils/crypto");
|
9
|
+
var _dpop = require("../../../src/utils/dpop");
|
7
10
|
var _reactNativeUuid = _interopRequireDefault(require("react-native-uuid"));
|
8
|
-
var
|
9
|
-
var
|
10
|
-
var _misc = require("../../utils/misc");
|
11
|
+
var _pop = require("../../../src/utils/pop");
|
12
|
+
var WalletInstanceAttestation = _interopRequireWildcard(require("../../wallet-instance-attestation"));
|
11
13
|
var _const = require("./const");
|
14
|
+
var _types = require("./types");
|
15
|
+
var _errors = require("../../../src/utils/errors");
|
16
|
+
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); }
|
17
|
+
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; }
|
12
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
19
|
/**
|
14
|
-
*
|
15
|
-
*
|
16
|
-
*
|
17
|
-
*
|
18
|
-
* @param
|
19
|
-
* @param
|
20
|
-
* @param
|
20
|
+
* Creates and sends the DPoP Proof JWT to be presented with the authorization code to the /token endpoint of the authorization server
|
21
|
+
* for requesting the issuance of an access token bound to the public key of the Wallet Instance contained within the DPoP.
|
22
|
+
* This enables the Wallet Instance to request a digital credential.
|
23
|
+
* The DPoP Proof JWT is generated according to the section 4.3 of the DPoP RFC 9449 specification.
|
24
|
+
* @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
|
25
|
+
* @param code The authorization code returned by {@link completeUserAuthorizationWithQueryMode} or {@link completeUserAuthorizationWithFormPost}
|
26
|
+
* @param redirectUri The redirect URI which is the custom URL scheme that the Wallet Instance is registered to handle
|
27
|
+
* @param clientId The client id returned by {@link startUserAuthorization}
|
28
|
+
* @param codeVerifier The code verifier returned by {@link startUserAuthorization}
|
29
|
+
* @param context.walletInstanceAttestation The Wallet Instance's attestation
|
30
|
+
* @param context.wiaCryptoContext The Wallet Instance's crypto context
|
21
31
|
* @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
|
22
|
-
* @
|
32
|
+
* @throws {ValidationFailed} if an error occurs while parsing the token response
|
33
|
+
* @return The token response containing the access token along with the token request signed with DPoP which has to be used in the {@link obtainCredential} step.
|
23
34
|
*/
|
24
|
-
const authorizeAccess = async (issuerConf, code, clientId, context) => {
|
35
|
+
const authorizeAccess = async (issuerConf, code, clientId, redirectUri, codeVerifier, context) => {
|
25
36
|
const {
|
26
37
|
appFetch = fetch,
|
27
38
|
walletInstanceAttestation,
|
28
|
-
|
39
|
+
wiaCryptoContext
|
29
40
|
} = context;
|
30
|
-
const
|
31
|
-
|
41
|
+
const parEndpoint = issuerConf.oauth_authorization_server.pushed_authorization_request_endpoint;
|
42
|
+
const parUrl = new URL(parEndpoint);
|
43
|
+
const aud = `${parUrl.protocol}//${parUrl.hostname}`;
|
44
|
+
const iss = WalletInstanceAttestation.decode(walletInstanceAttestation).payload.cnf.jwk.kid;
|
45
|
+
const tokenUrl = issuerConf.oauth_authorization_server.token_endpoint;
|
32
46
|
// Use an ephemeral key to be destroyed after use
|
33
|
-
const
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
47
|
+
const tokenRequestSignedDPop = await (0, _crypto.withEphemeralKey)(async ephimeralContext => {
|
48
|
+
return await (0, _dpop.createDPopToken)({
|
49
|
+
htm: "POST",
|
50
|
+
htu: tokenUrl,
|
51
|
+
jti: `${_reactNativeUuid.default.v4()}`
|
52
|
+
}, ephimeralContext);
|
53
|
+
});
|
54
|
+
const signedWiaPoP = await (0, _pop.createPopToken)({
|
55
|
+
jti: `${_reactNativeUuid.default.v4()}`,
|
56
|
+
aud,
|
57
|
+
iss
|
58
|
+
}, wiaCryptoContext);
|
39
59
|
const requestBody = {
|
40
|
-
grant_type: "
|
60
|
+
grant_type: "authorization_code",
|
41
61
|
client_id: clientId,
|
42
62
|
code,
|
63
|
+
redirect_uri: redirectUri,
|
43
64
|
code_verifier: codeVerifier,
|
44
65
|
client_assertion_type: _const.ASSERTION_TYPE,
|
45
|
-
client_assertion: walletInstanceAttestation
|
46
|
-
redirect_uri: walletProviderBaseUrl
|
66
|
+
client_assertion: walletInstanceAttestation + "~" + signedWiaPoP
|
47
67
|
};
|
48
|
-
|
49
|
-
|
68
|
+
const authorizationRequestFormBody = new URLSearchParams(requestBody);
|
69
|
+
const tokenRes = await appFetch(tokenUrl, {
|
50
70
|
method: "POST",
|
51
71
|
headers: {
|
52
72
|
"Content-Type": "application/x-www-form-urlencoded",
|
53
|
-
DPoP:
|
73
|
+
DPoP: tokenRequestSignedDPop
|
54
74
|
},
|
55
|
-
body:
|
56
|
-
}).then((0, _misc.hasStatus)(200)).then(res => res.json()).then(body => (
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
75
|
+
body: authorizationRequestFormBody.toString()
|
76
|
+
}).then((0, _misc.hasStatus)(200)).then(res => res.json()).then(body => _types.TokenResponse.safeParse(body));
|
77
|
+
if (!tokenRes.success) {
|
78
|
+
throw new _errors.ValidationFailed(tokenRes.error.message);
|
79
|
+
}
|
80
|
+
return {
|
81
|
+
accessToken: tokenRes.data,
|
82
|
+
tokenRequestSignedDPop
|
83
|
+
};
|
61
84
|
};
|
62
85
|
exports.authorizeAccess = authorizeAccess;
|
63
86
|
//# sourceMappingURL=05-authorize-access.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_reactNativeUuid","_interopRequireDefault","
|
1
|
+
{"version":3,"names":["_misc","require","_crypto","_dpop","_reactNativeUuid","_interopRequireDefault","_pop","WalletInstanceAttestation","_interopRequireWildcard","_const","_types","_errors","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","authorizeAccess","issuerConf","code","clientId","redirectUri","codeVerifier","context","appFetch","fetch","walletInstanceAttestation","wiaCryptoContext","parEndpoint","oauth_authorization_server","pushed_authorization_request_endpoint","parUrl","URL","aud","protocol","hostname","iss","decode","payload","cnf","jwk","kid","tokenUrl","token_endpoint","tokenRequestSignedDPop","withEphemeralKey","ephimeralContext","createDPopToken","htm","htu","jti","uuid","v4","signedWiaPoP","createPopToken","requestBody","grant_type","client_id","redirect_uri","code_verifier","client_assertion_type","ASSERTION_TYPE","client_assertion","authorizationRequestFormBody","URLSearchParams","tokenRes","method","headers","DPoP","body","toString","then","hasStatus","res","json","TokenResponse","safeParse","success","ValidationFailed","error","message","accessToken","data","exports"],"sourceRoot":"../../../../src","sources":["credential/issuance/05-authorize-access.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAGA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,IAAA,GAAAL,OAAA;AACA,IAAAM,yBAAA,GAAAC,uBAAA,CAA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