mp-front-cli 0.0.43 → 0.0.45

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,9 +1,57 @@
1
- import { C as s } from "./custom-encrypter-6d8ba182.js";
2
- import "crypto";
3
- import "./custom-validator-49426b3d.js";
4
- import "./custom-encoder-70a77460.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 a = (n, r, t) => (s(n, typeof r != "symbol" ? r + "" : r, t), t);
4
+ import E, { JWK as c, JWE as i } from "node-jose";
5
+ import { createHash as y } from "crypto";
6
+ import { C as p } from "./custom-validator-74fcaf87.js";
7
+ import "./mp-front-cli-encoder.es.js";
5
8
  import "./mp-front-cli-logger.es.js";
6
9
  import "./index-df4e0539.js";
10
+ import "next-auth";
11
+ class K extends p {
12
+ constructor() {
13
+ super(...arguments);
14
+ a(this, "signatureKey");
15
+ }
16
+ async generateKey() {
17
+ const t = process.env.SECRET_SIGNATURE;
18
+ if (!t)
19
+ throw new Error("Define a SECRET_SIGNATURE from `.env`");
20
+ this.signatureKey = await c.asKey({
21
+ kty: "oct",
22
+ k: E.util.base64url.encode(t)
23
+ });
24
+ }
25
+ async encrypt(t) {
26
+ if (await this.generateKey(), !this.signatureKey)
27
+ throw new Error("PLEASE CREATE A KEY TO ENCRYPT 🙂");
28
+ const e = JSON.stringify(t).normalize("NFD").replace(/[\u0300-\u036f]/g, "");
29
+ return await i.createEncrypt(
30
+ { format: "compact" },
31
+ this.signatureKey
32
+ ).update(e).final();
33
+ }
34
+ async decrypt(t) {
35
+ if (await this.generateKey(), !this.signatureKey)
36
+ throw new Error("PLEASE CREATE A KEY TO DECRYPT 🙂");
37
+ const { payload: e } = await i.createDecrypt(this.signatureKey).decrypt(
38
+ t
39
+ );
40
+ return JSON.parse(e.toString());
41
+ }
42
+ async isEncrypted(t) {
43
+ this.logInfo("EncryptionHandler", t);
44
+ try {
45
+ return await this.decrypt(t ?? ""), this.logInfo("EncryptionHandler", "IS ENCRYPTED 🥵"), !0;
46
+ } catch (e) {
47
+ return this.logError("EncryptionHandler", JSON.stringify(e)), this.logInfo("EncryptionHandler", "IS NOT ENCRYPTED 🙂"), !1;
48
+ }
49
+ }
50
+ generateSHA(t) {
51
+ const e = JSON.stringify(t);
52
+ return y("sha256").update(e).digest("hex");
53
+ }
54
+ }
7
55
  export {
8
- s as CustomEncrypter
56
+ K as CustomEncrypter
9
57
  };
@@ -1,11 +1,13 @@
1
1
  import "rxjs";
2
- import { C } from "./custom-header-7dd638e5.js";
3
- import "./custom-encrypter-6d8ba182.js";
2
+ import { C as f } 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";
6
- import "./custom-validator-49426b3d.js";
7
- import "./index-df4e0539.js";
5
+ import "node-jose";
8
6
  import "crypto";
7
+ import "./custom-validator-74fcaf87.js";
8
+ import "./mp-front-cli-encoder.es.js";
9
+ import "./index-df4e0539.js";
10
+ import "next-auth";
9
11
  export {
10
- C as CustomHeader
12
+ f as CustomHeader
11
13
  };
@@ -1,8 +1,8 @@
1
- import "./custom-encoder-70a77460.js";
2
- import { C as a } from "./custom-validator-49426b3d.js";
1
+ import "./mp-front-cli-encoder.es.js";
2
+ import { C as a } from "./custom-validator-74fcaf87.js";
3
+ import "next-auth";
3
4
  import "./mp-front-cli-logger.es.js";
4
5
  import "./index-df4e0539.js";
5
- import "crypto";
6
6
  export {
7
7
  a as CustomValidator
8
8
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mp-front-cli",
3
- "version": "0.0.43",
3
+ "version": "0.0.45",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {