TotpSecret class

用於產生TotpMultiFactorAssertion 的提供程序

儲存共用金鑰和其他參數以產生基於時間的 OTP。實作檢索共用金鑰並產生 QR 碼 URL 的方法。

簽名:

export declare class TotpSecret 

特性

財產修飾符類型描述
程式碼間隔秒數數位OTP 代碼應更改的時間間隔(以秒為單位)。
程式碼長度數位要產生的一次性密碼的長度。
報名完成截止日期細繩TOTP 註冊應完成的時間戳記(UTC 字串)。
哈希演算法細繩使用的哈希演算法。
金鑰細繩用於註冊 TOTP MFA 和產生 OTP 的共用金鑰/種子。

方法

方法修飾符描述
generateQrCodeUrl(帳戶名稱, 發行人)傳回一個QR 碼URL,如https://github.com/google/google-authenticator/wiki/Key-Uri-Format 所述。這可以作為QR 碼顯示給用戶,以便掃描到TOTP 應用程式(如Google在Authenticator)中。如果未指定可選參數,則 accountName 為和發行人被使用。

TotpSecret.codeIntervalSeconds

OTP 代碼應更改的時間間隔(以秒為單位)。

簽名:

readonly codeIntervalSeconds: number;

ToppSecret.codeLength

要產生的一次性密碼的長度。

簽名:

readonly codeLength: number;

TotpSecret.enrollmentCompletionDeadline

TOTP 註冊應完成的時間戳記(UTC 字串)。

簽名:

readonly enrollmentCompletionDeadline: string;

ToppSecret.hashing演算法

使用的哈希演算法。

簽名:

readonly hashingAlgorithm: string;

ToppSecret.secretKey

用於註冊 TOTP MFA 和產生 OTP 的共用金鑰/種子。

簽名:

readonly secretKey: string;

TotpSecret.generateQrCodeUrl()

傳回一個QR 碼URL,如https://github.com/google/google-authenticator/wiki/Key-Uri-Format 所述。這可以作為QR 碼顯示給用戶,以便掃描到TOTP 應用程式(如Google在Authenticator)中。如果未指定可選參數,則 accountName 為和發行人被使用。

簽名:

generateQrCodeUrl(accountName?: string, issuer?: string): string;

參數

範圍類型描述
帳戶名稱細繩帳戶/應用程式的名稱以及使用者識別碼。
發行人細繩TOTP 的發行者(可能是應用程式名稱)。

返回:

細繩

二維碼 URL 字串。