starti.app 1.0.49 → 1.0.51-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ export declare class EventTargetWithType<T extends Record<any, Event>> extends EventTarget {
2
+ addEventListener<K extends keyof T>(type: K, callback: EventListenerOrEventListenerObjectWithType<T[K]>, options?: boolean | AddEventListenerOptions): void;
3
+ removeEventListener<K extends keyof T>(type: K, callback: EventListenerOrEventListenerObjectWithType<T[K]>, options?: boolean | EventListenerOptions): void;
4
+ }
5
+ export declare type EventTargetMethods<T extends EventTargetWithType<any>> = Pick<T, 'addEventListener' | 'removeEventListener'>;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EventTargetWithType = void 0;
4
+ class EventTargetWithType extends EventTarget {
5
+ addEventListener(type, callback, options) {
6
+ super.addEventListener(type, callback, options);
7
+ }
8
+ removeEventListener(type, callback, options) {
9
+ super.removeEventListener(type, callback, options);
10
+ }
11
+ }
12
+ exports.EventTargetWithType = EventTargetWithType;
package/dist/nfc.d.ts CHANGED
@@ -1,15 +1,19 @@
1
+ import { EventTargetMethods, EventTargetWithType } from "./@types/EventHandlerWithTypes";
1
2
  export declare const NFC: INFC;
