starti.app 1.0.39 → 1.0.40
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/clientUser.js +2 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.js +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -3
- package/dist/services/ui-service.d.ts +16 -0
- package/dist/services/ui-service.js +75 -0
- package/package.json +1 -1
- package/umd/main.js +1 -1
package/dist/clientUser.js
CHANGED
|
@@ -20,7 +20,7 @@ exports.ClientUser = new class extends EventTarget {
|
|
|
20
20
|
const fcmToken = yield index_1.default.PushNotification.getToken();
|
|
21
21
|
if (!fcmToken || fcmToken.length === 0) {
|
|
22
22
|
console.warn('Failed to register logged in client user', clientUserId, 'No FCM token');
|
|
23
|
-
|
|
23
|
+
throw new Error(`Failed to register logged in client user ${clientUserId}: No FCM token`);
|
|
24
24
|
}
|
|
25
25
|
const params = {
|
|
26
26
|
brandId: brandId,
|
|
@@ -35,6 +35,7 @@ exports.ClientUser = new class extends EventTarget {
|
|
|
35
35
|
});
|
|
36
36
|
if (!response.ok) {
|
|
37
37
|
console.warn('Failed to register logged in client user', clientUserId, params);
|
|
38
|
+
throw new Error(`Failed to register logged in client user ${clientUserId}: Firebase returned statuscode ${response.status}`);
|
|
38
39
|
}
|
|
39
40
|
});
|
|
40
41
|
}
|
package/dist/config.d.ts
CHANGED
package/dist/config.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.baseUrl = void 0;
|
|
3
|
+
exports.styleTagId = exports.baseUrl = void 0;
|
|
4
4
|
exports.baseUrl = 'https://europe-west3-startiapp-admin-test-e56ab.cloudfunctions.net';
|
|
5
|
+
exports.styleTagId = 'startiapp-styling';
|
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ declare const startiapp: {
|
|
|
12
12
|
/** The QR- and barcode scanning functionality. */
|
|
13
13
|
QrScanner: import("./qrscanner").IQrScanner;
|
|
14
14
|
/** Call this method to initialize the starti.app API integration. This method should be called AFTER all integrations are ready (see onIntegrationsAreReady). */
|
|
15
|
-
initialize(): void;
|
|
15
|
+
initialize(options?: InitializeParams): void;
|
|
16
16
|
/** Call this method to check if the app is running in the starti.app app. */
|
|
17
17
|
isRunningInApp(): boolean;
|
|
18
18
|
addEventListener(type: StartiappEvents, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ const clientUser_1 = require("./clientUser");
|
|
|
6
6
|
const nfc_1 = require("./nfc");
|
|
7
7
|
const pushnotification_1 = require("./pushnotification");
|
|
8
8
|
const qrscanner_1 = require("./qrscanner");
|
|
9
|
+
const ui_service_1 = require("./services/ui-service");
|
|
9
10
|
const untypedWindow = window;
|
|
10
11
|
untypedWindow.appIntegrationsAreReady = () => {
|
|
11
12
|
app_1.App.setStartiappIsLoaded();
|
|
@@ -39,11 +40,13 @@ const startiapp = new class extends EventTarget {
|
|
|
39
40
|
this.QrScanner = qrscanner_1.QrScanner;
|
|
40
41
|
}
|
|
41
42
|
/** Call this method to initialize the starti.app API integration. This method should be called AFTER all integrations are ready (see onIntegrationsAreReady). */
|
|
42
|
-
initialize() {
|
|
43
|
-
if (AppIntegration === undefined)
|
|
43
|
+
initialize(options) {
|
|
44
|
+
if (typeof AppIntegration === 'undefined')
|
|
44
45
|
throw new Error('The starti.app API integration is not available.');
|
|
45
|
-
if (app_1.App.isStartiappLoaded())
|
|
46
|
+
if (app_1.App.isStartiappLoaded()) {
|
|
47
|
+
ui_service_1.AppUI.setOptions(options);
|
|
46
48
|
AppIntegration.webAppIsReady();
|
|
49
|
+
}
|
|
47
50
|
}
|
|
48
51
|
/** Call this method to check if the app is running in the starti.app app. */
|
|
49
52
|
isRunningInApp() {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
declare class UI implements IUI {
|
|
2
|
+
private options;
|
|
3
|
+
private styleString;
|
|
4
|
+
private initialViewportMetaContent;
|
|
5
|
+
setOptions(options?: InitializeParams): void;
|
|
6
|
+
getOptions(): InitializeParams;
|
|
7
|
+
private updateUI;
|
|
8
|
+
}
|
|
9
|
+
interface IUI {
|
|
10
|
+
/** set options for DOM customization and update ui. All default values are false */
|
|
11
|
+
setOptions(options?: InitializeParams): void;
|
|
12
|
+
/** get the currently set options for DOM customization */
|
|
13
|
+
getOptions(): InitializeParams;
|
|
14
|
+
}
|
|
15
|
+
export declare const AppUI: UI;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppUI = void 0;
|
|
4
|
+
const config_1 = require("../config");
|
|
5
|
+
class UI {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.options = { allowDrag: false, allowHighligt: false, allowZoom: false, allowScrollBounce: false };
|
|
8
|
+
}
|
|
9
|
+
setOptions(options) {
|
|
10
|
+
this.options = Object.assign(this.options, options);
|
|
11
|
+
if (document.querySelector('meta[name="viewport"]') != null && typeof (this.initialViewportMetaContent) == 'undefined') {
|
|
12
|
+
this.initialViewportMetaContent = document.querySelector('meta[name="viewport"]').getAttribute("content");
|
|
13
|
+
}
|
|
14
|
+
if (!this.initialViewportMetaContent.includes("viewport-fit=cover"))
|
|
15
|
+
this.initialViewportMetaContent += ", viewport-fit=cover";
|
|
16
|
+
this.updateUI();
|
|
17
|
+
}
|
|
18
|
+
getOptions() {
|
|
19
|
+
return this.options;
|
|
20
|
+
}
|
|
21
|
+
updateUI() {
|
|
22
|
+
this.styleString = "";
|
|
23
|
+
const prevStyleElement = document.getElementById(config_1.styleTagId);
|
|
24
|
+
if (prevStyleElement) {
|
|
25
|
+
prevStyleElement.remove();
|
|
26
|
+
}
|
|
27
|
+
const images = document.getElementsByTagName('img');
|
|
28
|
+
const links = document.getElementsByTagName('a');
|
|
29
|
+
if (!this.options.allowDrag) {
|
|
30
|
+
[...images, ...links].forEach(element => {
|
|
31
|
+
element.setAttribute('draggable', 'false');
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
[...images, ...links].forEach(element => {
|
|
36
|
+
element.removeAttribute('draggable');
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
let viewport = document.querySelector("meta[name=viewport]");
|
|
40
|
+
if (!this.options.allowHighligt) {
|
|
41
|
+
this.styleString += `
|
|
42
|
+
body {
|
|
43
|
+
-webkit-user-select: none;
|
|
44
|
+
-khtml-user-select: none;
|
|
45
|
+
-moz-user-select: none;
|
|
46
|
+
-o-user-select: none;
|
|
47
|
+
user-select: none;
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
}
|
|
51
|
+
if (!this.options.allowScrollBounce) {
|
|
52
|
+
this.styleString += `
|
|
53
|
+
html {
|
|
54
|
+
overscroll-behavior: none;
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
57
|
+
}
|
|
58
|
+
if (!this.options.allowZoom) {
|
|
59
|
+
this.styleString += `
|
|
60
|
+
body {
|
|
61
|
+
touch-action: pan-x pan-y;
|
|
62
|
+
}
|
|
63
|
+
`;
|
|
64
|
+
viewport.setAttribute('content', 'width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, viewport-fit=cover');
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
viewport.setAttribute('content', this.initialViewportMetaContent);
|
|
68
|
+
}
|
|
69
|
+
const styleElement = document.createElement('style');
|
|
70
|
+
styleElement.textContent = this.styleString;
|
|
71
|
+
styleElement.setAttribute('id', config_1.styleTagId);
|
|
72
|
+
document.body.appendChild(styleElement);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.AppUI = new UI();
|
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 r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(self,(()=>(()=>{"use strict";var e={752:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.App=void 0,t.App=new class extends EventTarget{constructor(){super(...arguments),this.startiappIsLoaded=!1}setStartiappIsLoaded(){this.startiappIsLoaded=!0}isStartiappLoaded(){return this.startiappIsLoaded}setAppUrl(e){AppIntegration.setAppUrl(e)}resetAppUrl(){AppIntegration.resetAppUrl()}appInForegroundEventRecievedEvent(){this.dispatchEvent(new CustomEvent("appInForeground"))}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,r)=>{this.resolveSetSafeAreaBackgroundColor=t,AppIntegration.setSafeAreaBackgroundColor(e)}))}disableScreenRotation(){AppIntegration.disableScreenRotation()}enableScreenRotation(){AppIntegration.enableScreenRotation()}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)}}},1:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Biometrics=void 0,t.Biometrics=new class 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(((r,n)=>{this.resolveScan=r;try{if(!BiometricIntegration)return void n("Biometrics virker kun i starti.app");BiometricIntegration.startScanning(e,t)}catch(e){n(e)}}))}startScanningResult(e){this.resolveScan(e)}getAuthenticationType(){return new Promise(((e,t)=>{this.resolveAuthType=e;try{if(!BiometricIntegration)return void t("Biometrics virker kun i starti.app");BiometricIntegration.getAuthenticationType()}catch(e){t(e)}}))}getAuthenticationTypeResult(e){this.resolveAuthType(e)}setSecuredContent(e){if(!BiometricIntegration)throw new Error("Biometrics virker kun i starti.app");BiometricIntegration.setSecuredContent(this.SECURED_CONTENT_KEY,JSON.stringify(e))}getSecuredContent(e=this.defaultScanTitle,t=this.defaultScanReason){return new Promise(((r,n)=>{this.resolveGetContent=r;try{if(!BiometricIntegration)return void n("Biometrics virker kun i starti.app");BiometricIntegration.getSecuredContent(this.SECURED_CONTENT_KEY,e,t)}catch(e){n(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)}}hasSecuredContent(){return new Promise(((e,t)=>{try{if(!BiometricIntegration)return void t("Biometrics virker kun i starti.app");this.resolveHasSecureContent=e,BiometricIntegration.hasSecuredContent(this.SECURED_CONTENT_KEY)}catch(e){t(e)}}))}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)}}removeSecuredContent(){if(!BiometricIntegration)throw new Error("Biometrics virker kun i starti.app");BiometricIntegration.removeSecuredContent(this.SECURED_CONTENT_KEY)}handleResolveGetUsernamePassword(e){try{const t=JSON.parse(e.content);this.resolveGetUsernamePassword(t)}catch(e){this.resolveGetUsernamePassword(null)}}setUsernameAndPassword(e,t){if(!BiometricIntegration)throw new Error("Biometrics virker kun i starti.app");BiometricIntegration.setSecuredContent(this.SECURED_LOGIN_KEY,JSON.stringify({username:e,password:t}))}removeUsernameAndPassword(){if(!BiometricIntegration)throw new Error("Biometrics virker kun i starti.app");BiometricIntegration.removeSecuredContent(this.SECURED_LOGIN_KEY)}hasUsernameAndPassword(){return new Promise(((e,t)=>{try{if(!BiometricIntegration)return void t("Biometrics virker kun i starti.app");this.resolveHasUsernameAndPassword=e,BiometricIntegration.hasSecuredContent(this.SECURED_LOGIN_KEY)}catch(e){t(e)}}))}getUsernameAndPassword(e=this.defaultScanTitle,t=this.defaultScanReason){return new Promise(((r,n)=>{try{if(!BiometricIntegration)return void n("Biometrics virker kun i starti.app");this.resolveGetUsernamePassword=r,BiometricIntegration.getSecuredContent(this.SECURED_LOGIN_KEY,e,t)}catch(e){n(e)}}))}}},495:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ClientUser=void 0;const i=r(913),s=r(607);t.ClientUser=new class extends EventTarget{registerId(e){return n(this,void 0,void 0,(function*(){const t=yield s.default.App.brandId(),r=yield s.default.App.deviceId(),n=yield s.default.PushNotification.getToken();if(!n||0===n.length)return void console.warn("Failed to register logged in client user",e,"No FCM token");const o={brandId:t,clientUserId:e,deviceId:r,fcmToken:n};(yield fetch(i.baseUrl+"/ClientUser-registerId",{body:JSON.stringify(o),headers:{"Content-Type":"application/json"},method:"POST"})).ok||console.warn("Failed to register logged in client user",e,o)}))}}},913:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.baseUrl=void 0,t.baseUrl="https://europe-west3-startiapp-admin-test-e56ab.cloudfunctions.net"},607:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(752),i=r(1),s=r(495),o=r(983),a=r(681),c=r(952),d=window;d.appIntegrationsAreReady=()=>{n.App.setStartiappIsLoaded(),document.body&&document.body.setAttribute("startiapp","true"),u.dispatchEvent(new CustomEvent("ready"))},d.startiappApp=n.App,d.startiappUser=s.ClientUser,d.startiappQrScanner=c.QrScanner,d.startiappPushNotification=a.PushNotification,d.startiappNFC=o.NFC,d.startiappBiometric=i.Biometrics,d.appErrorEvent=e=>{u.dispatchEvent(new CustomEvent("error",{detail:e}))};const u=new class extends EventTarget{constructor(){super(...arguments),this.App=n.App,this.Biometrics=i.Biometrics,this.User=s.ClientUser,this.NfcScanner=o.NFC,this.PushNotification=a.PushNotification,this.QrScanner=c.QrScanner}initialize(){if(void 0===AppIntegration)throw new Error("The starti.app API integration is not available.");n.App.isStartiappLoaded()&&AppIntegration.webAppIsReady()}isRunningInApp(){return navigator.userAgent.toLowerCase().indexOf("starti.app")>-1}addEventListener(e,t,r){super.addEventListener(e,t,r)}removeEventListener(e,t,r){super.removeEventListener(e,t,r)}};t.default=u,d.startiapp=u},983:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NFC=void 0,t.NFC=new class extends EventTarget{isNFCSupported(){return new Promise(((e,t)=>{this.resolveNFCSupported=e;try{if(!NFCIntegration)return void t("NFC virker kun i starti.app");NFCIntegration.isNFCSupported()}catch(e){t(e)}}))}isNFCSupportedResult(e){this.resolveNFCSupported(e)}startNFCReader(){return new Promise(((e,t)=>{this.resolveStartNFCReader=e;try{if(!NFCIntegration)return void t("NFC virker kun i starti.app");NFCIntegration.initNFC()}catch(e){t(e)}}))}startNFCReaderResult(e){this.resolveStartNFCReader(e)}stopNFCReader(){return new Promise(((e,t)=>{this.resolveStopNFCReader=e;try{if(!NFCIntegration)return void t("NFC virker kun i starti.app");NFCIntegration.stopListening()}catch(e){t(e)}}))}stopListeningResult(e){this.resolveStopNFCReader(e)}nfcTagResultRecievedEvent(e){const t=new CustomEvent("nfcTagScanned",{detail:e});this.dispatchEvent(t)}}},681:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.PushNotification=void 0;const i=r(913),s=r(607);t.PushNotification=new class extends EventTarget{requestAccess(){return n(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.resolveRequestAccess=e,PushNotificationIntegration.requestAccess()}))}))}requestAccessResult(e){this.resolveRequestAccess(e)}getToken(){return new Promise(((e,t)=>{this.resolveFCMToken=e,PushNotificationIntegration.getFCMToken()}))}getFCMTokenResult(e){this.resolveFCMToken(e)}tokenReceivedEvent(e){this.dispatchEvent(new CustomEvent("tokenRefreshed",{detail:e}))}notificationReceivedEvent(e){this.dispatchEvent(new CustomEvent("notificationReceived",{detail:e}))}subscribeToTopics(e){return n(this,void 0,void 0,(function*(){PushNotificationIntegration.firebasePushNotificationSubscribeToTopics(e);const t=yield this.getToken(),r=yield s.default.App.brandId(),n=yield s.default.App.deviceId(),o=[];e.forEach((e=>{const s={brand:r,topic:e,token:t,deviceId:n},a=fetch(i.baseUrl+"/PushNotification-subscribeToTopic",{body:JSON.stringify(s)});o.push(a)})),(yield Promise.all(o)).forEach(((t,r)=>{t.ok||console.warn("Failed to sign up to topic",r,e[r])}))}))}unsubscribeFromTopics(e){return n(this,void 0,void 0,(function*(){PushNotificationIntegration.firebasePushNotificationTopicsUnsubscribe(e);const t=yield this.getToken(),r=yield s.default.App.brandId(),n=yield s.default.App.deviceId(),o=[];e.forEach((e=>{const s={brand:r,topic:e,token:t,deviceId:n},a=fetch(i.baseUrl+"/PushNotification-unSubscribeFromTopic",{body:JSON.stringify(s)});o.push(a)})),(yield Promise.all(o)).forEach(((t,r)=>{t.ok||console.warn("Failed to unsubscribe from topic",r,e[r])}))}))}firebasePushNotificationTopicsUnsubscribeResult(e){}firebasePushNotificationSubscribeToTopicsResult(e){}}},952:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.QrScanner=void 0,t.QrScanner=new class extends EventTarget{scan(){return new Promise(((e,t)=>{QrScannerIntegration?(this.resolveScan=e,QrScannerIntegration.startQrCodeScanner()):t("QrScanner integration is not available")}))}qrResultRecievedEvent(e){this.resolveScan(e)}isCameraAccessGranted(){return new Promise(((e,t)=>{if(!QrScannerIntegration)return t("Scanner virker kun i starti.app");this.resolveCameraAccessGranted=e,QrScannerIntegration.isCameraAccessGranted()}))}isCameraAccessGrantedResult(e){this.resolveCameraAccessGranted(e)}requestCameraAccess(){return new Promise(((e,t)=>{if(!QrScannerIntegration)return t("Scanner virker kun i starti.app");this.resolveRequestCameraAccess=e,QrScannerIntegration.requestCameraAccess()}))}requestCameraAccessResult(e){this.resolveRequestCameraAccess(e)}}}},t={};return function r(n){var i=t[n];if(void 0!==i)return i.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,r),s.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 r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(self,(()=>(()=>{"use strict";var e={752:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.App=void 0,t.App=new class extends EventTarget{constructor(){super(...arguments),this.startiappIsLoaded=!1}setStartiappIsLoaded(){this.startiappIsLoaded=!0}isStartiappLoaded(){return this.startiappIsLoaded}setAppUrl(e){AppIntegration.setAppUrl(e)}resetAppUrl(){AppIntegration.resetAppUrl()}appInForegroundEventRecievedEvent(){this.dispatchEvent(new CustomEvent("appInForeground"))}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()}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)}}},1:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Biometrics=void 0,t.Biometrics=new class 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,r)=>{this.resolveScan=n;try{if(!BiometricIntegration)return void r("Biometrics virker kun i starti.app");BiometricIntegration.startScanning(e,t)}catch(e){r(e)}}))}startScanningResult(e){this.resolveScan(e)}getAuthenticationType(){return new Promise(((e,t)=>{this.resolveAuthType=e;try{if(!BiometricIntegration)return void t("Biometrics virker kun i starti.app");BiometricIntegration.getAuthenticationType()}catch(e){t(e)}}))}getAuthenticationTypeResult(e){this.resolveAuthType(e)}setSecuredContent(e){if(!BiometricIntegration)throw new Error("Biometrics virker kun i starti.app");BiometricIntegration.setSecuredContent(this.SECURED_CONTENT_KEY,JSON.stringify(e))}getSecuredContent(e=this.defaultScanTitle,t=this.defaultScanReason){return new Promise(((n,r)=>{this.resolveGetContent=n;try{if(!BiometricIntegration)return void r("Biometrics virker kun i starti.app");BiometricIntegration.getSecuredContent(this.SECURED_CONTENT_KEY,e,t)}catch(e){r(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)}}hasSecuredContent(){return new Promise(((e,t)=>{try{if(!BiometricIntegration)return void t("Biometrics virker kun i starti.app");this.resolveHasSecureContent=e,BiometricIntegration.hasSecuredContent(this.SECURED_CONTENT_KEY)}catch(e){t(e)}}))}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)}}removeSecuredContent(){if(!BiometricIntegration)throw new Error("Biometrics virker kun i starti.app");BiometricIntegration.removeSecuredContent(this.SECURED_CONTENT_KEY)}handleResolveGetUsernamePassword(e){try{const t=JSON.parse(e.content);this.resolveGetUsernamePassword(t)}catch(e){this.resolveGetUsernamePassword(null)}}setUsernameAndPassword(e,t){if(!BiometricIntegration)throw new Error("Biometrics virker kun i starti.app");BiometricIntegration.setSecuredContent(this.SECURED_LOGIN_KEY,JSON.stringify({username:e,password:t}))}removeUsernameAndPassword(){if(!BiometricIntegration)throw new Error("Biometrics virker kun i starti.app");BiometricIntegration.removeSecuredContent(this.SECURED_LOGIN_KEY)}hasUsernameAndPassword(){return new Promise(((e,t)=>{try{if(!BiometricIntegration)return void t("Biometrics virker kun i starti.app");this.resolveHasUsernameAndPassword=e,BiometricIntegration.hasSecuredContent(this.SECURED_LOGIN_KEY)}catch(e){t(e)}}))}getUsernameAndPassword(e=this.defaultScanTitle,t=this.defaultScanReason){return new Promise(((n,r)=>{try{if(!BiometricIntegration)return void r("Biometrics virker kun i starti.app");this.resolveGetUsernamePassword=n,BiometricIntegration.getSecuredContent(this.SECURED_LOGIN_KEY,e,t)}catch(e){r(e)}}))}}},495:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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(s,a)}c((r=r.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ClientUser=void 0;const i=n(913),o=n(607);t.ClientUser=new class extends EventTarget{registerId(e){return r(this,void 0,void 0,(function*(){const t=yield o.default.App.brandId(),n=yield o.default.App.deviceId(),r=yield o.default.PushNotification.getToken();if(!r||0===r.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 s={brandId:t,clientUserId:e,deviceId:n,fcmToken:r},a=yield fetch(i.baseUrl+"/ClientUser-registerId",{body:JSON.stringify(s),headers:{"Content-Type":"application/json"},method:"POST"});if(!a.ok)throw console.warn("Failed to register logged in client user",e,s),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-test-e56ab.cloudfunctions.net",t.styleTagId="startiapp-styling"},607:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});const r=n(752),i=n(1),o=n(495),s=n(983),a=n(681),c=n(952),d=n(716),u=window;u.appIntegrationsAreReady=()=>{r.App.setStartiappIsLoaded(),document.body&&document.body.setAttribute("startiapp","true"),l.dispatchEvent(new CustomEvent("ready"))},u.startiappApp=r.App,u.startiappUser=o.ClientUser,u.startiappQrScanner=c.QrScanner,u.startiappPushNotification=a.PushNotification,u.startiappNFC=s.NFC,u.startiappBiometric=i.Biometrics,u.appErrorEvent=e=>{l.dispatchEvent(new CustomEvent("error",{detail:e}))};const l=new class extends EventTarget{constructor(){super(...arguments),this.App=r.App,this.Biometrics=i.Biometrics,this.User=o.ClientUser,this.NfcScanner=s.NFC,this.PushNotification=a.PushNotification,this.QrScanner=c.QrScanner}initialize(e){if("undefined"==typeof AppIntegration)throw new Error("The starti.app API integration is not available.");r.App.isStartiappLoaded()&&(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)}};t.default=l,u.startiapp=l},983:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NFC=void 0,t.NFC=new class extends EventTarget{isNFCSupported(){return new Promise(((e,t)=>{this.resolveNFCSupported=e;try{if(!NFCIntegration)return void t("NFC virker kun i starti.app");NFCIntegration.isNFCSupported()}catch(e){t(e)}}))}isNFCSupportedResult(e){this.resolveNFCSupported(e)}startNFCReader(){return new Promise(((e,t)=>{this.resolveStartNFCReader=e;try{if(!NFCIntegration)return void t("NFC virker kun i starti.app");NFCIntegration.initNFC()}catch(e){t(e)}}))}startNFCReaderResult(e){this.resolveStartNFCReader(e)}stopNFCReader(){return new Promise(((e,t)=>{this.resolveStopNFCReader=e;try{if(!NFCIntegration)return void t("NFC virker kun i starti.app");NFCIntegration.stopListening()}catch(e){t(e)}}))}stopListeningResult(e){this.resolveStopNFCReader(e)}nfcTagResultRecievedEvent(e){const t=new CustomEvent("nfcTagScanned",{detail:e});this.dispatchEvent(t)}}},681:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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(s,a)}c((r=r.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.PushNotification=void 0;const i=n(913),o=n(607);t.PushNotification=new class extends EventTarget{requestAccess(){return r(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.resolveRequestAccess=e,PushNotificationIntegration.requestAccess()}))}))}requestAccessResult(e){this.resolveRequestAccess(e)}getToken(){return new Promise(((e,t)=>{this.resolveFCMToken=e,PushNotificationIntegration.getFCMToken()}))}getFCMTokenResult(e){this.resolveFCMToken(e)}tokenReceivedEvent(e){this.dispatchEvent(new CustomEvent("tokenRefreshed",{detail:e}))}notificationReceivedEvent(e){this.dispatchEvent(new CustomEvent("notificationReceived",{detail:e}))}subscribeToTopics(e){return r(this,void 0,void 0,(function*(){PushNotificationIntegration.firebasePushNotificationSubscribeToTopics(e);const t=yield this.getToken(),n=yield o.default.App.brandId(),r=yield o.default.App.deviceId(),s=[];e.forEach((e=>{const o={brand:n,topic:e,token:t,deviceId:r},a=fetch(i.baseUrl+"/PushNotification-subscribeToTopic",{body:JSON.stringify(o)});s.push(a)})),(yield Promise.all(s)).forEach(((t,n)=>{t.ok||console.warn("Failed to sign up to topic",n,e[n])}))}))}unsubscribeFromTopics(e){return r(this,void 0,void 0,(function*(){PushNotificationIntegration.firebasePushNotificationTopicsUnsubscribe(e);const t=yield this.getToken(),n=yield o.default.App.brandId(),r=yield o.default.App.deviceId(),s=[];e.forEach((e=>{const o={brand:n,topic:e,token:t,deviceId:r},a=fetch(i.baseUrl+"/PushNotification-unSubscribeFromTopic",{body:JSON.stringify(o)});s.push(a)})),(yield Promise.all(s)).forEach(((t,n)=>{t.ok||console.warn("Failed to unsubscribe from topic",n,e[n])}))}))}firebasePushNotificationTopicsUnsubscribeResult(e){}firebasePushNotificationSubscribeToTopicsResult(e){}}},952:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.QrScanner=void 0,t.QrScanner=new class extends EventTarget{scan(){return new Promise(((e,t)=>{QrScannerIntegration?(this.resolveScan=e,QrScannerIntegration.startQrCodeScanner()):t("QrScanner integration is not available")}))}qrResultRecievedEvent(e){this.resolveScan(e)}isCameraAccessGranted(){return new Promise(((e,t)=>{if(!QrScannerIntegration)return t("Scanner virker kun i starti.app");this.resolveCameraAccessGranted=e,QrScannerIntegration.isCameraAccessGranted()}))}isCameraAccessGrantedResult(e){this.resolveCameraAccessGranted(e)}requestCameraAccess(){return new Promise(((e,t)=>{if(!QrScannerIntegration)return t("Scanner virker kun i starti.app");this.resolveRequestCameraAccess=e,QrScannerIntegration.requestCameraAccess()}))}requestCameraAccessResult(e){this.resolveRequestCameraAccess(e)}}},716:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AppUI=void 0;const r=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(r.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 o=document.createElement("style");o.textContent=this.styleString,o.setAttribute("id",r.styleTagId),document.body.appendChild(o)}}}},t={};return function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,n),o.exports}(607)})()));
|