feat(cryptography): add create signature action

This commit is contained in:
Ali BARIN
2024-07-16 11:24:52 +00:00
parent 0f9d732667
commit 949a2543f5
4 changed files with 67 additions and 13 deletions

View File

@@ -4,7 +4,7 @@ import defineAction from '../../../../helpers/define-action.js';
export default defineAction({
name: 'Create HMAC',
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: [
{
label: 'Algorithm',
@@ -14,10 +14,18 @@ export default defineAction({
value: 'sha256',
description: 'Specifies the cryptographic hash function to use for HMAC generation.',
options: [
{ label: 'SHA-256 ', value: 'sha256' },
{ label: 'SHA-256', value: 'sha256' },
],
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',
key: 'secretKey',
@@ -26,19 +34,11 @@ export default defineAction({
description: 'The secret key used to create the HMAC.',
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($) {
const hash = createHmac($.step.parameters.algorithm, $.step.parameters.secretKey)
.update($.step.parameters.data)
.update($.step.parameters.message)
.digest('hex');
$.setActionItem({