Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make alby oauth url customizable #37

Merged
merged 5 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ const authClient = new auth.OAuth2User({

const authUrl = authClient.generateAuthURL({
code_challenge_method: "S256",
// authorizeUrl: "https://getalby.com/oauth" endpoint for authorization (replace with the appropriate URL based on the environment)
});
// open auth URL
// `code` is passed as a query parameter when the user is redirected back aufter authorization
Expand Down
2 changes: 1 addition & 1 deletion src/OAuth2User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export class OAuth2User implements OAuthClient {
code_challenge_method = "plain";
}
const code_challenge = this.code_challenge;
const url = new URL(AUTHORIZE_URL);
const url = new URL(options.authorizeUrl || AUTHORIZE_URL);
url.search = buildQueryString({
...options,
client_id,
Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface Token extends Omit<GetTokenResponse, "expires_in"> {


export type GenerateAuthUrlOptions =
| {
{authorizeUrl?: string} & (|{
code_challenge_method?: string;
code_challenge?: string;
}
Expand All @@ -42,7 +42,7 @@ export type GenerateAuthUrlOptions =
code_challenge: string;
/** Specifies the method you are using to make a request (S256 OR plain). */
code_challenge_method?: "plain";
};
});

export abstract class OAuthClient implements AuthClient {
abstract token?: Token;
Expand Down