mp-front-cli 2.3.2-next.0 → 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-CATazTYM.cjs → AuthEngine-CDNhQfnX.cjs} +1 -1
- package/dist/{AuthEngine-CQfKuww8.js → AuthEngine-T4Nti8Ya.js} +227 -238
- package/dist/core/services/service-token.d.ts +1 -2
- package/dist/core/services/service-token.d.ts.map +1 -1
- package/dist/core/utils/api-request/fetch-service-parent-be.d.ts +1 -3
- package/dist/core/utils/api-request/fetch-service-parent-be.d.ts.map +1 -1
- package/dist/core/utils/custom-encrypter.d.ts +4 -11
- package/dist/core/utils/custom-encrypter.d.ts.map +1 -1
- package/dist/core/utils/custom-header.d.ts +2 -6
- package/dist/core/utils/custom-header.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 +2 -2
- package/dist/mp-front-cli-core.cjs +1 -1
- package/dist/mp-front-cli-core.js +2 -2
- package/dist/mp-front-cli-encrypter.cjs +1 -1
- package/dist/mp-front-cli-encrypter.js +32 -63
- package/dist/mp-front-cli-header.cjs +1 -1
- package/dist/mp-front-cli-header.js +17 -18
- package/dist/mp-front-cli-services.cjs +1 -1
- package/dist/mp-front-cli-services.js +1 -1
- package/dist/{service-token-DrUMHiYQ.js → service-token-BfQQMCM4.js} +166 -174
- package/dist/service-token-CPZee3-I.cjs +3 -0
- package/dist/stringify-BbkhfUoJ.js +9 -0
- package/dist/{stringify-BN6t_WDt.cjs → stringify-Ixz5_KTs.cjs} +1 -1
- package/package.json +7 -8
- package/dist/service-token-g-Zt_ctQ.cjs +0 -3
- package/dist/stringify-93tp0umt.js +0 -9
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { CustomLogger } from '../utils/custom-logger';
|
|
2
2
|
export declare class ServiceToken extends CustomLogger {
|
|
3
|
-
private customEncrypter;
|
|
4
3
|
private API_AUTH_BACK_URL;
|
|
5
4
|
private API_AUTH_BACK_USERNAME_AUTH;
|
|
6
5
|
private API_AUTH_BACK_PASSWORD_AUTH;
|
|
7
6
|
private headers;
|
|
8
7
|
private ID;
|
|
9
8
|
constructor();
|
|
10
|
-
get(
|
|
9
|
+
get(): import('rxjs').Observable<any>;
|
|
11
10
|
}
|
|
12
11
|
//# sourceMappingURL=service-token.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-token.d.ts","sourceRoot":"","sources":["../../../src/core/services/service-token.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"service-token.d.ts","sourceRoot":"","sources":["../../../src/core/services/service-token.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAErD,qBAAa,YAAa,SAAQ,YAAY;IAC5C,OAAO,CAAC,iBAAiB,CAAQ;IACjC,OAAO,CAAC,2BAA2B,CAAQ;IAC3C,OAAO,CAAC,2BAA2B,CAAQ;IAC3C,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,EAAE,CAA0C;;IAcpD,GAAG;CA6BJ"}
|
|
@@ -9,9 +9,7 @@ export declare abstract class FetchServiceParentBE<TRes, TData = object, TypeDat
|
|
|
9
9
|
constructor(apiUrl: string, method?: Method, headers?: HeadersInit);
|
|
10
10
|
private errorHandler;
|
|
11
11
|
private formatParams;
|
|
12
|
-
fetchData(params?: TData, uuid?: string,
|
|
13
|
-
encryptCredentials?: boolean;
|
|
14
|
-
}): Observable<ApiResponse<TRes, TypeDataResponse, Relationships>>;
|
|
12
|
+
fetchData(params?: TData, uuid?: string): Observable<ApiResponse<TRes, TypeDataResponse, Relationships>>;
|
|
15
13
|
fetchCustomData(params?: TData, uuid?: string, useToken?: boolean): Observable<TRes>;
|
|
16
14
|
protected abstract onInit(): OnInit;
|
|
17
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-service-parent-be.d.ts","sourceRoot":"","sources":["../../../../src/core/utils/api-request/fetch-service-parent-be.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAA0B,MAAM,MAAM,CAAA;AAEpE,OAAO,KAAK,EACV,WAAW,EACX,MAAM,EACN,iBAAiB,EAClB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAM/C,8BAAsB,oBAAoB,CACxC,IAAI,EACJ,KAAK,GAAG,MAAM,EACd,gBAAgB,SAAS,iBAAiB,GAAG,QAAQ,EACrD,aAAa,GAAG,MAAM,CACtB,SAAQ,YAAY;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;IAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;IAC/B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAqB;gBAEtC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB;IAMtE,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,YAAY;IASpB,SAAS,CACP,MAAM,GAAE,KAAmB,EAC3B,IAAI,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"fetch-service-parent-be.d.ts","sourceRoot":"","sources":["../../../../src/core/utils/api-request/fetch-service-parent-be.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAA0B,MAAM,MAAM,CAAA;AAEpE,OAAO,KAAK,EACV,WAAW,EACX,MAAM,EACN,iBAAiB,EAClB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAM/C,8BAAsB,oBAAoB,CACxC,IAAI,EACJ,KAAK,GAAG,MAAM,EACd,gBAAgB,SAAS,iBAAiB,GAAG,QAAQ,EACrD,aAAa,GAAG,MAAM,CACtB,SAAQ,YAAY;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;IAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;IAC/B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAqB;gBAEtC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB;IAMtE,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,YAAY;IASpB,SAAS,CACP,MAAM,GAAE,KAAmB,EAC3B,IAAI,CAAC,EAAE,MAAM,GACZ,UAAU,CAAC,WAAW,CAAC,IAAI,EAAE,gBAAgB,EAAE,aAAa,CAAC,CAAC;IA+CjE,eAAe,CACb,MAAM,GAAE,KAAmB,EAC3B,IAAI,CAAC,EAAE,MAAM,EACb,QAAQ,CAAC,EAAE,OAAO,GACjB,UAAU,CAAC,IAAI,CAAC;IAmDnB,SAAS,CAAC,QAAQ,CAAC,MAAM,IAAI,MAAM;CACpC"}
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import { CustomEncoder } from './custom-encoder';
|
|
2
|
-
type AlgType = "jwe" | "aes";
|
|
3
2
|
export declare class CustomEncrypter extends CustomEncoder {
|
|
4
|
-
private
|
|
5
|
-
private
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
constructor(alg?: AlgType);
|
|
9
|
-
private generateAESKey;
|
|
10
|
-
private generateJWEKey;
|
|
11
|
-
encrypt<T>(payload: T): Promise<string>;
|
|
12
|
-
decrypt<T>(encrypted: string): Promise<string | T>;
|
|
3
|
+
private signatureKey;
|
|
4
|
+
private generateKey;
|
|
5
|
+
protected encrypt<T>(payload: T): Promise<string>;
|
|
6
|
+
protected decrypt<T>(encrypted: string): Promise<T>;
|
|
13
7
|
protected isEncrypted(value: string | null): Promise<boolean>;
|
|
14
8
|
protected generateSHA<T>(value: T): string;
|
|
15
9
|
}
|
|
16
|
-
export {};
|
|
17
10
|
//# sourceMappingURL=custom-encrypter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-encrypter.d.ts","sourceRoot":"","sources":["../../../src/core/utils/custom-encrypter.ts"],"names":[],"mappings":"
|
|
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"}
|
|
@@ -3,11 +3,7 @@ import { CustomEncrypter } from './custom-encrypter';
|
|
|
3
3
|
export declare class CustomHeader extends CustomEncrypter {
|
|
4
4
|
private headers;
|
|
5
5
|
constructor(headers?: HeadersInit);
|
|
6
|
-
addTokenBackend(headers: HeadersInit
|
|
7
|
-
getHeaders(
|
|
8
|
-
headers?: HeadersInit;
|
|
9
|
-
useToken?: boolean;
|
|
10
|
-
encryptCredentials?: boolean;
|
|
11
|
-
}): Observable<HeadersInit>;
|
|
6
|
+
addTokenBackend(headers: HeadersInit): Observable<HeadersInit>;
|
|
7
|
+
getHeaders(headers?: HeadersInit, useToken?: boolean): Observable<HeadersInit>;
|
|
12
8
|
}
|
|
13
9
|
//# sourceMappingURL=custom-header.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-header.d.ts","sourceRoot":"","sources":["../../../src/core/utils/custom-header.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAiB,MAAM,MAAM,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAGpD,qBAAa,YAAa,SAAQ,eAAe;IAC/C,OAAO,CAAC,OAAO,CAAa;gBAEhB,OAAO,GAAE,WAAgB;IASrC,eAAe,
|
|
1
|
+
{"version":3,"file":"custom-header.d.ts","sourceRoot":"","sources":["../../../src/core/utils/custom-header.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAiB,MAAM,MAAM,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAGpD,qBAAa,YAAa,SAAQ,eAAe;IAC/C,OAAO,CAAC,OAAO,CAAa;gBAEhB,OAAO,GAAE,WAAgB;IASrC,eAAe,CAAC,OAAO,EAAE,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC;IAS9D,UAAU,CACR,OAAO,GAAE,WAAgB,EACzB,QAAQ,UAAO,GACd,UAAU,CAAC,WAAW,CAAC;CAW3B"}
|
|
@@ -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,6 +1,6 @@
|
|
|
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
|
-
import { S as x } from "./service-token-
|
|
3
|
+
import { S as x } from "./service-token-BfQQMCM4.js";
|
|
4
4
|
export {
|
|
5
5
|
r as ApiMiddleware,
|
|
6
6
|
s as AuthEngine,
|
|
@@ -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,6 +1,6 @@
|
|
|
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
|
-
import { S as x } from "./service-token-
|
|
3
|
+
import { S as x } from "./service-token-BfQQMCM4.js";
|
|
4
4
|
export {
|
|
5
5
|
r as ApiMiddleware,
|
|
6
6
|
s as AuthEngine,
|
|
@@ -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,78 +1,47 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import E from "
|
|
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";
|
|
5
6
|
import { CustomEncoder as g } from "./mp-front-cli-encoder.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
o(this, "ALGORITHM", "aes-256-gcm");
|
|
12
|
-
o(this, "IV_LENGTH", 12);
|
|
13
|
-
o(this, "AUTH_TAG_LENGTH", 16);
|
|
14
|
-
o(this, "algType", "jwe");
|
|
15
|
-
this.algType = t;
|
|
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
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
i(this, "signatureKey");
|
|
16
12
|
}
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
if (!
|
|
20
|
-
const r = this.generateSHA(t), n = Buffer.from(r, "hex");
|
|
21
|
-
if (n.length !== 32)
|
|
22
|
-
throw new Error("KEY MUST BE 32 bytes (64 hex chars)");
|
|
23
|
-
return n;
|
|
24
|
-
}
|
|
25
|
-
async generateJWEKey() {
|
|
26
|
-
const t = process.env.SECRET_SIGNATURE;
|
|
27
|
-
if (!t)
|
|
13
|
+
async generateKey() {
|
|
14
|
+
const e = process.env.SECRET_SIGNATURE;
|
|
15
|
+
if (!e)
|
|
28
16
|
throw new Error("Define a SECRET_SIGNATURE from `.env`");
|
|
29
|
-
|
|
17
|
+
this.signatureKey = await c({
|
|
30
18
|
kty: "oct",
|
|
31
|
-
k: E.
|
|
19
|
+
k: E.encode(new TextEncoder().encode(e))
|
|
32
20
|
});
|
|
33
21
|
}
|
|
34
|
-
async encrypt(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return await E.JWE.createEncrypt(
|
|
39
|
-
{ format: "compact" },
|
|
40
|
-
h
|
|
41
|
-
).update(n).final();
|
|
42
|
-
}
|
|
43
|
-
const y = this.generateAESKey(), i = d(this.IV_LENGTH), a = S(this.ALGORITHM, y, i), c = Buffer.concat([
|
|
44
|
-
a.update(n, "utf8"),
|
|
45
|
-
a.final()
|
|
46
|
-
]), u = a.getAuthTag();
|
|
47
|
-
return Buffer.concat([i, u, c]).toString("hex");
|
|
22
|
+
async encrypt(e) {
|
|
23
|
+
if (await this.generateKey(), !this.signatureKey) throw new Error("PLEASE CREATE A KEY TO ENCRYPT 🙂");
|
|
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);
|
|
48
26
|
}
|
|
49
|
-
async decrypt(
|
|
50
|
-
if (this.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
const r = this.generateAESKey(), n = Buffer.from(t, "hex"), y = n.subarray(0, this.IV_LENGTH), i = n.subarray(
|
|
55
|
-
this.IV_LENGTH,
|
|
56
|
-
this.IV_LENGTH + this.AUTH_TAG_LENGTH
|
|
57
|
-
), a = n.subarray(this.IV_LENGTH + this.AUTH_TAG_LENGTH), c = A(this.ALGORITHM, r, y);
|
|
58
|
-
return c.setAuthTag(i), Buffer.concat([
|
|
59
|
-
c.update(a),
|
|
60
|
-
c.final()
|
|
61
|
-
]).toString("utf8");
|
|
27
|
+
async decrypt(e) {
|
|
28
|
+
if (await this.generateKey(), !this.signatureKey) throw new Error("PLEASE CREATE A KEY TO DECRYPT 🙂");
|
|
29
|
+
const { plaintext: n } = await p(e, this.signatureKey);
|
|
30
|
+
return JSON.parse(new TextDecoder().decode(n));
|
|
62
31
|
}
|
|
63
|
-
async isEncrypted(
|
|
64
|
-
this.logInfo("EncryptionHandler",
|
|
32
|
+
async isEncrypted(e) {
|
|
33
|
+
this.logInfo("EncryptionHandler", e);
|
|
65
34
|
try {
|
|
66
|
-
return await this.decrypt(
|
|
67
|
-
} catch (
|
|
68
|
-
return this.logWarn("EncryptionHandler", JSON.stringify(
|
|
35
|
+
return await this.decrypt(e ?? ""), this.logDebug("EncryptionHandler", "IS ENCRYPTED 🥵"), !0;
|
|
36
|
+
} catch (n) {
|
|
37
|
+
return this.logWarn("EncryptionHandler", JSON.stringify(n)), this.logDebug("EncryptionHandler", "IS NOT ENCRYPTED 🙂"), !1;
|
|
69
38
|
}
|
|
70
39
|
}
|
|
71
|
-
generateSHA(
|
|
72
|
-
const
|
|
73
|
-
return
|
|
40
|
+
generateSHA(e) {
|
|
41
|
+
const n = JSON.stringify(e);
|
|
42
|
+
return d("sha256").update(n).digest("hex");
|
|
74
43
|
}
|
|
75
44
|
}
|
|
76
45
|
export {
|
|
77
|
-
|
|
46
|
+
l as CustomEncrypter
|
|
78
47
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var c=(s,t,e)=>t in s?a(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var n=(s,t,e)=>c(s,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("rxjs"),d=require("./mp-front-cli-encrypter.cjs"),p=require("./service-token-CPZee3-I.cjs");class u extends d.CustomEncrypter{constructor(e={}){super();n(this,"headers");this.headers={Accept:"application/json","Content-Type":"application/vnd.api+json",...e}}addTokenBackend(e){return this.logDebug("addTokenBackend CustomHeader",JSON.stringify(e)),new p.ServiceToken().get().pipe(r.switchMap(o=>r.of({...e,Authorization:`Bearer ${o}`})))}getHeaders(e={},o=!0){return this.logDebug("getHeaders CustomHeader"),o?this.addTokenBackend(e).pipe(r.switchMap(i=>r.of({...i,...this.headers}))):r.of(e).pipe(r.switchMap(i=>r.of({...i,...this.headers})))}}exports.CustomHeader=u;
|
|
@@ -1,33 +1,32 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { switchMap as
|
|
5
|
-
import { CustomEncrypter as
|
|
6
|
-
import { S as
|
|
7
|
-
class
|
|
1
|
+
var p = Object.defineProperty;
|
|
2
|
+
var d = (r, t, e) => t in r ? p(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
|
+
var n = (r, t, e) => d(r, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { switchMap as a, of as o } from "rxjs";
|
|
5
|
+
import { CustomEncrypter as c } from "./mp-front-cli-encrypter.js";
|
|
6
|
+
import { S as u } from "./service-token-BfQQMCM4.js";
|
|
7
|
+
class f extends c {
|
|
8
8
|
constructor(e = {}) {
|
|
9
9
|
super();
|
|
10
|
-
|
|
10
|
+
n(this, "headers");
|
|
11
11
|
this.headers = {
|
|
12
12
|
Accept: "application/json",
|
|
13
13
|
"Content-Type": "application/vnd.api+json",
|
|
14
14
|
...e
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
addTokenBackend(e
|
|
18
|
-
return this.logDebug("addTokenBackend CustomHeader", JSON.stringify(e)), new
|
|
19
|
-
|
|
17
|
+
addTokenBackend(e) {
|
|
18
|
+
return this.logDebug("addTokenBackend CustomHeader", JSON.stringify(e)), new u().get().pipe(
|
|
19
|
+
a((i) => o({ ...e, Authorization: `Bearer ${i}` }))
|
|
20
20
|
);
|
|
21
21
|
}
|
|
22
|
-
getHeaders(e) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
i((n) => o({ ...n, ...this.headers }))
|
|
22
|
+
getHeaders(e = {}, i = !0) {
|
|
23
|
+
return this.logDebug("getHeaders CustomHeader"), i ? this.addTokenBackend(e).pipe(
|
|
24
|
+
a((s) => o({ ...s, ...this.headers }))
|
|
25
|
+
) : o(e).pipe(
|
|
26
|
+
a((s) => o({ ...s, ...this.headers }))
|
|
28
27
|
);
|
|
29
28
|
}
|
|
30
29
|
}
|
|
31
30
|
export {
|
|
32
|
-
|
|
31
|
+
f as CustomHeader
|
|
33
32
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./service-token-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./service-token-CPZee3-I.cjs");exports.ServiceToken=e.ServiceToken;
|