@mp-front/common 0.0.2-next.2 → 0.0.2-next.4
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/cache-providers/redis/redis-cache.d.ts +1 -1
- package/dist/{client-DuXI9Ldu.js → client-Bdo9xBca.js} +65 -65
- package/dist/client-CCn8WzaX.cjs +1 -0
- package/dist/{encoder-CXAlLf5T.js → encoder-DQ28XRzN.js} +1 -1
- package/dist/{encoder-BEp9qfLf.cjs → encoder-DrKsNmKq.cjs} +1 -1
- package/dist/{encrypter-CgZLhLnj.cjs → encrypter-BQWKlKtz.cjs} +1 -1
- package/dist/{encrypter-ZTjrp3uD.js → encrypter-BXo3FT6G.js} +1 -1
- package/dist/http/client.d.ts.map +1 -1
- package/dist/{lodash-QjAkD17S.js → lodash-BzOkiDvV.js} +291 -274
- package/dist/{lodash-DNCgFYS7.cjs → lodash-DahFf0th.cjs} +5 -5
- package/dist/mp-front-common-all.cjs +1 -1
- package/dist/mp-front-common-all.js +3 -3
- package/dist/mp-front-common-cache.cjs +1 -1
- package/dist/mp-front-common-cache.js +2 -2
- package/dist/mp-front-common-cacheProviders.cjs +1 -1
- package/dist/mp-front-common-cacheProviders.js +1 -1
- package/dist/mp-front-common-engine.cjs +1 -1
- package/dist/mp-front-common-engine.js +1 -1
- package/dist/mp-front-common-helpers.cjs +1 -1
- package/dist/mp-front-common-helpers.js +2 -2
- package/dist/mp-front-common-http.cjs +1 -1
- package/dist/mp-front-common-http.js +1 -1
- package/dist/{redis-cache-HiNx0Kbv.js → redis-cache-BWqtENoP.js} +1 -1
- package/dist/{redis-cache-BstIlgPR.cjs → redis-cache-xm1YpsCP.cjs} +1 -1
- package/package.json +2 -2
- package/dist/client-AVep4jK5.cjs +0 -1
|
@@ -17,7 +17,7 @@ export declare class RedisCache<T> {
|
|
|
17
17
|
ttl(key: string, time: number): void;
|
|
18
18
|
simpleGet(key: string): Promise<string>;
|
|
19
19
|
simpleHGet(key: string, field: string): Promise<string>;
|
|
20
|
-
simpleHGetBuffer(key: string, field: string): Promise<Buffer
|
|
20
|
+
simpleHGetBuffer(key: string, field: string): Promise<Buffer>;
|
|
21
21
|
simpleHSet<T extends string | number | Buffer = string>(key: string, field: string, value: T): Promise<number>;
|
|
22
22
|
simpleHGetAll(key: string): Promise<Record<string, string>>;
|
|
23
23
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
var L = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var i = (o, e, t) =>
|
|
4
|
-
import { switchMap as d, of as
|
|
5
|
-
import { L as
|
|
6
|
-
import "./lodash-
|
|
2
|
+
var $ = (o, e, t) => e in o ? L(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
|
+
var i = (o, e, t) => $(o, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { switchMap as d, of as h, catchError as q, filter as J, EMPTY as A } from "rxjs";
|
|
5
|
+
import { L as R } from "./logger-DtlFWyFO.js";
|
|
6
|
+
import "./lodash-BzOkiDvV.js";
|
|
7
7
|
import "node-jose";
|
|
8
8
|
import "crypto";
|
|
9
|
-
import { R, a as
|
|
9
|
+
import { R as B, a as y, E as I } from "./default-errors-DsKmUZbG.js";
|
|
10
10
|
import { f as N } from "./fetch-CUIb9XhZ.js";
|
|
11
|
-
import { A } from "./authorization-service-DE-hoYji.js";
|
|
12
|
-
import { E as
|
|
13
|
-
import { L as
|
|
14
|
-
import { v as
|
|
15
|
-
class
|
|
11
|
+
import { A as k } from "./authorization-service-DE-hoYji.js";
|
|
12
|
+
import { E as j } from "./encoder-DQ28XRzN.js";
|
|
13
|
+
import { L as S } from "./loading-handler-ivYFmS_V.js";
|
|
14
|
+
import { v as T } from "./v5-Cu1sjPlx.js";
|
|
15
|
+
class H {
|
|
16
16
|
constructor(e = {}) {
|
|
17
|
-
i(this, "logger", new
|
|
17
|
+
i(this, "logger", new R());
|
|
18
18
|
i(this, "headers");
|
|
19
19
|
this.headers = {
|
|
20
20
|
Accept: "application/json",
|
|
@@ -23,29 +23,29 @@ class q {
|
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
addTokenBackend(e) {
|
|
26
|
-
return this.logger.logDebug("addTokenBackend HttpHeaders", JSON.stringify(e)), new
|
|
27
|
-
d((t) =>
|
|
26
|
+
return this.logger.logDebug("addTokenBackend HttpHeaders", JSON.stringify(e)), new k().get().pipe(
|
|
27
|
+
d((t) => h({ ...e, Authorization: `Bearer ${t}` }))
|
|
28
28
|
);
|
|
29
29
|
}
|
|
30
30
|
get(e) {
|
|
31
31
|
this.logger.logDebug("get HttpHeaders");
|
|
32
|
-
const t =
|
|
32
|
+
const t = h({ ...this.headers });
|
|
33
33
|
return e ? t.pipe(
|
|
34
34
|
d((s) => this.addTokenBackend(s))
|
|
35
35
|
) : t;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
const
|
|
39
|
-
class
|
|
38
|
+
const U = process.env.ID_FRONT ?? "NOT_AVAILABLE";
|
|
39
|
+
class te {
|
|
40
40
|
constructor() {
|
|
41
|
-
i(this, "httpHeaders", new
|
|
42
|
-
i(this, "logger", new
|
|
41
|
+
i(this, "httpHeaders", new H());
|
|
42
|
+
i(this, "logger", new R());
|
|
43
43
|
}
|
|
44
44
|
errorCatcher(e, t) {
|
|
45
45
|
var s, r, a;
|
|
46
46
|
if (e != null && e.errors)
|
|
47
|
-
throw new
|
|
48
|
-
((a = (r = (s = e.errors).at) == null ? void 0 : r.call(s, 0)) == null ? void 0 : a.code) ??
|
|
47
|
+
throw new B(
|
|
48
|
+
((a = (r = (s = e.errors).at) == null ? void 0 : r.call(s, 0)) == null ? void 0 : a.code) ?? y.DEFAULT,
|
|
49
49
|
t ?? ""
|
|
50
50
|
);
|
|
51
51
|
return !(e != null && e.errors);
|
|
@@ -69,7 +69,7 @@ class Z {
|
|
|
69
69
|
formatParams(e, t) {
|
|
70
70
|
return JSON.stringify(t === "JSON:API" ? {
|
|
71
71
|
data: {
|
|
72
|
-
type:
|
|
72
|
+
type: U,
|
|
73
73
|
attributes: e
|
|
74
74
|
}
|
|
75
75
|
} : e);
|
|
@@ -89,8 +89,8 @@ class Z {
|
|
|
89
89
|
if (e === "GET") {
|
|
90
90
|
const u = new URL(t);
|
|
91
91
|
if (r.params)
|
|
92
|
-
for (const
|
|
93
|
-
u.searchParams.append(
|
|
92
|
+
for (const m of Object.keys(r.params))
|
|
93
|
+
u.searchParams.append(m, `${r.params[m]}`);
|
|
94
94
|
return { ...n, url: u.toString() };
|
|
95
95
|
}
|
|
96
96
|
return { ...n, body: this.formatParams(s, a) };
|
|
@@ -106,18 +106,18 @@ class Z {
|
|
|
106
106
|
(a) => N(e, {
|
|
107
107
|
...r,
|
|
108
108
|
headers: {
|
|
109
|
-
...
|
|
110
|
-
...
|
|
109
|
+
...a,
|
|
110
|
+
...r.headers
|
|
111
111
|
}
|
|
112
112
|
}).pipe(
|
|
113
|
-
|
|
113
|
+
q((n) => {
|
|
114
114
|
throw this.logger.logError(JSON.stringify(n)), this.logger.logError(
|
|
115
115
|
`HttpBackend \x1B[37m <URL>: \x1B[33m ${e} \x1B[37m <RequestID>: \x1B[33m ${t} \x1B[37m <HEADERS>: \x1B[33m ${JSON.stringify(
|
|
116
116
|
a
|
|
117
117
|
)} \x1B[37m <BODY>: \x1B[33m ${JSON.stringify(
|
|
118
118
|
this.formatParams(r.body, r.format)
|
|
119
119
|
)} \x1B[37m <RESPONSE>: \x1B[33m ${JSON.stringify(n)} \x1B[33m`
|
|
120
|
-
), new
|
|
120
|
+
), new B(y.DEFAULT, t);
|
|
121
121
|
}),
|
|
122
122
|
d((n) => (this.logger.logDebug(
|
|
123
123
|
`HttpBackend \x1B[37m <URL>: \x1B[33m ${e} \x1B[37m <RequestID>: \x1B[33m ${t} \x1B[37m <HEADERS>: \x1B[33m ${JSON.stringify(
|
|
@@ -125,19 +125,19 @@ class Z {
|
|
|
125
125
|
)} \x1B[37m <BODY>: \x1B[33m ${JSON.stringify(
|
|
126
126
|
this.formatParams(r.body, r.format)
|
|
127
127
|
)} \x1B[37m <RESPONSE>: \x1B[33m ${JSON.stringify(n)} \x1B[33m`
|
|
128
|
-
),
|
|
128
|
+
), h(n)))
|
|
129
129
|
)
|
|
130
130
|
),
|
|
131
|
-
|
|
131
|
+
J((a) => this.errorCatcher(a, t))
|
|
132
132
|
);
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
-
const
|
|
136
|
-
class
|
|
135
|
+
const Y = "requestID", O = "Content-Type";
|
|
136
|
+
class re {
|
|
137
137
|
constructor() {
|
|
138
|
-
i(this, "httpHeaders", new
|
|
139
|
-
i(this, "logger", new
|
|
140
|
-
i(this, "encoder", new
|
|
138
|
+
i(this, "httpHeaders", new H());
|
|
139
|
+
i(this, "logger", new R());
|
|
140
|
+
i(this, "encoder", new j());
|
|
141
141
|
i(this, "isLoadingEnabled", !0);
|
|
142
142
|
}
|
|
143
143
|
/**
|
|
@@ -237,70 +237,70 @@ class ee {
|
|
|
237
237
|
* Building configuration object request
|
|
238
238
|
*/
|
|
239
239
|
buildRequest(e, t, s, r) {
|
|
240
|
-
const
|
|
240
|
+
const n = new URLSearchParams(window.location.search).get("flow") ?? "N/A", u = {
|
|
241
241
|
url: t,
|
|
242
|
-
headers: r.headers,
|
|
242
|
+
headers: { ...r.headers, flow: n },
|
|
243
243
|
method: e,
|
|
244
244
|
selector: (c) => c.json()
|
|
245
|
-
},
|
|
245
|
+
}, m = (/* @__PURE__ */ new Date()).toISOString(), f = T(m, T.URL);
|
|
246
246
|
if (e === "GET") {
|
|
247
|
-
const c = new URL(t, location.origin), E = r.params ?? {},
|
|
248
|
-
const [
|
|
249
|
-
if (
|
|
250
|
-
const
|
|
251
|
-
|
|
247
|
+
const c = new URL(t, location.origin), E = r.params ?? {}, w = Object.entries(E).reduce((l, P) => {
|
|
248
|
+
const [g, x] = P;
|
|
249
|
+
if (l[g] = `${x}`, Object.hasOwn(E, g)) {
|
|
250
|
+
const p = E[g];
|
|
251
|
+
p != null && (l[g] = p);
|
|
252
252
|
}
|
|
253
|
-
return
|
|
254
|
-
}, {}), D = this.encoder.encode(
|
|
255
|
-
for (const
|
|
256
|
-
c.searchParams.append(
|
|
257
|
-
return { ...
|
|
253
|
+
return l;
|
|
254
|
+
}, {}), D = this.encoder.encode(w, f), b = JSON.parse(D);
|
|
255
|
+
for (const l of Object.keys(b))
|
|
256
|
+
c.searchParams.append(l, `${b[l]}`);
|
|
257
|
+
return { ...u, url: c.toString() };
|
|
258
258
|
}
|
|
259
259
|
if (new Headers(r.headers).get("Content-Type") === "multipart/form-data") {
|
|
260
260
|
const c = s;
|
|
261
|
-
return c.append(
|
|
262
|
-
...
|
|
261
|
+
return c.append(Y, f), {
|
|
262
|
+
...u,
|
|
263
263
|
body: c
|
|
264
264
|
};
|
|
265
265
|
}
|
|
266
266
|
return {
|
|
267
|
-
...
|
|
268
|
-
body: this.encoder.encode(s ?? {},
|
|
267
|
+
...u,
|
|
268
|
+
body: this.encoder.encode(s ?? {}, f)
|
|
269
269
|
};
|
|
270
270
|
}
|
|
271
271
|
request({
|
|
272
272
|
url: e,
|
|
273
273
|
...t
|
|
274
274
|
}) {
|
|
275
|
-
return
|
|
275
|
+
return S.getInstance().setSubject(this.isLoadingEnabled), this.httpHeaders.get(!1).pipe(
|
|
276
276
|
d((s) => {
|
|
277
277
|
const r = {
|
|
278
278
|
...s,
|
|
279
279
|
...t.headers
|
|
280
280
|
};
|
|
281
|
-
return
|
|
281
|
+
return O in r && r[O] === "multipart/form-data" && delete r[O], N(e, {
|
|
282
282
|
...t,
|
|
283
283
|
headers: r
|
|
284
284
|
}).pipe(
|
|
285
|
-
d((a) =>
|
|
285
|
+
d((a) => h(this.encoder.decode(a))),
|
|
286
286
|
d((a) => {
|
|
287
287
|
if ("code" in a)
|
|
288
288
|
throw a;
|
|
289
|
-
return
|
|
290
|
-
`HttpClient <URL>: ${e} <HEADERS>: ${JSON.stringify(
|
|
291
|
-
),
|
|
289
|
+
return S.getInstance().setSubject(!1), this.logger.logDebug(
|
|
290
|
+
`HttpClient <URL>: ${e} <HEADERS>: ${JSON.stringify(r)} <BODY> ${JSON.stringify(t.body)} <RESPONSE>: ${JSON.stringify(a)}`
|
|
291
|
+
), h(a);
|
|
292
292
|
}),
|
|
293
|
-
|
|
294
|
-
`HttpClient <URL>: ${e} <HEADERS>: ${JSON.stringify(
|
|
295
|
-
),
|
|
293
|
+
q((a) => (this.logger.logError(
|
|
294
|
+
`HttpClient <URL>: ${e} <HEADERS>: ${JSON.stringify(r)} <BODY> ${JSON.stringify(t.body)} <ERROR>: ${JSON.stringify(a)}`
|
|
295
|
+
), S.getInstance().setSubject(!1), I.getInstance().setSubject(a), A))
|
|
296
296
|
);
|
|
297
297
|
})
|
|
298
298
|
);
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
301
|
export {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
302
|
+
H,
|
|
303
|
+
Y as R,
|
|
304
|
+
te as a,
|
|
305
|
+
re as b
|
|
306
306
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var L=Object.defineProperty;var P=(c,e,t)=>e in c?L(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t;var o=(c,e,t)=>P(c,typeof e!="symbol"?e+"":e,t);const i=require("rxjs"),q=require("./logger-BMbeDoGU.cjs");require("./lodash-DahFf0th.cjs");require("node-jose");require("crypto");const l=require("./default-errors-DiEIEEE2.cjs"),y=require("./fetch-BZP9DZLg.cjs"),x=require("./authorization-service-DkLS18Us.cjs"),$=require("./encoder-DrKsNmKq.cjs"),p=require("./loading-handler-BrN0O37N.cjs"),B=require("./v5-BTqP79vV.cjs");class R{constructor(e={}){o(this,"logger",new q.Logger);o(this,"headers");this.headers={Accept:"application/json","Content-Type":"application/vnd.api+json",...e}}addTokenBackend(e){return this.logger.logDebug("addTokenBackend HttpHeaders",JSON.stringify(e)),new x.AuthorizationService().get().pipe(i.switchMap(t=>i.of({...e,Authorization:`Bearer ${t}`})))}get(e){this.logger.logDebug("get HttpHeaders");const t=i.of({...this.headers});return e?t.pipe(i.switchMap(s=>this.addTokenBackend(s))):t}}const J=process.env.ID_FRONT??"NOT_AVAILABLE";class I{constructor(){o(this,"httpHeaders",new R);o(this,"logger",new q.Logger)}errorCatcher(e,t){var s,r,n;if(e!=null&&e.errors)throw new l.RuntimeError(((n=(r=(s=e.errors).at)==null?void 0:r.call(s,0))==null?void 0:n.code)??l.RuntimeErrorCode.DEFAULT,t??"");return!(e!=null&&e.errors)}get(e,t={}){const s=this.buildRequest("GET",e,null,t);return this.request(s)}post(e,t,s={}){const r=this.buildRequest("POST",e,t,s);return this.request(r)}put(e,t,s={}){const r=this.buildRequest("PUT",e,t,s);return this.request(r)}delete(e,t={}){const s=this.buildRequest("DELETE",e,null,t);return this.request(s)}formatParams(e,t){return JSON.stringify(t==="JSON:API"?{data:{type:J,attributes:e}}:e)}buildRequest(e,t,s,r){const n=r.format??"JSON:API",a={requestID:r==null?void 0:r.requestID,withCredentials:(r==null?void 0:r.withCredentials)??!0,url:t,headers:r.headers,method:e,selector:u=>u.json()};if(e==="GET"){const u=new URL(t);if(r.params)for(const g of Object.keys(r.params))u.searchParams.append(g,`${r.params[g]}`);return{...a,url:u.toString()}}return{...a,body:this.formatParams(s,n)}}request({url:e,requestID:t,withCredentials:s=!1,...r}){return this.httpHeaders.get(s).pipe(i.switchMap(n=>y.fromFetch(e,{...r,headers:{...n,...r.headers}}).pipe(i.catchError(a=>{throw this.logger.logError(JSON.stringify(a)),this.logger.logError(`HttpBackend \x1B[37m <URL>: \x1B[33m ${e} \x1B[37m <RequestID>: \x1B[33m ${t} \x1B[37m <HEADERS>: \x1B[33m ${JSON.stringify(n)} \x1B[37m <BODY>: \x1B[33m ${JSON.stringify(this.formatParams(r.body,r.format))} \x1B[37m <RESPONSE>: \x1B[33m ${JSON.stringify(a)} \x1B[33m`),new l.RuntimeError(l.RuntimeErrorCode.DEFAULT,t)}),i.switchMap(a=>(this.logger.logDebug(`HttpBackend \x1B[37m <URL>: \x1B[33m ${e} \x1B[37m <RequestID>: \x1B[33m ${t} \x1B[37m <HEADERS>: \x1B[33m ${JSON.stringify(n)} \x1B[37m <BODY>: \x1B[33m ${JSON.stringify(this.formatParams(r.body,r.format))} \x1B[37m <RESPONSE>: \x1B[33m ${JSON.stringify(a)} \x1B[33m`),i.of(a))))),i.filter(n=>this.errorCatcher(n,t)))}}const H="requestID",O="Content-Type";class A{constructor(){o(this,"httpHeaders",new R);o(this,"logger",new q.Logger);o(this,"encoder",new $.Encoder);o(this,"isLoadingEnabled",!0)}setIsLoadingEnabled(e){this.isLoadingEnabled=e}get(e,t={}){const s=this.buildRequest("GET",e,null,t);return this.request(s)}post(e,t,s={}){const r=this.buildRequest("POST",e,t,s);return this.request(r)}put(e,t,s={}){const r=this.buildRequest("PUT",e,t,s);return this.request(r)}patch(e,t,s={}){const r=this.buildRequest("PATCH",e,t,s);return this.request(r)}delete(e,t={}){const s=this.buildRequest("DELETE",e,null,t);return this.request(s)}buildRequest(e,t,s,r){const a=new URLSearchParams(window.location.search).get("flow")??"N/A",u={url:t,headers:{...r.headers,flow:a},method:e,selector:d=>d.json()},g=new Date().toISOString(),E=B.v5(g,B.v5.URL);if(e==="GET"){const d=new URL(t,location.origin),f=r.params??{},w=Object.entries(f).reduce((h,N)=>{const[m,D]=N;if(h[m]=`${D}`,Object.hasOwn(f,m)){const S=f[m];S!=null&&(h[m]=S)}return h},{}),T=this.encoder.encode(w,E),b=JSON.parse(T);for(const h of Object.keys(b))d.searchParams.append(h,`${b[h]}`);return{...u,url:d.toString()}}if(new Headers(r.headers).get("Content-Type")==="multipart/form-data"){const d=s;return d.append(H,E),{...u,body:d}}return{...u,body:this.encoder.encode(s??{},E)}}request({url:e,...t}){return p.LoadingHandler.getInstance().setSubject(this.isLoadingEnabled),this.httpHeaders.get(!1).pipe(i.switchMap(s=>{const r={...s,...t.headers};return O in r&&r[O]==="multipart/form-data"&&delete r[O],y.fromFetch(e,{...t,headers:r}).pipe(i.switchMap(n=>i.of(this.encoder.decode(n))),i.switchMap(n=>{if("code"in n)throw n;return p.LoadingHandler.getInstance().setSubject(!1),this.logger.logDebug(`HttpClient <URL>: ${e} <HEADERS>: ${JSON.stringify(r)} <BODY> ${JSON.stringify(t.body)} <RESPONSE>: ${JSON.stringify(n)}`),i.of(n)}),i.catchError(n=>(this.logger.logError(`HttpClient <URL>: ${e} <HEADERS>: ${JSON.stringify(r)} <BODY> ${JSON.stringify(t.body)} <ERROR>: ${JSON.stringify(n)}`),p.LoadingHandler.getInstance().setSubject(!1),l.ErrorHandler.getInstance().setSubject(n),i.EMPTY)))}))}}exports.HttpBackend=I;exports.HttpClient=A;exports.HttpHeaders=R;exports.REQUEST_ID_KEY=H;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var i = Object.defineProperty;
|
|
2
2
|
var c = (e, r, o) => r in e ? i(e, r, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[r] = o;
|
|
3
3
|
var s = (e, r, o) => c(e, typeof r != "symbol" ? r + "" : r, o);
|
|
4
|
-
import { l as g } from "./lodash-
|
|
4
|
+
import { l as g } from "./lodash-BzOkiDvV.js";
|
|
5
5
|
import { L as f } from "./logger-DtlFWyFO.js";
|
|
6
6
|
import "node-jose";
|
|
7
7
|
import "crypto";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var i=Object.defineProperty;var c=(o,r,e)=>r in o?i(o,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[r]=e;var n=(o,r,e)=>c(o,typeof r!="symbol"?r+"":r,e);const g=require("./lodash-
|
|
1
|
+
"use strict";var i=Object.defineProperty;var c=(o,r,e)=>r in o?i(o,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[r]=e;var n=(o,r,e)=>c(o,typeof r!="symbol"?r+"":r,e);const g=require("./lodash-DahFf0th.cjs"),f=require("./logger-BMbeDoGU.cjs");require("node-jose");require("crypto");class l{constructor(){n(this,"logger",new f.Logger)}encode(r,e){try{this.logger.logDebug("encode Encoder",JSON.stringify(r));const s=JSON.stringify(r),t=Buffer.from(s).toString("base64");return JSON.stringify({info:t,requestID:e})}catch{return this.logger.logDebug("error convert to base64"),JSON.stringify({info:r,requestID:e})}}decode(r){try{g.lodashExports.isString(r)&&(r=JSON.parse(r));const{info:e}=r;this.logger.logDebug("decode Encoder",JSON.stringify(e));const s=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;if(g.lodashExports.isString(e)&&s.test(e)){const t=Buffer.from(e,"base64").toString();return JSON.parse(t)}}catch{this.logger.logError("error convert to base64")}return r}}exports.Encoder=l;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var c=Object.defineProperty;var o=(t,e,r)=>e in t?c(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var i=(t,e,r)=>o(t,typeof e!="symbol"?e+"":e,r);const n=require("node-jose"),g=require("crypto"),E=require("./logger-BMbeDoGU.cjs");require("./lodash-
|
|
1
|
+
"use strict";var c=Object.defineProperty;var o=(t,e,r)=>e in t?c(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var i=(t,e,r)=>o(t,typeof e!="symbol"?e+"":e,r);const n=require("node-jose"),g=require("crypto"),E=require("./logger-BMbeDoGU.cjs");require("./lodash-DahFf0th.cjs");const a=t=>t.replace(/[\u00A0-\uffff]/gu,e=>"\\u"+("000"+e.charCodeAt(0).toString(16)).slice(-4));class y{constructor(){i(this,"logger",new E.Logger);i(this,"signatureKey")}async generateKey(){const e=process.env.SECRET_SIGNATURE;if(!e)throw new Error("Define a SECRET_SIGNATURE from `.env`");this.signatureKey=await n.JWK.asKey({kty:"oct",k:n.util.base64url.encode(e)})}async encrypt(e){if(await this.generateKey(),!this.signatureKey)throw new Error("PLEASE CREATE A KEY TO ENCRYPT 🙂");const r=JSON.stringify(e),s=a(r);return await n.JWE.createEncrypt({format:"compact"},this.signatureKey).update(s).final()}async decrypt(e){if(await this.generateKey(),!this.signatureKey)throw new Error("PLEASE CREATE A KEY TO DECRYPT 🙂");const{payload:r}=await n.JWE.createDecrypt(this.signatureKey).decrypt(e);return JSON.parse(r.toString())}async isEncrypted(e){this.logger.logInfo("EncryptionHandler",e);try{return await this.decrypt(e??""),this.logger.logDebug("EncryptionHandler","IS ENCRYPTED 🥵"),!0}catch(r){return this.logger.logWarn("EncryptionHandler",JSON.stringify(r)),this.logger.logDebug("EncryptionHandler","IS NOT ENCRYPTED 🙂"),!1}}generateSHA(e){const r=JSON.stringify(e);return g.createHash("sha256").update(r).digest("hex")}}exports.Encrypter=y;exports.escapeUnicode=a;
|
|
@@ -4,7 +4,7 @@ var a = (t, e, r) => s(t, typeof e != "symbol" ? e + "" : e, r);
|
|
|
4
4
|
import n from "node-jose";
|
|
5
5
|
import { createHash as c } from "crypto";
|
|
6
6
|
import { L as E } from "./logger-DtlFWyFO.js";
|
|
7
|
-
import "./lodash-
|
|
7
|
+
import "./lodash-BzOkiDvV.js";
|
|
8
8
|
const g = (t) => t.replace(/[\u00A0-\uffff]/gu, (e) => "\\u" + ("000" + e.charCodeAt(0).toString(16)).slice(-4));
|
|
9
9
|
class d {
|
|
10
10
|
constructor() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/http/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAA;AAKtC,OAAO,KAAK,EAAE,WAAW,EAAyB,MAAM,cAAc,CAAA;AAMtE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAoB;IAChD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;IAExC,OAAO,CAA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