Skip to content

Commit bca26e4

Browse files
committed
Add: callback for metadata
1 parent 590d484 commit bca26e4

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"build": "npm run build:esm && npm run build:cjs",
3939
"build:esm": "tsc -p tsconfig.prod.json && echo '{\"type\": \"module\"}' > dist/esm/package.json",
4040
"build:cjs": "tsc -p tsconfig.cjs.json && echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json",
41+
"prepare": "npm run build",
4142
"prepack": "npm run build:esm && npm run build:cjs",
4243
"lint": "eslint src/",
4344
"test": "jest",

src/client/auth.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ export interface OAuthClientProvider {
2626
*/
2727
state?(): string | Promise<string>;
2828

29+
/**
30+
* If implemented, this permits the OAuth client to save the authorization server metadata.
31+
*/
32+
saveAuthorizationServerMetadata?(metadata?: OAuthMetadata): void | Promise<void>;
33+
2934
/**
3035
* Loads information about this OAuth client, as registered already with the
3136
* server, or returns `undefined` if the client is not registered with the
@@ -113,6 +118,10 @@ export async function auth(
113118

114119
const metadata = await discoverOAuthMetadata(authorizationServerUrl);
115120

121+
if (provider.saveAuthorizationServerMetadata) {
122+
await provider.saveAuthorizationServerMetadata(metadata);
123+
}
124+
116125
// Handle client registration if needed
117126
let clientInformation = await Promise.resolve(provider.clientInformation());
118127
if (!clientInformation) {

0 commit comments

Comments
 (0)