@openid4vc/oauth2 0.3.0-alpha-20251031085020 → 0.3.0-alpha-20251031102233
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 +46 -1
- package/dist/index.d.ts +46 -1
- package/dist/index.js +249 -196
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +243 -197
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1630,6 +1630,9 @@ interface CreatePushedAuthorizationErrorResponseOptions {
|
|
|
1630
1630
|
}
|
|
1631
1631
|
//#endregion
|
|
1632
1632
|
//#region src/authorization-request/z-authorization-request.d.ts
|
|
1633
|
+
declare const zPushedAuthorizationRequestUriPrefix: z$1.ZodLiteral<"urn:ietf:params:oauth:request_uri:">;
|
|
1634
|
+
declare const pushedAuthorizationRequestUriPrefix: "urn:ietf:params:oauth:request_uri:";
|
|
1635
|
+
type PushedAuthorizationRequestUriPrefix = z$1.infer<typeof zPushedAuthorizationRequestUriPrefix>;
|
|
1633
1636
|
declare const zAuthorizationRequest: z$1.ZodObject<{
|
|
1634
1637
|
response_type: z$1.ZodString;
|
|
1635
1638
|
client_id: z$1.ZodString;
|
|
@@ -1652,6 +1655,16 @@ interface ParsePushedAuthorizationRequestOptions {
|
|
|
1652
1655
|
interface ParsePushedAuthorizationRequestResult extends ParseAuthorizationRequestResult {
|
|
1653
1656
|
authorizationRequest: AuthorizationRequest;
|
|
1654
1657
|
}
|
|
1658
|
+
interface ParsePushedAuthorizationRequestUriOptions {
|
|
1659
|
+
uri: string;
|
|
1660
|
+
}
|
|
1661
|
+
/**
|
|
1662
|
+
* Parse a pushed authorization request URI prefixed with `urn:ietf:params:oauth:request_uri:`
|
|
1663
|
+
* and returns the identifier, without the prefix.
|
|
1664
|
+
*
|
|
1665
|
+
* @throws {Oauth2ServerErrorResponseError}
|
|
1666
|
+
*/
|
|
1667
|
+
declare function parsePushedAuthorizationRequestUri(options: ParsePushedAuthorizationRequestUriOptions): string;
|
|
1655
1668
|
//#endregion
|
|
1656
1669
|
//#region src/authorization-request/verify-pushed-authorization-request.d.ts
|
|
1657
1670
|
type VerifyPushedAuthorizationRequestReturn = VerifyAuthorizationRequestReturn;
|
|
@@ -1659,6 +1672,38 @@ interface VerifyPushedAuthorizationRequestOptions extends VerifyAuthorizationReq
|
|
|
1659
1672
|
authorizationRequest: AuthorizationRequest;
|
|
1660
1673
|
}
|
|
1661
1674
|
//#endregion
|
|
1675
|
+
//#region src/authorization-response/z-authorization-response.d.ts
|
|
1676
|
+
declare const zAuthorizationResponse: z$1.ZodObject<{
|
|
1677
|
+
state: z$1.ZodOptional<z$1.ZodString>;
|
|
1678
|
+
code: z$1.ZodString;
|
|
1679
|
+
error: z$1.ZodOptional<z$1.ZodNever>;
|
|
1680
|
+
}, z$1.core.$loose>;
|
|
1681
|
+
declare const zAuthorizationResponseFromUriParams: z$1.ZodPipe<z$1.ZodPipe<z$1.ZodURL, z$1.ZodTransform<unknown, string>>, z$1.ZodObject<{
|
|
1682
|
+
state: z$1.ZodOptional<z$1.ZodString>;
|
|
1683
|
+
code: z$1.ZodString;
|
|
1684
|
+
error: z$1.ZodOptional<z$1.ZodNever>;
|
|
1685
|
+
}, z$1.core.$loose>>;
|
|
1686
|
+
type AuthorizationResponse = z$1.infer<typeof zAuthorizationResponse>;
|
|
1687
|
+
declare const zAuthorizationErrorResponse: z$1.ZodObject<{
|
|
1688
|
+
state: z$1.ZodOptional<z$1.ZodString>;
|
|
1689
|
+
code: z$1.ZodOptional<z$1.ZodNever>;
|
|
1690
|
+
error: z$1.ZodUnion<readonly [z$1.ZodEnum<typeof Oauth2ErrorCodes>, z$1.ZodString]>;
|
|
1691
|
+
error_description: z$1.ZodOptional<z$1.ZodString>;
|
|
1692
|
+
error_uri: z$1.ZodOptional<z$1.ZodString>;
|
|
1693
|
+
}, z$1.core.$loose>;
|
|
1694
|
+
type AuthorizationErrorResponse = z$1.infer<typeof zAuthorizationErrorResponse>;
|
|
1695
|
+
//#endregion
|
|
1696
|
+
//#region src/authorization-response/parse-authorization-response.d.ts
|
|
1697
|
+
interface ParseAuthorizationRequestOptions {
|
|
1698
|
+
url: string;
|
|
1699
|
+
}
|
|
1700
|
+
/**
|
|
1701
|
+
* Parse an authorization response redirect URL.
|
|
1702
|
+
*
|
|
1703
|
+
* @throws {Oauth2ServerErrorResponseError}
|
|
1704
|
+
*/
|
|
1705
|
+
declare function parseAuthorizationResponseRedirectUrl(options: ParseAuthorizationRequestOptions): AuthorizationResponse | AuthorizationErrorResponse;
|
|
1706
|
+
//#endregion
|
|
1662
1707
|
//#region src/common/jwk/jwk-thumbprint.d.ts
|
|
1663
1708
|
interface CalculateJwkThumbprintOptions {
|
|
1664
1709
|
/**
|
|
@@ -3340,5 +3385,5 @@ declare function verifyResourceRequest(options: VerifyResourceRequestOptions): P
|
|
|
3340
3385
|
authorizationServer: string;
|
|
3341
3386
|
}>;
|
|
3342
3387
|
//#endregion
|
|
3343
|
-
export { type AccessTokenErrorResponse, type AccessTokenProfileJwtPayload, type AccessTokenResponse, type AuthorizationChallengeErrorResponse, type AuthorizationChallengeRequest, type AuthorizationChallengeResponse, type AuthorizationCodeGrantIdentifier, type AuthorizationServerMetadata, type CalculateJwkThumbprintOptions, type CallbackContext, type ClientAttestationJwtHeader, type ClientAttestationJwtPayload, type ClientAttestationPopJwtHeader, type ClientAttestationPopJwtPayload, type ClientAuthenticationCallback, type ClientAuthenticationCallbackOptions, type ClientAuthenticationClientAttestationJwtOptions, type ClientAuthenticationClientSecretBasicOptions, type ClientAuthenticationClientSecretPostOptions, type ClientAuthenticationDynamicOptions, type ClientAuthenticationNoneOptions, type CreateAuthorizationRequestUrlOptions, type CreateClientAttestationJwtOptions, type CreatePkceReturn, type CreatePushedAuthorizationErrorResponseOptions, type CreatePushedAuthorizationResponseOptions, type DecodeJwtHeaderResult, type DecodeJwtOptions, type DecodeJwtResult, type DecryptJweCallback, type DecryptJweCallbackOptions, type EncryptJweCallback, type GenerateRandomCallback, HashAlgorithm, type HashCallback, type HttpMethod, IdTokenJwtHeader, IdTokenJwtPayload, InvalidFetchResponseError, type JweEncryptor, type Jwk, type JwkSet, type JwtHeader, type JwtPayload, type JwtSigner, type JwtSignerCustom, type JwtSignerDid, type JwtSignerJwk, type JwtSignerWithJwk, type JwtSignerX5c, Oauth2AuthorizationServer, type Oauth2AuthorizationServerOptions, Oauth2Client, Oauth2ClientAuthorizationChallengeError, Oauth2ClientErrorResponseError, type Oauth2ClientOptions, Oauth2Error, Oauth2ErrorCodes, type Oauth2ErrorOptions, type Oauth2ErrorResponse, Oauth2JwtParseError, Oauth2JwtVerificationError, Oauth2ResourceServer, type Oauth2ResourceServerOptions, Oauth2ResourceUnauthorizedError, Oauth2ServerErrorResponseError, type Oid4vcTsConfig, type ParseAuthorizationChallengeRequestOptions, type ParseAuthorizationChallengeRequestResult, type ParsePushedAuthorizationRequestOptions, type ParsePushedAuthorizationRequestResult, PkceCodeChallengeMethod, type PreAuthorizedCodeGrantIdentifier, type RefreshTokenGrantIdentifier, type RequestClientAttestationOptions, type RequestDpopOptions, type RequestLike, type ResourceRequestOptions, type ResourceRequestResponseNotOk, type ResourceRequestResponseOk, type RetrieveAuthorizationCodeAccessTokenOptions, type RetrievePreAuthorizedCodeAccessTokenOptions, type SignJwtCallback, SupportedAuthenticationScheme, SupportedClientAuthenticationMethod, type TokenIntrospectionResponse, type VerifiedClientAttestationJwt, type VerifyAccessTokenRequestReturn, type VerifyAuthorizationChallengeRequestOptions, type VerifyAuthorizationChallengeRequestReturn, VerifyIdTokenJwtOptions, type VerifyJwtCallback, type VerifyPushedAuthorizationRequestOptions, type VerifyPushedAuthorizationRequestReturn, type VerifyResourceRequestOptions, type WwwAuthenticateHeaderChallenge, authorizationCodeGrantIdentifier, calculateJwkThumbprint, clientAuthenticationAnonymous, clientAuthenticationClientAttestationJwt, clientAuthenticationClientSecretBasic, clientAuthenticationClientSecretPost, clientAuthenticationDynamic, clientAuthenticationNone, createClientAttestationJwt, decodeJwt, decodeJwtHeader, fetchAuthorizationServerMetadata, fetchJwks, fetchWellKnownMetadata, getAuthorizationServerMetadataFromList, getGlobalConfig, isJwkInSet, jwtHeaderFromJwtSigner, jwtSignerFromJwt, preAuthorizedCodeGrantIdentifier, refreshTokenGrantIdentifier, resourceRequest, setGlobalConfig, verifyClientAttestationJwt, verifyIdTokenJwt, verifyJwt, verifyResourceRequest, zAlgValueNotNone, zAuthorizationCodeGrantIdentifier, zAuthorizationServerMetadata, zCompactJwe, zCompactJwt, zIdTokenJwtHeader, zIdTokenJwtPayload, zJwk, zJwkSet, zJwtHeader, zJwtPayload, zOauth2ErrorResponse, zPreAuthorizedCodeGrantIdentifier, zRefreshTokenGrantIdentifier };
|
|
3388
|
+
export { type AccessTokenErrorResponse, type AccessTokenProfileJwtPayload, type AccessTokenResponse, type AuthorizationChallengeErrorResponse, type AuthorizationChallengeRequest, type AuthorizationChallengeResponse, type AuthorizationCodeGrantIdentifier, AuthorizationErrorResponse, AuthorizationResponse, type AuthorizationServerMetadata, type CalculateJwkThumbprintOptions, type CallbackContext, type ClientAttestationJwtHeader, type ClientAttestationJwtPayload, type ClientAttestationPopJwtHeader, type ClientAttestationPopJwtPayload, type ClientAuthenticationCallback, type ClientAuthenticationCallbackOptions, type ClientAuthenticationClientAttestationJwtOptions, type ClientAuthenticationClientSecretBasicOptions, type ClientAuthenticationClientSecretPostOptions, type ClientAuthenticationDynamicOptions, type ClientAuthenticationNoneOptions, type CreateAuthorizationRequestUrlOptions, type CreateClientAttestationJwtOptions, type CreatePkceReturn, type CreatePushedAuthorizationErrorResponseOptions, type CreatePushedAuthorizationResponseOptions, type DecodeJwtHeaderResult, type DecodeJwtOptions, type DecodeJwtResult, type DecryptJweCallback, type DecryptJweCallbackOptions, type EncryptJweCallback, type GenerateRandomCallback, HashAlgorithm, type HashCallback, type HttpMethod, IdTokenJwtHeader, IdTokenJwtPayload, InvalidFetchResponseError, type JweEncryptor, type Jwk, type JwkSet, type JwtHeader, type JwtPayload, type JwtSigner, type JwtSignerCustom, type JwtSignerDid, type JwtSignerJwk, type JwtSignerWithJwk, type JwtSignerX5c, Oauth2AuthorizationServer, type Oauth2AuthorizationServerOptions, Oauth2Client, Oauth2ClientAuthorizationChallengeError, Oauth2ClientErrorResponseError, type Oauth2ClientOptions, Oauth2Error, Oauth2ErrorCodes, type Oauth2ErrorOptions, type Oauth2ErrorResponse, Oauth2JwtParseError, Oauth2JwtVerificationError, Oauth2ResourceServer, type Oauth2ResourceServerOptions, Oauth2ResourceUnauthorizedError, Oauth2ServerErrorResponseError, type Oid4vcTsConfig, type ParseAuthorizationChallengeRequestOptions, type ParseAuthorizationChallengeRequestResult, ParseAuthorizationRequestOptions, type ParsePushedAuthorizationRequestOptions, type ParsePushedAuthorizationRequestResult, PkceCodeChallengeMethod, type PreAuthorizedCodeGrantIdentifier, type PushedAuthorizationRequestUriPrefix, type RefreshTokenGrantIdentifier, type RequestClientAttestationOptions, type RequestDpopOptions, type RequestLike, type ResourceRequestOptions, type ResourceRequestResponseNotOk, type ResourceRequestResponseOk, type RetrieveAuthorizationCodeAccessTokenOptions, type RetrievePreAuthorizedCodeAccessTokenOptions, type SignJwtCallback, SupportedAuthenticationScheme, SupportedClientAuthenticationMethod, type TokenIntrospectionResponse, type VerifiedClientAttestationJwt, type VerifyAccessTokenRequestReturn, type VerifyAuthorizationChallengeRequestOptions, type VerifyAuthorizationChallengeRequestReturn, VerifyIdTokenJwtOptions, type VerifyJwtCallback, type VerifyPushedAuthorizationRequestOptions, type VerifyPushedAuthorizationRequestReturn, type VerifyResourceRequestOptions, type WwwAuthenticateHeaderChallenge, authorizationCodeGrantIdentifier, calculateJwkThumbprint, clientAuthenticationAnonymous, clientAuthenticationClientAttestationJwt, clientAuthenticationClientSecretBasic, clientAuthenticationClientSecretPost, clientAuthenticationDynamic, clientAuthenticationNone, createClientAttestationJwt, decodeJwt, decodeJwtHeader, fetchAuthorizationServerMetadata, fetchJwks, fetchWellKnownMetadata, getAuthorizationServerMetadataFromList, getGlobalConfig, isJwkInSet, jwtHeaderFromJwtSigner, jwtSignerFromJwt, parseAuthorizationResponseRedirectUrl, parsePushedAuthorizationRequestUri, preAuthorizedCodeGrantIdentifier, pushedAuthorizationRequestUriPrefix, refreshTokenGrantIdentifier, resourceRequest, setGlobalConfig, verifyClientAttestationJwt, verifyIdTokenJwt, verifyJwt, verifyResourceRequest, zAlgValueNotNone, zAuthorizationCodeGrantIdentifier, zAuthorizationErrorResponse, zAuthorizationResponse, zAuthorizationResponseFromUriParams, zAuthorizationServerMetadata, zCompactJwe, zCompactJwt, zIdTokenJwtHeader, zIdTokenJwtPayload, zJwk, zJwkSet, zJwtHeader, zJwtPayload, zOauth2ErrorResponse, zPreAuthorizedCodeGrantIdentifier, zPushedAuthorizationRequestUriPrefix, zRefreshTokenGrantIdentifier };
|
|
3344
3389
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1630,6 +1630,9 @@ interface CreatePushedAuthorizationErrorResponseOptions {
|
|
|
1630
1630
|
}
|
|
1631
1631
|
//#endregion
|
|
1632
1632
|
//#region src/authorization-request/z-authorization-request.d.ts
|
|
1633
|
+
declare const zPushedAuthorizationRequestUriPrefix: z$1.ZodLiteral<"urn:ietf:params:oauth:request_uri:">;
|
|
1634
|
+
declare const pushedAuthorizationRequestUriPrefix: "urn:ietf:params:oauth:request_uri:";
|
|
1635
|
+
type PushedAuthorizationRequestUriPrefix = z$1.infer<typeof zPushedAuthorizationRequestUriPrefix>;
|
|
1633
1636
|
declare const zAuthorizationRequest: z$1.ZodObject<{
|
|
1634
1637
|
response_type: z$1.ZodString;
|
|
1635
1638
|
client_id: z$1.ZodString;
|
|
@@ -1652,6 +1655,16 @@ interface ParsePushedAuthorizationRequestOptions {
|
|
|
1652
1655
|
interface ParsePushedAuthorizationRequestResult extends ParseAuthorizationRequestResult {
|
|
1653
1656
|
authorizationRequest: AuthorizationRequest;
|
|
1654
1657
|
}
|
|
1658
|
+
interface ParsePushedAuthorizationRequestUriOptions {
|
|
1659
|
+
uri: string;
|
|
1660
|
+
}
|
|
1661
|
+
/**
|
|
1662
|
+
* Parse a pushed authorization request URI prefixed with `urn:ietf:params:oauth:request_uri:`
|
|
1663
|
+
* and returns the identifier, without the prefix.
|
|
1664
|
+
*
|
|
1665
|
+
* @throws {Oauth2ServerErrorResponseError}
|
|
1666
|
+
*/
|
|
1667
|
+
declare function parsePushedAuthorizationRequestUri(options: ParsePushedAuthorizationRequestUriOptions): string;
|
|
1655
1668
|
//#endregion
|
|
1656
1669
|
//#region src/authorization-request/verify-pushed-authorization-request.d.ts
|
|
1657
1670
|
type VerifyPushedAuthorizationRequestReturn = VerifyAuthorizationRequestReturn;
|
|
@@ -1659,6 +1672,38 @@ interface VerifyPushedAuthorizationRequestOptions extends VerifyAuthorizationReq
|
|
|
1659
1672
|
authorizationRequest: AuthorizationRequest;
|
|
1660
1673
|
}
|
|
1661
1674
|
//#endregion
|
|
1675
|
+
//#region src/authorization-response/z-authorization-response.d.ts
|
|
1676
|
+
declare const zAuthorizationResponse: z$1.ZodObject<{
|
|
1677
|
+
state: z$1.ZodOptional<z$1.ZodString>;
|
|
1678
|
+
code: z$1.ZodString;
|
|
1679
|
+
error: z$1.ZodOptional<z$1.ZodNever>;
|
|
1680
|
+
}, z$1.core.$loose>;
|
|
1681
|
+
declare const zAuthorizationResponseFromUriParams: z$1.ZodPipe<z$1.ZodPipe<z$1.ZodURL, z$1.ZodTransform<unknown, string>>, z$1.ZodObject<{
|
|
1682
|
+
state: z$1.ZodOptional<z$1.ZodString>;
|
|
1683
|
+
code: z$1.ZodString;
|
|
1684
|
+
error: z$1.ZodOptional<z$1.ZodNever>;
|
|
1685
|
+
}, z$1.core.$loose>>;
|
|
1686
|
+
type AuthorizationResponse = z$1.infer<typeof zAuthorizationResponse>;
|
|
1687
|
+
declare const zAuthorizationErrorResponse: z$1.ZodObject<{
|
|
1688
|
+
state: z$1.ZodOptional<z$1.ZodString>;
|
|
1689
|
+
code: z$1.ZodOptional<z$1.ZodNever>;
|
|
1690
|
+
error: z$1.ZodUnion<readonly [z$1.ZodEnum<typeof Oauth2ErrorCodes>, z$1.ZodString]>;
|
|
1691
|
+
error_description: z$1.ZodOptional<z$1.ZodString>;
|
|
1692
|
+
error_uri: z$1.ZodOptional<z$1.ZodString>;
|
|
1693
|
+
}, z$1.core.$loose>;
|
|
1694
|
+
type AuthorizationErrorResponse = z$1.infer<typeof zAuthorizationErrorResponse>;
|
|
1695
|
+
//#endregion
|
|
1696
|
+
//#region src/authorization-response/parse-authorization-response.d.ts
|
|
1697
|
+
interface ParseAuthorizationRequestOptions {
|
|
1698
|
+
url: string;
|
|
1699
|
+
}
|
|
1700
|
+
/**
|
|
1701
|
+
* Parse an authorization response redirect URL.
|
|
1702
|
+
*
|
|
1703
|
+
* @throws {Oauth2ServerErrorResponseError}
|
|
1704
|
+
*/
|
|
1705
|
+
declare function parseAuthorizationResponseRedirectUrl(options: ParseAuthorizationRequestOptions): AuthorizationResponse | AuthorizationErrorResponse;
|
|
1706
|
+
//#endregion
|
|
1662
1707
|
//#region src/common/jwk/jwk-thumbprint.d.ts
|
|
1663
1708
|
interface CalculateJwkThumbprintOptions {
|
|
1664
1709
|
/**
|
|
@@ -3340,5 +3385,5 @@ declare function verifyResourceRequest(options: VerifyResourceRequestOptions): P
|
|
|
3340
3385
|
authorizationServer: string;
|
|
3341
3386
|
}>;
|
|
3342
3387
|
//#endregion
|
|
3343
|
-
export { type AccessTokenErrorResponse, type AccessTokenProfileJwtPayload, type AccessTokenResponse, type AuthorizationChallengeErrorResponse, type AuthorizationChallengeRequest, type AuthorizationChallengeResponse, type AuthorizationCodeGrantIdentifier, type AuthorizationServerMetadata, type CalculateJwkThumbprintOptions, type CallbackContext, type ClientAttestationJwtHeader, type ClientAttestationJwtPayload, type ClientAttestationPopJwtHeader, type ClientAttestationPopJwtPayload, type ClientAuthenticationCallback, type ClientAuthenticationCallbackOptions, type ClientAuthenticationClientAttestationJwtOptions, type ClientAuthenticationClientSecretBasicOptions, type ClientAuthenticationClientSecretPostOptions, type ClientAuthenticationDynamicOptions, type ClientAuthenticationNoneOptions, type CreateAuthorizationRequestUrlOptions, type CreateClientAttestationJwtOptions, type CreatePkceReturn, type CreatePushedAuthorizationErrorResponseOptions, type CreatePushedAuthorizationResponseOptions, type DecodeJwtHeaderResult, type DecodeJwtOptions, type DecodeJwtResult, type DecryptJweCallback, type DecryptJweCallbackOptions, type EncryptJweCallback, type GenerateRandomCallback, HashAlgorithm, type HashCallback, type HttpMethod, IdTokenJwtHeader, IdTokenJwtPayload, InvalidFetchResponseError, type JweEncryptor, type Jwk, type JwkSet, type JwtHeader, type JwtPayload, type JwtSigner, type JwtSignerCustom, type JwtSignerDid, type JwtSignerJwk, type JwtSignerWithJwk, type JwtSignerX5c, Oauth2AuthorizationServer, type Oauth2AuthorizationServerOptions, Oauth2Client, Oauth2ClientAuthorizationChallengeError, Oauth2ClientErrorResponseError, type Oauth2ClientOptions, Oauth2Error, Oauth2ErrorCodes, type Oauth2ErrorOptions, type Oauth2ErrorResponse, Oauth2JwtParseError, Oauth2JwtVerificationError, Oauth2ResourceServer, type Oauth2ResourceServerOptions, Oauth2ResourceUnauthorizedError, Oauth2ServerErrorResponseError, type Oid4vcTsConfig, type ParseAuthorizationChallengeRequestOptions, type ParseAuthorizationChallengeRequestResult, type ParsePushedAuthorizationRequestOptions, type ParsePushedAuthorizationRequestResult, PkceCodeChallengeMethod, type PreAuthorizedCodeGrantIdentifier, type RefreshTokenGrantIdentifier, type RequestClientAttestationOptions, type RequestDpopOptions, type RequestLike, type ResourceRequestOptions, type ResourceRequestResponseNotOk, type ResourceRequestResponseOk, type RetrieveAuthorizationCodeAccessTokenOptions, type RetrievePreAuthorizedCodeAccessTokenOptions, type SignJwtCallback, SupportedAuthenticationScheme, SupportedClientAuthenticationMethod, type TokenIntrospectionResponse, type VerifiedClientAttestationJwt, type VerifyAccessTokenRequestReturn, type VerifyAuthorizationChallengeRequestOptions, type VerifyAuthorizationChallengeRequestReturn, VerifyIdTokenJwtOptions, type VerifyJwtCallback, type VerifyPushedAuthorizationRequestOptions, type VerifyPushedAuthorizationRequestReturn, type VerifyResourceRequestOptions, type WwwAuthenticateHeaderChallenge, authorizationCodeGrantIdentifier, calculateJwkThumbprint, clientAuthenticationAnonymous, clientAuthenticationClientAttestationJwt, clientAuthenticationClientSecretBasic, clientAuthenticationClientSecretPost, clientAuthenticationDynamic, clientAuthenticationNone, createClientAttestationJwt, decodeJwt, decodeJwtHeader, fetchAuthorizationServerMetadata, fetchJwks, fetchWellKnownMetadata, getAuthorizationServerMetadataFromList, getGlobalConfig, isJwkInSet, jwtHeaderFromJwtSigner, jwtSignerFromJwt, preAuthorizedCodeGrantIdentifier, refreshTokenGrantIdentifier, resourceRequest, setGlobalConfig, verifyClientAttestationJwt, verifyIdTokenJwt, verifyJwt, verifyResourceRequest, zAlgValueNotNone, zAuthorizationCodeGrantIdentifier, zAuthorizationServerMetadata, zCompactJwe, zCompactJwt, zIdTokenJwtHeader, zIdTokenJwtPayload, zJwk, zJwkSet, zJwtHeader, zJwtPayload, zOauth2ErrorResponse, zPreAuthorizedCodeGrantIdentifier, zRefreshTokenGrantIdentifier };
|
|
3388
|
+
export { type AccessTokenErrorResponse, type AccessTokenProfileJwtPayload, type AccessTokenResponse, type AuthorizationChallengeErrorResponse, type AuthorizationChallengeRequest, type AuthorizationChallengeResponse, type AuthorizationCodeGrantIdentifier, AuthorizationErrorResponse, AuthorizationResponse, type AuthorizationServerMetadata, type CalculateJwkThumbprintOptions, type CallbackContext, type ClientAttestationJwtHeader, type ClientAttestationJwtPayload, type ClientAttestationPopJwtHeader, type ClientAttestationPopJwtPayload, type ClientAuthenticationCallback, type ClientAuthenticationCallbackOptions, type ClientAuthenticationClientAttestationJwtOptions, type ClientAuthenticationClientSecretBasicOptions, type ClientAuthenticationClientSecretPostOptions, type ClientAuthenticationDynamicOptions, type ClientAuthenticationNoneOptions, type CreateAuthorizationRequestUrlOptions, type CreateClientAttestationJwtOptions, type CreatePkceReturn, type CreatePushedAuthorizationErrorResponseOptions, type CreatePushedAuthorizationResponseOptions, type DecodeJwtHeaderResult, type DecodeJwtOptions, type DecodeJwtResult, type DecryptJweCallback, type DecryptJweCallbackOptions, type EncryptJweCallback, type GenerateRandomCallback, HashAlgorithm, type HashCallback, type HttpMethod, IdTokenJwtHeader, IdTokenJwtPayload, InvalidFetchResponseError, type JweEncryptor, type Jwk, type JwkSet, type JwtHeader, type JwtPayload, type JwtSigner, type JwtSignerCustom, type JwtSignerDid, type JwtSignerJwk, type JwtSignerWithJwk, type JwtSignerX5c, Oauth2AuthorizationServer, type Oauth2AuthorizationServerOptions, Oauth2Client, Oauth2ClientAuthorizationChallengeError, Oauth2ClientErrorResponseError, type Oauth2ClientOptions, Oauth2Error, Oauth2ErrorCodes, type Oauth2ErrorOptions, type Oauth2ErrorResponse, Oauth2JwtParseError, Oauth2JwtVerificationError, Oauth2ResourceServer, type Oauth2ResourceServerOptions, Oauth2ResourceUnauthorizedError, Oauth2ServerErrorResponseError, type Oid4vcTsConfig, type ParseAuthorizationChallengeRequestOptions, type ParseAuthorizationChallengeRequestResult, ParseAuthorizationRequestOptions, type ParsePushedAuthorizationRequestOptions, type ParsePushedAuthorizationRequestResult, PkceCodeChallengeMethod, type PreAuthorizedCodeGrantIdentifier, type PushedAuthorizationRequestUriPrefix, type RefreshTokenGrantIdentifier, type RequestClientAttestationOptions, type RequestDpopOptions, type RequestLike, type ResourceRequestOptions, type ResourceRequestResponseNotOk, type ResourceRequestResponseOk, type RetrieveAuthorizationCodeAccessTokenOptions, type RetrievePreAuthorizedCodeAccessTokenOptions, type SignJwtCallback, SupportedAuthenticationScheme, SupportedClientAuthenticationMethod, type TokenIntrospectionResponse, type VerifiedClientAttestationJwt, type VerifyAccessTokenRequestReturn, type VerifyAuthorizationChallengeRequestOptions, type VerifyAuthorizationChallengeRequestReturn, VerifyIdTokenJwtOptions, type VerifyJwtCallback, type VerifyPushedAuthorizationRequestOptions, type VerifyPushedAuthorizationRequestReturn, type VerifyResourceRequestOptions, type WwwAuthenticateHeaderChallenge, authorizationCodeGrantIdentifier, calculateJwkThumbprint, clientAuthenticationAnonymous, clientAuthenticationClientAttestationJwt, clientAuthenticationClientSecretBasic, clientAuthenticationClientSecretPost, clientAuthenticationDynamic, clientAuthenticationNone, createClientAttestationJwt, decodeJwt, decodeJwtHeader, fetchAuthorizationServerMetadata, fetchJwks, fetchWellKnownMetadata, getAuthorizationServerMetadataFromList, getGlobalConfig, isJwkInSet, jwtHeaderFromJwtSigner, jwtSignerFromJwt, parseAuthorizationResponseRedirectUrl, parsePushedAuthorizationRequestUri, preAuthorizedCodeGrantIdentifier, pushedAuthorizationRequestUriPrefix, refreshTokenGrantIdentifier, resourceRequest, setGlobalConfig, verifyClientAttestationJwt, verifyIdTokenJwt, verifyJwt, verifyResourceRequest, zAlgValueNotNone, zAuthorizationCodeGrantIdentifier, zAuthorizationErrorResponse, zAuthorizationResponse, zAuthorizationResponseFromUriParams, zAuthorizationServerMetadata, zCompactJwe, zCompactJwt, zIdTokenJwtHeader, zIdTokenJwtPayload, zJwk, zJwkSet, zJwtHeader, zJwtPayload, zOauth2ErrorResponse, zPreAuthorizedCodeGrantIdentifier, zPushedAuthorizationRequestUriPrefix, zRefreshTokenGrantIdentifier };
|
|
3344
3389
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -718,6 +718,248 @@ async function verifyClientAttestation({ authorizationServer, clientAttestationJ
|
|
|
718
718
|
}
|
|
719
719
|
}
|
|
720
720
|
|
|
721
|
+
//#endregion
|
|
722
|
+
//#region src/dpop/z-dpop.ts
|
|
723
|
+
const zDpopJwtPayload = zod.default.object({
|
|
724
|
+
...zJwtPayload.shape,
|
|
725
|
+
iat: __openid4vc_utils.zInteger,
|
|
726
|
+
htu: __openid4vc_utils.zHttpsUrl,
|
|
727
|
+
htm: __openid4vc_utils.zHttpMethod,
|
|
728
|
+
jti: zod.default.string(),
|
|
729
|
+
ath: zod.default.optional(zod.default.string())
|
|
730
|
+
}).loose();
|
|
731
|
+
const zDpopJwtHeader = zod.default.object({
|
|
732
|
+
...zJwtHeader.shape,
|
|
733
|
+
typ: zod.default.literal("dpop+jwt"),
|
|
734
|
+
jwk: zJwk
|
|
735
|
+
}).loose();
|
|
736
|
+
|
|
737
|
+
//#endregion
|
|
738
|
+
//#region src/dpop/dpop.ts
|
|
739
|
+
async function createDpopHeadersForRequest(options) {
|
|
740
|
+
return { DPoP: await createDpopJwt(options) };
|
|
741
|
+
}
|
|
742
|
+
async function createDpopJwt(options) {
|
|
743
|
+
let ath;
|
|
744
|
+
if (options.accessToken) ath = (0, __openid4vc_utils.encodeToBase64Url)(await options.callbacks.hash((0, __openid4vc_utils.decodeUtf8String)(options.accessToken), HashAlgorithm.Sha256));
|
|
745
|
+
const header = (0, __openid4vc_utils.parseWithErrorHandling)(zDpopJwtHeader, {
|
|
746
|
+
typ: "dpop+jwt",
|
|
747
|
+
jwk: options.signer.publicJwk,
|
|
748
|
+
alg: options.signer.alg
|
|
749
|
+
});
|
|
750
|
+
const payload = (0, __openid4vc_utils.parseWithErrorHandling)(zDpopJwtPayload, {
|
|
751
|
+
htu: htuFromRequestUrl(options.request.url),
|
|
752
|
+
iat: (0, __openid4vc_utils.dateToSeconds)(options.issuedAt),
|
|
753
|
+
htm: options.request.method,
|
|
754
|
+
jti: (0, __openid4vc_utils.encodeToBase64Url)(await options.callbacks.generateRandom(32)),
|
|
755
|
+
ath,
|
|
756
|
+
nonce: options.nonce,
|
|
757
|
+
...options.additionalPayload
|
|
758
|
+
});
|
|
759
|
+
const { jwt } = await options.callbacks.signJwt(options.signer, {
|
|
760
|
+
header,
|
|
761
|
+
payload
|
|
762
|
+
});
|
|
763
|
+
return jwt;
|
|
764
|
+
}
|
|
765
|
+
async function verifyDpopJwt(options) {
|
|
766
|
+
try {
|
|
767
|
+
const { header, payload } = decodeJwt({
|
|
768
|
+
jwt: options.dpopJwt,
|
|
769
|
+
headerSchema: zDpopJwtHeader,
|
|
770
|
+
payloadSchema: zDpopJwtPayload
|
|
771
|
+
});
|
|
772
|
+
if (options.allowedSigningAlgs && !options.allowedSigningAlgs.includes(header.alg)) throw new Oauth2Error(`dpop jwt uses alg value '${header.alg}' but allowed dpop signging alg values are ${options.allowedSigningAlgs.join(", ")}.`);
|
|
773
|
+
if (options.expectedNonce) {
|
|
774
|
+
if (!payload.nonce) throw new Oauth2Error(`Dpop jwt does not have a nonce value, but expected nonce value '${options.expectedNonce}'`);
|
|
775
|
+
if (payload.nonce !== options.expectedNonce) throw new Oauth2Error(`Dpop jwt contains nonce value '${payload.nonce}', but expected nonce value '${options.expectedNonce}'`);
|
|
776
|
+
}
|
|
777
|
+
if (options.request.method !== payload.htm) throw new Oauth2Error(`Dpop jwt contains htm value '${payload.htm}', but expected htm value '${options.request.method}'`);
|
|
778
|
+
const expectedHtu = htuFromRequestUrl(options.request.url);
|
|
779
|
+
if (expectedHtu !== payload.htu) throw new Oauth2Error(`Dpop jwt contains htu value '${payload.htu}', but expected htu value '${expectedHtu}'.`);
|
|
780
|
+
if (options.accessToken) {
|
|
781
|
+
const expectedAth = (0, __openid4vc_utils.encodeToBase64Url)(await options.callbacks.hash((0, __openid4vc_utils.decodeUtf8String)(options.accessToken), HashAlgorithm.Sha256));
|
|
782
|
+
if (!payload.ath) throw new Oauth2Error(`Dpop jwt does not have a ath value, but expected ath value '${expectedAth}'.`);
|
|
783
|
+
if (payload.ath !== expectedAth) throw new Oauth2Error(`Dpop jwt contains ath value '${payload.ath}', but expected ath value '${expectedAth}'.`);
|
|
784
|
+
}
|
|
785
|
+
const jwkThumbprint = await calculateJwkThumbprint({
|
|
786
|
+
hashAlgorithm: HashAlgorithm.Sha256,
|
|
787
|
+
hashCallback: options.callbacks.hash,
|
|
788
|
+
jwk: header.jwk
|
|
789
|
+
});
|
|
790
|
+
if (options.expectedJwkThumbprint && options.expectedJwkThumbprint !== jwkThumbprint) throw new Oauth2Error(`Dpop is signed with jwk with thumbprint value '${jwkThumbprint}', but expect jwk thumbprint value '${options.expectedJwkThumbprint}'`);
|
|
791
|
+
await verifyJwt({
|
|
792
|
+
signer: {
|
|
793
|
+
alg: header.alg,
|
|
794
|
+
method: "jwk",
|
|
795
|
+
publicJwk: header.jwk
|
|
796
|
+
},
|
|
797
|
+
now: options.now,
|
|
798
|
+
header,
|
|
799
|
+
payload,
|
|
800
|
+
compact: options.dpopJwt,
|
|
801
|
+
verifyJwtCallback: options.callbacks.verifyJwt,
|
|
802
|
+
errorMessage: "dpop jwt verification failed"
|
|
803
|
+
});
|
|
804
|
+
return {
|
|
805
|
+
header,
|
|
806
|
+
payload,
|
|
807
|
+
jwkThumbprint
|
|
808
|
+
};
|
|
809
|
+
} catch (error) {
|
|
810
|
+
if (error instanceof Oauth2Error) throw new Oauth2ServerErrorResponseError({
|
|
811
|
+
error: Oauth2ErrorCodes.InvalidDpopProof,
|
|
812
|
+
error_description: error.message
|
|
813
|
+
});
|
|
814
|
+
throw error;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
function htuFromRequestUrl(requestUrl) {
|
|
818
|
+
const htu = new __openid4vc_utils.URL(requestUrl);
|
|
819
|
+
htu.search = "";
|
|
820
|
+
htu.hash = "";
|
|
821
|
+
return htu.toString();
|
|
822
|
+
}
|
|
823
|
+
function extractDpopNonceFromHeaders(headers) {
|
|
824
|
+
return headers.get("DPoP-Nonce");
|
|
825
|
+
}
|
|
826
|
+
function extractDpopJwtFromHeaders(headers) {
|
|
827
|
+
const dpopJwt = headers.get("DPoP");
|
|
828
|
+
if (!dpopJwt) return { valid: true };
|
|
829
|
+
if (!zCompactJwt.safeParse(dpopJwt).success) return { valid: false };
|
|
830
|
+
return {
|
|
831
|
+
valid: true,
|
|
832
|
+
dpopJwt
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
//#endregion
|
|
837
|
+
//#region src/authorization-request/parse-authorization-request.ts
|
|
838
|
+
/**
|
|
839
|
+
* Parse an authorization request.
|
|
840
|
+
*
|
|
841
|
+
* @throws {Oauth2ServerErrorResponseError}
|
|
842
|
+
*/
|
|
843
|
+
function parseAuthorizationRequest(options) {
|
|
844
|
+
const extractedDpopJwt = extractDpopJwtFromHeaders(options.request.headers);
|
|
845
|
+
if (!extractedDpopJwt.valid) throw new Oauth2ServerErrorResponseError({
|
|
846
|
+
error: Oauth2ErrorCodes.InvalidDpopProof,
|
|
847
|
+
error_description: `Request contains a 'DPoP' header, but the value is not a valid DPoP jwt`
|
|
848
|
+
});
|
|
849
|
+
const extractedClientAttestationJwts = extractClientAttestationJwtsFromHeaders(options.request.headers);
|
|
850
|
+
if (!extractedClientAttestationJwts.valid) throw new Oauth2ServerErrorResponseError({
|
|
851
|
+
error: Oauth2ErrorCodes.InvalidClient,
|
|
852
|
+
error_description: "Request contains client attestation header, but the values are not valid client attestation and client attestation PoP header."
|
|
853
|
+
});
|
|
854
|
+
return {
|
|
855
|
+
dpop: extractedDpopJwt.dpopJwt ? {
|
|
856
|
+
jwt: extractedDpopJwt.dpopJwt,
|
|
857
|
+
jwkThumbprint: options.authorizationRequest.dpop_jkt
|
|
858
|
+
} : options.authorizationRequest.dpop_jkt ? {
|
|
859
|
+
jwt: extractedDpopJwt.dpopJwt,
|
|
860
|
+
jwkThumbprint: options.authorizationRequest.dpop_jkt
|
|
861
|
+
} : void 0,
|
|
862
|
+
clientAttestation: extractedClientAttestationJwts.clientAttestationHeader ? {
|
|
863
|
+
clientAttestationJwt: extractedClientAttestationJwts.clientAttestationHeader,
|
|
864
|
+
clientAttestationPopJwt: extractedClientAttestationJwts.clientAttestationPopHeader
|
|
865
|
+
} : void 0
|
|
866
|
+
};
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
//#endregion
|
|
870
|
+
//#region src/authorization-request/z-authorization-request.ts
|
|
871
|
+
const zPushedAuthorizationRequestUriPrefix = zod.default.literal("urn:ietf:params:oauth:request_uri:");
|
|
872
|
+
const pushedAuthorizationRequestUriPrefix = zPushedAuthorizationRequestUriPrefix.value;
|
|
873
|
+
const zAuthorizationRequest = zod.default.object({
|
|
874
|
+
response_type: zod.default.string(),
|
|
875
|
+
client_id: zod.default.string(),
|
|
876
|
+
issuer_state: zod.default.optional(zod.default.string()),
|
|
877
|
+
redirect_uri: zod.default.url().optional(),
|
|
878
|
+
resource: zod.default.optional(__openid4vc_utils.zHttpsUrl),
|
|
879
|
+
scope: zod.default.optional(zod.default.string()),
|
|
880
|
+
state: zod.default.optional(zod.default.string()),
|
|
881
|
+
dpop_jkt: zod.default.optional(zod.default.base64url()),
|
|
882
|
+
code_challenge: zod.default.optional(zod.default.string()),
|
|
883
|
+
code_challenge_method: zod.default.optional(zod.default.string())
|
|
884
|
+
}).loose();
|
|
885
|
+
const zPushedAuthorizationRequest = zod.default.object({
|
|
886
|
+
request_uri: zod.default.string(),
|
|
887
|
+
client_id: zod.default.string()
|
|
888
|
+
}).loose();
|
|
889
|
+
const zPushedAuthorizationResponse = zod.default.object({
|
|
890
|
+
request_uri: zod.default.string(),
|
|
891
|
+
expires_in: zod.default.number().int()
|
|
892
|
+
}).loose();
|
|
893
|
+
|
|
894
|
+
//#endregion
|
|
895
|
+
//#region src/authorization-request/parse-pushed-authorization-request.ts
|
|
896
|
+
/**
|
|
897
|
+
* Parse an pushed authorization request.
|
|
898
|
+
*
|
|
899
|
+
* @throws {Oauth2ServerErrorResponseError}
|
|
900
|
+
*/
|
|
901
|
+
function parsePushedAuthorizationRequest(options) {
|
|
902
|
+
const parsedAuthorizationRequest = zAuthorizationRequest.safeParse(options.authorizationRequest);
|
|
903
|
+
if (!parsedAuthorizationRequest.success) throw new Oauth2ServerErrorResponseError({
|
|
904
|
+
error: Oauth2ErrorCodes.InvalidRequest,
|
|
905
|
+
error_description: `Error occurred during validation of pushed authorization request.\n${(0, __openid4vc_utils.formatZodError)(parsedAuthorizationRequest.error)}`
|
|
906
|
+
});
|
|
907
|
+
const authorizationRequest = parsedAuthorizationRequest.data;
|
|
908
|
+
const { clientAttestation, dpop } = parseAuthorizationRequest({
|
|
909
|
+
authorizationRequest,
|
|
910
|
+
request: options.request
|
|
911
|
+
});
|
|
912
|
+
return {
|
|
913
|
+
authorizationRequest,
|
|
914
|
+
dpop,
|
|
915
|
+
clientAttestation
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
/**
|
|
919
|
+
* Parse a pushed authorization request URI prefixed with `urn:ietf:params:oauth:request_uri:`
|
|
920
|
+
* and returns the identifier, without the prefix.
|
|
921
|
+
*
|
|
922
|
+
* @throws {Oauth2ServerErrorResponseError}
|
|
923
|
+
*/
|
|
924
|
+
function parsePushedAuthorizationRequestUri(options) {
|
|
925
|
+
if (!options.uri.startsWith(pushedAuthorizationRequestUriPrefix)) throw new Oauth2ServerErrorResponseError({
|
|
926
|
+
error: Oauth2ErrorCodes.InvalidRequest,
|
|
927
|
+
error_description: `The 'request_uri' must start with the prefix "${pushedAuthorizationRequestUriPrefix}".`
|
|
928
|
+
});
|
|
929
|
+
return options.uri.substring(pushedAuthorizationRequestUriPrefix.length);
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
//#endregion
|
|
933
|
+
//#region src/authorization-response/z-authorization-response.ts
|
|
934
|
+
const zAuthorizationResponse = zod.default.object({
|
|
935
|
+
state: zod.default.string().optional(),
|
|
936
|
+
code: zod.default.string().nonempty(),
|
|
937
|
+
error: zod.default.optional(zod.default.never())
|
|
938
|
+
}).loose();
|
|
939
|
+
const zAuthorizationResponseFromUriParams = zod.default.url().transform((url) => Object.fromEntries(new __openid4vc_utils.URL(url).searchParams)).pipe(zAuthorizationResponse);
|
|
940
|
+
const zAuthorizationErrorResponse = zod.default.object({
|
|
941
|
+
...zOauth2ErrorResponse.shape,
|
|
942
|
+
state: zod.default.string().optional(),
|
|
943
|
+
code: zod.default.optional(zod.default.never())
|
|
944
|
+
}).loose();
|
|
945
|
+
|
|
946
|
+
//#endregion
|
|
947
|
+
//#region src/authorization-response/parse-authorization-response.ts
|
|
948
|
+
/**
|
|
949
|
+
* Parse an authorization response redirect URL.
|
|
950
|
+
*
|
|
951
|
+
* @throws {Oauth2ServerErrorResponseError}
|
|
952
|
+
*/
|
|
953
|
+
function parseAuthorizationResponseRedirectUrl(options) {
|
|
954
|
+
const searchParams = Object.fromEntries(new __openid4vc_utils.URL(options.url).searchParams);
|
|
955
|
+
const parsedAuthorizationResponse = zod.default.union([zAuthorizationErrorResponse, zAuthorizationResponse]).safeParse(searchParams);
|
|
956
|
+
if (!parsedAuthorizationResponse.success) throw new Oauth2ServerErrorResponseError({
|
|
957
|
+
error: Oauth2ErrorCodes.InvalidRequest,
|
|
958
|
+
error_description: `Error occurred during validation of authorization response redirect URL.\n${(0, __openid4vc_utils.formatZodError)(parsedAuthorizationResponse.error)}`
|
|
959
|
+
});
|
|
960
|
+
return parsedAuthorizationResponse.data;
|
|
961
|
+
}
|
|
962
|
+
|
|
721
963
|
//#endregion
|
|
722
964
|
//#region src/z-grant-type.ts
|
|
723
965
|
const zPreAuthorizedCodeGrantIdentifier = zod.default.literal("urn:ietf:params:oauth:grant-type:pre-authorized_code");
|
|
@@ -1120,121 +1362,6 @@ async function createAccessTokenResponse(options) {
|
|
|
1120
1362
|
});
|
|
1121
1363
|
}
|
|
1122
1364
|
|
|
1123
|
-
//#endregion
|
|
1124
|
-
//#region src/dpop/z-dpop.ts
|
|
1125
|
-
const zDpopJwtPayload = zod.default.object({
|
|
1126
|
-
...zJwtPayload.shape,
|
|
1127
|
-
iat: __openid4vc_utils.zInteger,
|
|
1128
|
-
htu: __openid4vc_utils.zHttpsUrl,
|
|
1129
|
-
htm: __openid4vc_utils.zHttpMethod,
|
|
1130
|
-
jti: zod.default.string(),
|
|
1131
|
-
ath: zod.default.optional(zod.default.string())
|
|
1132
|
-
}).loose();
|
|
1133
|
-
const zDpopJwtHeader = zod.default.object({
|
|
1134
|
-
...zJwtHeader.shape,
|
|
1135
|
-
typ: zod.default.literal("dpop+jwt"),
|
|
1136
|
-
jwk: zJwk
|
|
1137
|
-
}).loose();
|
|
1138
|
-
|
|
1139
|
-
//#endregion
|
|
1140
|
-
//#region src/dpop/dpop.ts
|
|
1141
|
-
async function createDpopHeadersForRequest(options) {
|
|
1142
|
-
return { DPoP: await createDpopJwt(options) };
|
|
1143
|
-
}
|
|
1144
|
-
async function createDpopJwt(options) {
|
|
1145
|
-
let ath;
|
|
1146
|
-
if (options.accessToken) ath = (0, __openid4vc_utils.encodeToBase64Url)(await options.callbacks.hash((0, __openid4vc_utils.decodeUtf8String)(options.accessToken), HashAlgorithm.Sha256));
|
|
1147
|
-
const header = (0, __openid4vc_utils.parseWithErrorHandling)(zDpopJwtHeader, {
|
|
1148
|
-
typ: "dpop+jwt",
|
|
1149
|
-
jwk: options.signer.publicJwk,
|
|
1150
|
-
alg: options.signer.alg
|
|
1151
|
-
});
|
|
1152
|
-
const payload = (0, __openid4vc_utils.parseWithErrorHandling)(zDpopJwtPayload, {
|
|
1153
|
-
htu: htuFromRequestUrl(options.request.url),
|
|
1154
|
-
iat: (0, __openid4vc_utils.dateToSeconds)(options.issuedAt),
|
|
1155
|
-
htm: options.request.method,
|
|
1156
|
-
jti: (0, __openid4vc_utils.encodeToBase64Url)(await options.callbacks.generateRandom(32)),
|
|
1157
|
-
ath,
|
|
1158
|
-
nonce: options.nonce,
|
|
1159
|
-
...options.additionalPayload
|
|
1160
|
-
});
|
|
1161
|
-
const { jwt } = await options.callbacks.signJwt(options.signer, {
|
|
1162
|
-
header,
|
|
1163
|
-
payload
|
|
1164
|
-
});
|
|
1165
|
-
return jwt;
|
|
1166
|
-
}
|
|
1167
|
-
async function verifyDpopJwt(options) {
|
|
1168
|
-
try {
|
|
1169
|
-
const { header, payload } = decodeJwt({
|
|
1170
|
-
jwt: options.dpopJwt,
|
|
1171
|
-
headerSchema: zDpopJwtHeader,
|
|
1172
|
-
payloadSchema: zDpopJwtPayload
|
|
1173
|
-
});
|
|
1174
|
-
if (options.allowedSigningAlgs && !options.allowedSigningAlgs.includes(header.alg)) throw new Oauth2Error(`dpop jwt uses alg value '${header.alg}' but allowed dpop signging alg values are ${options.allowedSigningAlgs.join(", ")}.`);
|
|
1175
|
-
if (options.expectedNonce) {
|
|
1176
|
-
if (!payload.nonce) throw new Oauth2Error(`Dpop jwt does not have a nonce value, but expected nonce value '${options.expectedNonce}'`);
|
|
1177
|
-
if (payload.nonce !== options.expectedNonce) throw new Oauth2Error(`Dpop jwt contains nonce value '${payload.nonce}', but expected nonce value '${options.expectedNonce}'`);
|
|
1178
|
-
}
|
|
1179
|
-
if (options.request.method !== payload.htm) throw new Oauth2Error(`Dpop jwt contains htm value '${payload.htm}', but expected htm value '${options.request.method}'`);
|
|
1180
|
-
const expectedHtu = htuFromRequestUrl(options.request.url);
|
|
1181
|
-
if (expectedHtu !== payload.htu) throw new Oauth2Error(`Dpop jwt contains htu value '${payload.htu}', but expected htu value '${expectedHtu}'.`);
|
|
1182
|
-
if (options.accessToken) {
|
|
1183
|
-
const expectedAth = (0, __openid4vc_utils.encodeToBase64Url)(await options.callbacks.hash((0, __openid4vc_utils.decodeUtf8String)(options.accessToken), HashAlgorithm.Sha256));
|
|
1184
|
-
if (!payload.ath) throw new Oauth2Error(`Dpop jwt does not have a ath value, but expected ath value '${expectedAth}'.`);
|
|
1185
|
-
if (payload.ath !== expectedAth) throw new Oauth2Error(`Dpop jwt contains ath value '${payload.ath}', but expected ath value '${expectedAth}'.`);
|
|
1186
|
-
}
|
|
1187
|
-
const jwkThumbprint = await calculateJwkThumbprint({
|
|
1188
|
-
hashAlgorithm: HashAlgorithm.Sha256,
|
|
1189
|
-
hashCallback: options.callbacks.hash,
|
|
1190
|
-
jwk: header.jwk
|
|
1191
|
-
});
|
|
1192
|
-
if (options.expectedJwkThumbprint && options.expectedJwkThumbprint !== jwkThumbprint) throw new Oauth2Error(`Dpop is signed with jwk with thumbprint value '${jwkThumbprint}', but expect jwk thumbprint value '${options.expectedJwkThumbprint}'`);
|
|
1193
|
-
await verifyJwt({
|
|
1194
|
-
signer: {
|
|
1195
|
-
alg: header.alg,
|
|
1196
|
-
method: "jwk",
|
|
1197
|
-
publicJwk: header.jwk
|
|
1198
|
-
},
|
|
1199
|
-
now: options.now,
|
|
1200
|
-
header,
|
|
1201
|
-
payload,
|
|
1202
|
-
compact: options.dpopJwt,
|
|
1203
|
-
verifyJwtCallback: options.callbacks.verifyJwt,
|
|
1204
|
-
errorMessage: "dpop jwt verification failed"
|
|
1205
|
-
});
|
|
1206
|
-
return {
|
|
1207
|
-
header,
|
|
1208
|
-
payload,
|
|
1209
|
-
jwkThumbprint
|
|
1210
|
-
};
|
|
1211
|
-
} catch (error) {
|
|
1212
|
-
if (error instanceof Oauth2Error) throw new Oauth2ServerErrorResponseError({
|
|
1213
|
-
error: Oauth2ErrorCodes.InvalidDpopProof,
|
|
1214
|
-
error_description: error.message
|
|
1215
|
-
});
|
|
1216
|
-
throw error;
|
|
1217
|
-
}
|
|
1218
|
-
}
|
|
1219
|
-
function htuFromRequestUrl(requestUrl) {
|
|
1220
|
-
const htu = new __openid4vc_utils.URL(requestUrl);
|
|
1221
|
-
htu.search = "";
|
|
1222
|
-
htu.hash = "";
|
|
1223
|
-
return htu.toString();
|
|
1224
|
-
}
|
|
1225
|
-
function extractDpopNonceFromHeaders(headers) {
|
|
1226
|
-
return headers.get("DPoP-Nonce");
|
|
1227
|
-
}
|
|
1228
|
-
function extractDpopJwtFromHeaders(headers) {
|
|
1229
|
-
const dpopJwt = headers.get("DPoP");
|
|
1230
|
-
if (!dpopJwt) return { valid: true };
|
|
1231
|
-
if (!zCompactJwt.safeParse(dpopJwt).success) return { valid: false };
|
|
1232
|
-
return {
|
|
1233
|
-
valid: true,
|
|
1234
|
-
dpopJwt
|
|
1235
|
-
};
|
|
1236
|
-
}
|
|
1237
|
-
|
|
1238
1365
|
//#endregion
|
|
1239
1366
|
//#region src/access-token/parse-access-token-request.ts
|
|
1240
1367
|
/**
|
|
@@ -1490,29 +1617,6 @@ async function verifyAccessTokenRequestPkce(options, callbacks) {
|
|
|
1490
1617
|
}
|
|
1491
1618
|
}
|
|
1492
1619
|
|
|
1493
|
-
//#endregion
|
|
1494
|
-
//#region src/authorization-request/z-authorization-request.ts
|
|
1495
|
-
const zAuthorizationRequest = zod.default.object({
|
|
1496
|
-
response_type: zod.default.string(),
|
|
1497
|
-
client_id: zod.default.string(),
|
|
1498
|
-
issuer_state: zod.default.optional(zod.default.string()),
|
|
1499
|
-
redirect_uri: zod.default.url().optional(),
|
|
1500
|
-
resource: zod.default.optional(__openid4vc_utils.zHttpsUrl),
|
|
1501
|
-
scope: zod.default.optional(zod.default.string()),
|
|
1502
|
-
state: zod.default.optional(zod.default.string()),
|
|
1503
|
-
dpop_jkt: zod.default.optional(zod.default.base64url()),
|
|
1504
|
-
code_challenge: zod.default.optional(zod.default.string()),
|
|
1505
|
-
code_challenge_method: zod.default.optional(zod.default.string())
|
|
1506
|
-
}).loose();
|
|
1507
|
-
const zPushedAuthorizationRequest = zod.default.object({
|
|
1508
|
-
request_uri: zod.default.string(),
|
|
1509
|
-
client_id: zod.default.string()
|
|
1510
|
-
}).loose();
|
|
1511
|
-
const zPushedAuthorizationResponse = zod.default.object({
|
|
1512
|
-
request_uri: zod.default.string(),
|
|
1513
|
-
expires_in: zod.default.number().int()
|
|
1514
|
-
}).loose();
|
|
1515
|
-
|
|
1516
1620
|
//#endregion
|
|
1517
1621
|
//#region src/authorization-challenge/z-authorization-challenge.ts
|
|
1518
1622
|
const zAuthorizationChallengeRequest = zod.default.object({
|
|
@@ -1563,39 +1667,6 @@ function createAuthorizationChallengeErrorResponse(options) {
|
|
|
1563
1667
|
});
|
|
1564
1668
|
}
|
|
1565
1669
|
|
|
1566
|
-
//#endregion
|
|
1567
|
-
//#region src/authorization-request/parse-authorization-request.ts
|
|
1568
|
-
/**
|
|
1569
|
-
* Parse an authorization request.
|
|
1570
|
-
*
|
|
1571
|
-
* @throws {Oauth2ServerErrorResponseError}
|
|
1572
|
-
*/
|
|
1573
|
-
function parseAuthorizationRequest(options) {
|
|
1574
|
-
const extractedDpopJwt = extractDpopJwtFromHeaders(options.request.headers);
|
|
1575
|
-
if (!extractedDpopJwt.valid) throw new Oauth2ServerErrorResponseError({
|
|
1576
|
-
error: Oauth2ErrorCodes.InvalidDpopProof,
|
|
1577
|
-
error_description: `Request contains a 'DPoP' header, but the value is not a valid DPoP jwt`
|
|
1578
|
-
});
|
|
1579
|
-
const extractedClientAttestationJwts = extractClientAttestationJwtsFromHeaders(options.request.headers);
|
|
1580
|
-
if (!extractedClientAttestationJwts.valid) throw new Oauth2ServerErrorResponseError({
|
|
1581
|
-
error: Oauth2ErrorCodes.InvalidClient,
|
|
1582
|
-
error_description: "Request contains client attestation header, but the values are not valid client attestation and client attestation PoP header."
|
|
1583
|
-
});
|
|
1584
|
-
return {
|
|
1585
|
-
dpop: extractedDpopJwt.dpopJwt ? {
|
|
1586
|
-
jwt: extractedDpopJwt.dpopJwt,
|
|
1587
|
-
jwkThumbprint: options.authorizationRequest.dpop_jkt
|
|
1588
|
-
} : options.authorizationRequest.dpop_jkt ? {
|
|
1589
|
-
jwt: extractedDpopJwt.dpopJwt,
|
|
1590
|
-
jwkThumbprint: options.authorizationRequest.dpop_jkt
|
|
1591
|
-
} : void 0,
|
|
1592
|
-
clientAttestation: extractedClientAttestationJwts.clientAttestationHeader ? {
|
|
1593
|
-
clientAttestationJwt: extractedClientAttestationJwts.clientAttestationHeader,
|
|
1594
|
-
clientAttestationPopJwt: extractedClientAttestationJwts.clientAttestationPopHeader
|
|
1595
|
-
} : void 0
|
|
1596
|
-
};
|
|
1597
|
-
}
|
|
1598
|
-
|
|
1599
1670
|
//#endregion
|
|
1600
1671
|
//#region src/authorization-challenge/parse-authorization-challenge-request.ts
|
|
1601
1672
|
/**
|
|
@@ -1727,31 +1798,6 @@ function createPushedAuthorizationErrorResponse(options) {
|
|
|
1727
1798
|
});
|
|
1728
1799
|
}
|
|
1729
1800
|
|
|
1730
|
-
//#endregion
|
|
1731
|
-
//#region src/authorization-request/parse-pushed-authorization-request.ts
|
|
1732
|
-
/**
|
|
1733
|
-
* Parse an pushed authorization request.
|
|
1734
|
-
*
|
|
1735
|
-
* @throws {Oauth2ServerErrorResponseError}
|
|
1736
|
-
*/
|
|
1737
|
-
function parsePushedAuthorizationRequest(options) {
|
|
1738
|
-
const parsedAuthorizationRequest = zAuthorizationRequest.safeParse(options.authorizationRequest);
|
|
1739
|
-
if (!parsedAuthorizationRequest.success) throw new Oauth2ServerErrorResponseError({
|
|
1740
|
-
error: Oauth2ErrorCodes.InvalidRequest,
|
|
1741
|
-
error_description: `Error occurred during validation of pushed authorization request.\n${(0, __openid4vc_utils.formatZodError)(parsedAuthorizationRequest.error)}`
|
|
1742
|
-
});
|
|
1743
|
-
const authorizationRequest = parsedAuthorizationRequest.data;
|
|
1744
|
-
const { clientAttestation, dpop } = parseAuthorizationRequest({
|
|
1745
|
-
authorizationRequest,
|
|
1746
|
-
request: options.request
|
|
1747
|
-
});
|
|
1748
|
-
return {
|
|
1749
|
-
authorizationRequest,
|
|
1750
|
-
dpop,
|
|
1751
|
-
clientAttestation
|
|
1752
|
-
};
|
|
1753
|
-
}
|
|
1754
|
-
|
|
1755
1801
|
//#endregion
|
|
1756
1802
|
//#region src/authorization-request/verify-pushed-authorization-request.ts
|
|
1757
1803
|
async function verifyPushedAuthorizationRequest(options) {
|
|
@@ -2614,7 +2660,10 @@ Object.defineProperty(exports, 'getGlobalConfig', {
|
|
|
2614
2660
|
exports.isJwkInSet = isJwkInSet;
|
|
2615
2661
|
exports.jwtHeaderFromJwtSigner = jwtHeaderFromJwtSigner;
|
|
2616
2662
|
exports.jwtSignerFromJwt = jwtSignerFromJwt;
|
|
2663
|
+
exports.parseAuthorizationResponseRedirectUrl = parseAuthorizationResponseRedirectUrl;
|
|
2664
|
+
exports.parsePushedAuthorizationRequestUri = parsePushedAuthorizationRequestUri;
|
|
2617
2665
|
exports.preAuthorizedCodeGrantIdentifier = preAuthorizedCodeGrantIdentifier;
|
|
2666
|
+
exports.pushedAuthorizationRequestUriPrefix = pushedAuthorizationRequestUriPrefix;
|
|
2618
2667
|
exports.refreshTokenGrantIdentifier = refreshTokenGrantIdentifier;
|
|
2619
2668
|
exports.resourceRequest = resourceRequest;
|
|
2620
2669
|
Object.defineProperty(exports, 'setGlobalConfig', {
|
|
@@ -2629,6 +2678,9 @@ exports.verifyJwt = verifyJwt;
|
|
|
2629
2678
|
exports.verifyResourceRequest = verifyResourceRequest;
|
|
2630
2679
|
exports.zAlgValueNotNone = zAlgValueNotNone;
|
|
2631
2680
|
exports.zAuthorizationCodeGrantIdentifier = zAuthorizationCodeGrantIdentifier;
|
|
2681
|
+
exports.zAuthorizationErrorResponse = zAuthorizationErrorResponse;
|
|
2682
|
+
exports.zAuthorizationResponse = zAuthorizationResponse;
|
|
2683
|
+
exports.zAuthorizationResponseFromUriParams = zAuthorizationResponseFromUriParams;
|
|
2632
2684
|
exports.zAuthorizationServerMetadata = zAuthorizationServerMetadata;
|
|
2633
2685
|
exports.zCompactJwe = zCompactJwe;
|
|
2634
2686
|
exports.zCompactJwt = zCompactJwt;
|
|
@@ -2640,5 +2692,6 @@ exports.zJwtHeader = zJwtHeader;
|
|
|
2640
2692
|
exports.zJwtPayload = zJwtPayload;
|
|
2641
2693
|
exports.zOauth2ErrorResponse = zOauth2ErrorResponse;
|
|
2642
2694
|
exports.zPreAuthorizedCodeGrantIdentifier = zPreAuthorizedCodeGrantIdentifier;
|
|
2695
|
+
exports.zPushedAuthorizationRequestUriPrefix = zPushedAuthorizationRequestUriPrefix;
|
|
2643
2696
|
exports.zRefreshTokenGrantIdentifier = zRefreshTokenGrantIdentifier;
|
|
2644
2697
|
//# sourceMappingURL=index.js.map
|