@pagopa/io-react-native-wallet 3.4.1 → 3.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/credential/issuance/api/IssuerConfig.js +6 -0
- package/lib/commonjs/credential/issuance/api/IssuerConfig.js.map +1 -1
- package/lib/commonjs/credential/issuance/v1.3.3/01-evaluate-issuer-trust.js +1 -0
- package/lib/commonjs/credential/issuance/v1.3.3/01-evaluate-issuer-trust.js.map +1 -1
- package/lib/commonjs/credential/issuance/v1.3.3/02-start-user-authorization.js +8 -1
- package/lib/commonjs/credential/issuance/v1.3.3/02-start-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/v1.3.3/03-complete-user-authorization.js +13 -7
- package/lib/commonjs/credential/issuance/v1.3.3/03-complete-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/v1.3.3/mappers.js +14 -6
- package/lib/commonjs/credential/issuance/v1.3.3/mappers.js.map +1 -1
- package/lib/commonjs/credential/offer/api/03-validate-credential-offer.js +6 -0
- package/lib/commonjs/credential/offer/api/03-validate-credential-offer.js.map +1 -0
- package/lib/commonjs/credential/offer/api/index.js.map +1 -1
- package/lib/commonjs/credential/offer/v1.0.0/index.js +3 -0
- package/lib/commonjs/credential/offer/v1.0.0/index.js.map +1 -1
- package/lib/commonjs/credential/offer/v1.3.3/01-resolve-credential-offer.js +7 -21
- package/lib/commonjs/credential/offer/v1.3.3/01-resolve-credential-offer.js.map +1 -1
- package/lib/commonjs/credential/offer/v1.3.3/02-extract-grant-details.js +5 -1
- package/lib/commonjs/credential/offer/v1.3.3/02-extract-grant-details.js.map +1 -1
- package/lib/commonjs/credential/offer/v1.3.3/03-validate-credential-offer.js +39 -0
- package/lib/commonjs/credential/offer/v1.3.3/03-validate-credential-offer.js.map +1 -0
- package/lib/commonjs/credential/offer/v1.3.3/index.js +3 -1
- package/lib/commonjs/credential/offer/v1.3.3/index.js.map +1 -1
- package/lib/module/credential/issuance/api/IssuerConfig.js +6 -0
- package/lib/module/credential/issuance/api/IssuerConfig.js.map +1 -1
- package/lib/module/credential/issuance/v1.3.3/01-evaluate-issuer-trust.js +1 -0
- package/lib/module/credential/issuance/v1.3.3/01-evaluate-issuer-trust.js.map +1 -1
- package/lib/module/credential/issuance/v1.3.3/02-start-user-authorization.js +8 -1
- package/lib/module/credential/issuance/v1.3.3/02-start-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/v1.3.3/03-complete-user-authorization.js +13 -7
- package/lib/module/credential/issuance/v1.3.3/03-complete-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/v1.3.3/mappers.js +14 -6
- package/lib/module/credential/issuance/v1.3.3/mappers.js.map +1 -1
- package/lib/module/credential/offer/api/03-validate-credential-offer.js +2 -0
- package/lib/module/credential/offer/api/03-validate-credential-offer.js.map +1 -0
- package/lib/module/credential/offer/api/index.js.map +1 -1
- package/lib/module/credential/offer/v1.0.0/index.js +3 -0
- package/lib/module/credential/offer/v1.0.0/index.js.map +1 -1
- package/lib/module/credential/offer/v1.3.3/01-resolve-credential-offer.js +10 -23
- package/lib/module/credential/offer/v1.3.3/01-resolve-credential-offer.js.map +1 -1
- package/lib/module/credential/offer/v1.3.3/02-extract-grant-details.js +6 -1
- package/lib/module/credential/offer/v1.3.3/02-extract-grant-details.js.map +1 -1
- package/lib/module/credential/offer/v1.3.3/03-validate-credential-offer.js +33 -0
- package/lib/module/credential/offer/v1.3.3/03-validate-credential-offer.js.map +1 -0
- package/lib/module/credential/offer/v1.3.3/index.js +3 -1
- package/lib/module/credential/offer/v1.3.3/index.js.map +1 -1
- package/lib/typescript/credential/issuance/api/01-evaluate-issuer-trust.d.ts +4 -0
- package/lib/typescript/credential/issuance/api/01-evaluate-issuer-trust.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/api/02-start-user-authorization.d.ts +4 -0
- package/lib/typescript/credential/issuance/api/02-start-user-authorization.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/api/03-complete-user-authorization.d.ts +3 -1
- package/lib/typescript/credential/issuance/api/03-complete-user-authorization.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/api/IssuerConfig.d.ts +1 -0
- package/lib/typescript/credential/issuance/api/IssuerConfig.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/v1.0.0/mappers.d.ts +1 -0
- package/lib/typescript/credential/issuance/v1.0.0/mappers.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/v1.3.3/01-evaluate-issuer-trust.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/v1.3.3/02-start-user-authorization.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/v1.3.3/03-complete-user-authorization.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/v1.3.3/mappers.d.ts +490 -4
- package/lib/typescript/credential/issuance/v1.3.3/mappers.d.ts.map +1 -1
- package/lib/typescript/credential/offer/api/02-extract-grant-details.d.ts +1 -1
- package/lib/typescript/credential/offer/api/03-validate-credential-offer.d.ts +19 -0
- package/lib/typescript/credential/offer/api/03-validate-credential-offer.d.ts.map +1 -0
- package/lib/typescript/credential/offer/api/index.d.ts +2 -1
- package/lib/typescript/credential/offer/api/index.d.ts.map +1 -1
- package/lib/typescript/credential/offer/v1.0.0/index.d.ts.map +1 -1
- package/lib/typescript/credential/offer/v1.3.3/01-resolve-credential-offer.d.ts +5 -11
- package/lib/typescript/credential/offer/v1.3.3/01-resolve-credential-offer.d.ts.map +1 -1
- package/lib/typescript/credential/offer/v1.3.3/02-extract-grant-details.d.ts.map +1 -1
- package/lib/typescript/credential/offer/v1.3.3/03-validate-credential-offer.d.ts +15 -0
- package/lib/typescript/credential/offer/v1.3.3/03-validate-credential-offer.d.ts.map +1 -0
- package/lib/typescript/credential/offer/v1.3.3/index.d.ts.map +1 -1
- package/lib/typescript/trust/v1.3.3/types.d.ts +2 -2
- package/package.json +6 -6
- package/src/credential/issuance/api/01-evaluate-issuer-trust.ts +4 -1
- package/src/credential/issuance/api/02-start-user-authorization.ts +4 -0
- package/src/credential/issuance/api/03-complete-user-authorization.ts +3 -1
- package/src/credential/issuance/api/IssuerConfig.ts +6 -0
- package/src/credential/issuance/v1.3.3/01-evaluate-issuer-trust.ts +1 -0
- package/src/credential/issuance/v1.3.3/02-start-user-authorization.ts +7 -0
- package/src/credential/issuance/v1.3.3/03-complete-user-authorization.ts +13 -9
- package/src/credential/issuance/v1.3.3/mappers.ts +15 -5
- package/src/credential/offer/api/02-extract-grant-details.ts +1 -1
- package/src/credential/offer/api/03-validate-credential-offer.ts +19 -0
- package/src/credential/offer/api/index.ts +3 -1
- package/src/credential/offer/v1.0.0/index.ts +3 -0
- package/src/credential/offer/v1.3.3/01-resolve-credential-offer.ts +8 -26
- package/src/credential/offer/v1.3.3/02-extract-grant-details.ts +6 -1
- package/src/credential/offer/v1.3.3/03-validate-credential-offer.ts +33 -0
- package/src/credential/offer/v1.3.3/index.ts +2 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { OfferApi } from "../api";
|
|
2
|
+
/**
|
|
3
|
+
* v1.3.3 implementation — validates a resolved Credential Offer against the
|
|
4
|
+
* Credential Issuer metadata (IT-Wallet spec, Section 12.1.2).
|
|
5
|
+
*
|
|
6
|
+
* Performs the IT-Wallet v1.3 structural checks on the offer and, when the
|
|
7
|
+
* Credential Issuer relies on multiple Authorization Servers, ensures the
|
|
8
|
+
* `authorization_server` selected by the offer matches one of the advertised
|
|
9
|
+
* `authorization_servers`.
|
|
10
|
+
*
|
|
11
|
+
* Delegates to the SDK's {@link sdkValidateCredentialOffer}; validation errors
|
|
12
|
+
* are mapped to {@link InvalidCredentialOfferError}.
|
|
13
|
+
*/
|
|
14
|
+
export declare const validateCredentialOffer: OfferApi["validateCredentialOffer"];
|
|
15
|
+
//# sourceMappingURL=03-validate-credential-offer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"03-validate-credential-offer.d.ts","sourceRoot":"","sources":["../../../../../src/credential/offer/v1.3.3/03-validate-credential-offer.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAGvC;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,yBAAyB,CAYrE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/credential/offer/v1.3.3/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/credential/offer/v1.3.3/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAKvC,eAAO,MAAM,KAAK,EAAE,QAInB,CAAC"}
|
|
@@ -92,7 +92,7 @@ export declare const CredentialIssuerEntityConfiguration: z.ZodIntersection<z.Zo
|
|
|
92
92
|
}, z.core.$strip>;
|
|
93
93
|
metadata: z.ZodObject<{
|
|
94
94
|
openid_credential_issuer: z.ZodObject<{
|
|
95
|
-
authorization_servers: z.ZodOptional<z.
|
|
95
|
+
authorization_servers: z.ZodOptional<z.ZodTuple<[z.ZodURL], z.ZodURL>>;
|
|
96
96
|
batch_credential_issuance: z.ZodOptional<z.ZodObject<{
|
|
97
97
|
batch_size: z.ZodNumber;
|
|
98
98
|
}, z.core.$strip>>;
|
|
@@ -657,7 +657,7 @@ export declare const EntityConfiguration: z.ZodUnion<readonly [z.ZodIntersection
|
|
|
657
657
|
}, z.core.$strip>;
|
|
658
658
|
metadata: z.ZodObject<{
|
|
659
659
|
openid_credential_issuer: z.ZodObject<{
|
|
660
|
-
authorization_servers: z.ZodOptional<z.
|
|
660
|
+
authorization_servers: z.ZodOptional<z.ZodTuple<[z.ZodURL], z.ZodURL>>;
|
|
661
661
|
batch_credential_issuance: z.ZodOptional<z.ZodObject<{
|
|
662
662
|
batch_size: z.ZodNumber;
|
|
663
663
|
}, z.core.$strip>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pagopa/io-react-native-wallet",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.3",
|
|
4
4
|
"description": "Provide data structures, helpers and API for IO Wallet",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -140,11 +140,11 @@
|
|
|
140
140
|
]
|
|
141
141
|
},
|
|
142
142
|
"dependencies": {
|
|
143
|
-
"@pagopa/io-wallet-oauth2": "1.
|
|
144
|
-
"@pagopa/io-wallet-oid-federation": "1.
|
|
145
|
-
"@pagopa/io-wallet-oid4vci": "1.
|
|
146
|
-
"@pagopa/io-wallet-oid4vp": "1.
|
|
147
|
-
"@pagopa/io-wallet-utils": "1.
|
|
143
|
+
"@pagopa/io-wallet-oauth2": "1.5.2",
|
|
144
|
+
"@pagopa/io-wallet-oid-federation": "1.5.2",
|
|
145
|
+
"@pagopa/io-wallet-oid4vci": "1.5.2",
|
|
146
|
+
"@pagopa/io-wallet-oid4vp": "1.5.2",
|
|
147
|
+
"@pagopa/io-wallet-utils": "1.5.2",
|
|
148
148
|
"@sd-jwt/core": "^0.19.0",
|
|
149
149
|
"@sd-jwt/crypto-nodejs": "^0.19.0",
|
|
150
150
|
"@sd-jwt/jwt-status-list": "^0.19.0",
|
|
@@ -8,10 +8,13 @@ export interface EvaluateIssuerTrustApi {
|
|
|
8
8
|
*
|
|
9
9
|
* @param issuerUrl The base url of the Issuer
|
|
10
10
|
* @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
|
|
11
|
+
* @param context.authorizationServer (optional) Authorization Server URL selected
|
|
12
|
+
* from a credential offer. When provided it must match one of the Credential
|
|
13
|
+
* Issuer metadata `authorization_servers`. Only honored from v1.3.3 onwards.
|
|
11
14
|
* @returns The Issuer's configuration
|
|
12
15
|
*/
|
|
13
16
|
evaluateIssuerTrust(
|
|
14
17
|
issuerUrl: string,
|
|
15
|
-
ctx?: { appFetch?: GlobalFetch["fetch"] }
|
|
18
|
+
ctx?: { appFetch?: GlobalFetch["fetch"]; authorizationServer?: string }
|
|
16
19
|
): Promise<{ issuerConf: IssuerConfig }>;
|
|
17
20
|
}
|
|
@@ -27,6 +27,8 @@ export interface StartUserAuthorizationApi {
|
|
|
27
27
|
* @param context.walletInstanceAttestation: the Wallet Instance's attestation
|
|
28
28
|
* @param context.redirectUri: the redirect URI
|
|
29
29
|
* @param context.appFetch: (optional) the fetch implementation
|
|
30
|
+
* @param context.scope: (optional) the OAuth 2.0 scope, forwarded to the PAR. When the issuance is started from a Credential Offer, it comes from the `authorization_code` grant.
|
|
31
|
+
* @param context.issuerState: (optional) the issuer state, forwarded to the PAR to correlate the authorization request with the Credential Offer.
|
|
30
32
|
* @returns The URI to which the end user should be redirected to start the authentication flow, along with additional authentication parameters
|
|
31
33
|
*/
|
|
32
34
|
startUserAuthorization(
|
|
@@ -40,6 +42,8 @@ export interface StartUserAuthorizationApi {
|
|
|
40
42
|
walletInstanceAttestation: string;
|
|
41
43
|
redirectUri: string;
|
|
42
44
|
appFetch?: GlobalFetch["fetch"];
|
|
45
|
+
scope?: string;
|
|
46
|
+
issuerState?: string;
|
|
43
47
|
}
|
|
44
48
|
): Promise<{
|
|
45
49
|
issuerRequestUri: string;
|
|
@@ -52,7 +52,6 @@ export interface CompleteUserAuthorizationApi {
|
|
|
52
52
|
* @param issuerConfig The issuer configuration returned by {@link evaluateIssuerTrust}
|
|
53
53
|
* @param pid The PID to present as a tuple [keyTag, credential].
|
|
54
54
|
* @param redirectUri The client redirect URI to which the authorization server will redirect after completing the authorization process.
|
|
55
|
-
* @param appFetch (optional) fetch api implementation. Default: built-in fetch
|
|
56
55
|
* @returns The authorization response which contains code, state and iss
|
|
57
56
|
*/
|
|
58
57
|
completeEaaUserAuthorizationWithQueryMode(
|
|
@@ -61,7 +60,10 @@ export interface CompleteUserAuthorizationApi {
|
|
|
61
60
|
pid: [keyTag: string, credential: string],
|
|
62
61
|
redirectUri: string,
|
|
63
62
|
context?: {
|
|
63
|
+
/** Fetch api implementation. Default: built-in fetch. */
|
|
64
64
|
appFetch?: GlobalFetch["fetch"];
|
|
65
|
+
/** Function to fetch the final redirect uri; it allows full control on how redirects are handled. If not provided, `appFetch` is used. */
|
|
66
|
+
fetchFinalRedirectUri?: (url: string) => Promise<string | undefined>;
|
|
65
67
|
}
|
|
66
68
|
): Promise<AuthorizationResult>;
|
|
67
69
|
|
|
@@ -50,6 +50,12 @@ const CredentialConfig = z.intersection(
|
|
|
50
50
|
export type IssuerConfig = z.infer<typeof IssuerConfig>;
|
|
51
51
|
export const IssuerConfig = z.object({
|
|
52
52
|
credential_issuer: z.string(),
|
|
53
|
+
/**
|
|
54
|
+
* Authorization Servers advertised by the Credential Issuer. Present when the
|
|
55
|
+
* Issuer relies on one or more external Authorization Servers; used to validate
|
|
56
|
+
* the `authorization_server` selected by a credential offer.
|
|
57
|
+
*/
|
|
58
|
+
authorization_servers: z.tuple([z.string()], z.string()).optional(),
|
|
53
59
|
pushed_authorization_request_endpoint: z.string(),
|
|
54
60
|
authorization_endpoint: z.string(),
|
|
55
61
|
token_endpoint: z.string(),
|
|
@@ -13,6 +13,7 @@ export const evaluateIssuerTrust: IssuanceApi["evaluateIssuerTrust"] = async (
|
|
|
13
13
|
const issuerMetadata = (await fetchMetadata({
|
|
14
14
|
config: sdkConfigV1_3,
|
|
15
15
|
credentialIssuerUrl: issuerUrl,
|
|
16
|
+
authorizationServer: context.authorizationServer,
|
|
16
17
|
callbacks: {
|
|
17
18
|
fetch: context.appFetch,
|
|
18
19
|
},
|
|
@@ -22,6 +22,8 @@ export const startUserAuthorization: IssuanceApi["startUserAuthorization"] =
|
|
|
22
22
|
walletInstanceAttestation,
|
|
23
23
|
redirectUri,
|
|
24
24
|
appFetch = fetch,
|
|
25
|
+
scope,
|
|
26
|
+
issuerState,
|
|
25
27
|
} = ctx;
|
|
26
28
|
|
|
27
29
|
const clientId = await wiaCryptoContext.getPublicKey().then((_) => _.kid);
|
|
@@ -76,6 +78,11 @@ export const startUserAuthorization: IssuanceApi["startUserAuthorization"] =
|
|
|
76
78
|
authorization_details: credentialDefinition,
|
|
77
79
|
codeChallengeMethodsSupported: ["S256"],
|
|
78
80
|
redirectUri,
|
|
81
|
+
// When the issuance is started from a Credential Offer, the `scope` and
|
|
82
|
+
// `issuer_state` carried by the authorization_code grant are forwarded to
|
|
83
|
+
// the PAR. They are `undefined` (and thus omitted) for the regular flow.
|
|
84
|
+
scope,
|
|
85
|
+
issuerState,
|
|
79
86
|
dpop: {
|
|
80
87
|
signer: wiaSigner,
|
|
81
88
|
},
|
|
@@ -161,7 +161,7 @@ export const completeEaaUserAuthorizationWithQueryMode: IssuanceApi["completeEaa
|
|
|
161
161
|
issuerConfig,
|
|
162
162
|
pid,
|
|
163
163
|
clientRedirectUri,
|
|
164
|
-
{ appFetch = fetch } = {}
|
|
164
|
+
{ appFetch = fetch, fetchFinalRedirectUri } = {}
|
|
165
165
|
) => {
|
|
166
166
|
Logger.log(
|
|
167
167
|
LogLevel.DEBUG,
|
|
@@ -195,16 +195,20 @@ export const completeEaaUserAuthorizationWithQueryMode: IssuanceApi["completeEaa
|
|
|
195
195
|
throw new AuthorizationError(errorMessage);
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
if (
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
198
|
+
let finalRedirectUri: string | undefined;
|
|
199
|
+
|
|
200
|
+
if (fetchFinalRedirectUri) {
|
|
201
|
+
finalRedirectUri = await fetchFinalRedirectUri(redirect_uri);
|
|
202
|
+
} else {
|
|
203
|
+
const response = await appFetch(redirect_uri).catch(() => null);
|
|
204
|
+
if (!response || !response.ok) {
|
|
205
|
+
const errorMessage = `An error occurred while completing the authorization flow. Ensure ${clientRedirectUri} is a valid HTTP url for redirect`;
|
|
206
|
+
Logger.log(LogLevel.ERROR, errorMessage);
|
|
207
|
+
throw new AuthorizationError(errorMessage);
|
|
208
|
+
}
|
|
209
|
+
finalRedirectUri = response.url;
|
|
204
210
|
}
|
|
205
211
|
|
|
206
|
-
const finalRedirectUri = response.url;
|
|
207
|
-
|
|
208
212
|
if (!finalRedirectUri || !finalRedirectUri.startsWith(clientRedirectUri)) {
|
|
209
213
|
const errorMessage = `The authorization server did not redirect to the provided client redirect URI. Expected: ${clientRedirectUri}, got: ${finalRedirectUri}`;
|
|
210
214
|
Logger.log(LogLevel.ERROR, errorMessage);
|
|
@@ -45,8 +45,17 @@ export const mapToIssuerConfig = createMapper<
|
|
|
45
45
|
federation_entity,
|
|
46
46
|
} = x.metadata;
|
|
47
47
|
|
|
48
|
+
// The Issuer's own `oauth_authorization_server` always describes the Issuer
|
|
49
|
+
// itself. When a credential offer selected a *different* Authorization
|
|
50
|
+
// Server, its metadata is surfaced separately through that server's
|
|
51
|
+
// federation claims, and the Authorization Server endpoints must be taken
|
|
52
|
+
// from there. Fall back to the Issuer's own server otherwise.
|
|
53
|
+
const oauthAuthorizationServer =
|
|
54
|
+
x.authorization_server_federation_claims?.metadata
|
|
55
|
+
?.oauth_authorization_server ?? oauth_authorization_server;
|
|
56
|
+
|
|
48
57
|
assert(
|
|
49
|
-
|
|
58
|
+
oauthAuthorizationServer,
|
|
50
59
|
"oauth_authorization_server is required in Issuer metadata"
|
|
51
60
|
);
|
|
52
61
|
assert(
|
|
@@ -55,19 +64,20 @@ export const mapToIssuerConfig = createMapper<
|
|
|
55
64
|
);
|
|
56
65
|
|
|
57
66
|
return {
|
|
58
|
-
authorization_endpoint:
|
|
67
|
+
authorization_endpoint: oauthAuthorizationServer.authorization_endpoint,
|
|
59
68
|
credential_endpoint: openid_credential_issuer.credential_endpoint,
|
|
60
69
|
credential_issuer: openid_credential_issuer.credential_issuer,
|
|
70
|
+
authorization_servers: openid_credential_issuer.authorization_servers,
|
|
61
71
|
credential_configurations_supported: mapCredentialConfigurationsSupported(
|
|
62
72
|
openid_credential_issuer
|
|
63
73
|
),
|
|
64
74
|
keys: [
|
|
65
75
|
...openid_credential_issuer.jwks.keys,
|
|
66
|
-
...
|
|
76
|
+
...oauthAuthorizationServer.jwks.keys,
|
|
67
77
|
] as JWK[],
|
|
68
78
|
pushed_authorization_request_endpoint:
|
|
69
|
-
|
|
70
|
-
token_endpoint:
|
|
79
|
+
oauthAuthorizationServer.pushed_authorization_request_endpoint,
|
|
80
|
+
token_endpoint: oauthAuthorizationServer.token_endpoint,
|
|
71
81
|
nonce_endpoint: openid_credential_issuer.nonce_endpoint ?? "",
|
|
72
82
|
federation_entity: federation_entity ?? {},
|
|
73
83
|
credential_issuance_batch_size:
|
|
@@ -4,7 +4,7 @@ export interface ExtractGrantDetailsApi {
|
|
|
4
4
|
/**
|
|
5
5
|
* Extract grant details from a resolved Credential Offer.
|
|
6
6
|
*
|
|
7
|
-
* @param offer - A previously resolved
|
|
7
|
+
* @param offer - A previously resolved Credential Offer.
|
|
8
8
|
* @returns The extracted {@link ExtractGrantDetailsResult} containing
|
|
9
9
|
* the grant type and its parameters.
|
|
10
10
|
* @throws {InvalidCredentialOfferError} If no supported grant type is found.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ValidateCredentialOfferOptions } from "@pagopa/io-wallet-oid4vci";
|
|
2
|
+
import type { CredentialOffer } from "./types";
|
|
3
|
+
|
|
4
|
+
export interface ValidateCredentialOfferApi {
|
|
5
|
+
/**
|
|
6
|
+
* Validate a resolved Credential Offer against the Credential Issuer metadata.
|
|
7
|
+
*
|
|
8
|
+
* @param options.offer - A previously resolved Credential Offer.
|
|
9
|
+
* @param options.credentialIssuerMetadata - The Credential Issuer metadata used
|
|
10
|
+
* to cross-check the offer (e.g. the `authorization_server` selected by the
|
|
11
|
+
* offer against the advertised `authorization_servers`).
|
|
12
|
+
* @returns A promise that resolves when the Credential Offer is valid.
|
|
13
|
+
* @throws {InvalidCredentialOfferError} If the Credential Offer fails validation.
|
|
14
|
+
*/
|
|
15
|
+
validateCredentialOffer(options: {
|
|
16
|
+
offer: CredentialOffer;
|
|
17
|
+
credentialIssuerMetadata: ValidateCredentialOfferOptions["credentialIssuerMetadata"];
|
|
18
|
+
}): Promise<void>;
|
|
19
|
+
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { ResolveCredentialOfferApi } from "./01-resolve-credential-offer";
|
|
2
2
|
import type { ExtractGrantDetailsApi } from "./02-extract-grant-details";
|
|
3
|
+
import type { ValidateCredentialOfferApi } from "./03-validate-credential-offer";
|
|
3
4
|
|
|
4
5
|
export interface OfferApi
|
|
5
6
|
extends ResolveCredentialOfferApi,
|
|
6
|
-
ExtractGrantDetailsApi
|
|
7
|
+
ExtractGrantDetailsApi,
|
|
8
|
+
ValidateCredentialOfferApi {}
|
|
7
9
|
|
|
8
10
|
export * from "./types";
|
|
@@ -1,35 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveCredentialOffer as sdkResolveCredentialOffer,
|
|
3
|
-
validateCredentialOffer,
|
|
4
3
|
CredentialOfferError,
|
|
5
4
|
} from "@pagopa/io-wallet-oid4vci";
|
|
6
|
-
import {
|
|
7
|
-
InvalidQRCodeError,
|
|
8
|
-
InvalidCredentialOfferError,
|
|
9
|
-
} from "../common/errors";
|
|
5
|
+
import { InvalidQRCodeError } from "../common/errors";
|
|
10
6
|
import type { OfferApi } from "../api";
|
|
7
|
+
import { sdkConfigV1_3 } from "../../../utils/config";
|
|
11
8
|
|
|
12
9
|
/**
|
|
13
10
|
* v1.3.3 implementation — first step of the User Request Flow
|
|
14
11
|
* (IT-Wallet spec, Section 12.1.2).
|
|
15
12
|
*
|
|
16
13
|
* Delegates to the SDK's {@link sdkResolveCredentialOffer} for URI parsing
|
|
17
|
-
* and by-reference fetching
|
|
18
|
-
* IT-Wallet v1.3 structural checks:
|
|
19
|
-
* - `credential_issuer` must be an HTTPS URL
|
|
20
|
-
* - `grants` object is required
|
|
21
|
-
* - `authorization_code` grant is required
|
|
22
|
-
* - `scope` is required within `authorization_code`
|
|
14
|
+
* and by-reference fetching of the Credential Offer.
|
|
23
15
|
*
|
|
24
16
|
* Supported URI schemes: `openid-credential-offer://`, `haip-vci://`, `https://`.
|
|
25
17
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
18
|
+
* Structural validation and cross-validation against the Credential Issuer
|
|
19
|
+
* metadata are **not** performed here; they belong to the dedicated
|
|
20
|
+
* validate-credential-offer step of the flow.
|
|
29
21
|
*
|
|
30
22
|
* Resolution errors (bad scheme, missing params, network failure) are mapped
|
|
31
|
-
* to {@link InvalidQRCodeError}
|
|
32
|
-
* {@link InvalidCredentialOfferError}.
|
|
23
|
+
* to {@link InvalidQRCodeError}.
|
|
33
24
|
*/
|
|
34
25
|
export const resolveCredentialOffer: OfferApi["resolveCredentialOffer"] =
|
|
35
26
|
async (credentialOffer, callbacks = {}) => {
|
|
@@ -37,6 +28,7 @@ export const resolveCredentialOffer: OfferApi["resolveCredentialOffer"] =
|
|
|
37
28
|
|
|
38
29
|
// Parse the URI and fetch the offer when transmitted by reference
|
|
39
30
|
const resolved = await sdkResolveCredentialOffer({
|
|
31
|
+
config: sdkConfigV1_3,
|
|
40
32
|
credentialOffer,
|
|
41
33
|
callbacks: { fetch: fetchFn },
|
|
42
34
|
}).catch((e: unknown) => {
|
|
@@ -46,15 +38,5 @@ export const resolveCredentialOffer: OfferApi["resolveCredentialOffer"] =
|
|
|
46
38
|
throw e;
|
|
47
39
|
});
|
|
48
40
|
|
|
49
|
-
// Structural validation (no metadata cross-checks at this stage)
|
|
50
|
-
await validateCredentialOffer({
|
|
51
|
-
credentialOffer: resolved,
|
|
52
|
-
}).catch((e: unknown) => {
|
|
53
|
-
if (e instanceof CredentialOfferError) {
|
|
54
|
-
throw new InvalidCredentialOfferError(e.message);
|
|
55
|
-
}
|
|
56
|
-
throw e;
|
|
57
|
-
});
|
|
58
|
-
|
|
59
41
|
return resolved;
|
|
60
42
|
};
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
import { InvalidCredentialOfferError } from "../common/errors";
|
|
6
6
|
import { withMappedErrors } from "../../../utils/errors";
|
|
7
7
|
import type { OfferApi } from "../api";
|
|
8
|
+
import { sdkConfigV1_3 } from "../../../utils/config";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* v1.3.3 implementation — second and final step of the User Request Flow
|
|
@@ -21,7 +22,11 @@ import type { OfferApi } from "../api";
|
|
|
21
22
|
*/
|
|
22
23
|
export const extractGrantDetails: OfferApi["extractGrantDetails"] = (offer) =>
|
|
23
24
|
withMappedErrors(
|
|
24
|
-
() =>
|
|
25
|
+
() =>
|
|
26
|
+
sdkExtractGrantDetails({
|
|
27
|
+
config: sdkConfigV1_3,
|
|
28
|
+
credentialOffer: offer,
|
|
29
|
+
}),
|
|
25
30
|
CredentialOfferError,
|
|
26
31
|
(e) => new InvalidCredentialOfferError(e.message)
|
|
27
32
|
);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
validateCredentialOffer as sdkValidateCredentialOffer,
|
|
3
|
+
CredentialOfferError,
|
|
4
|
+
} from "@pagopa/io-wallet-oid4vci";
|
|
5
|
+
import { InvalidCredentialOfferError } from "../common/errors";
|
|
6
|
+
import type { OfferApi } from "../api";
|
|
7
|
+
import { sdkConfigV1_3 } from "../../../utils/config";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* v1.3.3 implementation — validates a resolved Credential Offer against the
|
|
11
|
+
* Credential Issuer metadata (IT-Wallet spec, Section 12.1.2).
|
|
12
|
+
*
|
|
13
|
+
* Performs the IT-Wallet v1.3 structural checks on the offer and, when the
|
|
14
|
+
* Credential Issuer relies on multiple Authorization Servers, ensures the
|
|
15
|
+
* `authorization_server` selected by the offer matches one of the advertised
|
|
16
|
+
* `authorization_servers`.
|
|
17
|
+
*
|
|
18
|
+
* Delegates to the SDK's {@link sdkValidateCredentialOffer}; validation errors
|
|
19
|
+
* are mapped to {@link InvalidCredentialOfferError}.
|
|
20
|
+
*/
|
|
21
|
+
export const validateCredentialOffer: OfferApi["validateCredentialOffer"] =
|
|
22
|
+
async ({ offer, credentialIssuerMetadata }) => {
|
|
23
|
+
await sdkValidateCredentialOffer({
|
|
24
|
+
config: sdkConfigV1_3,
|
|
25
|
+
credentialOffer: offer,
|
|
26
|
+
credentialIssuerMetadata,
|
|
27
|
+
}).catch((e: unknown) => {
|
|
28
|
+
if (e instanceof CredentialOfferError) {
|
|
29
|
+
throw new InvalidCredentialOfferError(e.message);
|
|
30
|
+
}
|
|
31
|
+
throw e;
|
|
32
|
+
});
|
|
33
|
+
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { OfferApi } from "../api";
|
|
2
2
|
import { resolveCredentialOffer } from "./01-resolve-credential-offer";
|
|
3
3
|
import { extractGrantDetails } from "./02-extract-grant-details";
|
|
4
|
+
import { validateCredentialOffer } from "./03-validate-credential-offer";
|
|
4
5
|
|
|
5
6
|
export const Offer: OfferApi = {
|
|
6
7
|
resolveCredentialOffer,
|
|
7
8
|
extractGrantDetails,
|
|
9
|
+
validateCredentialOffer,
|
|
8
10
|
};
|