Skip to content

Commit

Permalink
refactor(types): enforce flat interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Apr 21, 2023
1 parent edc5290 commit c958d61
Show file tree
Hide file tree
Showing 8 changed files with 161 additions and 57 deletions.
3 changes: 3 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
- [GenerateKeyPairOptions](interfaces/GenerateKeyPairOptions.md)
- [HttpRequestOptions](interfaces/HttpRequestOptions.md)
- [IDToken](interfaces/IDToken.md)
- [IntrospectionConfirmationClaims](interfaces/IntrospectionConfirmationClaims.md)
- [IntrospectionRequestOptions](interfaces/IntrospectionRequestOptions.md)
- [IntrospectionResponse](interfaces/IntrospectionResponse.md)
- [MTLSEndpointAliases](interfaces/MTLSEndpointAliases.md)
Expand All @@ -73,9 +74,11 @@
- [RevocationRequestOptions](interfaces/RevocationRequestOptions.md)
- [TokenEndpointRequestOptions](interfaces/TokenEndpointRequestOptions.md)
- [TokenEndpointResponse](interfaces/TokenEndpointResponse.md)
- [UserInfoAddress](interfaces/UserInfoAddress.md)
- [UserInfoRequestOptions](interfaces/UserInfoRequestOptions.md)
- [UserInfoResponse](interfaces/UserInfoResponse.md)
- [WWWAuthenticateChallenge](interfaces/WWWAuthenticateChallenge.md)
- [WWWAuthenticateChallengeParameters](interfaces/WWWAuthenticateChallengeParameters.md)

### Type Aliases

Expand Down
22 changes: 22 additions & 0 deletions docs/interfaces/IntrospectionConfirmationClaims.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Interface: IntrospectionConfirmationClaims

