Reputation: 222
I want to create a DynamicValue plugin for Paw generating Json Web Tokens. The full source can be found here: https://github.com/choffmeister/Paw-JsonWebTokenDynamicValue
Relevant file:
// JsonWebTokenDynamicValue.js
import jsrsasign from 'jsrsasign';
@registerDynamicValueClass
class JsonWebTokenDynamicValue {
static identifier = 'de.choffmeister.PawExtensions.JsonWebTokenDynamicValue';
static title = 'Json Web Token';
static help = 'https://github.com/choffmeister/Paw-JsonWebTokenDynamicValue';
static inputs = [
DynamicValueInput('signatureSecret', 'Secret', 'SecureValue'),
DynamicValueInput('signatureSecretIsBase64', 'Secret is Base64', 'Checkbox'),
DynamicValueInput('payload', 'Payload', 'JSON')
];
evaluate() {
console.log(JSON.stringify(this.payload, null, 2));
console.log(JSON.stringify(this.signatureSecretIsBase64, null, 2));
const now = Math.floor((new Date()).getTime() / 1000);
const header = {
typ: 'JWT',
alg: 'HS256'
};
const payload = {
...this.payload,
exp: now + (60 * 60 * 24 * 7),
iat: now
};
const secret = this.signatureSecretIsBase64
? {b64: jsrsasign.b64utob64(this.signatureSecret)}
: this.signatureSecret;
return jsrsasign.jws.JWS.sign(null, header, payload, secret);
}
}
How it looks in the GUI:
I searched https://luckymarmot.com/paw/doc/extensions/create-dynamic-value, the surrounding documentation and all plugin examples I could find on the web, but I still have two problems I cannot solve:
Checkbox
then the input field is not visible (see screenshot). I get a value (empty string), but just cannot see it. How can I make the checkbox appear?When using the DynamicValueInput of type JSON
then used dynamic values inside the JSON (see screenshot) are not resolved, but instead I get kind of a description object (stringified), what this dynamic value is. Logging the this.payload
object looks like this:
{
"foo": "[{\"data\":{\"environmentVariable\":\"2925ABDA-8AAC-440B-B2CA-DA216CD37A09\"},\"identifier\":\"com.luckymarmot.EnvironmentVariableDynamicValue\"}]"
}
Maybe it is worth to note: When using DynamicInputValue of type KeyValueList
then the inner dynamic values are resolved properly. How can I achive this with the JSON
type, too?
Upvotes: 1
Views: 197
Reputation: 3481
This issue has been solved in Paw 2.3.3 and @Thekwasti's extension has actually been published here: https://luckymarmot.com/paw/extensions/JsonWebTokenDynamicValue
Upvotes: 0