File tree 3 files changed +11
-1
lines changed
documentation/pages/personal/secrets
3 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ The transformer is a function that will be applied to the secret field before lo
51
51
Available transformers:
52
52
53
53
- ` ?otp ` to generate a one-time password from a secret key
54
+ - ` ?otp+expiry ` to generate a one-time password from a secret key and display its expiry date (in seconds)
54
55
- ` ?json=<JSONPathQuery> ` to extract a value from a JSON object
55
56
(please refer to [ JSONPath documentation] ( https://github.com/JSONPath-Plus/JSONPath#syntax-through-examples ) for more information)
56
57
Original file line number Diff line number Diff line change 1
1
import { isUuid } from './strings' ;
2
- import { transformJsonPath , transformOtp } from './secretTransformation' ;
2
+ import { transformJsonPath , transformOtp , transformOtpAndExpiry } from './secretTransformation' ;
3
3
import { ParsedPath } from '../types' ;
4
4
import { InvalidDashlanePathError } from '../errors' ;
5
5
@@ -52,6 +52,9 @@ export const parsePath = (path: string): ParsedPath => {
52
52
case 'otp' :
53
53
transformation = transformOtp ;
54
54
break ;
55
+ case 'otp+expiry' :
56
+ transformation = transformOtpAndExpiry ;
57
+ break ;
55
58
case 'json' :
56
59
transformation = ( json : string ) => transformJsonPath ( json , queryParamValue ) ;
57
60
break ;
Original file line number Diff line number Diff line change @@ -5,6 +5,12 @@ export const transformOtp = (secret: string) => {
5
5
return authenticator . generate ( secret ) ;
6
6
} ;
7
7
8
+ export const transformOtpAndExpiry = ( secret : string ) => {
9
+ const otp = authenticator . generate ( secret ) ;
10
+ const expiry = authenticator . timeRemaining ( ) ;
11
+ return `${ otp } ${ expiry } ` ;
12
+ } ;
13
+
8
14
export const transformJsonPath = ( json : string , path : string ) => {
9
15
const result = JSONPath < unknown > ( { path, json : JSON . parse ( json ) as object , wrap : false } ) ;
10
16
if ( result === undefined ) {
You can’t perform that action at this time.
0 commit comments