@nextblock-cms/db 0.20.1 → 0.21.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/index.cjs.js +1 -1
- package/index.es.js +4 -10
- package/lib/config-resolve.cjs.js +1 -1
- package/lib/config-resolve.es.js +11 -15
- package/lib/media-actions.cjs.js +1 -1
- package/lib/media-actions.es.js +53 -60
- package/lib/package-validation.cjs.js +1 -1
- package/lib/package-validation.es.js +45 -57
- package/lib/secret-crypto.cjs.js +1 -1
- package/lib/secret-crypto.es.js +101 -116
- package/lib/supabase/client.cjs.js +1 -1
- package/lib/supabase/client.es.js +14 -19
- package/lib/supabase/server.cjs.js +1 -1
- package/lib/supabase/server.es.js +45 -53
- package/lib/supabase/ssg-client.cjs.js +1 -1
- package/lib/supabase/ssg-client.es.js +7 -7
- package/lib/supabase/types.cjs.js +1 -1
- package/lib/supabase/types.es.js +27 -15
- package/package.json +1 -1
- package/secrets.cjs.js +1 -1
- package/secrets.es.js +3 -19
- package/server.cjs.js +1 -1
- package/server.es.js +6 -31
- package/supabase/migrations/02017_install_guide_node22.sql +70 -0
package/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./lib/supabase/client.cjs.js"),t=require("./lib/supabase/types.cjs.js"),n=require("./lib/media-actions.cjs.js");exports.Constants=t.Constants,exports.createClient=e.createClient,exports.getActiveLanguagesClientSide=e.getActiveLanguagesClientSide,exports.getProfileWithRoleClientSide=e.getProfileWithRoleClientSide,exports.recordMediaUpload=n.recordMediaUpload;
|
package/index.es.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import { createClient as
|
|
2
|
-
import { Constants as
|
|
3
|
-
import { recordMediaUpload as
|
|
4
|
-
export {
|
|
5
|
-
l as Constants,
|
|
6
|
-
o as createClient,
|
|
7
|
-
r as getActiveLanguagesClientSide,
|
|
8
|
-
i as getProfileWithRoleClientSide,
|
|
9
|
-
d as recordMediaUpload
|
|
10
|
-
};
|
|
1
|
+
import { createClient as e, getActiveLanguagesClientSide as t, getProfileWithRoleClientSide as n } from "./lib/supabase/client.es.js";
|
|
2
|
+
import { Constants as r } from "./lib/supabase/types.es.js";
|
|
3
|
+
import { recordMediaUpload as i } from "./lib/media-actions.es.js";
|
|
4
|
+
export { r as Constants, e as createClient, t as getActiveLanguagesClientSide, n as getProfileWithRoleClientSide, i as recordMediaUpload };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
var e=new Set;function t(t,n,r){let i=typeof t==`string`?t.trim():``;if(i)return i;let a=process.env[n],o=typeof a==`string`?a.trim():``;return o?(r?.warnOnEnvFallback!==!1&&!e.has(n)&&(e.add(n),console.warn(`[nextblock-config] "${n}" is still resolved from an environment variable. Configure it in the CMS to move it into the database.`)),o):null}function n(){return process.env.NEXT_PUBLIC_IS_SANDBOX===`true`}exports.isSandboxEnvironment=n,exports.resolveConfigValue=t;
|
package/lib/config-resolve.es.js
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
`[nextblock-config] "${n}" is still resolved from an environment variable. Configure it in the CMS to move it into the database.`
|
|
9
|
-
)), e) : null;
|
|
1
|
+
//#region libs/db/src/lib/config-resolve.ts
|
|
2
|
+
var e = /* @__PURE__ */ new Set();
|
|
3
|
+
function t(t, n, r) {
|
|
4
|
+
let i = typeof t == "string" ? t.trim() : "";
|
|
5
|
+
if (i) return i;
|
|
6
|
+
let a = process.env[n], o = typeof a == "string" ? a.trim() : "";
|
|
7
|
+
return o ? (r?.warnOnEnvFallback !== !1 && !e.has(n) && (e.add(n), console.warn(`[nextblock-config] "${n}" is still resolved from an environment variable. Configure it in the CMS to move it into the database.`)), o) : null;
|
|
10
8
|
}
|
|
11
|
-
function
|
|
12
|
-
|
|
9
|
+
function n() {
|
|
10
|
+
return process.env.NEXT_PUBLIC_IS_SANDBOX === "true";
|
|
13
11
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
f as resolveConfigValue
|
|
17
|
-
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { n as isSandboxEnvironment, t as resolveConfigValue };
|
package/lib/media-actions.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use
|
|
1
|
+
"use server";const e=require("./supabase/server.cjs.js");let t=require("next/cache"),n=require("@nextblock-cms/utils/server");async function r(r,i){let a=r.actorUserId,o=a?e.getServiceRoleSupabaseClient():e.createClient(),s;if(a)s=a;else{let{data:{user:e},error:t}=await o.auth.getUser();if(t||!e)return i?{error:`User not authenticated for media record.`}:(0,n.encodedRedirect)(`error`,`/cms/media`,`User not authenticated for media record.`);s=e.id}let{data:c}=await o.from(`profiles`).select(`role`).eq(`id`,s).single();if(!c||![`ADMIN`,`WRITER`].includes(c.role))return i?{error:`Forbidden: Insufficient permissions to record media.`}:(0,n.encodedRedirect)(`error`,`/cms/media`,`Forbidden: Insufficient permissions to record media.`);let l=r.r2Variants.find(e=>e.variantLabel===`original_avif`)||r.r2Variants.find(e=>e.variantLabel===`xlarge_avif`)||r.r2Variants[0]||r.originalImageDetails;l||=r.originalImageDetails||{objectKey:r.r2OriginalKey,url:``,width:0,height:0,fileType:`application/octet-stream`,sizeBytes:0,variantLabel:`fallback_original`};let u=[...r.originalImageDetails&&r.originalImageDetails.objectKey!==l.objectKey?[r.originalImageDetails]:[],...r.r2Variants].filter((e,t,n)=>t===n.findIndex(t=>t.objectKey===e.objectKey)),d=r.description??(l.fileType?.startsWith(`image/`)||r.originalImageDetails?.fileType?.startsWith(`image/`)?(e=>{let t=e.lastIndexOf(`.`);return(t>0?e.substring(0,t):e).replace(/[-+_\\]+/g,` `).replace(/\s+/g,` `).trim().replace(/\b\w+/g,e=>e.charAt(0).toUpperCase()+e.slice(1))})(r.fileName):null),f={uploader_id:s,file_name:r.fileName,object_key:l.objectKey,file_path:l.objectKey,folder:(()=>{let e=l.objectKey.match(/^(.*\/)?.*$/);return e&&e[1]?e[1]:null})(),file_type:l.fileType,size_bytes:l.sizeBytes,description:d,width:l.width,height:l.height,variants:u,blur_data_url:r.blurDataUrl||null},{data:p,error:m}=await o.from(`media`).insert(f).select().single();if(m)return console.error(`Error recording media upload:`,m),i?{error:`Failed to record media: ${m.message}`}:(0,n.encodedRedirect)(`error`,`/cms/media`,`Failed to record media: ${m.message}`);if((0,t.revalidatePath)(`/cms/media`),i)return{success:!0,data:p};(0,n.encodedRedirect)(`success`,`/cms/media`,`Media recorded successfully.`)}exports.recordMediaUpload=r;
|
package/lib/media-actions.es.js
CHANGED
|
@@ -1,61 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}, { data: I, error: o } = await l.from("media").insert(p).select().single();
|
|
53
|
-
if (o)
|
|
54
|
-
return console.error("Error recording media upload:", o), a ? { error: `Failed to record media: ${o.message}` } : n("error", "/cms/media", `Failed to record media: ${o.message}`);
|
|
55
|
-
if (v("/cms/media"), a)
|
|
56
|
-
return { success: !0, data: I };
|
|
57
|
-
n("success", "/cms/media", "Media recorded successfully.");
|
|
1
|
+
"use server";
|
|
2
|
+
import { createClient as e, getServiceRoleSupabaseClient as t } from "./supabase/server.es.js";
|
|
3
|
+
import { revalidatePath as n } from "next/cache";
|
|
4
|
+
import { encodedRedirect as r } from "@nextblock-cms/utils/server";
|
|
5
|
+
//#region libs/db/src/lib/media-actions.ts
|
|
6
|
+
async function i(i, a) {
|
|
7
|
+
let o = i.actorUserId, s = o ? t() : e(), c;
|
|
8
|
+
if (o) c = o;
|
|
9
|
+
else {
|
|
10
|
+
let { data: { user: e }, error: t } = await s.auth.getUser();
|
|
11
|
+
if (t || !e) return a ? { error: "User not authenticated for media record." } : r("error", "/cms/media", "User not authenticated for media record.");
|
|
12
|
+
c = e.id;
|
|
13
|
+
}
|
|
14
|
+
let { data: l } = await s.from("profiles").select("role").eq("id", c).single();
|
|
15
|
+
if (!l || !["ADMIN", "WRITER"].includes(l.role)) return a ? { error: "Forbidden: Insufficient permissions to record media." } : r("error", "/cms/media", "Forbidden: Insufficient permissions to record media.");
|
|
16
|
+
let u = i.r2Variants.find((e) => e.variantLabel === "original_avif") || i.r2Variants.find((e) => e.variantLabel === "xlarge_avif") || i.r2Variants[0] || i.originalImageDetails;
|
|
17
|
+
u ||= i.originalImageDetails || {
|
|
18
|
+
objectKey: i.r2OriginalKey,
|
|
19
|
+
url: "",
|
|
20
|
+
width: 0,
|
|
21
|
+
height: 0,
|
|
22
|
+
fileType: "application/octet-stream",
|
|
23
|
+
sizeBytes: 0,
|
|
24
|
+
variantLabel: "fallback_original"
|
|
25
|
+
};
|
|
26
|
+
let d = [...i.originalImageDetails && i.originalImageDetails.objectKey !== u.objectKey ? [i.originalImageDetails] : [], ...i.r2Variants].filter((e, t, n) => t === n.findIndex((t) => t.objectKey === e.objectKey)), f = i.description ?? (u.fileType?.startsWith("image/") || i.originalImageDetails?.fileType?.startsWith("image/") ? ((e) => {
|
|
27
|
+
let t = e.lastIndexOf(".");
|
|
28
|
+
return (t > 0 ? e.substring(0, t) : e).replace(/[-+_\\]+/g, " ").replace(/\s+/g, " ").trim().replace(/\b\w+/g, (e) => e.charAt(0).toUpperCase() + e.slice(1));
|
|
29
|
+
})(i.fileName) : null), p = {
|
|
30
|
+
uploader_id: c,
|
|
31
|
+
file_name: i.fileName,
|
|
32
|
+
object_key: u.objectKey,
|
|
33
|
+
file_path: u.objectKey,
|
|
34
|
+
folder: (() => {
|
|
35
|
+
let e = u.objectKey.match(/^(.*\/)?.*$/);
|
|
36
|
+
return e && e[1] ? e[1] : null;
|
|
37
|
+
})(),
|
|
38
|
+
file_type: u.fileType,
|
|
39
|
+
size_bytes: u.sizeBytes,
|
|
40
|
+
description: f,
|
|
41
|
+
width: u.width,
|
|
42
|
+
height: u.height,
|
|
43
|
+
variants: d,
|
|
44
|
+
blur_data_url: i.blurDataUrl || null
|
|
45
|
+
}, { data: m, error: h } = await s.from("media").insert(p).select().single();
|
|
46
|
+
if (h) return console.error("Error recording media upload:", h), a ? { error: `Failed to record media: ${h.message}` } : r("error", "/cms/media", `Failed to record media: ${h.message}`);
|
|
47
|
+
if (n("/cms/media"), a) return {
|
|
48
|
+
success: !0,
|
|
49
|
+
data: m
|
|
50
|
+
};
|
|
51
|
+
r("success", "/cms/media", "Media recorded successfully.");
|
|
58
52
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
};
|
|
53
|
+
//#endregion
|
|
54
|
+
export { i as recordMediaUpload };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require("./supabase/server.cjs.js");let t=require("@supabase/supabase-js"),n=require("next/cache");require("server-only");var r=`package-activation`;function i(e){if(typeof e!=`string`||!e.trim())return null;let t=e.trim(),n=/(?:z|[+-]\d{2}:?\d{2})$/i.test(t),r=Date.parse(n?t:`${t.replace(` `,`T`)}Z`);return Number.isFinite(r)?r:null}function a(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=t.nextblock&&typeof t.nextblock==`object`&&!Array.isArray(t.nextblock)?t.nextblock:null,r=[n?.expiration,n?.trial_ends_at,t.expiration].map(i).filter(e=>e!==null);return r.length>0?Math.min(...r):null}function o(e,t=Date.now()){if(e.status!==`active`)return!1;let n=a(e.meta);return n===null||n>t}async function s(e,t){try{let{data:n,error:r}=await t.from(`package_activations`).select(`status, meta`).eq(`package_id`,e).eq(`status`,`active`).limit(5);return r||!Array.isArray(n)?!1:n.some(e=>o(e))}catch(t){return console.error(`Error verifying package ${e}:`,t),!1}}var c=(0,n.unstable_cache)(async e=>{let n=process.env.NEXT_PUBLIC_SUPABASE_URL||process.env.SUPABASE_URL,r=process.env.SUPABASE_SERVICE_ROLE_KEY||process.env.SUPABASE_SECRET_KEY||process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY||process.env.SUPABASE_ANON_KEY||process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY||process.env.SUPABASE_PUBLISHABLE_KEY;return!n||!r?!1:s(e,(0,t.createClient)(n,r,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1}}))},[`package-activation`],{revalidate:60,tags:[r]});async function l(t,n){if(n)return s(t,n);let r=process.env.NEXT_PUBLIC_SUPABASE_URL||process.env.SUPABASE_URL,i=process.env.SUPABASE_SERVICE_ROLE_KEY||process.env.SUPABASE_SECRET_KEY||process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY||process.env.SUPABASE_ANON_KEY||process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY||process.env.SUPABASE_PUBLISHABLE_KEY;return r&&i?c(t):s(t,await e.createClient())}exports.PACKAGE_ACTIVATION_CACHE_TAG=r,exports.isPackageActivationRowValid=o,exports.resolvePackageActivationExpiry=a,exports.verifyPackageOnline=l;
|
|
@@ -1,63 +1,51 @@
|
|
|
1
|
+
import { createClient as e } from "./supabase/server.es.js";
|
|
2
|
+
import { createClient as t } from "@supabase/supabase-js";
|
|
3
|
+
import { unstable_cache as n } from "next/cache";
|
|
1
4
|
import "server-only";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return null;
|
|
9
|
-
const r = e.trim(), t = /(?:z|[+-]\d{2}:?\d{2})$/i.test(r), n = Date.parse(t ? r : `${r.replace(" ", "T")}Z`);
|
|
10
|
-
return Number.isFinite(n) ? n : null;
|
|
5
|
+
//#region libs/db/src/lib/package-validation.ts
|
|
6
|
+
var r = "package-activation";
|
|
7
|
+
function i(e) {
|
|
8
|
+
if (typeof e != "string" || !e.trim()) return null;
|
|
9
|
+
let t = e.trim(), n = /(?:z|[+-]\d{2}:?\d{2})$/i.test(t), r = Date.parse(n ? t : `${t.replace(" ", "T")}Z`);
|
|
10
|
+
return Number.isFinite(r) ? r : null;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
function a(e) {
|
|
13
|
+
if (!e || typeof e != "object" || Array.isArray(e)) return null;
|
|
14
|
+
let t = e, n = t.nextblock && typeof t.nextblock == "object" && !Array.isArray(t.nextblock) ? t.nextblock : null, r = [
|
|
15
|
+
n?.expiration,
|
|
16
|
+
n?.trial_ends_at,
|
|
17
|
+
t.expiration
|
|
18
|
+
].map(i).filter((e) => e !== null);
|
|
19
|
+
return r.length > 0 ? Math.min(...r) : null;
|
|
17
20
|
}
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return t === null || t > r;
|
|
21
|
+
function o(e, t = Date.now()) {
|
|
22
|
+
if (e.status !== "active") return !1;
|
|
23
|
+
let n = a(e.meta);
|
|
24
|
+
return n === null || n > t;
|
|
23
25
|
}
|
|
24
|
-
async function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
async function s(e, t) {
|
|
27
|
+
try {
|
|
28
|
+
let { data: n, error: r } = await t.from("package_activations").select("status, meta").eq("package_id", e).eq("status", "active").limit(5);
|
|
29
|
+
return r || !Array.isArray(n) ? !1 : n.some((e) => o(e));
|
|
30
|
+
} catch (t) {
|
|
31
|
+
return console.error(`Error verifying package ${e}:`, t), !1;
|
|
32
|
+
}
|
|
31
33
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
{ revalidate: 60, tags: [A] }
|
|
48
|
-
);
|
|
49
|
-
async function U(e, r) {
|
|
50
|
-
if (r)
|
|
51
|
-
return a(e, r);
|
|
52
|
-
const t = process.env.NEXT_PUBLIC_SUPABASE_URL || process.env.SUPABASE_URL, n = process.env.SUPABASE_SERVICE_ROLE_KEY || process.env.SUPABASE_SECRET_KEY || process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY || process.env.SUPABASE_ANON_KEY || process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY || process.env.SUPABASE_PUBLISHABLE_KEY;
|
|
53
|
-
if (t && n)
|
|
54
|
-
return S(e);
|
|
55
|
-
const s = await c();
|
|
56
|
-
return a(e, s);
|
|
34
|
+
var c = n(async (e) => {
|
|
35
|
+
let n = process.env.NEXT_PUBLIC_SUPABASE_URL || process.env.SUPABASE_URL, r = process.env.SUPABASE_SERVICE_ROLE_KEY || process.env.SUPABASE_SECRET_KEY || process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY || process.env.SUPABASE_ANON_KEY || process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY || process.env.SUPABASE_PUBLISHABLE_KEY;
|
|
36
|
+
return !n || !r ? !1 : s(e, t(n, r, { auth: {
|
|
37
|
+
persistSession: !1,
|
|
38
|
+
autoRefreshToken: !1,
|
|
39
|
+
detectSessionInUrl: !1
|
|
40
|
+
} }));
|
|
41
|
+
}, ["package-activation"], {
|
|
42
|
+
revalidate: 60,
|
|
43
|
+
tags: [r]
|
|
44
|
+
});
|
|
45
|
+
async function l(t, n) {
|
|
46
|
+
if (n) return s(t, n);
|
|
47
|
+
let r = process.env.NEXT_PUBLIC_SUPABASE_URL || process.env.SUPABASE_URL, i = process.env.SUPABASE_SERVICE_ROLE_KEY || process.env.SUPABASE_SECRET_KEY || process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY || process.env.SUPABASE_ANON_KEY || process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY || process.env.SUPABASE_PUBLISHABLE_KEY;
|
|
48
|
+
return r && i ? c(t) : s(t, await e());
|
|
57
49
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
l as isPackageActivationRowValid,
|
|
61
|
-
_ as resolvePackageActivationExpiry,
|
|
62
|
-
U as verifyPackageOnline
|
|
63
|
-
};
|
|
50
|
+
//#endregion
|
|
51
|
+
export { r as PACKAGE_ACTIVATION_CACHE_TAG, o as isPackageActivationRowValid, a as resolvePackageActivationExpiry, l as verifyPackageOnline };
|
package/lib/secret-crypto.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
let e=require("node:crypto");var t=`aes-256-gcm`,n=1;function r(t){let n=t.trim();if(!n)throw Error(`A non-empty encryption secret is required to manage stored secrets.`);return(0,e.createHash)(`sha256`).update(n).digest()}function i(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.algorithm===`aes-256-gcm`&&t.version===1&&typeof t.authTag==`string`&&typeof t.ciphertext==`string`&&typeof t.iv==`string`}function a(e){if(!i(e))throw Error(`Invalid encrypted secret payload.`);let t=e;return{algorithm:t.algorithm,authTag:t.authTag,ciphertext:t.ciphertext,iv:t.iv,last4:typeof t.last4==`string`?t.last4:``,updatedAt:typeof t.updatedAt==`string`?t.updatedAt:``,version:t.version}}function o(n){let i=n.value.trim();if(!i)throw Error(`A non-empty value is required to encrypt a secret.`);let a=r(n.encryptionSecret),o=(0,e.randomBytes)(12),s=(0,e.createCipheriv)(t,a,o),c=Buffer.concat([s.update(i,`utf8`),s.final()]);return{algorithm:t,authTag:s.getAuthTag().toString(`base64`),ciphertext:c.toString(`base64`),iv:o.toString(`base64`),last4:i.slice(-4),updatedAt:(n.now??new Date).toISOString(),version:1}}function s(n){let i=a(n.envelope),o=r(n.encryptionSecret);try{let n=(0,e.createDecipheriv)(t,o,Buffer.from(i.iv,`base64`));return n.setAuthTag(Buffer.from(i.authTag,`base64`)),Buffer.concat([n.update(Buffer.from(i.ciphertext,`base64`)),n.final()]).toString(`utf8`)}catch{throw Error(`Failed to decrypt stored secret.`)}}function c(e){let t=(e??``).trim();return t?`•••• ${t}`:`Stored secret`}function l(e){if(!i(e))return{hasStoredValue:!1,last4:null,maskedValue:null,updatedAt:null};let t=e,n=typeof t.last4==`string`&&t.last4?t.last4:null;return{hasStoredValue:!0,last4:n,maskedValue:c(n),updatedAt:typeof t.updatedAt==`string`&&t.updatedAt?t.updatedAt:null}}var u=`nextblock-secret-encryption-key-v1`;function d(){let t=process.env.SUPABASE_SERVICE_ROLE_KEY??process.env.SUPABASE_SECRET_KEY;return typeof t!=`string`||!t.trim()?null:(0,e.createHmac)(`sha256`,t.trim()).update(u).digest(`hex`)}function f(){let e=[],t=t=>{let n=typeof t==`string`?t.trim():``;n&&!e.includes(n)&&e.push(n)};return t(process.env.NEXTBLOCK_ENCRYPTION_KEY),t(process.env.CORTEX_AI_ENCRYPTION_KEY),t(d()),e}function p(){return f()[0]??null}function m(){return p()!==null}function h(){let e=p();if(!e)throw Error(`An encryption key (NEXTBLOCK_ENCRYPTION_KEY or CORTEX_AI_ENCRYPTION_KEY) is required to manage stored secrets.`);return e}function g(e,t){return o({value:e,encryptionSecret:h(),now:t})}function _(e){return s({envelope:e,encryptionSecret:h()})}function v(e){if(!i(e))return null;for(let t of f())try{return s({envelope:e,encryptionSecret:t})}catch{}return null}exports.SECRET_ENVELOPE_ALGORITHM=t,exports.SECRET_ENVELOPE_VERSION=n,exports.decryptSecret=s,exports.decryptWithEnvKey=_,exports.encryptSecret=o,exports.encryptWithEnvKey=g,exports.getMaskedSecret=c,exports.getSecretEnvelopeStatus=l,exports.hasSecretEncryptionKey=m,exports.isEncryptedSecretEnvelope=i,exports.requireSecretEncryptionKey=h,exports.resolveSecretEncryptionKey=p,exports.tryDecryptWithEnvKey=v;
|
package/lib/secret-crypto.es.js
CHANGED
|
@@ -1,131 +1,116 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { createCipheriv as e, createDecipheriv as t, createHash as n, createHmac as r, randomBytes as i } from "node:crypto";
|
|
2
|
+
//#region libs/db/src/lib/secret-crypto.ts
|
|
3
|
+
var a = "aes-256-gcm", o = 1;
|
|
4
|
+
function s(e) {
|
|
5
|
+
let t = e.trim();
|
|
6
|
+
if (!t) throw Error("A non-empty encryption secret is required to manage stored secrets.");
|
|
7
|
+
return n("sha256").update(t).digest();
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return e.algorithm === o && e.version === s && typeof e.authTag == "string" && typeof e.ciphertext == "string" && typeof e.iv == "string";
|
|
9
|
+
function c(e) {
|
|
10
|
+
if (!e || typeof e != "object") return !1;
|
|
11
|
+
let t = e;
|
|
12
|
+
return t.algorithm === "aes-256-gcm" && t.version === 1 && typeof t.authTag == "string" && typeof t.ciphertext == "string" && typeof t.iv == "string";
|
|
14
13
|
}
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
function A(t) {
|
|
30
|
-
const e = t.value.trim();
|
|
31
|
-
if (!e)
|
|
32
|
-
throw new Error("A non-empty value is required to encrypt a secret.");
|
|
33
|
-
const n = a(t.encryptionSecret), r = h(12), c = g(o, n, r), l = Buffer.concat([c.update(e, "utf8"), c.final()]), y = c.getAuthTag();
|
|
34
|
-
return {
|
|
35
|
-
algorithm: o,
|
|
36
|
-
authTag: y.toString("base64"),
|
|
37
|
-
ciphertext: l.toString("base64"),
|
|
38
|
-
iv: r.toString("base64"),
|
|
39
|
-
last4: e.slice(-4),
|
|
40
|
-
updatedAt: (t.now ?? /* @__PURE__ */ new Date()).toISOString(),
|
|
41
|
-
version: s
|
|
42
|
-
};
|
|
14
|
+
function l(e) {
|
|
15
|
+
if (!c(e)) throw Error("Invalid encrypted secret payload.");
|
|
16
|
+
let t = e;
|
|
17
|
+
return {
|
|
18
|
+
algorithm: t.algorithm,
|
|
19
|
+
authTag: t.authTag,
|
|
20
|
+
ciphertext: t.ciphertext,
|
|
21
|
+
iv: t.iv,
|
|
22
|
+
last4: typeof t.last4 == "string" ? t.last4 : "",
|
|
23
|
+
updatedAt: typeof t.updatedAt == "string" ? t.updatedAt : "",
|
|
24
|
+
version: t.version
|
|
25
|
+
};
|
|
43
26
|
}
|
|
44
27
|
function u(t) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
28
|
+
let n = t.value.trim();
|
|
29
|
+
if (!n) throw Error("A non-empty value is required to encrypt a secret.");
|
|
30
|
+
let r = s(t.encryptionSecret), o = i(12), c = e(a, r, o), l = Buffer.concat([c.update(n, "utf8"), c.final()]);
|
|
31
|
+
return {
|
|
32
|
+
algorithm: a,
|
|
33
|
+
authTag: c.getAuthTag().toString("base64"),
|
|
34
|
+
ciphertext: l.toString("base64"),
|
|
35
|
+
iv: o.toString("base64"),
|
|
36
|
+
last4: n.slice(-4),
|
|
37
|
+
updatedAt: (t.now ?? /* @__PURE__ */ new Date()).toISOString(),
|
|
38
|
+
version: 1
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function d(e) {
|
|
42
|
+
let n = l(e.envelope), r = s(e.encryptionSecret);
|
|
43
|
+
try {
|
|
44
|
+
let e = t(a, r, Buffer.from(n.iv, "base64"));
|
|
45
|
+
return e.setAuthTag(Buffer.from(n.authTag, "base64")), Buffer.concat([e.update(Buffer.from(n.ciphertext, "base64")), e.final()]).toString("utf8");
|
|
46
|
+
} catch {
|
|
47
|
+
throw Error("Failed to decrypt stored secret.");
|
|
48
|
+
}
|
|
59
49
|
}
|
|
60
|
-
function
|
|
61
|
-
|
|
62
|
-
|
|
50
|
+
function f(e) {
|
|
51
|
+
let t = (e ?? "").trim();
|
|
52
|
+
return t ? `•••• ${t}` : "Stored secret";
|
|
63
53
|
}
|
|
64
|
-
function
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
54
|
+
function p(e) {
|
|
55
|
+
if (!c(e)) return {
|
|
56
|
+
hasStoredValue: !1,
|
|
57
|
+
last4: null,
|
|
58
|
+
maskedValue: null,
|
|
59
|
+
updatedAt: null
|
|
60
|
+
};
|
|
61
|
+
let t = e, n = typeof t.last4 == "string" && t.last4 ? t.last4 : null;
|
|
62
|
+
return {
|
|
63
|
+
hasStoredValue: !0,
|
|
64
|
+
last4: n,
|
|
65
|
+
maskedValue: f(n),
|
|
66
|
+
updatedAt: typeof t.updatedAt == "string" && t.updatedAt ? t.updatedAt : null
|
|
67
|
+
};
|
|
74
68
|
}
|
|
75
|
-
|
|
76
|
-
function
|
|
77
|
-
|
|
78
|
-
|
|
69
|
+
var m = "nextblock-secret-encryption-key-v1";
|
|
70
|
+
function h() {
|
|
71
|
+
let e = process.env.SUPABASE_SERVICE_ROLE_KEY ?? process.env.SUPABASE_SECRET_KEY;
|
|
72
|
+
return typeof e != "string" || !e.trim() ? null : r("sha256", e.trim()).update(m).digest("hex");
|
|
79
73
|
}
|
|
80
|
-
function
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
74
|
+
function g() {
|
|
75
|
+
let e = [], t = (t) => {
|
|
76
|
+
let n = typeof t == "string" ? t.trim() : "";
|
|
77
|
+
n && !e.includes(n) && e.push(n);
|
|
78
|
+
};
|
|
79
|
+
return t(process.env.NEXTBLOCK_ENCRYPTION_KEY), t(process.env.CORTEX_AI_ENCRYPTION_KEY), t(h()), e;
|
|
86
80
|
}
|
|
87
|
-
function
|
|
88
|
-
|
|
81
|
+
function _() {
|
|
82
|
+
return g()[0] ?? null;
|
|
89
83
|
}
|
|
90
|
-
function
|
|
91
|
-
|
|
84
|
+
function v() {
|
|
85
|
+
return _() !== null;
|
|
92
86
|
}
|
|
93
|
-
function
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
"An encryption key (NEXTBLOCK_ENCRYPTION_KEY or CORTEX_AI_ENCRYPTION_KEY) is required to manage stored secrets."
|
|
98
|
-
);
|
|
99
|
-
return t;
|
|
87
|
+
function y() {
|
|
88
|
+
let e = _();
|
|
89
|
+
if (!e) throw Error("An encryption key (NEXTBLOCK_ENCRYPTION_KEY or CORTEX_AI_ENCRYPTION_KEY) is required to manage stored secrets.");
|
|
90
|
+
return e;
|
|
100
91
|
}
|
|
101
|
-
function
|
|
102
|
-
|
|
92
|
+
function b(e, t) {
|
|
93
|
+
return u({
|
|
94
|
+
value: e,
|
|
95
|
+
encryptionSecret: y(),
|
|
96
|
+
now: t
|
|
97
|
+
});
|
|
103
98
|
}
|
|
104
|
-
function
|
|
105
|
-
|
|
99
|
+
function x(e) {
|
|
100
|
+
return d({
|
|
101
|
+
envelope: e,
|
|
102
|
+
encryptionSecret: y()
|
|
103
|
+
});
|
|
106
104
|
}
|
|
107
|
-
function
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
105
|
+
function S(e) {
|
|
106
|
+
if (!c(e)) return null;
|
|
107
|
+
for (let t of g()) try {
|
|
108
|
+
return d({
|
|
109
|
+
envelope: e,
|
|
110
|
+
encryptionSecret: t
|
|
111
|
+
});
|
|
112
|
+
} catch {}
|
|
113
|
+
return null;
|
|
116
114
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
s as SECRET_ENVELOPE_VERSION,
|
|
120
|
-
u as decryptSecret,
|
|
121
|
-
I as decryptWithEnvKey,
|
|
122
|
-
A as encryptSecret,
|
|
123
|
-
C as encryptWithEnvKey,
|
|
124
|
-
_ as getMaskedSecret,
|
|
125
|
-
R as getSecretEnvelopeStatus,
|
|
126
|
-
N as hasSecretEncryptionKey,
|
|
127
|
-
i as isEncryptedSecretEnvelope,
|
|
128
|
-
f as requireSecretEncryptionKey,
|
|
129
|
-
d as resolveSecretEncryptionKey,
|
|
130
|
-
w as tryDecryptWithEnvKey
|
|
131
|
-
};
|
|
115
|
+
//#endregion
|
|
116
|
+
export { a as SECRET_ENVELOPE_ALGORITHM, o as SECRET_ENVELOPE_VERSION, d as decryptSecret, x as decryptWithEnvKey, u as encryptSecret, b as encryptWithEnvKey, f as getMaskedSecret, p as getSecretEnvelopeStatus, v as hasSecretEncryptionKey, c as isEncryptedSecretEnvelope, y as requireSecretEncryptionKey, _ as resolveSecretEncryptionKey, S as tryDecryptWithEnvKey };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
let e=require("@supabase/ssr");var t=()=>{let t=typeof window<`u`?window.__NEXTBLOCK_PUBLIC_ENV__:void 0,n=process.env.NEXT_PUBLIC_SUPABASE_URL||process.env.SUPABASE_URL||t?.url,r=process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY||process.env.SUPABASE_ANON_KEY||process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY||process.env.SUPABASE_PUBLISHABLE_KEY||t?.anonKey;if(!n||!r)throw Error(`CRITICAL: Supabase URL or Anon Key is missing. Please ensure NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY are set in your production environment. URL_IS_SET: ${!!n}, ANON_KEY_IS_SET: ${!!r}`);return(0,e.createBrowserClient)(n,r)};async function n(e,t){let{data:n,error:r}=await e.from(`profiles`).select(`id, full_name, avatar_url, role, updated_at, website`).eq(`id`,t).single();return r||!n?null:n}async function r(){let{data:e,error:n}=await t().from(`languages`).select(`id, code, name, is_default, is_active, created_at, updated_at`).order(`name`,{ascending:!0});return n?[]:e||[]}exports.createClient=t,exports.getActiveLanguagesClientSide=r,exports.getProfileWithRoleClientSide=n;
|
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
import { createBrowserClient as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
);
|
|
8
|
-
return o(r, e);
|
|
1
|
+
import { createBrowserClient as e } from "@supabase/ssr";
|
|
2
|
+
//#region libs/db/src/lib/supabase/client.ts
|
|
3
|
+
var t = () => {
|
|
4
|
+
let t = typeof window < "u" ? window.__NEXTBLOCK_PUBLIC_ENV__ : void 0, n = process.env.NEXT_PUBLIC_SUPABASE_URL || process.env.SUPABASE_URL || t?.url, r = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY || process.env.SUPABASE_ANON_KEY || process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY || process.env.SUPABASE_PUBLISHABLE_KEY || t?.anonKey;
|
|
5
|
+
if (!n || !r) throw Error(`CRITICAL: Supabase URL or Anon Key is missing. Please ensure NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY are set in your production environment. URL_IS_SET: ${!!n}, ANON_KEY_IS_SET: ${!!r}`);
|
|
6
|
+
return e(n, r);
|
|
9
7
|
};
|
|
10
|
-
async function
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
async function n(e, t) {
|
|
9
|
+
let { data: n, error: r } = await e.from("profiles").select("id, full_name, avatar_url, role, updated_at, website").eq("id", t).single();
|
|
10
|
+
return r || !n ? null : n;
|
|
13
11
|
}
|
|
14
|
-
async function
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
async function r() {
|
|
13
|
+
let { data: e, error: n } = await t().from("languages").select("id, code, name, is_default, is_active, created_at, updated_at").order("name", { ascending: !0 });
|
|
14
|
+
return n ? [] : e || [];
|
|
17
15
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
i as getActiveLanguagesClientSide,
|
|
21
|
-
_ as getProfileWithRoleClientSide
|
|
22
|
-
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { t as createClient, r as getActiveLanguagesClientSide, n as getProfileWithRoleClientSide };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
let e=require("@supabase/ssr"),t=require("@supabase/supabase-js"),n=require("next/headers");var r=`This module cannot be imported from a Client Component module. It should only be used from a Server Component.`;if(typeof window<`u`)throw Error(r);var i=()=>{let t=process.env.NEXT_PUBLIC_SUPABASE_URL||process.env.SUPABASE_URL||`https://dummy.supabase.co`,r=process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY||process.env.SUPABASE_ANON_KEY||process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY||process.env.SUPABASE_PUBLISHABLE_KEY||`dummy-anon-key`;return(0,e.createServerClient)(t,r,{cookies:{getAll:async()=>{try{return(await(0,n.cookies)()).getAll()}catch{return[]}},setAll:async e=>{try{let t=await(0,n.cookies)();for(let{name:n,value:r,options:i}of e)r&&r.length>0?t.set({name:n,value:r,...i}):i&&Object.keys(i).length>0?t.delete({name:n,...i}):t.delete(n)}catch{}}}})};async function a(e){let{data:t,error:n}=await i().from(`profiles`).select(`id, full_name, avatar_url, role, updated_at, website`).eq(`id`,e).single();return n||!t?(console.error(`Error fetching profile (server-side):`,n?.message),null):t}async function o(){let{data:e,error:t}=await i().from(`languages`).select(`id, code, name, is_default, is_active, created_at, updated_at`).order(`name`,{ascending:!0});return t?(console.error(`Error fetching languages (server-side):`,t.message),[]):e||[]}var s=()=>{let e=process.env.NEXT_PUBLIC_SUPABASE_URL||process.env.SUPABASE_URL,n=process.env.SUPABASE_SERVICE_ROLE_KEY||process.env.SUPABASE_SECRET_KEY;if(!e||!n)throw Error(`Missing Supabase Service Role environment variables`);return(0,t.createClient)(e,n,{auth:{autoRefreshToken:!1,persistSession:!1}})};exports.createClient=i,exports.getActiveLanguagesServerSide=o,exports.getProfileWithRoleServerSide=a,exports.getServiceRoleSupabaseClient=s;
|
|
@@ -1,57 +1,49 @@
|
|
|
1
|
-
import { createServerClient as
|
|
2
|
-
import { createClient as
|
|
3
|
-
import { cookies as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
);
|
|
1
|
+
import { createServerClient as e } from "@supabase/ssr";
|
|
2
|
+
import { createClient as t } from "@supabase/supabase-js";
|
|
3
|
+
import { cookies as n } from "next/headers";
|
|
4
|
+
//#region libs/db/src/lib/supabase/server.ts
|
|
5
|
+
var r = "This module cannot be imported from a Client Component module. It should only be used from a Server Component.";
|
|
6
|
+
if (typeof window < "u") throw Error(r);
|
|
7
|
+
var i = () => {
|
|
8
|
+
let t = process.env.NEXT_PUBLIC_SUPABASE_URL || process.env.SUPABASE_URL || "https://dummy.supabase.co", r = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY || process.env.SUPABASE_ANON_KEY || process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY || process.env.SUPABASE_PUBLISHABLE_KEY || "dummy-anon-key";
|
|
9
|
+
return e(t, r, { cookies: {
|
|
10
|
+
getAll: async () => {
|
|
11
|
+
try {
|
|
12
|
+
return (await n()).getAll();
|
|
13
|
+
} catch {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
setAll: async (e) => {
|
|
18
|
+
try {
|
|
19
|
+
let t = await n();
|
|
20
|
+
for (let { name: n, value: r, options: i } of e) r && r.length > 0 ? t.set({
|
|
21
|
+
name: n,
|
|
22
|
+
value: r,
|
|
23
|
+
...i
|
|
24
|
+
}) : i && Object.keys(i).length > 0 ? t.delete({
|
|
25
|
+
name: n,
|
|
26
|
+
...i
|
|
27
|
+
}) : t.delete(n);
|
|
28
|
+
} catch {}
|
|
29
|
+
}
|
|
30
|
+
} });
|
|
32
31
|
};
|
|
33
|
-
async function
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
async function a(e) {
|
|
33
|
+
let { data: t, error: n } = await i().from("profiles").select("id, full_name, avatar_url, role, updated_at, website").eq("id", e).single();
|
|
34
|
+
return n || !t ? (console.error("Error fetching profile (server-side):", n?.message), null) : t;
|
|
36
35
|
}
|
|
37
|
-
async function
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
async function o() {
|
|
37
|
+
let { data: e, error: t } = await i().from("languages").select("id, code, name, is_default, is_active, created_at, updated_at").order("name", { ascending: !0 });
|
|
38
|
+
return t ? (console.error("Error fetching languages (server-side):", t.message), []) : e || [];
|
|
40
39
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
persistSession: !1
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
export {
|
|
53
|
-
c as createClient,
|
|
54
|
-
d as getActiveLanguagesServerSide,
|
|
55
|
-
f as getProfileWithRoleServerSide,
|
|
56
|
-
A as getServiceRoleSupabaseClient
|
|
40
|
+
var s = () => {
|
|
41
|
+
let e = process.env.NEXT_PUBLIC_SUPABASE_URL || process.env.SUPABASE_URL, n = process.env.SUPABASE_SERVICE_ROLE_KEY || process.env.SUPABASE_SECRET_KEY;
|
|
42
|
+
if (!e || !n) throw Error("Missing Supabase Service Role environment variables");
|
|
43
|
+
return t(e, n, { auth: {
|
|
44
|
+
autoRefreshToken: !1,
|
|
45
|
+
persistSession: !1
|
|
46
|
+
} });
|
|
57
47
|
};
|
|
48
|
+
//#endregion
|
|
49
|
+
export { i as createClient, o as getActiveLanguagesServerSide, a as getProfileWithRoleServerSide, s as getServiceRoleSupabaseClient };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
let e=require("@supabase/supabase-js");var t=()=>{let t=process.env.NEXT_PUBLIC_SUPABASE_URL||process.env.SUPABASE_URL,n=process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY||process.env.SUPABASE_ANON_KEY||process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY||process.env.SUPABASE_PUBLISHABLE_KEY,r=t||`https://dummy.supabase.co`,i=n||`dummy-key`;return(!t||!n)&&console.warn(`Supabase URL or Anon Key is missing for SSG client. Returning dummy client to prevent build crash.`),(0,e.createClient)(r,i)};exports.getSsgSupabaseClient=t;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { createClient as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export {
|
|
7
|
-
S as getSsgSupabaseClient
|
|
1
|
+
import { createClient as e } from "@supabase/supabase-js";
|
|
2
|
+
//#region libs/db/src/lib/supabase/ssg-client.ts
|
|
3
|
+
var t = () => {
|
|
4
|
+
let t = process.env.NEXT_PUBLIC_SUPABASE_URL || process.env.SUPABASE_URL, n = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY || process.env.SUPABASE_ANON_KEY || process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY || process.env.SUPABASE_PUBLISHABLE_KEY, r = t || "https://dummy.supabase.co", i = n || "dummy-key";
|
|
5
|
+
return (!t || !n) && console.warn("Supabase URL or Anon Key is missing for SSG client. Returning dummy client to prevent build crash."), e(r, i);
|
|
8
6
|
};
|
|
7
|
+
//#endregion
|
|
8
|
+
export { t as getSsgSupabaseClient };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
var e={public:{Enums:{approval_status:[`pending`,`approved`,`denied`],interaction_type:[`review`,`comment`],menu_location:[`HEADER`,`FOOTER`,`SIDEBAR`],page_status:[`draft`,`published`,`archived`],revision_type:[`snapshot`,`diff`],user_role:[`ADMIN`,`WRITER`,`USER`]}}};exports.Constants=e;
|
package/lib/supabase/types.es.js
CHANGED
|
@@ -1,15 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
//#region libs/db/src/lib/supabase/types.ts
|
|
2
|
+
var e = { public: { Enums: {
|
|
3
|
+
approval_status: [
|
|
4
|
+
"pending",
|
|
5
|
+
"approved",
|
|
6
|
+
"denied"
|
|
7
|
+
],
|
|
8
|
+
interaction_type: ["review", "comment"],
|
|
9
|
+
menu_location: [
|
|
10
|
+
"HEADER",
|
|
11
|
+
"FOOTER",
|
|
12
|
+
"SIDEBAR"
|
|
13
|
+
],
|
|
14
|
+
page_status: [
|
|
15
|
+
"draft",
|
|
16
|
+
"published",
|
|
17
|
+
"archived"
|
|
18
|
+
],
|
|
19
|
+
revision_type: ["snapshot", "diff"],
|
|
20
|
+
user_role: [
|
|
21
|
+
"ADMIN",
|
|
22
|
+
"WRITER",
|
|
23
|
+
"USER"
|
|
24
|
+
]
|
|
25
|
+
} } };
|
|
26
|
+
//#endregion
|
|
27
|
+
export { e as Constants };
|
package/package.json
CHANGED
package/secrets.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./lib/secret-crypto.cjs.js"),t=require("./lib/config-resolve.cjs.js");exports.SECRET_ENVELOPE_ALGORITHM=e.SECRET_ENVELOPE_ALGORITHM,exports.SECRET_ENVELOPE_VERSION=e.SECRET_ENVELOPE_VERSION,exports.decryptSecret=e.decryptSecret,exports.decryptWithEnvKey=e.decryptWithEnvKey,exports.encryptSecret=e.encryptSecret,exports.encryptWithEnvKey=e.encryptWithEnvKey,exports.getMaskedSecret=e.getMaskedSecret,exports.getSecretEnvelopeStatus=e.getSecretEnvelopeStatus,exports.hasSecretEncryptionKey=e.hasSecretEncryptionKey,exports.isEncryptedSecretEnvelope=e.isEncryptedSecretEnvelope,exports.isSandboxEnvironment=t.isSandboxEnvironment,exports.requireSecretEncryptionKey=e.requireSecretEncryptionKey,exports.resolveConfigValue=t.resolveConfigValue,exports.resolveSecretEncryptionKey=e.resolveSecretEncryptionKey,exports.tryDecryptWithEnvKey=e.tryDecryptWithEnvKey;
|
package/secrets.es.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
4
|
-
c as SECRET_ENVELOPE_ALGORITHM,
|
|
5
|
-
y as SECRET_ENVELOPE_VERSION,
|
|
6
|
-
o as decryptSecret,
|
|
7
|
-
p as decryptWithEnvKey,
|
|
8
|
-
S as encryptSecret,
|
|
9
|
-
i as encryptWithEnvKey,
|
|
10
|
-
v as getMaskedSecret,
|
|
11
|
-
s as getSecretEnvelopeStatus,
|
|
12
|
-
K as hasSecretEncryptionKey,
|
|
13
|
-
a as isEncryptedSecretEnvelope,
|
|
14
|
-
r as isSandboxEnvironment,
|
|
15
|
-
d as requireSecretEncryptionKey,
|
|
16
|
-
E as resolveConfigValue,
|
|
17
|
-
l as resolveSecretEncryptionKey,
|
|
18
|
-
h as tryDecryptWithEnvKey
|
|
19
|
-
};
|
|
1
|
+
import { SECRET_ENVELOPE_ALGORITHM as e, SECRET_ENVELOPE_VERSION as t, decryptSecret as n, decryptWithEnvKey as r, encryptSecret as i, encryptWithEnvKey as a, getMaskedSecret as o, getSecretEnvelopeStatus as s, hasSecretEncryptionKey as c, isEncryptedSecretEnvelope as l, requireSecretEncryptionKey as u, resolveSecretEncryptionKey as d, tryDecryptWithEnvKey as f } from "./lib/secret-crypto.es.js";
|
|
2
|
+
import { isSandboxEnvironment as p, resolveConfigValue as m } from "./lib/config-resolve.es.js";
|
|
3
|
+
export { e as SECRET_ENVELOPE_ALGORITHM, t as SECRET_ENVELOPE_VERSION, n as decryptSecret, r as decryptWithEnvKey, i as encryptSecret, a as encryptWithEnvKey, o as getMaskedSecret, s as getSecretEnvelopeStatus, c as hasSecretEncryptionKey, l as isEncryptedSecretEnvelope, p as isSandboxEnvironment, u as requireSecretEncryptionKey, m as resolveConfigValue, d as resolveSecretEncryptionKey, f as tryDecryptWithEnvKey };
|
package/server.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./lib/supabase/server.cjs.js"),t=require("./lib/supabase/ssg-client.cjs.js"),n=require("./lib/package-validation.cjs.js"),r=require("./lib/secret-crypto.cjs.js"),i=require("./lib/config-resolve.cjs.js");exports.PACKAGE_ACTIVATION_CACHE_TAG=n.PACKAGE_ACTIVATION_CACHE_TAG,exports.SECRET_ENVELOPE_ALGORITHM=r.SECRET_ENVELOPE_ALGORITHM,exports.SECRET_ENVELOPE_VERSION=r.SECRET_ENVELOPE_VERSION,exports.createClient=e.createClient,exports.decryptSecret=r.decryptSecret,exports.decryptWithEnvKey=r.decryptWithEnvKey,exports.encryptSecret=r.encryptSecret,exports.encryptWithEnvKey=r.encryptWithEnvKey,exports.getActiveLanguagesServerSide=e.getActiveLanguagesServerSide,exports.getMaskedSecret=r.getMaskedSecret,exports.getProfileWithRoleServerSide=e.getProfileWithRoleServerSide,exports.getSecretEnvelopeStatus=r.getSecretEnvelopeStatus,exports.getServiceRoleSupabaseClient=e.getServiceRoleSupabaseClient,exports.getSsgSupabaseClient=t.getSsgSupabaseClient,exports.hasSecretEncryptionKey=r.hasSecretEncryptionKey,exports.isEncryptedSecretEnvelope=r.isEncryptedSecretEnvelope,exports.isPackageActivationRowValid=n.isPackageActivationRowValid,exports.isSandboxEnvironment=i.isSandboxEnvironment,exports.requireSecretEncryptionKey=r.requireSecretEncryptionKey,exports.resolveConfigValue=i.resolveConfigValue,exports.resolvePackageActivationExpiry=n.resolvePackageActivationExpiry,exports.resolveSecretEncryptionKey=r.resolveSecretEncryptionKey,exports.tryDecryptWithEnvKey=r.tryDecryptWithEnvKey,exports.verifyPackageOnline=n.verifyPackageOnline;
|
package/server.es.js
CHANGED
|
@@ -1,31 +1,6 @@
|
|
|
1
|
-
import { createClient as
|
|
2
|
-
import { getSsgSupabaseClient as
|
|
3
|
-
import { PACKAGE_ACTIVATION_CACHE_TAG as
|
|
4
|
-
import { SECRET_ENVELOPE_ALGORITHM as
|
|
5
|
-
import { isSandboxEnvironment as
|
|
6
|
-
export {
|
|
7
|
-
S as PACKAGE_ACTIVATION_CACHE_TAG,
|
|
8
|
-
g as SECRET_ENVELOPE_ALGORITHM,
|
|
9
|
-
s as SECRET_ENVELOPE_VERSION,
|
|
10
|
-
r as createClient,
|
|
11
|
-
A as decryptSecret,
|
|
12
|
-
C as decryptWithEnvKey,
|
|
13
|
-
d as encryptSecret,
|
|
14
|
-
f as encryptWithEnvKey,
|
|
15
|
-
i as getActiveLanguagesServerSide,
|
|
16
|
-
x as getMaskedSecret,
|
|
17
|
-
n as getProfileWithRoleServerSide,
|
|
18
|
-
K as getSecretEnvelopeStatus,
|
|
19
|
-
o as getServiceRoleSupabaseClient,
|
|
20
|
-
E as getSsgSupabaseClient,
|
|
21
|
-
P as hasSecretEncryptionKey,
|
|
22
|
-
R as isEncryptedSecretEnvelope,
|
|
23
|
-
p as isPackageActivationRowValid,
|
|
24
|
-
T as isSandboxEnvironment,
|
|
25
|
-
_ as requireSecretEncryptionKey,
|
|
26
|
-
V as resolveConfigValue,
|
|
27
|
-
y as resolvePackageActivationExpiry,
|
|
28
|
-
m as resolveSecretEncryptionKey,
|
|
29
|
-
u as tryDecryptWithEnvKey,
|
|
30
|
-
v as verifyPackageOnline
|
|
31
|
-
};
|
|
1
|
+
import { createClient as e, getActiveLanguagesServerSide as t, getProfileWithRoleServerSide as n, getServiceRoleSupabaseClient as r } from "./lib/supabase/server.es.js";
|
|
2
|
+
import { getSsgSupabaseClient as i } from "./lib/supabase/ssg-client.es.js";
|
|
3
|
+
import { PACKAGE_ACTIVATION_CACHE_TAG as a, isPackageActivationRowValid as o, resolvePackageActivationExpiry as s, verifyPackageOnline as c } from "./lib/package-validation.es.js";
|
|
4
|
+
import { SECRET_ENVELOPE_ALGORITHM as l, SECRET_ENVELOPE_VERSION as u, decryptSecret as d, decryptWithEnvKey as f, encryptSecret as p, encryptWithEnvKey as m, getMaskedSecret as h, getSecretEnvelopeStatus as g, hasSecretEncryptionKey as _, isEncryptedSecretEnvelope as v, requireSecretEncryptionKey as y, resolveSecretEncryptionKey as b, tryDecryptWithEnvKey as x } from "./lib/secret-crypto.es.js";
|
|
5
|
+
import { isSandboxEnvironment as S, resolveConfigValue as C } from "./lib/config-resolve.es.js";
|
|
6
|
+
export { a as PACKAGE_ACTIVATION_CACHE_TAG, l as SECRET_ENVELOPE_ALGORITHM, u as SECRET_ENVELOPE_VERSION, e as createClient, d as decryptSecret, f as decryptWithEnvKey, p as encryptSecret, m as encryptWithEnvKey, t as getActiveLanguagesServerSide, h as getMaskedSecret, n as getProfileWithRoleServerSide, g as getSecretEnvelopeStatus, r as getServiceRoleSupabaseClient, i as getSsgSupabaseClient, _ as hasSecretEncryptionKey, v as isEncryptedSecretEnvelope, o as isPackageActivationRowValid, S as isSandboxEnvironment, y as requireSecretEncryptionKey, C as resolveConfigValue, s as resolvePackageActivationExpiry, b as resolveSecretEncryptionKey, x as tryDecryptWithEnvKey, c as verifyPackageOnline };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
-- 02017: install guide (EN + FR) -- Node.js floor 20 -> 22.12.
|
|
2
|
+
--
|
|
3
|
+
-- The "How to Install NextBlock" post ('how-to-setup-nextblock', EN) and its French twin
|
|
4
|
+
-- ('comment-configurer-nextblock', FR) still tell readers to install Node.js 20. The
|
|
5
|
+
-- upgraded dependencies no longer run there: supabase-js >= 2.110 and AI SDK 7 declare
|
|
6
|
+
-- node >= 22, and both paths the guide describes need 22.12 -- the create-nextblock CLI
|
|
7
|
+
-- (engines >= 22.12.0) and the cloned repository's Vitest 5 / Vite 8 toolchain. Node 20
|
|
8
|
+
-- has been end-of-life since 2026-04-30. The copy shipped through 02000 (catch-up) / 02004
|
|
9
|
+
-- (baseline) and lives on real installs, so per the append-only rule this is a
|
|
10
|
+
-- forward-only data fix instead of an edit to those files.
|
|
11
|
+
--
|
|
12
|
+
-- Targets the text block of each guide post by parent (post resolved by slug + language
|
|
13
|
+
-- code; never blocks.id: ids drift on every install) plus the 'Node.js 20' signature, and
|
|
14
|
+
-- rewrites only the eight seeded phrases (four EN, four FR; "or newer" / "ou plus récent"
|
|
15
|
+
-- appears twice per language) with replace(), leaving the rest of the block and any
|
|
16
|
+
-- operator-edited wording untouched. post_revisions rows of the same posts get the same
|
|
17
|
+
-- rewrite so restoring a seeded revision cannot bring the Node.js 20 copy back.
|
|
18
|
+
-- Idempotent: a second run matches zero rows (the rewritten text no longer contains
|
|
19
|
+
-- 'Node.js 20').
|
|
20
|
+
--
|
|
21
|
+
-- NOTE: keep the word "sandbox" OUT of this filename -- generate-sandbox-reset.ts
|
|
22
|
+
-- excludes any migration whose filename contains "sandbox" from the reset bundle.
|
|
23
|
+
|
|
24
|
+
CREATE OR REPLACE FUNCTION pg_temp.nb_install_guide_node22(src text)
|
|
25
|
+
RETURNS text
|
|
26
|
+
LANGUAGE sql
|
|
27
|
+
IMMUTABLE
|
|
28
|
+
AS $fn$
|
|
29
|
+
SELECT replace(replace(replace(replace(replace(replace(replace(replace(src,
|
|
30
|
+
'>Node.js 20 or newer</a>',
|
|
31
|
+
'>Node.js 22.12 or newer</a>'),
|
|
32
|
+
'>Node.js 20+</a> and Docker Desktop',
|
|
33
|
+
'>Node.js 22.12+</a> and Docker Desktop'),
|
|
34
|
+
'managed-cloud path: Node.js 20+ plus',
|
|
35
|
+
'managed-cloud path: Node.js 22.12+ plus'),
|
|
36
|
+
'cloned repository: Node.js 20+ and git',
|
|
37
|
+
'cloned repository: Node.js 22.12+ and git'),
|
|
38
|
+
'>Node.js 20 ou plus récent</a>',
|
|
39
|
+
'>Node.js 22.12 ou plus récent</a>'),
|
|
40
|
+
'>Node.js 20+</a> et Docker Desktop',
|
|
41
|
+
'>Node.js 22.12+</a> et Docker Desktop'),
|
|
42
|
+
'Node.js 20+ ainsi qu',
|
|
43
|
+
'Node.js 22.12+ ainsi qu'),
|
|
44
|
+
'Node.js 20+ et git',
|
|
45
|
+
'Node.js 22.12+ et git')
|
|
46
|
+
$fn$;
|
|
47
|
+
|
|
48
|
+
UPDATE public.blocks AS b
|
|
49
|
+
SET content = pg_temp.nb_install_guide_node22(b.content::text)::jsonb,
|
|
50
|
+
updated_at = now()
|
|
51
|
+
FROM public.posts AS p
|
|
52
|
+
JOIN public.languages AS l ON l.id = p.language_id
|
|
53
|
+
WHERE b.post_id = p.id
|
|
54
|
+
AND b.block_type = 'text'
|
|
55
|
+
AND ((p.slug = 'how-to-setup-nextblock' AND l.code = 'en')
|
|
56
|
+
OR (p.slug = 'comment-configurer-nextblock' AND l.code = 'fr'))
|
|
57
|
+
AND b.content::text LIKE '%Node.js 20%'
|
|
58
|
+
AND b.content::text <> pg_temp.nb_install_guide_node22(b.content::text);
|
|
59
|
+
|
|
60
|
+
UPDATE public.post_revisions AS r
|
|
61
|
+
SET content = pg_temp.nb_install_guide_node22(r.content::text)::jsonb
|
|
62
|
+
FROM public.posts AS p
|
|
63
|
+
JOIN public.languages AS l ON l.id = p.language_id
|
|
64
|
+
WHERE r.post_id = p.id
|
|
65
|
+
AND ((p.slug = 'how-to-setup-nextblock' AND l.code = 'en')
|
|
66
|
+
OR (p.slug = 'comment-configurer-nextblock' AND l.code = 'fr'))
|
|
67
|
+
AND r.content::text LIKE '%Node.js 20%'
|
|
68
|
+
AND r.content::text <> pg_temp.nb_install_guide_node22(r.content::text);
|
|
69
|
+
|
|
70
|
+
DROP FUNCTION IF EXISTS pg_temp.nb_install_guide_node22(text);
|