How to use createSignInUrl method in qawolf

Best JavaScript code snippet using qawolf

identifo.mjs

Source:identifo.mjs Github

copy

Full Screen

1var APIErrorCodes;2(function(APIErrorCodes2) {3 APIErrorCodes2["PleaseEnableTFA"] = "error.api.request.2fa.please_enable";4 APIErrorCodes2["NetworkError"] = "error.network";5})(APIErrorCodes || (APIErrorCodes = {}));6var TFAType;7(function(TFAType2) {8 TFAType2["TFATypeApp"] = "app";9 TFAType2["TFATypeSMS"] = "sms";10 TFAType2["TFATypeEmail"] = "email";11})(TFAType || (TFAType = {}));12class ApiError extends Error {13 constructor(error) {14 super((error == null ? void 0 : error.message) || "Unknown API error");15 this.detailedMessage = error == null ? void 0 : error.detailed_message;16 this.id = error == null ? void 0 : error.id;17 this.status = error == null ? void 0 : error.status;18 }19}20var __defProp$1 = Object.defineProperty;21var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;22var __hasOwnProp$1 = Object.prototype.hasOwnProperty;23var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;24var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;25var __spreadValues$1 = (a, b) => {26 for (var prop in b || (b = {}))27 if (__hasOwnProp$1.call(b, prop))28 __defNormalProp$1(a, prop, b[prop]);29 if (__getOwnPropSymbols$1)30 for (var prop of __getOwnPropSymbols$1(b)) {31 if (__propIsEnum$1.call(b, prop))32 __defNormalProp$1(a, prop, b[prop]);33 }34 return a;35};36var __async$2 = (__this, __arguments, generator) => {37 return new Promise((resolve, reject) => {38 var fulfilled = (value) => {39 try {40 step(generator.next(value));41 } catch (e) {42 reject(e);43 }44 };45 var rejected = (value) => {46 try {47 step(generator.throw(value));48 } catch (e) {49 reject(e);50 }51 };52 var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);53 step((generator = generator.apply(__this, __arguments)).next());54 });55};56const APP_ID_HEADER_KEY = "X-Identifo-Clientid";57const AUTHORIZATION_HEADER_KEY = "Authorization";58class Api {59 constructor(config, tokenService) {60 this.config = config;61 this.tokenService = tokenService;62 this.defaultHeaders = {63 [APP_ID_HEADER_KEY]: "",64 Accept: "application/json",65 "Content-Type": "application/json"66 };67 this.catchNetworkErrorHandler = (e) => {68 if (e.message === "Network Error" || e.message === "Failed to fetch" || e.message === "Preflight response is not successful" || e.message.indexOf("is not allowed by Access-Control-Allow-Origin") > -1) {69 console.error(e.message);70 throw new ApiError({71 id: APIErrorCodes.NetworkError,72 status: 0,73 message: "Configuration error",74 detailed_message: `Please check Identifo URL and add "${window.location.protocol}//${window.location.host}" to "REDIRECT URLS" in Identifo app settings.`75 });76 }77 throw e;78 };79 this.checkStatusCodeAndGetJSON = (r) => __async$2(this, null, function* () {80 if (!r.ok) {81 const error = yield r.json();82 throw new ApiError(error == null ? void 0 : error.error);83 }84 return r.json();85 });86 this.baseUrl = config.url.replace(/\/$/, "");87 this.defaultHeaders[APP_ID_HEADER_KEY] = config.appId;88 this.appId = config.appId;89 }90 get(path, options) {91 return this.send(path, __spreadValues$1({ method: "GET" }, options));92 }93 put(path, data, options) {94 return this.send(path, __spreadValues$1({ method: "PUT", body: JSON.stringify(data) }, options));95 }96 post(path, data, options) {97 return this.send(path, __spreadValues$1({ method: "POST", body: JSON.stringify(data) }, options));98 }99 send(path, options) {100 const init = __spreadValues$1({}, options);101 init.headers = __spreadValues$1(__spreadValues$1({}, init.headers), this.defaultHeaders);102 return fetch(`${this.baseUrl}${path}`, init).catch(this.catchNetworkErrorHandler).then(this.checkStatusCodeAndGetJSON).then((value) => value);103 }104 getUser() {105 return __async$2(this, null, function* () {106 var _a, _b;107 if (!((_a = this.tokenService.getToken()) == null ? void 0 : _a.token)) {108 throw new Error("No token in token service.");109 }110 return this.get("/me", {111 headers: {112 [AUTHORIZATION_HEADER_KEY]: `Bearer ${(_b = this.tokenService.getToken()) == null ? void 0 : _b.token}`113 }114 });115 });116 }117 renewToken() {118 return __async$2(this, null, function* () {119 var _a, _b;120 if (!((_a = this.tokenService.getToken("refresh")) == null ? void 0 : _a.token)) {121 throw new Error("No token in token service.");122 }123 return this.post("/auth/token", { scopes: this.config.scopes }, {124 headers: {125 [AUTHORIZATION_HEADER_KEY]: `Bearer ${(_b = this.tokenService.getToken("refresh")) == null ? void 0 : _b.token}`126 }127 }).then((r) => this.storeToken(r));128 });129 }130 updateUser(user) {131 return __async$2(this, null, function* () {132 var _a, _b;133 if (!((_a = this.tokenService.getToken()) == null ? void 0 : _a.token)) {134 throw new Error("No token in token service.");135 }136 return this.put("/me", user, {137 headers: {138 [AUTHORIZATION_HEADER_KEY]: `Bearer ${(_b = this.tokenService.getToken("access")) == null ? void 0 : _b.token}`139 }140 });141 });142 }143 login(email, password, deviceToken, scopes) {144 return __async$2(this, null, function* () {145 const data = {146 email,147 password,148 device_token: deviceToken,149 scopes150 };151 return this.post("/auth/login", data).then((r) => this.storeToken(r));152 });153 }154 federatedLogin(_0, _1, _2, _3) {155 return __async$2(this, arguments, function* (provider, scopes, redirectUrl, callbackUrl, opts = { width: 600, height: 800, popUp: false }) {156 var dataForm = document.createElement("form");157 dataForm.style.display = "none";158 if (opts.popUp) {159 dataForm.target = "TargetWindow";160 }161 dataForm.method = "POST";162 const params = new URLSearchParams();163 params.set("appId", this.config.appId);164 params.set("provider", provider);165 params.set("scopes", scopes.join(","));166 params.set("redirectUrl", redirectUrl);167 if (callbackUrl) {168 params.set("callbackUrl", callbackUrl);169 }170 dataForm.action = `${this.baseUrl}/auth/federated?${params.toString()}`;171 document.body.appendChild(dataForm);172 if (opts.popUp) {173 const left = window.screenX + window.outerWidth / 2 - (opts.width || 600) / 2;174 const top = window.screenY + window.outerHeight / 2 - (opts.height || 800) / 2;175 var postWindow = window.open("", "TargetWindow", `status=0,title=0,height=${opts.height},width=${opts.width},top=${top},left=${left},scrollbars=1`);176 if (postWindow) {177 dataForm.submit();178 }179 } else {180 dataForm.submit();181 }182 });183 }184 federatedLoginComplete(params) {185 return __async$2(this, null, function* () {186 return this.get(`/auth/federated/complete?${params.toString()}`).then((r) => this.storeToken(r));187 });188 }189 register(email, password, scopes) {190 return __async$2(this, null, function* () {191 const data = {192 email,193 password,194 scopes195 };196 return this.post("/auth/register", data).then((r) => this.storeToken(r));197 });198 }199 requestResetPassword(email) {200 return __async$2(this, null, function* () {201 const data = {202 email203 };204 return this.post("/auth/request_reset_password", data);205 });206 }207 resetPassword(password) {208 return __async$2(this, null, function* () {209 var _a, _b;210 if (!((_a = this.tokenService.getToken()) == null ? void 0 : _a.token)) {211 throw new Error("No token in token service.");212 }213 const data = {214 password215 };216 return this.post("/auth/reset_password", data, {217 headers: {218 [AUTHORIZATION_HEADER_KEY]: `Bearer ${(_b = this.tokenService.getToken()) == null ? void 0 : _b.token}`219 }220 });221 });222 }223 getAppSettings() {224 return __async$2(this, null, function* () {225 return this.get("/auth/app_settings");226 });227 }228 enableTFA() {229 return __async$2(this, null, function* () {230 var _a, _b;231 if (!((_a = this.tokenService.getToken()) == null ? void 0 : _a.token)) {232 throw new Error("No token in token service.");233 }234 return this.put("/auth/tfa/enable", {}, {235 headers: { [AUTHORIZATION_HEADER_KEY]: `BEARER ${(_b = this.tokenService.getToken()) == null ? void 0 : _b.token}` }236 });237 });238 }239 verifyTFA(code, scopes) {240 return __async$2(this, null, function* () {241 var _a, _b;242 if (!((_a = this.tokenService.getToken()) == null ? void 0 : _a.token)) {243 throw new Error("No token in token service.");244 }245 return this.post("/auth/tfa/login", { tfa_code: code, scopes }, { headers: { [AUTHORIZATION_HEADER_KEY]: `BEARER ${(_b = this.tokenService.getToken()) == null ? void 0 : _b.token}` } }).then((r) => this.storeToken(r));246 });247 }248 logout() {249 return __async$2(this, null, function* () {250 var _a, _b, _c;251 if (!((_a = this.tokenService.getToken()) == null ? void 0 : _a.token)) {252 throw new Error("No token in token service.");253 }254 return this.post("/me/logout", {255 refresh_token: (_b = this.tokenService.getToken("refresh")) == null ? void 0 : _b.token256 }, {257 headers: {258 [AUTHORIZATION_HEADER_KEY]: `Bearer ${(_c = this.tokenService.getToken()) == null ? void 0 : _c.token}`259 }260 });261 });262 }263 storeToken(response) {264 if (response.access_token) {265 this.tokenService.saveToken(response.access_token, "access");266 }267 if (response.refresh_token) {268 this.tokenService.saveToken(response.refresh_token, "refresh");269 }270 return response;271 }272}273const jwtRegex = /^([a-zA-Z0-9_=]+)\.([a-zA-Z0-9_=]+)\.([a-zA-Z0-9_\-=]*$)/;274const INVALID_TOKEN_ERROR = "Empty or invalid token";275const TOKEN_QUERY_KEY = "token";276const REFRESH_TOKEN_QUERY_KEY = "refresh_token";277class CookieStorage {278 constructor() {279 this.isAccessible = false;280 }281 saveToken() {282 return true;283 }284 getToken() {285 throw new Error("Can not get token from HttpOnly");286 }287 deleteToken() {288 }289}290class StorageManager {291 constructor(storageType, accessKey, refreshKey) {292 this.preffix = "identifo_";293 this.storageType = "localStorage";294 this.access = `${this.preffix}access_token`;295 this.refresh = `${this.preffix}refresh_token`;296 this.isAccessible = true;297 this.access = accessKey ? this.preffix + accessKey : this.access;298 this.refresh = refreshKey ? this.preffix + refreshKey : this.refresh;299 this.storageType = storageType;300 }301 saveToken(token, tokenType) {302 if (token) {303 window[this.storageType].setItem(this[tokenType], token);304 return true;305 }306 return false;307 }308 getToken(tokenType) {309 var _a;310 return (_a = window[this.storageType].getItem(this[tokenType])) != null ? _a : "";311 }312 deleteToken(tokenType) {313 window[this.storageType].removeItem(this[tokenType]);314 }315}316class LocalStorage extends StorageManager {317 constructor(accessKey, refreshKey) {318 super("localStorage", accessKey, refreshKey);319 }320}321class SessionStorage extends StorageManager {322 constructor(accessKey, refreshKey) {323 super("sessionStorage", accessKey, refreshKey);324 }325}326var __async$1 = (__this, __arguments, generator) => {327 return new Promise((resolve, reject) => {328 var fulfilled = (value) => {329 try {330 step(generator.next(value));331 } catch (e) {332 reject(e);333 }334 };335 var rejected = (value) => {336 try {337 step(generator.throw(value));338 } catch (e) {339 reject(e);340 }341 };342 var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);343 step((generator = generator.apply(__this, __arguments)).next());344 });345};346class TokenService {347 constructor(tokenManager) {348 this.tokenManager = tokenManager || new LocalStorage();349 }350 handleVerification(token, audience, issuer) {351 return __async$1(this, null, function* () {352 if (!this.tokenManager.isAccessible)353 return true;354 try {355 yield this.validateToken(token, audience, issuer);356 this.saveToken(token);357 return true;358 } catch (err) {359 this.removeToken();360 return Promise.reject(err);361 }362 });363 }364 validateToken(token, audience, issuer) {365 return __async$1(this, null, function* () {366 var _a;367 if (!token)368 throw new Error(INVALID_TOKEN_ERROR);369 const jwtPayload = this.parseJWT(token);370 const isJwtExpired = this.isJWTExpired(jwtPayload);371 if (((_a = jwtPayload.aud) == null ? void 0 : _a.includes(audience)) && (!issuer || jwtPayload.iss === issuer) && !isJwtExpired) {372 return Promise.resolve(true);373 }374 throw new Error(INVALID_TOKEN_ERROR);375 });376 }377 parseJWT(token) {378 const base64Url = token.split(".")[1];379 if (!base64Url)380 return { aud: [], iss: "", exp: 10 };381 const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");382 const jsonPayload = decodeURIComponent(atob(base64).split("").map((c) => `%${`00${c.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""));383 return JSON.parse(jsonPayload);384 }385 isJWTExpired(token) {386 const now = new Date().getTime() / 1e3;387 if (token.exp && now > token.exp) {388 return true;389 }390 return false;391 }392 isAuthenticated(audience, issuer) {393 if (!this.tokenManager.isAccessible)394 return Promise.resolve(true);395 const token = this.tokenManager.getToken("access");396 return this.validateToken(token, audience, issuer);397 }398 saveToken(token, type = "access") {399 return this.tokenManager.saveToken(token, type);400 }401 removeToken(type = "access") {402 this.tokenManager.deleteToken(type);403 }404 getToken(type = "access") {405 const token = this.tokenManager.getToken(type);406 if (!token)407 return null;408 const jwtPayload = this.parseJWT(token);409 return { token, payload: jwtPayload };410 }411}412class UrlBuilder {413 constructor(config) {414 this.config = config;415 }416 getUrl(flow) {417 var _a, _b;418 const scopes = ((_a = this.config.scopes) == null ? void 0 : _a.join()) || "";419 const redirectUri = encodeURIComponent((_b = this.config.redirectUri) != null ? _b : window.location.href);420 const baseParams = `appId=${this.config.appId}&scopes=${scopes}`;421 const urlParams = `${baseParams}&callbackUrl=${redirectUri}`;422 const postLogoutRedirectUri = this.config.postLogoutRedirectUri ? `&callbackUrl=${encodeURIComponent(this.config.postLogoutRedirectUri)}` : `&callbackUrl=${redirectUri}&redirectUri=${this.config.url}/web/login?${encodeURIComponent(baseParams)}`;423 const urls = {424 signup: `${this.config.url}/web/register?${urlParams}`,425 signin: `${this.config.url}/web/login?${urlParams}`,426 logout: `${this.config.url}/web/logout?${baseParams}${postLogoutRedirectUri}`,427 renew: `${this.config.url}/web/token/renew?${baseParams}&redirectUri=${redirectUri}`,428 default: "default"429 };430 return urls[flow] || urls.default;431 }432 createSignupUrl() {433 return this.getUrl("signup");434 }435 createSigninUrl() {436 return this.getUrl("signin");437 }438 createLogoutUrl() {439 return this.getUrl("logout");440 }441 createRenewSessionUrl() {442 return this.getUrl("renew");443 }444}445var __defProp = Object.defineProperty;446var __defProps = Object.defineProperties;447var __getOwnPropDescs = Object.getOwnPropertyDescriptors;448var __getOwnPropSymbols = Object.getOwnPropertySymbols;449var __hasOwnProp = Object.prototype.hasOwnProperty;450var __propIsEnum = Object.prototype.propertyIsEnumerable;451var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;452var __spreadValues = (a, b) => {453 for (var prop in b || (b = {}))454 if (__hasOwnProp.call(b, prop))455 __defNormalProp(a, prop, b[prop]);456 if (__getOwnPropSymbols)457 for (var prop of __getOwnPropSymbols(b)) {458 if (__propIsEnum.call(b, prop))459 __defNormalProp(a, prop, b[prop]);460 }461 return a;462};463var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));464var __async = (__this, __arguments, generator) => {465 return new Promise((resolve, reject) => {466 var fulfilled = (value) => {467 try {468 step(generator.next(value));469 } catch (e) {470 reject(e);471 }472 };473 var rejected = (value) => {474 try {475 step(generator.throw(value));476 } catch (e) {477 reject(e);478 }479 };480 var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);481 step((generator = generator.apply(__this, __arguments)).next());482 });483};484class IdentifoAuth {485 constructor(config) {486 this.token = null;487 this.isAuth = false;488 var _a, _b;489 this.config = __spreadProps(__spreadValues({}, config), { autoRenew: (_a = config.autoRenew) != null ? _a : true });490 this.tokenService = new TokenService(config.tokenManager);491 this.urlBuilder = new UrlBuilder(this.config);492 this.api = new Api(config, this.tokenService);493 this.handleToken(((_b = this.tokenService.getToken()) == null ? void 0 : _b.token) || "", "access");494 }495 handleToken(token, tokenType) {496 if (token) {497 if (tokenType === "access") {498 const payload = this.tokenService.parseJWT(token);499 this.token = { token, payload };500 this.isAuth = true;501 this.tokenService.saveToken(token);502 } else {503 this.tokenService.saveToken(token, "refresh");504 }505 }506 }507 resetAuthValues() {508 this.token = null;509 this.isAuth = false;510 this.tokenService.removeToken();511 this.tokenService.removeToken("refresh");512 }513 signup() {514 window.location.href = this.urlBuilder.createSignupUrl();515 }516 signin() {517 window.location.href = this.urlBuilder.createSigninUrl();518 }519 logout() {520 this.resetAuthValues();521 window.location.href = this.urlBuilder.createLogoutUrl();522 }523 handleAuthentication() {524 return __async(this, null, function* () {525 const { access, refresh } = this.getTokenFromUrl();526 if (!access) {527 this.resetAuthValues();528 return Promise.reject();529 }530 try {531 yield this.tokenService.handleVerification(access, this.config.appId, this.config.issuer);532 this.handleToken(access, "access");533 if (refresh) {534 this.handleToken(refresh, "refresh");535 }536 return yield Promise.resolve(true);537 } catch (err) {538 this.resetAuthValues();539 return yield Promise.reject();540 } finally {541 window.location.hash = "";542 }543 });544 }545 getTokenFromUrl() {546 const urlParams = new URLSearchParams(window.location.search);547 const tokens = { access: "", refresh: "" };548 const accessToken = urlParams.get(TOKEN_QUERY_KEY);549 const refreshToken = urlParams.get(REFRESH_TOKEN_QUERY_KEY);550 if (refreshToken && jwtRegex.test(refreshToken)) {551 tokens.refresh = refreshToken;552 }553 if (accessToken && jwtRegex.test(accessToken)) {554 tokens.access = accessToken;555 }556 return tokens;557 }558 getToken() {559 return __async(this, null, function* () {560 const token = this.tokenService.getToken();561 const refreshToken = this.tokenService.getToken("refresh");562 if (token) {563 const isExpired = this.tokenService.isJWTExpired(token.payload);564 if (isExpired && refreshToken) {565 try {566 yield this.renewSession();567 return yield Promise.resolve(this.token);568 } catch (err) {569 this.resetAuthValues();570 throw new Error("No token");571 }572 }573 return Promise.resolve(token);574 }575 return Promise.resolve(null);576 });577 }578 renewSession() {579 return __async(this, null, function* () {580 try {581 const { access, refresh } = yield this.renewSessionWithToken();582 this.handleToken(access, "access");583 this.handleToken(refresh, "refresh");584 return yield Promise.resolve(access);585 } catch (err) {586 return Promise.reject();587 }588 });589 }590 renewSessionWithToken() {591 return __async(this, null, function* () {592 try {593 const tokens = yield this.api.renewToken().then((l) => ({ access: l.access_token || "", refresh: l.refresh_token || "" }));594 return tokens;595 } catch (err) {596 return Promise.reject(err);597 }598 });599 }600}601export { APIErrorCodes, ApiError, CookieStorage as CookieStorageManager, IdentifoAuth, LocalStorage as LocalStorageManager, SessionStorage as SessionStorageManager, TFAType };...

Full Screen

Full Screen

popup.ts

Source:popup.ts Github

copy

Full Screen

1import {AuthHandlers} from "polar-bookshelf/web/js/apps/repository/auth_handler/AuthHandler";2import {Tracer} from "polar-shared/src/util/Tracer";3import {PopupApp} from "./ui/popup/PopupApp";4import {Tabs} from "./chrome/Tabs";5import loadLinkInActiveTab = Tabs.loadLinkInActiveTab;6import {SignInSuccessURLs} from "polar-bookshelf/apps/repository/js/login/SignInSuccessURLs";7function loadLinkInNewTab(link: string) {8 chrome.tabs.create({url: link});9}10function closeWindowAfterDelay() {11 setTimeout(() => window.close(), 7500);12}13async function requireAuth(): Promise<boolean> {14 console.log("Verifying we're logged into Polar...");15 const authHandler = AuthHandlers.get();16 console.log("Getting userInfo...");17 const userInfo = await Tracer.async(() => authHandler.userInfo(), 'userInfo');18 console.log("Getting userInfo...done");19 if (! userInfo.isPresent()) {20 console.log("Authenticating ...");21 async function createSignInURL(): Promise<string> {22 const baseURL = `${document.location.origin}/login.html`;23 const signInSuccessUrl = await Tabs.queryCurrentTabForLink();24 console.log("Using signInSuccessUrl: ", signInSuccessUrl);25 return SignInSuccessURLs.createSignInURL(signInSuccessUrl, baseURL);26 }27 const signInURL = await createSignInURL();28 await loadLinkInActiveTab(signInURL);29 // https://firebaseopensource.com/projects/firebase/quickstart-js/auth/chromextension/readme/30 // https://firebase.google.com/docs/auth/web/google-signin31 // https://developer.chrome.com/apps/app_identity32 console.log("Authenticating ...done");33 return false;34 } else {35 console.log("Already authenticated.");36 }37 console.log("Verifying we're logged into Polar...done");38 return true;39}40export function injectContentScript() {41 console.log("Injecting content script...");42 chrome.tabs.executeScript({43 file: 'content-bundle.js'44 });45 console.log("Injecting content script...done");46}47export function startApp() {48 console.log("Starting react app...");49 PopupApp.start();50 console.log("Starting react app...done");51}52async function handleExtensionActivated() {53 startApp();54 const authenticated = await requireAuth();55 if (authenticated) {56 await injectContentScript();57 }58 window.close();59}60/**61 * Called when the user clicks the button in the page to 'share' with Polar.62 */63async function onExtensionActivated() {64 handleExtensionActivated()65 .catch(err => console.error("Unable to handle popup: ", err));66}67document.addEventListener("DOMContentLoaded", () => {68 onExtensionActivated()69 .catch(err => {70 console.log("failed");71 // closeWindowAfterDelay();72 console.error("Unable to send URL to polar: ", err)73 });...

Full Screen

Full Screen

App.jsx

Source:App.jsx Github

copy

Full Screen

1import { useState } from 'react'2import { Button } from '@/components/dom/Button'3import { ThreeApp } from '@/components/three/ThreeApp'4import { useStore } from './store'5export function App() {6 const [startedAR, setStartedAR] = useState(false)7 const onStartAR = () => {8 console.log('starting XR session')9 setStartedAR(true)10 }11 return startedAR ? <ThreeApp /> : <LandingPage onStartAR={onStartAR} />12}13function LandingPage({ onStartAR }) {14 const snap = useStore()15 const isSupportedBrowser = navigator.userAgent.includes('WebXRViewer')16 let body17 if (isSupportedBrowser) {18 if (snap.credentials) {19 body = <SignedIn onStartAR={onStartAR} />20 } else {21 body = <SignedOut />22 }23 } else {24 body = <UnsupportedBrowser />25 }26 return (27 <div className="flex flex-col justify-center items-center w-full h-full">28 <img alt="Augmented Environments Lab logo" src="/ael-logo.jpg" width={200} />29 {body}30 </div>31 )32}33function UnsupportedBrowser() {34 return (35 <div className="grid gap-10 place-items-center px-8">36 <p className="text-center">Please visit this page in WebXR Viewer on a supported iOS device.</p>37 <a38 href="https://apps.apple.com/us/app/webxr-viewer/id1295998056?itsct=apps_box_badge&amp;itscg=30200"39 style={{ display: 'inline-block', overflow: 'hidden', borderRadius: '13px', width: '250px', height: '83px' }}40 >41 <img42 src="https://tools.applemediaservices.com/api/badges/download-on-the-app-store/black/en-us?size=250x83&amp;releaseDate=1512604800&h=337a4ee86d323f6cc8ce8ab793b4b045"43 alt="Download on the App Store"44 style={{ borderRadius: '13px', width: '250px', height: '83px' }}45 />46 </a>47 </div>48 )49}50function SignedOut() {51 const signInURL = createSigninURL()52 return (53 <a href={signInURL}>54 <Button>Sign In</Button>55 </a>56 )57}58function SignedIn({ onStartAR }) {59 const snap = useStore()60 const signInURL = createSigninURL()61 return (62 <>63 <div className="mb-6 text-center">64 <p>65 Signed in as <span className="font-semibold">{formatEmail(snap.credentials.email)}</span>66 </p>67 <a className="text-hubs-blue hover:text-hubs-lightblue" href={signInURL}>68 Switch account69 </a>70 </div>71 <Button primary onClick={onStartAR}>72 Start Tracking73 </Button>74 </>75 )76}77function formatEmail(email) {78 const [alias, domain] = email.split('@')79 return `${alias.substring(0, 3)}...@${domain}`80}81function createSigninURL() {82 const url = new URL('https://hubs.aelatgt.net/signin')83 url.searchParams.set('sign_in_destination_url', 'https://ios.aelatgt.net')84 return url.toString()...

Full Screen

Full Screen

navigator.ts

Source:navigator.ts Github

copy

Full Screen

1import { BBAuthTokenErrorCode } from '../auth';2const SIGNIN_BASE_URL = 'https://signin.blackbaud.com/signin/';3const ERROR_BASE_URL = 'https://host.nxt.blackbaud.com/errors/';4const euc = encodeURIComponent;5function paramsToQS(params: any) {6 const qs = [];7 for (const p in params) {8 /* istanbul ignore else */9 if (params.hasOwnProperty(p)) {10 qs.push(`${euc(p)}=${euc(params[p])}`);11 }12 }13 return qs.join('&');14}15function createSigninUrl(inactive?: boolean) {16 let url = `${SIGNIN_BASE_URL}?redirectUrl=${euc(location.href)}`;17 if (inactive) {18 url += '&inactivity=1';19 }20 return url;21}22export class BBAuthNavigator {23 /* istanbul ignore next */24 public static navigate(url: string, replace?: boolean) {25 if (replace) {26 location.replace(url);27 } else {28 location.href = url;29 }30 }31 public static redirectToSignin(signinRedirectParams?: any) {32 let signinUrl = createSigninUrl();33 if (signinRedirectParams) {34 signinUrl += '&' + paramsToQS(signinRedirectParams);35 }36 this.navigate(signinUrl);37 }38 public static redirectToSignoutForInactivity() {39 const signinUrl = createSigninUrl(true);40 const signoutUrl = `${SIGNIN_BASE_URL}sign-out?redirectUrl=${euc(signinUrl)}`;41 this.navigate(signoutUrl);42 }43 public static redirectToError(code: BBAuthTokenErrorCode) {44 let path: string;45 let errorCode: string;46 switch (code) {47 case BBAuthTokenErrorCode.InvalidEnvironment:48 errorCode = 'invalid_env';49 path = 'security';50 break;51 default:52 path = 'broken';53 break;54 }55 let url = `${ERROR_BASE_URL}${path}?source=auth-client&url=${euc(location.href)}`;56 if (errorCode) {57 url += `&code=${euc(errorCode)}`;58 }59 this.navigate(url);60 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const qawolf = require("qawolf");2(async () => {3 const browser = await qawolf.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.click("input[name=q]");7 await page.fill("input[name=q]", "qawolf");8 await page.press("input[name=q]", "Enter");9 await page.click("text=QA Wolf: End-to-end testing for developers");10 await qawolf.createSignInUrl(page);11 await page.close();12 await context.close();13 await browser.close();14})();15const qawolf = require("qawolf");16describe("test", () => {17 let browser;18 let page;19 beforeAll(async () => {20 browser = await qawolf.launch();21 });22 afterAll(async () => {23 await browser.close();24 });25 beforeEach(async () => {26 const context = await browser.newContext();27 page = await context.newPage();28 });29 afterEach(async () => {30 await page.close();31 });32 it("test", async () => {33 await page.click("input[name=q]");34 await page.fill("input[name=q]", "qawolf");35 await page.press("input[name=q]", "Enter");36 await page.click("text=QA Wolf: End-to-end testing for developers");37 await qawolf.createSignInUrl(page);38 });39});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { createSignInUrl } = require('qawolf');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 const url = await createSignInUrl(page, 'test');8 await page.goto(url);9 await page.waitForSelector("text=Welcome, test!");10 await page.close();11 await context.close();12 await browser.close();13})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { createSignInUrl } = require('qawolf');2const { createSignInUrl } = require('qawolf');3const { createSignInUrl } = require('qawolf');4const { createSignInUrl } = require('qawolf');5const { createSignInUrl } = require('qawolf');6const { createSignInUrl } = require('qawolf');7const { createSignInUrl } = require('qawolf');8const { createSignInUrl } = require('qawolf');9const { createSignInUrl } = require('qawolf');10const { createSignInUrl } = require('qawolf');11const { createSignInUrl } = require('qawolf');12const { createSignInUrl } = require('qawolf');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { createSignInUrl } = require('qawolf');2console.log(url);3const { createSignInUrl } = require('qawolf');4console.log(url);5const { createSignInUrl } = require('qawolf');6console.log(url);7const { createSignInUrl } = require('qawolf');8console.log(url);9const { createSignInUrl } = require('qawolf');10console.log(url);11const { createSignInUrl } = require('qawolf');12console.log(url);13const { createSignInUrl } = require('qawolf');14console.log(url);15const { createSignInUrl } = require('qawolf');16console.log(url);17const { createSignInUrl } = require('qawolf');18console.log(url);19const { createSignInUrl } = require('qawolf');

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run qawolf automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful