0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-06 20:40:08 -05:00
logto/packages/integration-tests/src/utils.ts

21 lines
711 B
TypeScript
Raw Normal View History

2022-10-21 00:14:17 -05:00
import type { Response } from 'got';
export const extractCookie = (response: Response) => {
const { headers } = response;
return headers['set-cookie']?.join('; ') ?? '';
};
export const generateUsername = () => `usr_${crypto.randomUUID().replaceAll('-', '_')}`;
export const generatePassword = () => `pwd_${crypto.randomUUID()}`;
export const generateResourceName = () => `res_${crypto.randomUUID()}`;
export const generateResourceIndicator = () => `https://${crypto.randomUUID()}.logto.io`;
export const generateEmail = () => `${crypto.randomUUID().toLowerCase()}@logto.io`;
export const generatePhone = () => {
const array = new Uint32Array(1);
return crypto.getRandomValues(array).join('');
};