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