mp-front-cli 2.3.2 → 2.3.3
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/{AuthEngine-DF2swG3Z.cjs → AuthEngine-CDNhQfnX.cjs} +1 -1
- package/dist/{AuthEngine-EDmxrdis.js → AuthEngine-T4Nti8Ya.js} +219 -228
- package/dist/core/utils/custom-encrypter.d.ts.map +1 -1
- package/dist/mp-front-cli-adapter.cjs +1 -1
- package/dist/mp-front-cli-adapter.js +70 -72
- package/dist/mp-front-cli-all.cjs +1 -1
- package/dist/mp-front-cli-all.js +1 -1
- package/dist/mp-front-cli-core.cjs +1 -1
- package/dist/mp-front-cli-core.js +1 -1
- package/dist/mp-front-cli-encrypter.cjs +1 -1
- package/dist/mp-front-cli-encrypter.js +25 -30
- package/dist/stringify-BbkhfUoJ.js +9 -0
- package/dist/{stringify-BN6t_WDt.cjs → stringify-Ixz5_KTs.cjs} +1 -1
- package/package.json +5 -6
- package/dist/stringify-93tp0umt.js +0 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-encrypter.d.ts","sourceRoot":"","sources":["../../../src/core/utils/custom-encrypter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAGhD,qBAAa,eAAgB,SAAQ,aAAa;IAChD,OAAO,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"custom-encrypter.d.ts","sourceRoot":"","sources":["../../../src/core/utils/custom-encrypter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAGhD,qBAAa,eAAgB,SAAQ,aAAa;IAChD,OAAO,CAAC,YAAY,CAAoC;YAE1C,WAAW;cAgBT,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;cAarB,OAAO,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM;cAQ5B,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAahD,SAAS,CAAC,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;CAIlC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("./custom-redis-BaTLH6jE.cjs"),Z=require("./stringify-Ixz5_KTs.cjs"),$=new Uint8Array(16);function q(){return crypto.getRandomValues($)}function v(r,s,i){return crypto.randomUUID?crypto.randomUUID():G(r)}function G(r,s,i){var y;r=r||{};const c=r.random??((y=r.rng)==null?void 0:y.call(r))??q();if(c.length<16)throw new Error("Random bytes length must be >= 16");return c[6]=c[6]&15|64,c[8]=c[8]&63|128,Z.unsafeStringify(c)}const H=process.env.PREFIX_LOGIN,b=process.env.TIMEOUT_SESSION_MINUTES,p={baseKeyPrefix:`${H}:`,userKeyPrefix:"user:",accountKeyPrefix:"account:",accountByUserIdPrefix:"account:user:",sessionKeyPrefix:"session:",sessionByUserIdPrefix:"session:user:",userByEmailKeyPrefix:"user:email:",verificationKeyPrefix:"verification:",expire:b*60},L=r=>{for(const s in r)return!1;return!0},C=/(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/,z=r=>r&&C.test(r)&&!Number.isNaN(Date.parse(r));function J(r={expire:b*60}){const s=F.CustomRedis,i={...p,...r},c=i.baseKeyPrefix||"",y=c+i.userKeyPrefix,A=c+i.userByEmailKeyPrefix,B=c+i.accountKeyPrefix,T=c+i.accountByUserIdPrefix,k=c+i.sessionKeyPrefix,j=c+i.sessionByUserIdPrefix,N=c+i.verificationKeyPrefix,x=e=>A+e,K=e=>y+e,g=e=>B+e,f=e=>T+e,I=(e,t)=>`${t}:${e}`,P=e=>k+e,l=e=>j+e,U=e=>N+e,w=async(e,t)=>{const n=Object.entries(t).reduce((a,[S,o])=>(a[S]=o instanceof Date?o.toISOString():o,a),{});await s.hset(e,n),await s.expire(e,i.expire)},d=async e=>{const t=await s.hgetall(e);return!t||L(t)?null:Object.entries(t).reduce((a,[S,o])=>(a[S]=z(o)?new Date(o):o,a),{})},O=async(e,t)=>(await w(K(e),t),t.email&&await s.set(x(t.email),e,"EX",i.expire),t),u=async e=>{const t=await d(K(e));return t?{...t}:null},R=async(e,t)=>{const n=g(e);await w(n,t),await s.set(f(t.userId),n,"EX",i.expire)},h=async e=>{const t=await d(g(e));return t?{...t}:null},_=async e=>{const t=g(e),n=await d(t);if(!n)return null;await s.hdel(t),await s.del(f(n.userId))},E=async(e,t)=>{const n=P(e);return await w(n,t),await s.set(l(t.userId),n,"EX",i.expire),t},m=async e=>{const t=await d(P(e));return t?{id:t.id,...t}:null},D=async e=>{const t=await m(e);if(!t)return null;const n=P(e);await s.del(n),await s.del(l(t.userId))},V=async(e,t)=>{const n=U(e);return await w(n,t),t},M=async e=>{const t=U(e),n=await d(t);return n?{identifier:n.identifier,...n}:null},X=async e=>{const t=U(e);await s.del(t)};return{async createUser(e){const t=v();return await O(t,{...e,id:t})},getUser:u,async getUserByEmail(e){const t=await s.get(x(e));return t?await u(t):null},async getUserByAccount({providerAccountId:e,provider:t}){const n=await h(I(e,t));return n?await u(n.userId):null},async updateUser(e){const t=e.id,n=await u(t);return await O(t,{...n,...e})},async deleteUser(e){const t=await u(e);if(!t)return null;const n=await s.get(f(e)),a=await s.get(l(e));await s.del(x(t.email),f(e),l(e)),a&&await s.del(a),n&&await s.del(n),await s.del(K(e))},async linkAccount(e){const t=I(e.providerAccountId,e.provider);return await R(t,{...e,id:t})},async unlinkAccount({providerAccountId:e,provider:t}){const n=I(e,t);await _(n)},async createSession(e){const t=e.sessionToken;return await E(t,{...e,id:t})},async getSessionAndUser(e){const n=await m(e);if(!n)return null;const a=await u(n.userId);return a?{session:n,user:a}:null},async updateSession(e){const t=e.sessionToken,n=await m(t);return n?await E(t,{...n,...e}):null},deleteSession:D,async createVerificationToken(e){const t=e.identifier;return await V(t,e),e},async useVerificationToken(e){const t=e.identifier,n=await M(t);return!n||e.token!==n.token?null:(await X(t),n)}}}exports.IORedisAdapter=J;exports.defaultOptions=p;
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
import { u as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (!w && (w = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !w))
|
|
7
|
-
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
8
|
-
return w(v);
|
|
1
|
+
import { C as M } from "./custom-redis-BMPP_XZi.js";
|
|
2
|
+
import { u as F } from "./stringify-BbkhfUoJ.js";
|
|
3
|
+
const Z = new Uint8Array(16);
|
|
4
|
+
function $() {
|
|
5
|
+
return crypto.getRandomValues(Z);
|
|
9
6
|
}
|
|
10
|
-
|
|
11
|
-
randomUUID: G
|
|
12
|
-
}
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
return O.randomUUID();
|
|
7
|
+
function C(r, s, i) {
|
|
8
|
+
return crypto.randomUUID ? crypto.randomUUID() : G(r);
|
|
9
|
+
}
|
|
10
|
+
function G(r, s, i) {
|
|
11
|
+
var y;
|
|
16
12
|
r = r || {};
|
|
17
|
-
const
|
|
18
|
-
|
|
13
|
+
const c = r.random ?? ((y = r.rng) == null ? void 0 : y.call(r)) ?? $();
|
|
14
|
+
if (c.length < 16)
|
|
15
|
+
throw new Error("Random bytes length must be >= 16");
|
|
16
|
+
return c[6] = c[6] & 15 | 64, c[8] = c[8] & 63 | 128, F(c);
|
|
19
17
|
}
|
|
20
|
-
const
|
|
21
|
-
baseKeyPrefix: `${
|
|
18
|
+
const H = process.env.PREFIX_LOGIN, b = process.env.TIMEOUT_SESSION_MINUTES, L = {
|
|
19
|
+
baseKeyPrefix: `${H}:`,
|
|
22
20
|
userKeyPrefix: "user:",
|
|
23
21
|
accountKeyPrefix: "account:",
|
|
24
22
|
accountByUserIdPrefix: "account:user:",
|
|
@@ -27,76 +25,76 @@ const L = process.env.PREFIX_LOGIN, b = process.env.TIMEOUT_SESSION_MINUTES, q =
|
|
|
27
25
|
userByEmailKeyPrefix: "user:email:",
|
|
28
26
|
verificationKeyPrefix: "verification:",
|
|
29
27
|
expire: b * 60
|
|
30
|
-
},
|
|
28
|
+
}, v = (r) => {
|
|
31
29
|
for (const s in r)
|
|
32
30
|
return !1;
|
|
33
31
|
return !0;
|
|
34
|
-
},
|
|
35
|
-
function
|
|
36
|
-
const s =
|
|
37
|
-
...
|
|
32
|
+
}, q = /(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/, z = (r) => r && q.test(r) && !Number.isNaN(Date.parse(r));
|
|
33
|
+
function W(r = { expire: b * 60 }) {
|
|
34
|
+
const s = M, i = {
|
|
35
|
+
...L,
|
|
38
36
|
...r
|
|
39
|
-
},
|
|
40
|
-
const n = Object.entries(t).reduce((
|
|
37
|
+
}, c = i.baseKeyPrefix || "", y = c + i.userKeyPrefix, p = c + i.userByEmailKeyPrefix, A = c + i.accountKeyPrefix, B = c + i.accountByUserIdPrefix, k = c + i.sessionKeyPrefix, T = c + i.sessionByUserIdPrefix, N = c + i.verificationKeyPrefix, x = (e) => p + e, K = (e) => y + e, I = (e) => A + e, f = (e) => B + e, U = (e, t) => `${t}:${e}`, g = (e) => k + e, l = (e) => T + e, P = (e) => N + e, w = async (e, t) => {
|
|
38
|
+
const n = Object.entries(t).reduce((a, [E, o]) => (a[E] = o instanceof Date ? o.toISOString() : o, a), {});
|
|
41
39
|
await s.hset(e, n), await s.expire(e, i.expire);
|
|
42
40
|
}, d = async (e) => {
|
|
43
41
|
const t = await s.hgetall(e);
|
|
44
|
-
return !t ||
|
|
45
|
-
}, S = async (e, t) => (await
|
|
42
|
+
return !t || v(t) ? null : Object.entries(t).reduce((a, [E, o]) => (a[E] = z(o) ? new Date(o) : o, a), {});
|
|
43
|
+
}, S = async (e, t) => (await w(K(e), t), t.email && await s.set(
|
|
46
44
|
x(t.email),
|
|
47
45
|
e,
|
|
48
46
|
"EX",
|
|
49
47
|
i.expire
|
|
50
48
|
), t), u = async (e) => {
|
|
51
|
-
const t = await d(
|
|
49
|
+
const t = await d(K(e));
|
|
52
50
|
return t ? { ...t } : null;
|
|
53
|
-
},
|
|
54
|
-
const n =
|
|
55
|
-
await
|
|
56
|
-
|
|
51
|
+
}, h = async (e, t) => {
|
|
52
|
+
const n = I(e);
|
|
53
|
+
await w(n, t), await s.set(
|
|
54
|
+
f(t.userId),
|
|
57
55
|
n,
|
|
58
56
|
"EX",
|
|
59
57
|
i.expire
|
|
60
58
|
);
|
|
61
|
-
},
|
|
62
|
-
const t = await d(
|
|
59
|
+
}, j = async (e) => {
|
|
60
|
+
const t = await d(I(e));
|
|
63
61
|
return t ? { ...t } : null;
|
|
64
|
-
},
|
|
65
|
-
const t =
|
|
62
|
+
}, _ = async (e) => {
|
|
63
|
+
const t = I(e), n = await d(t);
|
|
66
64
|
if (!n) return null;
|
|
67
|
-
await s.hdel(t), await s.del(
|
|
68
|
-
},
|
|
69
|
-
const n =
|
|
70
|
-
return await
|
|
71
|
-
|
|
65
|
+
await s.hdel(t), await s.del(f(n.userId));
|
|
66
|
+
}, O = async (e, t) => {
|
|
67
|
+
const n = g(e);
|
|
68
|
+
return await w(n, t), await s.set(
|
|
69
|
+
l(t.userId),
|
|
72
70
|
n,
|
|
73
71
|
"EX",
|
|
74
72
|
i.expire
|
|
75
73
|
), t;
|
|
76
74
|
}, m = async (e) => {
|
|
77
|
-
const t = await d(
|
|
75
|
+
const t = await d(g(e));
|
|
78
76
|
return t ? {
|
|
79
77
|
id: t.id,
|
|
80
78
|
...t
|
|
81
79
|
} : null;
|
|
82
|
-
},
|
|
80
|
+
}, D = async (e) => {
|
|
83
81
|
const t = await m(e);
|
|
84
82
|
if (!t) return null;
|
|
85
|
-
const n = I(e);
|
|
86
|
-
await s.del(n), await s.del(f(t.userId));
|
|
87
|
-
}, X = async (e, t) => {
|
|
88
83
|
const n = g(e);
|
|
89
|
-
|
|
90
|
-
},
|
|
91
|
-
const
|
|
84
|
+
await s.del(n), await s.del(l(t.userId));
|
|
85
|
+
}, R = async (e, t) => {
|
|
86
|
+
const n = P(e);
|
|
87
|
+
return await w(n, t), t;
|
|
88
|
+
}, V = async (e) => {
|
|
89
|
+
const t = P(e), n = await d(t);
|
|
92
90
|
return n ? { identifier: n.identifier, ...n } : null;
|
|
93
|
-
},
|
|
94
|
-
const t =
|
|
91
|
+
}, X = async (e) => {
|
|
92
|
+
const t = P(e);
|
|
95
93
|
await s.del(t);
|
|
96
94
|
};
|
|
97
95
|
return {
|
|
98
96
|
async createUser(e) {
|
|
99
|
-
const t =
|
|
97
|
+
const t = C();
|
|
100
98
|
return await S(t, { ...e, id: t });
|
|
101
99
|
},
|
|
102
100
|
getUser: u,
|
|
@@ -105,8 +103,8 @@ function ee(r = { expire: b * 60 }) {
|
|
|
105
103
|
return t ? await u(t) : null;
|
|
106
104
|
},
|
|
107
105
|
async getUserByAccount({ providerAccountId: e, provider: t }) {
|
|
108
|
-
const n = await
|
|
109
|
-
|
|
106
|
+
const n = await j(
|
|
107
|
+
U(e, t)
|
|
110
108
|
);
|
|
111
109
|
return n ? await u(n.userId) : null;
|
|
112
110
|
},
|
|
@@ -117,27 +115,27 @@ function ee(r = { expire: b * 60 }) {
|
|
|
117
115
|
async deleteUser(e) {
|
|
118
116
|
const t = await u(e);
|
|
119
117
|
if (!t) return null;
|
|
120
|
-
const n = await s.get(
|
|
118
|
+
const n = await s.get(f(e)), a = await s.get(l(e));
|
|
121
119
|
await s.del(
|
|
122
120
|
x(t.email),
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
),
|
|
121
|
+
f(e),
|
|
122
|
+
l(e)
|
|
123
|
+
), a && await s.del(a), n && await s.del(n), await s.del(K(e));
|
|
126
124
|
},
|
|
127
125
|
async linkAccount(e) {
|
|
128
|
-
const t =
|
|
129
|
-
return await
|
|
126
|
+
const t = U(e.providerAccountId, e.provider);
|
|
127
|
+
return await h(t, { ...e, id: t });
|
|
130
128
|
},
|
|
131
129
|
async unlinkAccount({
|
|
132
130
|
providerAccountId: e,
|
|
133
131
|
provider: t
|
|
134
132
|
}) {
|
|
135
|
-
const n =
|
|
136
|
-
await
|
|
133
|
+
const n = U(e, t);
|
|
134
|
+
await _(n);
|
|
137
135
|
},
|
|
138
136
|
async createSession(e) {
|
|
139
137
|
const t = e.sessionToken;
|
|
140
|
-
return await
|
|
138
|
+
return await O(t, {
|
|
141
139
|
...e,
|
|
142
140
|
id: t
|
|
143
141
|
});
|
|
@@ -145,25 +143,25 @@ function ee(r = { expire: b * 60 }) {
|
|
|
145
143
|
async getSessionAndUser(e) {
|
|
146
144
|
const n = await m(e);
|
|
147
145
|
if (!n) return null;
|
|
148
|
-
const
|
|
149
|
-
return
|
|
146
|
+
const a = await u(n.userId);
|
|
147
|
+
return a ? { session: n, user: a } : null;
|
|
150
148
|
},
|
|
151
149
|
async updateSession(e) {
|
|
152
150
|
const t = e.sessionToken, n = await m(t);
|
|
153
|
-
return n ? await
|
|
151
|
+
return n ? await O(t, { ...n, ...e }) : null;
|
|
154
152
|
},
|
|
155
|
-
deleteSession:
|
|
153
|
+
deleteSession: D,
|
|
156
154
|
async createVerificationToken(e) {
|
|
157
155
|
const t = e.identifier;
|
|
158
|
-
return await
|
|
156
|
+
return await R(t, e), e;
|
|
159
157
|
},
|
|
160
158
|
async useVerificationToken(e) {
|
|
161
|
-
const t = e.identifier, n = await
|
|
162
|
-
return !n || e.token !== n.token ? null : (await
|
|
159
|
+
const t = e.identifier, n = await V(t);
|
|
160
|
+
return !n || e.token !== n.token ? null : (await X(t), n);
|
|
163
161
|
}
|
|
164
162
|
};
|
|
165
163
|
}
|
|
166
164
|
export {
|
|
167
|
-
|
|
168
|
-
|
|
165
|
+
W as IORedisAdapter,
|
|
166
|
+
L as defaultOptions
|
|
169
167
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./AuthEngine-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./AuthEngine-CDNhQfnX.cjs"),r=require("./loading-handler-CVkAHN_A.cjs"),n=require("./service-token-CPZee3-I.cjs");exports.ApiMiddleware=e.ApiMiddleware;exports.AuthEngine=e.AuthEngine;exports.ErrorCatalog=e.ErrorCatalog;exports.Exception=e.Exception;exports.FetchServiceBE=e.FetchServiceBE;exports.FetchServiceFE=e.FetchServiceFE;exports.FetchServiceParentBE=e.FetchServiceParentBE;exports.LoadingHandler=r.LoadingHandler;exports.MessageHandler=r.MessageHandler;exports.RxSubjectManager=r.RxSubjectManager;exports.ServiceToken=n.ServiceToken;
|
package/dist/mp-front-cli-all.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as r, a as s, E as o, b as t, F as c, c as i, d as n } from "./AuthEngine-
|
|
1
|
+
import { A as r, a as s, E as o, b as t, F as c, c as i, d as n } from "./AuthEngine-T4Nti8Ya.js";
|
|
2
2
|
import { L as d, M as S, R as g } from "./loading-handler-Br21zGTA.js";
|
|
3
3
|
import { S as x } from "./service-token-BfQQMCM4.js";
|
|
4
4
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./AuthEngine-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./AuthEngine-CDNhQfnX.cjs"),r=require("./loading-handler-CVkAHN_A.cjs"),n=require("./service-token-CPZee3-I.cjs");exports.ApiMiddleware=e.ApiMiddleware;exports.AuthEngine=e.AuthEngine;exports.ErrorCatalog=e.ErrorCatalog;exports.Exception=e.Exception;exports.FetchServiceBE=e.FetchServiceBE;exports.FetchServiceFE=e.FetchServiceFE;exports.FetchServiceParentBE=e.FetchServiceParentBE;exports.LoadingHandler=r.LoadingHandler;exports.MessageHandler=r.MessageHandler;exports.RxSubjectManager=r.RxSubjectManager;exports.ServiceToken=n.ServiceToken;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as r, a as s, E as o, b as t, F as c, c as i, d as n } from "./AuthEngine-
|
|
1
|
+
import { A as r, a as s, E as o, b as t, F as c, c as i, d as n } from "./AuthEngine-T4Nti8Ya.js";
|
|
2
2
|
import { L as d, M as S, R as g } from "./loading-handler-Br21zGTA.js";
|
|
3
3
|
import { S as x } from "./service-token-BfQQMCM4.js";
|
|
4
4
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var o=Object.defineProperty;var a=(r,t,e)=>t in r?o(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var s=(r,t,e)=>a(r,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("jose"),E=require("crypto"),y=require("./mp-front-cli-encoder.cjs"),u=r=>r.replace(/[\u00A0-\uffff]/gu,t=>"\\u"+("000"+t.charCodeAt(0).toString(16)).slice(-4));class d extends y.CustomEncoder{constructor(){super(...arguments);s(this,"signatureKey")}async generateKey(){const e=process.env.SECRET_SIGNATURE;if(!e)throw new Error("Define a SECRET_SIGNATURE from `.env`");this.signatureKey=await c.importJWK({kty:"oct",k:c.base64url.encode(new TextEncoder().encode(e))})}async encrypt(e){if(await this.generateKey(),!this.signatureKey)throw new Error("PLEASE CREATE A KEY TO ENCRYPT 🙂");const n=JSON.stringify(e),i=u(n);return await new c.CompactEncrypt(new TextEncoder().encode(i)).setProtectedHeader({alg:"A256KW",enc:"A256GCM"}).encrypt(this.signatureKey)}async decrypt(e){if(await this.generateKey(),!this.signatureKey)throw new Error("PLEASE CREATE A KEY TO DECRYPT 🙂");const{plaintext:n}=await c.compactDecrypt(e,this.signatureKey);return JSON.parse(new TextDecoder().decode(n))}async isEncrypted(e){this.logInfo("EncryptionHandler",e);try{return await this.decrypt(e??""),this.logDebug("EncryptionHandler","IS ENCRYPTED 🥵"),!0}catch(n){return this.logWarn("EncryptionHandler",JSON.stringify(n)),this.logDebug("EncryptionHandler","IS NOT ENCRYPTED 🙂"),!1}}generateSHA(e){const n=JSON.stringify(e);return E.createHash("sha256").update(n).digest("hex")}}exports.CustomEncrypter=d;
|
|
@@ -1,52 +1,47 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var i = (r,
|
|
4
|
-
import
|
|
5
|
-
import { createHash as
|
|
6
|
-
import { CustomEncoder as
|
|
7
|
-
const
|
|
8
|
-
class
|
|
1
|
+
var s = Object.defineProperty;
|
|
2
|
+
var a = (r, t, e) => t in r ? s(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
|
+
var i = (r, t, e) => a(r, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { importJWK as c, base64url as E, CompactEncrypt as y, compactDecrypt as p } from "jose";
|
|
5
|
+
import { createHash as d } from "crypto";
|
|
6
|
+
import { CustomEncoder as g } from "./mp-front-cli-encoder.js";
|
|
7
|
+
const u = (r) => r.replace(/[\u00A0-\uffff]/gu, (t) => "\\u" + ("000" + t.charCodeAt(0).toString(16)).slice(-4));
|
|
8
|
+
class l extends g {
|
|
9
9
|
constructor() {
|
|
10
10
|
super(...arguments);
|
|
11
11
|
i(this, "signatureKey");
|
|
12
12
|
}
|
|
13
13
|
async generateKey() {
|
|
14
|
-
const
|
|
15
|
-
if (!
|
|
14
|
+
const e = process.env.SECRET_SIGNATURE;
|
|
15
|
+
if (!e)
|
|
16
16
|
throw new Error("Define a SECRET_SIGNATURE from `.env`");
|
|
17
|
-
this.signatureKey = await
|
|
17
|
+
this.signatureKey = await c({
|
|
18
18
|
kty: "oct",
|
|
19
|
-
k:
|
|
19
|
+
k: E.encode(new TextEncoder().encode(e))
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
|
-
async encrypt(
|
|
22
|
+
async encrypt(e) {
|
|
23
23
|
if (await this.generateKey(), !this.signatureKey) throw new Error("PLEASE CREATE A KEY TO ENCRYPT 🙂");
|
|
24
|
-
const n = JSON.stringify(
|
|
25
|
-
return await
|
|
26
|
-
{ format: "compact" },
|
|
27
|
-
this.signatureKey
|
|
28
|
-
).update(s).final();
|
|
24
|
+
const n = JSON.stringify(e), o = u(n);
|
|
25
|
+
return await new y(new TextEncoder().encode(o)).setProtectedHeader({ alg: "A256KW", enc: "A256GCM" }).encrypt(this.signatureKey);
|
|
29
26
|
}
|
|
30
|
-
async decrypt(
|
|
27
|
+
async decrypt(e) {
|
|
31
28
|
if (await this.generateKey(), !this.signatureKey) throw new Error("PLEASE CREATE A KEY TO DECRYPT 🙂");
|
|
32
|
-
const {
|
|
33
|
-
|
|
34
|
-
).decrypt(t);
|
|
35
|
-
return JSON.parse(n.toString());
|
|
29
|
+
const { plaintext: n } = await p(e, this.signatureKey);
|
|
30
|
+
return JSON.parse(new TextDecoder().decode(n));
|
|
36
31
|
}
|
|
37
|
-
async isEncrypted(
|
|
38
|
-
this.logInfo("EncryptionHandler",
|
|
32
|
+
async isEncrypted(e) {
|
|
33
|
+
this.logInfo("EncryptionHandler", e);
|
|
39
34
|
try {
|
|
40
|
-
return await this.decrypt(
|
|
35
|
+
return await this.decrypt(e ?? ""), this.logDebug("EncryptionHandler", "IS ENCRYPTED 🥵"), !0;
|
|
41
36
|
} catch (n) {
|
|
42
37
|
return this.logWarn("EncryptionHandler", JSON.stringify(n)), this.logDebug("EncryptionHandler", "IS NOT ENCRYPTED 🙂"), !1;
|
|
43
38
|
}
|
|
44
39
|
}
|
|
45
|
-
generateSHA(
|
|
46
|
-
const n = JSON.stringify(
|
|
47
|
-
return
|
|
40
|
+
generateSHA(e) {
|
|
41
|
+
const n = JSON.stringify(e);
|
|
42
|
+
return d("sha256").update(n).digest("hex");
|
|
48
43
|
}
|
|
49
44
|
}
|
|
50
45
|
export {
|
|
51
|
-
|
|
46
|
+
l as CustomEncrypter
|
|
52
47
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const i = [];
|
|
2
|
+
for (let n = 0; n < 256; ++n)
|
|
3
|
+
i.push((n + 256).toString(16).slice(1));
|
|
4
|
+
function c(n, u = 0) {
|
|
5
|
+
return (i[n[u + 0]] + i[n[u + 1]] + i[n[u + 2]] + i[n[u + 3]] + "-" + i[n[u + 4]] + i[n[u + 5]] + "-" + i[n[u + 6]] + i[n[u + 7]] + "-" + i[n[u + 8]] + i[n[u + 9]] + "-" + i[n[u + 10]] + i[n[u + 11]] + i[n[u + 12]] + i[n[u + 13]] + i[n[u + 14]] + i[n[u + 15]]).toLowerCase();
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
c as u
|
|
9
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const n=[];for(let i=0;i<256;++i)n.push((i+256).toString(16).slice(1));function c(i,u=0){return
|
|
1
|
+
"use strict";const n=[];for(let i=0;i<256;++i)n.push((i+256).toString(16).slice(1));function c(i,u=0){return(n[i[u+0]]+n[i[u+1]]+n[i[u+2]]+n[i[u+3]]+"-"+n[i[u+4]]+n[i[u+5]]+"-"+n[i[u+6]]+n[i[u+7]]+"-"+n[i[u+8]]+n[i[u+9]]+"-"+n[i[u+10]]+n[i[u+11]]+n[i[u+12]]+n[i[u+13]]+n[i[u+14]]+n[i[u+15]]).toLowerCase()}exports.unsafeStringify=c;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mp-front-cli",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/mp-front-cli-all.cjs",
|
|
@@ -82,18 +82,17 @@
|
|
|
82
82
|
"peerDependencies": {
|
|
83
83
|
"i18next": "25.2.0",
|
|
84
84
|
"ioredis": "5.3.2",
|
|
85
|
-
"
|
|
86
|
-
"
|
|
85
|
+
"jose": "6.2.2",
|
|
86
|
+
"next-auth": "4.24.14",
|
|
87
87
|
"rxjs": "7.8.1"
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"uuid": "
|
|
90
|
+
"uuid": "14.0.0"
|
|
91
91
|
},
|
|
92
92
|
"devDependencies": {
|
|
93
93
|
"@eslint/eslintrc": "3.2.0",
|
|
94
94
|
"@eslint/js": "9.19.0",
|
|
95
95
|
"@types/node": "20.10.6",
|
|
96
|
-
"@types/node-jose": "1.1.13",
|
|
97
96
|
"@types/uuid": "10.0.0",
|
|
98
97
|
"@typescript-eslint/eslint-plugin": "8.22.0",
|
|
99
98
|
"eslint": "9.38.0",
|
|
@@ -102,7 +101,7 @@
|
|
|
102
101
|
"globals": "15.14.0",
|
|
103
102
|
"husky": "9.1.7",
|
|
104
103
|
"typescript": "5.7.2",
|
|
105
|
-
"vite": "6.4.
|
|
104
|
+
"vite": "6.4.2",
|
|
106
105
|
"vite-plugin-dts": "4.5.0",
|
|
107
106
|
"vite-tsconfig-paths": "5.1.4"
|
|
108
107
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
const i = [];
|
|
2
|
-
for (let n = 0; n < 256; ++n)
|
|
3
|
-
i.push((n + 256).toString(16).slice(1));
|
|
4
|
-
function c(n, u = 0) {
|
|
5
|
-
return i[n[u + 0]] + i[n[u + 1]] + i[n[u + 2]] + i[n[u + 3]] + "-" + i[n[u + 4]] + i[n[u + 5]] + "-" + i[n[u + 6]] + i[n[u + 7]] + "-" + i[n[u + 8]] + i[n[u + 9]] + "-" + i[n[u + 10]] + i[n[u + 11]] + i[n[u + 12]] + i[n[u + 13]] + i[n[u + 14]] + i[n[u + 15]];
|
|
6
|
-
}
|
|
7
|
-
export {
|
|
8
|
-
c as u
|
|
9
|
-
};
|