@powerlines/plugin-crypto 0.10.264 → 0.10.265
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 +29 -0
- package/dist/components/crypto.cjs +148 -0
- package/dist/components/crypto.d.cts +14 -0
- package/dist/components/crypto.d.cts.map +1 -0
- package/dist/components/crypto.d.mts +14 -0
- package/dist/components/crypto.d.mts.map +1 -0
- package/dist/components/crypto.mjs +148 -0
- package/dist/components/crypto.mjs.map +1 -0
- package/dist/components/index.cjs +1 -0
- package/dist/components/index.d.cts +1 -0
- package/dist/components/index.d.mts +1 -0
- package/dist/components/index.mjs +3 -0
- package/dist/index.cjs +7 -178
- package/dist/index.d.cts +4 -12
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +4 -12
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -147
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.cjs +0 -2
- package/dist/types/index.d.cts +1 -2
- package/dist/types/index.d.mts +1 -2
- package/dist/types/index.mjs +0 -3
- package/dist/types/plugin.cjs +0 -1
- package/dist/types/plugin.d.cts +43 -2
- package/dist/types/plugin.d.cts.map +1 -0
- package/dist/types/plugin.d.mts +43 -2
- package/dist/types/plugin.d.mts.map +1 -0
- package/dist/types/plugin.mjs +0 -2
- package/package.json +5 -5
- package/dist/index-BgAdqTbb.d.mts +0 -1
- package/dist/index-CEgs-Dz2.d.cts +0 -1
- package/dist/plugin-C3MaN5jp.mjs +0 -1
- package/dist/plugin-Cf2rp5ZX.d.cts +0 -43
- package/dist/plugin-Cf2rp5ZX.d.cts.map +0 -1
- package/dist/plugin-DHXHjv16.cjs +0 -0
- package/dist/plugin-DKdZAcdo.d.mts +0 -43
- package/dist/plugin-DKdZAcdo.d.mts.map +0 -1
- package/dist/types-CTUnla4x.mjs +0 -1
- package/dist/types-DHkg7xmX.cjs +0 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
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;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let powerlines_lib_utilities_file_header = require("powerlines/lib/utilities/file-header");
|
|
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_lib_utilities_file_header.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;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CryptoPluginContext } from "../types/plugin.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/components/crypto.d.ts
|
|
4
|
+
|
|
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
|
+
declare function cryptoModule(context: CryptoPluginContext): string;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { cryptoModule };
|
|
14
|
+
//# sourceMappingURL=crypto.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.d.cts","names":[],"sources":["../../src/components/crypto.ts"],"sourcesContent":[],"mappings":";;;;;;AA2BA;;;;iBAAgB,YAAA,UAAsB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CryptoPluginContext } from "../types/plugin.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/components/crypto.d.ts
|
|
4
|
+
|
|
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
|
+
declare function cryptoModule(context: CryptoPluginContext): string;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { cryptoModule };
|
|
14
|
+
//# sourceMappingURL=crypto.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.d.mts","names":[],"sources":["../../src/components/crypto.ts"],"sourcesContent":[],"mappings":";;;;;;AA2BA;;;;iBAAgB,YAAA,UAAsB"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { getFileHeader } from "powerlines/lib/utilities/file-header";
|
|
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
|
|
@@ -0,0 +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/lib/utilities/file-header\";\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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const require_crypto = require('./crypto.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { cryptoModule } from "./crypto.cjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { cryptoModule } from "./crypto.mjs";
|
package/dist/index.cjs
CHANGED
|
@@ -1,184 +1,13 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
-
key = keys[i];
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
14
|
-
__defProp(to, key, {
|
|
15
|
-
get: ((k) => from[k]).bind(null, key),
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return to;
|
|
22
|
-
};
|
|
23
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
-
value: mod,
|
|
25
|
-
enumerable: true
|
|
26
|
-
}) : target, mod));
|
|
27
|
-
|
|
28
|
-
//#endregion
|
|
29
|
-
require('./plugin-DHXHjv16.cjs');
|
|
30
|
-
require('./types-DHkg7xmX.cjs');
|
|
2
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
3
|
+
const require_crypto = require('./components/crypto.cjs');
|
|
4
|
+
require('./components/index.cjs');
|
|
31
5
|
let __noble_ciphers_utils_js = require("@noble/ciphers/utils.js");
|
|
32
6
|
let __powerlines_plugin_env = require("@powerlines/plugin-env");
|
|
33
|
-
__powerlines_plugin_env = __toESM(__powerlines_plugin_env);
|
|
7
|
+
__powerlines_plugin_env = require_rolldown_runtime.__toESM(__powerlines_plugin_env);
|
|
34
8
|
let defu = require("defu");
|
|
35
|
-
defu = __toESM(defu);
|
|
36
|
-
let powerlines_lib_utilities_file_header = require("powerlines/lib/utilities/file-header");
|
|
37
|
-
|
|
38
|
-
//#region src/components/crypto.ts
|
|
39
|
-
/**
|
|
40
|
-
* Generates the crypto module content.
|
|
41
|
-
*
|
|
42
|
-
* @param context - The build context containing runtime information.
|
|
43
|
-
* @returns A string representing the crypto module code.
|
|
44
|
-
*/
|
|
45
|
-
function cryptoModule(context) {
|
|
46
|
-
return `
|
|
47
|
-
/**
|
|
48
|
-
* The cryptography module provides custom helper functions to support encrypting and decrypting data.
|
|
49
|
-
*
|
|
50
|
-
* @module ${context.config.framework}:crypto
|
|
51
|
-
*/
|
|
52
|
-
|
|
53
|
-
${(0, powerlines_lib_utilities_file_header.getFileHeader)(context)}
|
|
54
|
-
|
|
55
|
-
import { xchacha20poly1305, chacha20poly1305 } from "@noble/ciphers/chacha.js";
|
|
56
|
-
import { randomBytes, managedNonce, hexToBytes } from "@noble/ciphers/utils.js";
|
|
57
|
-
import { scrypt } from "@noble/hashes/scrypt.js";
|
|
58
|
-
import { blake3 } from "@noble/hashes/blake3.js";
|
|
59
|
-
${context.config.crypto.encryptionKey ? `
|
|
60
|
-
const nonce = randomBytes(24);
|
|
61
|
-
const chacha = xchacha20poly1305(hexToBytes("${context.config.crypto.encryptionKey}"), nonce);
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Symmetrically encrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher.
|
|
65
|
-
*
|
|
66
|
-
* @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305
|
|
67
|
-
*
|
|
68
|
-
* @param plaintext - The data to encrypt.
|
|
69
|
-
* @returns The encrypted data.
|
|
70
|
-
*/
|
|
71
|
-
export function encrypt(plaintext: string): string {
|
|
72
|
-
return chacha.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.
|
|
81
|
-
*
|
|
82
|
-
* @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305
|
|
83
|
-
*
|
|
84
|
-
* @param encrypted - The encrypted data to decrypt.
|
|
85
|
-
* @returns The decrypted data.
|
|
86
|
-
*/
|
|
87
|
-
export function decrypt(encrypted: string): string {
|
|
88
|
-
const decrypted = chacha.decrypt(
|
|
89
|
-
nonce,
|
|
90
|
-
encrypted,
|
|
91
|
-
null
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
return new TextDecoder().decode(decrypted);
|
|
95
|
-
}
|
|
96
|
-
` : ""}
|
|
9
|
+
defu = require_rolldown_runtime.__toESM(defu);
|
|
97
10
|
|
|
98
|
-
/**
|
|
99
|
-
* Symmetrically encrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher with a password.
|
|
100
|
-
*
|
|
101
|
-
* @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305
|
|
102
|
-
*
|
|
103
|
-
* @param password - The password used to derive the encryption key.
|
|
104
|
-
* @param plaintext - The data to encrypt.
|
|
105
|
-
* @returns The encrypted data.
|
|
106
|
-
*/
|
|
107
|
-
export function encryptWithPassword(password: string, plaintext: string): string {
|
|
108
|
-
const key = scrypt(
|
|
109
|
-
new TextEncoder().encode(password),
|
|
110
|
-
hexToBytes("${context.config.crypto.salt ? context.config.crypto.salt : "nonce"}"),
|
|
111
|
-
1048576, // requires 1GB of RAM to calculate
|
|
112
|
-
8,
|
|
113
|
-
1,
|
|
114
|
-
32
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
return chacha20poly1305(key).encrypt(
|
|
118
|
-
nonce,
|
|
119
|
-
new TextEncoder().encode(plaintext),
|
|
120
|
-
null
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Symmetrically decrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher with a password.
|
|
126
|
-
*
|
|
127
|
-
* @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305
|
|
128
|
-
*
|
|
129
|
-
* @param password - The password used to derive the decryption key.
|
|
130
|
-
* @param encrypted - The encrypted data to decrypt.
|
|
131
|
-
* @returns The decrypted data.
|
|
132
|
-
*/
|
|
133
|
-
export function decryptWithPassword(password: string, encrypted: string): string {
|
|
134
|
-
const key = scrypt(
|
|
135
|
-
new TextEncoder().encode(password),
|
|
136
|
-
hexToBytes("${context.config.crypto.salt ? context.config.crypto.salt : "nonce"}"),
|
|
137
|
-
1048576, // requires 1GB of RAM to calculate
|
|
138
|
-
8,
|
|
139
|
-
1,
|
|
140
|
-
32
|
|
141
|
-
);
|
|
142
|
-
|
|
143
|
-
const decrypted = chacha20poly1305(key).decrypt(
|
|
144
|
-
nonce,
|
|
145
|
-
encrypted,
|
|
146
|
-
null
|
|
147
|
-
);
|
|
148
|
-
|
|
149
|
-
return new TextDecoder().decode(decrypted);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Hashes data using the [BLAKE3](https://en.wikipedia.org/wiki/BLAKE_(hash_function)#BLAKE3) hash function.
|
|
154
|
-
*
|
|
155
|
-
* @see https://en.wikipedia.org/wiki/BLAKE_(hash_function)#BLAKE3
|
|
156
|
-
*
|
|
157
|
-
* @param data - The data to hash.
|
|
158
|
-
* @returns The hashed data.
|
|
159
|
-
*/
|
|
160
|
-
export function hash(data: string): string {
|
|
161
|
-
return Buffer.from(
|
|
162
|
-
blake3(new TextEncoder().encode(data), {
|
|
163
|
-
key: ${context.config.crypto.salt ? `hexToBytes("${context.config.crypto.salt}")` : "new TextEncoder().encode(\"powerlines\")"})
|
|
164
|
-
})
|
|
165
|
-
).toString("hex");
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// Export noble cipher and hash functions for advanced usage
|
|
169
|
-
|
|
170
|
-
export * from "@noble/ciphers/chacha.js";
|
|
171
|
-
export * from "@noble/ciphers/aes.js";
|
|
172
|
-
export * from "@noble/ciphers/utils.js";
|
|
173
|
-
export * from '@noble/hashes/blake3.js';
|
|
174
|
-
export * from '@noble/hashes/pbkdf2.js';
|
|
175
|
-
export * from '@noble/hashes/scrypt.js';
|
|
176
|
-
export * from '@noble/hashes/utils.js';
|
|
177
|
-
|
|
178
|
-
`;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
//#endregion
|
|
182
11
|
//#region src/index.ts
|
|
183
12
|
/**
|
|
184
13
|
* A Powerlines plugin to assist in developing other Powerlines plugins.
|
|
@@ -205,13 +34,13 @@ function plugin(options = {}) {
|
|
|
205
34
|
},
|
|
206
35
|
async prepare() {
|
|
207
36
|
this.debug(`Preparing the Crypto runtime artifacts for the Powerlines project.`);
|
|
208
|
-
await this.emitBuiltin(await Promise.resolve(cryptoModule(this)), "crypto");
|
|
37
|
+
await this.emitBuiltin(await Promise.resolve(require_crypto.cryptoModule(this)), "crypto");
|
|
209
38
|
}
|
|
210
39
|
}];
|
|
211
40
|
}
|
|
212
41
|
var src_default = plugin;
|
|
213
42
|
|
|
214
43
|
//#endregion
|
|
215
|
-
exports.cryptoModule = cryptoModule;
|
|
44
|
+
exports.cryptoModule = require_crypto.cryptoModule;
|
|
216
45
|
exports.default = src_default;
|
|
217
46
|
exports.plugin = plugin;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./
|
|
1
|
+
import { CryptoPluginContext, CryptoPluginOptions, CryptoPluginResolvedConfig, CryptoPluginUserConfig, __ΩCryptoPluginContext, __ΩCryptoPluginOptions, __ΩCryptoPluginResolvedConfig, __ΩCryptoPluginUserConfig } from "./types/plugin.cjs";
|
|
2
|
+
import { cryptoModule } from "./components/crypto.cjs";
|
|
3
|
+
import "./components/index.cjs";
|
|
4
|
+
import "./types/index.cjs";
|
|
3
5
|
import { Plugin } from "powerlines/types/plugin";
|
|
4
6
|
|
|
5
|
-
//#region src/components/crypto.d.ts
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Generates the crypto module content.
|
|
9
|
-
*
|
|
10
|
-
* @param context - The build context containing runtime information.
|
|
11
|
-
* @returns A string representing the crypto module code.
|
|
12
|
-
*/
|
|
13
|
-
declare function cryptoModule(context: CryptoPluginContext): string;
|
|
14
|
-
//#endregion
|
|
15
7
|
//#region src/index.d.ts
|
|
16
8
|
/**
|
|
17
9
|
* A Powerlines plugin to assist in developing other Powerlines plugins.
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AA+BgB,iBAAA,MAAM,CAAA,iBACH,mBADG,GACmB,mBADnB,CAAA,CAAA,OAAA,CAAA,EAEX,mBAFW,CAAA,EAkDf,MAlDe,CAkDR,QAlDQ,CAAA,EAAA"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./
|
|
1
|
+
import { CryptoPluginContext, CryptoPluginOptions, CryptoPluginResolvedConfig, CryptoPluginUserConfig, __ΩCryptoPluginContext, __ΩCryptoPluginOptions, __ΩCryptoPluginResolvedConfig, __ΩCryptoPluginUserConfig } from "./types/plugin.mjs";
|
|
2
|
+
import { cryptoModule } from "./components/crypto.mjs";
|
|
3
|
+
import "./components/index.mjs";
|
|
4
|
+
import "./types/index.mjs";
|
|
3
5
|
import { Plugin } from "powerlines/types/plugin";
|
|
4
6
|
|
|
5
|
-
//#region src/components/crypto.d.ts
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Generates the crypto module content.
|
|
9
|
-
*
|
|
10
|
-
* @param context - The build context containing runtime information.
|
|
11
|
-
* @returns A string representing the crypto module code.
|
|
12
|
-
*/
|
|
13
|
-
declare function cryptoModule(context: CryptoPluginContext): string;
|
|
14
|
-
//#endregion
|
|
15
7
|
//#region src/index.d.ts
|
|
16
8
|
/**
|
|
17
9
|
* A Powerlines plugin to assist in developing other Powerlines plugins.
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AA+BgB,iBAAA,MAAM,CAAA,iBACH,mBADG,GACmB,mBADnB,CAAA,CAAA,OAAA,CAAA,EAEX,mBAFW,CAAA,EAkDf,MAlDe,CAkDR,QAlDQ,CAAA,EAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,154 +1,9 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import "./
|
|
1
|
+
import { cryptoModule } from "./components/crypto.mjs";
|
|
2
|
+
import "./components/index.mjs";
|
|
3
3
|
import { bytesToHex, randomBytes } from "@noble/ciphers/utils.js";
|
|
4
4
|
import env from "@powerlines/plugin-env";
|
|
5
5
|
import defu from "defu";
|
|
6
|
-
import { getFileHeader } from "powerlines/lib/utilities/file-header";
|
|
7
6
|
|
|
8
|
-
//#region src/components/crypto.ts
|
|
9
|
-
/**
|
|
10
|
-
* Generates the crypto module content.
|
|
11
|
-
*
|
|
12
|
-
* @param context - The build context containing runtime information.
|
|
13
|
-
* @returns A string representing the crypto module code.
|
|
14
|
-
*/
|
|
15
|
-
function cryptoModule(context) {
|
|
16
|
-
return `
|
|
17
|
-
/**
|
|
18
|
-
* The cryptography module provides custom helper functions to support encrypting and decrypting data.
|
|
19
|
-
*
|
|
20
|
-
* @module ${context.config.framework}:crypto
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
${getFileHeader(context)}
|
|
24
|
-
|
|
25
|
-
import { xchacha20poly1305, chacha20poly1305 } from "@noble/ciphers/chacha.js";
|
|
26
|
-
import { randomBytes, managedNonce, hexToBytes } from "@noble/ciphers/utils.js";
|
|
27
|
-
import { scrypt } from "@noble/hashes/scrypt.js";
|
|
28
|
-
import { blake3 } from "@noble/hashes/blake3.js";
|
|
29
|
-
${context.config.crypto.encryptionKey ? `
|
|
30
|
-
const nonce = randomBytes(24);
|
|
31
|
-
const chacha = xchacha20poly1305(hexToBytes("${context.config.crypto.encryptionKey}"), nonce);
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Symmetrically encrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher.
|
|
35
|
-
*
|
|
36
|
-
* @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305
|
|
37
|
-
*
|
|
38
|
-
* @param plaintext - The data to encrypt.
|
|
39
|
-
* @returns The encrypted data.
|
|
40
|
-
*/
|
|
41
|
-
export function encrypt(plaintext: string): string {
|
|
42
|
-
return chacha.encrypt(
|
|
43
|
-
nonce,
|
|
44
|
-
new TextEncoder().encode(plaintext),
|
|
45
|
-
null
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Symmetrically decrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher.
|
|
51
|
-
*
|
|
52
|
-
* @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305
|
|
53
|
-
*
|
|
54
|
-
* @param encrypted - The encrypted data to decrypt.
|
|
55
|
-
* @returns The decrypted data.
|
|
56
|
-
*/
|
|
57
|
-
export function decrypt(encrypted: string): string {
|
|
58
|
-
const decrypted = chacha.decrypt(
|
|
59
|
-
nonce,
|
|
60
|
-
encrypted,
|
|
61
|
-
null
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
return new TextDecoder().decode(decrypted);
|
|
65
|
-
}
|
|
66
|
-
` : ""}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Symmetrically encrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher with a password.
|
|
70
|
-
*
|
|
71
|
-
* @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305
|
|
72
|
-
*
|
|
73
|
-
* @param password - The password used to derive the encryption key.
|
|
74
|
-
* @param plaintext - The data to encrypt.
|
|
75
|
-
* @returns The encrypted data.
|
|
76
|
-
*/
|
|
77
|
-
export function encryptWithPassword(password: string, plaintext: string): string {
|
|
78
|
-
const key = scrypt(
|
|
79
|
-
new TextEncoder().encode(password),
|
|
80
|
-
hexToBytes("${context.config.crypto.salt ? context.config.crypto.salt : "nonce"}"),
|
|
81
|
-
1048576, // requires 1GB of RAM to calculate
|
|
82
|
-
8,
|
|
83
|
-
1,
|
|
84
|
-
32
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
return chacha20poly1305(key).encrypt(
|
|
88
|
-
nonce,
|
|
89
|
-
new TextEncoder().encode(plaintext),
|
|
90
|
-
null
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Symmetrically decrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher with a password.
|
|
96
|
-
*
|
|
97
|
-
* @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305
|
|
98
|
-
*
|
|
99
|
-
* @param password - The password used to derive the decryption key.
|
|
100
|
-
* @param encrypted - The encrypted data to decrypt.
|
|
101
|
-
* @returns The decrypted data.
|
|
102
|
-
*/
|
|
103
|
-
export function decryptWithPassword(password: string, encrypted: string): string {
|
|
104
|
-
const key = scrypt(
|
|
105
|
-
new TextEncoder().encode(password),
|
|
106
|
-
hexToBytes("${context.config.crypto.salt ? context.config.crypto.salt : "nonce"}"),
|
|
107
|
-
1048576, // requires 1GB of RAM to calculate
|
|
108
|
-
8,
|
|
109
|
-
1,
|
|
110
|
-
32
|
|
111
|
-
);
|
|
112
|
-
|
|
113
|
-
const decrypted = chacha20poly1305(key).decrypt(
|
|
114
|
-
nonce,
|
|
115
|
-
encrypted,
|
|
116
|
-
null
|
|
117
|
-
);
|
|
118
|
-
|
|
119
|
-
return new TextDecoder().decode(decrypted);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Hashes data using the [BLAKE3](https://en.wikipedia.org/wiki/BLAKE_(hash_function)#BLAKE3) hash function.
|
|
124
|
-
*
|
|
125
|
-
* @see https://en.wikipedia.org/wiki/BLAKE_(hash_function)#BLAKE3
|
|
126
|
-
*
|
|
127
|
-
* @param data - The data to hash.
|
|
128
|
-
* @returns The hashed data.
|
|
129
|
-
*/
|
|
130
|
-
export function hash(data: string): string {
|
|
131
|
-
return Buffer.from(
|
|
132
|
-
blake3(new TextEncoder().encode(data), {
|
|
133
|
-
key: ${context.config.crypto.salt ? `hexToBytes("${context.config.crypto.salt}")` : "new TextEncoder().encode(\"powerlines\")"})
|
|
134
|
-
})
|
|
135
|
-
).toString("hex");
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// Export noble cipher and hash functions for advanced usage
|
|
139
|
-
|
|
140
|
-
export * from "@noble/ciphers/chacha.js";
|
|
141
|
-
export * from "@noble/ciphers/aes.js";
|
|
142
|
-
export * from "@noble/ciphers/utils.js";
|
|
143
|
-
export * from '@noble/hashes/blake3.js';
|
|
144
|
-
export * from '@noble/hashes/pbkdf2.js';
|
|
145
|
-
export * from '@noble/hashes/scrypt.js';
|
|
146
|
-
export * from '@noble/hashes/utils.js';
|
|
147
|
-
|
|
148
|
-
`;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
//#endregion
|
|
152
7
|
//#region src/index.ts
|
|
153
8
|
/**
|
|
154
9
|
* A Powerlines plugin to assist in developing other Powerlines plugins.
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/
|
|
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/types/plugin\";\nimport { cryptoModule } from \"./components/crypto\";\nimport { CryptoPluginContext, CryptoPluginOptions } from \"./types/plugin\";\n\nexport * from \"./components\";\nexport * from \"./types\";\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":";;;;;;;;;;AA+BA,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;;AAGH,kBAAe"}
|
package/dist/types/index.cjs
CHANGED
package/dist/types/index.d.cts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../index-CEgs-Dz2.cjs";
|
|
1
|
+
import { CryptoPluginContext, CryptoPluginOptions, CryptoPluginResolvedConfig, CryptoPluginUserConfig, __ΩCryptoPluginContext, __ΩCryptoPluginOptions, __ΩCryptoPluginResolvedConfig, __ΩCryptoPluginUserConfig } from "./plugin.cjs";
|
|
3
2
|
export { CryptoPluginContext, CryptoPluginOptions, CryptoPluginResolvedConfig, CryptoPluginUserConfig, __ΩCryptoPluginContext, __ΩCryptoPluginOptions, __ΩCryptoPluginResolvedConfig, __ΩCryptoPluginUserConfig };
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../index-BgAdqTbb.mjs";
|
|
1
|
+
import { CryptoPluginContext, CryptoPluginOptions, CryptoPluginResolvedConfig, CryptoPluginUserConfig, __ΩCryptoPluginContext, __ΩCryptoPluginOptions, __ΩCryptoPluginResolvedConfig, __ΩCryptoPluginUserConfig } from "./plugin.mjs";
|
|
3
2
|
export { CryptoPluginContext, CryptoPluginOptions, CryptoPluginResolvedConfig, CryptoPluginUserConfig, __ΩCryptoPluginContext, __ΩCryptoPluginOptions, __ΩCryptoPluginResolvedConfig, __ΩCryptoPluginUserConfig };
|
package/dist/types/index.mjs
CHANGED
package/dist/types/plugin.cjs
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require('../plugin-DHXHjv16.cjs');
|
package/dist/types/plugin.d.cts
CHANGED
|
@@ -1,2 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;UAyBiB,mBAAA;;AAAjB;AAuBA;;;;EAAmE,IAAA,CAAA,EAAA,MAAA;EAOlD;;;;;;EAOL,aAAA,CAAA,EAAA,MAAmB;EACL;;;EAEtB,GAAA,CAAA,EApBI,gBAoBJ;;UAjBa,sBAAA,SAA+B;;;;WAIrC,KAAK;;UAGC,0BAAA,SAAmC;;;;UAI1C,SAAS,KAAK;;KAGZ,4CACc,6BACtB,8BACA,iBAAiB"}
|
package/dist/types/plugin.d.mts
CHANGED
|
@@ -1,2 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;UAyBiB,mBAAA;;AAAjB;AAuBA;;;;EAAmE,IAAA,CAAA,EAAA,MAAA;EAOlD;;;;;;EAOL,aAAA,CAAA,EAAA,MAAmB;EACL;;;EAEtB,GAAA,CAAA,EApBI,gBAoBJ;;UAjBa,sBAAA,SAA+B;;;;WAIrC,KAAK;;UAGC,0BAAA,SAAmC;;;;UAI1C,SAAS,KAAK;;KAGZ,4CACc,6BACtB,8BACA,iBAAiB"}
|
package/dist/types/plugin.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-crypto",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.265",
|
|
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.15.
|
|
90
|
+
"@powerlines/plugin-env": "^0.15.162",
|
|
91
91
|
"@storm-software/config-tools": "^1.189.0",
|
|
92
92
|
"@stryke/path": "^0.26.4",
|
|
93
93
|
"defu": "^6.1.4",
|
|
94
|
-
"powerlines": "^0.38.
|
|
94
|
+
"powerlines": "^0.38.21"
|
|
95
95
|
},
|
|
96
96
|
"devDependencies": {
|
|
97
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
97
|
+
"@powerlines/plugin-plugin": "^0.12.205",
|
|
98
98
|
"@types/node": "^24.10.9"
|
|
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": "6000a15bf3fbc1b7eaaf967088c68eef9949786a"
|
|
105
105
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
package/dist/plugin-C3MaN5jp.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -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 as a, __ΩCryptoPluginUserConfig as c, CryptoPluginUserConfig as i, CryptoPluginOptions as n, __ΩCryptoPluginOptions as o, CryptoPluginResolvedConfig as r, __ΩCryptoPluginResolvedConfig as s, CryptoPluginContext as t };
|
|
43
|
-
//# sourceMappingURL=plugin-Cf2rp5ZX.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-Cf2rp5ZX.d.cts","names":[],"sources":["../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;UAyBiB,mBAAA;;AAAjB;AAuBA;;;;EAAmE,IAAA,CAAA,EAAA,MAAA;EAOlD;;;;;;EAOL,aAAA,CAAA,EAAA,MAAmB;EACL;;;EAEtB,GAAA,CAAA,EApBI,gBAoBJ;;UAjBa,sBAAA,SAA+B;;;;WAIrC,KAAK;;UAGC,0BAAA,SAAmC;;;;UAI1C,SAAS,KAAK;;KAGZ,4CACc,6BACtB,8BACA,iBAAiB"}
|
package/dist/plugin-DHXHjv16.cjs
DELETED
|
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 as a, __ΩCryptoPluginUserConfig as c, CryptoPluginUserConfig as i, CryptoPluginOptions as n, __ΩCryptoPluginOptions as o, CryptoPluginResolvedConfig as r, __ΩCryptoPluginResolvedConfig as s, CryptoPluginContext as t };
|
|
43
|
-
//# sourceMappingURL=plugin-DKdZAcdo.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-DKdZAcdo.d.mts","names":[],"sources":["../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;UAyBiB,mBAAA;;AAAjB;AAuBA;;;;EAAmE,IAAA,CAAA,EAAA,MAAA;EAOlD;;;;;;EAOL,aAAA,CAAA,EAAA,MAAmB;EACL;;;EAEtB,GAAA,CAAA,EApBI,gBAoBJ;;UAjBa,sBAAA,SAA+B;;;;WAIrC,KAAK;;UAGC,0BAAA,SAAmC;;;;UAI1C,SAAS,KAAK;;KAGZ,4CACc,6BACtB,8BACA,iBAAiB"}
|
package/dist/types-CTUnla4x.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
package/dist/types-DHkg7xmX.cjs
DELETED
|
File without changes
|