@powerlines/plugin-crypto 0.10.391 → 0.10.393

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-crypto",
3
- "version": "0.10.391",
3
+ "version": "0.10.393",
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.1.1",
90
- "@powerlines/plugin-env": "^0.16.82",
90
+ "@powerlines/plugin-env": "^0.16.84",
91
91
  "@storm-software/config-tools": "^1.189.39",
92
92
  "@stryke/path": "^0.27.2",
93
93
  "defu": "^6.1.4",
94
- "powerlines": "^0.42.2"
94
+ "powerlines": "^0.42.4"
95
95
  },
96
96
  "devDependencies": {
97
- "@powerlines/plugin-plugin": "^0.12.312",
97
+ "@powerlines/plugin-plugin": "^0.12.314",
98
98
  "@types/node": "^25.5.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": "d00a8306c2e4bc7b8fd853b0f935b5ef5f32d845"
104
+ "gitHead": "c3243c1ec0fbacb4afd4bd3db20432f443334076"
105
105
  }
@@ -1,29 +0,0 @@
1
- //#region \0rolldown/runtime.js
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,3 +0,0 @@
1
- import "node:module";
2
-
3
- export { };
@@ -1,148 +0,0 @@
1
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
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 `
13
- /**
14
- * The cryptography module provides custom helper functions to support encrypting and decrypting data.
15
- *
16
- * @module ${context.config.framework}:crypto
17
- */
18
-
19
- ${(0, powerlines_utils.getFileHeader)(context)}
20
-
21
- import { xchacha20poly1305, chacha20poly1305 } from "@noble/ciphers/chacha.js";
22
- import { randomBytes, managedNonce, hexToBytes } from "@noble/ciphers/utils.js";
23
- import { scrypt } from "@noble/hashes/scrypt.js";
24
- import { blake3 } from "@noble/hashes/blake3.js";
25
- ${context.config.crypto.encryptionKey ? `
26
- const nonce = randomBytes(24);
27
- const chacha = xchacha20poly1305(hexToBytes("${context.config.crypto.encryptionKey}"), nonce);
28
-
29
- /**
30
- * Symmetrically encrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher.
31
- *
32
- * @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305
33
- *
34
- * @param plaintext - The data to encrypt.
35
- * @returns The encrypted data.
36
- */
37
- export function encrypt(plaintext: string): string {
38
- return chacha.encrypt(
39
- nonce,
40
- new TextEncoder().encode(plaintext),
41
- null
42
- );
43
- }
44
-
45
- /**
46
- * Symmetrically decrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher.
47
- *
48
- * @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305
49
- *
50
- * @param encrypted - The encrypted data to decrypt.
51
- * @returns The decrypted data.
52
- */
53
- export function decrypt(encrypted: string): string {
54
- const decrypted = chacha.decrypt(
55
- nonce,
56
- encrypted,
57
- null
58
- );
59
-
60
- return new TextDecoder().decode(decrypted);
61
- }
62
- ` : ""}
63
-
64
- /**
65
- * Symmetrically encrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher with a password.
66
- *
67
- * @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305
68
- *
69
- * @param password - The password used to derive the encryption key.
70
- * @param plaintext - The data to encrypt.
71
- * @returns The encrypted data.
72
- */
73
- export function encryptWithPassword(password: string, plaintext: string): string {
74
- const key = scrypt(
75
- new TextEncoder().encode(password),
76
- hexToBytes("${context.config.crypto.salt ? context.config.crypto.salt : "nonce"}"),
77
- 1048576, // requires 1GB of RAM to calculate
78
- 8,
79
- 1,
80
- 32
81
- );
82
-
83
- return chacha20poly1305(key).encrypt(
84
- nonce,
85
- new TextEncoder().encode(plaintext),
86
- null
87
- );
88
- }
89
-
90
- /**
91
- * Symmetrically decrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher with a password.
92
- *
93
- * @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305
94
- *
95
- * @param password - The password used to derive the decryption key.
96
- * @param encrypted - The encrypted data to decrypt.
97
- * @returns The decrypted data.
98
- */
99
- export function decryptWithPassword(password: string, encrypted: string): string {
100
- const key = scrypt(
101
- new TextEncoder().encode(password),
102
- hexToBytes("${context.config.crypto.salt ? context.config.crypto.salt : "nonce"}"),
103
- 1048576, // requires 1GB of RAM to calculate
104
- 8,
105
- 1,
106
- 32
107
- );
108
-
109
- const decrypted = chacha20poly1305(key).decrypt(
110
- nonce,
111
- encrypted,
112
- null
113
- );
114
-
115
- return new TextDecoder().decode(decrypted);
116
- }
117
-
118
- /**
119
- * Hashes data using the [BLAKE3](https://en.wikipedia.org/wiki/BLAKE_(hash_function)#BLAKE3) hash function.
120
- *
121
- * @see https://en.wikipedia.org/wiki/BLAKE_(hash_function)#BLAKE3
122
- *
123
- * @param data - The data to hash.
124
- * @returns The hashed data.
125
- */
126
- export function hash(data: string): string {
127
- return Buffer.from(
128
- blake3(new TextEncoder().encode(data), {
129
- key: ${context.config.crypto.salt ? `hexToBytes("${context.config.crypto.salt}")` : "new TextEncoder().encode(\"powerlines\")"})
130
- })
131
- ).toString("hex");
132
- }
133
-
134
- // Export noble cipher and hash functions for advanced usage
135
-
136
- export * from "@noble/ciphers/chacha.js";
137
- export * from "@noble/ciphers/aes.js";
138
- export * from "@noble/ciphers/utils.js";
139
- export * from '@noble/hashes/blake3.js';
140
- export * from '@noble/hashes/pbkdf2.js';
141
- export * from '@noble/hashes/scrypt.js';
142
- export * from '@noble/hashes/utils.js';
143
-
144
- `;
145
- }
146
-
147
- //#endregion
148
- exports.cryptoModule = cryptoModule;
@@ -1,13 +0,0 @@
1
- import { CryptoPluginContext } from "../types/plugin.cjs";
2
-
3
- //#region src/components/crypto.d.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
- declare function cryptoModule(context: CryptoPluginContext): string;
11
- //#endregion
12
- export { cryptoModule };
13
- //# sourceMappingURL=crypto.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"crypto.d.cts","names":[],"sources":["../../src/components/crypto.ts"],"mappings":";;;;;AA2BA;;;;iBAAgB,YAAA,CAAa,OAAA,EAAS,mBAAA"}
@@ -1,13 +0,0 @@
1
- import { CryptoPluginContext } from "../types/plugin.mjs";
2
-
3
- //#region src/components/crypto.d.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
- declare function cryptoModule(context: CryptoPluginContext): string;
11
- //#endregion
12
- export { cryptoModule };
13
- //# sourceMappingURL=crypto.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"crypto.d.mts","names":[],"sources":["../../src/components/crypto.ts"],"mappings":";;;;;AA2BA;;;;iBAAgB,YAAA,CAAa,OAAA,EAAS,mBAAA"}
@@ -1,148 +0,0 @@
1
- import { getFileHeader } from "powerlines/utils";
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 `
12
- /**
13
- * The cryptography module provides custom helper functions to support encrypting and decrypting data.
14
- *
15
- * @module ${context.config.framework}:crypto
16
- */
17
-
18
- ${getFileHeader(context)}
19
-
20
- import { xchacha20poly1305, chacha20poly1305 } from "@noble/ciphers/chacha.js";
21
- import { randomBytes, managedNonce, hexToBytes } from "@noble/ciphers/utils.js";
22
- import { scrypt } from "@noble/hashes/scrypt.js";
23
- import { blake3 } from "@noble/hashes/blake3.js";
24
- ${context.config.crypto.encryptionKey ? `
25
- const nonce = randomBytes(24);
26
- const chacha = xchacha20poly1305(hexToBytes("${context.config.crypto.encryptionKey}"), nonce);
27
-
28
- /**
29
- * Symmetrically encrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher.
30
- *
31
- * @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305
32
- *
33
- * @param plaintext - The data to encrypt.
34
- * @returns The encrypted data.
35
- */
36
- export function encrypt(plaintext: string): string {
37
- return chacha.encrypt(
38
- nonce,
39
- new TextEncoder().encode(plaintext),
40
- null
41
- );
42
- }
43
-
44
- /**
45
- * Symmetrically decrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher.
46
- *
47
- * @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305
48
- *
49
- * @param encrypted - The encrypted data to decrypt.
50
- * @returns The decrypted data.
51
- */
52
- export function decrypt(encrypted: string): string {
53
- const decrypted = chacha.decrypt(
54
- nonce,
55
- encrypted,
56
- null
57
- );
58
-
59
- return new TextDecoder().decode(decrypted);
60
- }
61
- ` : ""}
62
-
63
- /**
64
- * Symmetrically encrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher with a password.
65
- *
66
- * @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305
67
- *
68
- * @param password - The password used to derive the encryption key.
69
- * @param plaintext - The data to encrypt.
70
- * @returns The encrypted data.
71
- */
72
- export function encryptWithPassword(password: string, plaintext: string): string {
73
- const key = scrypt(
74
- new TextEncoder().encode(password),
75
- hexToBytes("${context.config.crypto.salt ? context.config.crypto.salt : "nonce"}"),
76
- 1048576, // requires 1GB of RAM to calculate
77
- 8,
78
- 1,
79
- 32
80
- );
81
-
82
- return chacha20poly1305(key).encrypt(
83
- nonce,
84
- new TextEncoder().encode(plaintext),
85
- null
86
- );
87
- }
88
-
89
- /**
90
- * Symmetrically decrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher with a password.
91
- *
92
- * @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305
93
- *
94
- * @param password - The password used to derive the decryption key.
95
- * @param encrypted - The encrypted data to decrypt.
96
- * @returns The decrypted data.
97
- */
98
- export function decryptWithPassword(password: string, encrypted: string): string {
99
- const key = scrypt(
100
- new TextEncoder().encode(password),
101
- hexToBytes("${context.config.crypto.salt ? context.config.crypto.salt : "nonce"}"),
102
- 1048576, // requires 1GB of RAM to calculate
103
- 8,
104
- 1,
105
- 32
106
- );
107
-
108
- const decrypted = chacha20poly1305(key).decrypt(
109
- nonce,
110
- encrypted,
111
- null
112
- );
113
-
114
- return new TextDecoder().decode(decrypted);
115
- }
116
-
117
- /**
118
- * Hashes data using the [BLAKE3](https://en.wikipedia.org/wiki/BLAKE_(hash_function)#BLAKE3) hash function.
119
- *
120
- * @see https://en.wikipedia.org/wiki/BLAKE_(hash_function)#BLAKE3
121
- *
122
- * @param data - The data to hash.
123
- * @returns The hashed data.
124
- */
125
- export function hash(data: string): string {
126
- return Buffer.from(
127
- blake3(new TextEncoder().encode(data), {
128
- key: ${context.config.crypto.salt ? `hexToBytes("${context.config.crypto.salt}")` : "new TextEncoder().encode(\"powerlines\")"})
129
- })
130
- ).toString("hex");
131
- }
132
-
133
- // Export noble cipher and hash functions for advanced usage
134
-
135
- export * from "@noble/ciphers/chacha.js";
136
- export * from "@noble/ciphers/aes.js";
137
- export * from "@noble/ciphers/utils.js";
138
- export * from '@noble/hashes/blake3.js';
139
- export * from '@noble/hashes/pbkdf2.js';
140
- export * from '@noble/hashes/scrypt.js';
141
- export * from '@noble/hashes/utils.js';
142
-
143
- `;
144
- }
145
-
146
- //#endregion
147
- export { cryptoModule };
148
- //# sourceMappingURL=crypto.mjs.map
@@ -1 +0,0 @@
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":";;;;;;;;;AA2BA,SAAgB,aAAa,SAA8B;AACzD,QAAO;;;;aAII,QAAQ,OAAO,UAAU;;;EAGpC,cAAc,QAAQ,CAAC;;;;;;EAOvB,QAAQ,OAAO,OAAO,gBAClB;;+CAGE,QAAQ,OAAO,OAAO,cACvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAoCD,GACL;;;;;;;;;;;;;;kBAciB,QAAQ,OAAO,OAAO,OAAO,QAAQ,OAAO,OAAO,OAAO,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;kBA0BlE,QAAQ,OAAO,OAAO,OAAO,QAAQ,OAAO,OAAO,OAAO,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;aA4B5E,QAAQ,OAAO,OAAO,OAClB,eAAe,QAAQ,OAAO,OAAO,KAAK,MAC1C,2CACL"}
@@ -1 +0,0 @@
1
- const require_crypto = require('./crypto.cjs');
@@ -1 +0,0 @@
1
- import { cryptoModule } from "./crypto.cjs";
@@ -1 +0,0 @@
1
- import { cryptoModule } from "./crypto.mjs";
@@ -1,3 +0,0 @@
1
- import { cryptoModule } from "./crypto.mjs";
2
-
3
- export { };
package/dist/index.cjs DELETED
@@ -1,45 +0,0 @@
1
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
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);
8
- let defu = require("defu");
9
- defu = require_runtime.__toESM(defu);
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.workspaceConfig?.name) || this.packageJson?.name}-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;
package/dist/index.d.cts DELETED
@@ -1,17 +0,0 @@
1
- import { CryptoPluginContext, CryptoPluginOptions, CryptoPluginResolvedConfig, CryptoPluginUserConfig, __ΩCryptoPluginContext, __ΩCryptoPluginOptions, __ΩCryptoPluginResolvedConfig, __ΩCryptoPluginUserConfig } from "./types/plugin.cjs";
2
- import { cryptoModule } from "./components/crypto.cjs";
3
- import { Plugin } from "powerlines";
4
-
5
- //#region src/index.d.ts
6
- declare module "powerlines" {
7
- interface Config {
8
- crypto?: CryptoPluginOptions;
9
- }
10
- }
11
- /**
12
- * A Powerlines plugin to assist in developing other Powerlines plugins.
13
- */
14
- declare function plugin<TContext extends CryptoPluginContext = CryptoPluginContext>(options?: CryptoPluginOptions): Plugin<TContext>[];
15
- //#endregion
16
- export { CryptoPluginContext, CryptoPluginOptions, CryptoPluginResolvedConfig, CryptoPluginUserConfig, __ΩCryptoPluginContext, __ΩCryptoPluginOptions, __ΩCryptoPluginResolvedConfig, __ΩCryptoPluginUserConfig, cryptoModule, plugin as default, plugin };
17
- //# sourceMappingURL=index.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;YA6BY,MAAA;IACR,MAAA,GAAS,mBAAA;EAAA;AAAA;;;;iBAOG,MAAA,kBACG,mBAAA,GAAsB,mBAAA,CAAA,CACvC,OAAA,GAAS,mBAAA,GAgDJ,MAAA,CAAO,QAAA"}
package/dist/index.d.mts DELETED
@@ -1,17 +0,0 @@
1
- import { CryptoPluginContext, CryptoPluginOptions, CryptoPluginResolvedConfig, CryptoPluginUserConfig, __ΩCryptoPluginContext, __ΩCryptoPluginOptions, __ΩCryptoPluginResolvedConfig, __ΩCryptoPluginUserConfig } from "./types/plugin.mjs";
2
- import { cryptoModule } from "./components/crypto.mjs";
3
- import { Plugin } from "powerlines";
4
-
5
- //#region src/index.d.ts
6
- declare module "powerlines" {
7
- interface Config {
8
- crypto?: CryptoPluginOptions;
9
- }
10
- }
11
- /**
12
- * A Powerlines plugin to assist in developing other Powerlines plugins.
13
- */
14
- declare function plugin<TContext extends CryptoPluginContext = CryptoPluginContext>(options?: CryptoPluginOptions): Plugin<TContext>[];
15
- //#endregion
16
- export { CryptoPluginContext, CryptoPluginOptions, CryptoPluginResolvedConfig, CryptoPluginUserConfig, __ΩCryptoPluginContext, __ΩCryptoPluginOptions, __ΩCryptoPluginResolvedConfig, __ΩCryptoPluginUserConfig, cryptoModule, plugin as default, plugin };
17
- //# sourceMappingURL=index.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;YA6BY,MAAA;IACR,MAAA,GAAS,mBAAA;EAAA;AAAA;;;;iBAOG,MAAA,kBACG,mBAAA,GAAsB,mBAAA,CAAA,CACvC,OAAA,GAAS,mBAAA,GAgDJ,MAAA,CAAO,QAAA"}
package/dist/index.mjs DELETED
@@ -1,40 +0,0 @@
1
- import { cryptoModule } from "./components/crypto.mjs";
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.workspaceConfig?.name) || this.packageJson?.name}-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 };
40
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
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: `${\n (this.config.name ?? this.workspaceConfig?.name) ||\n this.packageJson?.name\n }-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":";;;;;;;;;;AAqCA,SAAgB,OAEd,UAA+B,EAAE,EAAE;AACnC,QAAO,CACL,IAAI,QAAQ,IAAI,EAChB;EACE,MAAM;EACN,SAAS;AACP,UAAO,EACL,QAAQ,KAAK,SAAS,EACpB,MAAM,IACH,KAAK,OAAO,QAAQ,KAAK,iBAAiB,SAC3C,KAAK,aAAa,KACnB,eACF,CAAC,EACH;;EAEH,iBAAiB;AACf,QAAK,aAAa,oBAAoB;AACtC,QAAK,aAAa,mBAAmB;AAErC,QAAK,OAAO,OAAO,SAAS,KAAK,IAAI,OAAO;AAC5C,OAAI,CAAC,KAAK,OAAO,OAAO,MAAM;AAC5B,SAAK,KACH,iOACD;AAED,SAAK,OAAO,OAAO,OAAO,WAAW,YAAY,GAAG,CAAC;;AAGvD,QAAK,OAAO,OAAO,kBAAkB,KAAK,IAAI,OAAO;AACrD,OAAI,CAAC,KAAK,OAAO,OAAO,eAAe;AACrC,SAAK,KACH,kQACD;AAED,SAAK,OAAO,OAAO,gBAAgB,WAAW,YAAY,GAAG,CAAC;;;EAGlE,MAAM,UAAU;AACd,QAAK,MACH,qEACD;AAED,SAAM,KAAK,YACT,MAAM,QAAQ,QAAQ,aAAa,KAAK,CAAC,EACzC,SACD;;EAEJ,CACF"}
File without changes
@@ -1,2 +0,0 @@
1
- import { CryptoPluginContext, CryptoPluginOptions, CryptoPluginResolvedConfig, CryptoPluginUserConfig, __ΩCryptoPluginContext, __ΩCryptoPluginOptions, __ΩCryptoPluginResolvedConfig, __ΩCryptoPluginUserConfig } from "./plugin.cjs";
2
- export { CryptoPluginContext, CryptoPluginOptions, CryptoPluginResolvedConfig, CryptoPluginUserConfig, __ΩCryptoPluginContext, __ΩCryptoPluginOptions, __ΩCryptoPluginResolvedConfig, __ΩCryptoPluginUserConfig };
@@ -1,2 +0,0 @@
1
- import { CryptoPluginContext, CryptoPluginOptions, CryptoPluginResolvedConfig, CryptoPluginUserConfig, __ΩCryptoPluginContext, __ΩCryptoPluginOptions, __ΩCryptoPluginResolvedConfig, __ΩCryptoPluginUserConfig } from "./plugin.mjs";
2
- export { CryptoPluginContext, CryptoPluginOptions, CryptoPluginResolvedConfig, CryptoPluginUserConfig, __ΩCryptoPluginContext, __ΩCryptoPluginOptions, __ΩCryptoPluginResolvedConfig, __ΩCryptoPluginUserConfig };
@@ -1 +0,0 @@
1
- export { };
File without changes
@@ -1,43 +0,0 @@
1
- import { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig } from "@powerlines/plugin-env/types/plugin";
2
-
3
- //#region src/types/plugin.d.ts
4
- interface CryptoPluginOptions {
5
- /**
6
- * The application specific secret used for encrypting and decrypting data.
7
- *
8
- * @remarks
9
- * If not provided, the plugin will attempt to read the key from the `SALT` environment variable.
10
- */
11
- salt?: string;
12
- /**
13
- * The encryption key used for encrypting and decrypting data.
14
- *
15
- * @remarks
16
- * If not provided, the plugin will attempt to read the key from the `ENCRYPTION_KEY` environment variable.
17
- */
18
- encryptionKey?: string;
19
- /**
20
- * Options for the Env plugin.
21
- */
22
- env?: EnvPluginOptions;
23
- }
24
- interface CryptoPluginUserConfig extends EnvPluginUserConfig {
25
- /**
26
- * Options for the Crypto plugin.
27
- */
28
- crypto?: Omit<CryptoPluginOptions, "env">;
29
- }
30
- interface CryptoPluginResolvedConfig extends EnvPluginResolvedConfig {
31
- /**
32
- * Options for the Crypto plugin.
33
- */
34
- crypto: Required<Omit<CryptoPluginOptions, "env">>;
35
- }
36
- type CryptoPluginContext<TResolvedConfig extends CryptoPluginResolvedConfig = CryptoPluginResolvedConfig> = EnvPluginContext<TResolvedConfig>;
37
- declare type __ΩCryptoPluginOptions = any[];
38
- declare type __ΩCryptoPluginUserConfig = any[];
39
- declare type __ΩCryptoPluginResolvedConfig = any[];
40
- declare type __ΩCryptoPluginContext = any[];
41
- //#endregion
42
- export { CryptoPluginContext, CryptoPluginOptions, CryptoPluginResolvedConfig, CryptoPluginUserConfig, __ΩCryptoPluginContext, __ΩCryptoPluginOptions, __ΩCryptoPluginResolvedConfig, __ΩCryptoPluginUserConfig };
43
- //# sourceMappingURL=plugin.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;UAyBiB,mBAAA;;AAAjB;;;;;EAOE,IAAA;EAaA;;;;AAGF;;EARE,aAAA;EAYc;;;EAPd,GAAA,GAAM,gBAAA;AAAA;AAAA,UAGS,sBAAA,SAA+B,mBAAA;EAI9C;;;EAAA,MAAA,GAAS,IAAA,CAAK,mBAAA;AAAA;AAAA,UAGC,0BAAA,SAAmC,uBAAA;EAAR;;;EAI1C,MAAA,EAAQ,QAAA,CAAS,IAAA,CAAK,mBAAA;AAAA;AAAA,KAGZ,mBAAA,yBACc,0BAAA,GACtB,0BAAA,IACA,gBAAA,CAAiB,eAAA;AAAA"}
@@ -1,43 +0,0 @@
1
- import { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig } from "@powerlines/plugin-env/types/plugin";
2
-
3
- //#region src/types/plugin.d.ts
4
- interface CryptoPluginOptions {
5
- /**
6
- * The application specific secret used for encrypting and decrypting data.
7
- *
8
- * @remarks
9
- * If not provided, the plugin will attempt to read the key from the `SALT` environment variable.
10
- */
11
- salt?: string;
12
- /**
13
- * The encryption key used for encrypting and decrypting data.
14
- *
15
- * @remarks
16
- * If not provided, the plugin will attempt to read the key from the `ENCRYPTION_KEY` environment variable.
17
- */
18
- encryptionKey?: string;
19
- /**
20
- * Options for the Env plugin.
21
- */
22
- env?: EnvPluginOptions;
23
- }
24
- interface CryptoPluginUserConfig extends EnvPluginUserConfig {
25
- /**
26
- * Options for the Crypto plugin.
27
- */
28
- crypto?: Omit<CryptoPluginOptions, "env">;
29
- }
30
- interface CryptoPluginResolvedConfig extends EnvPluginResolvedConfig {
31
- /**
32
- * Options for the Crypto plugin.
33
- */
34
- crypto: Required<Omit<CryptoPluginOptions, "env">>;
35
- }
36
- type CryptoPluginContext<TResolvedConfig extends CryptoPluginResolvedConfig = CryptoPluginResolvedConfig> = EnvPluginContext<TResolvedConfig>;
37
- declare type __ΩCryptoPluginOptions = any[];
38
- declare type __ΩCryptoPluginUserConfig = any[];
39
- declare type __ΩCryptoPluginResolvedConfig = any[];
40
- declare type __ΩCryptoPluginContext = any[];
41
- //#endregion
42
- export { CryptoPluginContext, CryptoPluginOptions, CryptoPluginResolvedConfig, CryptoPluginUserConfig, __ΩCryptoPluginContext, __ΩCryptoPluginOptions, __ΩCryptoPluginResolvedConfig, __ΩCryptoPluginUserConfig };
43
- //# sourceMappingURL=plugin.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;UAyBiB,mBAAA;;AAAjB;;;;;EAOE,IAAA;EAaA;;;;AAGF;;EARE,aAAA;EAYc;;;EAPd,GAAA,GAAM,gBAAA;AAAA;AAAA,UAGS,sBAAA,SAA+B,mBAAA;EAI9C;;;EAAA,MAAA,GAAS,IAAA,CAAK,mBAAA;AAAA;AAAA,UAGC,0BAAA,SAAmC,uBAAA;EAAR;;;EAI1C,MAAA,EAAQ,QAAA,CAAS,IAAA,CAAK,mBAAA;AAAA;AAAA,KAGZ,mBAAA,yBACc,0BAAA,GACtB,0BAAA,IACA,gBAAA,CAAiB,eAAA;AAAA"}
@@ -1 +0,0 @@
1
- export { };