md-face-engine 1.1.2 → 1.1.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.
@@ -0,0 +1,123 @@
1
+ import { f as E, b as y } from "./client-BJQU_Kcy.js";
2
+ const f = {
3
+ base: {
4
+ key: "base",
5
+ label: "Base",
6
+ defaults: { intensity: 0.5, sigma: 4, brightness: 0, contrast: 1, warmthR: 0, warmthB: 0, warmthA: 0 },
7
+ deep: {}
8
+ }
9
+ };
10
+ function p(a) {
11
+ return f[a] || null;
12
+ }
13
+ const w = ["base"], u = "mdfe2_", g = "md-face-engine", s = `-----BEGIN PUBLIC KEY-----
14
+ MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEW9CHbTVvVXcm09wZIj6GKGaq8ae1
15
+ XGQAum9LBLgoT3+4q3xPc7W9KSw1z4xgfOByTi8OzdjbjEaF3VrHjzl05w==
16
+ -----END PUBLIC KEY-----`;
17
+ let c = null;
18
+ function v(a) {
19
+ const e = a.replace(/-/g, "+").replace(/_/g, "/"), t = e + "=".repeat((4 - e.length % 4) % 4);
20
+ return atob(t);
21
+ }
22
+ function C(a) {
23
+ const e = v(a), t = new Uint8Array(e.length);
24
+ for (let r = 0; r < e.length; r += 1)
25
+ t[r] = e.charCodeAt(r);
26
+ return t;
27
+ }
28
+ function b(a) {
29
+ const e = a.replace(/-----BEGIN PUBLIC KEY-----/g, "").replace(/-----END PUBLIC KEY-----/g, "").replace(/\s+/g, ""), t = atob(e), r = new Uint8Array(t.length);
30
+ for (let i = 0; i < t.length; i += 1)
31
+ r[i] = t.charCodeAt(i);
32
+ return r.buffer;
33
+ }
34
+ async function m(a = s) {
35
+ if (a === s && c)
36
+ return c;
37
+ const e = b(a), t = await crypto.subtle.importKey(
38
+ "spki",
39
+ e,
40
+ { name: "ECDSA", namedCurve: "P-256" },
41
+ !1,
42
+ ["verify"]
43
+ );
44
+ return a === s && (c = t), t;
45
+ }
46
+ async function A(a, e = {}) {
47
+ const {
48
+ now: t = Date.now(),
49
+ publicKeyPem: r = s,
50
+ allowExpired: i = !1
51
+ } = e;
52
+ if (!a || typeof a != "string")
53
+ return { valid: !1, reason: "Token vacío o inválido" };
54
+ if (!a.startsWith(u))
55
+ return { valid: !1, reason: "Prefijo de token inválido" };
56
+ const l = a.slice(u.length).split(".");
57
+ if (l.length !== 2)
58
+ return { valid: !1, reason: "Formato de token inválido" };
59
+ const [d, h] = l;
60
+ let n;
61
+ try {
62
+ n = JSON.parse(v(d));
63
+ } catch {
64
+ return { valid: !1, reason: "Payload de licencia inválido" };
65
+ }
66
+ try {
67
+ const o = await m(r);
68
+ if (!await crypto.subtle.verify(
69
+ { name: "ECDSA", hash: "SHA-256" },
70
+ o,
71
+ C(h),
72
+ new TextEncoder().encode(d)
73
+ ))
74
+ return { valid: !1, reason: "Firma de licencia inválida" };
75
+ } catch {
76
+ return { valid: !1, reason: "Error verificando firma de licencia" };
77
+ }
78
+ return n.productCode !== g ? { valid: !1, reason: "Licencia de otro producto" } : !i && (typeof n.exp != "number" || n.exp < t) ? { valid: !1, reason: "Licencia vencida", payload: n } : { valid: !0, reason: null, payload: n };
79
+ }
80
+ class B {
81
+ constructor() {
82
+ this.license = null, this.activated = !1;
83
+ }
84
+ async activate(e) {
85
+ const t = await A(e);
86
+ if (!t.valid)
87
+ throw this.license = null, this.activated = !1, new Error(`Licencia inválida: ${t.reason}`);
88
+ return this.license = t.payload, this.activated = !0, t.payload;
89
+ }
90
+ isActivated() {
91
+ return this.activated;
92
+ }
93
+ assertActivated() {
94
+ if (!this.activated)
95
+ throw new Error("md-face-engine no está activado. Configura VITE_MD_FACE_ENGINE_TOKEN.");
96
+ }
97
+ getLicense() {
98
+ return this.assertActivated(), this.license;
99
+ }
100
+ getProductCode() {
101
+ return g;
102
+ }
103
+ getFilterRegistry() {
104
+ return this.assertActivated(), f;
105
+ }
106
+ getFilterOrder() {
107
+ return this.assertActivated(), w;
108
+ }
109
+ getFilter(e) {
110
+ return this.assertActivated(), p(e);
111
+ }
112
+ getFilterConfigManager() {
113
+ return this.assertActivated(), E;
114
+ }
115
+ buildWebglConfigForProduct(e) {
116
+ return this.assertActivated(), y(e);
117
+ }
118
+ }
119
+ export {
120
+ B as MartidermEngine,
121
+ B as MdFaceEngine,
122
+ B as default
123
+ };
@@ -0,0 +1,4 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./client-G2U5YE6M.cjs"),v={base:{key:"base",label:"Base",defaults:{intensity:.5,sigma:4,brightness:0,contrast:1,warmthR:0,warmthB:0,warmthA:0},deep:{}}};function p(r){return v[r]||null}const w=["base"],g="mdfe2_",h="md-face-engine",s=`-----BEGIN PUBLIC KEY-----
2
+ MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEW9CHbTVvVXcm09wZIj6GKGaq8ae1
3
+ XGQAum9LBLgoT3+4q3xPc7W9KSw1z4xgfOByTi8OzdjbjEaF3VrHjzl05w==
4
+ -----END PUBLIC KEY-----`;let c=null;function E(r){const e=r.replace(/-/g,"+").replace(/_/g,"/"),t=e+"=".repeat((4-e.length%4)%4);return atob(t)}function b(r){const e=E(r),t=new Uint8Array(e.length);for(let a=0;a<e.length;a+=1)t[a]=e.charCodeAt(a);return t}function C(r){const e=r.replace(/-----BEGIN PUBLIC KEY-----/g,"").replace(/-----END PUBLIC KEY-----/g,"").replace(/\s+/g,""),t=atob(e),a=new Uint8Array(t.length);for(let i=0;i<t.length;i+=1)a[i]=t.charCodeAt(i);return a.buffer}async function A(r=s){if(r===s&&c)return c;const e=C(r),t=await crypto.subtle.importKey("spki",e,{name:"ECDSA",namedCurve:"P-256"},!1,["verify"]);return r===s&&(c=t),t}async function m(r,e={}){const{now:t=Date.now(),publicKeyPem:a=s,allowExpired:i=!1}=e;if(!r||typeof r!="string")return{valid:!1,reason:"Token vacío o inválido"};if(!r.startsWith(g))return{valid:!1,reason:"Prefijo de token inválido"};const d=r.slice(g.length).split(".");if(d.length!==2)return{valid:!1,reason:"Formato de token inválido"};const[u,y]=d;let n;try{n=JSON.parse(E(u))}catch{return{valid:!1,reason:"Payload de licencia inválido"}}try{const o=await A(a);if(!await crypto.subtle.verify({name:"ECDSA",hash:"SHA-256"},o,b(y),new TextEncoder().encode(u)))return{valid:!1,reason:"Firma de licencia inválida"}}catch{return{valid:!1,reason:"Error verificando firma de licencia"}}return n.productCode!==h?{valid:!1,reason:"Licencia de otro producto"}:!i&&(typeof n.exp!="number"||n.exp<t)?{valid:!1,reason:"Licencia vencida",payload:n}:{valid:!0,reason:null,payload:n}}class l{constructor(){this.license=null,this.activated=!1}async activate(e){const t=await m(e);if(!t.valid)throw this.license=null,this.activated=!1,new Error(`Licencia inválida: ${t.reason}`);return this.license=t.payload,this.activated=!0,t.payload}isActivated(){return this.activated}assertActivated(){if(!this.activated)throw new Error("md-face-engine no está activado. Configura VITE_MD_FACE_ENGINE_TOKEN.")}getLicense(){return this.assertActivated(),this.license}getProductCode(){return h}getFilterRegistry(){return this.assertActivated(),v}getFilterOrder(){return this.assertActivated(),w}getFilter(e){return this.assertActivated(),p(e)}getFilterConfigManager(){return this.assertActivated(),f.filterConfigManager}buildWebglConfigForProduct(e){return this.assertActivated(),f.buildWebglConfigForProduct(e)}}exports.MartidermEngine=l;exports.MdFaceEngine=l;exports.default=l;