API Reference / DhanAuth
Class: DhanAuth
Defined in: src/auth/DhanAuth.ts:37
Constructors
Constructor
new DhanAuth():
DhanAuth
Returns
DhanAuth
Methods
generateTotp()
staticgenerateTotp(secret,options?):string
Defined in: src/auth/DhanAuth.ts:45
RFC 6238 TOTP from a base32 secret.
Provided so a headless process can log in without a phone, but note that the secret is then as sensitive as the PIN — anything holding both can mint tokens for the account indefinitely.
Parameters
secret
string
options?
TotpOptions = {}
Returns
string
totpSecondsRemaining()
statictotpSecondsRemaining(options?):number
Defined in: src/auth/DhanAuth.ts:63
Seconds until the current TOTP window rolls over.
Parameters
options?
Pick<TotpOptions, "timestamp" | "period"> = {}
Returns
number
generateAccessToken()
staticgenerateAccessToken(request,dependencies?):Promise<TokenResponse>
Defined in: src/auth/DhanAuth.ts:72
Exchanges client id + PIN + TOTP for an access token.
Parameters
request
dependencies?
DhanAuthDependencies = {}
Returns
Promise<TokenResponse>
renewWebToken()
staticrenewWebToken(request,dependencies?):Promise<TokenResponse>
Defined in: src/auth/DhanAuth.ts:101
Extends an existing token without a fresh PIN/TOTP round trip.
Only works while the current token is still valid — once it has expired, generateAccessToken is the only way back in.
Parameters
request
dependencies?
DhanAuthDependencies = {}
Returns
Promise<TokenResponse>