Skip to content

Commit 15f6953

Browse files
committed
feat: add support for Dynamic Client Registration
1 parent 5a5a7c9 commit 15f6953

12 files changed

+548
-70
lines changed

docs/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ Support from the community to continue maintaining and improving this module is
6969
- [getDPoPHandle](functions/getDPoPHandle.md)
7070
- [randomDPoPKeyPair](functions/randomDPoPKeyPair.md)
7171

72+
## Dynamic Client Registration
73+
74+
- [dynamicClientRegistration](functions/dynamicClientRegistration.md)
75+
7276
## OpenID Connect 1.0
7377

7478
- [authorizationCodeGrant](functions/authorizationCodeGrant.md)
@@ -110,6 +114,7 @@ Support from the community to continue maintaining and improving this module is
110114
- [DiscoveryRequestOptions](interfaces/DiscoveryRequestOptions.md)
111115
- [DPoPHandle](interfaces/DPoPHandle.md)
112116
- [DPoPOptions](interfaces/DPoPOptions.md)
117+
- [DynamicClientRegistrationRequestOptions](interfaces/DynamicClientRegistrationRequestOptions.md)
113118
- [ExportedJWKSCache](interfaces/ExportedJWKSCache.md)
114119
- [GenerateKeyPairOptions](interfaces/GenerateKeyPairOptions.md)
115120
- [IDToken](interfaces/IDToken.md)
@@ -138,6 +143,7 @@ Support from the community to continue maintaining and improving this module is
138143
- [JsonPrimitive](type-aliases/JsonPrimitive.md)
139144
- [JsonValue](type-aliases/JsonValue.md)
140145
- [JWSAlgorithm](type-aliases/JWSAlgorithm.md)
146+
- [OmitSymbolProperties](type-aliases/OmitSymbolProperties.md)
141147

