kavachos 0.1.1 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -5682,7 +5682,7 @@ function createOAuthModule(db, config) {
5682
5682
  throw new Error("OAuth callback: state has expired. Restart the authorization flow.");
5683
5683
  }
5684
5684
  await db.delete(oauthStates).where(eq(oauthStates.state, state));
5685
- const tokens = await provider.exchangeCode(stateRow.codeVerifier, code2, redirectUri);
5685
+ const tokens = await provider.exchangeCode(code2, stateRow.codeVerifier, redirectUri);
5686
5686
  const userInfo = await provider.getUserInfo(tokens.accessToken);
5687
5687
  const existingRows = await db.select().from(oauthAccounts).where(
5688
5688
  and(
@@ -15631,6 +15631,31 @@ function buildStatements(provider) {
15631
15631
  resource TEXT,
15632
15632
  expires_at ${ts} NOT NULL,
15633
15633
  created_at ${ts} NOT NULL
15634
+ )`,
15635
+ // ------------------------------------------------------------------
15636
+ // kavach_oauth_accounts (provider account linking)
15637
+ // ------------------------------------------------------------------
15638
+ `CREATE TABLE ${ifne} kavach_oauth_accounts (
15639
+ id TEXT NOT NULL PRIMARY KEY,
15640
+ user_id TEXT NOT NULL,
15641
+ provider TEXT NOT NULL,
15642
+ provider_account_id TEXT NOT NULL,
15643
+ access_token TEXT NOT NULL,
15644
+ refresh_token TEXT,
15645
+ expires_at ${tsNull},
15646
+ created_at ${ts} NOT NULL,
15647
+ updated_at ${ts} NOT NULL
15648
+ )`,
15649
+ // ------------------------------------------------------------------
15650
+ // kavach_oauth_states (PKCE state for CSRF protection)
15651
+ // ------------------------------------------------------------------
15652
+ `CREATE TABLE ${ifne} kavach_oauth_states (
15653
+ state TEXT NOT NULL PRIMARY KEY,
15654
+ code_verifier TEXT NOT NULL,
15655
+ redirect_uri TEXT NOT NULL,
15656
+ provider TEXT NOT NULL,
15657
+ expires_at ${ts} NOT NULL,
15658
+ created_at ${ts} NOT NULL
15634
15659
  )`,
15635
15660
  // ------------------------------------------------------------------
15636
15661
  // kavach_budget_policies