@pagopa/io-react-native-wallet 0.27.1 → 0.28.1
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 +27 -19
- package/lib/commonjs/client/generated/wallet-provider.js.map +1 -1
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js +3 -0
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/presentation/01-start-flow.js +14 -24
- package/lib/commonjs/credential/presentation/01-start-flow.js.map +1 -1
- package/lib/commonjs/credential/presentation/03-get-request-object.js +30 -42
- package/lib/commonjs/credential/presentation/03-get-request-object.js.map +1 -1
- package/lib/commonjs/credential/presentation/04-retrieve-rp-jwks.js +32 -0
- package/lib/commonjs/credential/presentation/04-retrieve-rp-jwks.js.map +1 -0
- package/lib/commonjs/credential/presentation/05-verify-request-object.js +53 -0
- package/lib/commonjs/credential/presentation/05-verify-request-object.js.map +1 -0
- package/lib/commonjs/credential/presentation/06-fetch-presentation-definition.js +39 -0
- package/lib/commonjs/credential/presentation/06-fetch-presentation-definition.js.map +1 -0
- package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js +125 -0
- package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js.map +1 -0
- package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js +289 -0
- package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js.map +1 -0
- package/lib/commonjs/credential/presentation/08-send-authorization-response.js +170 -0
- package/lib/commonjs/credential/presentation/08-send-authorization-response.js.map +1 -0
- package/lib/commonjs/credential/presentation/errors.js +69 -1
- package/lib/commonjs/credential/presentation/errors.js.map +1 -1
- package/lib/commonjs/credential/presentation/index.js +29 -1
- package/lib/commonjs/credential/presentation/index.js.map +1 -1
- package/lib/commonjs/credential/presentation/types.js +124 -3
- package/lib/commonjs/credential/presentation/types.js.map +1 -1
- package/lib/commonjs/sd-jwt/index.js +41 -1
- package/lib/commonjs/sd-jwt/index.js.map +1 -1
- package/lib/commonjs/trust/chain.js +35 -50
- package/lib/commonjs/trust/chain.js.map +1 -1
- package/lib/commonjs/trust/index.js +139 -16
- package/lib/commonjs/trust/index.js.map +1 -1
- package/lib/commonjs/trust/types.js +36 -12
- package/lib/commonjs/trust/types.js.map +1 -1
- package/lib/commonjs/trust/utils.js +41 -0
- package/lib/commonjs/trust/utils.js.map +1 -0
- package/lib/commonjs/utils/jwk.js +5 -1
- package/lib/commonjs/utils/jwk.js.map +1 -1
- package/lib/commonjs/wallet-instance/index.js +10 -0
- package/lib/commonjs/wallet-instance/index.js.map +1 -1
- package/lib/module/client/generated/wallet-provider.js +22 -15
- package/lib/module/client/generated/wallet-provider.js.map +1 -1
- package/lib/module/credential/issuance/03-start-user-authorization.js +3 -0
- package/lib/module/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/module/credential/presentation/01-start-flow.js +14 -24
- package/lib/module/credential/presentation/01-start-flow.js.map +1 -1
- package/lib/module/credential/presentation/03-get-request-object.js +31 -43
- package/lib/module/credential/presentation/03-get-request-object.js.map +1 -1
- package/lib/module/credential/presentation/04-retrieve-rp-jwks.js +25 -0
- package/lib/module/credential/presentation/04-retrieve-rp-jwks.js.map +1 -0
- package/lib/module/credential/presentation/05-verify-request-object.js +46 -0
- package/lib/module/credential/presentation/05-verify-request-object.js.map +1 -0
- package/lib/module/credential/presentation/06-fetch-presentation-definition.js +32 -0
- package/lib/module/credential/presentation/06-fetch-presentation-definition.js.map +1 -0
- package/lib/module/credential/presentation/07-evaluate-dcql-query.js +117 -0
- package/lib/module/credential/presentation/07-evaluate-dcql-query.js.map +1 -0
- package/lib/module/credential/presentation/07-evaluate-input-descriptor.js +278 -0
- package/lib/module/credential/presentation/07-evaluate-input-descriptor.js.map +1 -0
- package/lib/module/credential/presentation/08-send-authorization-response.js +158 -0
- package/lib/module/credential/presentation/08-send-authorization-response.js.map +1 -0
- package/lib/module/credential/presentation/errors.js +64 -0
- package/lib/module/credential/presentation/errors.js.map +1 -1
- package/lib/module/credential/presentation/index.js +6 -2
- package/lib/module/credential/presentation/index.js.map +1 -1
- package/lib/module/credential/presentation/types.js +121 -2
- package/lib/module/credential/presentation/types.js.map +1 -1
- package/lib/module/sd-jwt/index.js +40 -1
- package/lib/module/sd-jwt/index.js.map +1 -1
- package/lib/module/trust/chain.js +32 -46
- package/lib/module/trust/chain.js.map +1 -1
- package/lib/module/trust/index.js +139 -18
- package/lib/module/trust/index.js.map +1 -1
- package/lib/module/trust/types.js +34 -11
- package/lib/module/trust/types.js.map +1 -1
- package/lib/module/trust/utils.js +33 -0
- package/lib/module/trust/utils.js.map +1 -0
- package/lib/module/utils/jwk.js +3 -0
- package/lib/module/utils/jwk.js.map +1 -1
- package/lib/module/wallet-instance/index.js +9 -0
- package/lib/module/wallet-instance/index.js.map +1 -1
- package/lib/typescript/client/generated/wallet-provider.d.ts +91 -54
- package/lib/typescript/client/generated/wallet-provider.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/01-start-flow.d.ts +26 -5
- package/lib/typescript/credential/presentation/01-start-flow.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/03-get-request-object.d.ts +7 -10
- package/lib/typescript/credential/presentation/03-get-request-object.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/04-retrieve-rp-jwks.d.ts +23 -0
- package/lib/typescript/credential/presentation/04-retrieve-rp-jwks.d.ts.map +1 -0
- package/lib/typescript/credential/presentation/05-verify-request-object.d.ts +18 -0
- package/lib/typescript/credential/presentation/05-verify-request-object.d.ts.map +1 -0
- package/lib/typescript/credential/presentation/06-fetch-presentation-definition.d.ts +21 -0
- package/lib/typescript/credential/presentation/06-fetch-presentation-definition.d.ts.map +1 -0
- package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts +20 -0
- package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts.map +1 -0
- package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts +88 -0
- package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts.map +1 -0
- package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts +70 -0
- package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts.map +1 -0
- package/lib/typescript/credential/presentation/errors.d.ts +44 -0
- package/lib/typescript/credential/presentation/errors.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/index.d.ts +7 -3
- package/lib/typescript/credential/presentation/index.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/types.d.ts +747 -10
- package/lib/typescript/credential/presentation/types.d.ts.map +1 -1
- package/lib/typescript/credential/status/types.d.ts +6 -6
- package/lib/typescript/sd-jwt/index.d.ts +31 -12
- package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/types.d.ts +6 -6
- package/lib/typescript/trust/chain.d.ts +4 -9
- package/lib/typescript/trust/chain.d.ts.map +1 -1
- package/lib/typescript/trust/index.d.ts +337 -61
- package/lib/typescript/trust/index.d.ts.map +1 -1
- package/lib/typescript/trust/types.d.ts +4074 -407
- package/lib/typescript/trust/types.d.ts.map +1 -1
- package/lib/typescript/trust/utils.d.ts +12 -0
- package/lib/typescript/trust/utils.d.ts.map +1 -0
- package/lib/typescript/utils/decoder.d.ts +1 -1
- package/lib/typescript/utils/decoder.d.ts.map +1 -1
- package/lib/typescript/utils/jwk.d.ts +137 -0
- package/lib/typescript/utils/jwk.d.ts.map +1 -1
- package/lib/typescript/wallet-instance/index.d.ts +8 -0
- package/lib/typescript/wallet-instance/index.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/types.d.ts +36 -36
- package/package.json +5 -2
- package/src/client/generated/wallet-provider.ts +28 -19
- package/src/credential/issuance/03-start-user-authorization.ts +3 -0
- package/src/credential/presentation/01-start-flow.ts +19 -26
- package/src/credential/presentation/03-get-request-object.ts +35 -58
- package/src/credential/presentation/04-retrieve-rp-jwks.ts +34 -0
- package/src/credential/presentation/05-verify-request-object.ts +52 -0
- package/src/credential/presentation/06-fetch-presentation-definition.ts +48 -0
- package/src/credential/presentation/07-evaluate-dcql-query.ts +166 -0
- package/src/credential/presentation/07-evaluate-input-descriptor.ts +391 -0
- package/src/credential/presentation/08-send-authorization-response.ts +220 -0
- package/src/credential/presentation/errors.ts +64 -0
- package/src/credential/presentation/index.ts +22 -1
- package/src/credential/presentation/types.ts +133 -2
- package/src/sd-jwt/index.ts +49 -1
- package/src/trust/chain.ts +46 -66
- package/src/trust/index.ts +185 -20
- package/src/trust/types.ts +34 -10
- package/src/trust/utils.ts +35 -0
- package/src/utils/decoder.ts +1 -1
- package/src/utils/jwk.ts +8 -1
- package/src/wallet-instance/index.ts +13 -0
- package/lib/commonjs/credential/presentation/04-send-authorization-response.js +0 -138
- package/lib/commonjs/credential/presentation/04-send-authorization-response.js.map +0 -1
- package/lib/module/credential/presentation/04-send-authorization-response.js +0 -128
- package/lib/module/credential/presentation/04-send-authorization-response.js.map +0 -1
- package/lib/typescript/credential/presentation/04-send-authorization-response.d.ts +0 -34
- package/lib/typescript/credential/presentation/04-send-authorization-response.d.ts.map +0 -1
- package/src/credential/presentation/04-send-authorization-response.ts +0 -168
package/src/trust/types.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import { UnixTime } from "../sd-jwt/types";
|
2
2
|
import { JWK } from "../utils/jwk";
|
3
3
|
import * as z from "zod";
|
4
|
+
import { PresentationDefinition } from "../credential/presentation/types";
|
4
5
|
|
5
6
|
export const TrustMark = z.object({ id: z.string(), trust_mark: z.string() });
|
6
7
|
export type TrustMark = z.infer<typeof TrustMark>;
|
@@ -11,8 +12,12 @@ const RelyingPartyMetadata = z.object({
|
|
11
12
|
client_name: z.string().optional(),
|
12
13
|
jwks: z.object({ keys: z.array(JWK) }),
|
13
14
|
contacts: z.array(z.string()).optional(),
|
15
|
+
presentation_definition: PresentationDefinition.optional(),
|
16
|
+
request_uris: z.array(z.string()).optional(),
|
17
|
+
authorization_signed_response_alg: z.string().optional(),
|
18
|
+
authorization_encrypted_response_alg: z.string().optional(),
|
19
|
+
authorization_encrypted_response_enc: z.string().optional(),
|
14
20
|
});
|
15
|
-
//.passthrough();
|
16
21
|
|
17
22
|
// Display metadata for a credential, used by the issuer to
|
18
23
|
// instruct the Wallet Solution on how to render the credential correctly
|
@@ -50,7 +55,7 @@ const IssuanceErrorSupported = z.object({
|
|
50
55
|
),
|
51
56
|
});
|
52
57
|
|
53
|
-
// Metadata for a
|
58
|
+
// Metadata for a credential which is supported by an Issuer
|
54
59
|
type SupportedCredentialMetadata = z.infer<typeof SupportedCredentialMetadata>;
|
55
60
|
const SupportedCredentialMetadata = z.object({
|
56
61
|
format: z.union([z.literal("vc+sd-jwt"), z.literal("vc+mdoc-cbor")]),
|
@@ -74,7 +79,7 @@ export const EntityStatement = z.object({
|
|
74
79
|
iss: z.string(),
|
75
80
|
sub: z.string(),
|
76
81
|
jwks: z.object({ keys: z.array(JWK) }),
|
77
|
-
trust_marks: z.array(TrustMark),
|
82
|
+
trust_marks: z.array(TrustMark).optional(),
|
78
83
|
iat: z.number(),
|
79
84
|
exp: z.number(),
|
80
85
|
}),
|
@@ -90,7 +95,7 @@ export const EntityConfigurationHeader = z.object({
|
|
90
95
|
});
|
91
96
|
|
92
97
|
/**
|
93
|
-
* @see https://openid.net/specs/openid-
|
98
|
+
* @see https://openid.net/specs/openid-federation-1_0-41.html
|
94
99
|
*/
|
95
100
|
const FederationEntityMetadata = z
|
96
101
|
.object({
|
@@ -99,6 +104,9 @@ const FederationEntityMetadata = z
|
|
99
104
|
federation_resolve_endpoint: z.string().optional(),
|
100
105
|
federation_trust_mark_status_endpoint: z.string().optional(),
|
101
106
|
federation_trust_mark_list_endpoint: z.string().optional(),
|
107
|
+
federation_trust_mark_endpoint: z.string().optional(),
|
108
|
+
federation_historical_keys_endpoint: z.string().optional(),
|
109
|
+
endpoint_auth_signing_alg_values_supported: z.string().optional(),
|
102
110
|
organization_name: z.string().optional(),
|
103
111
|
homepage_uri: z.string().optional(),
|
104
112
|
policy_uri: z.string().optional(),
|
@@ -107,7 +115,7 @@ const FederationEntityMetadata = z
|
|
107
115
|
})
|
108
116
|
.passthrough();
|
109
117
|
|
110
|
-
//
|
118
|
+
// Structure common to every Entity Configuration document
|
111
119
|
const BaseEntityConfiguration = z.object({
|
112
120
|
header: EntityConfigurationHeader,
|
113
121
|
payload: z
|
@@ -171,10 +179,24 @@ export const CredentialIssuerEntityConfiguration = BaseEntityConfiguration.and(
|
|
171
179
|
token_endpoint_auth_signing_alg_values_supported: z.array(z.string()),
|
172
180
|
request_object_signing_alg_values_supported: z.array(z.string()),
|
173
181
|
}),
|
174
|
-
/**
|
175
|
-
|
176
|
-
|
177
|
-
|
182
|
+
/**
|
183
|
+
* Credential Issuers act as Relying Party when they require the presentation of other credentials.
|
184
|
+
* This does not apply for PID issuance, which requires CIE authz.
|
185
|
+
*/
|
186
|
+
openid_credential_verifier: RelyingPartyMetadata.optional(),
|
187
|
+
/**
|
188
|
+
* @deprecated use `openid_credential_verifier`
|
189
|
+
* TODO [SIW-2111]: remove after migrating to 0.9.x
|
190
|
+
*/
|
191
|
+
wallet_relying_party: z
|
192
|
+
.object({
|
193
|
+
application_type: z.string().optional(),
|
194
|
+
client_id: z.string().optional(),
|
195
|
+
client_name: z.string().optional(),
|
196
|
+
jwks: z.object({ keys: z.array(JWK) }),
|
197
|
+
contacts: z.array(z.string()).optional(),
|
198
|
+
})
|
199
|
+
.optional(),
|
178
200
|
}),
|
179
201
|
}),
|
180
202
|
})
|
@@ -188,7 +210,7 @@ export const RelyingPartyEntityConfiguration = BaseEntityConfiguration.and(
|
|
188
210
|
z.object({
|
189
211
|
payload: z.object({
|
190
212
|
metadata: z.object({
|
191
|
-
|
213
|
+
openid_credential_verifier: RelyingPartyMetadata,
|
192
214
|
}),
|
193
215
|
}),
|
194
216
|
})
|
@@ -232,3 +254,5 @@ export const EntityConfiguration = z.union(
|
|
232
254
|
description: "Any kind of Entity Configuration allowed in the ecosystem",
|
233
255
|
}
|
234
256
|
);
|
257
|
+
|
258
|
+
export const FederationListResponse = z.array(z.string());
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import {
|
2
|
+
decode as decodeJwt,
|
3
|
+
verify as verifyJwt,
|
4
|
+
} from "@pagopa/io-react-native-jwt";
|
5
|
+
|
6
|
+
import type { JWK, JWTDecodeResult } from "../utils/jwk";
|
7
|
+
|
8
|
+
export type ParsedToken = {
|
9
|
+
header: JWTDecodeResult["protectedHeader"];
|
10
|
+
payload: JWTDecodeResult["payload"];
|
11
|
+
};
|
12
|
+
|
13
|
+
// Verify a token signature
|
14
|
+
// The kid is extracted from the token header
|
15
|
+
export const verify = async (
|
16
|
+
token: string,
|
17
|
+
kid: string,
|
18
|
+
jwks: JWK[]
|
19
|
+
): Promise<ParsedToken> => {
|
20
|
+
const jwk = jwks.find((k) => k.kid === kid);
|
21
|
+
if (!jwk) {
|
22
|
+
throw new Error(`Invalid kid: ${kid}, token: ${token}`);
|
23
|
+
}
|
24
|
+
const { protectedHeader: header, payload } = await verifyJwt(token, jwk);
|
25
|
+
return { header, payload };
|
26
|
+
};
|
27
|
+
|
28
|
+
/**
|
29
|
+
* Return type for this function is necessary to avoid an issue during the bob build process.
|
30
|
+
* It seems like typescript can't correctly infer the return type of the function.
|
31
|
+
*/
|
32
|
+
export const decode = (token: string): ParsedToken => {
|
33
|
+
const { protectedHeader: header, payload } = decodeJwt(token);
|
34
|
+
return { header, payload };
|
35
|
+
};
|
package/src/utils/decoder.ts
CHANGED
package/src/utils/jwk.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { removePadding } from "@pagopa/io-react-native-jwt";
|
1
|
+
import { decode, removePadding } from "@pagopa/io-react-native-jwt";
|
2
2
|
import { z } from "zod";
|
3
3
|
|
4
4
|
export type JWK = z.infer<typeof JWK>;
|
@@ -58,3 +58,10 @@ export function fixBase64EncodingOnKey(key: JWK): JWK {
|
|
58
58
|
...(n ? { n: removePadding(n) } : {}),
|
59
59
|
};
|
60
60
|
}
|
61
|
+
|
62
|
+
export type JWKS = z.infer<typeof JWKS>;
|
63
|
+
export const JWKS = z.object({
|
64
|
+
keys: z.array(JWK),
|
65
|
+
});
|
66
|
+
|
67
|
+
export type JWTDecodeResult = ReturnType<typeof decode>;
|
@@ -87,3 +87,16 @@ export async function getWalletInstanceStatus(context: {
|
|
87
87
|
path: { id: context.id },
|
88
88
|
});
|
89
89
|
}
|
90
|
+
|
91
|
+
/**
|
92
|
+
* Get the status of the current Wallet Instance.
|
93
|
+
* @returns Details on the status of the current Wallet Instance
|
94
|
+
*/
|
95
|
+
export async function getCurrentWalletInstanceStatus(context: {
|
96
|
+
walletProviderBaseUrl: string;
|
97
|
+
appFetch?: GlobalFetch["fetch"];
|
98
|
+
}): Promise<WalletInstanceData> {
|
99
|
+
const api = getWalletProviderClient(context);
|
100
|
+
|
101
|
+
return api.get("/wallet-instances/current/status");
|
102
|
+
}
|
@@ -1,138 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.sendAuthorizationResponse = exports.AuthorizationResponse = void 0;
|
7
|
-
var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
|
8
|
-
var _uuid = require("uuid");
|
9
|
-
var WalletInstanceAttestation = _interopRequireWildcard(require("../../wallet-instance-attestation"));
|
10
|
-
var _errors = require("./errors");
|
11
|
-
var _misc = require("../../utils/misc");
|
12
|
-
var _sdJwt = require("../../sd-jwt");
|
13
|
-
var z = _interopRequireWildcard(require("zod"));
|
14
|
-
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); }
|
15
|
-
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; }
|
16
|
-
const AuthorizationResponse = z.object({
|
17
|
-
status: z.string(),
|
18
|
-
response_code: z.string() /**
|
19
|
-
FIXME: [SIW-627] we expect this value from every RP implementation
|
20
|
-
Actually some RP does not return the value
|
21
|
-
We make it optional to not break the flow.
|
22
|
-
*/.optional()
|
23
|
-
});
|
24
|
-
|
25
|
-
/**
|
26
|
-
* Choose an RSA public key from those offered by the RP for encryption.
|
27
|
-
*
|
28
|
-
* @param entity The RP entity configuration
|
29
|
-
* @returns A suitable public key with its compatible encryption algorithm
|
30
|
-
* @throws {NoSuitableKeysFoundInEntityConfiguration} If entity do not contain any public key suitable for encrypting
|
31
|
-
*/
|
32
|
-
exports.AuthorizationResponse = AuthorizationResponse;
|
33
|
-
const chooseRSAPublicKeyToEncrypt = entity => {
|
34
|
-
const [usingRsa256] = entity.wallet_relying_party.jwks.keys.filter(jwk => jwk.use === "enc" && jwk.kty === "RSA");
|
35
|
-
if (usingRsa256) {
|
36
|
-
return usingRsa256;
|
37
|
-
}
|
38
|
-
|
39
|
-
// No suitable key has been found
|
40
|
-
throw new _errors.NoSuitableKeysFoundInEntityConfiguration("Encrypt with RP public key");
|
41
|
-
};
|
42
|
-
|
43
|
-
/**
|
44
|
-
* Generate a Verified Presentation token for a received request object within the context of an authorization request flow.
|
45
|
-
* The presentation is created by revealing data from the provided credentials based on the requested claims.
|
46
|
-
* Each Verified Credential is accompanied by the claims that the user consents to disclose from it.
|
47
|
-
*
|
48
|
-
* @todo: Allow for handling more than one Verified Credential.
|
49
|
-
*/
|
50
|
-
const prepareVpToken = async (requestObject, walletInstanceAttestation, _ref) => {
|
51
|
-
let [vc, claims, cryptoCtx] = _ref;
|
52
|
-
// this throws if vc cannot satisfy all the requested claims
|
53
|
-
const {
|
54
|
-
token: vp,
|
55
|
-
paths
|
56
|
-
} = await (0, _sdJwt.disclose)(vc, claims);
|
57
|
-
|
58
|
-
// obtain issuer from Wallet Instance
|
59
|
-
const {
|
60
|
-
payload: {
|
61
|
-
iss
|
62
|
-
}
|
63
|
-
} = WalletInstanceAttestation.decode(walletInstanceAttestation);
|
64
|
-
const pidKid = await cryptoCtx.getPublicKey().then(_ => _.kid);
|
65
|
-
|
66
|
-
// TODO: [SIW-359] check all requeste claims of the requestedObj are satisfied
|
67
|
-
const vp_token = await new _ioReactNativeJwt.SignJWT(cryptoCtx).setProtectedHeader({
|
68
|
-
typ: "JWT",
|
69
|
-
kid: pidKid
|
70
|
-
}).setPayload({
|
71
|
-
vp: vp,
|
72
|
-
jti: `${(0, _uuid.v4)()}`,
|
73
|
-
iss,
|
74
|
-
nonce: requestObject.nonce
|
75
|
-
}).setAudience(requestObject.response_uri).setIssuedAt().setExpirationTime("1h").sign();
|
76
|
-
const vc_scope = requestObject.scope;
|
77
|
-
const presentation_submission = {
|
78
|
-
definition_id: `${(0, _uuid.v4)()}`,
|
79
|
-
id: `${(0, _uuid.v4)()}`,
|
80
|
-
descriptor_map: paths.map(p => ({
|
81
|
-
id: vc_scope,
|
82
|
-
path: `$.vp_token.${p.path}`,
|
83
|
-
format: "vc+sd-jwt"
|
84
|
-
}))
|
85
|
-
};
|
86
|
-
return {
|
87
|
-
vp_token,
|
88
|
-
presentation_submission
|
89
|
-
};
|
90
|
-
};
|
91
|
-
/**
|
92
|
-
* Complete the presentation flow by sending the authorization response to the Relying Party
|
93
|
-
*
|
94
|
-
* @param requestObject The Request Object that describes the presentation
|
95
|
-
* @param rpConf The Relying Party's configuration
|
96
|
-
* @param presentation The presentation tuple consisting in the signed credential,
|
97
|
-
* the list of claims to be disclosed, and the context to access the key that proves the holder binding
|
98
|
-
* @param context.walletInstanceAttestation The Wallet Instance Attestation token
|
99
|
-
* @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
|
100
|
-
* @returns The result of the presentation flow
|
101
|
-
*/
|
102
|
-
const sendAuthorizationResponse = async (requestObject, rpConf, presentation, _ref2) => {
|
103
|
-
let {
|
104
|
-
appFetch = fetch,
|
105
|
-
walletInstanceAttestation
|
106
|
-
} = _ref2;
|
107
|
-
// the request is an unsigned jws without iss, aud, exp
|
108
|
-
// https://openid.net/specs/openid-4-verifiable-presentations-1_0.html#name-signed-and-encrypted-respon
|
109
|
-
const rsaPublicJwk = chooseRSAPublicKeyToEncrypt(rpConf);
|
110
|
-
const {
|
111
|
-
vp_token,
|
112
|
-
presentation_submission
|
113
|
-
} = await prepareVpToken(requestObject, walletInstanceAttestation, presentation);
|
114
|
-
const authzResponsePayload = JSON.stringify({
|
115
|
-
state: requestObject.state,
|
116
|
-
presentation_submission,
|
117
|
-
nonce: requestObject.nonce,
|
118
|
-
vp_token
|
119
|
-
});
|
120
|
-
const encrypted = await new _ioReactNativeJwt.EncryptJwe(authzResponsePayload, {
|
121
|
-
alg: "RSA-OAEP-256",
|
122
|
-
enc: "A256CBC-HS512",
|
123
|
-
kid: rsaPublicJwk.kid
|
124
|
-
}).encrypt(rsaPublicJwk);
|
125
|
-
const formBody = new URLSearchParams({
|
126
|
-
response: encrypted
|
127
|
-
});
|
128
|
-
const body = formBody.toString();
|
129
|
-
return appFetch(requestObject.response_uri, {
|
130
|
-
method: "POST",
|
131
|
-
headers: {
|
132
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
133
|
-
},
|
134
|
-
body
|
135
|
-
}).then((0, _misc.hasStatusOrThrow)(200)).then(res => res.json()).then(AuthorizationResponse.parse);
|
136
|
-
};
|
137
|
-
exports.sendAuthorizationResponse = sendAuthorizationResponse;
|
138
|
-
//# sourceMappingURL=04-send-authorization-response.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["_ioReactNativeJwt","require","_uuid","WalletInstanceAttestation","_interopRequireWildcard","_errors","_misc","_sdJwt","z","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","AuthorizationResponse","object","status","string","response_code","optional","exports","chooseRSAPublicKeyToEncrypt","entity","usingRsa256","wallet_relying_party","jwks","keys","filter","jwk","use","kty","NoSuitableKeysFoundInEntityConfiguration","prepareVpToken","requestObject","walletInstanceAttestation","_ref","vc","claims","cryptoCtx","token","vp","paths","disclose","payload","iss","decode","pidKid","getPublicKey","then","_","kid","vp_token","SignJWT","setProtectedHeader","typ","setPayload","jti","uuidv4","nonce","setAudience","response_uri","setIssuedAt","setExpirationTime","sign","vc_scope","scope","presentation_submission","definition_id","id","descriptor_map","map","p","path","format","sendAuthorizationResponse","rpConf","presentation","_ref2","appFetch","fetch","rsaPublicJwk","authzResponsePayload","JSON","stringify","state","encrypted","EncryptJwe","alg","enc","encrypt","formBody","URLSearchParams","response","body","toString","method","headers","hasStatusOrThrow","res","json","parse"],"sourceRoot":"../../../../src","sources":["credential/presentation/04-send-authorization-response.ts"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,yBAAA,GAAAC,uBAAA,CAAAH,OAAA;AAEA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAEA,IAAAM,MAAA,GAAAN,OAAA;AAGA,IAAAO,CAAA,GAAAJ,uBAAA,CAAAH,OAAA;AAAyB,SAAAQ,yBAAAC,WAAA,eAAAC,OAAA,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KAAK;IAC1BP;EACF,CAAC,CAAC;EAEF,MAAMkC,SAAS,GAAG,MAAM,IAAIC,4BAAU,CAACL,oBAAoB,EAAE;IAC3DM,GAAG,EAAE,cAAc;IACnBC,GAAG,EAAE,eAAe;IACpBtC,GAAG,EAAE8B,YAAY,CAAC9B;EACpB,CAAC,CAAC,CAACuC,OAAO,CAACT,YAAY,CAAC;EAExB,MAAMU,QAAQ,GAAG,IAAIC,eAAe,CAAC;IAAEC,QAAQ,EAAEP;EAAU,CAAC,CAAC;EAC7D,MAAMQ,IAAI,GAAGH,QAAQ,CAACI,QAAQ,CAAC,CAAC;EAEhC,OAAOhB,QAAQ,CAAC7C,aAAa,CAAC2B,YAAY,EAAE;IAC1CmC,MAAM,EAAE,MAAM;IACdC,OAAO,EAAE;MACP,cAAc,EAAE;IAClB,CAAC;IACDH;EACF,CAAC,CAAC,CACC7C,IAAI,CAAC,IAAAiD,sBAAgB,EAAC,GAAG,CAAC,CAAC,CAC3BjD,IAAI,CAAEkD,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBnD,IAAI,CAAClC,qBAAqB,CAACsF,KAAK,CAAC;AACtC,CAAC;AAAChF,OAAA,CAAAsD,yBAAA,GAAAA,yBAAA"}
|
@@ -1,128 +0,0 @@
|
|
1
|
-
import { EncryptJwe, SignJWT } from "@pagopa/io-react-native-jwt";
|
2
|
-
import { v4 as uuidv4 } from "uuid";
|
3
|
-
import * as WalletInstanceAttestation from "../../wallet-instance-attestation";
|
4
|
-
import { NoSuitableKeysFoundInEntityConfiguration } from "./errors";
|
5
|
-
import { hasStatusOrThrow } from "../../utils/misc";
|
6
|
-
import { disclose } from "../../sd-jwt";
|
7
|
-
import * as z from "zod";
|
8
|
-
export const AuthorizationResponse = z.object({
|
9
|
-
status: z.string(),
|
10
|
-
response_code: z.string() /**
|
11
|
-
FIXME: [SIW-627] we expect this value from every RP implementation
|
12
|
-
Actually some RP does not return the value
|
13
|
-
We make it optional to not break the flow.
|
14
|
-
*/.optional()
|
15
|
-
});
|
16
|
-
|
17
|
-
/**
|
18
|
-
* Choose an RSA public key from those offered by the RP for encryption.
|
19
|
-
*
|
20
|
-
* @param entity The RP entity configuration
|
21
|
-
* @returns A suitable public key with its compatible encryption algorithm
|
22
|
-
* @throws {NoSuitableKeysFoundInEntityConfiguration} If entity do not contain any public key suitable for encrypting
|
23
|
-
*/
|
24
|
-
const chooseRSAPublicKeyToEncrypt = entity => {
|
25
|
-
const [usingRsa256] = entity.wallet_relying_party.jwks.keys.filter(jwk => jwk.use === "enc" && jwk.kty === "RSA");
|
26
|
-
if (usingRsa256) {
|
27
|
-
return usingRsa256;
|
28
|
-
}
|
29
|
-
|
30
|
-
// No suitable key has been found
|
31
|
-
throw new NoSuitableKeysFoundInEntityConfiguration("Encrypt with RP public key");
|
32
|
-
};
|
33
|
-
|
34
|
-
/**
|
35
|
-
* Generate a Verified Presentation token for a received request object within the context of an authorization request flow.
|
36
|
-
* The presentation is created by revealing data from the provided credentials based on the requested claims.
|
37
|
-
* Each Verified Credential is accompanied by the claims that the user consents to disclose from it.
|
38
|
-
*
|
39
|
-
* @todo: Allow for handling more than one Verified Credential.
|
40
|
-
*/
|
41
|
-
const prepareVpToken = async (requestObject, walletInstanceAttestation, _ref) => {
|
42
|
-
let [vc, claims, cryptoCtx] = _ref;
|
43
|
-
// this throws if vc cannot satisfy all the requested claims
|
44
|
-
const {
|
45
|
-
token: vp,
|
46
|
-
paths
|
47
|
-
} = await disclose(vc, claims);
|
48
|
-
|
49
|
-
// obtain issuer from Wallet Instance
|
50
|
-
const {
|
51
|
-
payload: {
|
52
|
-
iss
|
53
|
-
}
|
54
|
-
} = WalletInstanceAttestation.decode(walletInstanceAttestation);
|
55
|
-
const pidKid = await cryptoCtx.getPublicKey().then(_ => _.kid);
|
56
|
-
|
57
|
-
// TODO: [SIW-359] check all requeste claims of the requestedObj are satisfied
|
58
|
-
const vp_token = await new SignJWT(cryptoCtx).setProtectedHeader({
|
59
|
-
typ: "JWT",
|
60
|
-
kid: pidKid
|
61
|
-
}).setPayload({
|
62
|
-
vp: vp,
|
63
|
-
jti: `${uuidv4()}`,
|
64
|
-
iss,
|
65
|
-
nonce: requestObject.nonce
|
66
|
-
}).setAudience(requestObject.response_uri).setIssuedAt().setExpirationTime("1h").sign();
|
67
|
-
const vc_scope = requestObject.scope;
|
68
|
-
const presentation_submission = {
|
69
|
-
definition_id: `${uuidv4()}`,
|
70
|
-
id: `${uuidv4()}`,
|
71
|
-
descriptor_map: paths.map(p => ({
|
72
|
-
id: vc_scope,
|
73
|
-
path: `$.vp_token.${p.path}`,
|
74
|
-
format: "vc+sd-jwt"
|
75
|
-
}))
|
76
|
-
};
|
77
|
-
return {
|
78
|
-
vp_token,
|
79
|
-
presentation_submission
|
80
|
-
};
|
81
|
-
};
|
82
|
-
/**
|
83
|
-
* Complete the presentation flow by sending the authorization response to the Relying Party
|
84
|
-
*
|
85
|
-
* @param requestObject The Request Object that describes the presentation
|
86
|
-
* @param rpConf The Relying Party's configuration
|
87
|
-
* @param presentation The presentation tuple consisting in the signed credential,
|
88
|
-
* the list of claims to be disclosed, and the context to access the key that proves the holder binding
|
89
|
-
* @param context.walletInstanceAttestation The Wallet Instance Attestation token
|
90
|
-
* @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
|
91
|
-
* @returns The result of the presentation flow
|
92
|
-
*/
|
93
|
-
export const sendAuthorizationResponse = async (requestObject, rpConf, presentation, _ref2) => {
|
94
|
-
let {
|
95
|
-
appFetch = fetch,
|
96
|
-
walletInstanceAttestation
|
97
|
-
} = _ref2;
|
98
|
-
// the request is an unsigned jws without iss, aud, exp
|
99
|
-
// https://openid.net/specs/openid-4-verifiable-presentations-1_0.html#name-signed-and-encrypted-respon
|
100
|
-
const rsaPublicJwk = chooseRSAPublicKeyToEncrypt(rpConf);
|
101
|
-
const {
|
102
|
-
vp_token,
|
103
|
-
presentation_submission
|
104
|
-
} = await prepareVpToken(requestObject, walletInstanceAttestation, presentation);
|
105
|
-
const authzResponsePayload = JSON.stringify({
|
106
|
-
state: requestObject.state,
|
107
|
-
presentation_submission,
|
108
|
-
nonce: requestObject.nonce,
|
109
|
-
vp_token
|
110
|
-
});
|
111
|
-
const encrypted = await new EncryptJwe(authzResponsePayload, {
|
112
|
-
alg: "RSA-OAEP-256",
|
113
|
-
enc: "A256CBC-HS512",
|
114
|
-
kid: rsaPublicJwk.kid
|
115
|
-
}).encrypt(rsaPublicJwk);
|
116
|
-
const formBody = new URLSearchParams({
|
117
|
-
response: encrypted
|
118
|
-
});
|
119
|
-
const body = formBody.toString();
|
120
|
-
return appFetch(requestObject.response_uri, {
|
121
|
-
method: "POST",
|
122
|
-
headers: {
|
123
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
124
|
-
},
|
125
|
-
body
|
126
|
-
}).then(hasStatusOrThrow(200)).then(res => res.json()).then(AuthorizationResponse.parse);
|
127
|
-
};
|
128
|
-
//# sourceMappingURL=04-send-authorization-response.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["EncryptJwe","SignJWT","v4","uuidv4","WalletInstanceAttestation","NoSuitableKeysFoundInEntityConfiguration","hasStatusOrThrow","disclose","z","AuthorizationResponse","object","status","string","response_code","optional","chooseRSAPublicKeyToEncrypt","entity","usingRsa256","wallet_relying_party","jwks","keys","filter","jwk","use","kty","prepareVpToken","requestObject","walletInstanceAttestation","_ref","vc","claims","cryptoCtx","token","vp","paths","payload","iss","decode","pidKid","getPublicKey","then","_","kid","vp_token","setProtectedHeader","typ","setPayload","jti","nonce","setAudience","response_uri","setIssuedAt","setExpirationTime","sign","vc_scope","scope","presentation_submission","definition_id","id","descriptor_map","map","p","path","format","sendAuthorizationResponse","rpConf","presentation","_ref2","appFetch","fetch","rsaPublicJwk","authzResponsePayload","JSON","stringify","state","encrypted","alg","enc","encrypt","formBody","URLSearchParams","response","body","toString","method","headers","res","json","parse"],"sourceRoot":"../../../../src","sources":["credential/presentation/04-send-authorization-response.ts"],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object";
|
3
|
-
import type { EvaluateRelyingPartyTrust } from "./02-evaluate-rp-trust";
|
4
|
-
import { type Presentation } from "./types";
|
5
|
-
import * as z from "zod";
|
6
|
-
export type AuthorizationResponse = z.infer<typeof AuthorizationResponse>;
|
7
|
-
export declare const AuthorizationResponse: z.ZodObject<{
|
8
|
-
status: z.ZodString;
|
9
|
-
response_code: z.ZodOptional<z.ZodString>;
|
10
|
-
}, "strip", z.ZodTypeAny, {
|
11
|
-
status: string;
|
12
|
-
response_code?: string | undefined;
|
13
|
-
}, {
|
14
|
-
status: string;
|
15
|
-
response_code?: string | undefined;
|
16
|
-
}>;
|
17
|
-
export type SendAuthorizationResponse = (requestObject: Out<GetRequestObject>["requestObject"], rpConf: Out<EvaluateRelyingPartyTrust>["rpConf"], presentation: Presentation, // TODO: [SIW-353] support multiple presentations
|
18
|
-
context: {
|
19
|
-
walletInstanceAttestation: string;
|
20
|
-
appFetch?: GlobalFetch["fetch"];
|
21
|
-
}) => Promise<AuthorizationResponse>;
|
22
|
-
/**
|
23
|
-
* Complete the presentation flow by sending the authorization response to the Relying Party
|
24
|
-
*
|
25
|
-
* @param requestObject The Request Object that describes the presentation
|
26
|
-
* @param rpConf The Relying Party's configuration
|
27
|
-
* @param presentation The presentation tuple consisting in the signed credential,
|
28
|
-
* the list of claims to be disclosed, and the context to access the key that proves the holder binding
|
29
|
-
* @param context.walletInstanceAttestation The Wallet Instance Attestation token
|
30
|
-
* @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
|
31
|
-
* @returns The result of the presentation flow
|
32
|
-
*/
|
33
|
-
export declare const sendAuthorizationResponse: SendAuthorizationResponse;
|
34
|
-
//# sourceMappingURL=04-send-authorization-response.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"04-send-authorization-response.d.ts","sourceRoot":"","sources":["../../../../src/credential/presentation/04-send-authorization-response.ts"],"names":[],"mappings":"AAKA,OAAO,EAAoB,KAAK,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAC1E,eAAO,MAAM,qBAAqB;;;;;;;;;EAShC,CAAC;AAkFH,MAAM,MAAM,yBAAyB,GAAG,CACtC,aAAa,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC,eAAe,CAAC,EACrD,MAAM,EAAE,GAAG,CAAC,yBAAyB,CAAC,CAAC,QAAQ,CAAC,EAChD,YAAY,EAAE,YAAY,EAAE,iDAAiD;AAC7E,OAAO,EAAE;IACP,yBAAyB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;CACjC,KACE,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAEpC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,yBAAyB,EAAE,yBA0CvC,CAAC"}
|