mp-front-cli 0.0.55 → 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.
@@ -1,6 +1,31 @@
1
- import { v as R } from "./v4-8464ab21.js";
2
- const F = process.env.PREFIX_LOGIN, O = process.env.TIMEOUT_SESSION_MINUTES, Z = {
3
- baseKeyPrefix: `${F}:`,
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: O * 60
12
- }, $ = (s) => {
13
- for (const p in s)
36
+ expire: B * 60
37
+ }, z = (c) => {
38
+ for (const s in c)
14
39
  return !1;
15
40
  return !0;
16
- }, G = /(\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))/, H = (s) => s && G.test(s) && !isNaN(Date.parse(s));
17
- function v(s, p = { expire: O * 60 }) {
18
- const r = {
19
- ...Z,
20
- ...p
21
- }, a = r.baseKeyPrefix || "", B = a + r.userKeyPrefix, m = a + r.userByEmailKeyPrefix, A = a + r.accountKeyPrefix, k = a + r.accountByUserIdPrefix, T = a + r.sessionKeyPrefix, b = a + r.sessionByUserIdPrefix, j = a + r.verificationKeyPrefix, w = (e) => m + e, l = (e) => B + e, x = (e) => A + e, d = (e) => k + e, K = (e, t) => `${t}:${e}`, P = (e) => T + e, y = (e) => b + e, I = (e) => j + e, f = async (e, t) => {
22
- const n = Object.entries(t).reduce((i, [g, o]) => (i[g] = o instanceof Date ? o.toISOString() : o, i), {});
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
- }, u = async (e) => {
49
+ }, y = async (e) => {
25
50
  const t = await s.hgetall(e);
26
- return !t || $(t) ? null : Object.entries(t).reduce((i, [g, o]) => (i[g] = H(o) ? new Date(o) : o, i), {});
27
- }, E = async (e, t) => (await f(l(e), t), t.email && await s.set(
28
- w(t.email),
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), c = async (e) => {
33
- const t = await u(l(e));
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 = x(e);
37
- await f(n, t), await s.set(
38
- d(t.userId),
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
- }, V = async (e) => {
44
- const t = await u(x(e));
68
+ }, R = async (e) => {
69
+ const t = await y(K(e));
45
70
  return t ? { ...t } : null;
46
- }, _ = async (e) => {
47
- const t = x(e), n = await u(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(d(n.userId));
51
- }, S = async (e, t) => {
52
- const n = P(e);
53
- return await f(n, t), await s.set(
54
- y(t.userId),
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
- }, U = async (e) => {
60
- const t = await u(P(e));
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
- }, h = async (e) => {
66
- const t = await U(e);
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
- return await f(n, t), t;
74
- }, X = async (e) => {
75
- const t = I(e), n = await u(t);
76
- return n ? { identifier: n.identifier, ...n } : null;
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 = I(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);
79
104
  await s.del(t);
80
105
  };
81
106
  return {
82
107
  async createUser(e) {
83
- const t = R();
108
+ const t = H();
84
109
  return await E(t, { ...e, id: t });
85
110
  },
86
- getUser: c,
111
+ getUser: d,
87
112
  async getUserByEmail(e) {
88
- const t = await s.get(w(e));
89
- return t ? await c(t) : null;
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 V(
93
- K(e, t)
117
+ const n = await R(
118
+ m(e, t)
94
119
  );
95
- return n ? await c(n.userId) : null;
120
+ return n ? await d(n.userId) : null;
96
121
  },
97
122
  async updateUser(e) {
98
- const t = e.id, n = await c(t);
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 c(e);
127
+ const t = await d(e);
103
128
  if (!t)
104
129
  return null;
105
- const n = await s.get(d(e)), i = await s.get(y(e));
130
+ const n = await s.get(f(e)), o = await s.get(l(e));
106
131
  await s.del(
107
- w(t.email),
108
- d(e),
109
- y(e)
110
- ), i && await s.del(i), n && await s.del(n), await s.del(l(e));
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 = K(e.providerAccountId, e.provider);
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 = K(e, t);
118
- await _(n);
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 S(t, { ...e, id: t });
147
+ return await O(t, { ...e, id: t });
123
148
  },
124
149
  async getSessionAndUser(e) {
125
- const n = await U(e);
150
+ const n = await P(e);
126
151
  if (!n)
127
152
  return null;
128
- const i = await c(n.userId);
129
- return i ? { session: n, user: i } : null;
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 U(t);
133
- return n ? await S(t, { ...n, ...e }) : null;
157
+ const t = e.sessionToken, n = await P(t);
158
+ return n ? await O(t, { ...n, ...e }) : null;
134
159
  },
135
- deleteSession: h,
160
+ deleteSession: _,
136
161
  async createVerificationToken(e) {
137
162
  const t = e.identifier;
138
- return await D(t, e), e;
163
+ return await X(t, e), e;
139
164
  },
140
165
  async useVerificationToken(e) {
141
- const t = e.identifier, n = await X(t);
142
- return !n || e.token !== n.token ? null : (await M(t), n);
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
- v as IORedisAdapter,
148
- Z as defaultOptions
172
+ te as IORedisAdapter,
173
+ q as defaultOptions
149
174
  };
@@ -1,20 +1,22 @@
1
- import { ApiMiddleware as d, ErrorCatalog as n, FetchServiceBE as S, FetchServiceFE as g } from "./mp-front-cli-core.es.js";
2
- import { S as x } from "./custom-header-db08aa72.js";
3
- import { LoadingHandler as s, MessageHandler as v, RxSubjectManager as E } from "./mp-front-cli-utils-rxjs.es.js";
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 "./custom-encrypter-e3901c44.js";
8
- import "./custom-encoder-70a77460.js";
8
+ import "./mp-front-cli-encrypter.es.js";
9
+ import "node-jose";
9
10
  import "crypto";
10
- import "./v4-8464ab21.js";
11
+ import "./mp-front-cli-encoder.es.js";
12
+ import "./stringify-788d71a0.js";
11
13
  export {
12
- d as ApiMiddleware,
13
- n as ErrorCatalog,
14
- S as FetchServiceBE,
15
- g as FetchServiceFE,
16
- s as LoadingHandler,
17
- v as MessageHandler,
18
- E as RxSubjectManager,
19
- x as ServiceToken
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,17 @@
1
- var p = Object.defineProperty;
2
- var a = (o, s, t) => s in o ? p(o, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[s] = t;
3
- var S = (o, s, t) => (a(o, typeof s != "symbol" ? s + "" : s, t), t);
4
- import y from "ioredis";
5
- import { C as l } from "./custom-encrypter-e3901c44.js";
6
- import "./custom-encoder-70a77460.js";
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
- import "./v4-8464ab21.js";
10
- class f extends l {
8
+ import "./mp-front-cli-encoder.es.js";
9
+ import "./mp-front-cli-logger.es.js";
10
+ import "ioredis";
11
+ class N extends u {
11
12
  constructor() {
12
13
  super(...arguments);
13
- S(this, "REDIS_HOST", process.env.REDIS_HOST);
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
- }));
14
+ l(this, "initClient", d);
24
15
  }
25
16
  getRootNode(t) {
26
17
  return this.initClient.get(t);
@@ -32,41 +23,34 @@ class f extends l {
32
23
  throw new Error("Not found entry point");
33
24
  }
34
25
  }
35
- setEntryPoint(t, e, n) {
36
- const i = typeof e == "string" ? e : JSON.stringify(e);
37
- this.initClient.set(t, i, "EX", 60 * n);
38
- }
39
- getSubNode(t, e) {
40
- return t in e ? e[t] : null;
41
- }
42
- setSubNode(t, e, n) {
43
- const i = { ...e };
44
- 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);
45
29
  }
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 };
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 };
49
33
  }
50
34
  async setRedisState({
51
35
  idApi: t,
52
- idData: e,
53
- body: n,
54
- expire: i,
55
- encrypted: E = !1,
36
+ idData: i,
37
+ body: e,
38
+ expire: n,
39
+ encrypted: h = !1,
56
40
  refresh: c = "REFRESH"
57
41
  /* REFRESH */
58
42
  }) {
59
- const r = `${t}:${this.generateSHA(e)}`, h = { expires_in: c === "REFRESH" ? i : 0, ...n };
60
- if (E) {
61
- const R = await this.encrypt(h);
62
- return this.setEntryPoint(r, R, i), 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;
63
47
  }
64
- return this.setEntryPoint(r, h, i), r;
48
+ return this.setEntryPoint(r, y, n), r;
65
49
  }
66
50
  async statusHost() {
67
- return new Promise((t, e) => {
68
- this.initClient.on("error", (n) => {
69
- this.killRedis(), e(n);
51
+ return new Promise((t, i) => {
52
+ this.initClient.on("error", (e) => {
53
+ this.killRedis(), i(e);
70
54
  }), this.initClient.on("connect", () => {
71
55
  t("success");
72
56
  });
@@ -78,10 +62,16 @@ class f extends l {
78
62
  deleteKey(t) {
79
63
  this.initClient.del(t);
80
64
  }
81
- ttl(t, e) {
82
- this.initClient.expire(t, e);
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);
83
73
  }
84
74
  }
85
75
  export {
86
- f as CustomCache
76
+ N as CustomCache
87
77
  };