@gustavo-valsechi/utils 1.0.10 → 1.0.14
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/index.js +13 -15
- package/dist/index.mjs +13 -15
- package/dist/src/cryptor/index.js +13 -15
- package/dist/src/cryptor/index.mjs +13 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -266,21 +266,19 @@ var Cryptor = {
|
|
|
266
266
|
},
|
|
267
267
|
decrypt: async (payload) => {
|
|
268
268
|
if (!SECRET) throw new Error("AUTH_SECRET or NEXT_PUBLIC_AUTH_SECRET is required!");
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
console.log("return", JSON.parse(new TextDecoder().decode(decrypted)));
|
|
283
|
-
return JSON.parse(new TextDecoder().decode(decrypted));
|
|
269
|
+
try {
|
|
270
|
+
const key = await Cryptor.deriveKey(SECRET);
|
|
271
|
+
const iv = Cryptor.fromBase64(payload.iv);
|
|
272
|
+
const encrypted = Cryptor.fromBase64(payload.data);
|
|
273
|
+
const decrypted = await crypto.subtle.decrypt(
|
|
274
|
+
{ name: "AES-GCM", iv },
|
|
275
|
+
key,
|
|
276
|
+
encrypted
|
|
277
|
+
);
|
|
278
|
+
return JSON.parse(new TextDecoder().decode(decrypted));
|
|
279
|
+
} catch (e) {
|
|
280
|
+
throw new Error("Invalid AUTH_SECRET or NEXT_PUBLIC_AUTH_SECRET!");
|
|
281
|
+
}
|
|
284
282
|
}
|
|
285
283
|
};
|
|
286
284
|
var cryptor_default = Cryptor;
|
package/dist/index.mjs
CHANGED
|
@@ -230,21 +230,19 @@ var Cryptor = {
|
|
|
230
230
|
},
|
|
231
231
|
decrypt: async (payload) => {
|
|
232
232
|
if (!SECRET) throw new Error("AUTH_SECRET or NEXT_PUBLIC_AUTH_SECRET is required!");
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
console.log("return", JSON.parse(new TextDecoder().decode(decrypted)));
|
|
247
|
-
return JSON.parse(new TextDecoder().decode(decrypted));
|
|
233
|
+
try {
|
|
234
|
+
const key = await Cryptor.deriveKey(SECRET);
|
|
235
|
+
const iv = Cryptor.fromBase64(payload.iv);
|
|
236
|
+
const encrypted = Cryptor.fromBase64(payload.data);
|
|
237
|
+
const decrypted = await crypto.subtle.decrypt(
|
|
238
|
+
{ name: "AES-GCM", iv },
|
|
239
|
+
key,
|
|
240
|
+
encrypted
|
|
241
|
+
);
|
|
242
|
+
return JSON.parse(new TextDecoder().decode(decrypted));
|
|
243
|
+
} catch (e) {
|
|
244
|
+
throw new Error("Invalid AUTH_SECRET or NEXT_PUBLIC_AUTH_SECRET!");
|
|
245
|
+
}
|
|
248
246
|
}
|
|
249
247
|
};
|
|
250
248
|
var cryptor_default = Cryptor;
|
|
@@ -68,21 +68,19 @@ var Cryptor = {
|
|
|
68
68
|
},
|
|
69
69
|
decrypt: async (payload) => {
|
|
70
70
|
if (!SECRET) throw new Error("AUTH_SECRET or NEXT_PUBLIC_AUTH_SECRET is required!");
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
console.log("return", JSON.parse(new TextDecoder().decode(decrypted)));
|
|
85
|
-
return JSON.parse(new TextDecoder().decode(decrypted));
|
|
71
|
+
try {
|
|
72
|
+
const key = await Cryptor.deriveKey(SECRET);
|
|
73
|
+
const iv = Cryptor.fromBase64(payload.iv);
|
|
74
|
+
const encrypted = Cryptor.fromBase64(payload.data);
|
|
75
|
+
const decrypted = await crypto.subtle.decrypt(
|
|
76
|
+
{ name: "AES-GCM", iv },
|
|
77
|
+
key,
|
|
78
|
+
encrypted
|
|
79
|
+
);
|
|
80
|
+
return JSON.parse(new TextDecoder().decode(decrypted));
|
|
81
|
+
} catch (e) {
|
|
82
|
+
throw new Error("Invalid AUTH_SECRET or NEXT_PUBLIC_AUTH_SECRET!");
|
|
83
|
+
}
|
|
86
84
|
}
|
|
87
85
|
};
|
|
88
86
|
var cryptor_default = Cryptor;
|
|
@@ -44,21 +44,19 @@ var Cryptor = {
|
|
|
44
44
|
},
|
|
45
45
|
decrypt: async (payload) => {
|
|
46
46
|
if (!SECRET) throw new Error("AUTH_SECRET or NEXT_PUBLIC_AUTH_SECRET is required!");
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
console.log("return", JSON.parse(new TextDecoder().decode(decrypted)));
|
|
61
|
-
return JSON.parse(new TextDecoder().decode(decrypted));
|
|
47
|
+
try {
|
|
48
|
+
const key = await Cryptor.deriveKey(SECRET);
|
|
49
|
+
const iv = Cryptor.fromBase64(payload.iv);
|
|
50
|
+
const encrypted = Cryptor.fromBase64(payload.data);
|
|
51
|
+
const decrypted = await crypto.subtle.decrypt(
|
|
52
|
+
{ name: "AES-GCM", iv },
|
|
53
|
+
key,
|
|
54
|
+
encrypted
|
|
55
|
+
);
|
|
56
|
+
return JSON.parse(new TextDecoder().decode(decrypted));
|
|
57
|
+
} catch (e) {
|
|
58
|
+
throw new Error("Invalid AUTH_SECRET or NEXT_PUBLIC_AUTH_SECRET!");
|
|
59
|
+
}
|
|
62
60
|
}
|
|
63
61
|
};
|
|
64
62
|
var cryptor_default = Cryptor;
|