kozz-module-maker 0.1.0 → 0.1.1
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/package.json
CHANGED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const crypto = require('crypto');
|
|
3
|
+
|
|
4
|
+
const boundaryName = process.argv[2];
|
|
5
|
+
if (!boundaryName) {
|
|
6
|
+
console.error('Boundary name not provided');
|
|
7
|
+
process.exit(1);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const payload = {
|
|
11
|
+
OS: 'windows',
|
|
12
|
+
platform: 'WA',
|
|
13
|
+
name: boundaryName,
|
|
14
|
+
role: 'boundary',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
let privateKey;
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
privateKey = fs.readFileSync('./keys/privatekey.pem', {
|
|
21
|
+
encoding: 'utf-8',
|
|
22
|
+
});
|
|
23
|
+
} catch (e) {
|
|
24
|
+
console.error(
|
|
25
|
+
'Please generate a keypair and leave the name of the private key as it is'
|
|
26
|
+
);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const signature = crypto.sign(
|
|
31
|
+
'sha256',
|
|
32
|
+
Buffer.from(JSON.stringify(payload, undefined, ' ')),
|
|
33
|
+
{ key: privateKey, padding: crypto.constants.RSA_PKCS1_PSS_PADDING }
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
console.log('This is the payload you have to paste on postman');
|
|
37
|
+
console.log(
|
|
38
|
+
JSON.stringify(
|
|
39
|
+
{
|
|
40
|
+
...payload,
|
|
41
|
+
signature: signature.toString('base64'),
|
|
42
|
+
},
|
|
43
|
+
undefined,
|
|
44
|
+
' '
|
|
45
|
+
)
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
process.exit(0);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const crypto = require('crypto');
|
|
3
|
+
|
|
4
|
+
const handlerName = process.argv[2];
|
|
5
|
+
if (!handlerName) {
|
|
6
|
+
console.error('handler name not provided');
|
|
7
|
+
process.exit(1);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const payload = {
|
|
11
|
+
// If you are signing a command handler, insert the command names in the array;
|
|
12
|
+
methods: [],
|
|
13
|
+
name: handlerName,
|
|
14
|
+
role: 'handler',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
let privateKey;
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
privateKey = fs.readFileSync('./keys/privatekey.pem', {
|
|
21
|
+
encoding: 'utf-8',
|
|
22
|
+
});
|
|
23
|
+
} catch (e) {
|
|
24
|
+
console.error(
|
|
25
|
+
'Please generate a keypair and leave the name of the private key as it is'
|
|
26
|
+
);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const signature = crypto.sign(
|
|
31
|
+
'sha256',
|
|
32
|
+
Buffer.from(JSON.stringify(payload, undefined, ' ')),
|
|
33
|
+
{ key: privateKey, padding: crypto.constants.RSA_PKCS1_PSS_PADDING }
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
console.log('This is the payload you have to paste on postman');
|
|
37
|
+
console.log({
|
|
38
|
+
...payload,
|
|
39
|
+
signature: signature.toString('base64'),
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
process.exit(0);
|