@ascendkit/nextjs 0.2.5 → 0.2.6

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.
@@ -2,5 +2,5 @@
2
2
  * Creates a Better Auth database adapter that routes all CRUD operations
3
3
  * through the AscendKit backend API, scoped by public key.
4
4
  */
5
- export declare function createAscendKitAdapter(publicKey: string, apiUrl: string): import("better-auth/adapters").AdapterFactory<import("better-auth").BetterAuthOptions>;
5
+ export declare function createAscendKitAdapter(publicKey: string, apiUrl: string, secretKey?: string): import("better-auth/adapters").AdapterFactory<import("better-auth").BetterAuthOptions>;
6
6
  //# sourceMappingURL=adapter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/server/adapter.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,0FA+DvE"}
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/server/adapter.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,0FA+D3F"}
@@ -4,7 +4,7 @@ import { createHttpClient } from "../shared/http-client";
4
4
  * Creates a Better Auth database adapter that routes all CRUD operations
5
5
  * through the AscendKit backend API, scoped by public key.
6
6
  */
7
- export function createAscendKitAdapter(publicKey, apiUrl) {
7
+ export function createAscendKitAdapter(publicKey, apiUrl, secretKey) {
8
8
  return createAdapterFactory({
9
9
  config: {
10
10
  adapterId: "ascendkit",
@@ -14,7 +14,7 @@ export function createAscendKitAdapter(publicKey, apiUrl) {
14
14
  supportsBooleans: true,
15
15
  },
16
16
  adapter: () => {
17
- const http = createHttpClient({ publicKey, apiUrl });
17
+ const http = createHttpClient({ publicKey, apiUrl, secretKey });
18
18
  return {
19
19
  async create({ model, data, select }) {
20
20
  return await http.post("/api/auth/db/create", { model, data, select });
@@ -71,7 +71,7 @@ export declare function AscendKitAuth(options?: AscendKitAuthOptions): Promise<i
71
71
  enabled: boolean;
72
72
  };
73
73
  }>>;
74
- export declare function createDisabledAuth(publicKey: string, apiUrl: string): import("better-auth").Auth<{
74
+ export declare function createDisabledAuth(publicKey: string, apiUrl: string, secretKey?: string): import("better-auth").Auth<{
75
75
  database: import("better-auth/adapters").AdapterFactory<import("better-auth").BetterAuthOptions>;
76
76
  emailAndPassword: {
77
77
  enabled: false;
@@ -79,6 +79,7 @@ export declare function createDisabledAuth(publicKey: string, apiUrl: string): i
79
79
  }>;
80
80
  export declare function buildAscendKitAuthFromConfig(args: {
81
81
  publicKey: string;
82
+ secretKey?: string;
82
83
  apiUrl: string;
83
84
  config: AuthConfig;
84
85
  waitlistRedirectPath?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"ascendkit-auth.d.ts","sourceRoot":"","sources":["../../src/server/ascendkit-auth.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAExE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,aAAa,CAAC,OAAO,GAAE,oBAAyB;;;;;;;;;;;;;;;;;;;sCAuG1B;YAAE,IAAI,EAAE;gBAAE,IAAI,EAAE,MAAM,CAAC;gBAAC,KAAK,EAAE,MAAM,CAAA;aAAE,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE;;;;;oCARxD;YAAE,IAAI,EAAE;gBAAE,IAAI,EAAE,MAAM,CAAC;gBAAC,KAAK,EAAE,MAAM,CAAA;aAAE,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE;;;;IA1E/F;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,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AAM,EAAE,SAAS,CAAC,EAAE,MAAM;;;;;GAMvF;AAED,wBAAsB,4BAA4B,CAAC,IAAI,EAAE;IACvD,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,UAAU,CAAC;IACnB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;;;;;;;;;;;;;;sCAmE2C;YAAE,IAAI,EAAE;gBAAE,IAAI,EAAE,MAAM,CAAC;gBAAC,KAAK,EAAE,MAAM,CAAA;aAAE,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE;;;;;oCARxD;YAAE,IAAI,EAAE;gBAAE,IAAI,EAAE,MAAM,CAAC;gBAAC,KAAK,EAAE,MAAM,CAAA;aAAE,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE;;;;IAwB/F"}
@@ -46,26 +46,27 @@ export async function AscendKitAuth(options = {}) {
46
46
  catch (err) {
47
47
  console.error("[AscendKit] Failed to fetch auth config:", err instanceof Error ? err.message : err);
48
48
  console.error("[AscendKit] Auth routes will operate with no providers until config is available.");
49
- return createDisabledAuth(publicKey, apiUrl);
49
+ return createDisabledAuth(publicKey, apiUrl, secretKey);
50
50
  }
51
51
  return buildAscendKitAuthFromConfig({
52
52
  publicKey,
53
+ secretKey,
53
54
  apiUrl,
54
55
  config,
55
56
  waitlistRedirectPath: options.waitlistRedirectPath,
56
57
  rejectedRedirectPath: options.rejectedRedirectPath,
57
58
  });
58
59
  }
59
- export function createDisabledAuth(publicKey, apiUrl) {
60
- const adapter = createAscendKitAdapter(publicKey, apiUrl);
60
+ export function createDisabledAuth(publicKey, apiUrl, secretKey) {
61
+ const adapter = createAscendKitAdapter(publicKey, apiUrl, secretKey);
61
62
  return betterAuth({
62
63
  database: adapter,
63
64
  emailAndPassword: { enabled: false },
64
65
  });
65
66
  }
66
67
  export async function buildAscendKitAuthFromConfig(args) {
67
- const { publicKey, apiUrl, config, waitlistRedirectPath, rejectedRedirectPath, } = args;
68
- const adapter = createAscendKitAdapter(publicKey, apiUrl);
68
+ const { publicKey, secretKey, apiUrl, config, waitlistRedirectPath, rejectedRedirectPath, } = args;
69
+ const adapter = createAscendKitAdapter(publicKey, apiUrl, secretKey);
69
70
  const proxyProviders = Object.entries(config.oauth)
70
71
  .filter(([, creds]) => creds.flowType === "proxy")
71
72
  .map(([provider]) => provider);
@@ -1 +1 @@
1
- {"version":3,"file":"auth-runtime.d.ts","sourceRoot":"","sources":["../../src/server/auth-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAM5D,KAAK,kBAAkB,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;AAC7D,KAAK,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;AAOlF,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjD,UAAU,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;IAC7D,OAAO,EAAE,MAAM,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAC5C;AA8BD,wBAAgB,0BAA0B,CAAC,OAAO,GAAE,oBAAyB,GAAG,oBAAoB,CA0HnG"}
1
+ {"version":3,"file":"auth-runtime.d.ts","sourceRoot":"","sources":["../../src/server/auth-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAM5D,KAAK,kBAAkB,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;AAC7D,KAAK,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;AAOlF,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjD,UAAU,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;IAC7D,OAAO,EAAE,MAAM,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAC5C;AA8BD,wBAAgB,0BAA0B,CAAC,OAAO,GAAE,oBAAyB,GAAG,oBAAoB,CA2HnG"}
@@ -52,19 +52,20 @@ export function createAscendKitAuthRuntime(options = {}) {
52
52
  }
53
53
  console.info("[AscendKit runtime] config_refresh_outcome=hit_304");
54
54
  if (!currentAuth) {
55
- currentAuth = createDisabledAuth(publicKey, apiUrl);
55
+ currentAuth = createDisabledAuth(publicKey, apiUrl, secretKey);
56
56
  }
57
57
  return;
58
58
  }
59
59
  if (!result.config) {
60
60
  console.warn("[AscendKit runtime] config_refresh_outcome=cold_fail reason=missing_config");
61
61
  if (!currentAuth) {
62
- currentAuth = createDisabledAuth(publicKey, apiUrl);
62
+ currentAuth = createDisabledAuth(publicKey, apiUrl, secretKey);
63
63
  }
64
64
  return;
65
65
  }
66
66
  const nextAuth = await buildAscendKitAuthFromConfig({
67
67
  publicKey,
68
+ secretKey,
68
69
  apiUrl,
69
70
  config: result.config,
70
71
  waitlistRedirectPath: options.waitlistRedirectPath,
@@ -83,7 +84,7 @@ export function createAscendKitAuthRuntime(options = {}) {
83
84
  catch (err) {
84
85
  console.warn("[AscendKit runtime] config_refresh_outcome=fallback_last_known_good", err instanceof Error ? err.message : err);
85
86
  if (!currentAuth) {
86
- currentAuth = createDisabledAuth(publicKey, apiUrl);
87
+ currentAuth = createDisabledAuth(publicKey, apiUrl, secretKey);
87
88
  }
88
89
  }
89
90
  })();
@@ -96,7 +97,7 @@ export function createAscendKitAuthRuntime(options = {}) {
96
97
  async function getAuth() {
97
98
  await refreshAuth();
98
99
  if (!currentAuth) {
99
- currentAuth = createDisabledAuth(publicKey, apiUrl);
100
+ currentAuth = createDisabledAuth(publicKey, apiUrl, secretKey);
100
101
  }
101
102
  return currentAuth;
102
103
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ascendkit/nextjs",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "AscendKit SDK for Next.js and React",
5
5
  "author": "ascendkit.dev",
6
6
  "license": "MIT",