fix: Support WWW-Authenticate scope param for SEP-835 (#983)
Co-authored-by: OtotheA <oscar@otothea.com>
This commit is contained in:
parent
216604720b
commit
ee9fed28cc
1 changed files with 118 additions and 74 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { auth, extractResourceMetadataUrl, OAuthClientProvider, UnauthorizedError } from './auth.js';
|
||||
import { auth, extractWWWAuthenticateParams, OAuthClientProvider, UnauthorizedError } from './auth.js';
|
||||
import { FetchLike } from '../shared/transport.js';
|
||||
|
||||
/**
|
||||
|
|
@ -54,7 +54,7 @@ export const withOAuth =
|
|||
// Handle 401 responses by attempting re-authentication
|
||||
if (response.status === 401) {
|
||||
try {
|
||||
const resourceMetadataUrl = extractResourceMetadataUrl(response);
|
||||
const { resourceMetadataUrl, scope } = extractWWWAuthenticateParams(response);
|
||||
|
||||
// Use provided baseUrl or extract from request URL
|
||||
const serverUrl = baseUrl || (typeof input === 'string' ? new URL(input).origin : input.origin);
|
||||
|
|
@ -62,6 +62,7 @@ export const withOAuth =
|
|||
const result = await auth(provider, {
|
||||
serverUrl,
|
||||
resourceMetadataUrl,
|
||||
scope,
|
||||
fetchFn: next
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue