@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
63 lines (60 loc) • 1.9 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PassageApp = void 0;
var _index = require("../../src/shared/index.js");
/**
* PassageApp class contains functions that operate on the Passage app level.
*/
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 _index.PassageReactNative.appInfo();
const parsedResult = JSON.parse(result);
return parsedResult;
} catch (error) {
throw new _index.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 _index.PassageReactNative.appUserExists(identifier);
if (result) {
const parsedResult = JSON.parse(result);
return parsedResult;
} else {
return null;
}
} catch (error) {
throw new _index.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 _index.PassageReactNative.appCreateUser(identifier, userMetadata || null);
const parsedResult = JSON.parse(result);
return parsedResult;
} catch (error) {
throw new _index.PassageError(error.code, error.message);
}
}
}
exports.PassageApp = PassageApp;
//# sourceMappingURL=PassageApp.js.map