Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/oauth2-redirect-optional.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@karnak19/pbkit": patch
---

Make `redirectUrl` optional in generated `auth*WithOAuth2` functions, matching PocketBase v0.39.4 which dropped the required `redirectURL` validator from `authWithOAuth2Code()`.
2 changes: 1 addition & 1 deletion packages/pbkit/src/sdk-generator/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ function authFunctions(col: CollectionSchema): string[] {
lines.push("}");
lines.push("");
lines.push(
`export async function auth${s}WithOAuth2(provider: string, code: string, codeVerifier: string, redirectUrl: string, opts?: { client?: PbClient }): Promise<${p}Record> {`,
`export async function auth${s}WithOAuth2(provider: string, code: string, codeVerifier: string, redirectUrl = "", opts?: { client?: PbClient }): Promise<${p}Record> {`,
);
lines.push(" const pb = opts?.client ?? client");
lines.push(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export async function authUserWithPassword(usernameOrEmail: string, password: st
return result.record as unknown as UsersRecord
}

export async function authUserWithOAuth2(provider: string, code: string, codeVerifier: string, redirectUrl: string, opts?: { client?: PbClient }): Promise<UsersRecord> {
export async function authUserWithOAuth2(provider: string, code: string, codeVerifier: string, redirectUrl = "", opts?: { client?: PbClient }): Promise<UsersRecord> {
const pb = opts?.client ?? client
const result = await pb.collection("users").authWithOAuth2Code(provider, code, codeVerifier, redirectUrl)
return result.record as unknown as UsersRecord
Expand Down
Loading