@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.49 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PassageHosted = void 0;
var _reactNative = require("react-native");
var _index = require("../shared/index.js");
/**
* PassageHosted class contains functions that use Hosted Login for authentication.
*/
class PassageHosted {
/**
* Authentication method for Passage Hosted apps
* If your Passage app is Hosted, use this method to register and log in your user.
* This method will open up a Passage login experience in a secure web view.
*/
async authorize() {
try {
if (_reactNative.Platform.OS === 'ios') {
// The iOS native "hostedAuthStart" method returns an AuthResult directly.
const result = await _index.PassageReactNative.hostedAuthorize();
return JSON.parse(result);
} else {
// The Android native "hostedAuthStart" method opens a Chrome Tab and returns void.
await _index.PassageReactNative.hostedAuthorize();
// Wait for a redirect back into the app with the auth code.
const {
code: authCode,
state
} = await (0, _index.waitForDeepLinkQueryValues)(['code', 'state']);
let result = await _index.PassageReactNative.hostedFinish(authCode, state);
return JSON.parse(result);
}
} catch (error) {
throw new _index.PassageError(error.code, error.message);
}
}
}
exports.PassageHosted = PassageHosted;
//# sourceMappingURL=PassageHosted.js.map
;