@farm.js/clerk 0.1.0-beta.6 → 0.1.0-beta.60

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.d.ts CHANGED
@@ -1,5 +1,8 @@
1
+ import { type ClerkClient } from "@clerk/backend";
1
2
  import { type FarmIntegrationLogger } from "@farm.js/core";
2
3
  export interface ClerkIntegrationInput {
4
+ /** Existing Clerk backend client. When provided, Farm does not construct its own client. */
5
+ instance?: ClerkIntegrationInstance;
3
6
  publishableKey?: string;
4
7
  secretKey?: string;
5
8
  signInUrl?: string;
@@ -9,9 +12,10 @@ export interface ClerkIntegrationInput {
9
12
  providerProps?: Record<string, unknown>;
10
13
  log?: FarmIntegrationLogger;
11
14
  }
15
+ export type ClerkIntegrationInstance = ClerkClient;
12
16
  interface ResolvedClerkConfig {
13
17
  publishableKey: string;
14
- secretKey: string;
18
+ secretKey?: string;
15
19
  }
16
20
  export declare function clerk(input?: ClerkIntegrationInput): import("@farm.js/core").DefinedIntegration<{
17
21
  category: "auth";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,KAAK,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAO9E,MAAM,WAAW,qBAAqB;IACpC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACpC,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,GAAG,CAAC,EAAE,qBAAqB,CAAC;CAC7B;AAED,UAAU,mBAAmB;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;CACnB;AAsBD,wBAAgB,KAAK,CAAC,KAAK,GAAE,qBAA0B;;;;;;;;;;;;;;;;;;;;;;yBA4DlB,OAAO;;GA6C3C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAqB,KAAK,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAO9E,MAAM,WAAW,qBAAqB;IACpC,4FAA4F;IAC5F,QAAQ,CAAC,EAAE,wBAAwB,CAAC;IACpC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACpC,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,GAAG,CAAC,EAAE,qBAAqB,CAAC;CAC7B;AAED,MAAM,MAAM,wBAAwB,GAAG,WAAW,CAAC;AAEnD,UAAU,mBAAmB;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAsBD,wBAAgB,KAAK,CAAC,KAAK,GAAE,qBAA0B;;;;;;;;;;;;;;;;;;;;;;yBA+DlB,OAAO;;GA6C3C"}
package/dist/index.js CHANGED
@@ -7,12 +7,12 @@ function resolveClerkKeys(input) {
7
7
  process.env.CLERK_PUBLISHABLE_KEY ??
8
8
  "";
9
9
  const secretKey = input.secretKey ?? process.env.CLERK_SECRET_KEY ?? "";
10
- if (!publishableKey || !secretKey) {
11
- throw new Error("Clerk integration requires NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY and CLERK_SECRET_KEY.");
10
+ if (!publishableKey || (!input.instance && !secretKey)) {
11
+ throw new Error("Clerk integration requires a publishable key and either a Clerk instance or CLERK_SECRET_KEY.");
12
12
  }
13
13
  return {
14
14
  publishableKey,
15
- secretKey,
15
+ secretKey: secretKey || undefined,
16
16
  };
17
17
  }
18
18
  export function clerk(input = {}) {
@@ -22,12 +22,15 @@ export function clerk(input = {}) {
22
22
  const signUpUrl = input.signUpUrl ?? "/sign-up";
23
23
  let cachedClient = null;
24
24
  const getClient = () => {
25
+ if (input.instance) {
26
+ return input.instance;
27
+ }
25
28
  if (cachedClient) {
26
29
  return cachedClient;
27
30
  }
28
31
  cachedClient = createClerkClient({
29
32
  publishableKey,
30
- secretKey,
33
+ secretKey: secretKey,
31
34
  });
32
35
  return cachedClient;
33
36
  };
@@ -49,7 +52,7 @@ export function clerk(input = {}) {
49
52
  publishableKey,
50
53
  secretKey,
51
54
  },
52
- required: ["publishableKey", "secretKey"],
55
+ required: input.instance ? ["publishableKey"] : ["publishableKey", "secretKey"],
53
56
  }),
54
57
  log: input.log,
55
58
  providers: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farm.js/clerk",
3
- "version": "0.1.0-beta.6",
3
+ "version": "0.1.0-beta.60",
4
4
  "description": "Clerk integration for Farm.js",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -26,8 +26,8 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@clerk/backend": "^3.2.0",
29
- "@farm.js/integration-utils": "0.1.0-beta.6",
30
- "@farm.js/core": "0.1.0-beta.6"
29
+ "@farm.js/core": "0.1.0-beta.60",
30
+ "@farm.js/integration-utils": "0.1.0-beta.60"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "@clerk/react": "^6.1.0",