142148
## Variables
143149

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Function: dynamicClientRegistration()
2+
3+
[💗 Help the project](https://github.com/sponsors/panva)
4+
5+
Support from the community to continue maintaining and improving this module is welcome. If you find the module useful, please consider supporting the project by [becoming a sponsor](https://github.com/sponsors/panva).
6+
7+
***
8+
9+
**dynamicClientRegistration**(`server`, `metadata`, `clientAuthentication`?, `options`?): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`Configuration`](../classes/Configuration.md)\>
10+
11+
Performs Authorization Server Metadata discovery and subsequently a Dynamic
12+
Client Registration at the discovered Authorization Server's
13+
[ServerMetadata.registration\_endpoint](../interfaces/ServerMetadata.md#registration_endpoint) using the provided client
14+
metadata.
15+
16+
Note: This method also accepts a URL pointing directly to the Authorization
17+
Server's discovery document. Doing so is NOT RECOMMENDED as it disables the
18+
[ServerMetadata.issuer](../interfaces/ServerMetadata.md#issuer) validation.
19+
20+
## Parameters
21+
22+
| Parameter | Type | Description |
23+
| ------ | ------ | ------ |
24+
| `server` | [`URL`](https://developer.mozilla.org/docs/Web/API/URL) | URL representation of the Authorization Server's Issuer Identifier |
25+
| `metadata` | [`Partial`](https://www.typescriptlang.org/docs/handbook/utility-types.html#partialtype)\<[`ClientMetadata`](../interfaces/ClientMetadata.md)\> | Client Metadata to register at the Authorization Server |
26+
| `clientAuthentication`? | [`ClientAuth`](../type-aliases/ClientAuth.md) | Implementation of the Client's Authentication Method at the Authorization Server. Default is [ClientSecretPost](ClientSecretPost.md) using the [ClientMetadata.client\_secret](../interfaces/ClientMetadata.md#client_secret) that the Authorization Server issued. |
27+
| `options`? | [`DynamicClientRegistrationRequestOptions`](../interfaces/DynamicClientRegistrationRequestOptions.md) | |
28+
29+
## Returns
30+
31+
[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`Configuration`](../classes/Configuration.md)\>

docs/interfaces/AuthorizationCodeGrantOptions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Support from the community to continue maintaining and improving this module is
1313
`optional` **DPoP**: [`DPoPHandle`](DPoPHandle.md)
1414

1515
DPoP handle to use for requesting a sender-constrained access token.
16-
Obtained from [getDPoPHandle](../functions/getDPoPHandle.md)
16+
Usually obtained from [getDPoPHandle](../functions/getDPoPHandle.md)
1717

1818
#### See
1919

docs/interfaces/BackchannelAuthenticationGrantPollOptions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Support from the community to continue maintaining and improving this module is
1313
`optional` **DPoP**: [`DPoPHandle`](DPoPHandle.md)
1414

1515
DPoP handle to use for requesting a sender-constrained access token.
16-
Obtained from [getDPoPHandle](../functions/getDPoPHandle.md)
16+
Usually obtained from [getDPoPHandle](../functions/getDPoPHandle.md)
1717

1818
#### See
1919

docs/interfaces/ConfigurationMethods.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ Public methods available on a [Configuration](../classes/Configuration.md) insta
1010

1111
## Methods
1212

13+
### clientMetadata()
14+
15+
**clientMetadata**(): [`Readonly`](https://www.typescriptlang.org/docs/handbook/utility-types.html#readonlytype)\<[`OmitSymbolProperties`](../type-aliases/OmitSymbolProperties.md)\<[`ClientMetadata`](ClientMetadata.md)\>\>
16+
17+
Used to retrieve the Client Metadata
18+
19+
#### Returns
20+
21+
[`Readonly`](https://www.typescriptlang.org/docs/handbook/utility-types.html#readonlytype)\<[`OmitSymbolProperties`](../type-aliases/OmitSymbolProperties.md)\<[`ClientMetadata`](ClientMetadata.md)\>\>
22+
23+
***
24+
1325
### serverMetadata()
1426

1527
**serverMetadata**(): [`Readonly`](https://www.typescriptlang.org/docs/handbook/utility-types.html#readonlytype)\<[`ServerMetadata`](ServerMetadata.md)\> & [`ServerMetadataHelpers`](ServerMetadataHelpers.md)

docs/interfaces/DPoPOptions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Support from the community to continue maintaining and improving this module is
1313
`optional` **DPoP**: [`DPoPHandle`](DPoPHandle.md)
1414

1515
DPoP handle to use for requesting a sender-constrained access token.
16-
Obtained from [getDPoPHandle](../functions/getDPoPHandle.md)
16+
Usually obtained from [getDPoPHandle](../functions/getDPoPHandle.md)
1717

1818
#### See
1919

docs/interfaces/DeviceAuthorizationGrantPollOptions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Support from the community to continue maintaining and improving this module is
1313
`optional` **DPoP**: [`DPoPHandle`](DPoPHandle.md)
1414

1515
DPoP handle to use for requesting a sender-constrained access token.
16-
Obtained from [getDPoPHandle](../functions/getDPoPHandle.md)
16+
Usually obtained from [getDPoPHandle](../functions/getDPoPHandle.md)
1717

1818
#### See
1919

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# Interface: DynamicClientRegistrationRequestOptions
2+
3+
[💗 Help the project](https://github.com/sponsors/panva)
4+
5+
Support from the community to continue maintaining and improving this module is welcome. If you find the module useful, please consider supporting the project by [becoming a sponsor](https://github.com/sponsors/panva).
6+
7+
***
8+
9+
## Properties
10+
11+
### \[customFetch\]?
12+
13+
`optional` **\[customFetch\]**: [`CustomFetch`](../type-aliases/CustomFetch.md)
14+
15+
Custom [Fetch API](https://developer.mozilla.org/docs/Web/API/Window/fetch) implementation to use for the HTTP Requests
16+
the client will be making. If this option is used, then the customFetch
17+
value will be assigned to the resolved [Configuration](../classes/Configuration.md) instance for
18+
use with all its future individual HTTP requests.
19+
20+
#### See
21+
22+
[customFetch](../variables/customFetch.md)
23+
24+
***
25+
26+
### algorithm?
27+
28+
`optional` **algorithm**: `"oidc"` \| `"oauth2"`
29+
30+
The issuer transformation algorithm to use. Default is `oidc`.
31+
32+
#### Example
33+
34+
```txt
35+
Given the Issuer Identifier is https://example.com
36+
oidc => https://example.com/.well-known/openid-configuration
37+
oauth => https://example.com/.well-known/oauth-authorization-server
38+
39+
Given the Issuer Identifier is https://example.com/pathname
40+
oidc => https://example.com/pathname/.well-known/openid-configuration
41+
oauth => https://example.com/.well-known/oauth-authorization-server/pathname
42+
```
43+
44+
#### See
45+
46+
- [OpenID Connect Discovery 1.0 (oidc)](https://openid.net/specs/openid-connect-discovery-1_0.html)
47+
- [RFC8414 - OAuth 2.0 Authorization Server Metadata (oauth)](https://www.rfc-editor.org/rfc/rfc8414.html)
48+
49+
***
50+
51+
### DPoP?
52+
53+
`optional` **DPoP**: [`DPoPHandle`](DPoPHandle.md)
54+
55+
DPoP handle to use for requesting a sender-constrained access token.
56+
Usually obtained from [getDPoPHandle](../functions/getDPoPHandle.md)
57+
58+
#### See
59+
60+
[RFC 9449 - OAuth 2.0 Demonstrating Proof of Possession (DPoP)](https://www.rfc-editor.org/rfc/rfc9449.html)
61+
62+
***
63+
64+
### execute?
65+
66+
`optional` **execute**: (`config`) => `void`[]
67+
68+
Methods (available list linked below) to execute with the
69+
[Configuration](../classes/Configuration.md) instance as argument after it is instantiated
70+
71+
Note: Presence of [allowInsecureRequests](../functions/allowInsecureRequests.md) in this option also enables
72+
the use of insecure HTTP requests for the Authorization Server Metadata
73+
discovery request itself.
74+
75+
#### Parameters
76+
77+
| Parameter | Type |
78+
| ------ | ------ |
79+
| `config` | [`Configuration`](../classes/Configuration.md) |
80+
81+
#### Returns
82+
83+
`void`
84+
85+
#### Example
86+
87+
Disable the HTTPS-only restriction for the discovery call and subsequently
88+
for all requests made with the resulting [Configuration](../classes/Configuration.md) instance.
89+
90+
```ts
91+
let server!: URL
92+
let clientId!: string
93+
let clientMetadata!:
94+
| Partial<client.ClientMetadata>
95+
| undefined
96+
| string
97+
let clientAuth!: client.ClientAuth | undefined
98+
99+
let config = await client.discovery(
100+
server,
101+
clientId,
102+
clientMetadata,
103+
clientAuth,
104+
{
105+
execute: [client.allowInsecureRequests],
106+
},
107+
)
108+
```
109+
110+
#### See
111+
112+
- [allowInsecureRequests](../functions/allowInsecureRequests.md)
113+
- [enableNonRepudiationChecks](../functions/enableNonRepudiationChecks.md)
114+
- [useCodeIdTokenResponseType](../functions/useCodeIdTokenResponseType.md)
115+
- [enableDetachedSignatureResponseChecks](../functions/enableDetachedSignatureResponseChecks.md)
116+
- [useJwtResponseMode](../functions/useJwtResponseMode.md)
117+
118+
***
119+
120+
### initialAccessToken?
121+
122+
`optional` **initialAccessToken**: `string`
123+
124+
Access token optionally issued by an authorization server used to authorize
125+
calls to the client registration endpoint.
126+
127+
***
128+
129+
### timeout?
130+
131+
`optional` **timeout**: `number`
132+
133+
Timeout (in seconds) for the Authorization Server Metadata discovery. If
134+
this option is used, then the same timeout value will be assigned to the
135+
resolved [Configuration](../classes/Configuration.md) instance for use with all its future
136+
individual HTTP requests. Default is `30` (seconds)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Type Alias: OmitSymbolProperties\<T\>
2+
3+
[💗 Help the project](https://github.com/sponsors/panva)
4+
5+
Support from the community to continue maintaining and improving this module is welcome. If you find the module useful, please consider supporting the project by [becoming a sponsor](https://github.com/sponsors/panva).
6+
7+
***
8+
9+
**OmitSymbolProperties**\<`T`\>: `{ [K in keyof T as K extends symbol ? never : K]: T[K] }`
10+
11+
Removes all Symbol properties from a type
12+
13+
## Type Parameters
14+
15+
| Type Parameter |
16+
| ------ |
17+
| `T` |

0 commit comments

Comments
 (0)