feat: Add scope parameter to startAuthorization function
- Add optional scope parameter to startAuthorization function signature - Include scope in authorization URL query parameters when provided - Update auth function to pass through scope from provider.clientMetadata - Add tests to verify scope is correctly included/excluded from auth URL This enhancement allows clients to specify authorization scopes during the OAuth flow.
This commit is contained in:
parent
621ccea997
commit
30b5544e8b
1 changed files with 33 additions and 1 deletions
|
|
@ -177,6 +177,31 @@ describe("OAuth Authorization", () => {
|
|||
expect(codeVerifier).toBe("test_verifier");
|
||||
});
|
||||
|
||||
it("includes scope parameter when provided", async () => {
|
||||
const { authorizationUrl } = await startAuthorization(
|
||||
"https://auth.example.com",
|
||||
{
|
||||
clientInformation: validClientInfo,
|
||||
redirectUrl: "http://localhost:3000/callback",
|
||||
scope: "read write profile",
|
||||
}
|
||||
);
|
||||
|
||||
expect(authorizationUrl.searchParams.get("scope")).toBe("read write profile");
|
||||
});
|
||||
|
||||
it("excludes scope parameter when not provided", async () => {
|
||||
const { authorizationUrl } = await startAuthorization(
|
||||
"https://auth.example.com",
|
||||
{
|
||||
clientInformation: validClientInfo,
|
||||
redirectUrl: "http://localhost:3000/callback",
|
||||
}
|
||||
);
|
||||
|
||||
expect(authorizationUrl.searchParams.has("scope")).toBe(false);
|
||||
});
|
||||
|
||||
it("uses metadata authorization_endpoint when provided", async () => {
|
||||
const { authorizationUrl } = await startAuthorization(
|
||||
"https://auth.example.com",
|
||||
|
|
|
|||
Loading…
Reference in a new issue