當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript speakeasy.generateSecret函數代碼示例

本文整理匯總了TypeScript中speakeasy.generateSecret函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript generateSecret函數的具體用法?TypeScript generateSecret怎麽用?TypeScript generateSecret使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了generateSecret函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: compose

 public compose() {
     if (Vesta.isApiServer) {
         const replace: any = {
             __DB_PASSWORD__: speakeasy.generateSecret({ length: 16, symbols: false }).ascii,
             __SALT__: speakeasy.generateSecret({ length: 8, symbols: false }).ascii.replace(/\$/g, "-"),
             __SECRET_KEY__: speakeasy.generateSecret({ length: 64 }).ascii.replace(/\$/g, "-"),
         };
         findInFileAndReplace(`${this.config.name}/vesta/docker-compose.yml`, replace);
     }
 }
開發者ID:VestaRayanAfzar,項目名稱:vesta,代碼行數:10,代碼來源:DockerGen.ts

示例2: async

export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
	// Get 'password' parameter
	const [password, passwordErr] = $.str.get(params.password);
	if (passwordErr) return rej('invalid password param');

	// Compare password
	const same = await bcrypt.compare(password, user.password);

	if (!same) {
		return rej('incorrect password');
	}

	// Generate user's secret key
	const secret = speakeasy.generateSecret({
		length: 32
	});

	await User.update(user._id, {
		$set: {
			twoFactorTempSecret: secret.base32
		}
	});

	// Get the data URL of the authenticator URL
	QRCode.toDataURL(speakeasy.otpauthURL({
		secret: secret.base32,
		encoding: 'base32',
		label: user.username,
		issuer: config.host
	}), (err, data_url) => {
		res({
			qr: data_url,
			secret: secret.base32,
			label: user.username,
			issuer: config.host
		});
	});
});
開發者ID:ha-dai,項目名稱:Misskey,代碼行數:38,代碼來源:register.ts

示例3:

// normal use.
speakeasy.totp({key: 'secret'});

// use a custom time step.
speakeasy.totp({key: 'secret', step: 60});

// use a custom time.
speakeasy.totp({key: 'secret', time: 159183717});

// use a initial time.
speakeasy.totp({key: 'secret', initial_time: 4182881485});

speakeasy.generateSecret({
    length: 3,
    name: 'testName',
    qr_codes: true,
    google_auth_qr: true,
    otpauth_url: true,
    symbols: true
});

speakeasy.generateSecretASCII(5, true);

speakeasy.otpauthURL({
    secret: 'otpauthURLSecret',
    label: 'otpauthURLLength'
});

speakeasy.totp.verify({secret: "secret", token: "123456"})

speakeasy.totp.verifyDelta({secret: "secret", token: "123456"})
開發者ID:Dru89,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:speakeasy-tests.ts

示例4:

// normal use.
speakeasy.totp({secret: 'secret'});

// use a custom time step.
speakeasy.totp({secret: 'secret', step: 60});

// use a custom time.
speakeasy.totp({secret: 'secret', time: 159183717});

// use a initial time.
speakeasy.totp({secret: 'secret', initial_time: 4182881485});

const otpauth_url: string = speakeasy.generateSecret({
    length: 3,
    name: 'testName',
    qr_codes: true,
    google_auth_qr: true,
    otpauth_url: true,
    symbols: true
}).otpauth_url;

const otpauth_url2: string | undefined = speakeasy.generateSecret({
    length: 3,
    name: 'testName',
}).otpauth_url;

speakeasy.generateSecretASCII(5, true);

speakeasy.otpauthURL({
    secret: 'otpauthURLSecret',
    label: 'otpauthURLLength'
});
開發者ID:Jeremy-F,項目名稱:DefinitelyTyped,代碼行數:32,代碼來源:speakeasy-tests.ts


注:本文中的speakeasy.generateSecret函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。