@smart-cloud/wpsuite-core 1.0.8 → 2.0.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.cjs +1 -1
- package/dist/index.d.cts +33 -9
- package/dist/index.d.ts +33 -9
- package/dist/index.js +1 -1
- package/package.json +6 -5
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var d=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var g=(t,e)=>()=>(t&&(e=t(t=0)),e);var h=(t,e)=>{for(var n in e)d(t,n,{get:e[n],enumerable:!0})},I=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of O(e))!D.call(t,i)&&i!==n&&d(t,i,{get:()=>e[i],enumerable:!(r=X(e,i))||r.enumerable});return t};var Y=t=>I(d({},"__esModule",{value:!0}),t);function s(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");for(;e.length%4;)e+="=";return Uint8Array.from(atob(e),n=>n.charCodeAt(0))}var f,y=g(()=>{"use strict";f=(t,e)=>{let r=Uint8Array.from(atob(t),i=>i.charCodeAt(0)).map((i,a)=>i^e+a&255);return new TextDecoder().decode(r)}});var _,P,v=g(()=>{"use strict";y();_=f("x8fO2eD///yro8Pr9vmVxdby9MzU7Jnf9cSZxfSc1MLq2NjbxOTq3PCD2w==",146),P=f("xafW79Hk4tr1//jc/erTzuDa1uHt6MPx2M+U4uHO7/7W0uzH7v/MzYrL6Q==",146)});var R={};h(R,{getConfig:()=>z});function S(t){try{return new URL(t.includes("://")?t:`http://${t}`).hostname.toLowerCase()}catch{return t.replace(/\/+$/,"").toLowerCase()}}function M(t){let e=S(t);return e.startsWith("www.")?e.slice(4):e}function C(t){let e=S(t);if(N.test(e)||V.test(e)||e==="localhost")return!0;let n=(0,A.parse)(e,{allowPrivateDomains:!0});return!!(!n.domain||!n.publicSuffix||G.includes(n.publicSuffix))}function H(t){let e=S(t);return C(e)||E.test(e)?!0:e.split(".").some(n=>E.test(n))}function J(t){return C(t)||H(t)}function Z(t,e){return e?M(t)===e:!1}function j(t,e){return J(t)?{free:!0,covered:!0}:{free:!1,covered:Z(t,e)}}var u,A,x,W,b,E,G,N,V,z,T=g(()=>{"use strict";u=require("jose");v();y();A=require("tldts");typeof WpSuite<"u"?b=WpSuite.siteSettings:b={};E=/\b(dev|test|testing|staging|stage|qa|uat|preview|demo|sandbox|preprod|beta|canary)\b/i,G=["localhost","local","test","invalid","example","lan","internal"],N=/^(127\.)|^(10\.)|^(192\.168\.)|^(172\.(1[6-9]|2\d|3[0-1])\.)/,V=/^(::1$)|(^fc00:)|(^fd)/i;z=async()=>{let t=null;if(b.subscriber){let n=await(0,u.importJWK)({kty:"EC",x,y:W,crv:"P-256"},"ES256"),r=new Date().getFullYear(),i=Math.floor((Date.now()-new Date(r,0,1).getTime())/(1e3*60*60*24*7)),a=await fetch(WpSuite.uploadUrl+"lic.jws?t="+WpSuite.siteSettings.lastUpdate+"&y="+r+"&w="+i).then(o=>o.ok?o.text():null).catch(()=>null);if(a)try{let o=location.hostname.split(":")[0],{payload:l}=await(0,u.jwtVerify)(a,n,{algorithms:["ES256"]}),m=j(o,l.domain);if(!m.free&&!m.covered)throw new Error("Invalid domain in JWT");let w=l.key.split(":"),k=s(w[0]),U=s(w[1]),p=(await fetch(WpSuite.uploadUrl+"config.enc?t="+WpSuite.siteSettings.lastUpdate).then(c=>c.ok?c.text():null).catch(()=>null))?.split(":");if(p?.length===2){let c=s(p[0]),L=s(p[1]),B=await crypto.subtle.importKey("raw",k,{name:"AES-GCM"},!1,["decrypt"]),K=await crypto.subtle.decrypt({name:"AES-GCM",iv:U},B,new Uint8Array([...c,...L]));t=JSON.parse(new TextDecoder().decode(K)),t.subscriptionType=l.subscriptionType}}catch(o){console.error(o.message)}}return t??null};x=_;W=P});var tt={};h(tt,{TEXT_DOMAIN:()=>q,getConfig:()=>Q,getPlugin:()=>$,getWpSuite:()=>F});module.exports=Y(tt);function F(){return globalThis.WpSuite}function $(t){return globalThis.WpSuite?.plugins[t]}var q="hub-for-wpsuiteio",Q=async t=>{let n=await(await Promise.resolve().then(()=>(T(),R))).getConfig();return n&&(n={...n[t],subscriptionType:n.subscriptionType}),n};0&&(module.exports={TEXT_DOMAIN,getConfig,getPlugin,getWpSuite});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
declare global {
|
|
2
|
-
|
|
2
|
+
var WpSuite: WpSuiteGlobal | undefined;
|
|
3
3
|
}
|
|
4
|
+
type WpSuiteView = "connect" | "diagnostics";
|
|
5
|
+
type PluginStatus = "unavailable" | "initializing" | "available" | "error";
|
|
6
|
+
type PluginAvailability = Omit<PluginStatus, "initializing">;
|
|
7
|
+
interface WpSuiteEvents {
|
|
8
|
+
emit(type: string, detail?: unknown): void;
|
|
9
|
+
on(type: string, cb: (ev: Event) => void, opts?: AddEventListenerOptions): void;
|
|
10
|
+
}
|
|
11
|
+
interface WpSuitePluginBase {
|
|
12
|
+
key: string;
|
|
13
|
+
version?: string;
|
|
14
|
+
status?: PluginStatus;
|
|
15
|
+
availability?: () => Promise<PluginAvailability>;
|
|
16
|
+
onReady?: (cb: () => void) => void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The plugins field simultaneously:
|
|
20
|
+
* - contains typed, named plugins,
|
|
21
|
+
* - and allows anything else (Record<string, WpSuitePluginBase | undefined>).
|
|
22
|
+
*/
|
|
23
|
+
type WpSuitePluginRegistry = Record<string, WpSuitePluginBase | undefined>;
|
|
24
|
+
interface WpSuiteGlobal {
|
|
25
|
+
siteSettings: SiteSettings;
|
|
26
|
+
nonce: string;
|
|
27
|
+
restUrl: string;
|
|
28
|
+
uploadUrl: string;
|
|
29
|
+
view: WpSuiteView;
|
|
30
|
+
plugins: WpSuitePluginRegistry;
|
|
31
|
+
events?: WpSuiteEvents;
|
|
32
|
+
}
|
|
33
|
+
declare function getWpSuite(): WpSuiteGlobal | undefined;
|
|
34
|
+
declare function getPlugin<K extends string>(key: K): WpSuitePluginBase | undefined;
|
|
4
35
|
declare const TEXT_DOMAIN = "hub-for-wpsuiteio";
|
|
5
36
|
interface SiteSettings {
|
|
6
37
|
accountId?: string;
|
|
@@ -9,14 +40,7 @@ interface SiteSettings {
|
|
|
9
40
|
subscriber?: boolean;
|
|
10
41
|
siteKey?: string;
|
|
11
42
|
}
|
|
12
|
-
interface WpSuite {
|
|
13
|
-
siteSettings: SiteSettings;
|
|
14
|
-
nonce: string;
|
|
15
|
-
restUrl: string;
|
|
16
|
-
uploadUrl: string;
|
|
17
|
-
view: "connect" | "diagnostics";
|
|
18
|
-
}
|
|
19
43
|
type SubscriptionType = "PROFESSIONAL" | "AGENCY";
|
|
20
44
|
declare const getConfig: (plugin: string) => Promise<Record<string, unknown> | null>;
|
|
21
45
|
|
|
22
|
-
export { type SiteSettings, type SubscriptionType, TEXT_DOMAIN,
|
|
46
|
+
export { type PluginAvailability, type PluginStatus, type SiteSettings, type SubscriptionType, TEXT_DOMAIN, type WpSuiteEvents, type WpSuiteGlobal, type WpSuitePluginBase, type WpSuitePluginRegistry, type WpSuiteView, getConfig, getPlugin, getWpSuite };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
declare global {
|
|
2
|
-
|
|
2
|
+
var WpSuite: WpSuiteGlobal | undefined;
|
|
3
3
|
}
|
|
4
|
+
type WpSuiteView = "connect" | "diagnostics";
|
|
5
|
+
type PluginStatus = "unavailable" | "initializing" | "available" | "error";
|
|
6
|
+
type PluginAvailability = Omit<PluginStatus, "initializing">;
|
|
7
|
+
interface WpSuiteEvents {
|
|
8
|
+
emit(type: string, detail?: unknown): void;
|
|
9
|
+
on(type: string, cb: (ev: Event) => void, opts?: AddEventListenerOptions): void;
|
|
10
|
+
}
|
|
11
|
+
interface WpSuitePluginBase {
|
|
12
|
+
key: string;
|
|
13
|
+
version?: string;
|
|
14
|
+
status?: PluginStatus;
|
|
15
|
+
availability?: () => Promise<PluginAvailability>;
|
|
16
|
+
onReady?: (cb: () => void) => void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The plugins field simultaneously:
|
|
20
|
+
* - contains typed, named plugins,
|
|
21
|
+
* - and allows anything else (Record<string, WpSuitePluginBase | undefined>).
|
|
22
|
+
*/
|
|
23
|
+
type WpSuitePluginRegistry = Record<string, WpSuitePluginBase | undefined>;
|
|
24
|
+
interface WpSuiteGlobal {
|
|
25
|
+
siteSettings: SiteSettings;
|
|
26
|
+
nonce: string;
|
|
27
|
+
restUrl: string;
|
|
28
|
+
uploadUrl: string;
|
|
29
|
+
view: WpSuiteView;
|
|
30
|
+
plugins: WpSuitePluginRegistry;
|
|
31
|
+
events?: WpSuiteEvents;
|
|
32
|
+
}
|
|
33
|
+
declare function getWpSuite(): WpSuiteGlobal | undefined;
|
|
34
|
+
declare function getPlugin<K extends string>(key: K): WpSuitePluginBase | undefined;
|
|
4
35
|
declare const TEXT_DOMAIN = "hub-for-wpsuiteio";
|
|
5
36
|
interface SiteSettings {
|
|
6
37
|
accountId?: string;
|
|
@@ -9,14 +40,7 @@ interface SiteSettings {
|
|
|
9
40
|
subscriber?: boolean;
|
|
10
41
|
siteKey?: string;
|
|
11
42
|
}
|
|
12
|
-
interface WpSuite {
|
|
13
|
-
siteSettings: SiteSettings;
|
|
14
|
-
nonce: string;
|
|
15
|
-
restUrl: string;
|
|
16
|
-
uploadUrl: string;
|
|
17
|
-
view: "connect" | "diagnostics";
|
|
18
|
-
}
|
|
19
43
|
type SubscriptionType = "PROFESSIONAL" | "AGENCY";
|
|
20
44
|
declare const getConfig: (plugin: string) => Promise<Record<string, unknown> | null>;
|
|
21
45
|
|
|
22
|
-
export { type SiteSettings, type SubscriptionType, TEXT_DOMAIN,
|
|
46
|
+
export { type PluginAvailability, type PluginStatus, type SiteSettings, type SubscriptionType, TEXT_DOMAIN, type WpSuiteEvents, type WpSuiteGlobal, type WpSuitePluginBase, type WpSuitePluginRegistry, type WpSuiteView, getConfig, getPlugin, getWpSuite };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var U=Object.defineProperty;var p=(t,e)=>()=>(t&&(e=t(t=0)),e);var L=(t,e)=>{for(var n in e)U(t,n,{get:e[n],enumerable:!0})};function o(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");for(;e.length%4;)e+="=";return Uint8Array.from(atob(e),n=>n.charCodeAt(0))}var d,g=p(()=>{"use strict";d=(t,e)=>{let s=Uint8Array.from(atob(t),r=>r.charCodeAt(0)).map((r,a)=>r^e+a&255);return new TextDecoder().decode(s)}});var m,w,h=p(()=>{"use strict";g();m=d("x8fO2eD///yro8Pr9vmVxdby9MzU7Jnf9cSZxfSc1MLq2NjbxOTq3PCD2w==",146),w=d("xafW79Hk4tr1//jc/erTzuDa1uHt6MPx2M+U4uHO7/7W0uzH7v/MzYrL6Q==",146)});var x={};L(x,{getConfig:()=>H});import{importJWK as B,jwtVerify as K}from"jose";import{parse as X}from"tldts";function y(t){try{return new URL(t.includes("://")?t:`http://${t}`).hostname.toLowerCase()}catch{return t.replace(/\/+$/,"").toLowerCase()}}function Y(t){let e=y(t);return e.startsWith("www.")?e.slice(4):e}function E(t){let e=y(t);if(D.test(e)||I.test(e)||e==="localhost")return!0;let n=X(e,{allowPrivateDomains:!0});return!!(!n.domain||!n.publicSuffix||O.includes(n.publicSuffix))}function G(t){let e=y(t);return E(e)||_.test(e)?!0:e.split(".").some(n=>_.test(n))}function N(t){return E(t)||G(t)}function V(t,e){return e?Y(t)===e:!1}function M(t,e){return N(t)?{free:!0,covered:!0}:{free:!1,covered:V(t,e)}}var P,v,f,_,O,D,I,H,W=p(()=>{"use strict";h();g();typeof WpSuite<"u"?f=WpSuite.siteSettings:f={};_=/\b(dev|test|testing|staging|stage|qa|uat|preview|demo|sandbox|preprod|beta|canary)\b/i,O=["localhost","local","test","invalid","example","lan","internal"],D=/^(127\.)|^(10\.)|^(192\.168\.)|^(172\.(1[6-9]|2\d|3[0-1])\.)/,I=/^(::1$)|(^fc00:)|(^fd)/i;H=async()=>{let t=null;if(f.subscriber){let n=await B({kty:"EC",x:P,y:v,crv:"P-256"},"ES256"),s=new Date().getFullYear(),r=Math.floor((Date.now()-new Date(s,0,1).getTime())/(1e3*60*60*24*7)),a=await fetch(WpSuite.uploadUrl+"lic.jws?t="+WpSuite.siteSettings.lastUpdate+"&y="+s+"&w="+r).then(i=>i.ok?i.text():null).catch(()=>null);if(a)try{let i=location.hostname.split(":")[0],{payload:u}=await K(a,n,{algorithms:["ES256"]}),b=M(i,u.domain);if(!b.free&&!b.covered)throw new Error("Invalid domain in JWT");let S=u.key.split(":"),A=o(S[0]),C=o(S[1]),l=(await fetch(WpSuite.uploadUrl+"config.enc?t="+WpSuite.siteSettings.lastUpdate).then(c=>c.ok?c.text():null).catch(()=>null))?.split(":");if(l?.length===2){let c=o(l[0]),R=o(l[1]),T=await crypto.subtle.importKey("raw",A,{name:"AES-GCM"},!1,["decrypt"]),k=await crypto.subtle.decrypt({name:"AES-GCM",iv:C},T,new Uint8Array([...c,...R]));t=JSON.parse(new TextDecoder().decode(k)),t.subscriptionType=u.subscriptionType}}catch(i){console.error(i.message)}}return t??null};P=m;v=w});function et(){return globalThis.WpSuite}function nt(t){return globalThis.WpSuite?.plugins[t]}var it="hub-for-wpsuiteio",rt=async t=>{let n=await(await Promise.resolve().then(()=>(W(),x))).getConfig();return n&&(n={...n[t],subscriptionType:n.subscriptionType}),n};export{it as TEXT_DOMAIN,rt as getConfig,nt as getPlugin,et as getWpSuite};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smart-cloud/wpsuite-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "WP Suite Core package",
|
|
5
5
|
"author": "Smart Cloud Solutions Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,14 +29,15 @@
|
|
|
29
29
|
"@wordpress/data": "^10.36.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
+
"@eslint/js": "^9.39.2",
|
|
32
33
|
"@types/node": "^25.0.2",
|
|
33
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
34
|
-
"@typescript-eslint/parser": "^8.
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "^8.50.0",
|
|
35
|
+
"@typescript-eslint/parser": "^8.50.0",
|
|
35
36
|
"@wordpress/data": "^10.36.0",
|
|
36
37
|
"eslint": "^9.39.2",
|
|
37
|
-
"
|
|
38
|
+
"globals": "^16.5.0",
|
|
38
39
|
"tsup": "^8.5.1",
|
|
39
40
|
"typescript": "^5.9.3",
|
|
40
|
-
"typescript-eslint": "^8.
|
|
41
|
+
"typescript-eslint": "^8.50.0"
|
|
41
42
|
}
|
|
42
43
|
}
|