@powerlines/plugin-crypto 0.10.465 → 0.10.466
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/_virtual/_rolldown/runtime.cjs +1 -29
- package/dist/components/crypto.cjs +10 -25
- package/dist/components/crypto.mjs +10 -24
- package/dist/components/crypto.mjs.map +1 -1
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.mjs +1 -3
- package/dist/index.cjs +1 -45
- package/dist/index.mjs +1 -39
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.mjs +1 -1
- package/dist/types/plugin.mjs +1 -1
- package/package.json +5 -5
|
@@ -1,29 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
-
key = keys[i];
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
-
__defProp(to, key, {
|
|
14
|
-
get: ((k) => from[k]).bind(null, key),
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
-
value: mod,
|
|
24
|
-
enumerable: true
|
|
25
|
-
}) : target, mod));
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
28
|
-
|
|
29
|
-
exports.__toESM = __toESM;
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));exports.__toESM=s;
|
|
@@ -1,30 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
let powerlines_utils = require("powerlines/utils");
|
|
3
|
-
|
|
4
|
-
//#region src/components/crypto.ts
|
|
5
|
-
/**
|
|
6
|
-
* Generates the crypto module content.
|
|
7
|
-
*
|
|
8
|
-
* @param context - The build context containing runtime information.
|
|
9
|
-
* @returns A string representing the crypto module code.
|
|
10
|
-
*/
|
|
11
|
-
function cryptoModule(context) {
|
|
12
|
-
return `
|
|
1
|
+
require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`powerlines/utils`);function t(t){return`
|
|
13
2
|
/**
|
|
14
3
|
* The cryptography module provides custom helper functions to support encrypting and decrypting data.
|
|
15
4
|
*
|
|
16
|
-
* @module ${
|
|
5
|
+
* @module ${t.config.framework}:crypto
|
|
17
6
|
*/
|
|
18
7
|
|
|
19
|
-
${(0,
|
|
8
|
+
${(0,e.getFileHeader)(t)}
|
|
20
9
|
|
|
21
10
|
import { xchacha20poly1305, chacha20poly1305 } from "@noble/ciphers/chacha.js";
|
|
22
11
|
import { randomBytes, managedNonce, hexToBytes } from "@noble/ciphers/utils.js";
|
|
23
12
|
import { scrypt } from "@noble/hashes/scrypt.js";
|
|
24
13
|
import { blake3 } from "@noble/hashes/blake3.js";
|
|
25
|
-
${
|
|
14
|
+
${t.config.crypto.encryptionKey?`
|
|
26
15
|
const nonce = randomBytes(24);
|
|
27
|
-
const chacha = xchacha20poly1305(hexToBytes("${
|
|
16
|
+
const chacha = xchacha20poly1305(hexToBytes("${t.config.crypto.encryptionKey}"), nonce);
|
|
28
17
|
|
|
29
18
|
/**
|
|
30
19
|
* Symmetrically encrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher.
|
|
@@ -59,7 +48,7 @@ export function decrypt(encrypted: string): string {
|
|
|
59
48
|
|
|
60
49
|
return new TextDecoder().decode(decrypted);
|
|
61
50
|
}
|
|
62
|
-
|
|
51
|
+
`:``}
|
|
63
52
|
|
|
64
53
|
/**
|
|
65
54
|
* Symmetrically encrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher with a password.
|
|
@@ -73,7 +62,7 @@ export function decrypt(encrypted: string): string {
|
|
|
73
62
|
export function encryptWithPassword(password: string, plaintext: string): string {
|
|
74
63
|
const key = scrypt(
|
|
75
64
|
new TextEncoder().encode(password),
|
|
76
|
-
hexToBytes("${
|
|
65
|
+
hexToBytes("${t.config.crypto.salt?t.config.crypto.salt:`nonce`}"),
|
|
77
66
|
1048576, // requires 1GB of RAM to calculate
|
|
78
67
|
8,
|
|
79
68
|
1,
|
|
@@ -99,7 +88,7 @@ export function encryptWithPassword(password: string, plaintext: string): string
|
|
|
99
88
|
export function decryptWithPassword(password: string, encrypted: string): string {
|
|
100
89
|
const key = scrypt(
|
|
101
90
|
new TextEncoder().encode(password),
|
|
102
|
-
hexToBytes("${
|
|
91
|
+
hexToBytes("${t.config.crypto.salt?t.config.crypto.salt:`nonce`}"),
|
|
103
92
|
1048576, // requires 1GB of RAM to calculate
|
|
104
93
|
8,
|
|
105
94
|
1,
|
|
@@ -126,7 +115,7 @@ export function decryptWithPassword(password: string, encrypted: string): string
|
|
|
126
115
|
export function hash(data: string): string {
|
|
127
116
|
return Buffer.from(
|
|
128
117
|
blake3(new TextEncoder().encode(data), {
|
|
129
|
-
key: ${
|
|
118
|
+
key: ${t.config.crypto.salt?`hexToBytes("${t.config.crypto.salt}")`:`new TextEncoder().encode("powerlines")`})
|
|
130
119
|
})
|
|
131
120
|
).toString("hex");
|
|
132
121
|
}
|
|
@@ -141,8 +130,4 @@ export * from '@noble/hashes/pbkdf2.js';
|
|
|
141
130
|
export * from '@noble/hashes/scrypt.js';
|
|
142
131
|
export * from '@noble/hashes/utils.js';
|
|
143
132
|
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
//#endregion
|
|
148
|
-
exports.cryptoModule = cryptoModule;
|
|
133
|
+
`}exports.cryptoModule=t;
|
|
@@ -1,29 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
//#region src/components/crypto.ts
|
|
4
|
-
/**
|
|
5
|
-
* Generates the crypto module content.
|
|
6
|
-
*
|
|
7
|
-
* @param context - The build context containing runtime information.
|
|
8
|
-
* @returns A string representing the crypto module code.
|
|
9
|
-
*/
|
|
10
|
-
function cryptoModule(context) {
|
|
11
|
-
return `
|
|
1
|
+
import{getFileHeader as e}from"powerlines/utils";function t(t){return`
|
|
12
2
|
/**
|
|
13
3
|
* The cryptography module provides custom helper functions to support encrypting and decrypting data.
|
|
14
4
|
*
|
|
15
|
-
* @module ${
|
|
5
|
+
* @module ${t.config.framework}:crypto
|
|
16
6
|
*/
|
|
17
7
|
|
|
18
|
-
${
|
|
8
|
+
${e(t)}
|
|
19
9
|
|
|
20
10
|
import { xchacha20poly1305, chacha20poly1305 } from "@noble/ciphers/chacha.js";
|
|
21
11
|
import { randomBytes, managedNonce, hexToBytes } from "@noble/ciphers/utils.js";
|
|
22
12
|
import { scrypt } from "@noble/hashes/scrypt.js";
|
|
23
13
|
import { blake3 } from "@noble/hashes/blake3.js";
|
|
24
|
-
${
|
|
14
|
+
${t.config.crypto.encryptionKey?`
|
|
25
15
|
const nonce = randomBytes(24);
|
|
26
|
-
const chacha = xchacha20poly1305(hexToBytes("${
|
|
16
|
+
const chacha = xchacha20poly1305(hexToBytes("${t.config.crypto.encryptionKey}"), nonce);
|
|
27
17
|
|
|
28
18
|
/**
|
|
29
19
|
* Symmetrically encrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher.
|
|
@@ -58,7 +48,7 @@ export function decrypt(encrypted: string): string {
|
|
|
58
48
|
|
|
59
49
|
return new TextDecoder().decode(decrypted);
|
|
60
50
|
}
|
|
61
|
-
|
|
51
|
+
`:``}
|
|
62
52
|
|
|
63
53
|
/**
|
|
64
54
|
* Symmetrically encrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher with a password.
|
|
@@ -72,7 +62,7 @@ export function decrypt(encrypted: string): string {
|
|
|
72
62
|
export function encryptWithPassword(password: string, plaintext: string): string {
|
|
73
63
|
const key = scrypt(
|
|
74
64
|
new TextEncoder().encode(password),
|
|
75
|
-
hexToBytes("${
|
|
65
|
+
hexToBytes("${t.config.crypto.salt?t.config.crypto.salt:`nonce`}"),
|
|
76
66
|
1048576, // requires 1GB of RAM to calculate
|
|
77
67
|
8,
|
|
78
68
|
1,
|
|
@@ -98,7 +88,7 @@ export function encryptWithPassword(password: string, plaintext: string): string
|
|
|
98
88
|
export function decryptWithPassword(password: string, encrypted: string): string {
|
|
99
89
|
const key = scrypt(
|
|
100
90
|
new TextEncoder().encode(password),
|
|
101
|
-
hexToBytes("${
|
|
91
|
+
hexToBytes("${t.config.crypto.salt?t.config.crypto.salt:`nonce`}"),
|
|
102
92
|
1048576, // requires 1GB of RAM to calculate
|
|
103
93
|
8,
|
|
104
94
|
1,
|
|
@@ -125,7 +115,7 @@ export function decryptWithPassword(password: string, encrypted: string): string
|
|
|
125
115
|
export function hash(data: string): string {
|
|
126
116
|
return Buffer.from(
|
|
127
117
|
blake3(new TextEncoder().encode(data), {
|
|
128
|
-
key: ${
|
|
118
|
+
key: ${t.config.crypto.salt?`hexToBytes("${t.config.crypto.salt}")`:`new TextEncoder().encode("powerlines")`})
|
|
129
119
|
})
|
|
130
120
|
).toString("hex");
|
|
131
121
|
}
|
|
@@ -140,9 +130,5 @@ export * from '@noble/hashes/pbkdf2.js';
|
|
|
140
130
|
export * from '@noble/hashes/scrypt.js';
|
|
141
131
|
export * from '@noble/hashes/utils.js';
|
|
142
132
|
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
//#endregion
|
|
147
|
-
export { cryptoModule };
|
|
133
|
+
`}export{t as cryptoModule};
|
|
148
134
|
//# sourceMappingURL=crypto.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.mjs","names":[],"sources":["../../src/components/crypto.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getFileHeader } from \"powerlines/utils\";\nimport { CryptoPluginContext } from \"../types/plugin\";\n\n/**\n * Generates the crypto module content.\n *\n * @param context - The build context containing runtime information.\n * @returns A string representing the crypto module code.\n */\nexport function cryptoModule(context: CryptoPluginContext) {\n return `\n/**\n * The cryptography module provides custom helper functions to support encrypting and decrypting data.\n *\n * @module ${context.config.framework}:crypto\n */\n\n${getFileHeader(context)}\n\nimport { xchacha20poly1305, chacha20poly1305 } from \"@noble/ciphers/chacha.js\";\nimport { randomBytes, managedNonce, hexToBytes } from \"@noble/ciphers/utils.js\";\nimport { scrypt } from \"@noble/hashes/scrypt.js\";\nimport { blake3 } from \"@noble/hashes/blake3.js\";\n${\n context.config.crypto.encryptionKey\n ? `\nconst nonce = randomBytes(24);\nconst chacha = xchacha20poly1305(hexToBytes(\"${\n context.config.crypto.encryptionKey\n }\"), nonce);\n\n/**\n * Symmetrically encrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher.\n *\n * @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305\n *\n * @param plaintext - The data to encrypt.\n * @returns The encrypted data.\n */\nexport function encrypt(plaintext: string): string {\n return chacha.encrypt(\n nonce,\n new TextEncoder().encode(plaintext),\n null\n );\n}\n\n/**\n * Symmetrically decrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher.\n *\n * @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305\n *\n * @param encrypted - The encrypted data to decrypt.\n * @returns The decrypted data.\n */\nexport function decrypt(encrypted: string): string {\n const decrypted = chacha.decrypt(\n nonce,\n encrypted,\n null\n );\n\n return new TextDecoder().decode(decrypted);\n}\n`\n : \"\"\n}\n\n/**\n * Symmetrically encrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher with a password.\n *\n * @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305\n *\n * @param password - The password used to derive the encryption key.\n * @param plaintext - The data to encrypt.\n * @returns The encrypted data.\n */\nexport function encryptWithPassword(password: string, plaintext: string): string {\n const key = scrypt(\n new TextEncoder().encode(password),\n hexToBytes(\"${context.config.crypto.salt ? context.config.crypto.salt : \"nonce\"}\"),\n 1048576, // requires 1GB of RAM to calculate\n 8,\n 1,\n 32\n );\n\n return chacha20poly1305(key).encrypt(\n nonce,\n new TextEncoder().encode(plaintext),\n null\n );\n}\n\n/**\n * Symmetrically decrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher with a password.\n *\n * @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305\n *\n * @param password - The password used to derive the decryption key.\n * @param encrypted - The encrypted data to decrypt.\n * @returns The decrypted data.\n */\nexport function decryptWithPassword(password: string, encrypted: string): string {\n const key = scrypt(\n new TextEncoder().encode(password),\n hexToBytes(\"${context.config.crypto.salt ? context.config.crypto.salt : \"nonce\"}\"),\n 1048576, // requires 1GB of RAM to calculate\n 8,\n 1,\n 32\n );\n\n const decrypted = chacha20poly1305(key).decrypt(\n nonce,\n encrypted,\n null\n );\n\n return new TextDecoder().decode(decrypted);\n}\n\n/**\n * Hashes data using the [BLAKE3](https://en.wikipedia.org/wiki/BLAKE_(hash_function)#BLAKE3) hash function.\n *\n * @see https://en.wikipedia.org/wiki/BLAKE_(hash_function)#BLAKE3\n *\n * @param data - The data to hash.\n * @returns The hashed data.\n */\nexport function hash(data: string): string {\n return Buffer.from(\n blake3(new TextEncoder().encode(data), {\n key: ${\n context.config.crypto.salt\n ? `hexToBytes(\"${context.config.crypto.salt}\")`\n : 'new TextEncoder().encode(\"powerlines\")'\n })\n })\n ).toString(\"hex\");\n}\n\n// Export noble cipher and hash functions for advanced usage\n\nexport * from \"@noble/ciphers/chacha.js\";\nexport * from \"@noble/ciphers/aes.js\";\nexport * from \"@noble/ciphers/utils.js\";\nexport * from '@noble/hashes/blake3.js';\nexport * from '@noble/hashes/pbkdf2.js';\nexport * from '@noble/hashes/scrypt.js';\nexport * from '@noble/hashes/utils.js';\n\n`;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"crypto.mjs","names":[],"sources":["../../src/components/crypto.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getFileHeader } from \"powerlines/utils\";\nimport { CryptoPluginContext } from \"../types/plugin\";\n\n/**\n * Generates the crypto module content.\n *\n * @param context - The build context containing runtime information.\n * @returns A string representing the crypto module code.\n */\nexport function cryptoModule(context: CryptoPluginContext) {\n return `\n/**\n * The cryptography module provides custom helper functions to support encrypting and decrypting data.\n *\n * @module ${context.config.framework}:crypto\n */\n\n${getFileHeader(context)}\n\nimport { xchacha20poly1305, chacha20poly1305 } from \"@noble/ciphers/chacha.js\";\nimport { randomBytes, managedNonce, hexToBytes } from \"@noble/ciphers/utils.js\";\nimport { scrypt } from \"@noble/hashes/scrypt.js\";\nimport { blake3 } from \"@noble/hashes/blake3.js\";\n${\n context.config.crypto.encryptionKey\n ? `\nconst nonce = randomBytes(24);\nconst chacha = xchacha20poly1305(hexToBytes(\"${\n context.config.crypto.encryptionKey\n }\"), nonce);\n\n/**\n * Symmetrically encrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher.\n *\n * @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305\n *\n * @param plaintext - The data to encrypt.\n * @returns The encrypted data.\n */\nexport function encrypt(plaintext: string): string {\n return chacha.encrypt(\n nonce,\n new TextEncoder().encode(plaintext),\n null\n );\n}\n\n/**\n * Symmetrically decrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher.\n *\n * @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305\n *\n * @param encrypted - The encrypted data to decrypt.\n * @returns The decrypted data.\n */\nexport function decrypt(encrypted: string): string {\n const decrypted = chacha.decrypt(\n nonce,\n encrypted,\n null\n );\n\n return new TextDecoder().decode(decrypted);\n}\n`\n : \"\"\n}\n\n/**\n * Symmetrically encrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher with a password.\n *\n * @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305\n *\n * @param password - The password used to derive the encryption key.\n * @param plaintext - The data to encrypt.\n * @returns The encrypted data.\n */\nexport function encryptWithPassword(password: string, plaintext: string): string {\n const key = scrypt(\n new TextEncoder().encode(password),\n hexToBytes(\"${context.config.crypto.salt ? context.config.crypto.salt : \"nonce\"}\"),\n 1048576, // requires 1GB of RAM to calculate\n 8,\n 1,\n 32\n );\n\n return chacha20poly1305(key).encrypt(\n nonce,\n new TextEncoder().encode(plaintext),\n null\n );\n}\n\n/**\n * Symmetrically decrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher with a password.\n *\n * @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305\n *\n * @param password - The password used to derive the decryption key.\n * @param encrypted - The encrypted data to decrypt.\n * @returns The decrypted data.\n */\nexport function decryptWithPassword(password: string, encrypted: string): string {\n const key = scrypt(\n new TextEncoder().encode(password),\n hexToBytes(\"${context.config.crypto.salt ? context.config.crypto.salt : \"nonce\"}\"),\n 1048576, // requires 1GB of RAM to calculate\n 8,\n 1,\n 32\n );\n\n const decrypted = chacha20poly1305(key).decrypt(\n nonce,\n encrypted,\n null\n );\n\n return new TextDecoder().decode(decrypted);\n}\n\n/**\n * Hashes data using the [BLAKE3](https://en.wikipedia.org/wiki/BLAKE_(hash_function)#BLAKE3) hash function.\n *\n * @see https://en.wikipedia.org/wiki/BLAKE_(hash_function)#BLAKE3\n *\n * @param data - The data to hash.\n * @returns The hashed data.\n */\nexport function hash(data: string): string {\n return Buffer.from(\n blake3(new TextEncoder().encode(data), {\n key: ${\n context.config.crypto.salt\n ? `hexToBytes(\"${context.config.crypto.salt}\")`\n : 'new TextEncoder().encode(\"powerlines\")'\n })\n })\n ).toString(\"hex\");\n}\n\n// Export noble cipher and hash functions for advanced usage\n\nexport * from \"@noble/ciphers/chacha.js\";\nexport * from \"@noble/ciphers/aes.js\";\nexport * from \"@noble/ciphers/utils.js\";\nexport * from '@noble/hashes/blake3.js';\nexport * from '@noble/hashes/pbkdf2.js';\nexport * from '@noble/hashes/scrypt.js';\nexport * from '@noble/hashes/utils.js';\n\n`;\n}\n"],"mappings":"iDA2BA,SAAgB,EAAa,EAA8B,CACzD,MAAO;;;;aAII,EAAQ,OAAO,UAAU;;;EAGpC,EAAc,EAAQ,CAAC;;;;;;EAOvB,EAAQ,OAAO,OAAO,cAClB;;+CAGE,EAAQ,OAAO,OAAO,cACvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoCD,GACL;;;;;;;;;;;;;;kBAciB,EAAQ,OAAO,OAAO,KAAO,EAAQ,OAAO,OAAO,KAAO,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;kBA0BlE,EAAQ,OAAO,OAAO,KAAO,EAAQ,OAAO,OAAO,KAAO,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;aA4B5E,EAAQ,OAAO,OAAO,KAClB,eAAe,EAAQ,OAAO,OAAO,KAAK,IAC1C,yCACL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
require(`./crypto.cjs`);
|
package/dist/index.cjs
CHANGED
|
@@ -1,45 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,
|
|
2
|
-
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_crypto = require('./components/crypto.cjs');
|
|
4
|
-
require('./components/index.cjs');
|
|
5
|
-
let _noble_ciphers_utils_js = require("@noble/ciphers/utils.js");
|
|
6
|
-
let _powerlines_plugin_env = require("@powerlines/plugin-env");
|
|
7
|
-
_powerlines_plugin_env = require_runtime.__toESM(_powerlines_plugin_env, 1);
|
|
8
|
-
let defu = require("defu");
|
|
9
|
-
defu = require_runtime.__toESM(defu, 1);
|
|
10
|
-
|
|
11
|
-
//#region src/index.ts
|
|
12
|
-
/**
|
|
13
|
-
* A Powerlines plugin to assist in developing other Powerlines plugins.
|
|
14
|
-
*/
|
|
15
|
-
function plugin(options = {}) {
|
|
16
|
-
return [(0, _powerlines_plugin_env.default)(options.env), {
|
|
17
|
-
name: "crypto",
|
|
18
|
-
config() {
|
|
19
|
-
return { crypto: (0, defu.default)(options, { salt: `${(this.config.name ?? this.packageJson?.name) || "powerlines"}-application` }) };
|
|
20
|
-
},
|
|
21
|
-
configResolved() {
|
|
22
|
-
this.dependencies["@noble/ciphers"] = "^2.0.1";
|
|
23
|
-
this.dependencies["@noble/hashes"] = "^2.0.1";
|
|
24
|
-
this.config.crypto.salt ??= this.env.parsed.SALT;
|
|
25
|
-
if (!this.config.crypto.salt) {
|
|
26
|
-
this.warn(`No salt provided to the Crypto plugin - a salt value will be generated automatically. Please note: It's highly recommended to provide a unique salt value via the \`salt\` plugin option or the \`SALT\` environment variable.`);
|
|
27
|
-
this.config.crypto.salt = (0, _noble_ciphers_utils_js.bytesToHex)((0, _noble_ciphers_utils_js.randomBytes)(12));
|
|
28
|
-
}
|
|
29
|
-
this.config.crypto.encryptionKey ??= this.env.parsed.ENCRYPTION_KEY;
|
|
30
|
-
if (!this.config.crypto.encryptionKey) {
|
|
31
|
-
this.warn(`No encryption key provided to the Crypto plugin - a secure key will be generated automatically. Please note: it's highly recommended to provide a secure encryption key via the \`encryptionKey\` plugin option or the \`ENCRYPTION_KEY\` environment variable.`);
|
|
32
|
-
this.config.crypto.encryptionKey = (0, _noble_ciphers_utils_js.bytesToHex)((0, _noble_ciphers_utils_js.randomBytes)(32));
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
async prepare() {
|
|
36
|
-
this.debug(`Preparing the Crypto runtime artifacts for the Powerlines project.`);
|
|
37
|
-
await this.emitBuiltin(await Promise.resolve(require_crypto.cryptoModule(this)), "crypto");
|
|
38
|
-
}
|
|
39
|
-
}];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
//#endregion
|
|
43
|
-
exports.cryptoModule = require_crypto.cryptoModule;
|
|
44
|
-
exports.default = plugin;
|
|
45
|
-
exports.plugin = plugin;
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./_virtual/_rolldown/runtime.cjs`),t=require(`./components/crypto.cjs`);require(`./components/index.cjs`);let n=require(`@noble/ciphers/utils.js`),r=require(`@powerlines/plugin-env`);r=e.__toESM(r,1);let i=require(`defu`);i=e.__toESM(i,1);function a(e={}){return[(0,r.default)(e.env),{name:`crypto`,config(){return{crypto:(0,i.default)(e,{salt:`${(this.config.name??this.packageJson?.name)||`powerlines`}-application`})}},configResolved(){this.dependencies[`@noble/ciphers`]=`^2.0.1`,this.dependencies[`@noble/hashes`]=`^2.0.1`,this.config.crypto.salt??=this.env.parsed.SALT,this.config.crypto.salt||(this.warn("No salt provided to the Crypto plugin - a salt value will be generated automatically. Please note: It's highly recommended to provide a unique salt value via the `salt` plugin option or the `SALT` environment variable."),this.config.crypto.salt=(0,n.bytesToHex)((0,n.randomBytes)(12))),this.config.crypto.encryptionKey??=this.env.parsed.ENCRYPTION_KEY,this.config.crypto.encryptionKey||(this.warn("No encryption key provided to the Crypto plugin - a secure key will be generated automatically. Please note: it's highly recommended to provide a secure encryption key via the `encryptionKey` plugin option or the `ENCRYPTION_KEY` environment variable."),this.config.crypto.encryptionKey=(0,n.bytesToHex)((0,n.randomBytes)(32)))},async prepare(){this.debug(`Preparing the Crypto runtime artifacts for the Powerlines project.`),await this.emitBuiltin(await Promise.resolve(t.cryptoModule(this)),`crypto`)}}]}exports.cryptoModule=t.cryptoModule,exports.default=a,exports.plugin=a;
|
package/dist/index.mjs
CHANGED
|
@@ -1,40 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "./components/index.mjs";
|
|
3
|
-
import { bytesToHex, randomBytes } from "@noble/ciphers/utils.js";
|
|
4
|
-
import env from "@powerlines/plugin-env";
|
|
5
|
-
import defu from "defu";
|
|
6
|
-
|
|
7
|
-
//#region src/index.ts
|
|
8
|
-
/**
|
|
9
|
-
* A Powerlines plugin to assist in developing other Powerlines plugins.
|
|
10
|
-
*/
|
|
11
|
-
function plugin(options = {}) {
|
|
12
|
-
return [env(options.env), {
|
|
13
|
-
name: "crypto",
|
|
14
|
-
config() {
|
|
15
|
-
return { crypto: defu(options, { salt: `${(this.config.name ?? this.packageJson?.name) || "powerlines"}-application` }) };
|
|
16
|
-
},
|
|
17
|
-
configResolved() {
|
|
18
|
-
this.dependencies["@noble/ciphers"] = "^2.0.1";
|
|
19
|
-
this.dependencies["@noble/hashes"] = "^2.0.1";
|
|
20
|
-
this.config.crypto.salt ??= this.env.parsed.SALT;
|
|
21
|
-
if (!this.config.crypto.salt) {
|
|
22
|
-
this.warn(`No salt provided to the Crypto plugin - a salt value will be generated automatically. Please note: It's highly recommended to provide a unique salt value via the \`salt\` plugin option or the \`SALT\` environment variable.`);
|
|
23
|
-
this.config.crypto.salt = bytesToHex(randomBytes(12));
|
|
24
|
-
}
|
|
25
|
-
this.config.crypto.encryptionKey ??= this.env.parsed.ENCRYPTION_KEY;
|
|
26
|
-
if (!this.config.crypto.encryptionKey) {
|
|
27
|
-
this.warn(`No encryption key provided to the Crypto plugin - a secure key will be generated automatically. Please note: it's highly recommended to provide a secure encryption key via the \`encryptionKey\` plugin option or the \`ENCRYPTION_KEY\` environment variable.`);
|
|
28
|
-
this.config.crypto.encryptionKey = bytesToHex(randomBytes(32));
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
async prepare() {
|
|
32
|
-
this.debug(`Preparing the Crypto runtime artifacts for the Powerlines project.`);
|
|
33
|
-
await this.emitBuiltin(await Promise.resolve(cryptoModule(this)), "crypto");
|
|
34
|
-
}
|
|
35
|
-
}];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
//#endregion
|
|
39
|
-
export { cryptoModule, plugin as default, plugin };
|
|
1
|
+
import{cryptoModule as e}from"./components/crypto.mjs";import"./components/index.mjs";import{bytesToHex as t,randomBytes as n}from"@noble/ciphers/utils.js";import r from"@powerlines/plugin-env";import i from"defu";function a(a={}){return[r(a.env),{name:`crypto`,config(){return{crypto:i(a,{salt:`${(this.config.name??this.packageJson?.name)||`powerlines`}-application`})}},configResolved(){this.dependencies[`@noble/ciphers`]=`^2.0.1`,this.dependencies[`@noble/hashes`]=`^2.0.1`,this.config.crypto.salt??=this.env.parsed.SALT,this.config.crypto.salt||(this.warn("No salt provided to the Crypto plugin - a salt value will be generated automatically. Please note: It's highly recommended to provide a unique salt value via the `salt` plugin option or the `SALT` environment variable."),this.config.crypto.salt=t(n(12))),this.config.crypto.encryptionKey??=this.env.parsed.ENCRYPTION_KEY,this.config.crypto.encryptionKey||(this.warn("No encryption key provided to the Crypto plugin - a secure key will be generated automatically. Please note: it's highly recommended to provide a secure encryption key via the `encryptionKey` plugin option or the `ENCRYPTION_KEY` environment variable."),this.config.crypto.encryptionKey=t(n(32)))},async prepare(){this.debug(`Preparing the Crypto runtime artifacts for the Powerlines project.`),await this.emitBuiltin(await Promise.resolve(e(this)),`crypto`)}}]}export{e as cryptoModule,a as default,a as plugin};
|
|
40
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { bytesToHex, randomBytes } from \"@noble/ciphers/utils.js\";\nimport env from \"@powerlines/plugin-env\";\nimport defu from \"defu\";\nimport { Plugin } from \"powerlines\";\nimport { cryptoModule } from \"./components/crypto\";\nimport { CryptoPluginContext, CryptoPluginOptions } from \"./types/plugin\";\n\nexport * from \"./components\";\nexport * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n crypto?: CryptoPluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin to assist in developing other Powerlines plugins.\n */\nexport function plugin<\n TContext extends CryptoPluginContext = CryptoPluginContext\n>(options: CryptoPluginOptions = {}) {\n return [\n env(options.env),\n {\n name: \"crypto\",\n config() {\n return {\n crypto: defu(options, {\n salt: `${(this.config.name ?? this.packageJson?.name) || \"powerlines\"}-application`\n })\n };\n },\n configResolved() {\n this.dependencies[\"@noble/ciphers\"] = \"^2.0.1\";\n this.dependencies[\"@noble/hashes\"] = \"^2.0.1\";\n\n this.config.crypto.salt ??= this.env.parsed.SALT!;\n if (!this.config.crypto.salt) {\n this.warn(\n `No salt provided to the Crypto plugin - a salt value will be generated automatically. Please note: It's highly recommended to provide a unique salt value via the \\`salt\\` plugin option or the \\`SALT\\` environment variable.`\n );\n\n this.config.crypto.salt = bytesToHex(randomBytes(12));\n }\n\n this.config.crypto.encryptionKey ??= this.env.parsed.ENCRYPTION_KEY!;\n if (!this.config.crypto.encryptionKey) {\n this.warn(\n `No encryption key provided to the Crypto plugin - a secure key will be generated automatically. Please note: it's highly recommended to provide a secure encryption key via the \\`encryptionKey\\` plugin option or the \\`ENCRYPTION_KEY\\` environment variable.`\n );\n\n this.config.crypto.encryptionKey = bytesToHex(randomBytes(32));\n }\n },\n async prepare() {\n this.debug(\n `Preparing the Crypto runtime artifacts for the Powerlines project.`\n );\n\n await this.emitBuiltin(\n await Promise.resolve(cryptoModule(this)),\n \"crypto\"\n );\n }\n }\n ] as Plugin<TContext>[];\n}\n\nexport default plugin;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { bytesToHex, randomBytes } from \"@noble/ciphers/utils.js\";\nimport env from \"@powerlines/plugin-env\";\nimport defu from \"defu\";\nimport { Plugin } from \"powerlines\";\nimport { cryptoModule } from \"./components/crypto\";\nimport { CryptoPluginContext, CryptoPluginOptions } from \"./types/plugin\";\n\nexport * from \"./components\";\nexport * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n crypto?: CryptoPluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin to assist in developing other Powerlines plugins.\n */\nexport function plugin<\n TContext extends CryptoPluginContext = CryptoPluginContext\n>(options: CryptoPluginOptions = {}) {\n return [\n env(options.env),\n {\n name: \"crypto\",\n config() {\n return {\n crypto: defu(options, {\n salt: `${(this.config.name ?? this.packageJson?.name) || \"powerlines\"}-application`\n })\n };\n },\n configResolved() {\n this.dependencies[\"@noble/ciphers\"] = \"^2.0.1\";\n this.dependencies[\"@noble/hashes\"] = \"^2.0.1\";\n\n this.config.crypto.salt ??= this.env.parsed.SALT!;\n if (!this.config.crypto.salt) {\n this.warn(\n `No salt provided to the Crypto plugin - a salt value will be generated automatically. Please note: It's highly recommended to provide a unique salt value via the \\`salt\\` plugin option or the \\`SALT\\` environment variable.`\n );\n\n this.config.crypto.salt = bytesToHex(randomBytes(12));\n }\n\n this.config.crypto.encryptionKey ??= this.env.parsed.ENCRYPTION_KEY!;\n if (!this.config.crypto.encryptionKey) {\n this.warn(\n `No encryption key provided to the Crypto plugin - a secure key will be generated automatically. Please note: it's highly recommended to provide a secure encryption key via the \\`encryptionKey\\` plugin option or the \\`ENCRYPTION_KEY\\` environment variable.`\n );\n\n this.config.crypto.encryptionKey = bytesToHex(randomBytes(32));\n }\n },\n async prepare() {\n this.debug(\n `Preparing the Crypto runtime artifacts for the Powerlines project.`\n );\n\n await this.emitBuiltin(\n await Promise.resolve(cryptoModule(this)),\n \"crypto\"\n );\n }\n }\n ] as Plugin<TContext>[];\n}\n\nexport default plugin;\n"],"mappings":"sNAqCA,SAAgB,EAEd,EAA+B,EAAE,CAAE,CACnC,MAAO,CACL,EAAI,EAAQ,IAAI,CAChB,CACE,KAAM,SACN,QAAS,CACP,MAAO,CACL,OAAQ,EAAK,EAAS,CACpB,KAAM,IAAI,KAAK,OAAO,MAAQ,KAAK,aAAa,OAAS,aAAa,cACvE,CAAC,CACH,EAEH,gBAAiB,CACf,KAAK,aAAa,kBAAoB,SACtC,KAAK,aAAa,iBAAmB,SAErC,KAAK,OAAO,OAAO,OAAS,KAAK,IAAI,OAAO,KACvC,KAAK,OAAO,OAAO,OACtB,KAAK,KACH,6NACD,CAED,KAAK,OAAO,OAAO,KAAO,EAAW,EAAY,GAAG,CAAC,EAGvD,KAAK,OAAO,OAAO,gBAAkB,KAAK,IAAI,OAAO,eAChD,KAAK,OAAO,OAAO,gBACtB,KAAK,KACH,8PACD,CAED,KAAK,OAAO,OAAO,cAAgB,EAAW,EAAY,GAAG,CAAC,GAGlE,MAAM,SAAU,CACd,KAAK,MACH,qEACD,CAED,MAAM,KAAK,YACT,MAAM,QAAQ,QAAQ,EAAa,KAAK,CAAC,CACzC,SACD,EAEJ,CACF"}
|
package/dist/types/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{};
|
package/dist/types/plugin.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-crypto",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.466",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A Powerlines plugin that provides unique identifier generation capabilities at runtime by adding the `id` builtin module.",
|
|
6
6
|
"repository": {
|
|
@@ -87,19 +87,19 @@
|
|
|
87
87
|
"keywords": ["powerlines", "storm-software", "powerlines-plugin"],
|
|
88
88
|
"dependencies": {
|
|
89
89
|
"@noble/ciphers": "^2.2.0",
|
|
90
|
-
"@powerlines/plugin-env": "^0.16.
|
|
90
|
+
"@powerlines/plugin-env": "^0.16.157",
|
|
91
91
|
"@storm-software/config-tools": "^1.189.78",
|
|
92
92
|
"@stryke/path": "^0.27.5",
|
|
93
93
|
"defu": "^6.1.7",
|
|
94
|
-
"powerlines": "^0.43.
|
|
94
|
+
"powerlines": "^0.43.27"
|
|
95
95
|
},
|
|
96
96
|
"devDependencies": {
|
|
97
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
97
|
+
"@powerlines/plugin-plugin": "^0.12.382",
|
|
98
98
|
"@types/node": "^25.6.0"
|
|
99
99
|
},
|
|
100
100
|
"publishConfig": { "access": "public" },
|
|
101
101
|
"main": "./dist/index.cjs",
|
|
102
102
|
"module": "./dist/index.mjs",
|
|
103
103
|
"types": "./dist/index.d.cts",
|
|
104
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "ad851a239011b884c15b0444db518d74927fd13f"
|
|
105
105
|
}
|