UNPKG

@passageidentity/passage-react-native

Version:

Passkey Complete for React Native - Go completely passwordless with a standalone auth solution in your React Native app with Passage by 1Password

58 lines (55 loc) 1.76 kB
"use strict"; import { PassageError, PassageReactNative } from "../../src/shared/index.js"; /** * PassageApp class contains functions that operate on the Passage app level. */ export class PassageApp { /** * Get information about an app. * * @return {Promise<PassageAppInfo>} a data object containing app information and the authentication policy */ async info() { try { const result = await PassageReactNative.appInfo(); const parsedResult = JSON.parse(result); return parsedResult; } catch (error) { throw new PassageError(error.code, error.message); } } /** * Look-up a user and return the user properties if the user exists * @param {string} identifier email address / phone for user * @return {Promise<PublicUserInfo | null>} */ async userExists(identifier) { try { const result = await PassageReactNative.appUserExists(identifier); if (result) { const parsedResult = JSON.parse(result); return parsedResult; } else { return null; } } catch (error) { throw new PassageError(error.code, error.message); } } /** * createUser creates a user in a 'pending' state. * @param {string} identifier the email or phone number of the user * @param {Metadata} userMetadata optional metadata to associate with the user * @return {Promise<PublicUserInfo>} */ async createUser(identifier, userMetadata) { try { const result = await PassageReactNative.appCreateUser(identifier, userMetadata || null); const parsedResult = JSON.parse(result); return parsedResult; } catch (error) { throw new PassageError(error.code, error.message); } } } //# sourceMappingURL=PassageApp.js.map