A few tweaks

This commit is contained in:
Gregory Schier
2025-01-17 15:10:02 -08:00
parent 16af8bf008
commit 0491bed46d
3 changed files with 11 additions and 9 deletions

8
package-lock.json generated
View File

@@ -9,7 +9,7 @@
"plugins/*" "plugins/*"
], ],
"dependencies": { "dependencies": {
"@yaakapp/api": "^0.2.29" "@yaakapp/api": "^0.3.0"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^22.7.4", "@types/node": "^22.7.4",
@@ -1013,9 +1013,9 @@
} }
}, },
"node_modules/@yaakapp/api": { "node_modules/@yaakapp/api": {
"version": "0.2.29", "version": "0.3.0",
"resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.2.29.tgz", "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.3.0.tgz",
"integrity": "sha512-RuyWRUGhYIQjFmaZTYuAekSkidl0b9rWcTV1l+Hs5Pw+LUv8+euedAvNodEJgxAgy42btUns7QUmdM5YNvgoug==", "integrity": "sha512-A2msKEiqVIOdqn2q9oVXT69aJ7EwrbwNZ6gdrvqTqeTERLddRtO0OKj6wYUUpiqbGr1QY8Byu4BzHclp/aYHWw==",
"dependencies": { "dependencies": {
"@types/node": "^22.5.4" "@types/node": "^22.5.4"
} }

View File

@@ -19,6 +19,6 @@
"workspaces-run": "^1.0.2" "workspaces-run": "^1.0.2"
}, },
"dependencies": { "dependencies": {
"@yaakapp/api": "^0.2.29" "@yaakapp/api": "^0.3.0"
} }
} }

View File

@@ -29,32 +29,34 @@ export const plugin: PluginDefinition = {
type: 'select', type: 'select',
name: 'algorithm', name: 'algorithm',
label: 'Algorithm', label: 'Algorithm',
hideLabel: true,
defaultValue: defaultAlgorithm, defaultValue: defaultAlgorithm,
options: algorithms.map(value => ({ name: value === 'none' ? 'None' : value, value })), options: algorithms.map(value => ({ name: value === 'none' ? 'None' : value, value })),
}, },
{ {
type: 'text', type: 'text',
name: 'secret', name: 'secret',
label: 'Secret', label: 'Secret or Private Key',
optional: true, optional: true,
}, },
{ {
type: 'checkbox', type: 'checkbox',
name: 'secretBase64', name: 'secretBase64',
label: 'Secret Base64 Encoded', label: 'Secret is base64 encoded',
}, },
{ {
type: 'editor', type: 'editor',
name: 'payload', name: 'payload',
label: 'Payload', label: 'Payload',
language: 'json', language: 'json',
optional: true, defaultValue: '{\n "foo": "bar"\n}',
placeholder: '{ }',
}, },
], ],
async onApply(_ctx, args) { async onApply(_ctx, args) {
const { algorithm, secret: _secret, secretBase64, payload } = args.config; const { algorithm, secret: _secret, secretBase64, payload } = args.config;
const secret = secretBase64 ? Buffer.from(`${_secret}`, 'base64') : `${_secret}`; const secret = secretBase64 ? Buffer.from(`${_secret}`, 'base64') : `${_secret}`;
const token = secret ? jwt.sign(`${payload}`, secret, { algorithm: algorithm as any }) : jwt.sign(`${payload}`, null); const token = jwt.sign(`${payload}`, secret, { algorithm: algorithm as any });
const value = `Bearer ${token}`; const value = `Bearer ${token}`;
return { setHeaders: [{ name: 'Authorization', value }] }; return { setHeaders: [{ name: 'Authorization', value }] };
} }