Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/few-parents-love.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@openid4vc/openid4vci": patch
"@openid4vc/oauth2": patch
---

Fixes miscellaneous typos and adds code to the authorization request.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface CreateAuthorizationChallengeResponseOptions {
/**
* Create an authorization challenge response
*
* @throws {ValidationError} if an error occured during verification of the {@link AuthorizationChallengeResponse}
* @throws {ValidationError} if an error occurred during verification of the {@link AuthorizationChallengeResponse}
*/
export function createAuthorizationChallengeResponse(options: CreateAuthorizationChallengeResponseOptions) {
const authorizationChallengeResponse = parseWithErrorHandling(zAuthorizationChallengeResponse, {
Expand Down Expand Up @@ -84,7 +84,7 @@ export interface CreateAuthorizationChallengeErrorResponseOptions {
/**
* Create an authorization challenge error response
*
* @throws {ValidationError} if an error occured during validation of the {@link AuthorizationChallengeErrorResponse}
* @throws {ValidationError} if an error occurred during validation of the {@link AuthorizationChallengeErrorResponse}
*/
export function createAuthorizationChallengeErrorResponse(options: CreateAuthorizationChallengeErrorResponseOptions) {
const authorizationChallengeErrorResponse = parseWithErrorHandling(zAuthorizationChallengeErrorResponse, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export interface SendAuthorizationChallengeRequestOptions {
resource?: string

/**
* Presentation during issuance sessios if credentials were presented
* Presentation during issuance session if credentials were presented
* as part of an issuance session
*/
presentationDuringIssuanceSession?: string
Expand All @@ -76,7 +76,7 @@ export interface SendAuthorizationChallengeRequestOptions {
*
* @throws {Oauth2ClientAuthorizationChallengeError} if the request failed and a {@link AuthorizationChallengeErrorResponse} is returned
* @throws {InvalidFetchResponseError} if the request failed but no error response could be parsed
* @throws {ValidationError} if a successful response was received but an error occured during verification of the {@link AuthorizationChallengeResponse}
* @throws {ValidationError} if a successful response was received but an error occurred during verification of the {@link AuthorizationChallengeResponse}
*/
export async function sendAuthorizationChallengeRequest(options: SendAuthorizationChallengeRequestOptions) {
const fetchWithZod = createZodFetcher(options.callbacks.fetch)
Expand All @@ -85,7 +85,7 @@ export async function sendAuthorizationChallengeRequest(options: SendAuthorizati
const authorizationChallengeEndpoint = authorizationServerMetadata.authorization_challenge_endpoint
if (!authorizationChallengeEndpoint) {
throw new Oauth2Error(
`Unable to send authorization challange. Authorization server '${authorizationServerMetadata.issuer}' has no 'authorization_challenge_endpoint'`
`Unable to send authorization challenge. Authorization server '${authorizationServerMetadata.issuer}' has no 'authorization_challenge_endpoint'`
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ export interface CreateAuthorizationRequestUrlOptions {
*/
scope?: string

/**
* State for the authorization request
*/
state?: string

/**
* The resource to which access is being requested. This can help the authorization
* server in determining the resource server to handle the authorization request for
Expand Down Expand Up @@ -109,6 +114,7 @@ export async function createAuthorizationRequestUrl(options: CreateAuthorization
redirect_uri: options.redirectUri,
resource: options.resource,
scope: options.scope,
state: options.state,
code_challenge: pkce?.codeChallenge,
code_challenge_method: pkce?.codeChallengeMethod,
}
Expand Down Expand Up @@ -197,7 +203,7 @@ async function pushAuthorizationRequest(options: PushAuthorizationRequestOptions

if (options.authorizationRequest.request_uri) {
throw new Oauth2Error(
`Authorization request contains 'request_uri' parameter. This is not allowed for pushed authorization reuqests.`
`Authorization request contains 'request_uri' parameter. This is not allowed for pushed authorization requests.`
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export interface CreatePushedAuthorizationResponseOptions {
/**
* Create an pushed authorization response
*
* @throws {ValidationError} if an error occured during verification of the {@link PushedAuthorizationResponse}
* @throws {ValidationError} if an error occurred during verification of the {@link PushedAuthorizationResponse}
*/
export function createPushedAuthorizationResponse(options: CreatePushedAuthorizationResponseOptions) {
const pushedAuthorizationResponse = parseWithErrorHandling(zPushedAuthorizationResponse, {
Expand Down Expand Up @@ -59,7 +59,7 @@ export interface CreatePushedAuthorizationErrorResponseOptions {
/**
* Create a pushed authorization error response
*
* @throws {ValidationError} if an error occured during validation of the {@link PushedAuthorizationErrorResponse}
* @throws {ValidationError} if an error occurred during validation of the {@link PushedAuthorizationErrorResponse}
*/
export function createPushedAuthorizationErrorResponse(options: CreatePushedAuthorizationErrorResponseOptions) {
const pushedAuthorizationErrorResponse = parseWithErrorHandling(zAccessTokenErrorResponse, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function parsePushedAuthorizationRequest(
if (!parsedAuthorizationRequest.success) {
throw new Oauth2ServerErrorResponseError({
error: Oauth2ErrorCodes.InvalidRequest,
error_description: `Error occured during validation of pushed authorization request.\n${formatZodError(parsedAuthorizationRequest.error)}`,
error_description: `Error occurred during validation of pushed authorization request.\n${formatZodError(parsedAuthorizationRequest.error)}`,
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const zAuthorizationRequest = z
redirect_uri: z.url().optional(),
resource: z.optional(zHttpsUrl),
scope: z.optional(z.string()),
state: z.optional(z.string()),

// DPoP jwk thumbprint
dpop_jkt: z.optional(z.base64url()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('Decode JWT', () => {
})
).toThrow(
`Unable to extract signer method from jwt. Found 1 allowed signer method(s) but contained invalid configuration:
FAILED: method did - kid in header starst with did that is different from did value in 'iss'`
FAILED: method did - kid in header starts with did that is different from did value in 'iss'`
)
})

Expand Down Expand Up @@ -134,7 +134,7 @@ SUCCEEDED: method did`)
).toThrow(`Unable to extract signer method from jwt. Found 4 signer method(s) that are not allowed:
SUCCEEDED: method x5c
SUCCEEDED: method federation
FAILED: method did - kid in header starst with did that is different from did value in 'iss'
FAILED: method did - kid in header starts with did that is different from did value in 'iss'
SUCCEEDED: method jwk`)
})

Expand Down
2 changes: 1 addition & 1 deletion packages/oauth2/src/common/jwt/decode-jwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export function jwtSignerFromJwt({
found.push({
method: 'did',
valid: false,
error: `kid in header starst with did that is different from did value in 'iss'`,
error: `kid in header starts with did that is different from did value in 'iss'`,
})
} else if (!header.kid?.startsWith('did:') && !header.kid?.startsWith('#')) {
found.push({
Expand Down
2 changes: 1 addition & 1 deletion packages/oauth2/src/error/Oauth2Error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class Oauth2Error extends Error {
public readonly cause?: unknown

public constructor(message?: string, options?: Oauth2ErrorOptions) {
const errorMessage = message ?? 'Unknown error occured.'
const errorMessage = message ?? 'Unknown error occurred.'
const causeMessage =
options?.cause instanceof Error ? ` ${options.cause.message}` : options?.cause ? ` ${options?.cause}` : ''

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export async function verifyResourceRequest(options: VerifyResourceRequestOption
} catch (error) {
const errorMessage = error instanceof Oauth2Error ? error.message : 'Error verifying DPoP jwt'
throw new Oauth2ResourceUnauthorizedError(
`Error occured during verification of jwt profile access token: ${error instanceof Error ? error.message : error}`,
`Error occurred during verification of jwt profile access token: ${error instanceof Error ? error.message : error}`,
{
scheme,
error: Oauth2ErrorCodes.InvalidDpopProof,
Expand Down
2 changes: 1 addition & 1 deletion packages/openid4vci/src/error/Openid4vciError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class Openid4vciError extends Error {
public readonly cause?: unknown

public constructor(message?: string, options?: Openid4vciErrorOptions) {
const errorMessage = message ?? 'Unknown error occured.'
const errorMessage = message ?? 'Unknown error occurred.'
const causeMessage =
options?.cause instanceof Error ? ` ${options.cause.message}` : options?.cause ? ` ${options?.cause}` : ''

Expand Down