@theholocron/holocron-plugin-clerk 5.0.0-alpha.19 → 5.0.0-alpha.191

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
@@ -1,4 +1,4 @@
1
- import { Auth, AuthDescription, AuthError, AuthEvent, AuthIdentity, AuthUser, CreateAuthUserInput, ParseWebhookInput, ResolveTokenInput, WebhookDashboardInfo } from "@theholocron/cli";
1
+ import { Auth, AuthDescription, AuthError, AuthEvent, AuthIdentity, AuthUser, CreateAuthUserInput, ParseWebhookInput, ResolveTokenInput, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess, WebhookDashboardInfo } from "@theholocron/cli";
2
2
  import { ClerkClient, ClerkClientOptions, createClerkClient } from "@theholocron/clerk-client";
3
3
  //#region src/auth.d.ts
4
4
  declare const resolveToken: (input?: ResolveTokenInput) => string;
@@ -23,30 +23,11 @@ declare class ClerkAuth implements Auth {
23
23
  declare function parseWebhook(input: ParseWebhookInput): Promise<AuthEvent>;
24
24
  //#endregion
25
25
  //#region src/verify-token.d.ts
26
- /**
27
- * `verifyToken` — plugin-level export used by `holocron auth set` +
28
- * `holocron auth check`. Hits Clerk's `/v1/instance` endpoint, which
29
- * requires a valid secret key and returns instance metadata (id,
30
- * environment_type, etc.). Invalid keys → 401.
31
- *
32
- * Clerk doesn't have a traditional user-oriented whoami — the "authed
33
- * entity" is your Clerk INSTANCE, not a user. `/v1/instance` is the
34
- * canonical "is this secret key valid?" endpoint.
35
- */
36
- interface VerifyTokenSuccess {
37
- ok: true;
38
- subject: string;
39
- }
40
- interface VerifyTokenFailure {
41
- ok: false;
42
- message: string;
43
- }
44
- type VerifyTokenResult = VerifyTokenSuccess | VerifyTokenFailure;
45
26
  interface VerifyTokenOptions {
46
27
  baseUrl?: string;
47
28
  fetch?: typeof fetch;
48
29
  }
49
- declare function verifyToken(token: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult>;
30
+ declare function verifyToken(token: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult$1>;
50
31
  //#endregion
51
32
  //#region src/index.d.ts
52
33
  interface ClerkPluginOptions extends ResolveTokenInput {
package/dist/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import { AuthError, ProviderApiError, WebhookVerificationError, createResolveToken } from "@theholocron/cli";
2
2
  import { createClerkClient } from "@theholocron/clerk-client";
3
3
  import { createHmac, timingSafeEqual } from "node:crypto";
4
+ import { errorMessage } from "@theholocron/misc-utils";
4
5
  //#region src/auth.ts
5
6
  const resolveToken = createResolveToken({
6
7
  envName: "HOLOCRON_CLERK_SECRET_KEY",
@@ -98,7 +99,7 @@ async function parseWebhook(input) {
98
99
  try {
99
100
  payload = JSON.parse(bodyStr);
100
101
  } catch (err) {
101
- throw new WebhookVerificationError(`Clerk webhook body is not valid JSON: ${err instanceof Error ? err.message : String(err)}`);
102
+ throw new WebhookVerificationError(`Clerk webhook body is not valid JSON: ${errorMessage(err)}`);
102
103
  }
103
104
  const normalizedType = CLERK_TO_NORMALIZED[payload.type];
104
105
  if (!normalizedType) throw new WebhookVerificationError(`Clerk webhook event type "${payload.type}" has no normalized mapping yet`);
@@ -141,7 +142,7 @@ async function verifySignature(input) {
141
142
  let sigBytes;
142
143
  try {
143
144
  sigBytes = Buffer.from(sig.slice(comma + 1), "base64");
144
- } catch /* istanbul ignore next -- Buffer.from('base64') never throws in Node.js */ {
145
+ } catch /* istanbul ignore next -- Buffer.from('base64') never throws in Node.js */ {
145
146
  return false;
146
147
  }
147
148
  if (sigBytes.length !== computed.length) return false;
@@ -150,16 +151,6 @@ async function verifySignature(input) {
150
151
  }
151
152
  //#endregion
152
153
  //#region src/verify-token.ts
153
- /**
154
- * `verifyToken` — plugin-level export used by `holocron auth set` +
155
- * `holocron auth check`. Hits Clerk's `/v1/instance` endpoint, which
156
- * requires a valid secret key and returns instance metadata (id,
157
- * environment_type, etc.). Invalid keys → 401.
158
- *
159
- * Clerk doesn't have a traditional user-oriented whoami — the "authed
160
- * entity" is your Clerk INSTANCE, not a user. `/v1/instance` is the
161
- * canonical "is this secret key valid?" endpoint.
162
- */
163
154
  async function verifyToken(token, opts = {}) {
164
155
  const client = createClerkClient({
165
156
  token,
@@ -175,7 +166,7 @@ async function verifyToken(token, opts = {}) {
175
166
  } catch (err) {
176
167
  return {
177
168
  ok: false,
178
- message: err instanceof Error ? err.message : String(err)
169
+ message: errorMessage(err)
179
170
  };
180
171
  }
181
172
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/holocron-plugin-clerk",
3
- "version": "5.0.0-alpha.19",
3
+ "version": "5.0.0-alpha.191",
4
4
  "description": "Holocron plugin for Clerk. Implements the auth capability against Clerk's Backend REST API.",
5
5
  "keywords": [
6
6
  "auth",
@@ -8,12 +8,12 @@
8
8
  "holocron",
9
9
  "plugin"
10
10
  ],
11
- "homepage": "https://github.com/theholocron/holocron/tree/main/packages/holocron-plugin-clerk#readme",
11
+ "homepage": "https://github.com/theholocron/holocron/tree/main/plugins/holocron-plugin-clerk#readme",
12
12
  "bugs": "https://github.com/theholocron/holocron/issues",
13
13
  "repository": {
14
14
  "type": "git",
15
15
  "url": "git+https://github.com/theholocron/holocron.git",
16
- "directory": "packages/holocron-plugin-clerk"
16
+ "directory": "plugins/holocron-plugin-clerk"
17
17
  },
18
18
  "license": "MIT",
19
19
  "author": "Newton Koumantzelis",
@@ -30,12 +30,13 @@
30
30
  "dist"
31
31
  ],
32
32
  "devDependencies": {
33
- "@theholocron/clerk-client": "^1.19.0",
34
- "@theholocron/eslint-config": "^8.0.0",
35
- "@theholocron/http-client": "^1.19.0",
36
- "@theholocron/tsconfig": "^8.0.0",
37
- "@theholocron/tsdown-config": "^8.0.0",
38
- "@theholocron/vitest-config": "^8.0.0",
33
+ "@theholocron/clerk-client": "^1.43.1",
34
+ "@theholocron/eslint-config": "^8.8.2",
35
+ "@theholocron/http-client": "^1.43.1",
36
+ "@theholocron/misc-utils": "^1.16.0",
37
+ "@theholocron/tsconfig": "^8.8.2",
38
+ "@theholocron/tsdown-config": "^8.8.2",
39
+ "@theholocron/vitest-config": "^8.8.2",
39
40
  "@types/node": "^26",
40
41
  "@vitest/coverage-v8": "^4.1.11",
41
42
  "@vitest/eslint-plugin": "^1.6.27",
@@ -43,14 +44,15 @@
43
44
  "eslint-plugin-n": "^18.3.0",
44
45
  "globals": "^17.11.0",
45
46
  "tsdown": "^0.22.14",
46
- "tsx": "4.23.12",
47
+ "tsx": "4.23.15",
47
48
  "typescript": "^5.9.3",
48
49
  "vitest": "^4.1.11",
49
- "@theholocron/cli": "5.0.0-alpha.19"
50
+ "@theholocron/cli": "5.0.0-alpha.191"
50
51
  },
51
52
  "peerDependencies": {
52
- "@theholocron/clerk-client": "^1.19.0",
53
- "@theholocron/cli": "5.0.0-alpha.19"
53
+ "@theholocron/clerk-client": "^1.43.1",
54
+ "@theholocron/misc-utils": "^1.16.0",
55
+ "@theholocron/cli": "5.0.0-alpha.191"
54
56
  },
55
57
  "engines": {
56
58
  "node": ">=22"