forked from luckymarmot/Paw-FactorialDynamicValue
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTOTPDynamicValue.js
More file actions
45 lines (36 loc) · 1.21 KB
/
TOTPDynamicValue.js
File metadata and controls
45 lines (36 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// console.log("Hello JS.")
const totp = require('./totp');
// console.log("Loaded TOTP.")
var TOTPDynamicValue = function() {
// Input "TOTP key"
this.totp_key = "AAAABBBBCCCCDDDD";
// Evaluate function: takes no params, should return the computer value
this.evaluate = function() {
var f = function(x) {
const code = totp.getCode(x)
// console.log(code)
return code;
}
return f(this.totp_key);
}
// Title function: takes no params, should return the string to display as
// the Dynamic Value title
this.title = function() {
return "Generate TOTP"
}
// Text function: takes no params, should return the string to display as
// the Dynamic Value text
this.text = function() {
return "" + this.totp_key + "!"
}
}
// Extension Identifier (as a reverse domain name)
TOTPDynamicValue.identifier = "com.luckymarmot.PawExtensions.TOTPDynamicValue";
// Extension Name
TOTPDynamicValue.title = "TOTP Dynamic Value";
// Dynamic Value Inputs
TOTPDynamicValue.inputs = [
DynamicValueInput("totp_key", "Input TOTP Key", "String"),
]
// Register this new Extension
registerDynamicValueClass(TOTPDynamicValue);