@nextblock-cms/db 0.17.7 → 0.17.8
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.
|
@@ -1 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache tag for every cached activation read. Activation and deactivation call
|
|
3
|
+
* `updateTag(PACKAGE_ACTIVATION_CACHE_TAG)` so a purchase unlocks the CMS on the very
|
|
4
|
+
* next request instead of after the 60 s window.
|
|
5
|
+
*/
|
|
6
|
+
export declare const PACKAGE_ACTIVATION_CACHE_TAG = "package-activation";
|
|
7
|
+
/**
|
|
8
|
+
* The moment a stored activation stops being valid, from what the row knows:
|
|
9
|
+
* the license expiration (recorded from the vendor at checkout, from Freemius at
|
|
10
|
+
* activation, and refreshed by the background re-validation) or the trial end. Null
|
|
11
|
+
* when the row carries no date, which is the case for keys activated before these
|
|
12
|
+
* fields existed and for lifetime licenses.
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolvePackageActivationExpiry(meta: unknown): number | null;
|
|
15
|
+
/** A row counts only while its status is active AND any known expiry is in the future. */
|
|
16
|
+
export declare function isPackageActivationRowValid(row: {
|
|
17
|
+
meta?: unknown;
|
|
18
|
+
status?: unknown;
|
|
19
|
+
}, now?: number): boolean;
|
|
1
20
|
export declare function verifyPackageOnline(packageId: string, customClient?: any): Promise<boolean>;
|
package/package.json
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
-- 02014: package_activations is readable by staff only.
|
|
2
|
+
--
|
|
3
|
+
-- The baseline granted SELECT on package_activations to every authenticated user
|
|
4
|
+
-- ("Allow authenticated read access" USING (true)). Public sign-up creates USER-role
|
|
5
|
+
-- accounts, so any storefront customer could read the plaintext license keys and the
|
|
6
|
+
-- Freemius install handles (meta.fm_uid / meta.fm_install_id) of the premium packages —
|
|
7
|
+
-- and the dashboard now buys and stores those keys itself. Only staff surfaces read
|
|
8
|
+
-- this table with the cookie client (the dashboard stats for ADMIN and WRITER, the
|
|
9
|
+
-- packages page for ADMIN); everything else goes through the service role, which is
|
|
10
|
+
-- unaffected. Writes were never allowed to authenticated users and stay that way.
|
|
11
|
+
|
|
12
|
+
DROP POLICY IF EXISTS "Allow authenticated read access" ON public.package_activations;
|
|
13
|
+
|
|
14
|
+
CREATE POLICY "Staff read package activations" ON public.package_activations
|
|
15
|
+
FOR SELECT TO authenticated
|
|
16
|
+
USING (
|
|
17
|
+
(SELECT public.get_current_user_role()) = ANY (ARRAY['ADMIN'::public.user_role, 'WRITER'::public.user_role])
|
|
18
|
+
);
|