@powerlines/plugin-crypto 0.10.466 → 0.10.467

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.466",
3
+ "version": "0.10.467",
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.157",
90
+ "@powerlines/plugin-env": "^0.16.158",
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.27"
94
+ "powerlines": "^0.43.28"
95
95
  },
96
96
  "devDependencies": {
97
- "@powerlines/plugin-plugin": "^0.12.382",
97
+ "@powerlines/plugin-plugin": "^0.12.383",
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": "ad851a239011b884c15b0444db518d74927fd13f"
104
+ "gitHead": "efeaec793549f37c700f2e876bf6097c37375c46"
105
105
  }
@@ -1 +0,0 @@
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,133 +0,0 @@
1
- require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`powerlines/utils`);function t(t){return`
2
- /**
3
- * The cryptography module provides custom helper functions to support encrypting and decrypting data.
4
- *
5
- * @module ${t.config.framework}:crypto
6
- */
7
-
8
- ${(0,e.getFileHeader)(t)}
9
-
10
- import { xchacha20poly1305, chacha20poly1305 } from "@noble/ciphers/chacha.js";
11
- import { randomBytes, managedNonce, hexToBytes } from "@noble/ciphers/utils.js";
12
- import { scrypt } from "@noble/hashes/scrypt.js";
13
- import { blake3 } from "@noble/hashes/blake3.js";
14
- ${t.config.crypto.encryptionKey?`
15
- const nonce = randomBytes(24);
16
- const chacha = xchacha20poly1305(hexToBytes("${t.config.crypto.encryptionKey}"), nonce);
17
-
18
- /**
19
- * Symmetrically encrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher.
20
- *
21
- * @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305
22
- *
23
- * @param plaintext - The data to encrypt.
24
- * @returns The encrypted data.
25
- */
26
- export function encrypt(plaintext: string): string {
27
- return chacha.encrypt(
28
- nonce,
29
- new TextEncoder().encode(plaintext),
30
- null
31
- );
32
- }
33
-
34
- /**
35
- * Symmetrically decrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher.
36
- *
37
- * @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305
38
- *
39
- * @param encrypted - The encrypted data to decrypt.
40
- * @returns The decrypted data.
41
- */
42
- export function decrypt(encrypted: string): string {
43
- const decrypted = chacha.decrypt(
44
- nonce,
45
- encrypted,
46
- null
47
- );
48
-
49
- return new TextDecoder().decode(decrypted);
50
- }
51
- `:``}
52
-
53
- /**
54
- * Symmetrically encrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher with a password.
55
- *
56
- * @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305
57
- *
58
- * @param password - The password used to derive the encryption key.
59
- * @param plaintext - The data to encrypt.
60
- * @returns The encrypted data.
61
- */
62
- export function encryptWithPassword(password: string, plaintext: string): string {
63
- const key = scrypt(
64
- new TextEncoder().encode(password),
65
- hexToBytes("${t.config.crypto.salt?t.config.crypto.salt:`nonce`}"),
66
- 1048576, // requires 1GB of RAM to calculate
67
- 8,
68
- 1,
69
- 32
70
- );
71
-
72
- return chacha20poly1305(key).encrypt(
73
- nonce,
74
- new TextEncoder().encode(plaintext),
75
- null
76
- );
77
- }
78
-
79
- /**
80
- * Symmetrically decrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher with a password.
81
- *
82
- * @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305
83
- *
84
- * @param password - The password used to derive the decryption key.
85
- * @param encrypted - The encrypted data to decrypt.
86
- * @returns The decrypted data.
87
- */
88
- export function decryptWithPassword(password: string, encrypted: string): string {
89
- const key = scrypt(
90
- new TextEncoder().encode(password),
91
- hexToBytes("${t.config.crypto.salt?t.config.crypto.salt:`nonce`}"),
92
- 1048576, // requires 1GB of RAM to calculate
93
- 8,
94
- 1,
95
- 32
96
- );
97
-
98
- const decrypted = chacha20poly1305(key).decrypt(
99
- nonce,
100
- encrypted,
101
- null
102
- );
103
-
104
- return new TextDecoder().decode(decrypted);
105
- }
106
-
107
- /**
108
- * Hashes data using the [BLAKE3](https://en.wikipedia.org/wiki/BLAKE_(hash_function)#BLAKE3) hash function.
109
- *
110
- * @see https://en.wikipedia.org/wiki/BLAKE_(hash_function)#BLAKE3
111
- *
112
- * @param data - The data to hash.
113
- * @returns The hashed data.
114
- */
115
- export function hash(data: string): string {
116
- return Buffer.from(
117
- blake3(new TextEncoder().encode(data), {
118
- key: ${t.config.crypto.salt?`hexToBytes("${t.config.crypto.salt}")`:`new TextEncoder().encode("powerlines")`})
119
- })
120
- ).toString("hex");
121
- }
122
-
123
- // Export noble cipher and hash functions for advanced usage
124
-
125
- export * from "@noble/ciphers/chacha.js";
126
- export * from "@noble/ciphers/aes.js";
127
- export * from "@noble/ciphers/utils.js";
128
- export * from '@noble/hashes/blake3.js';
129
- export * from '@noble/hashes/pbkdf2.js';
130
- export * from '@noble/hashes/scrypt.js';
131
- export * from '@noble/hashes/utils.js';
132
-
133
- `}exports.cryptoModule=t;
@@ -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,134 +0,0 @@
1
- import{getFileHeader as e}from"powerlines/utils";function t(t){return`
2
- /**
3
- * The cryptography module provides custom helper functions to support encrypting and decrypting data.
4
- *
5
- * @module ${t.config.framework}:crypto
6
- */
7
-
8
- ${e(t)}
9
-
10
- import { xchacha20poly1305, chacha20poly1305 } from "@noble/ciphers/chacha.js";
11
- import { randomBytes, managedNonce, hexToBytes } from "@noble/ciphers/utils.js";
12
- import { scrypt } from "@noble/hashes/scrypt.js";
13
- import { blake3 } from "@noble/hashes/blake3.js";
14
- ${t.config.crypto.encryptionKey?`
15
- const nonce = randomBytes(24);
16
- const chacha = xchacha20poly1305(hexToBytes("${t.config.crypto.encryptionKey}"), nonce);
17
-
18
- /**
19
- * Symmetrically encrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher.
20
- *
21
- * @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305
22
- *
23
- * @param plaintext - The data to encrypt.
24
- * @returns The encrypted data.
25
- */
26
- export function encrypt(plaintext: string): string {
27
- return chacha.encrypt(
28
- nonce,
29
- new TextEncoder().encode(plaintext),
30
- null
31
- );
32
- }
33
-
34
- /**
35
- * Symmetrically decrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher.
36
- *
37
- * @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305
38
- *
39
- * @param encrypted - The encrypted data to decrypt.
40
- * @returns The decrypted data.
41
- */
42
- export function decrypt(encrypted: string): string {
43
- const decrypted = chacha.decrypt(
44
- nonce,
45
- encrypted,
46
- null
47
- );
48
-
49
- return new TextDecoder().decode(decrypted);
50
- }
51
- `:``}
52
-
53
- /**
54
- * Symmetrically encrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher with a password.
55
- *
56
- * @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305
57
- *
58
- * @param password - The password used to derive the encryption key.
59
- * @param plaintext - The data to encrypt.
60
- * @returns The encrypted data.
61
- */
62
- export function encryptWithPassword(password: string, plaintext: string): string {
63
- const key = scrypt(
64
- new TextEncoder().encode(password),
65
- hexToBytes("${t.config.crypto.salt?t.config.crypto.salt:`nonce`}"),
66
- 1048576, // requires 1GB of RAM to calculate
67
- 8,
68
- 1,
69
- 32
70
- );
71
-
72
- return chacha20poly1305(key).encrypt(
73
- nonce,
74
- new TextEncoder().encode(plaintext),
75
- null
76
- );
77
- }
78
-
79
- /**
80
- * Symmetrically decrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher with a password.
81
- *
82
- * @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305
83
- *
84
- * @param password - The password used to derive the decryption key.
85
- * @param encrypted - The encrypted data to decrypt.
86
- * @returns The decrypted data.
87
- */
88
- export function decryptWithPassword(password: string, encrypted: string): string {
89
- const key = scrypt(
90
- new TextEncoder().encode(password),
91
- hexToBytes("${t.config.crypto.salt?t.config.crypto.salt:`nonce`}"),
92
- 1048576, // requires 1GB of RAM to calculate
93
- 8,
94
- 1,
95
- 32
96
- );
97
-
98
- const decrypted = chacha20poly1305(key).decrypt(
99
- nonce,
100
- encrypted,
101
- null
102
- );
103
-
104
- return new TextDecoder().decode(decrypted);
105
- }
106
-
107
- /**
108
- * Hashes data using the [BLAKE3](https://en.wikipedia.org/wiki/BLAKE_(hash_function)#BLAKE3) hash function.
109
- *
110
- * @see https://en.wikipedia.org/wiki/BLAKE_(hash_function)#BLAKE3
111
- *
112
- * @param data - The data to hash.
113
- * @returns The hashed data.
114
- */
115
- export function hash(data: string): string {
116
- return Buffer.from(
117
- blake3(new TextEncoder().encode(data), {
118
- key: ${t.config.crypto.salt?`hexToBytes("${t.config.crypto.salt}")`:`new TextEncoder().encode("powerlines")`})
119
- })
120
- ).toString("hex");
121
- }
122
-
123
- // Export noble cipher and hash functions for advanced usage
124
-
125
- export * from "@noble/ciphers/chacha.js";
126
- export * from "@noble/ciphers/aes.js";
127
- export * from "@noble/ciphers/utils.js";
128
- export * from '@noble/hashes/blake3.js';
129
- export * from '@noble/hashes/pbkdf2.js';
130
- export * from '@noble/hashes/scrypt.js';
131
- export * from '@noble/hashes/utils.js';
132
-
133
- `}export{t as cryptoModule};
134
- //# 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":"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 +0,0 @@
1
- require(`./crypto.cjs`);
@@ -1 +0,0 @@
1
- import { cryptoModule } from "./crypto.cjs";
@@ -1 +0,0 @@
1
- import { cryptoModule } from "./crypto.mjs";
@@ -1 +0,0 @@
1
- import"./crypto.mjs";export{};
package/dist/index.cjs DELETED
@@ -1 +0,0 @@
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.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,GA6CJ,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,GA6CJ,MAAA,CAAO,QAAA"}
package/dist/index.mjs DELETED
@@ -1,2 +0,0 @@
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};
2
- //# 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: `${(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"}
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{};