[💗 Help the project](https://github.com/sponsors/panva)

## Table of contents

### Properties

- [jkt](IntrospectionConfirmationClaims.md#jkt)
- [x5t#S256](IntrospectionConfirmationClaims.md#x5t#s256)

## Properties

### jkt

`Optional` `Readonly` **jkt**: `string`

___

### x5t#S256

`Optional` `Readonly` **x5t#S256**: `string`
9 changes: 1 addition & 8 deletions docs/interfaces/IntrospectionResponse.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,7 @@ ___

### cnf

`Optional` `Readonly` **cnf**: `Object`

#### Type declaration

| Name | Type |
| :------ | :------ |
| `jkt?` | `string` |
| `x5t#S256?` | `string` |
`Optional` `Readonly` **cnf**: [`IntrospectionConfirmationClaims`](IntrospectionConfirmationClaims.md)

___

Expand Down
50 changes: 50 additions & 0 deletions docs/interfaces/UserInfoAddress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Interface: UserInfoAddress

[💗 Help the project](https://github.com/sponsors/panva)

## Table of contents

### Properties

- [country](UserInfoAddress.md#country)
- [formatted](UserInfoAddress.md#formatted)
- [locality](UserInfoAddress.md#locality)
- [postal\_code](UserInfoAddress.md#postal_code)
- [region](UserInfoAddress.md#region)
- [street\_address](UserInfoAddress.md#street_address)

## Properties

### country

`Optional` `Readonly` **country**: `string`

___

### formatted

`Optional` `Readonly` **formatted**: `string`

___

### locality

`Optional` `Readonly` **locality**: `string`

___

### postal\_code

`Optional` `Readonly` **postal\_code**: `string`

___

### region

`Optional` `Readonly` **region**: `string`

___

### street\_address

`Optional` `Readonly` **street\_address**: `string`
13 changes: 1 addition & 12 deletions docs/interfaces/UserInfoResponse.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,7 @@ ___

### address

`Optional` `Readonly` **address**: `Object`

#### Type declaration

| Name | Type |
| :------ | :------ |
| `country?` | `string` |
| `formatted?` | `string` |
| `locality?` | `string` |
| `postal_code?` | `string` |
| `region?` | `string` |
| `street_address?` | `string` |
`Optional` `Readonly` **address**: [`UserInfoAddress`](UserInfoAddress.md)

___

Expand Down
13 changes: 1 addition & 12 deletions docs/interfaces/WWWAuthenticateChallenge.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,7 @@

### parameters

`Readonly` **parameters**: `Object`

#### Type declaration

| Name | Type |
| :------ | :------ |
| `algs?` | `string` |
| `error?` | `string` |
| `error_description?` | `string` |
| `error_uri?` | `string` |
| `realm?` | `string` |
| `scope?` | `string` |
`Readonly` **parameters**: [`WWWAuthenticateChallengeParameters`](WWWAuthenticateChallengeParameters.md)

___

Expand Down
50 changes: 50 additions & 0 deletions docs/interfaces/WWWAuthenticateChallengeParameters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Interface: WWWAuthenticateChallengeParameters

[💗 Help the project](https://github.com/sponsors/panva)

## Table of contents

### Properties

- [algs](WWWAuthenticateChallengeParameters.md#algs)
- [error](WWWAuthenticateChallengeParameters.md#error)
- [error\_description](WWWAuthenticateChallengeParameters.md#error_description)
- [error\_uri](WWWAuthenticateChallengeParameters.md#error_uri)
- [realm](WWWAuthenticateChallengeParameters.md#realm)
- [scope](WWWAuthenticateChallengeParameters.md#scope)

## Properties

### algs

`Optional` `Readonly` **algs**: `string`

___

### error

`Optional` `Readonly` **error**: `string`

___

### error\_description

`Optional` `Readonly` **error\_description**: `string`

___

### error\_uri

`Optional` `Readonly` **error\_uri**: `string`

___

### realm

`Optional` `Readonly` **realm**: `string`

___

### scope

`Optional` `Readonly` **scope**: `string`
58 changes: 33 additions & 25 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1453,20 +1453,22 @@ export function isOAuth2Error(input?: ReturnTypes): input is OAuth2Error {
return value.error !== undefined
}

export interface WWWAuthenticateChallengeParameters {
readonly realm?: string
readonly error?: string
readonly error_description?: string
readonly error_uri?: string
readonly algs?: string
readonly scope?: string

/** NOTE: because the parameter names are case insensitive they are always returned lowercased */
readonly [parameter: string]: string | undefined
}

export interface WWWAuthenticateChallenge {
/** NOTE: because the value is case insensitive it is always returned lowercased */
readonly scheme: string
readonly parameters: {
readonly realm?: string
readonly error?: string
readonly error_description?: string
readonly error_uri?: string
readonly algs?: string
readonly scope?: string

/** NOTE: because the parameter names are case insensitive they are always returned lowercased */
readonly [parameter: string]: string | undefined
}
readonly parameters: WWWAuthenticateChallengeParameters
}

function unquote(value: string) {
Expand Down Expand Up @@ -1717,6 +1719,17 @@ export async function userInfoRequest(
})
}

export interface UserInfoAddress {
readonly formatted?: string
readonly street_address?: string
readonly locality?: string
readonly region?: string
readonly postal_code?: string
readonly country?: string

readonly [claim: string]: JsonValue | undefined
}

export interface UserInfoResponse {
readonly sub: string
readonly name?: string
Expand All @@ -1736,14 +1749,7 @@ export interface UserInfoResponse {
readonly locale?: string
readonly phone_number?: string
readonly updated_at?: number
readonly address?: {
readonly formatted?: string
readonly street_address?: string
readonly locality?: string
readonly region?: string
readonly postal_code?: string
readonly country?: string
}
readonly address?: UserInfoAddress

readonly [claim: string]: JsonValue | undefined
}
Expand Down Expand Up @@ -2731,6 +2737,13 @@ export async function introspectionRequest(
return authenticatedRequest(as, client, 'POST', url, body, headers, options)
}

export interface IntrospectionConfirmationClaims {
readonly 'x5t#S256'?: string
readonly jkt?: string

readonly [claim: string]: JsonValue | undefined
}

export interface IntrospectionResponse {
readonly active: boolean
readonly client_id?: string
Expand All @@ -2745,12 +2758,7 @@ export interface IntrospectionResponse {
readonly sub?: string
readonly nbf?: number
readonly token_type?: string
readonly cnf?: {
readonly 'x5t#S256'?: string
readonly jkt?: string

readonly [claim: string]: JsonValue | undefined
}
readonly cnf?: IntrospectionConfirmationClaims

readonly [claim: string]: JsonValue | undefined
}
Expand Down

0 comments on commit c958d61

Please sign in to comment.