@theholocron/holocron-plugin-clerk 5.0.0-alpha.231 → 5.0.0-alpha.232
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 +3 -0
- package/dist/index.mjs +33 -23
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -44,6 +44,9 @@ declare function createContext(options?: ClerkPluginOptions): PluginContext;
|
|
|
44
44
|
declare function auth(ctx: PluginContext): Auth;
|
|
45
45
|
declare function createPlugin(options?: ClerkPluginOptions): {
|
|
46
46
|
name: string;
|
|
47
|
+
probes: {
|
|
48
|
+
connection: import("@theholocron/cli").Probe;
|
|
49
|
+
};
|
|
47
50
|
capabilities: {
|
|
48
51
|
auth: () => Auth;
|
|
49
52
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AuthError, ProviderApiError, WebhookVerificationError, createResolveToken } from "@theholocron/cli";
|
|
1
|
+
import { AuthError, ProviderApiError, WebhookVerificationError, connectionProbe, createResolveToken } from "@theholocron/cli";
|
|
2
2
|
import { createClerkClient } from "@theholocron/clerk-client";
|
|
3
|
-
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
4
3
|
import { errorMessage } from "@theholocron/misc-utils";
|
|
4
|
+
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
5
5
|
//#region src/auth.ts
|
|
6
6
|
const resolveToken = createResolveToken({
|
|
7
7
|
envName: "HOLOCRON_CLERK_SECRET_KEY",
|
|
@@ -72,6 +72,27 @@ function isAlreadyExistsError(err) {
|
|
|
72
72
|
return false;
|
|
73
73
|
}
|
|
74
74
|
//#endregion
|
|
75
|
+
//#region src/verify-token.ts
|
|
76
|
+
async function verifyToken(token, opts = {}) {
|
|
77
|
+
const client = createClerkClient({
|
|
78
|
+
token,
|
|
79
|
+
baseUrl: opts.baseUrl,
|
|
80
|
+
fetch: opts.fetch
|
|
81
|
+
});
|
|
82
|
+
try {
|
|
83
|
+
const inst = await client.instance.get();
|
|
84
|
+
return {
|
|
85
|
+
ok: true,
|
|
86
|
+
subject: `${inst?.environment_type ?? "unknown"} instance ${inst?.id ?? "unknown"}`
|
|
87
|
+
};
|
|
88
|
+
} catch (err) {
|
|
89
|
+
return {
|
|
90
|
+
ok: false,
|
|
91
|
+
message: errorMessage(err)
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
//#endregion
|
|
75
96
|
//#region src/parse-webhook.ts
|
|
76
97
|
/**
|
|
77
98
|
* Translates a Clerk webhook delivery into the normalized `AuthEvent`
|
|
@@ -150,27 +171,6 @@ async function verifySignature(input) {
|
|
|
150
171
|
})) throw new WebhookVerificationError("Svix signature verification failed");
|
|
151
172
|
}
|
|
152
173
|
//#endregion
|
|
153
|
-
//#region src/verify-token.ts
|
|
154
|
-
async function verifyToken(token, opts = {}) {
|
|
155
|
-
const client = createClerkClient({
|
|
156
|
-
token,
|
|
157
|
-
baseUrl: opts.baseUrl,
|
|
158
|
-
fetch: opts.fetch
|
|
159
|
-
});
|
|
160
|
-
try {
|
|
161
|
-
const inst = await client.instance.get();
|
|
162
|
-
return {
|
|
163
|
-
ok: true,
|
|
164
|
-
subject: `${inst?.environment_type ?? "unknown"} instance ${inst?.id ?? "unknown"}`
|
|
165
|
-
};
|
|
166
|
-
} catch (err) {
|
|
167
|
-
return {
|
|
168
|
-
ok: false,
|
|
169
|
-
message: errorMessage(err)
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
//#endregion
|
|
174
174
|
//#region src/index.ts
|
|
175
175
|
function createContext(options = {}) {
|
|
176
176
|
let client;
|
|
@@ -190,6 +190,16 @@ function createPlugin(options = {}) {
|
|
|
190
190
|
const ctx = createContext(options);
|
|
191
191
|
return {
|
|
192
192
|
name: "@theholocron/holocron-plugin-clerk",
|
|
193
|
+
probes: { connection: connectionProbe({
|
|
194
|
+
provider: "Clerk",
|
|
195
|
+
url: options.baseUrl ?? "https://api.clerk.com",
|
|
196
|
+
fetch: options.fetch,
|
|
197
|
+
token: () => resolveToken(options),
|
|
198
|
+
verify: (token) => verifyToken(token, {
|
|
199
|
+
baseUrl: options.baseUrl,
|
|
200
|
+
fetch: options.fetch
|
|
201
|
+
})
|
|
202
|
+
}) },
|
|
193
203
|
capabilities: { auth: () => auth(ctx) }
|
|
194
204
|
};
|
|
195
205
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/holocron-plugin-clerk",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.232",
|
|
4
4
|
"description": "Holocron plugin for Clerk. Implements the auth capability against Clerk's Backend REST API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"auth",
|
|
@@ -47,12 +47,12 @@
|
|
|
47
47
|
"tsx": "4.23.15",
|
|
48
48
|
"typescript": "^5.9.3",
|
|
49
49
|
"vitest": "^4.1.11",
|
|
50
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
50
|
+
"@theholocron/cli": "5.0.0-alpha.232"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"@theholocron/clerk-client": "^1.43.1",
|
|
54
54
|
"@theholocron/misc-utils": "^1.16.0",
|
|
55
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
55
|
+
"@theholocron/cli": "5.0.0-alpha.232"
|
|
56
56
|
},
|
|
57
57
|
"engines": {
|
|
58
58
|
"node": ">=22"
|