Skip to content

Commit

Permalink
docs: expose clock skew and tolerance documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Jan 9, 2024
1 parent 1708f21 commit 2d90c49
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 9 deletions.
2 changes: 2 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@

### Variables

- [clockSkew](variables/clockSkew.md)
- [clockTolerance](variables/clockTolerance.md)
- [expectNoNonce](variables/expectNoNonce.md)
- [expectNoState](variables/expectNoState.md)
- [skipAuthTimeCheck](variables/skipAuthTimeCheck.md)
Expand Down
56 changes: 56 additions & 0 deletions docs/interfaces/Client.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Recognized Client Metadata that have an effect on the exposed functionality.
### Properties

- [client\_id](Client.md#client_id)
- [[clockSkew]](Client.md#[clockskew])
- [[clockTolerance]](Client.md#[clocktolerance])
- [authorization\_signed\_response\_alg](Client.md#authorization_signed_response_alg)
- [client\_secret](Client.md#client_secret)
- [default\_max\_age](Client.md#default_max_age)
Expand All @@ -36,6 +38,60 @@ Client identifier.

___

### [clockSkew]

`Optional` **[clockSkew]**: `number`

Use to adjust the client's assumed current time. Positive and negative finite values
representing seconds are allowed. Default is `0` (Date.now() + 0 seconds is used).

**`Example`**

When the client's local clock is mistakenly 1 hour in the past

```ts
const client: oauth.Client = {
client_id: 'abc4ba37-4ab8-49b5-99d4-9441ba35d428',
// ... other metadata
[oauth.clockSkew]: +(60 * 60),
}
```

**`Example`**

When the client's local clock is mistakenly 1 hour in the future

```ts
const client: oauth.Client = {
client_id: 'abc4ba37-4ab8-49b5-99d4-9441ba35d428',
// ... other metadata
[oauth.clockSkew]: -(60 * 60),
}
```

___

### [clockTolerance]

`Optional` **[clockTolerance]**: `number`

Use to set allowed client's clock tolerance when checking DateTime JWT Claims. Only positive
finite values representing seconds are allowed. Default is `30` (30 seconds).

**`Example`**

Tolerate 30 seconds clock skew when validating JWT claims like exp or nbf.

```ts
const client: oauth.Client = {
client_id: 'abc4ba37-4ab8-49b5-99d4-9441ba35d428',
// ... other metadata
[oauth.clockTolerance]: 30,
}
```

___

### authorization\_signed\_response\_alg

`Optional` **authorization\_signed\_response\_alg**: [`JWSAlgorithm`](../types/JWSAlgorithm.md)
Expand Down
13 changes: 13 additions & 0 deletions docs/interfaces/ProtectedResourceRequestOptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
### Properties

- [DPoP](ProtectedResourceRequestOptions.md#dpop)
- [[clockSkew]](ProtectedResourceRequestOptions.md#[clockskew])
- [signal](ProtectedResourceRequestOptions.md#signal)

## Properties
Expand All @@ -19,6 +20,18 @@ DPoP-related options.

___

### [clockSkew]

`Optional` **[clockSkew]**: `number`

Use to adjust the client's assumed current time. Positive and negative finite values
representing seconds are allowed. Default is `0` (Date.now() + 0 seconds is used).

This option only affects the request if the [DPoP](DPoPRequestOptions.md#dpop)
option is also used.

___

### signal

`Optional` **signal**: [`AbortSignal`]( https://developer.mozilla.org/docs/Web/API/AbortSignal ) \| () => [`AbortSignal`]( https://developer.mozilla.org/docs/Web/API/AbortSignal )
Expand Down
5 changes: 5 additions & 0 deletions docs/variables/clockSkew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Variable: clockSkew

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

`Const` **clockSkew**: typeof [`clockSkew`](clockSkew.md)
5 changes: 5 additions & 0 deletions docs/variables/clockTolerance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Variable: clockTolerance

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

`Const` **clockTolerance**: typeof [`clockTolerance`](clockTolerance.md)
16 changes: 7 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,7 @@ interface JWK {
readonly [parameter: string]: JsonValue | undefined
}

/** @ignore during Documentation generation but part of the public API */
export const clockSkew = Symbol()
/** @ignore during Documentation generation but part of the public API */
export const clockTolerance = Symbol()

/**
Expand Down Expand Up @@ -512,9 +510,9 @@ export interface Client {
* Use to adjust the client's assumed current time. Positive and negative finite values
* representing seconds are allowed. Default is `0` (Date.now() + 0 seconds is used).
*
* @ignore during Documentation generation but part of the public API
* @example
*
* @example Client's local clock is mistakenly 1 hour in the past
* When the client's local clock is mistakenly 1 hour in the past
*
* ```ts
* const client: oauth.Client = {
Expand All @@ -524,7 +522,9 @@ export interface Client {
* }
* ```
*
* @example Client's local clock is mistakenly 1 hour in the future
* @example
*
* When the client's local clock is mistakenly 1 hour in the future
*
* ```ts
* const client: oauth.Client = {
Expand All @@ -540,9 +540,9 @@ export interface Client {
* Use to set allowed client's clock tolerance when checking DateTime JWT Claims. Only positive
* finite values representing seconds are allowed. Default is `30` (30 seconds).
*
* @ignore during Documentation generation but part of the public API
* @example
*
* @example Tolerate 30 seconds clock skew when validating JWT claims like exp or nbf.
* Tolerate 30 seconds clock skew when validating JWT claims like exp or nbf.
*
* ```ts
* const client: oauth.Client = {
Expand Down Expand Up @@ -1686,8 +1686,6 @@ export interface ProtectedResourceRequestOptions
*
* This option only affects the request if the {@link ProtectedResourceRequestOptions.DPoP DPoP}
* option is also used.
*
* @ignore during Documentation generation but part of the public API
*/
[clockSkew]?: number
}
Expand Down

0 comments on commit 2d90c49

Please sign in to comment.