starti.app 1.0.44 → 1.0.46
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.
- package/dist/app.d.ts +6 -0
- package/dist/app.js +23 -0
- package/dist/biometrics.js +2 -2
- package/dist/index.js +2 -4
- package/package.json +1 -1
- package/umd/main.js +1 -1
package/dist/app.d.ts
CHANGED
|
@@ -39,5 +39,11 @@ export interface IApp {
|
|
|
39
39
|
addInternalDomain(domain: string): void;
|
|
40
40
|
/** Remove internal domain */
|
|
41
41
|
removeInternalDomain(domain: string): void;
|
|
42
|
+
/** Add external domain(s) */
|
|
43
|
+
addExternalDomains(...domains: RegExp[]): void;
|
|
44
|
+
/** Remove external domain(s) */
|
|
45
|
+
removeExternalDomains(...domains: RegExp[]): void;
|
|
46
|
+
/** Get external domains */
|
|
47
|
+
getExternalDomains(): Promise<ExternalDomain[]>;
|
|
42
48
|
}
|
|
43
49
|
export {};
|
package/dist/app.js
CHANGED
|
@@ -75,6 +75,29 @@ class AppClass extends EventTarget {
|
|
|
75
75
|
enableScreenRotation() {
|
|
76
76
|
AppIntegration.enableScreenRotation();
|
|
77
77
|
}
|
|
78
|
+
addExternalDomains(...domains) {
|
|
79
|
+
let domainObjects = domains.map(m => ({
|
|
80
|
+
pattern: m.source,
|
|
81
|
+
flags: m.flags
|
|
82
|
+
}));
|
|
83
|
+
AppIntegration.addExternalDomains(domainObjects);
|
|
84
|
+
}
|
|
85
|
+
removeExternalDomains(...domains) {
|
|
86
|
+
let domainObjects = domains.map(m => ({
|
|
87
|
+
pattern: m.source,
|
|
88
|
+
flags: m.flags
|
|
89
|
+
}));
|
|
90
|
+
AppIntegration.removeExternalDomains(domainObjects);
|
|
91
|
+
}
|
|
92
|
+
getExternalDomains() {
|
|
93
|
+
return new Promise((resolve, reject) => {
|
|
94
|
+
this.resolveExternalDomains = resolve;
|
|
95
|
+
AppIntegration.getExternalDomains();
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
getExternalDomainsResult(result) {
|
|
99
|
+
this.resolveExternalDomains(result);
|
|
100
|
+
}
|
|
78
101
|
appInForegroundEventRecievedEvent() {
|
|
79
102
|
this.dispatchEvent(new CustomEvent('appInForeground'));
|
|
80
103
|
}
|
package/dist/biometrics.js
CHANGED
|
@@ -68,7 +68,7 @@ class BiometricsClass extends EventTarget {
|
|
|
68
68
|
* */
|
|
69
69
|
handleResolveGetUsernamePassword(result) {
|
|
70
70
|
try {
|
|
71
|
-
const parsed = JSON.parse(result.
|
|
71
|
+
const parsed = JSON.parse(result.result);
|
|
72
72
|
this.resolveGetUsernamePassword(parsed);
|
|
73
73
|
}
|
|
74
74
|
catch (error) {
|
|
@@ -101,7 +101,7 @@ class BiometricsClass extends EventTarget {
|
|
|
101
101
|
this.handleResolveGetUsernamePassword(parsed);
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
104
|
-
this.resolveGetContent(parsed.
|
|
104
|
+
this.resolveGetContent(parsed.result);
|
|
105
105
|
}
|
|
106
106
|
catch (error) {
|
|
107
107
|
this.resolveGetContent(null);
|
package/dist/index.js
CHANGED
|
@@ -45,10 +45,8 @@ class StartiappClass extends EventTarget {
|
|
|
45
45
|
initialize(options) {
|
|
46
46
|
if (typeof AppIntegration === 'undefined')
|
|
47
47
|
throw new Error('The starti.app API integration is not available.');
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
AppIntegration.webAppIsReady();
|
|
51
|
-
}
|
|
48
|
+
ui_service_1.AppUI.setOptions(options);
|
|
49
|
+
AppIntegration.webAppIsReady();
|
|
52
50
|
}
|
|
53
51
|
/** Call this method to check if the app is running in the starti.app app. */
|
|
54
52
|
isRunningInApp() {
|
package/package.json
CHANGED
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)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.App=void 0;class n extends EventTarget{constructor(){super(...arguments),this.startiappIsLoaded=!1}setStartiappIsLoaded(){this.startiappIsLoaded=!0}isStartiappLoaded(){return this.startiappIsLoaded}setAppUrl(e){AppIntegration.setAppUrl(e)}resetAppUrl(){AppIntegration.resetAppUrl()}openExternalBrowser(e){AppIntegration.openBrowser(e)}downloadFile(e,t){AppIntegration.download(e,t)}brandId(){return new Promise(((e,t)=>{this.resolveBrandId=e,AppIntegration.brandId()}))}requestReview(){AppIntegration.requestReview()}deviceId(){return new Promise(((e,t)=>{this.resolveDeviceId=e,AppIntegration.deviceId()}))}version(){return new Promise(((e,t)=>{this.resolveVersion=e,AppIntegration.version()}))}getInternalDomains(){return new Promise(((e,t)=>{this.resolveGetInternalDomains=e,AppIntegration.getInternalDomains()}))}addInternalDomain(e){AppIntegration.addInternalDomain(e)}removeInternalDomain(e){AppIntegration.removeInternalDomain(e)}showStatusBar(){AppIntegration.showStatusBar()}hideStatusBar(){AppIntegration.hideStatusBar()}setSafeAreaBackgroundColor(e){return new Promise(((t,n)=>{this.resolveSetSafeAreaBackgroundColor=t,AppIntegration.setSafeAreaBackgroundColor(e)}))}disableScreenRotation(){AppIntegration.disableScreenRotation()}enableScreenRotation(){AppIntegration.enableScreenRotation()}appInForegroundEventRecievedEvent(){this.dispatchEvent(new CustomEvent("appInForeground"))}brandIdResult(e){this.resolveBrandId(e)}versionResult(e){this.resolveVersion(e)}deviceIdResult(e){this.resolveDeviceId(e)}setSafeAreaBackgroundColorResult(e){this.resolveSetSafeAreaBackgroundColor(e)}navigatingPageEvent(e){this.dispatchEvent(new CustomEvent("navigatingPage",{detail:e}))}getInternalDomainsResult(e){this.resolveGetInternalDomains(e)}}t.App=new n},1:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Biometrics=void 0;class n 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."}scan(e=this.defaultScanTitle,t=this.defaultScanReason){return new Promise(((n,s)=>{this.resolveScan=n,BiometricIntegration.startScanning(e,t)}))}getAuthenticationType(){return new Promise(((e,t)=>{this.resolveAuthType=e,BiometricIntegration.getAuthenticationType()}))}setSecuredContent(e){BiometricIntegration.setSecuredContent(this.SECURED_CONTENT_KEY,JSON.stringify(e))}getSecuredContent(e=this.defaultScanTitle,t=this.defaultScanReason){return new Promise(((n,s)=>{this.resolveGetContent=n,BiometricIntegration.getSecuredContent(this.SECURED_CONTENT_KEY,e,t)}))}hasSecuredContent(){return new Promise(((e,t)=>{this.resolveHasSecureContent=e,BiometricIntegration.hasSecuredContent(this.SECURED_CONTENT_KEY)}))}removeSecuredContent(){BiometricIntegration.removeSecuredContent(this.SECURED_CONTENT_KEY)}setUsernameAndPassword(e,t){BiometricIntegration.setSecuredContent(this.SECURED_LOGIN_KEY,JSON.stringify({username:e,password:t}))}removeUsernameAndPassword(){BiometricIntegration.removeSecuredContent(this.SECURED_LOGIN_KEY)}hasUsernameAndPassword(){return new Promise(((e,t)=>{this.resolveHasUsernameAndPassword=e,BiometricIntegration.hasSecuredContent(this.SECURED_LOGIN_KEY)}))}getUsernameAndPassword(e=this.defaultScanTitle,t=this.defaultScanReason){return new Promise(((n,s)=>{this.resolveGetUsernamePassword=n,BiometricIntegration.getSecuredContent(this.SECURED_LOGIN_KEY,e,t)}))}handleResolveGetUsernamePassword(e){try{const t=JSON.parse(e.content);this.resolveGetUsernamePassword(t)}catch(e){this.resolveGetUsernamePassword(null)}}hasSecuredContentResult(e){try{const t=JSON.parse(e);if(t.key===this.SECURED_LOGIN_KEY)return void this.resolveHasUsernameAndPassword(t.result);this.resolveHasSecureContent(t.result)}catch(e){this.resolveHasSecureContent(!1)}}getAuthenticationTypeResult(e){this.resolveAuthType(e)}startScanningResult(e){this.resolveScan(e)}getSecuredContentResult(e){try{const t=JSON.parse(e);if(t.key===this.SECURED_LOGIN_KEY)return void this.handleResolveGetUsernamePassword(t);this.resolveGetContent(t.content)}catch(e){this.resolveGetContent(null)}}}t.Biometrics=new n},495:function(e,t,n){var s=this&&this.__awaiter||function(e,t,n,s){return new(n||(n=Promise))((function(i,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ClientUser=void 0;const i=n(913),r=n(607);t.ClientUser=new class extends EventTarget{registerId(e){return s(this,void 0,void 0,(function*(){const t=yield r.default.App.brandId(),n=yield r.default.App.deviceId(),s=yield r.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(i.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)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Device=void 0;class n extends EventTarget{startAccelerometer(){DeviceIntegration.startAccelerometer()}stopAccelerometer(){DeviceIntegration.stopAccelerometer()}onShakeEvent(){this.dispatchEvent(new CustomEvent("shake"))}}t.Device=new n},607:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});const s=n(752),i=n(1),r=n(495),o=n(955),a=n(983),c=n(681),d=n(952),l=n(716),u=window;u.appIntegrationsAreReady=()=>{s.App.setStartiappIsLoaded(),h.dispatchEvent(new CustomEvent("ready"))},u.startiappDevice=o.Device,u.startiappApp=s.App,u.startiappUser=r.ClientUser,u.startiappQrScanner=d.QrScanner,u.startiappPushNotification=c.PushNotification,u.startiappNFC=a.NFC,u.startiappBiometric=i.Biometrics,u.appErrorEvent=e=>{h.dispatchEvent(new CustomEvent("error",{detail:e}))};class p extends EventTarget{constructor(){super(...arguments),this.App=s.App,this.Device=o.Device,this.Biometrics=i.Biometrics,this.User=r.ClientUser,this.Nfc=a.NFC,this.PushNotification=c.PushNotification,this.QrScanner=d.QrScanner}initialize(e){if("undefined"==typeof AppIntegration)throw new Error("The starti.app API integration is not available.");s.App.isStartiappLoaded()&&(l.AppUI.setOptions(e),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 h=new p;if(h.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=h,u.startiapp=h},983:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NFC=void 0;class n extends EventTarget{isNFCSupported(){return new Promise(((e,t)=>{this.resolveNFCSupported=e,NFCIntegration.isNFCSupported()}))}startNFCReader(){return new Promise(((e,t)=>{this.resolveStartNFCReader=e,NFCIntegration.initNFC()}))}stopNFCReader(){return new Promise(((e,t)=>{this.resolveStopNFCReader=e,NFCIntegration.stopListening()}))}stopListeningResult(e){this.resolveStopNFCReader(e)}nfcTagResultRecievedEvent(e){const t=new CustomEvent("nfcTagScanned",{detail:e});this.dispatchEvent(t)}isNFCSupportedResult(e){this.resolveNFCSupported(e)}initNFCResult(e){this.resolveStartNFCReader(e)}}t.NFC=new n},681:function(e,t,n){var s=this&&this.__awaiter||function(e,t,n,s){return new(n||(n=Promise))((function(i,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.PushNotification=void 0;const i=n(913),r=n(607);class o extends EventTarget{requestAccess(){return s(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.resolveRequestAccess=e,PushNotificationIntegration.requestAccess()}))}))}getToken(){return new Promise(((e,t)=>{this.resolveFCMToken=e,PushNotificationIntegration.getFCMToken()}))}subscribeToTopics(e){return s(this,void 0,void 0,(function*(){PushNotificationIntegration.firebasePushNotificationSubscribeToTopics(e);const t=yield this.getToken(),n=yield r.default.App.brandId(),s=yield r.default.App.deviceId(),o=[];e.forEach((e=>{const r={brand:n,topic:e,token:t,deviceId:s},a=fetch(i.baseUrl+"/PushNotification-subscribeToTopic",{body:JSON.stringify(r)});o.push(a)})),(yield Promise.all(o)).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*(){PushNotificationIntegration.firebasePushNotificationTopicsUnsubscribe(e);const t=yield this.getToken(),n=yield r.default.App.brandId(),s=yield r.default.App.deviceId(),o=[];e.forEach((e=>{const r={brand:n,topic:e,token:t,deviceId:s},a=fetch(i.baseUrl+"/PushNotification-unSubscribeFromTopic",{body:JSON.stringify(r)});o.push(a)})),(yield Promise.all(o)).forEach(((t,n)=>{t.ok||console.warn("Failed to unsubscribe from topic",n,e[n])}))}))}requestAccessResult(e){this.resolveRequestAccess(e)}getFCMTokenResult(e){this.resolveFCMToken(e)}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 o},952:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.QrScanner=void 0;class n extends EventTarget{scan(){return new Promise(((e,t)=>{this.resolveScan=e,QrScannerIntegration.startQrCodeScanner()}))}isCameraAccessGranted(){return new Promise(((e,t)=>{this.resolveCameraAccessGranted=e,QrScannerIntegration.isCameraAccessGranted()}))}requestCameraAccess(){return new Promise(((e,t)=>{this.resolveRequestCameraAccess=e,QrScannerIntegration.requestCameraAccess()}))}requestCameraAccessResult(e){this.resolveRequestCameraAccess(e)}startQrCodeScannerResult(e){this.resolveScan(e)}isCameraAccessGrantedResult(e){this.resolveCameraAccessGranted(e)}}t.QrScanner=new n},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 i=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?i.setAttribute("content",this.initialViewportMetaContent):(this.styleString+="\n body {\n touch-action: pan-x pan-y;\n }\n ",i.setAttribute("content","width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, viewport-fit=cover"));const r=document.createElement("style");r.textContent=this.styleString,r.setAttribute("id",s.styleTagId),document.body.appendChild(r)}}}},t={};return function n(s){var i=t[s];if(void 0!==i)return i.exports;var r=t[s]={exports:{}};return e[s].call(r.exports,r,r.exports,n),r.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={752:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.App=void 0;class n extends EventTarget{constructor(){super(...arguments),this.startiappIsLoaded=!1}setStartiappIsLoaded(){this.startiappIsLoaded=!0}isStartiappLoaded(){return this.startiappIsLoaded}setAppUrl(e){AppIntegration.setAppUrl(e)}resetAppUrl(){AppIntegration.resetAppUrl()}openExternalBrowser(e){AppIntegration.openBrowser(e)}downloadFile(e,t){AppIntegration.download(e,t)}brandId(){return new Promise(((e,t)=>{this.resolveBrandId=e,AppIntegration.brandId()}))}requestReview(){AppIntegration.requestReview()}deviceId(){return new Promise(((e,t)=>{this.resolveDeviceId=e,AppIntegration.deviceId()}))}version(){return new Promise(((e,t)=>{this.resolveVersion=e,AppIntegration.version()}))}getInternalDomains(){return new Promise(((e,t)=>{this.resolveGetInternalDomains=e,AppIntegration.getInternalDomains()}))}addInternalDomain(e){AppIntegration.addInternalDomain(e)}removeInternalDomain(e){AppIntegration.removeInternalDomain(e)}showStatusBar(){AppIntegration.showStatusBar()}hideStatusBar(){AppIntegration.hideStatusBar()}setSafeAreaBackgroundColor(e){return new Promise(((t,n)=>{this.resolveSetSafeAreaBackgroundColor=t,AppIntegration.setSafeAreaBackgroundColor(e)}))}disableScreenRotation(){AppIntegration.disableScreenRotation()}enableScreenRotation(){AppIntegration.enableScreenRotation()}addExternalDomains(...e){let t=e.map((e=>({pattern:e.source,flags:e.flags})));AppIntegration.addExternalDomains(t)}removeExternalDomains(...e){let t=e.map((e=>({pattern:e.source,flags:e.flags})));AppIntegration.removeExternalDomains(t)}getExternalDomains(){return new Promise(((e,t)=>{this.resolveExternalDomains=e,AppIntegration.getExternalDomains()}))}getExternalDomainsResult(e){this.resolveExternalDomains(e)}appInForegroundEventRecievedEvent(){this.dispatchEvent(new CustomEvent("appInForeground"))}brandIdResult(e){this.resolveBrandId(e)}versionResult(e){this.resolveVersion(e)}deviceIdResult(e){this.resolveDeviceId(e)}setSafeAreaBackgroundColorResult(e){this.resolveSetSafeAreaBackgroundColor(e)}navigatingPageEvent(e){this.dispatchEvent(new CustomEvent("navigatingPage",{detail:e}))}getInternalDomainsResult(e){this.resolveGetInternalDomains(e)}}t.App=new n},1:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Biometrics=void 0;class n 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."}scan(e=this.defaultScanTitle,t=this.defaultScanReason){return new Promise(((n,s)=>{this.resolveScan=n,BiometricIntegration.startScanning(e,t)}))}getAuthenticationType(){return new Promise(((e,t)=>{this.resolveAuthType=e,BiometricIntegration.getAuthenticationType()}))}setSecuredContent(e){BiometricIntegration.setSecuredContent(this.SECURED_CONTENT_KEY,JSON.stringify(e))}getSecuredContent(e=this.defaultScanTitle,t=this.defaultScanReason){return new Promise(((n,s)=>{this.resolveGetContent=n,BiometricIntegration.getSecuredContent(this.SECURED_CONTENT_KEY,e,t)}))}hasSecuredContent(){return new Promise(((e,t)=>{this.resolveHasSecureContent=e,BiometricIntegration.hasSecuredContent(this.SECURED_CONTENT_KEY)}))}removeSecuredContent(){BiometricIntegration.removeSecuredContent(this.SECURED_CONTENT_KEY)}setUsernameAndPassword(e,t){BiometricIntegration.setSecuredContent(this.SECURED_LOGIN_KEY,JSON.stringify({username:e,password:t}))}removeUsernameAndPassword(){BiometricIntegration.removeSecuredContent(this.SECURED_LOGIN_KEY)}hasUsernameAndPassword(){return new Promise(((e,t)=>{this.resolveHasUsernameAndPassword=e,BiometricIntegration.hasSecuredContent(this.SECURED_LOGIN_KEY)}))}getUsernameAndPassword(e=this.defaultScanTitle,t=this.defaultScanReason){return new Promise(((n,s)=>{this.resolveGetUsernamePassword=n,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)}}hasSecuredContentResult(e){try{const t=JSON.parse(e);if(t.key===this.SECURED_LOGIN_KEY)return void this.resolveHasUsernameAndPassword(t.result);this.resolveHasSecureContent(t.result)}catch(e){this.resolveHasSecureContent(!1)}}getAuthenticationTypeResult(e){this.resolveAuthType(e)}startScanningResult(e){this.resolveScan(e)}getSecuredContentResult(e){try{const t=JSON.parse(e);if(t.key===this.SECURED_LOGIN_KEY)return void this.handleResolveGetUsernamePassword(t);this.resolveGetContent(t.result)}catch(e){this.resolveGetContent(null)}}}t.Biometrics=new n},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{c(s.next(e))}catch(e){i(e)}}function a(e){try{c(s.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((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)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Device=void 0;class n extends EventTarget{startAccelerometer(){DeviceIntegration.startAccelerometer()}stopAccelerometer(){DeviceIntegration.stopAccelerometer()}onShakeEvent(){this.dispatchEvent(new CustomEvent("shake"))}}t.Device=new n},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(983),c=n(681),l=n(952),d=n(716),u=window;u.appIntegrationsAreReady=()=>{s.App.setStartiappIsLoaded(),h.dispatchEvent(new CustomEvent("ready"))},u.startiappDevice=o.Device,u.startiappApp=s.App,u.startiappUser=i.ClientUser,u.startiappQrScanner=l.QrScanner,u.startiappPushNotification=c.PushNotification,u.startiappNFC=a.NFC,u.startiappBiometric=r.Biometrics,u.appErrorEvent=e=>{h.dispatchEvent(new CustomEvent("error",{detail:e}))};class p extends EventTarget{constructor(){super(...arguments),this.App=s.App,this.Device=o.Device,this.Biometrics=r.Biometrics,this.User=i.ClientUser,this.Nfc=a.NFC,this.PushNotification=c.PushNotification,this.QrScanner=l.QrScanner}initialize(e){if("undefined"==typeof AppIntegration)throw new Error("The starti.app API integration is not available.");d.AppUI.setOptions(e),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 h=new p;if(h.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=h,u.startiapp=h},983:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NFC=void 0;class n extends EventTarget{isNFCSupported(){return new Promise(((e,t)=>{this.resolveNFCSupported=e,NFCIntegration.isNFCSupported()}))}startNFCReader(){return new Promise(((e,t)=>{this.resolveStartNFCReader=e,NFCIntegration.initNFC()}))}stopNFCReader(){return new Promise(((e,t)=>{this.resolveStopNFCReader=e,NFCIntegration.stopListening()}))}stopListeningResult(e){this.resolveStopNFCReader(e)}nfcTagResultRecievedEvent(e){const t=new CustomEvent("nfcTagScanned",{detail:e});this.dispatchEvent(t)}isNFCSupportedResult(e){this.resolveNFCSupported(e)}initNFCResult(e){this.resolveStartNFCReader(e)}}t.NFC=new n},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{c(s.next(e))}catch(e){i(e)}}function a(e){try{c(s.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.PushNotification=void 0;const r=n(913),i=n(607);class o extends EventTarget{requestAccess(){return s(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.resolveRequestAccess=e,PushNotificationIntegration.requestAccess()}))}))}getToken(){return new Promise(((e,t)=>{this.resolveFCMToken=e,PushNotificationIntegration.getFCMToken()}))}subscribeToTopics(e){return s(this,void 0,void 0,(function*(){PushNotificationIntegration.firebasePushNotificationSubscribeToTopics(e);const t=yield this.getToken(),n=yield i.default.App.brandId(),s=yield i.default.App.deviceId(),o=[];e.forEach((e=>{const i={brand:n,topic:e,token:t,deviceId:s},a=fetch(r.baseUrl+"/PushNotification-subscribeToTopic",{body:JSON.stringify(i)});o.push(a)})),(yield Promise.all(o)).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*(){PushNotificationIntegration.firebasePushNotificationTopicsUnsubscribe(e);const t=yield this.getToken(),n=yield i.default.App.brandId(),s=yield i.default.App.deviceId(),o=[];e.forEach((e=>{const i={brand:n,topic:e,token:t,deviceId:s},a=fetch(r.baseUrl+"/PushNotification-unSubscribeFromTopic",{body:JSON.stringify(i)});o.push(a)})),(yield Promise.all(o)).forEach(((t,n)=>{t.ok||console.warn("Failed to unsubscribe from topic",n,e[n])}))}))}requestAccessResult(e){this.resolveRequestAccess(e)}getFCMTokenResult(e){this.resolveFCMToken(e)}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 o},952:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.QrScanner=void 0;class n extends EventTarget{scan(){return new Promise(((e,t)=>{this.resolveScan=e,QrScannerIntegration.startQrCodeScanner()}))}isCameraAccessGranted(){return new Promise(((e,t)=>{this.resolveCameraAccessGranted=e,QrScannerIntegration.isCameraAccessGranted()}))}requestCameraAccess(){return new Promise(((e,t)=>{this.resolveRequestCameraAccess=e,QrScannerIntegration.requestCameraAccess()}))}requestCameraAccessResult(e){this.resolveRequestCameraAccess(e)}startQrCodeScannerResult(e){this.resolveScan(e)}isCameraAccessGrantedResult(e){this.resolveCameraAccessGranted(e)}}t.QrScanner=new n},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)})()));
|