feat(cryptography): add create signature action
This commit is contained in:
@@ -4,7 +4,7 @@ import defineAction from '../../../../helpers/define-action.js';
|
|||||||
export default defineAction({
|
export default defineAction({
|
||||||
name: 'Create HMAC',
|
name: 'Create HMAC',
|
||||||
key: 'createHmac',
|
key: 'createHmac',
|
||||||
description: 'Create a Hash-based Message Authentication Code (HMAC) using the specified algorithm, secret key, and message data.',
|
description: 'Create a Hash-based Message Authentication Code (HMAC) using the specified algorithm, secret key, and message.',
|
||||||
arguments: [
|
arguments: [
|
||||||
{
|
{
|
||||||
label: 'Algorithm',
|
label: 'Algorithm',
|
||||||
@@ -14,10 +14,18 @@ export default defineAction({
|
|||||||
value: 'sha256',
|
value: 'sha256',
|
||||||
description: 'Specifies the cryptographic hash function to use for HMAC generation.',
|
description: 'Specifies the cryptographic hash function to use for HMAC generation.',
|
||||||
options: [
|
options: [
|
||||||
{ label: 'SHA-256 ', value: 'sha256' },
|
{ label: 'SHA-256', value: 'sha256' },
|
||||||
],
|
],
|
||||||
variables: true,
|
variables: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'Message',
|
||||||
|
key: 'message',
|
||||||
|
type: 'string',
|
||||||
|
required: true,
|
||||||
|
description: 'The input message to be hashed. This is the value that will be processed to generate the HMAC.',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: 'Secret key',
|
label: 'Secret key',
|
||||||
key: 'secretKey',
|
key: 'secretKey',
|
||||||
@@ -26,19 +34,11 @@ export default defineAction({
|
|||||||
description: 'The secret key used to create the HMAC.',
|
description: 'The secret key used to create the HMAC.',
|
||||||
variables: true,
|
variables: true,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
label: 'Message data',
|
|
||||||
key: 'data',
|
|
||||||
type: 'string',
|
|
||||||
required: true,
|
|
||||||
description: 'The input data or message to be hashed. This is the data that will be processed to generate the HMAC.',
|
|
||||||
variables: true,
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
|
|
||||||
async run($) {
|
async run($) {
|
||||||
const hash = createHmac($.step.parameters.algorithm, $.step.parameters.secretKey)
|
const hash = createHmac($.step.parameters.algorithm, $.step.parameters.secretKey)
|
||||||
.update($.step.parameters.data)
|
.update($.step.parameters.message)
|
||||||
.digest('hex');
|
.digest('hex');
|
||||||
|
|
||||||
$.setActionItem({
|
$.setActionItem({
|
||||||
|
@@ -0,0 +1,51 @@
|
|||||||
|
import crypto from 'node:crypto';
|
||||||
|
import defineAction from '../../../../helpers/define-action.js';
|
||||||
|
|
||||||
|
export default defineAction({
|
||||||
|
name: 'Create Signature',
|
||||||
|
key: 'createSignature',
|
||||||
|
description: 'Create a digital signature using the specified algorithm, secret key, and message.',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
label: 'Algorithm',
|
||||||
|
key: 'algorithm',
|
||||||
|
type: 'dropdown',
|
||||||
|
required: true,
|
||||||
|
value: 'RSA-SHA256',
|
||||||
|
description: 'Specifies the cryptographic hash function to use for HMAC generation.',
|
||||||
|
options: [
|
||||||
|
{ label: 'RSA-SHA256', value: 'RSA-SHA256' },
|
||||||
|
],
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Message',
|
||||||
|
key: 'message',
|
||||||
|
type: 'string',
|
||||||
|
required: true,
|
||||||
|
description: 'The input message to be signed.',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Private key',
|
||||||
|
key: 'privateKey',
|
||||||
|
type: 'string',
|
||||||
|
required: true,
|
||||||
|
description: 'The RSA private key in PEM format used for signing.',
|
||||||
|
variables: true,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const signer = crypto.createSign($.step.parameters.algorithm);
|
||||||
|
signer.update($.step.parameters.message);
|
||||||
|
signer.end();
|
||||||
|
const signature = signer.sign($.step.parameters.privateKey, 'hex');
|
||||||
|
|
||||||
|
$.setActionItem({
|
||||||
|
raw: {
|
||||||
|
signature
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
@@ -1,3 +1,4 @@
|
|||||||
import createHmac from './create-hmac/index.js';
|
import createHmac from './create-hmac/index.js';
|
||||||
|
import createRsaSha256Signature from './create-rsa-sha256-signature/index.js';
|
||||||
|
|
||||||
export default [createHmac];
|
export default [createHmac, createRsaSha256Signature];
|
||||||
|
@@ -2,7 +2,9 @@
|
|||||||
favicon: /favicons/cryptography.svg
|
favicon: /favicons/cryptography.svg
|
||||||
items:
|
items:
|
||||||
- name: Create HMAC
|
- name: Create HMAC
|
||||||
desc: Create a Hash-based Message Authentication Code (HMAC) using the specified algorithm, secret key, and message data.
|
desc: Create a Hash-based Message Authentication Code (HMAC) using the specified algorithm, secret key, and message.
|
||||||
|
- name: Create Signature
|
||||||
|
desc: Create a digital signature using the specified algorithm, secret key, and message.
|
||||||
---
|
---
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
Reference in New Issue
Block a user