@theholocron/holocron-plugin-clerk 3.59.0 → 3.60.0

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.mts CHANGED
@@ -9,7 +9,7 @@ declare class ClerkAuth implements Auth {
9
9
  private readonly client;
10
10
  readonly key: "auth";
11
11
  readonly providerName = "clerk";
12
- constructor(client: ClerkClient, _opts?: ClerkAuthOptions);
12
+ constructor(client: () => ClerkClient, _opts?: ClerkAuthOptions);
13
13
  describe(): Promise<AuthDescription>;
14
14
  whoami(): Promise<AuthIdentity>;
15
15
  ensureWebhookApp(): Promise<{
@@ -57,7 +57,7 @@ interface ClerkPluginOptions extends ResolveTokenInput {
57
57
  }
58
58
  interface PluginContext {
59
59
  options: ClerkPluginOptions;
60
- client: ClerkClient;
60
+ client: () => ClerkClient;
61
61
  }
62
62
  declare function createContext(options?: ClerkPluginOptions): PluginContext;
63
63
  declare function auth(ctx: PluginContext): Auth;
package/dist/index.mjs CHANGED
@@ -26,12 +26,12 @@ var ClerkAuth = class {
26
26
  async whoami() {
27
27
  return {
28
28
  provider: "clerk",
29
- details: { userCount: (await this.client.users.count()).total_count }
29
+ details: { userCount: (await this.client().users.count()).total_count }
30
30
  };
31
31
  }
32
32
  async ensureWebhookApp() {
33
33
  try {
34
- await this.client.webhooks.ensureSvixApp();
34
+ await this.client().webhooks.ensureSvixApp();
35
35
  return { alreadyExists: false };
36
36
  } catch (err) {
37
37
  if (err instanceof ProviderApiError && isAlreadyExistsError(err)) return { alreadyExists: true };
@@ -39,13 +39,13 @@ var ClerkAuth = class {
39
39
  }
40
40
  }
41
41
  async getWebhookDashboardUrl() {
42
- const body = await this.client.webhooks.getSvixUrl();
42
+ const body = await this.client().webhooks.getSvixUrl();
43
43
  const url = body.url ?? body.svix_url;
44
44
  if (!url) throw new ProviderApiError("Clerk POST /webhooks/svix_url returned 200 but no `url` field", 500, void 0);
45
45
  return { url };
46
46
  }
47
47
  async createUser(input) {
48
- const user = await this.client.users.create({
48
+ const user = await this.client().users.create({
49
49
  email_address: [input.email],
50
50
  password: input.password,
51
51
  ...input.firstName ? { first_name: input.firstName } : {},
@@ -182,9 +182,10 @@ async function verifyToken(token, opts = {}) {
182
182
  //#endregion
183
183
  //#region src/index.ts
184
184
  function createContext(options = {}) {
185
+ let client;
185
186
  return {
186
187
  options,
187
- client: createClerkClient({
188
+ client: () => client ??= createClerkClient({
188
189
  token: resolveToken(options),
189
190
  baseUrl: options.baseUrl,
190
191
  fetch: options.fetch
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/holocron-plugin-clerk",
3
- "version": "3.59.0",
3
+ "version": "3.60.0",
4
4
  "description": "Holocron plugin for Clerk. Implements the auth capability against Clerk's Backend REST API.",
5
5
  "keywords": [
6
6
  "auth",
@@ -45,11 +45,11 @@
45
45
  "tsx": "4.23.12",
46
46
  "typescript": "^5.9.3",
47
47
  "vitest": "^4.1.11",
48
- "@theholocron/cli": "3.59.0"
48
+ "@theholocron/cli": "3.60.0"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@theholocron/clerk-client": "^1.14.2",
52
- "@theholocron/cli": "3.59.0"
52
+ "@theholocron/cli": "3.60.0"
53
53
  },
54
54
  "engines": {
55
55
  "node": ">=22"