@openid4vc/oauth2 0.3.0-alpha-20251029102217 → 0.3.0-alpha-20251030140425
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/dist/index.d.mts +275 -2
- package/dist/index.d.ts +275 -2
- package/dist/index.js +98 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +89 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -189,6 +189,7 @@ const zJwtPayload = zod.default.object({
|
|
|
189
189
|
nbf: __openid4vc_utils.zInteger.optional(),
|
|
190
190
|
nonce: zod.default.string().optional(),
|
|
191
191
|
jti: zod.default.string().optional(),
|
|
192
|
+
sub: zod.default.string().optional(),
|
|
192
193
|
cnf: zJwtConfirmationPayload.optional(),
|
|
193
194
|
status: zod.default.record(zod.default.string(), zod.default.any()).optional(),
|
|
194
195
|
trust_chain: zod.default.tuple([zod.default.string()], zod.default.string()).optional()
|
|
@@ -868,6 +869,91 @@ var Oauth2ResourceUnauthorizedError = class Oauth2ResourceUnauthorizedError exte
|
|
|
868
869
|
}
|
|
869
870
|
};
|
|
870
871
|
|
|
872
|
+
//#endregion
|
|
873
|
+
//#region src/id-token/z-id-token-jwt.ts
|
|
874
|
+
const zIdTokenJwtHeader = zod.default.object({ ...zJwtHeader.shape }).loose();
|
|
875
|
+
const zIdTokenJwtPayload = zod.default.object({
|
|
876
|
+
...zJwtPayload.shape,
|
|
877
|
+
iss: zod.default.string(),
|
|
878
|
+
sub: zod.default.string(),
|
|
879
|
+
aud: zod.default.string(),
|
|
880
|
+
exp: __openid4vc_utils.zInteger,
|
|
881
|
+
iat: __openid4vc_utils.zInteger,
|
|
882
|
+
auth_time: __openid4vc_utils.zInteger.optional(),
|
|
883
|
+
acr: zod.default.string().optional(),
|
|
884
|
+
amr: zod.default.array(zod.default.string()).optional(),
|
|
885
|
+
azp: zod.default.string().optional(),
|
|
886
|
+
name: zod.default.string().optional(),
|
|
887
|
+
given_name: zod.default.string().optional(),
|
|
888
|
+
family_name: zod.default.string().optional(),
|
|
889
|
+
middle_name: zod.default.string().optional(),
|
|
890
|
+
nickname: zod.default.string().optional(),
|
|
891
|
+
preferred_username: zod.default.string().optional(),
|
|
892
|
+
profile: zod.default.url().optional(),
|
|
893
|
+
picture: zod.default.url().optional(),
|
|
894
|
+
website: zod.default.url().optional(),
|
|
895
|
+
email: zod.default.email().optional(),
|
|
896
|
+
email_verified: zod.default.boolean().optional(),
|
|
897
|
+
gender: zod.default.enum(["male", "female"]).or(zod.default.string()).optional(),
|
|
898
|
+
birthdate: zod.default.iso.date().optional(),
|
|
899
|
+
zoneinfo: zod.default.string().optional(),
|
|
900
|
+
locale: zod.default.string().optional(),
|
|
901
|
+
phone_number: zod.default.string().optional(),
|
|
902
|
+
phone_number_verified: zod.default.boolean().optional(),
|
|
903
|
+
address: zod.default.object({
|
|
904
|
+
formatted: zod.default.string().optional(),
|
|
905
|
+
street_address: zod.default.string().optional(),
|
|
906
|
+
locality: zod.default.string().optional(),
|
|
907
|
+
region: zod.default.string().optional(),
|
|
908
|
+
postal_code: zod.default.string().optional(),
|
|
909
|
+
country: zod.default.string().optional()
|
|
910
|
+
}).loose().optional(),
|
|
911
|
+
updated_at: __openid4vc_utils.zInteger.optional()
|
|
912
|
+
}).loose();
|
|
913
|
+
|
|
914
|
+
//#endregion
|
|
915
|
+
//#region src/id-token/verify-id-token.ts
|
|
916
|
+
/**
|
|
917
|
+
* Verify an ID Token JWT.
|
|
918
|
+
*/
|
|
919
|
+
async function verifyJwtIdToken(options) {
|
|
920
|
+
const { header, payload } = decodeJwt({
|
|
921
|
+
jwt: options.idToken,
|
|
922
|
+
headerSchema: zIdTokenJwtHeader,
|
|
923
|
+
payloadSchema: zIdTokenJwtPayload
|
|
924
|
+
});
|
|
925
|
+
const jwksUrl = options.authorizationServer.jwks_uri;
|
|
926
|
+
if (!jwksUrl) throw new Oauth2Error(`Authorization server '${options.authorizationServer.issuer}' does not have a 'jwks_uri' parameter to fetch JWKs.`);
|
|
927
|
+
if (payload.iss !== options.authorizationServer.issuer) throw new Oauth2Error(`Invalid 'iss' claim in id token jwt. Expected '${options.authorizationServer.issuer}', got '${payload.iss}'.`);
|
|
928
|
+
if (payload.azp && payload.azp !== options.clientId) throw new Oauth2Error(`Invalid 'azp' claim in id token jwt. Expected '${options.clientId}', got '${payload.azp}'.`);
|
|
929
|
+
const jwks = await fetchJwks(jwksUrl, options.callbacks.fetch);
|
|
930
|
+
const publicJwk = extractJwkFromJwksForJwt({
|
|
931
|
+
kid: header.kid,
|
|
932
|
+
jwks,
|
|
933
|
+
use: "sig"
|
|
934
|
+
});
|
|
935
|
+
await verifyJwt({
|
|
936
|
+
compact: options.idToken,
|
|
937
|
+
header,
|
|
938
|
+
payload,
|
|
939
|
+
signer: {
|
|
940
|
+
method: "jwk",
|
|
941
|
+
publicJwk,
|
|
942
|
+
alg: header.alg
|
|
943
|
+
},
|
|
944
|
+
verifyJwtCallback: options.callbacks.verifyJwt,
|
|
945
|
+
errorMessage: "Error during verification of id token jwt.",
|
|
946
|
+
now: options.now,
|
|
947
|
+
expectedAudience: options.clientId,
|
|
948
|
+
expectedIssuer: options.authorizationServer.issuer,
|
|
949
|
+
expectedNonce: options.expectedNonce
|
|
950
|
+
});
|
|
951
|
+
return {
|
|
952
|
+
header,
|
|
953
|
+
payload
|
|
954
|
+
};
|
|
955
|
+
}
|
|
956
|
+
|
|
871
957
|
//#endregion
|
|
872
958
|
//#region src/metadata/fetch-well-known-metadata.ts
|
|
873
959
|
/**
|
|
@@ -2282,7 +2368,8 @@ var Oauth2Client = class {
|
|
|
2282
2368
|
scope: options.scope,
|
|
2283
2369
|
callbacks: this.options.callbacks,
|
|
2284
2370
|
pkceCodeVerifier: options.pkceCodeVerifier,
|
|
2285
|
-
dpop: options.dpop
|
|
2371
|
+
dpop: options.dpop,
|
|
2372
|
+
state: options.state
|
|
2286
2373
|
});
|
|
2287
2374
|
}
|
|
2288
2375
|
async retrievePreAuthorizedCodeAccessToken({ authorizationServerMetadata, preAuthorizedCode, additionalRequestPayload, txCode, dpop, resource }) {
|
|
@@ -2501,6 +2588,12 @@ exports.Oauth2ServerErrorResponseError = Oauth2ServerErrorResponseError;
|
|
|
2501
2588
|
exports.PkceCodeChallengeMethod = PkceCodeChallengeMethod;
|
|
2502
2589
|
exports.SupportedAuthenticationScheme = SupportedAuthenticationScheme;
|
|
2503
2590
|
exports.SupportedClientAuthenticationMethod = SupportedClientAuthenticationMethod;
|
|
2591
|
+
Object.defineProperty(exports, 'VerifiedClientAttestationJwt', {
|
|
2592
|
+
enumerable: true,
|
|
2593
|
+
get: function () {
|
|
2594
|
+
return VerifiedClientAttestationJwt;
|
|
2595
|
+
}
|
|
2596
|
+
});
|
|
2504
2597
|
exports.authorizationCodeGrantIdentifier = authorizationCodeGrantIdentifier;
|
|
2505
2598
|
exports.calculateJwkThumbprint = calculateJwkThumbprint;
|
|
2506
2599
|
exports.clientAuthenticationAnonymous = clientAuthenticationAnonymous;
|
|
@@ -2534,13 +2627,17 @@ Object.defineProperty(exports, 'setGlobalConfig', {
|
|
|
2534
2627
|
return __openid4vc_utils.setGlobalConfig;
|
|
2535
2628
|
}
|
|
2536
2629
|
});
|
|
2630
|
+
exports.verifyClientAttestationJwt = verifyClientAttestationJwt;
|
|
2537
2631
|
exports.verifyJwt = verifyJwt;
|
|
2632
|
+
exports.verifyJwtIdToken = verifyJwtIdToken;
|
|
2538
2633
|
exports.verifyResourceRequest = verifyResourceRequest;
|
|
2539
2634
|
exports.zAlgValueNotNone = zAlgValueNotNone;
|
|
2540
2635
|
exports.zAuthorizationCodeGrantIdentifier = zAuthorizationCodeGrantIdentifier;
|
|
2541
2636
|
exports.zAuthorizationServerMetadata = zAuthorizationServerMetadata;
|
|
2542
2637
|
exports.zCompactJwe = zCompactJwe;
|
|
2543
2638
|
exports.zCompactJwt = zCompactJwt;
|
|
2639
|
+
exports.zIdTokenJwtHeader = zIdTokenJwtHeader;
|
|
2640
|
+
exports.zIdTokenJwtPayload = zIdTokenJwtPayload;
|
|
2544
2641
|
exports.zJwk = zJwk;
|
|
2545
2642
|
exports.zJwkSet = zJwkSet;
|
|
2546
2643
|
exports.zJwtHeader = zJwtHeader;
|