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

41 lines (40 loc) 1.58 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PassageSocial = void 0; var _reactNative = require("react-native"); var _index = require("../shared/index.js"); /** * PassageSocial class contains functions that use social providers for authentication. */ class PassageSocial { /** * Initiates authorization via a supported third-party social provider. * @param {SocialConnection} connection The social connection to use for login. */ async authorize(connection) { return new Promise(async (resolve, reject) => { try { let authResultJson; if (_reactNative.Platform.OS === 'ios') { // The iOS native "authorize" method returns an AuthResult directly. authResultJson = await _index.PassageReactNative.socialAuthorize(connection); } else { // The Android native "authorize" method opens a Chrome Tab and returns void. await _index.PassageReactNative.socialAuthorize(connection); // Wait for a redirect back into the app with the auth code. const authCodeObj = await (0, _index.waitForDeepLinkQueryValues)(['code']); const authCode = authCodeObj.code; authResultJson = await _index.PassageReactNative.socialFinish(authCode); } const authResult = JSON.parse(authResultJson); resolve(authResult); } catch (error) { reject(new _index.PassageError(error.code, error.message)); } }); } } exports.PassageSocial = PassageSocial; //# sourceMappingURL=PassageSocial.js.map