mp-front-cli 0.0.54 → 0.0.55

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.
@@ -3,7 +3,7 @@ var J = (r, t, e) => t in r ? G(r, t, { enumerable: !0, configurable: !0, writab
3
3
  var v = (r, t, e) => (J(r, typeof t != "symbol" ? t + "" : t, e), e);
4
4
  import { switchMap as g, of as T, catchError as V } from "rxjs";
5
5
  import { CustomLogger as q } from "./mp-front-cli-logger.es.js";
6
- import { C as z } from "./custom-encrypter-1573699a.js";
6
+ import { C as z } from "./custom-encrypter-e3901c44.js";
7
7
  var O = function(r, t) {
8
8
  return O = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, n) {
9
9
  e.__proto__ = n;
@@ -0,0 +1,149 @@
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}:`,
4
+ userKeyPrefix: "user:",
5
+ accountKeyPrefix: "account:",
6
+ accountByUserIdPrefix: "account:user:",
7
+ sessionKeyPrefix: "session:",
8
+ sessionByUserIdPrefix: "session:user:",
9
+ userByEmailKeyPrefix: "user:email:",
10
+ verificationKeyPrefix: "verification:",
11
+ expire: O * 60
12
+ }, $ = (s) => {
13
+ for (const p in s)
14
+ return !1;
15
+ 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), {});
23
+ await s.hset(e, n), await s.expire(e, r.expire);
24
+ }, u = async (e) => {
25
+ 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),
29
+ e,
30
+ "EX",
31
+ r.expire
32
+ ), t), c = async (e) => {
33
+ const t = await u(l(e));
34
+ return t ? { ...t } : null;
35
+ }, N = async (e, t) => {
36
+ const n = x(e);
37
+ await f(n, t), await s.set(
38
+ d(t.userId),
39
+ n,
40
+ "EX",
41
+ r.expire
42
+ );
43
+ }, V = async (e) => {
44
+ const t = await u(x(e));
45
+ return t ? { ...t } : null;
46
+ }, _ = async (e) => {
47
+ const t = x(e), n = await u(t);
48
+ if (!n)
49
+ 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),
55
+ n,
56
+ "EX",
57
+ r.expire
58
+ ), t;
59
+ }, U = async (e) => {
60
+ const t = await u(P(e));
61
+ return t ? {
62
+ id: t.id,
63
+ ...t
64
+ } : null;
65
+ }, h = async (e) => {
66
+ const t = await U(e);
67
+ if (!t)
68
+ return null;
69
+ const n = P(e);
70
+ await s.del(n), await s.del(y(t.userId));
71
+ }, D = async (e, t) => {
72
+ 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;
77
+ }, M = async (e) => {
78
+ const t = I(e);
79
+ await s.del(t);
80
+ };
81
+ return {
82
+ async createUser(e) {
83
+ const t = R();
84
+ return await E(t, { ...e, id: t });
85
+ },
86
+ getUser: c,
87
+ async getUserByEmail(e) {
88
+ const t = await s.get(w(e));
89
+ return t ? await c(t) : null;
90
+ },
91
+ async getUserByAccount({ providerAccountId: e, provider: t }) {
92
+ const n = await V(
93
+ K(e, t)
94
+ );
95
+ return n ? await c(n.userId) : null;
96
+ },
97
+ async updateUser(e) {
98
+ const t = e.id, n = await c(t);
99
+ return await E(t, { ...n, ...e });
100
+ },
101
+ async deleteUser(e) {
102
+ const t = await c(e);
103
+ if (!t)
104
+ return null;
105
+ const n = await s.get(d(e)), i = await s.get(y(e));
106
+ 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));
111
+ },
112
+ async linkAccount(e) {
113
+ const t = K(e.providerAccountId, e.provider);
114
+ return await N(t, { ...e, id: t });
115
+ },
116
+ async unlinkAccount({ providerAccountId: e, provider: t }) {
117
+ const n = K(e, t);
118
+ await _(n);
119
+ },
120
+ async createSession(e) {
121
+ const t = e.sessionToken;
122
+ return await S(t, { ...e, id: t });
123
+ },
124
+ async getSessionAndUser(e) {
125
+ const n = await U(e);
126
+ if (!n)
127
+ return null;
128
+ const i = await c(n.userId);
129
+ return i ? { session: n, user: i } : null;
130
+ },
131
+ async updateSession(e) {
132
+ const t = e.sessionToken, n = await U(t);
133
+ return n ? await S(t, { ...n, ...e }) : null;
134
+ },
135
+ deleteSession: h,
136
+ async createVerificationToken(e) {
137
+ const t = e.identifier;
138
+ return await D(t, e), e;
139
+ },
140
+ async useVerificationToken(e) {
141
+ const t = e.identifier, n = await X(t);
142
+ return !n || e.token !== n.token ? null : (await M(t), n);
143
+ }
144
+ };
145
+ }
146
+ export {
147
+ v as IORedisAdapter,
148
+ Z as defaultOptions
149
+ };
@@ -1,19 +1,20 @@
1
- import { ApiMiddleware as c, ErrorCatalog as d, FetchServiceBE as n, FetchServiceFE as S } from "./mp-front-cli-core.es.js";
2
- import { S as l } from "./custom-header-eeb04e28.js";
3
- import { LoadingHandler as f, MessageHandler as s, RxSubjectManager as v } from "./mp-front-cli-utils-rxjs.es.js";
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";
4
4
  import "./index-df4e0539.js";
5
5
  import "./mp-front-cli-logger.es.js";
6
6
  import "rxjs";
7
- import "./custom-encrypter-1573699a.js";
8
- import "./custom-encoder-05d6a9f1.js";
7
+ import "./custom-encrypter-e3901c44.js";
8
+ import "./custom-encoder-70a77460.js";
9
9
  import "crypto";
10
+ import "./v4-8464ab21.js";
10
11
  export {
11
- c as ApiMiddleware,
12
- d as ErrorCatalog,
13
- n as FetchServiceBE,
14
- S as FetchServiceFE,
15
- f as LoadingHandler,
16
- s as MessageHandler,
17
- v as RxSubjectManager,
18
- l as ServiceToken
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
19
20
  };
@@ -2,11 +2,12 @@ var p = Object.defineProperty;
2
2
  var a = (o, s, t) => s in o ? p(o, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[s] = t;
3
3
  var S = (o, s, t) => (a(o, typeof s != "symbol" ? s + "" : s, t), t);
4
4
  import y from "ioredis";
5
- import { C as l } from "./custom-encrypter-1573699a.js";
6
- import "./custom-encoder-05d6a9f1.js";
5
+ import { C as l } from "./custom-encrypter-e3901c44.js";
6
+ import "./custom-encoder-70a77460.js";
7
7
  import "./mp-front-cli-logger.es.js";
8
8
  import "crypto";
9
- class I extends l {
9
+ import "./v4-8464ab21.js";
10
+ class f extends l {
10
11
  constructor() {
11
12
  super(...arguments);
12
13
  S(this, "REDIS_HOST", process.env.REDIS_HOST);
@@ -82,5 +83,5 @@ class I extends l {
82
83
  }
83
84
  }
84
85
  export {
85
- I as CustomCache
86
+ f as CustomCache
86
87
  };