@frogbotai/piece-crypto 0.29.0 → 0.31.0
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/actions/decodeBase64.js +9 -4
- package/dist/actions/decodeBase64.js.map +1 -1
- package/dist/actions/encodeBase64.js +9 -4
- package/dist/actions/encodeBase64.js.map +1 -1
- package/dist/actions/encryptFile.d.ts.map +1 -1
- package/dist/actions/encryptFile.js +65 -38
- package/dist/actions/encryptFile.js.map +1 -1
- package/dist/actions/generateHmac.d.ts.map +1 -1
- package/dist/actions/generateHmac.js +32 -8
- package/dist/actions/generateHmac.js.map +1 -1
- package/dist/actions/generatePassword.d.ts.map +1 -1
- package/dist/actions/generatePassword.js +14 -9
- package/dist/actions/generatePassword.js.map +1 -1
- package/dist/actions/generateRsaSignature.js +33 -11
- package/dist/actions/generateRsaSignature.js.map +1 -1
- package/dist/actions/hashText.js +16 -5
- package/dist/actions/hashText.js.map +1 -1
- package/dist/define.js +1 -0
- package/dist/define.js.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { defineAction } from '../define.js';
|
|
3
|
-
const inputSchema = z.object({
|
|
3
|
+
const inputSchema = z.object({
|
|
4
|
+
text: z.string().meta({
|
|
5
|
+
label: 'Text'
|
|
6
|
+
})
|
|
7
|
+
});
|
|
4
8
|
export const decodeBase64 = defineAction({
|
|
5
9
|
slug: 'decodeBase64',
|
|
6
10
|
label: 'Decode Base64',
|
|
7
11
|
description: 'Decode Base64 text as UTF-8.',
|
|
8
12
|
input: inputSchema,
|
|
9
13
|
output: z.string(),
|
|
10
|
-
|
|
11
|
-
return Buffer.from(input.text, 'base64').toString();
|
|
12
|
-
}
|
|
14
|
+
run ({ input }) {
|
|
15
|
+
return Promise.resolve(Buffer.from(input.text, 'base64').toString());
|
|
16
|
+
}
|
|
13
17
|
});
|
|
18
|
+
|
|
14
19
|
//# sourceMappingURL=decodeBase64.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/actions/decodeBase64.ts"],"names":["z","defineAction","inputSchema","object","text","string","meta","label","decodeBase64","slug","description","input","output","run","Promise","resolve","Buffer","from","toString"],"mappings":"AAAA,SAASA,CAAC,QAAQ,MAAM;AAExB,SAASC,YAAY,QAAQ,eAAe;AAE5C,MAAMC,cAAcF,EAAEG,MAAM,CAAC;IAAEC,MAAMJ,EAAEK,MAAM,GAAGC,IAAI,CAAC;QAAEC,OAAO;IAAO;AAAG;AAExE,OAAO,MAAMC,eAAeP,aAAa;IACvCQ,MAAM;IACNF,OAAO;IACPG,aAAa;IACbC,OAAOT;IACPU,QAAQZ,EAAEK,MAAM;IAChBQ,KAAI,EAAEF,KAAK,EAAE;QACX,OAAOG,QAAQC,OAAO,CAACC,OAAOC,IAAI,CAACN,MAAMP,IAAI,EAAE,UAAUc,QAAQ;IACnE;AACF,GAAG","file":"decodeBase64.js"}
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { defineAction } from '../define.js';
|
|
3
|
-
const inputSchema = z.object({
|
|
3
|
+
const inputSchema = z.object({
|
|
4
|
+
text: z.string().meta({
|
|
5
|
+
label: 'Text'
|
|
6
|
+
})
|
|
7
|
+
});
|
|
4
8
|
export const encodeBase64 = defineAction({
|
|
5
9
|
slug: 'encodeBase64',
|
|
6
10
|
label: 'Encode Base64',
|
|
7
11
|
description: 'Encode UTF-8 text as Base64.',
|
|
8
12
|
input: inputSchema,
|
|
9
13
|
output: z.string().regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/),
|
|
10
|
-
|
|
11
|
-
return Buffer.from(input.text).toString('base64');
|
|
12
|
-
}
|
|
14
|
+
run ({ input }) {
|
|
15
|
+
return Promise.resolve(Buffer.from(input.text).toString('base64'));
|
|
16
|
+
}
|
|
13
17
|
});
|
|
18
|
+
|
|
14
19
|
//# sourceMappingURL=encodeBase64.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/actions/encodeBase64.ts"],"names":["z","defineAction","inputSchema","object","text","string","meta","label","encodeBase64","slug","description","input","output","regex","run","Promise","resolve","Buffer","from","toString"],"mappings":"AAAA,SAASA,CAAC,QAAQ,MAAM;AAExB,SAASC,YAAY,QAAQ,eAAe;AAE5C,MAAMC,cAAcF,EAAEG,MAAM,CAAC;IAAEC,MAAMJ,EAAEK,MAAM,GAAGC,IAAI,CAAC;QAAEC,OAAO;IAAO;AAAG;AAExE,OAAO,MAAMC,eAAeP,aAAa;IACvCQ,MAAM;IACNF,OAAO;IACPG,aAAa;IACbC,OAAOT;IACPU,QAAQZ,EAAEK,MAAM,GAAGQ,KAAK,CAAC;IACzBC,KAAI,EAAEH,KAAK,EAAE;QACX,OAAOI,QAAQC,OAAO,CAACC,OAAOC,IAAI,CAACP,MAAMP,IAAI,EAAEe,QAAQ,CAAC;IAC1D;AACF,GAAG","file":"encodeBase64.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encryptFile.d.ts","sourceRoot":"","sources":["../../src/actions/encryptFile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"encryptFile.d.ts","sourceRoot":"","sources":["../../src/actions/encryptFile.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAoDxB,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;CAoCtB,CAAC"}
|
|
@@ -1,47 +1,66 @@
|
|
|
1
|
+
import { createPieceFile, filesCollectionSlug, findPieceFile } from 'frogbot/pieces';
|
|
1
2
|
import { createMessage, encrypt, readKey } from 'openpgp';
|
|
2
3
|
import { z } from 'zod';
|
|
3
4
|
import { defineAction } from '../define.js';
|
|
4
|
-
const fileId = z.union([
|
|
5
|
+
const fileId = z.union([
|
|
6
|
+
z.string(),
|
|
7
|
+
z.number()
|
|
8
|
+
]);
|
|
5
9
|
const inputSchema = z.object({
|
|
6
|
-
file: fileId.meta({
|
|
7
|
-
|
|
10
|
+
file: fileId.meta({
|
|
11
|
+
label: 'File'
|
|
12
|
+
}),
|
|
13
|
+
publicKey: z.string().meta({
|
|
14
|
+
label: 'Public Key'
|
|
15
|
+
})
|
|
8
16
|
});
|
|
9
17
|
const output = z.discriminatedUnion('success', [
|
|
10
|
-
z.object({
|
|
11
|
-
|
|
18
|
+
z.object({
|
|
19
|
+
success: z.literal(true),
|
|
20
|
+
filename: z.string().min(1),
|
|
21
|
+
file: fileId
|
|
22
|
+
}),
|
|
23
|
+
z.object({
|
|
24
|
+
success: z.literal(false),
|
|
25
|
+
error: z.string().min(1)
|
|
26
|
+
})
|
|
12
27
|
]);
|
|
13
28
|
async function loadFile(req, id) {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
29
|
+
const doc = await findPieceFile(req, 'Crypto', {
|
|
30
|
+
id,
|
|
31
|
+
depth: 0,
|
|
32
|
+
req,
|
|
33
|
+
overrideAccess: false
|
|
34
|
+
});
|
|
35
|
+
if (typeof doc.url !== 'string') throw new Error(`File '${id}' is unavailable.`);
|
|
21
36
|
const config = await req.frogbot.config._internal.payloadConfig;
|
|
22
37
|
const base = new URL(config.serverURL || req.url);
|
|
23
38
|
const url = new URL(doc.url, base);
|
|
24
|
-
if (![
|
|
39
|
+
if (![
|
|
40
|
+
'http:',
|
|
41
|
+
'https:'
|
|
42
|
+
].includes(url.protocol) || url.username || url.password) {
|
|
25
43
|
throw new Error('Invalid file URL.');
|
|
26
44
|
}
|
|
27
45
|
const headers = new Headers();
|
|
28
46
|
if (url.origin === base.origin) {
|
|
29
|
-
for (const name of [
|
|
47
|
+
for (const name of [
|
|
48
|
+
'authorization',
|
|
49
|
+
'cookie'
|
|
50
|
+
]){
|
|
30
51
|
const value = req.headers.get(name);
|
|
31
|
-
if (value)
|
|
32
|
-
headers.set(name, value);
|
|
52
|
+
if (value) headers.set(name, value);
|
|
33
53
|
}
|
|
34
54
|
}
|
|
35
55
|
const response = await fetch(url, {
|
|
36
56
|
headers,
|
|
37
57
|
signal: req.signal ?? undefined,
|
|
38
|
-
redirect: 'error'
|
|
58
|
+
redirect: 'error'
|
|
39
59
|
});
|
|
40
|
-
if (!response.ok)
|
|
41
|
-
throw new Error(`File '${id}' is unavailable (${response.status}).`);
|
|
60
|
+
if (!response.ok) throw new Error(`File '${id}' is unavailable (${response.status}).`);
|
|
42
61
|
return {
|
|
43
62
|
data: new Uint8Array(await response.arrayBuffer()),
|
|
44
|
-
name: String(doc.filename ?? 'file')
|
|
63
|
+
name: String(doc.filename ?? 'file')
|
|
45
64
|
};
|
|
46
65
|
}
|
|
47
66
|
export const encryptFile = defineAction({
|
|
@@ -50,37 +69,45 @@ export const encryptFile = defineAction({
|
|
|
50
69
|
description: 'Encrypt a file with an ASCII-armored OpenPGP public key.',
|
|
51
70
|
input: inputSchema,
|
|
52
71
|
output,
|
|
53
|
-
async run({ input, req }) {
|
|
72
|
+
async run ({ input, req }) {
|
|
54
73
|
try {
|
|
55
74
|
const source = await loadFile(req, input.file);
|
|
56
|
-
const publicKey = await readKey({
|
|
75
|
+
const publicKey = await readKey({
|
|
76
|
+
armoredKey: input.publicKey
|
|
77
|
+
});
|
|
57
78
|
const encrypted = await encrypt({
|
|
58
|
-
message: await createMessage({
|
|
79
|
+
message: await createMessage({
|
|
80
|
+
binary: source.data
|
|
81
|
+
}),
|
|
59
82
|
encryptionKeys: publicKey,
|
|
60
|
-
format: 'armored'
|
|
83
|
+
format: 'armored'
|
|
61
84
|
});
|
|
62
85
|
const filename = `${source.name}.pgp`;
|
|
63
86
|
const data = Buffer.from(encrypted);
|
|
64
|
-
|
|
65
|
-
if (!collection) {
|
|
66
|
-
throw new Error('Crypto file encryption requires a configured files collection.');
|
|
67
|
-
}
|
|
87
|
+
filesCollectionSlug(req, 'Crypto');
|
|
68
88
|
req.signal?.throwIfAborted();
|
|
69
|
-
const doc = await req
|
|
70
|
-
collection,
|
|
71
|
-
data: {},
|
|
89
|
+
const doc = await createPieceFile(req, 'Crypto', {
|
|
72
90
|
req,
|
|
73
|
-
file: {
|
|
74
|
-
|
|
91
|
+
file: {
|
|
92
|
+
data,
|
|
93
|
+
mimetype: 'application/pgp-encrypted',
|
|
94
|
+
name: filename,
|
|
95
|
+
size: data.length
|
|
96
|
+
},
|
|
97
|
+
overrideAccess: false
|
|
75
98
|
});
|
|
76
|
-
return {
|
|
77
|
-
|
|
78
|
-
|
|
99
|
+
return {
|
|
100
|
+
success: true,
|
|
101
|
+
filename,
|
|
102
|
+
file: doc.id
|
|
103
|
+
};
|
|
104
|
+
} catch (error) {
|
|
79
105
|
return {
|
|
80
106
|
success: false,
|
|
81
|
-
error: error instanceof Error ? error.message : 'Encryption failed'
|
|
107
|
+
error: error instanceof Error ? error.message : 'Encryption failed'
|
|
82
108
|
};
|
|
83
109
|
}
|
|
84
|
-
}
|
|
110
|
+
}
|
|
85
111
|
});
|
|
112
|
+
|
|
86
113
|
//# sourceMappingURL=encryptFile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/actions/encryptFile.ts"],"names":["createPieceFile","filesCollectionSlug","findPieceFile","createMessage","encrypt","readKey","z","defineAction","fileId","union","string","number","inputSchema","object","file","meta","label","publicKey","output","discriminatedUnion","success","literal","filename","min","error","loadFile","req","id","doc","depth","overrideAccess","url","Error","config","frogbot","_internal","payloadConfig","base","URL","serverURL","includes","protocol","username","password","headers","Headers","origin","name","value","get","set","response","fetch","signal","undefined","redirect","ok","status","data","Uint8Array","arrayBuffer","String","encryptFile","slug","description","input","run","source","armoredKey","encrypted","message","binary","encryptionKeys","format","Buffer","from","throwIf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,OAAOgB,OAAOC,IAAI,CAACN;YACzBpE,oBAAoByB,KAAK;YAEzBA,IAAI2B,MAAM,EAAEuB;YAEZ,MAAMhD,MAAM,MAAM5B,gBAAgB0B,KAAK,UAAU;gBAC/CA;gBACAZ,MAAM;oBAAE4C;oBAAMmB,UAAU;oBAA6B9B,MAAMzB;oBAAUwD,MAAMpB,KAAKqB,MAAM;gBAAC;gBACvFjD,gBAAgB;YAClB;YAEA,OAAO;gBAAEV,SAAS;gBAAME;gBAAUR,MAAMc,IAAID,EAAE;YAAC;QACjD,EAAE,OAAOH,OAAO;YACd,OAAO;gBACLJ,SAAS;gBACTI,OAAOA,iBAAiBQ,QAAQR,MAAM8C,OAAO,GAAG;YAClD;QACF;IACF;AACF,GAAG","file":"encryptFile.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateHmac.d.ts","sourceRoot":"","sources":["../../src/actions/generateHmac.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAYxB,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"generateHmac.d.ts","sourceRoot":"","sources":["../../src/actions/generateHmac.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAYxB,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;CAavB,CAAC"}
|
|
@@ -2,11 +2,34 @@ import { createHmac } from 'node:crypto';
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { defineAction } from '../define.js';
|
|
4
4
|
const inputSchema = z.object({
|
|
5
|
-
secretKey: z.string().meta({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
secretKey: z.string().meta({
|
|
6
|
+
label: 'Secret Key',
|
|
7
|
+
secret: true
|
|
8
|
+
}),
|
|
9
|
+
secretKeyEncoding: z.enum([
|
|
10
|
+
'utf-8',
|
|
11
|
+
'hex',
|
|
12
|
+
'base64'
|
|
13
|
+
]).meta({
|
|
14
|
+
label: 'Secret Key Encoding'
|
|
15
|
+
}),
|
|
16
|
+
method: z.enum([
|
|
17
|
+
'md5',
|
|
18
|
+
'sha256',
|
|
19
|
+
'sha512'
|
|
20
|
+
]).meta({
|
|
21
|
+
label: 'Method'
|
|
22
|
+
}),
|
|
23
|
+
text: z.string().meta({
|
|
24
|
+
label: 'Text',
|
|
25
|
+
description: 'The text to sign'
|
|
26
|
+
}),
|
|
27
|
+
outputEncoding: z.enum([
|
|
28
|
+
'hex',
|
|
29
|
+
'base64'
|
|
30
|
+
]).default('hex').meta({
|
|
31
|
+
label: 'Output Encoding'
|
|
32
|
+
})
|
|
10
33
|
});
|
|
11
34
|
export const generateHmac = defineAction({
|
|
12
35
|
slug: 'generateHmac',
|
|
@@ -14,9 +37,10 @@ export const generateHmac = defineAction({
|
|
|
14
37
|
description: 'Generate a keyed hash-based message authentication code.',
|
|
15
38
|
input: inputSchema,
|
|
16
39
|
output: z.string().min(1),
|
|
17
|
-
|
|
40
|
+
run ({ input }) {
|
|
18
41
|
const key = Buffer.from(input.secretKey, input.secretKeyEncoding);
|
|
19
|
-
return createHmac(input.method, key).update(input.text).digest(input.outputEncoding);
|
|
20
|
-
}
|
|
42
|
+
return Promise.resolve(createHmac(input.method, key).update(input.text).digest(input.outputEncoding));
|
|
43
|
+
}
|
|
21
44
|
});
|
|
45
|
+
|
|
22
46
|
//# sourceMappingURL=generateHmac.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/actions/generateHmac.ts"],"names":["createHmac","z","defineAction","inputSchema","object","secretKey","string","meta","label","secret","secretKeyEncoding","enum","method","text","description","outputEncoding","default","generateHmac","slug","input","output","min","run","key","Buffer","from","Promise","resolve","update","digest"],"mappings":"AAAA,SAASA,UAAU,QAAQ,cAAc;AAEzC,SAASC,CAAC,QAAQ,MAAM;AAExB,SAASC,YAAY,QAAQ,eAAe;AAE5C,MAAMC,cAAcF,EAAEG,MAAM,CAAC;IAC3BC,WAAWJ,EAAEK,MAAM,GAAGC,IAAI,CAAC;QAAEC,OAAO;QAAcC,QAAQ;IAAK;IAC/DC,mBAAmBT,EAAEU,IAAI,CAAC;QAAC;QAAS;QAAO;KAAS,EAAEJ,IAAI,CAAC;QAAEC,OAAO;IAAsB;IAC1FI,QAAQX,EAAEU,IAAI,CAAC;QAAC;QAAO;QAAU;KAAS,EAAEJ,IAAI,CAAC;QAAEC,OAAO;IAAS;IACnEK,MAAMZ,EAAEK,MAAM,GAAGC,IAAI,CAAC;QAAEC,OAAO;QAAQM,aAAa;IAAmB;IACvEC,gBAAgBd,EAAEU,IAAI,CAAC;QAAC;QAAO;KAAS,EAAEK,OAAO,CAAC,OAAOT,IAAI,CAAC;QAAEC,OAAO;IAAkB;AAC3F;AAEA,OAAO,MAAMS,eAAef,aAAa;IACvCgB,MAAM;IACNV,OAAO;IACPM,aAAa;IACbK,OAAOhB;IACPiB,QAAQnB,EAAEK,MAAM,GAAGe,GAAG,CAAC;IACvBC,KAAI,EAAEH,KAAK,EAAE;QACX,MAAMI,MAAMC,OAAOC,IAAI,CAACN,MAAMd,SAAS,EAAEc,MAAMT,iBAAiB;QAEhE,OAAOgB,QAAQC,OAAO,CACpB3B,WAAWmB,MAAMP,MAAM,EAAEW,KAAKK,MAAM,CAACT,MAAMN,IAAI,EAAEgB,MAAM,CAACV,MAAMJ,cAAc;IAEhF;AACF,GAAG","file":"generateHmac.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generatePassword.d.ts","sourceRoot":"","sources":["../../src/actions/generatePassword.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAcxB,eAAO,MAAM,gBAAgB;;;;;;;;
|
|
1
|
+
{"version":3,"file":"generatePassword.d.ts","sourceRoot":"","sources":["../../src/actions/generatePassword.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAcxB,eAAO,MAAM,gBAAgB;;;;;;;;CAkB3B,CAAC"}
|
|
@@ -4,11 +4,15 @@ import { defineAction } from '../define.js';
|
|
|
4
4
|
const alphanumeric = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
|
5
5
|
const symbols = '!@#$%^&*()_+~`|}{[]:;?><,./-=';
|
|
6
6
|
const inputSchema = z.object({
|
|
7
|
-
length: z.number().int().min(0).max(256).meta({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
length: z.number().int().min(0).max(256).meta({
|
|
8
|
+
label: 'Password Length'
|
|
9
|
+
}),
|
|
10
|
+
characterSet: z.enum([
|
|
11
|
+
'alphanumeric',
|
|
12
|
+
'alphanumeric-symbols'
|
|
13
|
+
]).default('alphanumeric').meta({
|
|
14
|
+
label: 'Character Set'
|
|
15
|
+
})
|
|
12
16
|
});
|
|
13
17
|
export const generatePassword = defineAction({
|
|
14
18
|
slug: 'generatePassword',
|
|
@@ -16,13 +20,14 @@ export const generatePassword = defineAction({
|
|
|
16
20
|
description: 'Generate a cryptographically secure random password.',
|
|
17
21
|
input: inputSchema,
|
|
18
22
|
output: z.string().max(256),
|
|
19
|
-
|
|
23
|
+
run ({ input }) {
|
|
20
24
|
const characters = input.characterSet === 'alphanumeric' ? alphanumeric : alphanumeric + symbols;
|
|
21
25
|
let password = '';
|
|
22
|
-
for
|
|
26
|
+
for(let index = 0; index < input.length; index++){
|
|
23
27
|
password += characters[randomInt(characters.length)];
|
|
24
28
|
}
|
|
25
|
-
return password;
|
|
26
|
-
}
|
|
29
|
+
return Promise.resolve(password);
|
|
30
|
+
}
|
|
27
31
|
});
|
|
32
|
+
|
|
28
33
|
//# sourceMappingURL=generatePassword.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/actions/generatePassword.ts"],"names":["randomInt","z","defineAction","alphanumeric","symbols","inputSchema","object","length","number","int","min","max","meta","label","characterSet","enum","default","generatePassword","slug","description","input","output","string","run","characters","password","index","Promise","resolve"],"mappings":"AAAA,SAASA,SAAS,QAAQ,cAAc;AAExC,SAASC,CAAC,QAAQ,MAAM;AAExB,SAASC,YAAY,QAAQ,eAAe;AAE5C,MAAMC,eAAe;AACrB,MAAMC,UAAU;AAChB,MAAMC,cAAcJ,EAAEK,MAAM,CAAC;IAC3BC,QAAQN,EAAEO,MAAM,GAAGC,GAAG,GAAGC,GAAG,CAAC,GAAGC,GAAG,CAAC,KAAKC,IAAI,CAAC;QAAEC,OAAO;IAAkB;IACzEC,cAAcb,EACXc,IAAI,CAAC;QAAC;QAAgB;KAAuB,EAC7CC,OAAO,CAAC,gBACRJ,IAAI,CAAC;QAAEC,OAAO;IAAgB;AACnC;AAEA,OAAO,MAAMI,mBAAmBf,aAAa;IAC3CgB,MAAM;IACNL,OAAO;IACPM,aAAa;IACbC,OAAOf;IACPgB,QAAQpB,EAAEqB,MAAM,GAAGX,GAAG,CAAC;IACvBY,KAAI,EAAEH,KAAK,EAAE;QACX,MAAMI,aACJJ,MAAMN,YAAY,KAAK,iBAAiBX,eAAeA,eAAeC;QAExE,IAAIqB,WAAW;QAEf,IAAK,IAAIC,QAAQ,GAAGA,QAAQN,MAAMb,MAAM,EAAEmB,QAAS;YACjDD,YAAYD,UAAU,CAACxB,UAAUwB,WAAWjB,MAAM,EAAE;QACtD;QAEA,OAAOoB,QAAQC,OAAO,CAACH;IACzB;AACF,GAAG","file":"generatePassword.js"}
|
|
@@ -2,11 +2,31 @@ import { createSign } from 'node:crypto';
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { defineAction } from '../define.js';
|
|
4
4
|
const inputSchema = z.object({
|
|
5
|
-
privateKey: z.string().meta({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
privateKey: z.string().meta({
|
|
6
|
+
label: 'Private Key',
|
|
7
|
+
secret: true
|
|
8
|
+
}),
|
|
9
|
+
passphrase: z.string().optional().meta({
|
|
10
|
+
label: 'Passphrase',
|
|
11
|
+
secret: true
|
|
12
|
+
}),
|
|
13
|
+
method: z.enum([
|
|
14
|
+
'sha256',
|
|
15
|
+
'sha384',
|
|
16
|
+
'sha512'
|
|
17
|
+
]).default('sha256').meta({
|
|
18
|
+
label: 'Method'
|
|
19
|
+
}),
|
|
20
|
+
text: z.string().meta({
|
|
21
|
+
label: 'Text',
|
|
22
|
+
description: 'The text to sign'
|
|
23
|
+
}),
|
|
24
|
+
outputEncoding: z.enum([
|
|
25
|
+
'base64',
|
|
26
|
+
'hex'
|
|
27
|
+
]).default('base64').meta({
|
|
28
|
+
label: 'Output Encoding'
|
|
29
|
+
})
|
|
10
30
|
});
|
|
11
31
|
export const generateRsaSignature = defineAction({
|
|
12
32
|
slug: 'generateRsaSignature',
|
|
@@ -14,13 +34,15 @@ export const generateRsaSignature = defineAction({
|
|
|
14
34
|
description: 'Sign text with an RSA private key.',
|
|
15
35
|
input: inputSchema,
|
|
16
36
|
output: z.string().min(1),
|
|
17
|
-
|
|
37
|
+
run ({ input }) {
|
|
18
38
|
const signer = createSign(input.method).update(input.text);
|
|
19
|
-
const key = input.passphrase
|
|
20
|
-
|
|
21
|
-
: input.
|
|
39
|
+
const key = input.passphrase ? {
|
|
40
|
+
key: input.privateKey,
|
|
41
|
+
passphrase: input.passphrase
|
|
42
|
+
} : input.privateKey;
|
|
22
43
|
signer.end();
|
|
23
|
-
return signer.sign(key, input.outputEncoding);
|
|
24
|
-
}
|
|
44
|
+
return Promise.resolve(signer.sign(key, input.outputEncoding));
|
|
45
|
+
}
|
|
25
46
|
});
|
|
47
|
+
|
|
26
48
|
//# sourceMappingURL=generateRsaSignature.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/actions/generateRsaSignature.ts"],"names":["createSign","z","defineAction","inputSchema","object","privateKey","string","meta","label","secret","passphrase","optional","method","enum","default","text","description","outputEncoding","generateRsaSignature","slug","input","output","min","run","signer","update","key","end","Promise","resolve","sign"],"mappings":"AAAA,SAASA,UAAU,QAAQ,cAAc;AAEzC,SAASC,CAAC,QAAQ,MAAM;AAExB,SAASC,YAAY,QAAQ,eAAe;AAE5C,MAAMC,cAAcF,EAAEG,MAAM,CAAC;IAC3BC,YAAYJ,EAAEK,MAAM,GAAGC,IAAI,CAAC;QAAEC,OAAO;QAAeC,QAAQ;IAAK;IACjEC,YAAYT,EAAEK,MAAM,GAAGK,QAAQ,GAAGJ,IAAI,CAAC;QAAEC,OAAO;QAAcC,QAAQ;IAAK;IAC3EG,QAAQX,EAAEY,IAAI,CAAC;QAAC;QAAU;QAAU;KAAS,EAAEC,OAAO,CAAC,UAAUP,IAAI,CAAC;QAAEC,OAAO;IAAS;IACxFO,MAAMd,EAAEK,MAAM,GAAGC,IAAI,CAAC;QAAEC,OAAO;QAAQQ,aAAa;IAAmB;IACvEC,gBAAgBhB,EAAEY,IAAI,CAAC;QAAC;QAAU;KAAM,EAAEC,OAAO,CAAC,UAAUP,IAAI,CAAC;QAAEC,OAAO;IAAkB;AAC9F;AAEA,OAAO,MAAMU,uBAAuBhB,aAAa;IAC/CiB,MAAM;IACNX,OAAO;IACPQ,aAAa;IACbI,OAAOjB;IACPkB,QAAQpB,EAAEK,MAAM,GAAGgB,GAAG,CAAC;IACvBC,KAAI,EAAEH,KAAK,EAAE;QACX,MAAMI,SAASxB,WAAWoB,MAAMR,MAAM,EAAEa,MAAM,CAACL,MAAML,IAAI;QACzD,MAAMW,MAAMN,MAAMV,UAAU,GACxB;YAAEgB,KAAKN,MAAMf,UAAU;YAAEK,YAAYU,MAAMV,UAAU;QAAC,IACtDU,MAAMf,UAAU;QAEpBmB,OAAOG,GAAG;QAEV,OAAOC,QAAQC,OAAO,CAACL,OAAOM,IAAI,CAACJ,KAAKN,MAAMH,cAAc;IAC9D;AACF,GAAG","file":"generateRsaSignature.js"}
|
package/dist/actions/hashText.js
CHANGED
|
@@ -2,8 +2,18 @@ import { createHash } from 'node:crypto';
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { defineAction } from '../define.js';
|
|
4
4
|
const inputSchema = z.object({
|
|
5
|
-
method: z.enum([
|
|
6
|
-
|
|
5
|
+
method: z.enum([
|
|
6
|
+
'md5',
|
|
7
|
+
'sha256',
|
|
8
|
+
'sha512',
|
|
9
|
+
'sha3-512'
|
|
10
|
+
]).meta({
|
|
11
|
+
label: 'Method'
|
|
12
|
+
}),
|
|
13
|
+
text: z.string().meta({
|
|
14
|
+
label: 'Text',
|
|
15
|
+
description: 'The text to hash'
|
|
16
|
+
})
|
|
7
17
|
});
|
|
8
18
|
export const hashText = defineAction({
|
|
9
19
|
slug: 'hashText',
|
|
@@ -11,8 +21,9 @@ export const hashText = defineAction({
|
|
|
11
21
|
description: 'Hash text with a selected digest algorithm.',
|
|
12
22
|
input: inputSchema,
|
|
13
23
|
output: z.string().regex(/^[a-f0-9]+$/),
|
|
14
|
-
|
|
15
|
-
return createHash(input.method).update(input.text).digest('hex');
|
|
16
|
-
}
|
|
24
|
+
run ({ input }) {
|
|
25
|
+
return Promise.resolve(createHash(input.method).update(input.text).digest('hex'));
|
|
26
|
+
}
|
|
17
27
|
});
|
|
28
|
+
|
|
18
29
|
//# sourceMappingURL=hashText.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/actions/hashText.ts"],"names":["createHash","z","defineAction","inputSchema","object","method","enum","meta","label","text","string","description","hashText","slug","input","output","regex","run","Promise","resolve","update","digest"],"mappings":"AAAA,SAASA,UAAU,QAAQ,cAAc;AAEzC,SAASC,CAAC,QAAQ,MAAM;AAExB,SAASC,YAAY,QAAQ,eAAe;AAE5C,MAAMC,cAAcF,EAAEG,MAAM,CAAC;IAC3BC,QAAQJ,EAAEK,IAAI,CAAC;QAAC;QAAO;QAAU;QAAU;KAAW,EAAEC,IAAI,CAAC;QAAEC,OAAO;IAAS;IAC/EC,MAAMR,EAAES,MAAM,GAAGH,IAAI,CAAC;QAAEC,OAAO;QAAQG,aAAa;IAAmB;AACzE;AAEA,OAAO,MAAMC,WAAWV,aAAa;IACnCW,MAAM;IACNL,OAAO;IACPG,aAAa;IACbG,OAAOX;IACPY,QAAQd,EAAES,MAAM,GAAGM,KAAK,CAAC;IACzBC,KAAI,EAAEH,KAAK,EAAE;QACX,OAAOI,QAAQC,OAAO,CAACnB,WAAWc,MAAMT,MAAM,EAAEe,MAAM,CAACN,MAAML,IAAI,EAAEY,MAAM,CAAC;IAC5E;AACF,GAAG","file":"hashText.js"}
|
package/dist/define.js
CHANGED
package/dist/define.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/define.ts"],"names":["createPieceHelpers","defineAction"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,iBAAiB;AAEpD,OAAO,MAAM,EAAEC,YAAY,EAAE,GAAGD,qBAAqB","file":"define.js"}
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,10 @@ import { hashText } from './actions/hashText.js';
|
|
|
9
9
|
export const createCrypto = definePiece({
|
|
10
10
|
slug: 'crypto',
|
|
11
11
|
label: 'Crypto',
|
|
12
|
-
admin: {
|
|
12
|
+
admin: {
|
|
13
|
+
description: 'Hash, sign, encode, encrypt, and generate secure values',
|
|
14
|
+
group: 'Core'
|
|
15
|
+
},
|
|
13
16
|
actions: [
|
|
14
17
|
hashText,
|
|
15
18
|
generateHmac,
|
|
@@ -17,7 +20,8 @@ export const createCrypto = definePiece({
|
|
|
17
20
|
generatePassword,
|
|
18
21
|
decodeBase64,
|
|
19
22
|
encodeBase64,
|
|
20
|
-
encryptFile
|
|
21
|
-
]
|
|
23
|
+
encryptFile
|
|
24
|
+
]
|
|
22
25
|
});
|
|
26
|
+
|
|
23
27
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["definePiece","decodeBase64","encodeBase64","encryptFile","generateHmac","generatePassword","generateRsaSignature","hashText","createCrypto","slug","label","admin","description","group","actions"],"mappings":"AAAA,SAASA,WAAW,QAAQ,iBAAiB;AAE7C,SAASC,YAAY,QAAQ,4BAA4B;AACzD,SAASC,YAAY,QAAQ,4BAA4B;AACzD,SAASC,WAAW,QAAQ,2BAA2B;AACvD,SAASC,YAAY,QAAQ,4BAA4B;AACzD,SAASC,gBAAgB,QAAQ,gCAAgC;AACjE,SAASC,oBAAoB,QAAQ,oCAAoC;AACzE,SAASC,QAAQ,QAAQ,wBAAwB;AAEjD,OAAO,MAAMC,eAAeR,YAAY;IACtCS,MAAM;IACNC,OAAO;IACPC,OAAO;QAAEC,aAAa;QAA2DC,OAAO;IAAO;IAC/FC,SAAS;QACPP;QACAH;QACAE;QACAD;QACAJ;QACAC;QACAC;KACD;AACH,GAAG","file":"index.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frogbotai/piece-crypto",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0",
|
|
4
4
|
"description": "crypto tools for FrogBot.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Colby Gilbert",
|
|
@@ -23,17 +23,17 @@
|
|
|
23
23
|
"zod": "^4.3.6"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"frogbot": "0.
|
|
26
|
+
"frogbot": "0.31.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"typescript": "5.6.2",
|
|
30
|
-
"frogbot": "0.
|
|
30
|
+
"frogbot": "0.31.0"
|
|
31
31
|
},
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
|
-
"build": "
|
|
36
|
+
"build": "node ../../../scripts/build-package.mjs",
|
|
37
37
|
"clean": "rm -rf dist",
|
|
38
38
|
"typecheck": "tsc --noEmit"
|
|
39
39
|
}
|