starti.app 1.0.48-alpha.0 → 1.0.48
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 +29 -19
- package/dist/biometrics.js +20 -10
- package/dist/device.js +8 -3
- package/dist/getIntegration.d.ts +10 -2
- package/dist/getIntegration.js +4 -4
- package/dist/index.d.ts +22 -0
- package/dist/index.js +5 -3
- package/dist/nfc.js +10 -3
- package/dist/pushnotification.js +10 -4
- package/dist/qrscanner.js +3 -0
- package/package.json +1 -1
- package/umd/main.js +1 -1
package/dist/app.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.App = void 0;
|
|
4
|
+
const getIntegration_1 = require("./getIntegration");
|
|
4
5
|
class AppClass extends EventTarget {
|
|
5
6
|
constructor() {
|
|
6
7
|
super(...arguments);
|
|
7
8
|
this.startiappIsLoaded = false;
|
|
8
9
|
}
|
|
10
|
+
get appIntegration() {
|
|
11
|
+
return (0, getIntegration_1.getIntegration)('AppIntegration');
|
|
12
|
+
}
|
|
9
13
|
setStartiappIsLoaded() {
|
|
10
14
|
this.startiappIsLoaded = true;
|
|
11
15
|
}
|
|
@@ -13,111 +17,117 @@ class AppClass extends EventTarget {
|
|
|
13
17
|
return this.startiappIsLoaded;
|
|
14
18
|
}
|
|
15
19
|
setAppUrl(url) {
|
|
16
|
-
|
|
20
|
+
this.appIntegration.setAppUrl(url);
|
|
17
21
|
}
|
|
18
22
|
resetAppUrl() {
|
|
19
|
-
|
|
23
|
+
this.appIntegration.resetAppUrl();
|
|
20
24
|
}
|
|
21
25
|
openExternalBrowser(url) {
|
|
22
|
-
|
|
26
|
+
this.appIntegration.openBrowser(url);
|
|
23
27
|
}
|
|
24
28
|
downloadFile(url, fileName) {
|
|
25
|
-
|
|
29
|
+
this.appIntegration.download(url, fileName);
|
|
26
30
|
}
|
|
27
31
|
brandId() {
|
|
28
32
|
return new Promise((resolve, reject) => {
|
|
29
33
|
this.resolveBrandId = resolve;
|
|
30
|
-
|
|
34
|
+
this.appIntegration.brandId();
|
|
31
35
|
});
|
|
32
36
|
}
|
|
33
37
|
requestReview() {
|
|
34
|
-
|
|
38
|
+
this.appIntegration.requestReview();
|
|
35
39
|
}
|
|
36
40
|
deviceId() {
|
|
37
41
|
return new Promise((resolve, reject) => {
|
|
38
42
|
this.resolveDeviceId = resolve;
|
|
39
|
-
|
|
43
|
+
this.appIntegration.deviceId();
|
|
40
44
|
});
|
|
41
45
|
}
|
|
42
46
|
version() {
|
|
43
47
|
return new Promise((resolve, reject) => {
|
|
44
48
|
this.resolveVersion = resolve;
|
|
45
|
-
|
|
49
|
+
this.appIntegration.version();
|
|
46
50
|
});
|
|
47
51
|
}
|
|
48
52
|
getInternalDomains() {
|
|
49
53
|
return new Promise((resolve, reject) => {
|
|
50
54
|
this.resolveGetInternalDomains = resolve;
|
|
51
|
-
|
|
55
|
+
this.appIntegration.getInternalDomains();
|
|
52
56
|
});
|
|
53
57
|
}
|
|
54
58
|
addInternalDomain(domain) {
|
|
55
|
-
|
|
59
|
+
this.appIntegration.addInternalDomain(domain);
|
|
56
60
|
}
|
|
57
61
|
removeInternalDomain(domain) {
|
|
58
|
-
|
|
62
|
+
this.appIntegration.removeInternalDomain(domain);
|
|
59
63
|
}
|
|
60
64
|
showStatusBar() {
|
|
61
|
-
|
|
65
|
+
this.appIntegration.showStatusBar();
|
|
62
66
|
}
|
|
63
67
|
hideStatusBar() {
|
|
64
|
-
|
|
68
|
+
this.appIntegration.hideStatusBar();
|
|
65
69
|
}
|
|
66
70
|
setSafeAreaBackgroundColor(color) {
|
|
67
71
|
return new Promise((resolve, reject) => {
|
|
68
72
|
this.resolveSetSafeAreaBackgroundColor = resolve;
|
|
69
|
-
|
|
73
|
+
this.appIntegration.setSafeAreaBackgroundColor(color);
|
|
70
74
|
});
|
|
71
75
|
}
|
|
72
76
|
disableScreenRotation() {
|
|
73
|
-
|
|
77
|
+
this.appIntegration.disableScreenRotation();
|
|
74
78
|
}
|
|
75
79
|
enableScreenRotation() {
|
|
76
|
-
|
|
80
|
+
this.appIntegration.enableScreenRotation();
|
|
77
81
|
}
|
|
78
82
|
addExternalDomains(...domains) {
|
|
79
83
|
let domainObjects = domains.map(m => ({
|
|
80
84
|
pattern: m.source,
|
|
81
85
|
flags: m.flags
|
|
82
86
|
}));
|
|
83
|
-
|
|
87
|
+
this.appIntegration.addExternalDomains(domainObjects);
|
|
84
88
|
}
|
|
85
89
|
removeExternalDomains(...domains) {
|
|
86
90
|
let domainObjects = domains.map(m => ({
|
|
87
91
|
pattern: m.source,
|
|
88
92
|
flags: m.flags
|
|
89
93
|
}));
|
|
90
|
-
|
|
94
|
+
this.appIntegration.removeExternalDomains(domainObjects);
|
|
91
95
|
}
|
|
92
96
|
getExternalDomains() {
|
|
93
97
|
return new Promise((resolve, reject) => {
|
|
94
98
|
this.resolveExternalDomains = resolve;
|
|
95
|
-
|
|
99
|
+
this.appIntegration.getExternalDomains();
|
|
96
100
|
});
|
|
97
101
|
}
|
|
98
102
|
getExternalDomainsResult(result) {
|
|
99
103
|
this.resolveExternalDomains(result);
|
|
104
|
+
this.resolveExternalDomains = null;
|
|
100
105
|
}
|
|
101
106
|
appInForegroundEventRecievedEvent() {
|
|
102
107
|
this.dispatchEvent(new CustomEvent('appInForeground'));
|
|
103
108
|
}
|
|
104
109
|
brandIdResult(result) {
|
|
105
110
|
this.resolveBrandId(result);
|
|
111
|
+
this.resolveBrandId = null;
|
|
106
112
|
}
|
|
107
113
|
versionResult(result) {
|
|
108
114
|
this.resolveVersion(result);
|
|
115
|
+
this.resolveVersion = null;
|
|
109
116
|
}
|
|
110
117
|
deviceIdResult(result) {
|
|
111
118
|
this.resolveDeviceId(result);
|
|
119
|
+
this.resolveDeviceId = null;
|
|
112
120
|
}
|
|
113
121
|
setSafeAreaBackgroundColorResult(result) {
|
|
114
122
|
this.resolveSetSafeAreaBackgroundColor(result);
|
|
123
|
+
this.resolveSetSafeAreaBackgroundColor = null;
|
|
115
124
|
}
|
|
116
125
|
navigatingPageEvent(result) {
|
|
117
126
|
this.dispatchEvent(new CustomEvent('navigatingPage', { detail: result }));
|
|
118
127
|
}
|
|
119
128
|
getInternalDomainsResult(result) {
|
|
120
129
|
this.resolveGetInternalDomains(result);
|
|
130
|
+
this.resolveGetInternalDomains = null;
|
|
121
131
|
}
|
|
122
132
|
}
|
|
123
133
|
;
|
package/dist/biometrics.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Biometrics = void 0;
|
|
4
|
+
const getIntegration_1 = require("./getIntegration");
|
|
4
5
|
class BiometricsClass extends EventTarget {
|
|
5
6
|
constructor() {
|
|
6
7
|
super(...arguments);
|
|
@@ -9,57 +10,60 @@ class BiometricsClass extends EventTarget {
|
|
|
9
10
|
this.defaultScanTitle = "Prove you have fingers!";
|
|
10
11
|
this.defaultScanReason = "Can't let you in if you don't.";
|
|
11
12
|
}
|
|
13
|
+
get biometricIntegration() {
|
|
14
|
+
return (0, getIntegration_1.getIntegration)('BiometricIntegration');
|
|
15
|
+
}
|
|
12
16
|
scan(title = this.defaultScanTitle, reason = this.defaultScanReason) {
|
|
13
17
|
const promise = new Promise((resolve, reject) => {
|
|
14
18
|
this.resolveScan = resolve;
|
|
15
|
-
|
|
19
|
+
this.biometricIntegration.startScanning(title, reason);
|
|
16
20
|
});
|
|
17
21
|
return promise;
|
|
18
22
|
}
|
|
19
23
|
getAuthenticationType() {
|
|
20
24
|
const promise = new Promise((resolve, reject) => {
|
|
21
25
|
this.resolveAuthType = resolve;
|
|
22
|
-
|
|
26
|
+
this.biometricIntegration.getAuthenticationType();
|
|
23
27
|
});
|
|
24
28
|
return promise;
|
|
25
29
|
}
|
|
26
30
|
setSecuredContent(content) {
|
|
27
|
-
|
|
31
|
+
this.biometricIntegration.setSecuredContent(this.SECURED_CONTENT_KEY, JSON.stringify(content));
|
|
28
32
|
}
|
|
29
33
|
getSecuredContent(title = this.defaultScanTitle, reason = this.defaultScanReason) {
|
|
30
34
|
const promise = new Promise((resolve, reject) => {
|
|
31
35
|
this.resolveGetContent = resolve;
|
|
32
|
-
|
|
36
|
+
this.biometricIntegration.getSecuredContent(this.SECURED_CONTENT_KEY, title, reason);
|
|
33
37
|
});
|
|
34
38
|
return promise;
|
|
35
39
|
}
|
|
36
40
|
hasSecuredContent() {
|
|
37
41
|
const promise = new Promise((resolve, reject) => {
|
|
38
42
|
this.resolveHasSecureContent = resolve;
|
|
39
|
-
|
|
43
|
+
this.biometricIntegration.hasSecuredContent(this.SECURED_CONTENT_KEY);
|
|
40
44
|
});
|
|
41
45
|
return promise;
|
|
42
46
|
}
|
|
43
47
|
removeSecuredContent() {
|
|
44
|
-
|
|
48
|
+
this.biometricIntegration.removeSecuredContent(this.SECURED_CONTENT_KEY);
|
|
45
49
|
}
|
|
46
50
|
setUsernameAndPassword(username, password) {
|
|
47
|
-
|
|
51
|
+
this.biometricIntegration.setSecuredContent(this.SECURED_LOGIN_KEY, JSON.stringify({ username, password }));
|
|
48
52
|
}
|
|
49
53
|
removeUsernameAndPassword() {
|
|
50
|
-
|
|
54
|
+
this.biometricIntegration.removeSecuredContent(this.SECURED_LOGIN_KEY);
|
|
51
55
|
}
|
|
52
56
|
hasUsernameAndPassword() {
|
|
53
57
|
const promise = new Promise((resolve, reject) => {
|
|
54
58
|
this.resolveHasUsernameAndPassword = resolve;
|
|
55
|
-
|
|
59
|
+
this.biometricIntegration.hasSecuredContent(this.SECURED_LOGIN_KEY);
|
|
56
60
|
});
|
|
57
61
|
return promise;
|
|
58
62
|
}
|
|
59
63
|
getUsernameAndPassword(scanTitle = this.defaultScanTitle, scanReason = this.defaultScanReason) {
|
|
60
64
|
const promise = new Promise((resolve, reject) => {
|
|
61
65
|
this.resolveGetUsernamePassword = resolve;
|
|
62
|
-
|
|
66
|
+
this.biometricIntegration.getSecuredContent(this.SECURED_LOGIN_KEY, scanTitle, scanReason);
|
|
63
67
|
});
|
|
64
68
|
return promise;
|
|
65
69
|
}
|
|
@@ -74,19 +78,24 @@ class BiometricsClass extends EventTarget {
|
|
|
74
78
|
catch (error) {
|
|
75
79
|
this.resolveGetUsernamePassword(null);
|
|
76
80
|
}
|
|
81
|
+
this.resolveGetUsernamePassword = null;
|
|
77
82
|
}
|
|
78
83
|
hasSecuredContentResult({ result, key }) {
|
|
79
84
|
if (key === this.SECURED_LOGIN_KEY) {
|
|
80
85
|
this.resolveHasUsernameAndPassword(result);
|
|
86
|
+
this.resolveHasUsernameAndPassword = null;
|
|
81
87
|
return;
|
|
82
88
|
}
|
|
83
89
|
this.resolveHasSecureContent(result);
|
|
90
|
+
this.resolveHasSecureContent = null;
|
|
84
91
|
}
|
|
85
92
|
getAuthenticationTypeResult(result) {
|
|
86
93
|
this.resolveAuthType(result);
|
|
94
|
+
this.resolveAuthType = null;
|
|
87
95
|
}
|
|
88
96
|
startScanningResult(result) {
|
|
89
97
|
this.resolveScan(result);
|
|
98
|
+
this.resolveScan = null;
|
|
90
99
|
}
|
|
91
100
|
getSecuredContentResult(result) {
|
|
92
101
|
if (result.key === this.SECURED_LOGIN_KEY) {
|
|
@@ -100,6 +109,7 @@ class BiometricsClass extends EventTarget {
|
|
|
100
109
|
catch (error) {
|
|
101
110
|
this.resolveGetContent(result.result);
|
|
102
111
|
}
|
|
112
|
+
this.resolveGetContent = null;
|
|
103
113
|
}
|
|
104
114
|
}
|
|
105
115
|
;
|
package/dist/device.js
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Device = void 0;
|
|
4
|
+
const getIntegration_1 = require("./getIntegration");
|
|
4
5
|
class DeviceClass extends EventTarget {
|
|
6
|
+
get deviceIntegration() {
|
|
7
|
+
return (0, getIntegration_1.getIntegration)('DeviceIntegration');
|
|
8
|
+
}
|
|
5
9
|
startAccelerometer() {
|
|
6
|
-
|
|
10
|
+
this.deviceIntegration.startAccelerometer();
|
|
7
11
|
}
|
|
8
12
|
stopAccelerometer() {
|
|
9
|
-
|
|
13
|
+
this.deviceIntegration.stopAccelerometer();
|
|
10
14
|
}
|
|
11
15
|
isAccelerometerStarted() {
|
|
12
16
|
return new Promise((resolve, _) => {
|
|
13
|
-
|
|
17
|
+
this.deviceIntegration.isAccelerometerStarted();
|
|
14
18
|
this.resolveIsAccelerometerStarted = resolve;
|
|
15
19
|
});
|
|
16
20
|
}
|
|
17
21
|
isAccelerometerStartedResult(result) {
|
|
18
22
|
this.resolveIsAccelerometerStarted(result);
|
|
23
|
+
this.resolveIsAccelerometerStarted = null;
|
|
19
24
|
}
|
|
20
25
|
onShakeEvent() {
|
|
21
26
|
this.dispatchEvent(new CustomEvent('shake'));
|
package/dist/getIntegration.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
declare type Integrations =
|
|
2
|
-
|
|
1
|
+
declare type Integrations = {
|
|
2
|
+
"AppIntegration": typeof AppIntegration;
|
|
3
|
+
"DeviceIntegration": typeof DeviceIntegration;
|
|
4
|
+
"QrScannerIntegration": typeof QrScannerIntegration;
|
|
5
|
+
"BiometricIntegration": typeof BiometricIntegration;
|
|
6
|
+
"CalendarIntegration": typeof CalendarIntegration;
|
|
7
|
+
"NFCIntegration": typeof NFCIntegration;
|
|
8
|
+
"PushNotificationIntegration": typeof PushNotificationIntegration;
|
|
9
|
+
};
|
|
10
|
+
export declare function getIntegration<T extends keyof Integrations>(integration: T): Integrations[T];
|
|
3
11
|
export {};
|
package/dist/getIntegration.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// Attept to get integration from window or window.parent to a max depth of X
|
|
3
|
+
// This is needed because the integrations are not injected into iframes
|
|
2
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
5
|
exports.getIntegration = void 0;
|
|
4
6
|
let integrationCache = {};
|
|
5
7
|
function getIntegration(integration) {
|
|
6
|
-
if (integrationCache[integration])
|
|
8
|
+
if (integrationCache[integration])
|
|
7
9
|
return integrationCache[integration];
|
|
8
|
-
}
|
|
9
10
|
const MAX_DEPTH = 5;
|
|
10
11
|
let integrationObject = window[integration];
|
|
11
12
|
let depth = 0;
|
|
@@ -13,9 +14,8 @@ function getIntegration(integration) {
|
|
|
13
14
|
integrationObject = window.parent[integration];
|
|
14
15
|
depth++;
|
|
15
16
|
}
|
|
16
|
-
if (!integrationObject)
|
|
17
|
+
if (!integrationObject)
|
|
17
18
|
throw new Error(`Could not find integration ${integration}`);
|
|
18
|
-
}
|
|
19
19
|
integrationCache[integration] = integrationObject;
|
|
20
20
|
return integrationObject;
|
|
21
21
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
1
|
declare class StartiappClass extends EventTarget {
|
|
2
|
+
get appIntegration(): {
|
|
3
|
+
download(url: string, filename: string): void;
|
|
4
|
+
openBrowser(url: string): void;
|
|
5
|
+
setAppUrl(url: string): void;
|
|
6
|
+
resetAppUrl(): void;
|
|
7
|
+
webAppIsReady(): void;
|
|
8
|
+
addExternalDomains(domains: ExternalDomain[]): void;
|
|
9
|
+
removeExternalDomains(domains: ExternalDomain[]): void;
|
|
10
|
+
getExternalDomains(): void;
|
|
11
|
+
disableScreenRotation(): void;
|
|
12
|
+
enableScreenRotation(): void;
|
|
13
|
+
getInternalDomains(): void;
|
|
14
|
+
addInternalDomain(domain: string): void;
|
|
15
|
+
removeInternalDomain(domain: string): void;
|
|
16
|
+
setSafeAreaBackgroundColor(color: string): void;
|
|
17
|
+
hideStatusBar(): void;
|
|
18
|
+
showStatusBar(): void;
|
|
19
|
+
requestReview(): void;
|
|
20
|
+
brandId(): void;
|
|
21
|
+
deviceId(): void;
|
|
22
|
+
version(): void;
|
|
23
|
+
};
|
|
2
24
|
/** Basic calls to the app. */
|
|
3
25
|
App: import("./app").IApp;
|
|
4
26
|
/** Access to device functionality. */
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ const app_1 = require("./app");
|
|
|
4
4
|
const biometrics_1 = require("./biometrics");
|
|
5
5
|
const clientUser_1 = require("./clientUser");
|
|
6
6
|
const device_1 = require("./device");
|
|
7
|
+
const getIntegration_1 = require("./getIntegration");
|
|
7
8
|
const nfc_1 = require("./nfc");
|
|
8
9
|
const pushnotification_1 = require("./pushnotification");
|
|
9
10
|
const qrscanner_1 = require("./qrscanner");
|
|
@@ -41,12 +42,13 @@ class StartiappClass extends EventTarget {
|
|
|
41
42
|
/** The QR- and barcode scanning functionality. */
|
|
42
43
|
this.QrScanner = qrscanner_1.QrScanner;
|
|
43
44
|
}
|
|
45
|
+
get appIntegration() {
|
|
46
|
+
return (0, getIntegration_1.getIntegration)('AppIntegration');
|
|
47
|
+
}
|
|
44
48
|
/** Call this method to initialize the starti.app API integration. This method should be called AFTER all integrations are ready (see onIntegrationsAreReady). */
|
|
45
49
|
initialize(options) {
|
|
46
|
-
if (typeof AppIntegration === 'undefined')
|
|
47
|
-
throw new Error('The starti.app API integration is not available.');
|
|
48
50
|
ui_service_1.AppUI.setOptions(options);
|
|
49
|
-
|
|
51
|
+
this.appIntegration.webAppIsReady();
|
|
50
52
|
}
|
|
51
53
|
/** Call this method to check if the app is running in the starti.app app. */
|
|
52
54
|
isRunningInApp() {
|
package/dist/nfc.js
CHANGED
|
@@ -1,30 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NFC = void 0;
|
|
4
|
+
const getIntegration_1 = require("./getIntegration");
|
|
4
5
|
class NfcClass extends EventTarget {
|
|
6
|
+
get NFCIntegration() {
|
|
7
|
+
return (0, getIntegration_1.getIntegration)('NFCIntegration');
|
|
8
|
+
}
|
|
5
9
|
isNFCSupported() {
|
|
6
10
|
const promise = new Promise((resolve, reject) => {
|
|
7
11
|
this.resolveNFCSupported = resolve;
|
|
8
|
-
NFCIntegration.isNFCSupported();
|
|
12
|
+
this.NFCIntegration.isNFCSupported();
|
|
9
13
|
});
|
|
10
14
|
return promise;
|
|
11
15
|
}
|
|
12
16
|
startNFCReader() {
|
|
13
17
|
const promise = new Promise((resolve, reject) => {
|
|
14
18
|
this.resolveStartNFCReader = resolve;
|
|
15
|
-
NFCIntegration.initNFC();
|
|
19
|
+
this.NFCIntegration.initNFC();
|
|
16
20
|
});
|
|
17
21
|
return promise;
|
|
18
22
|
}
|
|
19
23
|
stopNFCReader() {
|
|
20
24
|
const promise = new Promise((resolve, reject) => {
|
|
21
25
|
this.resolveStopNFCReader = resolve;
|
|
22
|
-
NFCIntegration.stopListening();
|
|
26
|
+
this.NFCIntegration.stopListening();
|
|
23
27
|
});
|
|
24
28
|
return promise;
|
|
25
29
|
}
|
|
26
30
|
stopListeningResult(result) {
|
|
27
31
|
this.resolveStopNFCReader(result);
|
|
32
|
+
this.resolveStopNFCReader = null;
|
|
28
33
|
}
|
|
29
34
|
nfcTagResultRecievedEvent(message) {
|
|
30
35
|
const event = new CustomEvent('nfcTagScanned', {
|
|
@@ -34,9 +39,11 @@ class NfcClass extends EventTarget {
|
|
|
34
39
|
}
|
|
35
40
|
isNFCSupportedResult(result) {
|
|
36
41
|
this.resolveNFCSupported(result);
|
|
42
|
+
this.resolveNFCSupported = null;
|
|
37
43
|
}
|
|
38
44
|
initNFCResult(result) {
|
|
39
45
|
this.resolveStartNFCReader(result);
|
|
46
|
+
this.resolveStartNFCReader = null;
|
|
40
47
|
}
|
|
41
48
|
}
|
|
42
49
|
;
|
package/dist/pushnotification.js
CHANGED
|
@@ -11,25 +11,29 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.PushNotification = void 0;
|
|
13
13
|
const config_1 = require("./config");
|
|
14
|
+
const getIntegration_1 = require("./getIntegration");
|
|
14
15
|
const index_1 = require("./index");
|
|
15
16
|
class PushNotificationClass extends EventTarget {
|
|
17
|
+
get pushNotificationIntegration() {
|
|
18
|
+
return (0, getIntegration_1.getIntegration)('PushNotificationIntegration');
|
|
19
|
+
}
|
|
16
20
|
requestAccess() {
|
|
17
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
22
|
return new Promise((resolve, _) => {
|
|
19
23
|
this.resolveRequestAccess = resolve;
|
|
20
|
-
|
|
24
|
+
this.pushNotificationIntegration.requestAccess();
|
|
21
25
|
});
|
|
22
26
|
});
|
|
23
27
|
}
|
|
24
28
|
getToken() {
|
|
25
29
|
return new Promise((resolve, _) => {
|
|
26
30
|
this.resolveFCMToken = resolve;
|
|
27
|
-
|
|
31
|
+
this.pushNotificationIntegration.getFCMToken();
|
|
28
32
|
});
|
|
29
33
|
}
|
|
30
34
|
subscribeToTopics(topics) {
|
|
31
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
|
|
36
|
+
this.pushNotificationIntegration.firebasePushNotificationSubscribeToTopics(topics);
|
|
33
37
|
const token = yield this.getToken();
|
|
34
38
|
const brandId = yield index_1.default.App.brandId();
|
|
35
39
|
const deviceId = yield index_1.default.App.deviceId();
|
|
@@ -56,7 +60,7 @@ class PushNotificationClass extends EventTarget {
|
|
|
56
60
|
}
|
|
57
61
|
unsubscribeFromTopics(topics) {
|
|
58
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
|
|
63
|
+
this.pushNotificationIntegration.firebasePushNotificationTopicsUnsubscribe(topics);
|
|
60
64
|
const token = yield this.getToken();
|
|
61
65
|
const brandId = yield index_1.default.App.brandId();
|
|
62
66
|
const deviceId = yield index_1.default.App.deviceId();
|
|
@@ -83,9 +87,11 @@ class PushNotificationClass extends EventTarget {
|
|
|
83
87
|
}
|
|
84
88
|
requestAccessResult(accessGranted) {
|
|
85
89
|
this.resolveRequestAccess(accessGranted);
|
|
90
|
+
this.resolveRequestAccess = null;
|
|
86
91
|
}
|
|
87
92
|
getFCMTokenResult(token) {
|
|
88
93
|
this.resolveFCMToken(token);
|
|
94
|
+
this.resolveFCMToken = null;
|
|
89
95
|
}
|
|
90
96
|
tokenReceivedEvent(token) {
|
|
91
97
|
this.dispatchEvent(new CustomEvent('tokenRefreshed', { detail: token }));
|
package/dist/qrscanner.js
CHANGED
|
@@ -26,12 +26,15 @@ class QrScannerClass extends EventTarget {
|
|
|
26
26
|
}
|
|
27
27
|
requestCameraAccessResult(result) {
|
|
28
28
|
this.resolveRequestCameraAccess(result);
|
|
29
|
+
this.resolveRequestCameraAccess = null;
|
|
29
30
|
}
|
|
30
31
|
startQrCodeScannerResult(message) {
|
|
31
32
|
this.resolveScan(message);
|
|
33
|
+
this.resolveScan = null;
|
|
32
34
|
}
|
|
33
35
|
isCameraAccessGrantedResult(result) {
|
|
34
36
|
this.resolveCameraAccessGranted(result);
|
|
37
|
+
this.resolveCameraAccessGranted = null;
|
|
35
38
|
}
|
|
36
39
|
}
|
|
37
40
|
;
|
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;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,r)=>{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,r)=>{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,r)=>{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({result:e,key:t}){t!==this.SECURED_LOGIN_KEY?this.resolveHasSecureContent(e):this.resolveHasUsernameAndPassword(e)}getAuthenticationTypeResult(e){this.resolveAuthType(e)}startScanningResult(e){this.resolveScan(e)}getSecuredContentResult(e){if(e.key!==this.SECURED_LOGIN_KEY)try{const t=JSON.parse(e.result);this.resolveGetContent(t)}catch(t){this.resolveGetContent(e.result)}else this.handleResolveGetUsernamePassword(e)}}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(i,s){function o(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(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((r=r.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ClientUser=void 0;const i=n(913),s=n(607);t.ClientUser=new class extends EventTarget{registerId(e){return r(this,void 0,void 0,(function*(){const t=yield s.default.App.brandId(),n=yield s.default.App.deviceId(),r=yield s.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(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()}isAccelerometerStarted(){return new Promise(((e,t)=>{DeviceIntegration.isAccelerometerStarted(),this.resolveIsAccelerometerStarted=e}))}isAccelerometerStartedResult(e){this.resolveIsAccelerometerStarted(e)}onShakeEvent(){this.dispatchEvent(new CustomEvent("shake"))}}t.Device=new n},900:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getIntegration=void 0;let n={};t.getIntegration=function(e){if(n[e])return n[e];let t=window[e],r=0;for(;!t&&r<5;)t=window.parent[e],r++;if(!t)throw new Error(`Could not find integration ${e}`);return n[e]=t,t}},607:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});const r=n(752),i=n(1),s=n(495),o=n(955),a=n(983),c=n(681),l=n(952),d=n(716),u=window;u.appIntegrationsAreReady=()=>{r.App.setStartiappIsLoaded(),h.dispatchEvent(new CustomEvent("ready"))},u.startiappDevice=o.Device,u.startiappApp=r.App,u.startiappUser=s.ClientUser,u.startiappQrScanner=l.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=r.App,this.Device=o.Device,this.Biometrics=i.Biometrics,this.User=s.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 r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,s){function o(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(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((r=r.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.PushNotification=void 0;const i=n(913),s=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 s.default.App.brandId(),r=yield s.default.App.deviceId(),o=[];e.forEach((e=>{const s={brand:n,topic:e,token:t,deviceId:r},a=fetch(i.baseUrl+"/PushNotification-subscribeToTopic",{body:JSON.stringify(s)});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 s.default.App.brandId(),r=yield s.default.App.deviceId(),o=[];e.forEach((e=>{const s={brand:n,topic:e,token:t,deviceId:r},a=fetch(i.baseUrl+"/PushNotification-unSubscribeFromTopic",{body:JSON.stringify(s)});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,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.QrScanner=void 0;const r=n(900);class i extends EventTarget{get qrScannerIntegration(){return(0,r.getIntegration)("QrScannerIntegration")}scan(){return new Promise(((e,t)=>{this.resolveScan=e,this.qrScannerIntegration.startQrCodeScanner()}))}isCameraAccessGranted(){return new Promise(((e,t)=>{this.resolveCameraAccessGranted=e,this.qrScannerIntegration.isCameraAccessGranted()}))}requestCameraAccess(){return new Promise(((e,t)=>{this.resolveRequestCameraAccess=e,this.qrScannerIntegration.requestCameraAccess()}))}requestCameraAccessResult(e){this.resolveRequestCameraAccess(e)}startQrCodeScannerResult(e){this.resolveScan(e)}isCameraAccessGrantedResult(e){this.resolveCameraAccessGranted(e)}}t.QrScanner=new i},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 s=document.createElement("style");s.textContent=this.styleString,s.setAttribute("id",r.styleTagId),document.body.appendChild(s)}}}},t={};return function n(r){var i=t[r];if(void 0!==i)return i.exports;var s=t[r]={exports:{}};return e[r].call(s.exports,s,s.exports,n),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 s in n)("object"==typeof exports?exports:e)[s]=n[s]}}(self,(()=>(()=>{"use strict";var e={752:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.App=void 0;const s=n(900);class r extends EventTarget{constructor(){super(...arguments),this.startiappIsLoaded=!1}get appIntegration(){return(0,s.getIntegration)("AppIntegration")}setStartiappIsLoaded(){this.startiappIsLoaded=!0}isStartiappLoaded(){return this.startiappIsLoaded}setAppUrl(e){this.appIntegration.setAppUrl(e)}resetAppUrl(){this.appIntegration.resetAppUrl()}openExternalBrowser(e){this.appIntegration.openBrowser(e)}downloadFile(e,t){this.appIntegration.download(e,t)}brandId(){return new Promise(((e,t)=>{this.resolveBrandId=e,this.appIntegration.brandId()}))}requestReview(){this.appIntegration.requestReview()}deviceId(){return new Promise(((e,t)=>{this.resolveDeviceId=e,this.appIntegration.deviceId()}))}version(){return new Promise(((e,t)=>{this.resolveVersion=e,this.appIntegration.version()}))}getInternalDomains(){return new Promise(((e,t)=>{this.resolveGetInternalDomains=e,this.appIntegration.getInternalDomains()}))}addInternalDomain(e){this.appIntegration.addInternalDomain(e)}removeInternalDomain(e){this.appIntegration.removeInternalDomain(e)}showStatusBar(){this.appIntegration.showStatusBar()}hideStatusBar(){this.appIntegration.hideStatusBar()}setSafeAreaBackgroundColor(e){return new Promise(((t,n)=>{this.resolveSetSafeAreaBackgroundColor=t,this.appIntegration.setSafeAreaBackgroundColor(e)}))}disableScreenRotation(){this.appIntegration.disableScreenRotation()}enableScreenRotation(){this.appIntegration.enableScreenRotation()}addExternalDomains(...e){let t=e.map((e=>({pattern:e.source,flags:e.flags})));this.appIntegration.addExternalDomains(t)}removeExternalDomains(...e){let t=e.map((e=>({pattern:e.source,flags:e.flags})));this.appIntegration.removeExternalDomains(t)}getExternalDomains(){return new Promise(((e,t)=>{this.resolveExternalDomains=e,this.appIntegration.getExternalDomains()}))}getExternalDomainsResult(e){this.resolveExternalDomains(e),this.resolveExternalDomains=null}appInForegroundEventRecievedEvent(){this.dispatchEvent(new CustomEvent("appInForeground"))}brandIdResult(e){this.resolveBrandId(e),this.resolveBrandId=null}versionResult(e){this.resolveVersion(e),this.resolveVersion=null}deviceIdResult(e){this.resolveDeviceId(e),this.resolveDeviceId=null}setSafeAreaBackgroundColorResult(e){this.resolveSetSafeAreaBackgroundColor(e),this.resolveSetSafeAreaBackgroundColor=null}navigatingPageEvent(e){this.dispatchEvent(new CustomEvent("navigatingPage",{detail:e}))}getInternalDomainsResult(e){this.resolveGetInternalDomains(e),this.resolveGetInternalDomains=null}}t.App=new r},1:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Biometrics=void 0;const s=n(900);class r extends EventTarget{constructor(){super(...arguments),this.SECURED_CONTENT_KEY="STARTI_APP_BIOMETRIC_CONTENT",this.SECURED_LOGIN_KEY="STARTI_APP_BIOMETRIC_LOGIN_CONTENT",this.defaultScanTitle="Prove you have fingers!",this.defaultScanReason="Can't let you in if you don't."}get biometricIntegration(){return(0,s.getIntegration)("BiometricIntegration")}scan(e=this.defaultScanTitle,t=this.defaultScanReason){return new Promise(((n,s)=>{this.resolveScan=n,this.biometricIntegration.startScanning(e,t)}))}getAuthenticationType(){return new Promise(((e,t)=>{this.resolveAuthType=e,this.biometricIntegration.getAuthenticationType()}))}setSecuredContent(e){this.biometricIntegration.setSecuredContent(this.SECURED_CONTENT_KEY,JSON.stringify(e))}getSecuredContent(e=this.defaultScanTitle,t=this.defaultScanReason){return new Promise(((n,s)=>{this.resolveGetContent=n,this.biometricIntegration.getSecuredContent(this.SECURED_CONTENT_KEY,e,t)}))}hasSecuredContent(){return new Promise(((e,t)=>{this.resolveHasSecureContent=e,this.biometricIntegration.hasSecuredContent(this.SECURED_CONTENT_KEY)}))}removeSecuredContent(){this.biometricIntegration.removeSecuredContent(this.SECURED_CONTENT_KEY)}setUsernameAndPassword(e,t){this.biometricIntegration.setSecuredContent(this.SECURED_LOGIN_KEY,JSON.stringify({username:e,password:t}))}removeUsernameAndPassword(){this.biometricIntegration.removeSecuredContent(this.SECURED_LOGIN_KEY)}hasUsernameAndPassword(){return new Promise(((e,t)=>{this.resolveHasUsernameAndPassword=e,this.biometricIntegration.hasSecuredContent(this.SECURED_LOGIN_KEY)}))}getUsernameAndPassword(e=this.defaultScanTitle,t=this.defaultScanReason){return new Promise(((n,s)=>{this.resolveGetUsernamePassword=n,this.biometricIntegration.getSecuredContent(this.SECURED_LOGIN_KEY,e,t)}))}handleResolveGetUsernamePassword(e){try{const t=JSON.parse(e.result);this.resolveGetUsernamePassword(t)}catch(e){this.resolveGetUsernamePassword(null)}this.resolveGetUsernamePassword=null}hasSecuredContentResult({result:e,key:t}){if(t===this.SECURED_LOGIN_KEY)return this.resolveHasUsernameAndPassword(e),void(this.resolveHasUsernameAndPassword=null);this.resolveHasSecureContent(e),this.resolveHasSecureContent=null}getAuthenticationTypeResult(e){this.resolveAuthType(e),this.resolveAuthType=null}startScanningResult(e){this.resolveScan(e),this.resolveScan=null}getSecuredContentResult(e){if(e.key!==this.SECURED_LOGIN_KEY){try{const t=JSON.parse(e.result);this.resolveGetContent(t)}catch(t){this.resolveGetContent(e.result)}this.resolveGetContent=null}else this.handleResolveGetUsernamePassword(e)}}t.Biometrics=new r},495:function(e,t,n){var s=this&&this.__awaiter||function(e,t,n,s){return new(n||(n=Promise))((function(r,i){function o(e){try{l(s.next(e))}catch(e){i(e)}}function a(e){try{l(s.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}l((s=s.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ClientUser=void 0;const r=n(913),i=n(607);t.ClientUser=new class extends EventTarget{registerId(e){return s(this,void 0,void 0,(function*(){const t=yield i.default.App.brandId(),n=yield i.default.App.deviceId(),s=yield i.default.PushNotification.getToken();if(!s||0===s.length)throw console.warn("Failed to register logged in client user",e,"No FCM token"),new Error(`Failed to register logged in client user ${e}: No FCM token`);const o={brandId:t,clientUserId:e,deviceId:n,fcmToken:s},a=yield fetch(r.baseUrl+"/ClientUser-registerId",{body:JSON.stringify(o),headers:{"Content-Type":"application/json"},method:"POST"});if(!a.ok)throw console.warn("Failed to register logged in client user",e,o),new Error(`Failed to register logged in client user ${e}: Firebase returned statuscode ${a.status}`)}))}}},913:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.styleTagId=t.baseUrl=void 0,t.baseUrl="https://europe-west3-startiapp-admin-1fac2.cloudfunctions.net",t.styleTagId="startiapp-styling"},955:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Device=void 0;const s=n(900);class r extends EventTarget{get deviceIntegration(){return(0,s.getIntegration)("DeviceIntegration")}startAccelerometer(){this.deviceIntegration.startAccelerometer()}stopAccelerometer(){this.deviceIntegration.stopAccelerometer()}isAccelerometerStarted(){return new Promise(((e,t)=>{this.deviceIntegration.isAccelerometerStarted(),this.resolveIsAccelerometerStarted=e}))}isAccelerometerStartedResult(e){this.resolveIsAccelerometerStarted(e),this.resolveIsAccelerometerStarted=null}onShakeEvent(){this.dispatchEvent(new CustomEvent("shake"))}}t.Device=new r},900:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getIntegration=void 0;let n={};t.getIntegration=function(e){if(n[e])return n[e];let t=window[e],s=0;for(;!t&&s<5;)t=window.parent[e],s++;if(!t)throw new Error(`Could not find integration ${e}`);return n[e]=t,t}},607:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});const s=n(752),r=n(1),i=n(495),o=n(955),a=n(900),l=n(983),c=n(681),d=n(952),u=n(716),p=window;p.appIntegrationsAreReady=()=>{s.App.setStartiappIsLoaded(),v.dispatchEvent(new CustomEvent("ready"))},p.startiappDevice=o.Device,p.startiappApp=s.App,p.startiappUser=i.ClientUser,p.startiappQrScanner=d.QrScanner,p.startiappPushNotification=c.PushNotification,p.startiappNFC=l.NFC,p.startiappBiometric=r.Biometrics,p.appErrorEvent=e=>{v.dispatchEvent(new CustomEvent("error",{detail:e}))};class h extends EventTarget{constructor(){super(...arguments),this.App=s.App,this.Device=o.Device,this.Biometrics=r.Biometrics,this.User=i.ClientUser,this.Nfc=l.NFC,this.PushNotification=c.PushNotification,this.QrScanner=d.QrScanner}get appIntegration(){return(0,a.getIntegration)("AppIntegration")}initialize(e){u.AppUI.setOptions(e),this.appIntegration.webAppIsReady()}isRunningInApp(){return navigator.userAgent.toLowerCase().indexOf("starti.app")>-1}addEventListener(e,t,n){super.addEventListener(e,t,n)}removeEventListener(e,t,n){super.removeEventListener(e,t,n)}}const v=new h;if(v.isRunningInApp())if(document.body)document.body.setAttribute("startiapp","true");else{const e=new MutationObserver((()=>{document.body&&(document.body.setAttribute("startiapp","true"),e.disconnect())}));e.observe(document.documentElement,{childList:!0})}t.default=v,p.startiapp=v},983:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NFC=void 0;const s=n(900);class r extends EventTarget{get NFCIntegration(){return(0,s.getIntegration)("NFCIntegration")}isNFCSupported(){return new Promise(((e,t)=>{this.resolveNFCSupported=e,this.NFCIntegration.isNFCSupported()}))}startNFCReader(){return new Promise(((e,t)=>{this.resolveStartNFCReader=e,this.NFCIntegration.initNFC()}))}stopNFCReader(){return new Promise(((e,t)=>{this.resolveStopNFCReader=e,this.NFCIntegration.stopListening()}))}stopListeningResult(e){this.resolveStopNFCReader(e),this.resolveStopNFCReader=null}nfcTagResultRecievedEvent(e){const t=new CustomEvent("nfcTagScanned",{detail:e});this.dispatchEvent(t)}isNFCSupportedResult(e){this.resolveNFCSupported(e),this.resolveNFCSupported=null}initNFCResult(e){this.resolveStartNFCReader(e),this.resolveStartNFCReader=null}}t.NFC=new r},681:function(e,t,n){var s=this&&this.__awaiter||function(e,t,n,s){return new(n||(n=Promise))((function(r,i){function o(e){try{l(s.next(e))}catch(e){i(e)}}function a(e){try{l(s.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}l((s=s.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.PushNotification=void 0;const r=n(913),i=n(900),o=n(607);class a extends EventTarget{get pushNotificationIntegration(){return(0,i.getIntegration)("PushNotificationIntegration")}requestAccess(){return s(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.resolveRequestAccess=e,this.pushNotificationIntegration.requestAccess()}))}))}getToken(){return new Promise(((e,t)=>{this.resolveFCMToken=e,this.pushNotificationIntegration.getFCMToken()}))}subscribeToTopics(e){return s(this,void 0,void 0,(function*(){this.pushNotificationIntegration.firebasePushNotificationSubscribeToTopics(e);const t=yield this.getToken(),n=yield o.default.App.brandId(),s=yield o.default.App.deviceId(),i=[];e.forEach((e=>{const o={brand:n,topic:e,token:t,deviceId:s},a=fetch(r.baseUrl+"/PushNotification-subscribeToTopic",{body:JSON.stringify(o)});i.push(a)})),(yield Promise.all(i)).forEach(((t,n)=>{t.ok||console.warn("Failed to sign up to topic",n,e[n])}))}))}unsubscribeFromTopics(e){return s(this,void 0,void 0,(function*(){this.pushNotificationIntegration.firebasePushNotificationTopicsUnsubscribe(e);const t=yield this.getToken(),n=yield o.default.App.brandId(),s=yield o.default.App.deviceId(),i=[];e.forEach((e=>{const o={brand:n,topic:e,token:t,deviceId:s},a=fetch(r.baseUrl+"/PushNotification-unSubscribeFromTopic",{body:JSON.stringify(o)});i.push(a)})),(yield Promise.all(i)).forEach(((t,n)=>{t.ok||console.warn("Failed to unsubscribe from topic",n,e[n])}))}))}requestAccessResult(e){this.resolveRequestAccess(e),this.resolveRequestAccess=null}getFCMTokenResult(e){this.resolveFCMToken(e),this.resolveFCMToken=null}tokenReceivedEvent(e){this.dispatchEvent(new CustomEvent("tokenRefreshed",{detail:e}))}notificationReceivedEvent(e){this.dispatchEvent(new CustomEvent("notificationReceived",{detail:e}))}firebasePushNotificationTopicsUnsubscribeResult(e){}firebasePushNotificationSubscribeToTopicsResult(e){}}t.PushNotification=new a},952:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.QrScanner=void 0;const s=n(900);class r extends EventTarget{get qrScannerIntegration(){return(0,s.getIntegration)("QrScannerIntegration")}scan(){return new Promise(((e,t)=>{this.resolveScan=e,this.qrScannerIntegration.startQrCodeScanner()}))}isCameraAccessGranted(){return new Promise(((e,t)=>{this.resolveCameraAccessGranted=e,this.qrScannerIntegration.isCameraAccessGranted()}))}requestCameraAccess(){return new Promise(((e,t)=>{this.resolveRequestCameraAccess=e,this.qrScannerIntegration.requestCameraAccess()}))}requestCameraAccessResult(e){this.resolveRequestCameraAccess(e),this.resolveRequestCameraAccess=null}startQrCodeScannerResult(e){this.resolveScan(e),this.resolveScan=null}isCameraAccessGrantedResult(e){this.resolveCameraAccessGranted(e),this.resolveCameraAccessGranted=null}}t.QrScanner=new r},716:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AppUI=void 0;const s=n(913);t.AppUI=new class{constructor(){this.options={allowDrag:!1,allowHighligt:!1,allowZoom:!1,allowScrollBounce:!1}}setOptions(e){this.options=Object.assign(this.options,e),null!=document.querySelector('meta[name="viewport"]')&&void 0===this.initialViewportMetaContent&&(this.initialViewportMetaContent=document.querySelector('meta[name="viewport"]').getAttribute("content")),this.initialViewportMetaContent.includes("viewport-fit=cover")||(this.initialViewportMetaContent+=", viewport-fit=cover"),this.updateUI()}getOptions(){return this.options}updateUI(){this.styleString="";const e=document.getElementById(s.styleTagId);e&&e.remove();const t=document.getElementsByTagName("img"),n=document.getElementsByTagName("a");this.options.allowDrag?[...t,...n].forEach((e=>{e.removeAttribute("draggable")})):[...t,...n].forEach((e=>{e.setAttribute("draggable","false")}));let r=document.querySelector("meta[name=viewport]");this.options.allowHighligt||(this.styleString+="\n body {\n -webkit-user-select: none; \n -khtml-user-select: none; \n -moz-user-select: none; \n -o-user-select: none; \n user-select: none;\n }\n "),this.options.allowScrollBounce||(this.styleString+="\n html {\n overscroll-behavior: none;\n }\n "),this.options.allowZoom?r.setAttribute("content",this.initialViewportMetaContent):(this.styleString+="\n body {\n touch-action: pan-x pan-y;\n }\n ",r.setAttribute("content","width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, viewport-fit=cover"));const i=document.createElement("style");i.textContent=this.styleString,i.setAttribute("id",s.styleTagId),document.body.appendChild(i)}}}},t={};return function n(s){var r=t[s];if(void 0!==r)return r.exports;var i=t[s]={exports:{}};return e[s].call(i.exports,i,i.exports,n),i.exports}(607)})()));
|