@voltro/plugin-auth-supabase 0.85.0 → 0.87.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.js CHANGED
@@ -1,53 +1 @@
1
- import { jwtBearerStrategy as e, readClaimPath as t } from "@voltro/protocol/jwt";
2
- //#region src/strategy.ts
3
- var n = "app_metadata.tenant_id", r = "base64-", i = 32768, a = 16, o = (e, t) => {
4
- try {
5
- let n = e(t);
6
- if (!n) {
7
- let r = [], o = 0;
8
- for (let n = 0; n < a; n++) {
9
- let a = e(`${t}.${n}`);
10
- if (!a) break;
11
- if (o += a.length, o > i) return;
12
- r.push(a);
13
- }
14
- if (r.length === 0) return;
15
- n = r.join("");
16
- }
17
- if (n.length > i) return;
18
- let o = n.startsWith(r) ? Buffer.from(n.slice(7), "base64url").toString("utf8") : n, s = JSON.parse(o);
19
- if (typeof s != "object" || !s) return;
20
- let c = s.access_token;
21
- return typeof c == "string" && c.length > 0 ? c : void 0;
22
- } catch {
23
- return;
24
- }
25
- }, s = (r) => {
26
- if (!r.projectRef && !r.jwksUrl && r.jwtSecret === void 0) throw Error("supabaseStrategy: pass `projectRef` (hosted JWKS), `jwksUrl` (self-hosted JWKS), or `jwtSecret` (legacy / self-hosted HS256 shared secret)");
27
- let i = r.projectRef, a = r.issuer ?? (i ? `https://${i}.supabase.co/auth/v1` : void 0), s = r.tenantClaim ?? n, c = r.scopesFromClaims, l = {
28
- id: "supabase",
29
- ...a === void 0 ? {} : { issuer: a },
30
- audience: r.audience ?? "authenticated",
31
- cookieName: r.cookieName === void 0 ? null : r.cookieName,
32
- cookieToToken: o,
33
- tenantIdFromClaims: (e) => {
34
- if (r.tenantIdFromClaims) return r.tenantIdFromClaims(e);
35
- let n = t(e, s);
36
- return typeof n == "string" && n.length > 0 ? n : r.defaultTenantId ?? null;
37
- },
38
- ...c === void 0 ? {} : { scopesFromClaims: (e) => c(e) }
39
- };
40
- if (r.jwtSecret !== void 0) return e({
41
- ...l,
42
- jwtSecret: r.jwtSecret,
43
- algorithms: ["HS256"]
44
- });
45
- let u = r.jwksUrl ?? `https://${i}.supabase.co/auth/v1/.well-known/jwks.json`;
46
- return e({
47
- ...l,
48
- jwksUrl: u,
49
- algorithms: ["RS256", "ES256"]
50
- });
51
- };
52
- //#endregion
53
- export { s as supabaseStrategy };
1
+ export { supabaseStrategy } from "./strategy.js";
@@ -0,0 +1,53 @@
1
+ import { jwtBearerStrategy as e, readClaimPath as t } from "@voltro/protocol/jwt";
2
+ //#region src/strategy.ts
3
+ var n = "app_metadata.tenant_id", r = "base64-", i = 32768, a = 16, o = (e, t) => {
4
+ try {
5
+ let n = e(t);
6
+ if (!n) {
7
+ let r = [], o = 0;
8
+ for (let n = 0; n < a; n++) {
9
+ let a = e(`${t}.${n}`);
10
+ if (!a) break;
11
+ if (o += a.length, o > i) return;
12
+ r.push(a);
13
+ }
14
+ if (r.length === 0) return;
15
+ n = r.join("");
16
+ }
17
+ if (n.length > i) return;
18
+ let o = n.startsWith(r) ? Buffer.from(n.slice(7), "base64url").toString("utf8") : n, s = JSON.parse(o);
19
+ if (typeof s != "object" || !s) return;
20
+ let c = s.access_token;
21
+ return typeof c == "string" && c.length > 0 ? c : void 0;
22
+ } catch {
23
+ return;
24
+ }
25
+ }, s = (r) => {
26
+ if (!r.projectRef && !r.jwksUrl && r.jwtSecret === void 0) throw Error("supabaseStrategy: pass `projectRef` (hosted JWKS), `jwksUrl` (self-hosted JWKS), or `jwtSecret` (legacy / self-hosted HS256 shared secret)");
27
+ let i = r.projectRef, a = r.issuer ?? (i ? `https://${i}.supabase.co/auth/v1` : void 0), s = r.tenantClaim ?? n, c = r.scopesFromClaims, l = {
28
+ id: "supabase",
29
+ ...a === void 0 ? {} : { issuer: a },
30
+ audience: r.audience ?? "authenticated",
31
+ cookieName: r.cookieName === void 0 ? null : r.cookieName,
32
+ cookieToToken: o,
33
+ tenantIdFromClaims: (e) => {
34
+ if (r.tenantIdFromClaims) return r.tenantIdFromClaims(e);
35
+ let n = t(e, s);
36
+ return typeof n == "string" && n.length > 0 ? n : r.defaultTenantId ?? null;
37
+ },
38
+ ...c === void 0 ? {} : { scopesFromClaims: (e) => c(e) }
39
+ };
40
+ if (r.jwtSecret !== void 0) return e({
41
+ ...l,
42
+ jwtSecret: r.jwtSecret,
43
+ algorithms: ["HS256"]
44
+ });
45
+ let u = r.jwksUrl ?? `https://${i}.supabase.co/auth/v1/.well-known/jwks.json`;
46
+ return e({
47
+ ...l,
48
+ jwksUrl: u,
49
+ algorithms: ["RS256", "ES256"]
50
+ });
51
+ };
52
+ //#endregion
53
+ export { s as supabaseStrategy };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voltro/plugin-auth-supabase",
3
- "version": "0.85.0",
3
+ "version": "0.87.0",
4
4
  "description": "Supabase Auth (GoTrue)-backed AuthStrategy for the Voltro framework. Verifies Supabase-issued JWTs via the project's JWKS endpoint. Conforms to @voltro/protocol AuthStrategy so it composes with other IdP plugins.",
5
5
  "keywords": [
6
6
  "voltro",
@@ -33,7 +33,7 @@
33
33
  "node": ">=24.0.0"
34
34
  },
35
35
  "dependencies": {
36
- "@voltro/protocol": "0.85.0"
36
+ "@voltro/protocol": "0.87.0"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "effect": "4.0.1"