@devtion/actions
Version:
A set of actions and helpers for CLI commands
72 lines • 4.07 kB
TypeScript
import { UserCredential } from "firebase/auth";
import { FirebaseApp } from "firebase/app";
import { Auth } from "firebase-admin/auth";
import { UserDocumentReferenceAndData } from "../../src/types/index";
/**
* Sleeps the function execution for given millis.
* @dev to be used in combination with loggers when writing data into files.
* @param ms <number> - sleep amount in milliseconds
* @returns <Promise<any>>
*/
export declare const sleep: (ms: any) => Promise<unknown>;
/**
* Return a pseudo random string of numeric values of specified length.
* @param length <string> - the number of values.
* @returns <string> - a pseudo random string of numeric values.
*/
export declare const generatePseudoRandomStringOfNumbers: (length: number) => string;
/**
* Create a new Firebase user account with specified email and password.
* @notice On successful creation of the user account, this user will also be signed in to your application.
* @dev The pw MUST not be the one used for login with the email on Google or other email providers. The pw is only valid for authentication with Firebase.
* @param userApp <FirebaseApp> - the initialized instance of the Firebase app.
* @param email <string> - the personal user email.
* @param pw <string> - a password to be associated with the user personal email here in Firebase.
* @returns <Promise<UserCredential>>
*/
export declare const createNewFirebaseUserWithEmailAndPw: (userApp: FirebaseApp, email: string, pw: string) => Promise<UserCredential>;
/**
* Return the verification code needed to complete the access with Github.
* @param gmailUserEmail <string> - the GMail email address.
* @param gmailClientId <string> - the GMail client identifier.
* @param gmailClientSecret <string> - the GMail client secret.
* @param gmailRedirectUrl <string> - the GMail redirect url.
* @param gmailRefreshToken <string> - the GMail refresh token.
* @dev You should have the GMail APIs for OAuth2.0 must be enabled and configured properly in order to get correct results.
* @returns <Promise<string>> - return the 6 digits verification code needed to complete the access with Github.
* @todo this method will not be used for testing right now. See PR #286 and #289 for info.
*/
export declare const getLastGithubVerificationCode: (gmailUserEmail: string, gmailClientId: string, gmailClientSecret: string, gmailRedirectUrl: string, gmailRefreshToken: string) => Promise<string>;
/**
* Test function to set custom claims of a user.
* @param adminAuth <Auth> - the admin auth instance.
* @param userId <string> - the uid of the user to add the privileges to.
* @param claims <{ [key: string]: boolean }> - the claims to set.
* @returns
*/
export declare const setCustomClaims: (adminAuth: Auth, userId: string, claims: {
[key: string]: boolean;
}) => Promise<void>;
/**
* Test function to create a new user
* @param userApp <FirebaseApp> - the Firebase user Application instance.
* @param email <string> - the email of the user.
* @param password <string> - the password of the user.
* @param isUserCoordinator <boolean> - whether the user is a coordinator or not.
* @param adminAuth <Auth> - the admin auth instance.
*/
export declare const createMockUser: (userApp: FirebaseApp, email: string, password: string, isUserCoordinator?: boolean, adminAuth?: Auth) => Promise<string>;
/**
* Generate a list of random passwords.
* @param numberOfUsers <number> - the number of users to generate passwords for.
* @returns <string[]> - the list of passwords.
*/
export declare const generateUserPasswords: (numberOfUsers: number) => string[];
/**
* Clean up the db and app by removing users created for testing.
* @param adminAuth <Auth> - the admin auth instance.
* @param adminFirestore <Firestore> - the admin firestore instance.
* @param uids <string[]> - the list of uids to delete.
*/
export declare const cleanUpMockUsers: (adminAuth: Auth, adminFirestore: FirebaseFirestore.Firestore, users: UserDocumentReferenceAndData[]) => Promise<void>;
//# sourceMappingURL=authentication.d.ts.map