starti.app 1.0.40 → 1.0.41-alpha.1
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.js +7 -5
- package/dist/biometrics.d.ts +2 -2
- package/dist/biometrics.js +48 -81
- package/dist/device.d.ts +17 -0
- package/dist/device.js +12 -0
- package/dist/index.d.ts +6 -4
- package/dist/index.js +18 -5
- package/dist/nfc.js +13 -38
- package/dist/pushnotification.js +16 -14
- package/dist/qrscanner.js +10 -16
- package/package.json +1 -1
- package/umd/main.js +1 -1
package/dist/app.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.App = void 0;
|
|
4
|
-
|
|
4
|
+
class AppClass extends EventTarget {
|
|
5
5
|
constructor() {
|
|
6
6
|
super(...arguments);
|
|
7
7
|
this.startiappIsLoaded = false;
|
|
@@ -18,9 +18,6 @@ exports.App = new class extends EventTarget {
|
|
|
18
18
|
resetAppUrl() {
|
|
19
19
|
AppIntegration.resetAppUrl();
|
|
20
20
|
}
|
|
21
|
-
appInForegroundEventRecievedEvent() {
|
|
22
|
-
this.dispatchEvent(new CustomEvent('appInForeground'));
|
|
23
|
-
}
|
|
24
21
|
openExternalBrowser(url) {
|
|
25
22
|
AppIntegration.openBrowser(url);
|
|
26
23
|
}
|
|
@@ -78,6 +75,9 @@ exports.App = new class extends EventTarget {
|
|
|
78
75
|
enableScreenRotation() {
|
|
79
76
|
AppIntegration.enableScreenRotation();
|
|
80
77
|
}
|
|
78
|
+
appInForegroundEventRecievedEvent() {
|
|
79
|
+
this.dispatchEvent(new CustomEvent('appInForeground'));
|
|
80
|
+
}
|
|
81
81
|
brandIdResult(result) {
|
|
82
82
|
this.resolveBrandId(result);
|
|
83
83
|
}
|
|
@@ -96,4 +96,6 @@ exports.App = new class extends EventTarget {
|
|
|
96
96
|
getInternalDomainsResult(result) {
|
|
97
97
|
this.resolveGetInternalDomains(result);
|
|
98
98
|
}
|
|
99
|
-
}
|
|
99
|
+
}
|
|
100
|
+
;
|
|
101
|
+
exports.App = new AppClass();
|
package/dist/biometrics.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export declare const Biometrics: IBiometrics;
|
|
2
1
|
declare type BiometricsEvents = "";
|
|
2
|
+
export declare const Biometrics: IBiometrics;
|
|
3
3
|
export interface IBiometrics {
|
|
4
4
|
/** Start scanning for biometrics */
|
|
5
|
-
scan(title
|
|
5
|
+
scan(title?: string, reason?: string): Promise<boolean>;
|
|
6
6
|
/** Get the type of biometrics used */
|
|
7
7
|
getAuthenticationType(): Promise<string>;
|
|
8
8
|
/** Set the content to be secured */
|
package/dist/biometrics.js
CHANGED
|
@@ -1,25 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Biometrics = void 0;
|
|
4
|
-
|
|
4
|
+
class BiometricsClass extends EventTarget {
|
|
5
5
|
constructor() {
|
|
6
6
|
super(...arguments);
|
|
7
7
|
this.SECURED_CONTENT_KEY = "STARTI_APP_BIOMETRIC_CONTENT";
|
|
8
8
|
this.SECURED_LOGIN_KEY = "STARTI_APP_BIOMETRIC_LOGIN_CONTENT";
|
|
9
9
|
this.defaultScanTitle = "Prove you have fingers!";
|
|
10
10
|
this.defaultScanReason = "Can't let you in if you don't.";
|
|
11
|
-
/**
|
|
12
|
-
* Username and password secured storage
|
|
13
|
-
* */
|
|
14
11
|
}
|
|
15
12
|
scan(title = this.defaultScanTitle, reason = this.defaultScanReason) {
|
|
16
13
|
const promise = new Promise((resolve, reject) => {
|
|
17
14
|
this.resolveScan = resolve;
|
|
18
15
|
try {
|
|
19
|
-
if (!BiometricIntegration) {
|
|
20
|
-
reject('Biometrics virker kun i starti.app');
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
16
|
BiometricIntegration.startScanning(title, reason);
|
|
24
17
|
}
|
|
25
18
|
catch (e) {
|
|
@@ -28,17 +21,10 @@ exports.Biometrics = new class extends EventTarget {
|
|
|
28
21
|
});
|
|
29
22
|
return promise;
|
|
30
23
|
}
|
|
31
|
-
startScanningResult(result) {
|
|
32
|
-
this.resolveScan(result);
|
|
33
|
-
}
|
|
34
24
|
getAuthenticationType() {
|
|
35
25
|
const promise = new Promise((resolve, reject) => {
|
|
36
26
|
this.resolveAuthType = resolve;
|
|
37
27
|
try {
|
|
38
|
-
if (!BiometricIntegration) {
|
|
39
|
-
reject('Biometrics virker kun i starti.app');
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
28
|
BiometricIntegration.getAuthenticationType();
|
|
43
29
|
}
|
|
44
30
|
catch (e) {
|
|
@@ -47,22 +33,13 @@ exports.Biometrics = new class extends EventTarget {
|
|
|
47
33
|
});
|
|
48
34
|
return promise;
|
|
49
35
|
}
|
|
50
|
-
getAuthenticationTypeResult(result) {
|
|
51
|
-
this.resolveAuthType(result);
|
|
52
|
-
}
|
|
53
36
|
setSecuredContent(content) {
|
|
54
|
-
if (!BiometricIntegration)
|
|
55
|
-
throw new Error('Biometrics virker kun i starti.app');
|
|
56
37
|
BiometricIntegration.setSecuredContent(this.SECURED_CONTENT_KEY, JSON.stringify(content));
|
|
57
38
|
}
|
|
58
39
|
getSecuredContent(title = this.defaultScanTitle, reason = this.defaultScanReason) {
|
|
59
40
|
const promise = new Promise((resolve, reject) => {
|
|
60
41
|
this.resolveGetContent = resolve;
|
|
61
42
|
try {
|
|
62
|
-
if (!BiometricIntegration) {
|
|
63
|
-
reject('Biometrics virker kun i starti.app');
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
43
|
BiometricIntegration.getSecuredContent(this.SECURED_CONTENT_KEY, title, reason);
|
|
67
44
|
}
|
|
68
45
|
catch (e) {
|
|
@@ -71,26 +48,9 @@ exports.Biometrics = new class extends EventTarget {
|
|
|
71
48
|
});
|
|
72
49
|
return promise;
|
|
73
50
|
}
|
|
74
|
-
getSecuredContentResult(result) {
|
|
75
|
-
try {
|
|
76
|
-
const parsed = JSON.parse(result);
|
|
77
|
-
if (parsed.key === this.SECURED_LOGIN_KEY) {
|
|
78
|
-
this.handleResolveGetUsernamePassword(parsed);
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
this.resolveGetContent(parsed.content);
|
|
82
|
-
}
|
|
83
|
-
catch (error) {
|
|
84
|
-
this.resolveGetContent(null);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
51
|
hasSecuredContent() {
|
|
88
52
|
const promise = new Promise((resolve, reject) => {
|
|
89
53
|
try {
|
|
90
|
-
if (!BiometricIntegration) {
|
|
91
|
-
reject('Biometrics virker kun i starti.app');
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
54
|
this.resolveHasSecureContent = resolve;
|
|
95
55
|
BiometricIntegration.hasSecuredContent(this.SECURED_CONTENT_KEY);
|
|
96
56
|
}
|
|
@@ -100,53 +60,18 @@ exports.Biometrics = new class extends EventTarget {
|
|
|
100
60
|
});
|
|
101
61
|
return promise;
|
|
102
62
|
}
|
|
103
|
-
hasSecuredContentResult(result) {
|
|
104
|
-
try {
|
|
105
|
-
const parsed = JSON.parse(result);
|
|
106
|
-
if (parsed.key === this.SECURED_LOGIN_KEY) {
|
|
107
|
-
this.resolveHasUsernameAndPassword(parsed.result);
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
this.resolveHasSecureContent(parsed.result);
|
|
111
|
-
}
|
|
112
|
-
catch (error) {
|
|
113
|
-
this.resolveHasSecureContent(false);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
63
|
removeSecuredContent() {
|
|
117
|
-
if (!BiometricIntegration)
|
|
118
|
-
throw new Error('Biometrics virker kun i starti.app');
|
|
119
64
|
BiometricIntegration.removeSecuredContent(this.SECURED_CONTENT_KEY);
|
|
120
65
|
}
|
|
121
|
-
/**
|
|
122
|
-
* Username and password secured storage
|
|
123
|
-
* */
|
|
124
|
-
handleResolveGetUsernamePassword(result) {
|
|
125
|
-
try {
|
|
126
|
-
const parsed = JSON.parse(result.content);
|
|
127
|
-
this.resolveGetUsernamePassword(parsed);
|
|
128
|
-
}
|
|
129
|
-
catch (error) {
|
|
130
|
-
this.resolveGetUsernamePassword(null);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
66
|
setUsernameAndPassword(username, password) {
|
|
134
|
-
if (!BiometricIntegration)
|
|
135
|
-
throw new Error('Biometrics virker kun i starti.app');
|
|
136
67
|
BiometricIntegration.setSecuredContent(this.SECURED_LOGIN_KEY, JSON.stringify({ username, password }));
|
|
137
68
|
}
|
|
138
69
|
removeUsernameAndPassword() {
|
|
139
|
-
if (!BiometricIntegration)
|
|
140
|
-
throw new Error('Biometrics virker kun i starti.app');
|
|
141
70
|
BiometricIntegration.removeSecuredContent(this.SECURED_LOGIN_KEY);
|
|
142
71
|
}
|
|
143
72
|
hasUsernameAndPassword() {
|
|
144
73
|
const promise = new Promise((resolve, reject) => {
|
|
145
74
|
try {
|
|
146
|
-
if (!BiometricIntegration) {
|
|
147
|
-
reject('Biometrics virker kun i starti.app');
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
75
|
this.resolveHasUsernameAndPassword = resolve;
|
|
151
76
|
BiometricIntegration.hasSecuredContent(this.SECURED_LOGIN_KEY);
|
|
152
77
|
}
|
|
@@ -159,10 +84,6 @@ exports.Biometrics = new class extends EventTarget {
|
|
|
159
84
|
getUsernameAndPassword(scanTitle = this.defaultScanTitle, scanReason = this.defaultScanReason) {
|
|
160
85
|
const promise = new Promise((resolve, reject) => {
|
|
161
86
|
try {
|
|
162
|
-
if (!BiometricIntegration) {
|
|
163
|
-
reject('Biometrics virker kun i starti.app');
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
87
|
this.resolveGetUsernamePassword = resolve;
|
|
167
88
|
BiometricIntegration.getSecuredContent(this.SECURED_LOGIN_KEY, scanTitle, scanReason);
|
|
168
89
|
}
|
|
@@ -172,4 +93,50 @@ exports.Biometrics = new class extends EventTarget {
|
|
|
172
93
|
});
|
|
173
94
|
return promise;
|
|
174
95
|
}
|
|
175
|
-
|
|
96
|
+
/**
|
|
97
|
+
* Username and password secured storage
|
|
98
|
+
* */
|
|
99
|
+
handleResolveGetUsernamePassword(result) {
|
|
100
|
+
try {
|
|
101
|
+
const parsed = JSON.parse(result.content);
|
|
102
|
+
this.resolveGetUsernamePassword(parsed);
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
this.resolveGetUsernamePassword(null);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
hasSecuredContentResult(result) {
|
|
109
|
+
try {
|
|
110
|
+
const parsed = JSON.parse(result);
|
|
111
|
+
if (parsed.key === this.SECURED_LOGIN_KEY) {
|
|
112
|
+
this.resolveHasUsernameAndPassword(parsed.result);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
this.resolveHasSecureContent(parsed.result);
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
this.resolveHasSecureContent(false);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
getAuthenticationTypeResult(result) {
|
|
122
|
+
this.resolveAuthType(result);
|
|
123
|
+
}
|
|
124
|
+
startScanningResult(result) {
|
|
125
|
+
this.resolveScan(result);
|
|
126
|
+
}
|
|
127
|
+
getSecuredContentResult(result) {
|
|
128
|
+
try {
|
|
129
|
+
const parsed = JSON.parse(result);
|
|
130
|
+
if (parsed.key === this.SECURED_LOGIN_KEY) {
|
|
131
|
+
this.handleResolveGetUsernamePassword(parsed);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
this.resolveGetContent(parsed.content);
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
this.resolveGetContent(null);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
;
|
|
142
|
+
exports.Biometrics = new BiometricsClass();
|
package/dist/device.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const Device: IDevice;
|
|
2
|
+
declare type DeviceEvents = "shake";
|
|
3
|
+
export interface IDevice {
|
|
4
|
+
/** Listen for events */
|
|
5
|
+
addEventListener(type: DeviceEvents, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
6
|
+
/** Remove event listener */
|
|
7
|
+
removeEventListener(type: DeviceEvents, callback: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
8
|
+
/**
|
|
9
|
+
* Start accelerometer
|
|
10
|
+
*
|
|
11
|
+
* this is required to detect shake events
|
|
12
|
+
* */
|
|
13
|
+
startAccelerometer(): void;
|
|
14
|
+
/** Stop accelerometer */
|
|
15
|
+
stopAccelerometer(): void;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
package/dist/device.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Device = void 0;
|
|
4
|
+
class DeviceClass extends EventTarget {
|
|
5
|
+
startAccelerometer() {
|
|
6
|
+
DeviceIntegration.startAccelerometer();
|
|
7
|
+
}
|
|
8
|
+
stopAccelerometer() {
|
|
9
|
+
DeviceIntegration.stopAccelerometer();
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.Device = new DeviceClass();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
declare
|
|
1
|
+
declare class StartiappClass extends EventTarget {
|
|
2
2
|
/** Basic calls to the app. */
|
|
3
3
|
App: import("./app").IApp;
|
|
4
|
+
/** Access to device functionality. */
|
|
5
|
+
Device: import("./device").IDevice;
|
|
4
6
|
/** The biometric functionality. */
|
|
5
7
|
Biometrics: import("./biometrics").IBiometrics;
|
|
6
8
|
/** Access to client user functionality. */
|
|
7
9
|
User: import("./clientUser").IClientUser;
|
|
8
10
|
/** The NFC scanning functionality. */
|
|
9
|
-
|
|
11
|
+
Nfc: import("./nfc").INFC;
|
|
10
12
|
/** Access to push notifications using Firebase. */
|
|
11
13
|
PushNotification: import("./pushnotification").IPushNotification;
|
|
12
14
|
/** The QR- and barcode scanning functionality. */
|
|
@@ -17,7 +19,7 @@ declare const startiapp: {
|
|
|
17
19
|
isRunningInApp(): boolean;
|
|
18
20
|
addEventListener(type: StartiappEvents, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
19
21
|
removeEventListener(type: StartiappEvents, callback: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
}
|
|
23
|
+
declare const startiapp: StartiappClass;
|
|
22
24
|
declare type StartiappEvents = "ready" | "error";
|
|
23
25
|
export default startiapp;
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const app_1 = require("./app");
|
|
4
4
|
const biometrics_1 = require("./biometrics");
|
|
5
5
|
const clientUser_1 = require("./clientUser");
|
|
6
|
+
const device_1 = require("./device");
|
|
6
7
|
const nfc_1 = require("./nfc");
|
|
7
8
|
const pushnotification_1 = require("./pushnotification");
|
|
8
9
|
const qrscanner_1 = require("./qrscanner");
|
|
@@ -10,10 +11,9 @@ const ui_service_1 = require("./services/ui-service");
|
|
|
10
11
|
const untypedWindow = window;
|
|
11
12
|
untypedWindow.appIntegrationsAreReady = () => {
|
|
12
13
|
app_1.App.setStartiappIsLoaded();
|
|
13
|
-
if (document.body)
|
|
14
|
-
document.body.setAttribute('startiapp', 'true');
|
|
15
14
|
startiapp.dispatchEvent(new CustomEvent('ready'));
|
|
16
15
|
};
|
|
16
|
+
untypedWindow.startiappDevice = device_1.Device;
|
|
17
17
|
untypedWindow.startiappApp = app_1.App;
|
|
18
18
|
untypedWindow.startiappUser = clientUser_1.ClientUser;
|
|
19
19
|
untypedWindow.startiappQrScanner = qrscanner_1.QrScanner;
|
|
@@ -23,17 +23,19 @@ untypedWindow.startiappBiometric = biometrics_1.Biometrics;
|
|
|
23
23
|
untypedWindow.appErrorEvent = (data) => {
|
|
24
24
|
startiapp.dispatchEvent(new CustomEvent('error', { detail: data }));
|
|
25
25
|
};
|
|
26
|
-
|
|
26
|
+
class StartiappClass extends EventTarget {
|
|
27
27
|
constructor() {
|
|
28
28
|
super(...arguments);
|
|
29
29
|
/** Basic calls to the app. */
|
|
30
30
|
this.App = app_1.App;
|
|
31
|
+
/** Access to device functionality. */
|
|
32
|
+
this.Device = device_1.Device;
|
|
31
33
|
/** The biometric functionality. */
|
|
32
34
|
this.Biometrics = biometrics_1.Biometrics;
|
|
33
35
|
/** Access to client user functionality. */
|
|
34
36
|
this.User = clientUser_1.ClientUser;
|
|
35
37
|
/** The NFC scanning functionality. */
|
|
36
|
-
this.
|
|
38
|
+
this.Nfc = nfc_1.NFC;
|
|
37
39
|
/** Access to push notifications using Firebase. */
|
|
38
40
|
this.PushNotification = pushnotification_1.PushNotification;
|
|
39
41
|
/** The QR- and barcode scanning functionality. */
|
|
@@ -61,6 +63,17 @@ const startiapp = new class extends EventTarget {
|
|
|
61
63
|
removeEventListener(type, callback, options) {
|
|
62
64
|
super.removeEventListener(type, callback, options);
|
|
63
65
|
}
|
|
64
|
-
}
|
|
66
|
+
}
|
|
67
|
+
;
|
|
68
|
+
const startiapp = new StartiappClass();
|
|
69
|
+
if (startiapp.isRunningInApp()) {
|
|
70
|
+
if (document.body)
|
|
71
|
+
document.body.setAttribute('startiapp', 'true');
|
|
72
|
+
else {
|
|
73
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
74
|
+
document.body.setAttribute('startiapp', 'true');
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
65
78
|
exports.default = startiapp;
|
|
66
79
|
untypedWindow.startiapp = startiapp;
|
package/dist/nfc.js
CHANGED
|
@@ -1,58 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NFC = void 0;
|
|
4
|
-
|
|
4
|
+
class NfcClass extends EventTarget {
|
|
5
5
|
isNFCSupported() {
|
|
6
6
|
const promise = new Promise((resolve, reject) => {
|
|
7
7
|
this.resolveNFCSupported = resolve;
|
|
8
|
-
|
|
9
|
-
if (!NFCIntegration) {
|
|
10
|
-
reject('NFC virker kun i starti.app');
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
NFCIntegration.isNFCSupported();
|
|
14
|
-
}
|
|
15
|
-
catch (e) {
|
|
16
|
-
reject(e);
|
|
17
|
-
}
|
|
8
|
+
NFCIntegration.isNFCSupported();
|
|
18
9
|
});
|
|
19
10
|
return promise;
|
|
20
11
|
}
|
|
21
|
-
isNFCSupportedResult(result) {
|
|
22
|
-
this.resolveNFCSupported(result);
|
|
23
|
-
}
|
|
24
12
|
startNFCReader() {
|
|
25
13
|
const promise = new Promise((resolve, reject) => {
|
|
26
14
|
this.resolveStartNFCReader = resolve;
|
|
27
|
-
|
|
28
|
-
if (!NFCIntegration) {
|
|
29
|
-
reject('NFC virker kun i starti.app');
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
NFCIntegration.initNFC();
|
|
33
|
-
}
|
|
34
|
-
catch (e) {
|
|
35
|
-
reject(e);
|
|
36
|
-
}
|
|
15
|
+
NFCIntegration.initNFC();
|
|
37
16
|
});
|
|
38
17
|
return promise;
|
|
39
18
|
}
|
|
40
|
-
startNFCReaderResult(result) {
|
|
41
|
-
this.resolveStartNFCReader(result);
|
|
42
|
-
}
|
|
43
19
|
stopNFCReader() {
|
|
44
20
|
const promise = new Promise((resolve, reject) => {
|
|
45
21
|
this.resolveStopNFCReader = resolve;
|
|
46
|
-
|
|
47
|
-
if (!NFCIntegration) {
|
|
48
|
-
reject('NFC virker kun i starti.app');
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
NFCIntegration.stopListening();
|
|
52
|
-
}
|
|
53
|
-
catch (e) {
|
|
54
|
-
reject(e);
|
|
55
|
-
}
|
|
22
|
+
NFCIntegration.stopListening();
|
|
56
23
|
});
|
|
57
24
|
return promise;
|
|
58
25
|
}
|
|
@@ -65,4 +32,12 @@ exports.NFC = new class extends EventTarget {
|
|
|
65
32
|
});
|
|
66
33
|
this.dispatchEvent(event);
|
|
67
34
|
}
|
|
68
|
-
|
|
35
|
+
isNFCSupportedResult(result) {
|
|
36
|
+
this.resolveNFCSupported(result);
|
|
37
|
+
}
|
|
38
|
+
startNFCReaderResult(result) {
|
|
39
|
+
this.resolveStartNFCReader(result);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
;
|
|
43
|
+
exports.NFC = new NfcClass();
|
package/dist/pushnotification.js
CHANGED
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.PushNotification = void 0;
|
|
13
13
|
const config_1 = require("./config");
|
|
14
14
|
const index_1 = require("./index");
|
|
15
|
-
|
|
15
|
+
class PushNotificationClass extends EventTarget {
|
|
16
16
|
requestAccess() {
|
|
17
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
18
|
return new Promise((resolve, _) => {
|
|
@@ -21,24 +21,12 @@ exports.PushNotification = new class extends EventTarget {
|
|
|
21
21
|
});
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
requestAccessResult(accessGranted) {
|
|
25
|
-
this.resolveRequestAccess(accessGranted);
|
|
26
|
-
}
|
|
27
24
|
getToken() {
|
|
28
25
|
return new Promise((resolve, _) => {
|
|
29
26
|
this.resolveFCMToken = resolve;
|
|
30
27
|
PushNotificationIntegration.getFCMToken();
|
|
31
28
|
});
|
|
32
29
|
}
|
|
33
|
-
getFCMTokenResult(token) {
|
|
34
|
-
this.resolveFCMToken(token);
|
|
35
|
-
}
|
|
36
|
-
tokenReceivedEvent(token) {
|
|
37
|
-
this.dispatchEvent(new CustomEvent('tokenRefreshed', { detail: token }));
|
|
38
|
-
}
|
|
39
|
-
notificationReceivedEvent(notification) {
|
|
40
|
-
this.dispatchEvent(new CustomEvent('notificationReceived', { detail: notification }));
|
|
41
|
-
}
|
|
42
30
|
subscribeToTopics(topics) {
|
|
43
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
32
|
PushNotificationIntegration.firebasePushNotificationSubscribeToTopics(topics);
|
|
@@ -93,6 +81,18 @@ exports.PushNotification = new class extends EventTarget {
|
|
|
93
81
|
});
|
|
94
82
|
});
|
|
95
83
|
}
|
|
84
|
+
requestAccessResult(accessGranted) {
|
|
85
|
+
this.resolveRequestAccess(accessGranted);
|
|
86
|
+
}
|
|
87
|
+
getFCMTokenResult(token) {
|
|
88
|
+
this.resolveFCMToken(token);
|
|
89
|
+
}
|
|
90
|
+
tokenReceivedEvent(token) {
|
|
91
|
+
this.dispatchEvent(new CustomEvent('tokenRefreshed', { detail: token }));
|
|
92
|
+
}
|
|
93
|
+
notificationReceivedEvent(notification) {
|
|
94
|
+
this.dispatchEvent(new CustomEvent('notificationReceived', { detail: notification }));
|
|
95
|
+
}
|
|
96
96
|
/**
|
|
97
97
|
* Always called with true from Firebase.
|
|
98
98
|
*/
|
|
@@ -101,4 +101,6 @@ exports.PushNotification = new class extends EventTarget {
|
|
|
101
101
|
* Always called with true from Firebase.
|
|
102
102
|
*/
|
|
103
103
|
firebasePushNotificationSubscribeToTopicsResult(result) { }
|
|
104
|
-
}
|
|
104
|
+
}
|
|
105
|
+
;
|
|
106
|
+
exports.PushNotification = new PushNotificationClass();
|
package/dist/qrscanner.js
CHANGED
|
@@ -1,35 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.QrScanner = void 0;
|
|
4
|
-
|
|
4
|
+
class QrScannerClass extends EventTarget {
|
|
5
5
|
scan() {
|
|
6
6
|
return new Promise((resolve, reject) => {
|
|
7
|
-
if (!QrScannerIntegration) {
|
|
8
|
-
reject('QrScanner integration is not available');
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
7
|
this.resolveScan = resolve;
|
|
12
8
|
QrScannerIntegration.startQrCodeScanner();
|
|
13
9
|
});
|
|
14
10
|
}
|
|
15
|
-
qrResultRecievedEvent(message) {
|
|
16
|
-
this.resolveScan(message);
|
|
17
|
-
}
|
|
18
11
|
isCameraAccessGranted() {
|
|
19
12
|
return new Promise((resolve, reject) => {
|
|
20
|
-
if (!QrScannerIntegration)
|
|
21
|
-
return reject('Scanner virker kun i starti.app');
|
|
22
13
|
this.resolveCameraAccessGranted = resolve;
|
|
23
14
|
QrScannerIntegration.isCameraAccessGranted();
|
|
24
15
|
});
|
|
25
16
|
}
|
|
26
|
-
isCameraAccessGrantedResult(result) {
|
|
27
|
-
this.resolveCameraAccessGranted(result);
|
|
28
|
-
}
|
|
29
17
|
requestCameraAccess() {
|
|
30
18
|
return new Promise((resolve, reject) => {
|
|
31
|
-
if (!QrScannerIntegration)
|
|
32
|
-
return reject('Scanner virker kun i starti.app');
|
|
33
19
|
this.resolveRequestCameraAccess = resolve;
|
|
34
20
|
QrScannerIntegration.requestCameraAccess();
|
|
35
21
|
});
|
|
@@ -37,4 +23,12 @@ exports.QrScanner = new class extends EventTarget {
|
|
|
37
23
|
requestCameraAccessResult(result) {
|
|
38
24
|
this.resolveRequestCameraAccess(result);
|
|
39
25
|
}
|
|
40
|
-
|
|
26
|
+
qrResultRecievedEvent(message) {
|
|
27
|
+
this.resolveScan(message);
|
|
28
|
+
}
|
|
29
|
+
isCameraAccessGrantedResult(result) {
|
|
30
|
+
this.resolveCameraAccessGranted(result);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
;
|
|
34
|
+
exports.QrScanner = new QrScannerClass();
|
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 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)})()));
|
|
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;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,r)=>{this.resolveScan=n;try{BiometricIntegration.startScanning(e,t)}catch(e){r(e)}}))}getAuthenticationType(){return new Promise(((e,t)=>{this.resolveAuthType=e;try{BiometricIntegration.getAuthenticationType()}catch(e){t(e)}}))}setSecuredContent(e){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{BiometricIntegration.getSecuredContent(this.SECURED_CONTENT_KEY,e,t)}catch(e){r(e)}}))}hasSecuredContent(){return new Promise(((e,t)=>{try{this.resolveHasSecureContent=e,BiometricIntegration.hasSecuredContent(this.SECURED_CONTENT_KEY)}catch(e){t(e)}}))}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)=>{try{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{this.resolveGetUsernamePassword=n,BiometricIntegration.getSecuredContent(this.SECURED_LOGIN_KEY,e,t)}catch(e){r(e)}}))}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 r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(s,i){function o(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((r=r.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ClientUser=void 0;const s=n(913),i=n(607);t.ClientUser=new class extends EventTarget{registerId(e){return r(this,void 0,void 0,(function*(){const t=yield i.default.App.brandId(),n=yield i.default.App.deviceId(),r=yield i.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 o={brandId:t,clientUserId:e,deviceId:n,fcmToken:r},a=yield fetch(s.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-test-e56ab.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()}}t.Device=new n},607:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});const r=n(752),s=n(1),i=n(495),o=n(955),a=n(983),c=n(681),d=n(952),l=n(716),u=window;u.appIntegrationsAreReady=()=>{r.App.setStartiappIsLoaded(),h.dispatchEvent(new CustomEvent("ready"))},u.startiappDevice=o.Device,u.startiappApp=r.App,u.startiappUser=i.ClientUser,u.startiappQrScanner=d.QrScanner,u.startiappPushNotification=c.PushNotification,u.startiappNFC=a.NFC,u.startiappBiometric=s.Biometrics,u.appErrorEvent=e=>{h.dispatchEvent(new CustomEvent("error",{detail:e}))};class p extends EventTarget{constructor(){super(...arguments),this.App=r.App,this.Device=o.Device,this.Biometrics=s.Biometrics,this.User=i.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.");r.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;h.isRunningInApp()&&(document.body?document.body.setAttribute("startiapp","true"):document.addEventListener("DOMContentLoaded",(()=>{document.body.setAttribute("startiapp","true")}))),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)}startNFCReaderResult(e){this.resolveStartNFCReader(e)}}t.NFC=new n},681:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(s,i){function o(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((r=r.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.PushNotification=void 0;const s=n(913),i=n(607);class o extends EventTarget{requestAccess(){return r(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 r(this,void 0,void 0,(function*(){PushNotificationIntegration.firebasePushNotificationSubscribeToTopics(e);const t=yield this.getToken(),n=yield i.default.App.brandId(),r=yield i.default.App.deviceId(),o=[];e.forEach((e=>{const i={brand:n,topic:e,token:t,deviceId:r},a=fetch(s.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 r(this,void 0,void 0,(function*(){PushNotificationIntegration.firebasePushNotificationTopicsUnsubscribe(e);const t=yield this.getToken(),n=yield i.default.App.brandId(),r=yield i.default.App.deviceId(),o=[];e.forEach((e=>{const i={brand:n,topic:e,token:t,deviceId:r},a=fetch(s.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)}qrResultRecievedEvent(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 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 s=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?s.setAttribute("content",this.initialViewportMetaContent):(this.styleString+="\n body {\n touch-action: pan-x pan-y;\n }\n ",s.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",r.styleTagId),document.body.appendChild(i)}}}},t={};return function n(r){var s=t[r];if(void 0!==s)return s.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,n),i.exports}(607)})()));
|