@smart-cloud/wpsuite-core 2.0.0 → 2.0.2
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 +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var b=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var l=(t,e)=>()=>(t&&(e=t(t=0)),e);var h=(t,e)=>{for(var n in e)b(t,n,{get:e[n],enumerable:!0})},H=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of N(e))!V.call(t,i)&&i!==n&&b(t,i,{get:()=>e[i],enumerable:!(r=G(e,i))||r.enumerable});return t};var J=t=>H(b({},"__esModule",{value:!0}),t);function m(t,e){return`wpsuite:${t}:${e}`}function $(t,e=8e3){return()=>new Promise(n=>{if(t.status==="available")return n("available");if(t.status==="error")return n("error");!t.status||t.status;let r=m(t.key,"ready"),i=m(t.key,"error"),s=()=>u("available"),o=()=>u("error"),a,u=p=>{window.removeEventListener(r,s),window.removeEventListener(i,o),a!==void 0&&window.clearTimeout(a),n(p)};window.addEventListener(r,s,{once:!0}),window.addEventListener(i,o,{once:!0}),a=window.setTimeout(()=>u("unavailable"),e)})}function Z(t){return e=>{window.addEventListener(m(t,"ready"),()=>e(),{once:!0})}}function _(t,e){let n=e?.timeoutMs??8e3;return t.availability??=$(t,n),t.onReady??=Z(t.key),t}var x=l(()=>{"use strict"});function d(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");for(;e.length%4;)e+="=";return Uint8Array.from(atob(e),n=>n.charCodeAt(0))}var w,S=l(()=>{"use strict";w=(t,e)=>{let r=Uint8Array.from(atob(t),i=>i.charCodeAt(0)).map((i,s)=>i^e+s&255);return new TextDecoder().decode(r)}});var A,R,k=l(()=>{"use strict";S();A=w("pqCvuoGQnp/KxKKIl2Y0ZndVVW91Qzh8VGM4ZlUjdWFLf3l4ZUtLf1Ekeg==",243),R=w("pMC3jLCLg7mUmJm/nHVybUF9d0JMR2JSeWg1QUBxTl13dU1kT1BtbitsSA==",243)});var U={};h(U,{getConfig:()=>it});function P(t){try{return new URL(t.includes("://")?t:`http://${t}`).hostname.toLowerCase()}catch{return t.replace(/\/+$/,"").toLowerCase()}}function q(t){let e=P(t);return e.startsWith("www.")?e.slice(4):e}function B(t){let e=P(t);if(z.test(e)||F.test(e)||e==="localhost")return!0;let n=(0,L.parse)(e,{allowPrivateDomains:!0});return!!(!n.domain||!n.publicSuffix||j.includes(n.publicSuffix))}function Q(t){let e=P(t);return B(e)||C.test(e)?!0:e.split(".").some(n=>C.test(n))}function tt(t){return B(t)||Q(t)}function et(t,e){return e?q(t)===e:!1}function nt(t,e){return tt(t)?{free:!0,covered:!0}:{free:!1,covered:et(t,e)}}var f,L,T,W,c,v,C,j,z,F,it,K=l(()=>{"use strict";f=require("jose");k();S();D();L=require("tldts"),c=E();c?v=c.siteSettings:v={};C=/\b(dev|test|testing|staging|stage|qa|uat|preview|demo|sandbox|preprod|beta|canary)\b/i,j=["localhost","local","test","invalid","example","lan","internal"],z=/^(127\.)|^(10\.)|^(192\.168\.)|^(172\.(1[6-9]|2\d|3[0-1])\.)/,F=/^(::1$)|(^fc00:)|(^fd)/i;it=async()=>{let t=null;if(v.subscriber){let n=await(0,f.importJWK)({kty:"EC",x:T,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)),s=await fetch(c.uploadUrl+"lic.jws?t="+c.siteSettings.lastUpdate+"&y="+r+"&w="+i).then(o=>o.ok?o.text():null).catch(()=>null);if(s)try{let o=location.hostname.split(":")[0],{payload:a}=await(0,f.jwtVerify)(s,n,{algorithms:["ES256"]}),u=nt(o,a.domain);if(!u.free&&!u.covered)throw new Error("Invalid domain in JWT");let p=a.key.split(":"),O=d(p[0]),X=d(p[1]),y=(await fetch(c.uploadUrl+"config.enc?t="+c.siteSettings.lastUpdate).then(g=>g.ok?g.text():null).catch(()=>null))?.split(":");if(y?.length===2){let g=d(y[0]),I=d(y[1]),M=await crypto.subtle.importKey("raw",O,{name:"AES-GCM"},!1,["decrypt"]),Y=await crypto.subtle.decrypt({name:"AES-GCM",iv:X},M,new Uint8Array([...g,...I]));t=JSON.parse(new TextDecoder().decode(Y)),t.subscriptionType=a.subscriptionType}}catch(o){console.error(o.message)}}return t??null};T=A;W=R});var at={};h(at,{TEXT_DOMAIN:()=>ot,attachDefaultPluginRuntime:()=>_,getConfig:()=>st,getPlugin:()=>rt,getWpSuite:()=>E});module.exports=J(at);function E(){return globalThis.WpSuite}function rt(t){return globalThis.WpSuite?.plugins[t]}var ot,st,D=l(()=>{x();ot="hub-for-wpsuiteio",st=async t=>{let n=await(await Promise.resolve().then(()=>(K(),U))).getConfig();return n&&(n={...n[t],subscriptionType:n.subscriptionType}),n}});D();0&&(module.exports={TEXT_DOMAIN,attachDefaultPluginRuntime,getConfig,getPlugin,getWpSuite});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/** Attaches the default runtime functions to a plugin object */
|
|
2
|
+
declare function attachDefaultPluginRuntime<T extends WpSuitePluginBase>(plugin: T, opts?: {
|
|
3
|
+
timeoutMs?: number;
|
|
4
|
+
}): T;
|
|
5
|
+
|
|
1
6
|
declare global {
|
|
2
7
|
var WpSuite: WpSuiteGlobal | undefined;
|
|
3
8
|
}
|
|
@@ -32,6 +37,7 @@ interface WpSuiteGlobal {
|
|
|
32
37
|
}
|
|
33
38
|
declare function getWpSuite(): WpSuiteGlobal | undefined;
|
|
34
39
|
declare function getPlugin<K extends string>(key: K): WpSuitePluginBase | undefined;
|
|
40
|
+
|
|
35
41
|
declare const TEXT_DOMAIN = "hub-for-wpsuiteio";
|
|
36
42
|
interface SiteSettings {
|
|
37
43
|
accountId?: string;
|
|
@@ -43,4 +49,4 @@ interface SiteSettings {
|
|
|
43
49
|
type SubscriptionType = "PROFESSIONAL" | "AGENCY";
|
|
44
50
|
declare const getConfig: (plugin: string) => Promise<Record<string, unknown> | null>;
|
|
45
51
|
|
|
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 };
|
|
52
|
+
export { type PluginAvailability, type PluginStatus, type SiteSettings, type SubscriptionType, TEXT_DOMAIN, type WpSuiteEvents, type WpSuiteGlobal, type WpSuitePluginBase, type WpSuitePluginRegistry, type WpSuiteView, attachDefaultPluginRuntime, getConfig, getPlugin, getWpSuite };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/** Attaches the default runtime functions to a plugin object */
|
|
2
|
+
declare function attachDefaultPluginRuntime<T extends WpSuitePluginBase>(plugin: T, opts?: {
|
|
3
|
+
timeoutMs?: number;
|
|
4
|
+
}): T;
|
|
5
|
+
|
|
1
6
|
declare global {
|
|
2
7
|
var WpSuite: WpSuiteGlobal | undefined;
|
|
3
8
|
}
|
|
@@ -32,6 +37,7 @@ interface WpSuiteGlobal {
|
|
|
32
37
|
}
|
|
33
38
|
declare function getWpSuite(): WpSuiteGlobal | undefined;
|
|
34
39
|
declare function getPlugin<K extends string>(key: K): WpSuitePluginBase | undefined;
|
|
40
|
+
|
|
35
41
|
declare const TEXT_DOMAIN = "hub-for-wpsuiteio";
|
|
36
42
|
interface SiteSettings {
|
|
37
43
|
accountId?: string;
|
|
@@ -43,4 +49,4 @@ interface SiteSettings {
|
|
|
43
49
|
type SubscriptionType = "PROFESSIONAL" | "AGENCY";
|
|
44
50
|
declare const getConfig: (plugin: string) => Promise<Record<string, unknown> | null>;
|
|
45
51
|
|
|
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 };
|
|
52
|
+
export { type PluginAvailability, type PluginStatus, type SiteSettings, type SubscriptionType, TEXT_DOMAIN, type WpSuiteEvents, type WpSuiteGlobal, type WpSuitePluginBase, type WpSuitePluginRegistry, type WpSuiteView, attachDefaultPluginRuntime, getConfig, getPlugin, getWpSuite };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var O=Object.defineProperty;var l=(t,e)=>()=>(t&&(e=t(t=0)),e);var X=(t,e)=>{for(var n in e)O(t,n,{get:e[n],enumerable:!0})};function y(t,e){return`wpsuite:${t}:${e}`}function I(t,e=8e3){return()=>new Promise(n=>{if(t.status==="available")return n("available");if(t.status==="error")return n("error");!t.status||t.status;let o=y(t.key,"ready"),r=y(t.key,"error"),s=()=>u("available"),i=()=>u("error"),a,u=p=>{window.removeEventListener(o,s),window.removeEventListener(r,i),a!==void 0&&window.clearTimeout(a),n(p)};window.addEventListener(o,s,{once:!0}),window.addEventListener(r,i,{once:!0}),a=window.setTimeout(()=>u("unavailable"),e)})}function M(t){return e=>{window.addEventListener(y(t,"ready"),()=>e(),{once:!0})}}function Y(t,e){let n=e?.timeoutMs??8e3;return t.availability??=I(t,n),t.onReady??=M(t.key),t}var v=l(()=>{"use strict"});function d(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");for(;e.length%4;)e+="=";return Uint8Array.from(atob(e),n=>n.charCodeAt(0))}var b,m=l(()=>{"use strict";b=(t,e)=>{let o=Uint8Array.from(atob(t),r=>r.charCodeAt(0)).map((r,s)=>r^e+s&255);return new TextDecoder().decode(o)}});var P,E,h=l(()=>{"use strict";m();P=b("pqCvuoGQnp/KxKKIl2Y0ZndVVW91Qzh8VGM4ZlUjdWFLf3l4ZUtLf1Ekeg==",243),E=b("pMC3jLCLg7mUmJm/nHVybUF9d0JMR2JSeWg1QUBxTl13dU1kT1BtbitsSA==",243)});var k={};X(k,{getConfig:()=>Q});import{importJWK as G,jwtVerify as N}from"jose";import{parse as V}from"tldts";function S(t){try{return new URL(t.includes("://")?t:`http://${t}`).hostname.toLowerCase()}catch{return t.replace(/\/+$/,"").toLowerCase()}}function Z(t){let e=S(t);return e.startsWith("www.")?e.slice(4):e}function R(t){let e=S(t);if(J.test(e)||$.test(e)||e==="localhost")return!0;let n=V(e,{allowPrivateDomains:!0});return!!(!n.domain||!n.publicSuffix||H.includes(n.publicSuffix))}function j(t){let e=S(t);return R(e)||_.test(e)?!0:e.split(".").some(n=>_.test(n))}function z(t){return R(t)||j(t)}function F(t,e){return e?Z(t)===e:!1}function q(t,e){return z(t)?{free:!0,covered:!0}:{free:!1,covered:F(t,e)}}var x,A,c,w,_,H,J,$,Q,C=l(()=>{"use strict";h();m();W();c=T();c?w=c.siteSettings:w={};_=/\b(dev|test|testing|staging|stage|qa|uat|preview|demo|sandbox|preprod|beta|canary)\b/i,H=["localhost","local","test","invalid","example","lan","internal"],J=/^(127\.)|^(10\.)|^(192\.168\.)|^(172\.(1[6-9]|2\d|3[0-1])\.)/,$=/^(::1$)|(^fc00:)|(^fd)/i;Q=async()=>{let t=null;if(w.subscriber){let n=await G({kty:"EC",x,y:A,crv:"P-256"},"ES256"),o=new Date().getFullYear(),r=Math.floor((Date.now()-new Date(o,0,1).getTime())/(1e3*60*60*24*7)),s=await fetch(c.uploadUrl+"lic.jws?t="+c.siteSettings.lastUpdate+"&y="+o+"&w="+r).then(i=>i.ok?i.text():null).catch(()=>null);if(s)try{let i=location.hostname.split(":")[0],{payload:a}=await N(s,n,{algorithms:["ES256"]}),u=q(i,a.domain);if(!u.free&&!u.covered)throw new Error("Invalid domain in JWT");let p=a.key.split(":"),L=d(p[0]),B=d(p[1]),f=(await fetch(c.uploadUrl+"config.enc?t="+c.siteSettings.lastUpdate).then(g=>g.ok?g.text():null).catch(()=>null))?.split(":");if(f?.length===2){let g=d(f[0]),U=d(f[1]),K=await crypto.subtle.importKey("raw",L,{name:"AES-GCM"},!1,["decrypt"]),D=await crypto.subtle.decrypt({name:"AES-GCM",iv:B},K,new Uint8Array([...g,...U]));t=JSON.parse(new TextDecoder().decode(D)),t.subscriptionType=a.subscriptionType}}catch(i){console.error(i.message)}}return t??null};x=P;A=E});function T(){return globalThis.WpSuite}function dt(t){return globalThis.WpSuite?.plugins[t]}var pt,gt,W=l(()=>{v();pt="hub-for-wpsuiteio",gt=async t=>{let n=await(await Promise.resolve().then(()=>(C(),k))).getConfig();return n&&(n={...n[t],subscriptionType:n.subscriptionType}),n}});W();export{pt as TEXT_DOMAIN,Y as attachDefaultPluginRuntime,gt as getConfig,dt as getPlugin,T as getWpSuite};
|