mp-front-cli 0.0.54 → 0.0.56
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/core/utils/api-request/fetch-service-be.d.ts +5 -3
- package/dist/core/utils/api-request/fetch-service-be.d.ts.map +1 -1
- package/dist/core/utils/custom-adapter.d.ts +15 -0
- package/dist/core/utils/custom-adapter.d.ts.map +1 -0
- package/dist/core/utils/custom-cache.d.ts +2 -6
- package/dist/core/utils/custom-cache.d.ts.map +1 -1
- package/dist/core/utils/custom-encrypter.d.ts.map +1 -1
- package/dist/core/utils/custom-redis.d.ts +4 -0
- package/dist/core/utils/custom-redis.d.ts.map +1 -0
- package/dist/{custom-header-eeb04e28.js → custom-header-3ba5652e.js} +94 -94
- package/dist/custom-redis-bee66564.js +11 -0
- package/dist/mp-front-cli-adapter.es.js +174 -0
- package/dist/mp-front-cli-all.es.js +16 -13
- package/dist/mp-front-cli-cache.es.js +38 -47
- package/dist/mp-front-cli-core.es.js +232 -1659
- package/dist/mp-front-cli-encoder.es.js +3704 -3
- package/dist/mp-front-cli-encrypter.es.js +51 -4
- package/dist/mp-front-cli-header.es.js +5 -4
- package/dist/stringify-788d71a0.js +9 -0
- package/package.json +11 -9
- package/dist/custom-encoder-05d6a9f1.js +0 -3712
- package/dist/custom-encrypter-1573699a.js +0 -20317
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { C as Z } from "./custom-redis-bee66564.js";
|
|
2
|
+
import { u as $ } from "./stringify-788d71a0.js";
|
|
3
|
+
import "ioredis";
|
|
4
|
+
let x;
|
|
5
|
+
const v = new Uint8Array(16);
|
|
6
|
+
function C() {
|
|
7
|
+
if (!x && (x = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !x))
|
|
8
|
+
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
9
|
+
return x(v);
|
|
10
|
+
}
|
|
11
|
+
const G = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), A = {
|
|
12
|
+
randomUUID: G
|
|
13
|
+
};
|
|
14
|
+
function H(c, s, r) {
|
|
15
|
+
if (A.randomUUID && !s && !c)
|
|
16
|
+
return A.randomUUID();
|
|
17
|
+
c = c || {};
|
|
18
|
+
const i = c.random || (c.rng || C)();
|
|
19
|
+
if (i[6] = i[6] & 15 | 64, i[8] = i[8] & 63 | 128, s) {
|
|
20
|
+
r = r || 0;
|
|
21
|
+
for (let u = 0; u < 16; ++u)
|
|
22
|
+
s[r + u] = i[u];
|
|
23
|
+
return s;
|
|
24
|
+
}
|
|
25
|
+
return $(i);
|
|
26
|
+
}
|
|
27
|
+
const L = process.env.PREFIX_LOGIN, B = process.env.TIMEOUT_SESSION_MINUTES, q = {
|
|
28
|
+
baseKeyPrefix: `${L}:`,
|
|
29
|
+
userKeyPrefix: "user:",
|
|
30
|
+
accountKeyPrefix: "account:",
|
|
31
|
+
accountByUserIdPrefix: "account:user:",
|
|
32
|
+
sessionKeyPrefix: "session:",
|
|
33
|
+
sessionByUserIdPrefix: "session:user:",
|
|
34
|
+
userByEmailKeyPrefix: "user:email:",
|
|
35
|
+
verificationKeyPrefix: "verification:",
|
|
36
|
+
expire: B * 60
|
|
37
|
+
}, z = (c) => {
|
|
38
|
+
for (const s in c)
|
|
39
|
+
return !1;
|
|
40
|
+
return !0;
|
|
41
|
+
}, J = /(\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))/, Q = (c) => c && J.test(c) && !Number.isNaN(Date.parse(c));
|
|
42
|
+
function te(c = { expire: B * 60 }) {
|
|
43
|
+
const s = Z, r = {
|
|
44
|
+
...q,
|
|
45
|
+
...c
|
|
46
|
+
}, i = r.baseKeyPrefix || "", u = i + r.userKeyPrefix, b = i + r.userByEmailKeyPrefix, k = i + r.accountKeyPrefix, T = i + r.accountByUserIdPrefix, D = i + r.sessionKeyPrefix, V = i + r.sessionByUserIdPrefix, j = i + r.verificationKeyPrefix, U = (e) => b + e, p = (e) => u + e, K = (e) => k + e, f = (e) => T + e, m = (e, t) => `${t}:${e}`, I = (e) => D + e, l = (e) => V + e, g = (e) => j + e, w = async (e, t) => {
|
|
47
|
+
const n = Object.entries(t).reduce((o, [S, a]) => (o[S] = a instanceof Date ? a.toISOString() : a, o), {});
|
|
48
|
+
await s.hset(e, n), await s.expire(e, r.expire);
|
|
49
|
+
}, y = async (e) => {
|
|
50
|
+
const t = await s.hgetall(e);
|
|
51
|
+
return !t || z(t) ? null : Object.entries(t).reduce((o, [S, a]) => (o[S] = Q(a) ? new Date(a) : a, o), {});
|
|
52
|
+
}, E = async (e, t) => (await w(p(e), t), t.email && await s.set(
|
|
53
|
+
U(t.email),
|
|
54
|
+
e,
|
|
55
|
+
"EX",
|
|
56
|
+
r.expire
|
|
57
|
+
), t), d = async (e) => {
|
|
58
|
+
const t = await y(p(e));
|
|
59
|
+
return t ? { ...t } : null;
|
|
60
|
+
}, N = async (e, t) => {
|
|
61
|
+
const n = K(e);
|
|
62
|
+
await w(n, t), await s.set(
|
|
63
|
+
f(t.userId),
|
|
64
|
+
n,
|
|
65
|
+
"EX",
|
|
66
|
+
r.expire
|
|
67
|
+
);
|
|
68
|
+
}, R = async (e) => {
|
|
69
|
+
const t = await y(K(e));
|
|
70
|
+
return t ? { ...t } : null;
|
|
71
|
+
}, h = async (e) => {
|
|
72
|
+
const t = K(e), n = await y(t);
|
|
73
|
+
if (!n)
|
|
74
|
+
return null;
|
|
75
|
+
await s.hdel(t), await s.del(f(n.userId));
|
|
76
|
+
}, O = async (e, t) => {
|
|
77
|
+
const n = I(e);
|
|
78
|
+
return await w(n, t), await s.set(
|
|
79
|
+
l(t.userId),
|
|
80
|
+
n,
|
|
81
|
+
"EX",
|
|
82
|
+
r.expire
|
|
83
|
+
), t;
|
|
84
|
+
}, P = async (e) => {
|
|
85
|
+
const t = await y(I(e));
|
|
86
|
+
return t ? {
|
|
87
|
+
id: t.id,
|
|
88
|
+
...t
|
|
89
|
+
} : null;
|
|
90
|
+
}, _ = async (e) => {
|
|
91
|
+
const t = await P(e);
|
|
92
|
+
if (!t)
|
|
93
|
+
return null;
|
|
94
|
+
const n = I(e);
|
|
95
|
+
await s.del(n), await s.del(l(t.userId));
|
|
96
|
+
}, X = async (e, t) => {
|
|
97
|
+
const n = g(e);
|
|
98
|
+
return await w(n, t), t;
|
|
99
|
+
}, M = async (e) => {
|
|
100
|
+
const t = g(e), n = await y(t);
|
|
101
|
+
return n ? { identifier: n.identifier, ...n } : null;
|
|
102
|
+
}, F = async (e) => {
|
|
103
|
+
const t = g(e);
|
|
104
|
+
await s.del(t);
|
|
105
|
+
};
|
|
106
|
+
return {
|
|
107
|
+
async createUser(e) {
|
|
108
|
+
const t = H();
|
|
109
|
+
return await E(t, { ...e, id: t });
|
|
110
|
+
},
|
|
111
|
+
getUser: d,
|
|
112
|
+
async getUserByEmail(e) {
|
|
113
|
+
const t = await s.get(U(e));
|
|
114
|
+
return t ? await d(t) : null;
|
|
115
|
+
},
|
|
116
|
+
async getUserByAccount({ providerAccountId: e, provider: t }) {
|
|
117
|
+
const n = await R(
|
|
118
|
+
m(e, t)
|
|
119
|
+
);
|
|
120
|
+
return n ? await d(n.userId) : null;
|
|
121
|
+
},
|
|
122
|
+
async updateUser(e) {
|
|
123
|
+
const t = e.id, n = await d(t);
|
|
124
|
+
return await E(t, { ...n, ...e });
|
|
125
|
+
},
|
|
126
|
+
async deleteUser(e) {
|
|
127
|
+
const t = await d(e);
|
|
128
|
+
if (!t)
|
|
129
|
+
return null;
|
|
130
|
+
const n = await s.get(f(e)), o = await s.get(l(e));
|
|
131
|
+
await s.del(
|
|
132
|
+
U(t.email),
|
|
133
|
+
f(e),
|
|
134
|
+
l(e)
|
|
135
|
+
), o && await s.del(o), n && await s.del(n), await s.del(p(e));
|
|
136
|
+
},
|
|
137
|
+
async linkAccount(e) {
|
|
138
|
+
const t = m(e.providerAccountId, e.provider);
|
|
139
|
+
return await N(t, { ...e, id: t });
|
|
140
|
+
},
|
|
141
|
+
async unlinkAccount({ providerAccountId: e, provider: t }) {
|
|
142
|
+
const n = m(e, t);
|
|
143
|
+
await h(n);
|
|
144
|
+
},
|
|
145
|
+
async createSession(e) {
|
|
146
|
+
const t = e.sessionToken;
|
|
147
|
+
return await O(t, { ...e, id: t });
|
|
148
|
+
},
|
|
149
|
+
async getSessionAndUser(e) {
|
|
150
|
+
const n = await P(e);
|
|
151
|
+
if (!n)
|
|
152
|
+
return null;
|
|
153
|
+
const o = await d(n.userId);
|
|
154
|
+
return o ? { session: n, user: o } : null;
|
|
155
|
+
},
|
|
156
|
+
async updateSession(e) {
|
|
157
|
+
const t = e.sessionToken, n = await P(t);
|
|
158
|
+
return n ? await O(t, { ...n, ...e }) : null;
|
|
159
|
+
},
|
|
160
|
+
deleteSession: _,
|
|
161
|
+
async createVerificationToken(e) {
|
|
162
|
+
const t = e.identifier;
|
|
163
|
+
return await X(t, e), e;
|
|
164
|
+
},
|
|
165
|
+
async useVerificationToken(e) {
|
|
166
|
+
const t = e.identifier, n = await M(t);
|
|
167
|
+
return !n || e.token !== n.token ? null : (await F(t), n);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
export {
|
|
172
|
+
te as IORedisAdapter,
|
|
173
|
+
q as defaultOptions
|
|
174
|
+
};
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import { ApiMiddleware as
|
|
2
|
-
import { S as
|
|
3
|
-
import { LoadingHandler as
|
|
1
|
+
import { ApiMiddleware as S, ErrorCatalog as g, FetchServiceBE as l, FetchServiceFE as x } from "./mp-front-cli-core.es.js";
|
|
2
|
+
import { S as s } from "./custom-header-3ba5652e.js";
|
|
3
|
+
import { LoadingHandler as E, MessageHandler as F, RxSubjectManager as M } from "./mp-front-cli-utils-rxjs.es.js";
|
|
4
|
+
import "i18next";
|
|
4
5
|
import "./index-df4e0539.js";
|
|
5
6
|
import "./mp-front-cli-logger.es.js";
|
|
6
7
|
import "rxjs";
|
|
7
|
-
import "./
|
|
8
|
-
import "
|
|
8
|
+
import "./mp-front-cli-encrypter.es.js";
|
|
9
|
+
import "node-jose";
|
|
9
10
|
import "crypto";
|
|
11
|
+
import "./mp-front-cli-encoder.es.js";
|
|
12
|
+
import "./stringify-788d71a0.js";
|
|
10
13
|
export {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
S as ApiMiddleware,
|
|
15
|
+
g as ErrorCatalog,
|
|
16
|
+
l as FetchServiceBE,
|
|
17
|
+
x as FetchServiceFE,
|
|
18
|
+
E as LoadingHandler,
|
|
19
|
+
F as MessageHandler,
|
|
20
|
+
M as RxSubjectManager,
|
|
21
|
+
s as ServiceToken
|
|
19
22
|
};
|
|
@@ -1,25 +1,17 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import
|
|
5
|
-
import { C as
|
|
6
|
-
import "
|
|
7
|
-
import "./mp-front-cli-logger.es.js";
|
|
1
|
+
var a = Object.defineProperty;
|
|
2
|
+
var m = (o, s, t) => s in o ? a(o, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[s] = t;
|
|
3
|
+
var l = (o, s, t) => (m(o, typeof s != "symbol" ? s + "" : s, t), t);
|
|
4
|
+
import { CustomEncrypter as u } from "./mp-front-cli-encrypter.es.js";
|
|
5
|
+
import { C as d } from "./custom-redis-bee66564.js";
|
|
6
|
+
import "node-jose";
|
|
8
7
|
import "crypto";
|
|
9
|
-
|
|
8
|
+
import "./mp-front-cli-encoder.es.js";
|
|
9
|
+
import "./mp-front-cli-logger.es.js";
|
|
10
|
+
import "ioredis";
|
|
11
|
+
class N extends u {
|
|
10
12
|
constructor() {
|
|
11
13
|
super(...arguments);
|
|
12
|
-
|
|
13
|
-
S(this, "REDIS_PORT", process.env.REDIS_PORT);
|
|
14
|
-
S(this, "REDIS_USER", process.env.REDIS_USER);
|
|
15
|
-
S(this, "REDIS_PASS", process.env.REDIS_PASS);
|
|
16
|
-
S(this, "initClient", new y({
|
|
17
|
-
host: this.REDIS_HOST,
|
|
18
|
-
port: this.REDIS_PORT,
|
|
19
|
-
username: this.REDIS_USER,
|
|
20
|
-
password: this.REDIS_PASS,
|
|
21
|
-
tls: {}
|
|
22
|
-
}));
|
|
14
|
+
l(this, "initClient", d);
|
|
23
15
|
}
|
|
24
16
|
getRootNode(t) {
|
|
25
17
|
return this.initClient.get(t);
|
|
@@ -31,41 +23,34 @@ class I extends l {
|
|
|
31
23
|
throw new Error("Not found entry point");
|
|
32
24
|
}
|
|
33
25
|
}
|
|
34
|
-
setEntryPoint(t,
|
|
35
|
-
const
|
|
36
|
-
this.initClient.set(t,
|
|
37
|
-
}
|
|
38
|
-
getSubNode(t, e) {
|
|
39
|
-
return t in e ? e[t] : null;
|
|
40
|
-
}
|
|
41
|
-
setSubNode(t, e, n) {
|
|
42
|
-
const i = { ...e };
|
|
43
|
-
return t in i || (i[t] = n), i;
|
|
26
|
+
setEntryPoint(t, i, e) {
|
|
27
|
+
const n = typeof i == "string" ? i : JSON.stringify(i);
|
|
28
|
+
this.initClient.set(t, n, "EX", 60 * e);
|
|
44
29
|
}
|
|
45
|
-
async getRedisState(t,
|
|
46
|
-
const
|
|
47
|
-
return r > 0 && this.ttl(
|
|
30
|
+
async getRedisState(t, i) {
|
|
31
|
+
const e = `${t}:${this.generateSHA(i)}`, n = await this.getEntryPoint(e), c = await this.isEncrypted(n) ? await this.decrypt(n ?? "") : JSON.parse(n), r = Number(c == null ? void 0 : c.expires_in);
|
|
32
|
+
return r > 0 && this.ttl(e, r * 60), { sha: e, data: c };
|
|
48
33
|
}
|
|
49
34
|
async setRedisState({
|
|
50
35
|
idApi: t,
|
|
51
|
-
idData:
|
|
52
|
-
body:
|
|
53
|
-
expire:
|
|
54
|
-
encrypted:
|
|
36
|
+
idData: i,
|
|
37
|
+
body: e,
|
|
38
|
+
expire: n,
|
|
39
|
+
encrypted: h = !1,
|
|
55
40
|
refresh: c = "REFRESH"
|
|
56
41
|
/* REFRESH */
|
|
57
42
|
}) {
|
|
58
|
-
const r = `${t}:${this.generateSHA(
|
|
59
|
-
if (
|
|
60
|
-
const
|
|
61
|
-
return this.setEntryPoint(r,
|
|
43
|
+
const r = `${t}:${this.generateSHA(i)}`, y = { expires_in: c === "REFRESH" ? n : 0, ...e };
|
|
44
|
+
if (h) {
|
|
45
|
+
const p = await this.encrypt(y);
|
|
46
|
+
return this.setEntryPoint(r, p, n), r;
|
|
62
47
|
}
|
|
63
|
-
return this.setEntryPoint(r,
|
|
48
|
+
return this.setEntryPoint(r, y, n), r;
|
|
64
49
|
}
|
|
65
50
|
async statusHost() {
|
|
66
|
-
return new Promise((t,
|
|
67
|
-
this.initClient.on("error", (
|
|
68
|
-
this.killRedis(), e
|
|
51
|
+
return new Promise((t, i) => {
|
|
52
|
+
this.initClient.on("error", (e) => {
|
|
53
|
+
this.killRedis(), i(e);
|
|
69
54
|
}), this.initClient.on("connect", () => {
|
|
70
55
|
t("success");
|
|
71
56
|
});
|
|
@@ -77,10 +62,16 @@ class I extends l {
|
|
|
77
62
|
deleteKey(t) {
|
|
78
63
|
this.initClient.del(t);
|
|
79
64
|
}
|
|
80
|
-
ttl(t,
|
|
81
|
-
this.initClient.expire(t,
|
|
65
|
+
ttl(t, i) {
|
|
66
|
+
this.initClient.expire(t, i);
|
|
67
|
+
}
|
|
68
|
+
simpleGet(t) {
|
|
69
|
+
return this.initClient.get(t);
|
|
70
|
+
}
|
|
71
|
+
simpleHGet(t, i) {
|
|
72
|
+
return this.initClient.hget(t, i);
|
|
82
73
|
}
|
|
83
74
|
}
|
|
84
75
|
export {
|
|
85
|
-
|
|
76
|
+
N as CustomCache
|
|
86
77
|
};
|