2
- declare type NFCEvents = "nfcTagScanned";
3
- export interface INFC {
4
- /** Listen for events */
5
- addEventListener(type: NFCEvents, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
6
- /** Removes an event listener */
7
- removeEventListener(type: NFCEvents, callback: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
3
+ declare type NfcTagResultRecived = Array<{
4
+ mimeType: string;
5
+ message: string;
6
+ typeFormat: string;
7
+ }>;
8
+ declare type NFCEvents = {
9
+ nfcTagScanned: CustomEvent<NfcTagResultRecived>;
10
+ };
11
+ export interface INFC extends EventTargetMethods<EventTargetWithType<NFCEvents>> {
8
12
  /** Check if the device supports NFC */
9
13
  isNfcSupported(): Promise<boolean>;
10
14
  /** Start scanning for NFC tags */
11
- startNfcReader(): Promise<StartiappResult>;
15
+ startNfcScanner(): Promise<Response>;
12
16
  /** Stop scanning for NFC tags */
13
- stopNfcReader(): Promise<boolean>;
17
+ stopNfcScanner(): Promise<Response>;
14
18
  }
15
19
  export {};
package/dist/nfc.js CHANGED
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NFC = void 0;
4
+ const EventHandlerWithTypes_1 = require("./@types/EventHandlerWithTypes");
4
5
  const getIntegration_1 = require("./getIntegration");
5
- class NfcClass extends EventTarget {
6
+ class NfcClass extends EventHandlerWithTypes_1.EventTargetWithType {
6
7
  get NFCIntegration() {
7
8
  return (0, getIntegration_1.getIntegration)('NFCIntegration');
8
9
  }
@@ -13,35 +14,35 @@ class NfcClass extends EventTarget {
13
14
  });
14
15
  return promise;
15
16
  }
16
- startNfcReader() {
17
- const promise = new Promise((resolve, reject) => {
17
+ startNfcScanner() {
18
+ const promise = new Promise((resolve) => {
18
19
  this.resolveStartNFCReader = resolve;
19
- this.NFCIntegration.initNFC();
20
+ this.NFCIntegration.startListening();
20
21
  });
21
22
  return promise;
22
23
  }
23
- stopNfcReader() {
24
- const promise = new Promise((resolve, reject) => {
24
+ stopNfcScanner() {
25
+ const promise = new Promise((resolve) => {
25
26
  this.resolveStopNFCReader = resolve;
26
27
  this.NFCIntegration.stopListening();
27
28
  });
28
29
  return promise;
29
30
  }
30
- stopListeningResult(result) {
31
- this.resolveStopNFCReader(result);
32
- this.resolveStopNFCReader = null;
33
- }
34
31
  nfcTagResultRecievedEvent(message) {
35
32
  const event = new CustomEvent('nfcTagScanned', {
36
33
  detail: message,
37
34
  });
38
35
  this.dispatchEvent(event);
39
36
  }
37
+ stopListeningResult(result) {
38
+ this.resolveStopNFCReader(result);
39
+ this.resolveStopNFCReader = null;
40
+ }
40
41
  isNFCSupportedResult(result) {
41
42
  this.resolveNFCSupported(result);
42
43
  this.resolveNFCSupported = null;
43
44
  }
44
- initNFCResult(result) {
45
+ startListeningResult(result) {
45
46
  this.resolveStartNFCReader(result);
46
47
  this.resolveStartNFCReader = null;
47
48
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starti.app",
3
- "version": "1.0.49",
3
+ "version": "1.0.51-alpha.0",
4
4
  "description": "Use this package for easy communication with the starti.app API.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/umd/main.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var s in n)("object"==typeof exports?exports:e)[s]=n[s]}}(self,(()=>(()=>{"use strict";var e={752:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.App=void 0;const s=n(900);class r extends EventTarget{constructor(){super(...arguments),this.startiappIsLoaded=!1}get appIntegration(){return(0,s.getIntegration)("AppIntegration")}setStartiappIsLoaded(){this.startiappIsLoaded=!0}isStartiappLoaded(){return this.startiappIsLoaded}setAppUrl(e){this.appIntegration.setAppUrl(e)}resetAppUrl(){this.appIntegration.resetAppUrl()}openExternalBrowser(e){this.appIntegration.openBrowser(e)}downloadFile(e,t){this.appIntegration.download(e,t)}brandId(){return new Promise(((e,t)=>{this.resolveBrandId=e,this.appIntegration.brandId()}))}requestReview(){this.appIntegration.requestReview()}deviceId(){return new Promise(((e,t)=>{this.resolveDeviceId=e,this.appIntegration.deviceId()}))}version(){return new Promise(((e,t)=>{this.resolveVersion=e,this.appIntegration.version()}))}getInternalDomains(){return new Promise(((e,t)=>{this.resolveGetInternalDomains=e,this.appIntegration.getInternalDomains()}))}addInternalDomain(e){this.appIntegration.addInternalDomain(e)}removeInternalDomain(e){this.appIntegration.removeInternalDomain(e)}showStatusBar(){this.appIntegration.showStatusBar()}hideStatusBar(){this.appIntegration.hideStatusBar()}setSafeAreaBackgroundColor(e){return new Promise(((t,n)=>{this.resolveSetSafeAreaBackgroundColor=t,this.appIntegration.setSafeAreaBackgroundColor(e)}))}disableScreenRotation(){this.appIntegration.disableScreenRotation()}enableScreenRotation(){this.appIntegration.enableScreenRotation()}addExternalDomains(...e){let t=e.map((e=>({pattern:e.source,flags:e.flags})));this.appIntegration.addExternalDomains(t)}removeExternalDomains(...e){let t=e.map((e=>({pattern:e.source,flags:e.flags})));this.appIntegration.removeExternalDomains(t)}getExternalDomains(){return new Promise(((e,t)=>{this.resolveExternalDomains=e,this.appIntegration.getExternalDomains()}))}getExternalDomainsResult(e){this.resolveExternalDomains(e),this.resolveExternalDomains=null}appInForegroundEventRecievedEvent(){this.dispatchEvent(new CustomEvent("appInForeground"))}brandIdResult(e){this.resolveBrandId(e),this.resolveBrandId=null}versionResult(e){this.resolveVersion(e),this.resolveVersion=null}deviceIdResult(e){this.resolveDeviceId(e),this.resolveDeviceId=null}setSafeAreaBackgroundColorResult(e){this.resolveSetSafeAreaBackgroundColor(e),this.resolveSetSafeAreaBackgroundColor=null}navigatingPageEvent(e){this.dispatchEvent(new CustomEvent("navigatingPage",{detail:e}))}getInternalDomainsResult(e){this.resolveGetInternalDomains(e),this.resolveGetInternalDomains=null}}t.App=new r},1:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Biometrics=void 0;const s=n(900);class r extends EventTarget{constructor(){super(...arguments),this.SECURED_CONTENT_KEY="STARTI_APP_BIOMETRIC_CONTENT",this.SECURED_LOGIN_KEY="STARTI_APP_BIOMETRIC_LOGIN_CONTENT",this.defaultScanTitle="Prove you have fingers!",this.defaultScanReason="Can't let you in if you don't."}get biometricIntegration(){return(0,s.getIntegration)("BiometricIntegration")}scan(e=this.defaultScanTitle,t=this.defaultScanReason){return new Promise(((n,s)=>{this.resolveScan=n,this.biometricIntegration.startScanning(e,t)}))}getAuthenticationType(){return new Promise(((e,t)=>{this.resolveAuthType=e,this.biometricIntegration.getAuthenticationType()}))}setSecuredContent(e){this.biometricIntegration.setSecuredContent(this.SECURED_CONTENT_KEY,JSON.stringify(e))}getSecuredContent(e=this.defaultScanTitle,t=this.defaultScanReason){return new Promise(((n,s)=>{this.resolveGetContent=n,this.biometricIntegration.getSecuredContent(this.SECURED_CONTENT_KEY,e,t)}))}hasSecuredContent(){return new Promise(((e,t)=>{this.resolveHasSecureContent=e,this.biometricIntegration.hasSecuredContent(this.SECURED_CONTENT_KEY)}))}removeSecuredContent(){this.biometricIntegration.removeSecuredContent(this.SECURED_CONTENT_KEY)}setUsernameAndPassword(e,t){this.biometricIntegration.setSecuredContent(this.SECURED_LOGIN_KEY,JSON.stringify({username:e,password:t}))}removeUsernameAndPassword(){this.biometricIntegration.removeSecuredContent(this.SECURED_LOGIN_KEY)}hasUsernameAndPassword(){return new Promise(((e,t)=>{this.resolveHasUsernameAndPassword=e,this.biometricIntegration.hasSecuredContent(this.SECURED_LOGIN_KEY)}))}getUsernameAndPassword(e=this.defaultScanTitle,t=this.defaultScanReason){return new Promise(((n,s)=>{this.resolveGetUsernamePassword=n,this.biometricIntegration.getSecuredContent(this.SECURED_LOGIN_KEY,e,t)}))}handleResolveGetUsernamePassword(e){try{const t=JSON.parse(e.result);this.resolveGetUsernamePassword(t)}catch(e){this.resolveGetUsernamePassword(null)}this.resolveGetUsernamePassword=null}hasSecuredContentResult({result:e,key:t}){if(t===this.SECURED_LOGIN_KEY)return this.resolveHasUsernameAndPassword(e),void(this.resolveHasUsernameAndPassword=null);this.resolveHasSecureContent(e),this.resolveHasSecureContent=null}getAuthenticationTypeResult(e){this.resolveAuthType(e),this.resolveAuthType=null}startScanningResult(e){this.resolveScan(e),this.resolveScan=null}getSecuredContentResult(e){if(e.key!==this.SECURED_LOGIN_KEY){try{const t=JSON.parse(e.result);this.resolveGetContent(t)}catch(t){this.resolveGetContent(e.result)}this.resolveGetContent=null}else this.handleResolveGetUsernamePassword(e)}}t.Biometrics=new r},495:function(e,t,n){var s=this&&this.__awaiter||function(e,t,n,s){return new(n||(n=Promise))((function(r,i){function o(e){try{l(s.next(e))}catch(e){i(e)}}function a(e){try{l(s.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}l((s=s.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ClientUser=void 0;const r=n(913),i=n(607);t.ClientUser=new class extends EventTarget{registerId(e){return s(this,void 0,void 0,(function*(){const t=yield i.default.App.brandId(),n=yield i.default.App.deviceId(),s=yield i.default.PushNotification.getToken();if(!s||0===s.length)throw console.warn("Failed to register logged in client user",e,"No FCM token"),new Error(`Failed to register logged in client user ${e}: No FCM token`);const o={brandId:t,clientUserId:e,deviceId:n,fcmToken:s},a=yield fetch(r.baseUrl+"/ClientUser-registerId",{body:JSON.stringify(o),headers:{"Content-Type":"application/json"},method:"POST"});if(!a.ok)throw console.warn("Failed to register logged in client user",e,o),new Error(`Failed to register logged in client user ${e}: Firebase returned statuscode ${a.status}`)}))}}},913:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.styleTagId=t.baseUrl=void 0,t.baseUrl="https://europe-west3-startiapp-admin-1fac2.cloudfunctions.net",t.styleTagId="startiapp-styling"},955:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Device=void 0;const s=n(900);class r extends EventTarget{get deviceIntegration(){return(0,s.getIntegration)("DeviceIntegration")}startAccelerometer(){this.deviceIntegration.startAccelerometer()}stopAccelerometer(){this.deviceIntegration.stopAccelerometer()}isAccelerometerStarted(){return new Promise(((e,t)=>{this.deviceIntegration.isAccelerometerStarted(),this.resolveIsAccelerometerStarted=e}))}isAccelerometerStartedResult(e){this.resolveIsAccelerometerStarted(e),this.resolveIsAccelerometerStarted=null}onShakeEvent(){this.dispatchEvent(new CustomEvent("shake"))}}t.Device=new r},900:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getIntegration=void 0;let n={};t.getIntegration=function(e){if(n[e])return n[e];let t=window[e],s=0;for(;!t&&s<5;)t=window.parent[e],s++;if(!t)throw new Error(`Could not find integration ${e}`);return n[e]=t,t}},607:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});const s=n(752),r=n(1),i=n(495),o=n(955),a=n(900),l=n(983),c=n(681),d=n(952),u=n(716),p=window;p.appIntegrationsAreReady=()=>{s.App.setStartiappIsLoaded(),v.dispatchEvent(new CustomEvent("ready"))},p.startiappDevice=o.Device,p.startiappApp=s.App,p.startiappUser=i.ClientUser,p.startiappQrScanner=d.QrScanner,p.startiappPushNotification=c.PushNotification,p.startiappNFC=l.NFC,p.startiappBiometric=r.Biometrics,p.appErrorEvent=e=>{v.dispatchEvent(new CustomEvent("error",{detail:e}))};class h extends EventTarget{constructor(){super(...arguments),this.App=s.App,this.Device=o.Device,this.Biometrics=r.Biometrics,this.User=i.ClientUser,this.NfcScanner=l.NFC,this.PushNotification=c.PushNotification,this.QrScanner=d.QrScanner}get appIntegration(){return(0,a.getIntegration)("AppIntegration")}initialize(e){u.AppUI.setOptions(e),this.appIntegration.webAppIsReady()}isRunningInApp(){return navigator.userAgent.toLowerCase().indexOf("starti.app")>-1}addEventListener(e,t,n){super.addEventListener(e,t,n)}removeEventListener(e,t,n){super.removeEventListener(e,t,n)}}const v=new h;if(v.isRunningInApp())if(document.body)document.body.setAttribute("startiapp","true");else{const e=new MutationObserver((()=>{document.body&&(document.body.setAttribute("startiapp","true"),e.disconnect())}));e.observe(document.documentElement,{childList:!0})}t.default=v,p.startiapp=v},983:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NFC=void 0;const s=n(900);class r extends EventTarget{get NFCIntegration(){return(0,s.getIntegration)("NFCIntegration")}isNfcSupported(){return new Promise(((e,t)=>{this.resolveNFCSupported=e,this.NFCIntegration.isNFCSupported()}))}startNfcReader(){return new Promise(((e,t)=>{this.resolveStartNFCReader=e,this.NFCIntegration.initNFC()}))}stopNfcReader(){return new Promise(((e,t)=>{this.resolveStopNFCReader=e,this.NFCIntegration.stopListening()}))}stopListeningResult(e){this.resolveStopNFCReader(e),this.resolveStopNFCReader=null}nfcTagResultRecievedEvent(e){const t=new CustomEvent("nfcTagScanned",{detail:e});this.dispatchEvent(t)}isNFCSupportedResult(e){this.resolveNFCSupported(e),this.resolveNFCSupported=null}initNFCResult(e){this.resolveStartNFCReader(e),this.resolveStartNFCReader=null}}t.NFC=new r},681:function(e,t,n){var s=this&&this.__awaiter||function(e,t,n,s){return new(n||(n=Promise))((function(r,i){function o(e){try{l(s.next(e))}catch(e){i(e)}}function a(e){try{l(s.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}l((s=s.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.PushNotification=void 0;const r=n(913),i=n(900),o=n(607);class a extends EventTarget{get pushNotificationIntegration(){return(0,i.getIntegration)("PushNotificationIntegration")}requestAccess(){return s(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.resolveRequestAccess=e,this.pushNotificationIntegration.requestAccess()}))}))}getToken(){return new Promise(((e,t)=>{this.resolveFCMToken=e,this.pushNotificationIntegration.getFCMToken()}))}subscribeToTopics(e){return s(this,void 0,void 0,(function*(){this.pushNotificationIntegration.firebasePushNotificationSubscribeToTopics(e);const t=yield this.getToken(),n=yield o.default.App.brandId(),s=yield o.default.App.deviceId(),i=[];e.forEach((e=>{const o={brand:n,topic:e,token:t,deviceId:s},a=fetch(r.baseUrl+"/PushNotification-subscribeToTopic",{body:JSON.stringify(o)});i.push(a)})),(yield Promise.all(i)).forEach(((t,n)=>{t.ok||console.warn("Failed to sign up to topic",n,e[n])}))}))}unsubscribeFromTopics(e){return s(this,void 0,void 0,(function*(){this.pushNotificationIntegration.firebasePushNotificationTopicsUnsubscribe(e);const t=yield this.getToken(),n=yield o.default.App.brandId(),s=yield o.default.App.deviceId(),i=[];e.forEach((e=>{const o={brand:n,topic:e,token:t,deviceId:s},a=fetch(r.baseUrl+"/PushNotification-unSubscribeFromTopic",{body:JSON.stringify(o)});i.push(a)})),(yield Promise.all(i)).forEach(((t,n)=>{t.ok||console.warn("Failed to unsubscribe from topic",n,e[n])}))}))}requestAccessResult(e){this.resolveRequestAccess(e),this.resolveRequestAccess=null}getFCMTokenResult(e){this.resolveFCMToken(e),this.resolveFCMToken=null}tokenReceivedEvent(e){this.dispatchEvent(new CustomEvent("tokenRefreshed",{detail:e}))}notificationReceivedEvent(e){this.dispatchEvent(new CustomEvent("notificationReceived",{detail:e}))}firebasePushNotificationTopicsUnsubscribeResult(e){}firebasePushNotificationSubscribeToTopicsResult(e){}}t.PushNotification=new a},952:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.QrScanner=void 0;const s=n(900);class r extends EventTarget{get qrScannerIntegration(){return(0,s.getIntegration)("QrScannerIntegration")}scan(){return new Promise(((e,t)=>{this.resolveScan=e,this.qrScannerIntegration.startQrCodeScanner()}))}isCameraAccessGranted(){return new Promise(((e,t)=>{this.resolveCameraAccessGranted=e,this.qrScannerIntegration.isCameraAccessGranted()}))}requestCameraAccess(){return new Promise(((e,t)=>{this.resolveRequestCameraAccess=e,this.qrScannerIntegration.requestCameraAccess()}))}requestCameraAccessResult(e){this.resolveRequestCameraAccess(e),this.resolveRequestCameraAccess=null}startQrCodeScannerResult(e){this.resolveScan(e),this.resolveScan=null}isCameraAccessGrantedResult(e){this.resolveCameraAccessGranted(e),this.resolveCameraAccessGranted=null}}t.QrScanner=new r},716:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AppUI=void 0;const s=n(913);t.AppUI=new class{constructor(){this.options={allowDrag:!1,allowHighligt:!1,allowZoom:!1,allowScrollBounce:!1}}setOptions(e){this.options=Object.assign(this.options,e),null!=document.querySelector('meta[name="viewport"]')&&void 0===this.initialViewportMetaContent&&(this.initialViewportMetaContent=document.querySelector('meta[name="viewport"]').getAttribute("content")),this.initialViewportMetaContent.includes("viewport-fit=cover")||(this.initialViewportMetaContent+=", viewport-fit=cover"),this.updateUI()}getOptions(){return this.options}updateUI(){this.styleString="";const e=document.getElementById(s.styleTagId);e&&e.remove();const t=document.getElementsByTagName("img"),n=document.getElementsByTagName("a");this.options.allowDrag?[...t,...n].forEach((e=>{e.removeAttribute("draggable")})):[...t,...n].forEach((e=>{e.setAttribute("draggable","false")}));let r=document.querySelector("meta[name=viewport]");this.options.allowHighligt||(this.styleString+="\n body {\n -webkit-user-select: none; \n -khtml-user-select: none; \n -moz-user-select: none; \n -o-user-select: none; \n user-select: none;\n }\n "),this.options.allowScrollBounce||(this.styleString+="\n html {\n overscroll-behavior: none;\n }\n "),this.options.allowZoom?r.setAttribute("content",this.initialViewportMetaContent):(this.styleString+="\n body {\n touch-action: pan-x pan-y;\n }\n ",r.setAttribute("content","width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, viewport-fit=cover"));const i=document.createElement("style");i.textContent=this.styleString,i.setAttribute("id",s.styleTagId),document.body.appendChild(i)}}}},t={};return function n(s){var r=t[s];if(void 0!==r)return r.exports;var i=t[s]={exports:{}};return e[s].call(i.exports,i,i.exports,n),i.exports}(607)})()));
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var s in n)("object"==typeof exports?exports:e)[s]=n[s]}}(self,(()=>(()=>{"use strict";var e={715:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EventTargetWithType=void 0;class n extends EventTarget{addEventListener(e,t,n){super.addEventListener(e,t,n)}removeEventListener(e,t,n){super.removeEventListener(e,t,n)}}t.EventTargetWithType=n},752:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.App=void 0;const s=n(900);class r extends EventTarget{constructor(){super(...arguments),this.startiappIsLoaded=!1}get appIntegration(){return(0,s.getIntegration)("AppIntegration")}setStartiappIsLoaded(){this.startiappIsLoaded=!0}isStartiappLoaded(){return this.startiappIsLoaded}setAppUrl(e){this.appIntegration.setAppUrl(e)}resetAppUrl(){this.appIntegration.resetAppUrl()}openExternalBrowser(e){this.appIntegration.openBrowser(e)}downloadFile(e,t){this.appIntegration.download(e,t)}brandId(){return new Promise(((e,t)=>{this.resolveBrandId=e,this.appIntegration.brandId()}))}requestReview(){this.appIntegration.requestReview()}deviceId(){return new Promise(((e,t)=>{this.resolveDeviceId=e,this.appIntegration.deviceId()}))}version(){return new Promise(((e,t)=>{this.resolveVersion=e,this.appIntegration.version()}))}getInternalDomains(){return new Promise(((e,t)=>{this.resolveGetInternalDomains=e,this.appIntegration.getInternalDomains()}))}addInternalDomain(e){this.appIntegration.addInternalDomain(e)}removeInternalDomain(e){this.appIntegration.removeInternalDomain(e)}showStatusBar(){this.appIntegration.showStatusBar()}hideStatusBar(){this.appIntegration.hideStatusBar()}setSafeAreaBackgroundColor(e){return new Promise(((t,n)=>{this.resolveSetSafeAreaBackgroundColor=t,this.appIntegration.setSafeAreaBackgroundColor(e)}))}disableScreenRotation(){this.appIntegration.disableScreenRotation()}enableScreenRotation(){this.appIntegration.enableScreenRotation()}addExternalDomains(...e){let t=e.map((e=>({pattern:e.source,flags:e.flags})));this.appIntegration.addExternalDomains(t)}removeExternalDomains(...e){let t=e.map((e=>({pattern:e.source,flags:e.flags})));this.appIntegration.removeExternalDomains(t)}getExternalDomains(){return new Promise(((e,t)=>{this.resolveExternalDomains=e,this.appIntegration.getExternalDomains()}))}getExternalDomainsResult(e){this.resolveExternalDomains(e),this.resolveExternalDomains=null}appInForegroundEventRecievedEvent(){this.dispatchEvent(new CustomEvent("appInForeground"))}brandIdResult(e){this.resolveBrandId(e),this.resolveBrandId=null}versionResult(e){this.resolveVersion(e),this.resolveVersion=null}deviceIdResult(e){this.resolveDeviceId(e),this.resolveDeviceId=null}setSafeAreaBackgroundColorResult(e){this.resolveSetSafeAreaBackgroundColor(e),this.resolveSetSafeAreaBackgroundColor=null}navigatingPageEvent(e){this.dispatchEvent(new CustomEvent("navigatingPage",{detail:e}))}getInternalDomainsResult(e){this.resolveGetInternalDomains(e),this.resolveGetInternalDomains=null}}t.App=new r},1:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Biometrics=void 0;const s=n(900);class r extends EventTarget{constructor(){super(...arguments),this.SECURED_CONTENT_KEY="STARTI_APP_BIOMETRIC_CONTENT",this.SECURED_LOGIN_KEY="STARTI_APP_BIOMETRIC_LOGIN_CONTENT",this.defaultScanTitle="Prove you have fingers!",this.defaultScanReason="Can't let you in if you don't."}get biometricIntegration(){return(0,s.getIntegration)("BiometricIntegration")}scan(e=this.defaultScanTitle,t=this.defaultScanReason){return new Promise(((n,s)=>{this.resolveScan=n,this.biometricIntegration.startScanning(e,t)}))}getAuthenticationType(){return new Promise(((e,t)=>{this.resolveAuthType=e,this.biometricIntegration.getAuthenticationType()}))}setSecuredContent(e){this.biometricIntegration.setSecuredContent(this.SECURED_CONTENT_KEY,JSON.stringify(e))}getSecuredContent(e=this.defaultScanTitle,t=this.defaultScanReason){return new Promise(((n,s)=>{this.resolveGetContent=n,this.biometricIntegration.getSecuredContent(this.SECURED_CONTENT_KEY,e,t)}))}hasSecuredContent(){return new Promise(((e,t)=>{this.resolveHasSecureContent=e,this.biometricIntegration.hasSecuredContent(this.SECURED_CONTENT_KEY)}))}removeSecuredContent(){this.biometricIntegration.removeSecuredContent(this.SECURED_CONTENT_KEY)}setUsernameAndPassword(e,t){this.biometricIntegration.setSecuredContent(this.SECURED_LOGIN_KEY,JSON.stringify({username:e,password:t}))}removeUsernameAndPassword(){this.biometricIntegration.removeSecuredContent(this.SECURED_LOGIN_KEY)}hasUsernameAndPassword(){return new Promise(((e,t)=>{this.resolveHasUsernameAndPassword=e,this.biometricIntegration.hasSecuredContent(this.SECURED_LOGIN_KEY)}))}getUsernameAndPassword(e=this.defaultScanTitle,t=this.defaultScanReason){return new Promise(((n,s)=>{this.resolveGetUsernamePassword=n,this.biometricIntegration.getSecuredContent(this.SECURED_LOGIN_KEY,e,t)}))}handleResolveGetUsernamePassword(e){try{const t=JSON.parse(e.result);this.resolveGetUsernamePassword(t)}catch(e){this.resolveGetUsernamePassword(null)}this.resolveGetUsernamePassword=null}hasSecuredContentResult({result:e,key:t}){if(t===this.SECURED_LOGIN_KEY)return this.resolveHasUsernameAndPassword(e),void(this.resolveHasUsernameAndPassword=null);this.resolveHasSecureContent(e),this.resolveHasSecureContent=null}getAuthenticationTypeResult(e){this.resolveAuthType(e),this.resolveAuthType=null}startScanningResult(e){this.resolveScan(e),this.resolveScan=null}getSecuredContentResult(e){if(e.key!==this.SECURED_LOGIN_KEY){try{const t=JSON.parse(e.result);this.resolveGetContent(t)}catch(t){this.resolveGetContent(e.result)}this.resolveGetContent=null}else this.handleResolveGetUsernamePassword(e)}}t.Biometrics=new r},495:function(e,t,n){var s=this&&this.__awaiter||function(e,t,n,s){return new(n||(n=Promise))((function(r,i){function o(e){try{l(s.next(e))}catch(e){i(e)}}function a(e){try{l(s.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}l((s=s.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ClientUser=void 0;const r=n(913),i=n(607);t.ClientUser=new class extends EventTarget{registerId(e){return s(this,void 0,void 0,(function*(){const t=yield i.default.App.brandId(),n=yield i.default.App.deviceId(),s=yield i.default.PushNotification.getToken();if(!s||0===s.length)throw console.warn("Failed to register logged in client user",e,"No FCM token"),new Error(`Failed to register logged in client user ${e}: No FCM token`);const o={brandId:t,clientUserId:e,deviceId:n,fcmToken:s},a=yield fetch(r.baseUrl+"/ClientUser-registerId",{body:JSON.stringify(o),headers:{"Content-Type":"application/json"},method:"POST"});if(!a.ok)throw console.warn("Failed to register logged in client user",e,o),new Error(`Failed to register logged in client user ${e}: Firebase returned statuscode ${a.status}`)}))}}},913:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.styleTagId=t.baseUrl=void 0,t.baseUrl="https://europe-west3-startiapp-admin-1fac2.cloudfunctions.net",t.styleTagId="startiapp-styling"},955:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Device=void 0;const s=n(900);class r extends EventTarget{get deviceIntegration(){return(0,s.getIntegration)("DeviceIntegration")}startAccelerometer(){this.deviceIntegration.startAccelerometer()}stopAccelerometer(){this.deviceIntegration.stopAccelerometer()}isAccelerometerStarted(){return new Promise(((e,t)=>{this.deviceIntegration.isAccelerometerStarted(),this.resolveIsAccelerometerStarted=e}))}isAccelerometerStartedResult(e){this.resolveIsAccelerometerStarted(e),this.resolveIsAccelerometerStarted=null}onShakeEvent(){this.dispatchEvent(new CustomEvent("shake"))}}t.Device=new r},900:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getIntegration=void 0;let n={};t.getIntegration=function(e){if(n[e])return n[e];let t=window[e],s=0;for(;!t&&s<5;)t=window.parent[e],s++;if(!t)throw new Error(`Could not find integration ${e}`);return n[e]=t,t}},607:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});const s=n(752),r=n(1),i=n(495),o=n(955),a=n(900),l=n(983),c=n(681),d=n(952),u=n(716),p=window;p.appIntegrationsAreReady=()=>{s.App.setStartiappIsLoaded(),v.dispatchEvent(new CustomEvent("ready"))},p.startiappDevice=o.Device,p.startiappApp=s.App,p.startiappUser=i.ClientUser,p.startiappQrScanner=d.QrScanner,p.startiappPushNotification=c.PushNotification,p.startiappNFC=l.NFC,p.startiappBiometric=r.Biometrics,p.appErrorEvent=e=>{v.dispatchEvent(new CustomEvent("error",{detail:e}))};class h extends EventTarget{constructor(){super(...arguments),this.App=s.App,this.Device=o.Device,this.Biometrics=r.Biometrics,this.User=i.ClientUser,this.NfcScanner=l.NFC,this.PushNotification=c.PushNotification,this.QrScanner=d.QrScanner}get appIntegration(){return(0,a.getIntegration)("AppIntegration")}initialize(e){u.AppUI.setOptions(e),this.appIntegration.webAppIsReady()}isRunningInApp(){return navigator.userAgent.toLowerCase().indexOf("starti.app")>-1}addEventListener(e,t,n){super.addEventListener(e,t,n)}removeEventListener(e,t,n){super.removeEventListener(e,t,n)}}const v=new h;if(v.isRunningInApp())if(document.body)document.body.setAttribute("startiapp","true");else{const e=new MutationObserver((()=>{document.body&&(document.body.setAttribute("startiapp","true"),e.disconnect())}));e.observe(document.documentElement,{childList:!0})}t.default=v,p.startiapp=v},983:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NFC=void 0;const s=n(715),r=n(900);class i extends s.EventTargetWithType{get NFCIntegration(){return(0,r.getIntegration)("NFCIntegration")}isNfcSupported(){return new Promise(((e,t)=>{this.resolveNFCSupported=e,this.NFCIntegration.isNFCSupported()}))}startNfcScanner(){return new Promise((e=>{this.resolveStartNFCReader=e,this.NFCIntegration.startListening()}))}stopNfcScanner(){return new Promise((e=>{this.resolveStopNFCReader=e,this.NFCIntegration.stopListening()}))}nfcTagResultRecievedEvent(e){const t=new CustomEvent("nfcTagScanned",{detail:e});this.dispatchEvent(t)}stopListeningResult(e){this.resolveStopNFCReader(e),this.resolveStopNFCReader=null}isNFCSupportedResult(e){this.resolveNFCSupported(e),this.resolveNFCSupported=null}startListeningResult(e){this.resolveStartNFCReader(e),this.resolveStartNFCReader=null}}t.NFC=new i},681:function(e,t,n){var s=this&&this.__awaiter||function(e,t,n,s){return new(n||(n=Promise))((function(r,i){function o(e){try{l(s.next(e))}catch(e){i(e)}}function a(e){try{l(s.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}l((s=s.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.PushNotification=void 0;const r=n(913),i=n(900),o=n(607);class a extends EventTarget{get pushNotificationIntegration(){return(0,i.getIntegration)("PushNotificationIntegration")}requestAccess(){return s(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.resolveRequestAccess=e,this.pushNotificationIntegration.requestAccess()}))}))}getToken(){return new Promise(((e,t)=>{this.resolveFCMToken=e,this.pushNotificationIntegration.getFCMToken()}))}subscribeToTopics(e){return s(this,void 0,void 0,(function*(){this.pushNotificationIntegration.firebasePushNotificationSubscribeToTopics(e);const t=yield this.getToken(),n=yield o.default.App.brandId(),s=yield o.default.App.deviceId(),i=[];e.forEach((e=>{const o={brand:n,topic:e,token:t,deviceId:s},a=fetch(r.baseUrl+"/PushNotification-subscribeToTopic",{body:JSON.stringify(o)});i.push(a)})),(yield Promise.all(i)).forEach(((t,n)=>{t.ok||console.warn("Failed to sign up to topic",n,e[n])}))}))}unsubscribeFromTopics(e){return s(this,void 0,void 0,(function*(){this.pushNotificationIntegration.firebasePushNotificationTopicsUnsubscribe(e);const t=yield this.getToken(),n=yield o.default.App.brandId(),s=yield o.default.App.deviceId(),i=[];e.forEach((e=>{const o={brand:n,topic:e,token:t,deviceId:s},a=fetch(r.baseUrl+"/PushNotification-unSubscribeFromTopic",{body:JSON.stringify(o)});i.push(a)})),(yield Promise.all(i)).forEach(((t,n)=>{t.ok||console.warn("Failed to unsubscribe from topic",n,e[n])}))}))}requestAccessResult(e){this.resolveRequestAccess(e),this.resolveRequestAccess=null}getFCMTokenResult(e){this.resolveFCMToken(e),this.resolveFCMToken=null}tokenReceivedEvent(e){this.dispatchEvent(new CustomEvent("tokenRefreshed",{detail:e}))}notificationReceivedEvent(e){this.dispatchEvent(new CustomEvent("notificationReceived",{detail:e}))}firebasePushNotificationTopicsUnsubscribeResult(e){}firebasePushNotificationSubscribeToTopicsResult(e){}}t.PushNotification=new a},952:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.QrScanner=void 0;const s=n(900);class r extends EventTarget{get qrScannerIntegration(){return(0,s.getIntegration)("QrScannerIntegration")}scan(){return new Promise(((e,t)=>{this.resolveScan=e,this.qrScannerIntegration.startQrCodeScanner()}))}isCameraAccessGranted(){return new Promise(((e,t)=>{this.resolveCameraAccessGranted=e,this.qrScannerIntegration.isCameraAccessGranted()}))}requestCameraAccess(){return new Promise(((e,t)=>{this.resolveRequestCameraAccess=e,this.qrScannerIntegration.requestCameraAccess()}))}requestCameraAccessResult(e){this.resolveRequestCameraAccess(e),this.resolveRequestCameraAccess=null}startQrCodeScannerResult(e){this.resolveScan(e),this.resolveScan=null}isCameraAccessGrantedResult(e){this.resolveCameraAccessGranted(e),this.resolveCameraAccessGranted=null}}t.QrScanner=new r},716:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AppUI=void 0;const s=n(913);t.AppUI=new class{constructor(){this.options={allowDrag:!1,allowHighligt:!1,allowZoom:!1,allowScrollBounce:!1}}setOptions(e){this.options=Object.assign(this.options,e),null!=document.querySelector('meta[name="viewport"]')&&void 0===this.initialViewportMetaContent&&(this.initialViewportMetaContent=document.querySelector('meta[name="viewport"]').getAttribute("content")),this.initialViewportMetaContent.includes("viewport-fit=cover")||(this.initialViewportMetaContent+=", viewport-fit=cover"),this.updateUI()}getOptions(){return this.options}updateUI(){this.styleString="";const e=document.getElementById(s.styleTagId);e&&e.remove();const t=document.getElementsByTagName("img"),n=document.getElementsByTagName("a");this.options.allowDrag?[...t,...n].forEach((e=>{e.removeAttribute("draggable")})):[...t,...n].forEach((e=>{e.setAttribute("draggable","false")}));let r=document.querySelector("meta[name=viewport]");this.options.allowHighligt||(this.styleString+="\n body {\n -webkit-user-select: none; \n -khtml-user-select: none; \n -moz-user-select: none; \n -o-user-select: none; \n user-select: none;\n }\n "),this.options.allowScrollBounce||(this.styleString+="\n html {\n overscroll-behavior: none;\n }\n "),this.options.allowZoom?r.setAttribute("content",this.initialViewportMetaContent):(this.styleString+="\n body {\n touch-action: pan-x pan-y;\n }\n ",r.setAttribute("content","width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, viewport-fit=cover"));const i=document.createElement("style");i.textContent=this.styleString,i.setAttribute("id",s.styleTagId),document.body.appendChild(i)}}}},t={};return function n(s){var r=t[s];if(void 0!==r)return r.exports;var i=t[s]={exports:{}};return e[s].call(i.exports,i,i.exports,n),i.exports}(607)})()));