UNPKG

@sneko/ionic-appauth

Version:

Intergration for OpenId/AppAuth-JS into Ionic V3/4/5

84 lines (83 loc) 3.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CordovaBrowser = void 0; var tslib_1 = require("tslib"); var cordova_document_1 = require("./cordova-document"); var auth_browser_1 = require("../auth-browser"); var safari_view_controller_1 = require("@ionic-native/safari-view-controller"); var in_app_browser_1 = require("@ionic-native/in-app-browser"); // REQUIRES CORDOVA PLUGINS // cordova-plugin-safariviewcontroller // cordova-plugin-customurlscheme // cordova-plugin-inappbrowser FROM https://github.com/Onegini/cordova-plugin-inappbrowser.git var CordovaBrowser = /** @class */ (function (_super) { tslib_1.__extends(CordovaBrowser, _super); function CordovaBrowser() { return _super !== null && _super.apply(this, arguments) || this; } CordovaBrowser.prototype.closeWindow = function () { return tslib_1.__awaiter(this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, cordova_document_1.CordovaDocument.ready()]; case 1: _a.sent(); return [4 /*yield*/, safari_view_controller_1.SafariViewController.isAvailable()]; case 2: if (_a.sent()) { try { safari_view_controller_1.SafariViewController.hide(); } catch (_b) { } } else { if (this.inAppBrowserRef != undefined) this.inAppBrowserRef.close(); } return [2 /*return*/]; } }); }); }; CordovaBrowser.prototype.showWindow = function (url) { return tslib_1.__awaiter(this, void 0, void 0, function () { var optionSafari, options; var _this = this; return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, cordova_document_1.CordovaDocument.ready()]; case 1: _a.sent(); return [4 /*yield*/, safari_view_controller_1.SafariViewController.isAvailable()]; case 2: if (_a.sent()) { optionSafari = { url: url, showDefaultShareMenuItem: false, toolbarColor: '#ffffff' }; safari_view_controller_1.SafariViewController.show(optionSafari).subscribe(function (result) { if (result.event === 'closed') { _this.onCloseFunction(); } }); } else { options = { location: 'no', zoom: 'no', clearcache: 'yes', clearsessioncache: 'yes', }; this.inAppBrowserRef = in_app_browser_1.InAppBrowser.create(url, '_self', options); if (this.inAppBrowserRef != undefined) this.inAppBrowserRef.on('exit').subscribe(function () { return _this.onCloseFunction(); }); } return [2 /*return*/]; } }); }); }; return CordovaBrowser; }(auth_browser_1.Browser)); exports.CordovaBrowser = CordovaBrowser;