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,8 +1,54 @@
1
- import { C as e } from "./custom-encrypter-e3901c44.js";
2
- import "crypto";
3
- import "./custom-encoder-70a77460.js";
4
- import "./v4-8464ab21.js";
1
+ var o = Object.defineProperty;
2
+ var s = (n, r, t) => r in n ? o(n, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[r] = t;
3
+ var i = (n, r, t) => (s(n, typeof r != "symbol" ? r + "" : r, t), t);
4
+ import a from "node-jose";
5
+ import { createHash as E } from "crypto";
6
+ import { CustomEncoder as c } from "./mp-front-cli-encoder.es.js";
5
7
  import "./mp-front-cli-logger.es.js";
8
+ class f extends c {
9
+ constructor() {
10
+ super(...arguments);
11
+ i(this, "signatureKey");
12
+ }
13
+ async generateKey() {
14
+ const t = process.env.SECRET_SIGNATURE;
15
+ if (!t)
16
+ throw new Error("Define a SECRET_SIGNATURE from `.env`");
17
+ this.signatureKey = await a.JWK.asKey({
18
+ kty: "oct",
19
+ k: a.util.base64url.encode(t)
20
+ });
21
+ }
22
+ async encrypt(t) {
23
+ if (await this.generateKey(), !this.signatureKey)
24
+ throw new Error("PLEASE CREATE A KEY TO ENCRYPT 🙂");
25
+ const e = JSON.stringify(t).normalize("NFD").replace(/[\u0300-\u036f]/g, "");
26
+ return await a.JWE.createEncrypt(
27
+ { format: "compact" },
28
+ this.signatureKey
29
+ ).update(e).final();
30
+ }
31
+ async decrypt(t) {
32
+ if (await this.generateKey(), !this.signatureKey)
33
+ throw new Error("PLEASE CREATE A KEY TO DECRYPT 🙂");
34
+ const { payload: e } = await a.JWE.createDecrypt(
35
+ this.signatureKey
36
+ ).decrypt(t);
37
+ return JSON.parse(e.toString());
38
+ }
39
+ async isEncrypted(t) {
40
+ this.logInfo("EncryptionHandler", t);
41
+ try {
42
+ return await this.decrypt(t ?? ""), this.logInfo("EncryptionHandler", "IS ENCRYPTED 🥵"), !0;
43
+ } catch (e) {
44
+ return this.logError("EncryptionHandler", JSON.stringify(e)), this.logInfo("EncryptionHandler", "IS NOT ENCRYPTED 🙂"), !1;
45
+ }
46
+ }
47
+ generateSHA(t) {
48
+ const e = JSON.stringify(t);
49
+ return E("sha256").update(e).digest("hex");
50
+ }
51
+ }
6
52
  export {
7
- e as CustomEncrypter
53
+ f as CustomEncrypter
8
54
  };
@@ -1,10 +1,10 @@
1
1
  import "rxjs";
2
- import { C as s } from "./custom-header-db08aa72.js";
3
- import "./custom-encrypter-e3901c44.js";
2
+ import { C as s } from "./custom-header-3ba5652e.js";
3
+ import "./mp-front-cli-encrypter.es.js";
4
4
  import "./mp-front-cli-logger.es.js";
5
- import "./custom-encoder-70a77460.js";
5
+ import "node-jose";
6
6
  import "crypto";
7
- import "./v4-8464ab21.js";
7
+ import "./mp-front-cli-encoder.es.js";
8
8
  export {
9
9
  s as CustomHeader
10
10
  };
@@ -0,0 +1,9 @@
1
+ const i = [];
2
+ for (let n = 0; n < 256; ++n)
3
+ i.push((n + 256).toString(16).slice(1));
4
+ function c(n, u = 0) {
5
+ return i[n[u + 0]] + i[n[u + 1]] + i[n[u + 2]] + i[n[u + 3]] + "-" + i[n[u + 4]] + i[n[u + 5]] + "-" + i[n[u + 6]] + i[n[u + 7]] + "-" + i[n[u + 8]] + i[n[u + 9]] + "-" + i[n[u + 10]] + i[n[u + 11]] + i[n[u + 12]] + i[n[u + 13]] + i[n[u + 14]] + i[n[u + 15]];
6
+ }
7
+ export {
8
+ c as u
9
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mp-front-cli",
3
- "version": "0.0.55",
3
+ "version": "0.0.56",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -59,19 +59,15 @@
59
59
  "peerDependencies": {
60
60
  "ioredis": "5.3.2",
61
61
  "rxjs": "7.8.1",
62
- "next-auth": "^4.24.6"
62
+ "node-jose": "2.2.0",
63
+ "i18next": "23.10.0"
63
64
  },
64
65
  "dependencies": {
66
+ "next-auth": "4.24.6",
67
+ "lodash": "4.17.21",
65
68
  "@types/node-jose": "1.1.13",
66
69
  "@types/uuid": "9.0.8",
67
70
  "husky": "^9.0.11",
68
- "i18next": "23.7.20",
69
- "ioredis": "5.3.2",
70
- "lodash": "4.17.21",
71
- "next": "14.1.0",
72
- "next-auth": "4.24.6",
73
- "node-jose": "2.2.0",
74
- "rxjs": "7.8.1",
75
71
  "uuid": "9.0.1"
76
72
  },
77
73
  "devDependencies": {
@@ -86,4 +82,4 @@
86
82
  "vite-plugin-dts": "3.7.1",
87
83
  "vite-tsconfig-paths": "4.2.2"
88
84
  }
89
- }
85
+ }