@smart-cloud/wpsuite-core 2.0.3 → 2.0.4
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 +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var b=Object.defineProperty;var
|
|
1
|
+
"use strict";var b=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var l=(e,t)=>()=>(e&&(t=e(e=0)),t);var x=(e,t)=>{for(var n in t)b(e,n,{get:t[n],enumerable:!0})},H=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of V(t))!F.call(e,i)&&i!==n&&b(e,i,{get:()=>t[i],enumerable:!(r=N(t,i))||r.enumerable});return e};var J=e=>H(b({},"__esModule",{value:!0}),e);function d(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");for(;t.length%4;)t+="=";return Uint8Array.from(atob(t),n=>n.charCodeAt(0))}var w,E,f=l(()=>{"use strict";w=(e,t)=>{let r=Uint8Array.from(atob(e),i=>i.charCodeAt(0)).map((i,o)=>i^t+o&255);return new TextDecoder().decode(r)},E=async e=>{let t=globalThis.grecaptcha,n=e?t?.enterprise:void 0,r=n?.ready??t?.ready,i=n?.execute??t?.execute;if(typeof i!="function")return{execute:void 0};try{return typeof r=="function"&&await new Promise(o=>r(()=>o())),{execute:i}}catch{return{execute:void 0}}}});function v(e,t){return`wpsuite:${e}:${t}`}function $(e,t=8e3){return()=>new Promise(n=>{if(e.status==="available")return n("available");if(e.status==="error")return n("error");!e.status||e.status;let r=v(e.key,"ready"),i=v(e.key,"error"),o=()=>c("available"),s=()=>c("error"),a,c=p=>{window.removeEventListener(r,o),window.removeEventListener(i,s),a!==void 0&&window.clearTimeout(a),n(p)};window.addEventListener(r,o,{once:!0}),window.addEventListener(i,s,{once:!0}),a=window.setTimeout(()=>c("unavailable"),t)})}function Z(e){return t=>{window.addEventListener(v(e,"ready"),()=>t(),{once:!0})}}function _(e,t){let n=t?.timeoutMs??8e3;return e.availability??=$(e,n),e.onReady??=Z(e.key),e}var R=l(()=>{"use strict"});var A,k,C=l(()=>{"use strict";f();A=w("///24djH19SDi+vD3tGN3c7q7NTM9PG3nazxrZz0rLqSoKCjvJyCtJjrsw==",170),k=w("/Z/u1+ncyvLd19D01cLL1vjCzvn18KuZsKf8iomml4auqpS/loekpeKjgQ==",170)});var K={};x(K,{getConfig:()=>re});function h(e){try{return new URL(e.includes("://")?e:`http://${e}`).hostname.toLowerCase()}catch{return e.replace(/\/+$/,"").toLowerCase()}}function Q(e){let t=h(e);return t.startsWith("www.")?t.slice(4):t}function U(e){let t=h(e);if(z.test(t)||q.test(t)||t==="localhost")return!0;let n=(0,B.parse)(t,{allowPrivateDomains:!0});return!!(!n.domain||!n.publicSuffix||j.includes(n.publicSuffix))}function ee(e){let t=h(e);return U(t)||T.test(t)?!0:t.split(".").some(n=>T.test(n))}function te(e){return U(e)||ee(e)}function ne(e,t){return t?Q(e)===t:!1}function ie(e,t){return te(e)?{free:!0,covered:!0}:{free:!1,covered:ne(e,t)}}var y,B,W,L,u,S,T,j,z,q,re,D=l(()=>{"use strict";y=require("jose");C();f();O();B=require("tldts"),u=P();u?S=u.siteSettings:S={};T=/\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])\.)/,q=/^(::1$)|(^fc00:)|(^fd)/i;re=async()=>{let e=null;if(S.subscriber){let n=await(0,y.importJWK)({kty:"EC",x:W,y:L,crv:"P-256"},"ES256"),r=new Date().getFullYear(),i=Math.floor((Date.now()-new Date(r,0,1).getTime())/(1e3*60*60*24*7)),o=await fetch(u.uploadUrl+"lic.jws?t="+u.siteSettings.lastUpdate+"&y="+r+"&w="+i).then(s=>s.ok?s.text():null).catch(()=>null);if(o)try{let s=location.hostname.split(":")[0],{payload:a}=await(0,y.jwtVerify)(o,n,{algorithms:["ES256"]}),c=ie(s,a.domain);if(!c.free&&!c.covered)throw new Error("Invalid domain in JWT");let p=a.key.split(":"),X=d(p[0]),G=d(p[1]),m=(await fetch(u.uploadUrl+"config.enc?t="+u.siteSettings.lastUpdate).then(g=>g.ok?g.text():null).catch(()=>null))?.split(":");if(m?.length===2){let g=d(m[0]),I=d(m[1]),M=await crypto.subtle.importKey("raw",X,{name:"AES-GCM"},!1,["decrypt"]),Y=await crypto.subtle.decrypt({name:"AES-GCM",iv:G},M,new Uint8Array([...g,...I]));e=JSON.parse(new TextDecoder().decode(Y)),e.subscriptionType=a.subscriptionType}}catch(s){console.error(s.message)}}return e??null};W=A;L=k});var ce={};x(ce,{TEXT_DOMAIN:()=>se,attachDefaultPluginRuntime:()=>_,getConfig:()=>ae,getPlugin:()=>oe,getRecaptcha:()=>E,getWpSuite:()=>P});module.exports=J(ce);function P(){return globalThis.WpSuite}function oe(e){return globalThis.WpSuite?.plugins[e]}var se,ae,O=l(()=>{f();R();se="hub-for-wpsuiteio",ae=async e=>{let n=await(await Promise.resolve().then(()=>(D(),K))).getConfig();return n&&(n={...n[e],subscriptionType:n.subscriptionType}),n}});O();0&&(module.exports={TEXT_DOMAIN,attachDefaultPluginRuntime,getConfig,getPlugin,getRecaptcha,getWpSuite});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
type RecaptchaFunction = (reCaptchaSiteKey: string, options: {
|
|
2
|
+
action: string;
|
|
3
|
+
}) => Promise<string | undefined>;
|
|
4
|
+
declare const getRecaptcha: (useRecaptchaEnterprise: boolean) => Promise<{
|
|
5
|
+
execute: RecaptchaFunction | undefined;
|
|
6
|
+
}>;
|
|
7
|
+
|
|
1
8
|
/** Attaches the default runtime functions to a plugin object */
|
|
2
9
|
declare function attachDefaultPluginRuntime<T extends WpSuitePluginBase>(plugin: T, opts?: {
|
|
3
10
|
timeoutMs?: number;
|
|
@@ -49,4 +56,4 @@ interface SiteSettings {
|
|
|
49
56
|
type SubscriptionType = "PROFESSIONAL" | "AGENCY";
|
|
50
57
|
declare const getConfig: (plugin: string) => Promise<Record<string, unknown> | null>;
|
|
51
58
|
|
|
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 };
|
|
59
|
+
export { type PluginAvailability, type PluginStatus, type RecaptchaFunction, type SiteSettings, type SubscriptionType, TEXT_DOMAIN, type WpSuiteEvents, type WpSuiteGlobal, type WpSuitePluginBase, type WpSuitePluginRegistry, type WpSuiteView, attachDefaultPluginRuntime, getConfig, getPlugin, getRecaptcha, getWpSuite };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
type RecaptchaFunction = (reCaptchaSiteKey: string, options: {
|
|
2
|
+
action: string;
|
|
3
|
+
}) => Promise<string | undefined>;
|
|
4
|
+
declare const getRecaptcha: (useRecaptchaEnterprise: boolean) => Promise<{
|
|
5
|
+
execute: RecaptchaFunction | undefined;
|
|
6
|
+
}>;
|
|
7
|
+
|
|
1
8
|
/** Attaches the default runtime functions to a plugin object */
|
|
2
9
|
declare function attachDefaultPluginRuntime<T extends WpSuitePluginBase>(plugin: T, opts?: {
|
|
3
10
|
timeoutMs?: number;
|
|
@@ -49,4 +56,4 @@ interface SiteSettings {
|
|
|
49
56
|
type SubscriptionType = "PROFESSIONAL" | "AGENCY";
|
|
50
57
|
declare const getConfig: (plugin: string) => Promise<Record<string, unknown> | null>;
|
|
51
58
|
|
|
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 };
|
|
59
|
+
export { type PluginAvailability, type PluginStatus, type RecaptchaFunction, type SiteSettings, type SubscriptionType, TEXT_DOMAIN, type WpSuiteEvents, type WpSuiteGlobal, type WpSuitePluginBase, type WpSuitePluginRegistry, type WpSuiteView, attachDefaultPluginRuntime, getConfig, getPlugin, getRecaptcha, getWpSuite };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var O=Object.defineProperty;var l=(t
|
|
1
|
+
var O=Object.defineProperty;var l=(e,t)=>()=>(e&&(t=e(e=0)),t);var X=(e,t)=>{for(var n in t)O(e,n,{get:t[n],enumerable:!0})};function d(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");for(;t.length%4;)t+="=";return Uint8Array.from(atob(t),n=>n.charCodeAt(0))}var m,G,f=l(()=>{"use strict";m=(e,t)=>{let r=Uint8Array.from(atob(e),i=>i.charCodeAt(0)).map((i,o)=>i^t+o&255);return new TextDecoder().decode(r)},G=async e=>{let t=globalThis.grecaptcha,n=e?t?.enterprise:void 0,r=n?.ready??t?.ready,i=n?.execute??t?.execute;if(typeof i!="function")return{execute:void 0};try{return typeof r=="function"&&await new Promise(o=>r(()=>o())),{execute:i}}catch{return{execute:void 0}}}});function b(e,t){return`wpsuite:${e}:${t}`}function I(e,t=8e3){return()=>new Promise(n=>{if(e.status==="available")return n("available");if(e.status==="error")return n("error");!e.status||e.status;let r=b(e.key,"ready"),i=b(e.key,"error"),o=()=>c("available"),s=()=>c("error"),a,c=p=>{window.removeEventListener(r,o),window.removeEventListener(i,s),a!==void 0&&window.clearTimeout(a),n(p)};window.addEventListener(r,o,{once:!0}),window.addEventListener(i,s,{once:!0}),a=window.setTimeout(()=>c("unavailable"),t)})}function M(e){return t=>{window.addEventListener(b(e,"ready"),()=>t(),{once:!0})}}function Y(e,t){let n=t?.timeoutMs??8e3;return e.availability??=I(e,n),e.onReady??=M(e.key),e}var S=l(()=>{"use strict"});var h,P,x=l(()=>{"use strict";f();h=m("///24djH19SDi+vD3tGN3c7q7NTM9PG3nazxrZz0rLqSoKCjvJyCtJjrsw==",170),P=m("/Z/u1+ncyvLd19D01cLL1vjCzvn18KuZsKf8iomml4auqpS/loekpeKjgQ==",170)});var k={};X(k,{getConfig:()=>ee});import{importJWK as N,jwtVerify as V}from"jose";import{parse as F}from"tldts";function v(e){try{return new URL(e.includes("://")?e:`http://${e}`).hostname.toLowerCase()}catch{return e.replace(/\/+$/,"").toLowerCase()}}function Z(e){let t=v(e);return t.startsWith("www.")?t.slice(4):t}function A(e){let t=v(e);if(J.test(t)||$.test(t)||t==="localhost")return!0;let n=F(t,{allowPrivateDomains:!0});return!!(!n.domain||!n.publicSuffix||H.includes(n.publicSuffix))}function j(e){let t=v(e);return A(t)||E.test(t)?!0:t.split(".").some(n=>E.test(n))}function z(e){return A(e)||j(e)}function q(e,t){return t?Z(e)===t:!1}function Q(e,t){return z(e)?{free:!0,covered:!0}:{free:!1,covered:q(e,t)}}var _,R,u,w,E,H,J,$,ee,C=l(()=>{"use strict";x();f();W();u=T();u?w=u.siteSettings:w={};E=/\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;ee=async()=>{let e=null;if(w.subscriber){let n=await N({kty:"EC",x:_,y:R,crv:"P-256"},"ES256"),r=new Date().getFullYear(),i=Math.floor((Date.now()-new Date(r,0,1).getTime())/(1e3*60*60*24*7)),o=await fetch(u.uploadUrl+"lic.jws?t="+u.siteSettings.lastUpdate+"&y="+r+"&w="+i).then(s=>s.ok?s.text():null).catch(()=>null);if(o)try{let s=location.hostname.split(":")[0],{payload:a}=await V(o,n,{algorithms:["ES256"]}),c=Q(s,a.domain);if(!c.free&&!c.covered)throw new Error("Invalid domain in JWT");let p=a.key.split(":"),L=d(p[0]),B=d(p[1]),y=(await fetch(u.uploadUrl+"config.enc?t="+u.siteSettings.lastUpdate).then(g=>g.ok?g.text():null).catch(()=>null))?.split(":");if(y?.length===2){let g=d(y[0]),U=d(y[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]));e=JSON.parse(new TextDecoder().decode(D)),e.subscriptionType=a.subscriptionType}}catch(s){console.error(s.message)}}return e??null};_=h;R=P});function T(){return globalThis.WpSuite}function pe(e){return globalThis.WpSuite?.plugins[e]}var ge,fe,W=l(()=>{f();S();ge="hub-for-wpsuiteio",fe=async e=>{let n=await(await Promise.resolve().then(()=>(C(),k))).getConfig();return n&&(n={...n[e],subscriptionType:n.subscriptionType}),n}});W();export{ge as TEXT_DOMAIN,Y as attachDefaultPluginRuntime,fe as getConfig,pe as getPlugin,G as getRecaptcha,T as getWpSuite};
|