starti.app 1.0.14 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.d.ts +8 -2
- package/dist/app.js +34 -30
- package/dist/biometrics.d.ts +19 -0
- package/dist/biometrics.js +96 -0
- package/dist/index.d.ts +15 -11
- package/dist/index.js +29 -12
- package/dist/nfc.d.ts +13 -0
- package/dist/nfc.js +68 -0
- package/dist/pushnotification.d.ts +4 -4
- package/dist/pushnotification.js +15 -14
- package/dist/qrscanner.d.ts +8 -0
- package/dist/qrscanner.js +45 -9
- package/package.json +2 -2
- package/umd/main.js +1 -1
package/dist/app.d.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
export declare const App: IApp;
|
|
2
|
+
declare type AppEvents = "appInForeground";
|
|
2
3
|
export interface IApp {
|
|
3
|
-
/** The event will be called whenever the app enters the foreground on the device and when the app starts og thus also enters the foreground on the device. */
|
|
4
|
-
onAppInForeground?: () => void;
|
|
5
4
|
/** Are the site running inside starti.app? Returns false if the site is loaded in a normal browser. */
|
|
6
5
|
isStartiappLoaded(): boolean;
|
|
7
6
|
/** Use this method to control which URL the app load when it is initialized. */
|
|
8
7
|
setAppUrl: (url: string) => void;
|
|
9
8
|
/** Returns the version number of the app (eg. 1.0.0). */
|
|
10
9
|
version(): Promise<string>;
|
|
10
|
+
/** Opens the given URL in the default browser. */
|
|
11
|
+
openExternalBrowser: (url: string) => void;
|
|
12
|
+
/** Downloads the given file. */
|
|
13
|
+
downloadFile: (url: string, fileName: string) => void;
|
|
14
|
+
/** Listen for events */
|
|
15
|
+
addEventListener(type: AppEvents, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
11
16
|
}
|
|
17
|
+
export {};
|
package/dist/app.js
CHANGED
|
@@ -1,33 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.App = void 0;
|
|
5
|
-
exports.App =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
4
|
+
exports.App = new class extends EventTarget {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.startiappIsLoaded = false;
|
|
8
|
+
}
|
|
9
|
+
setStartiappIsLoaded() {
|
|
10
|
+
this.startiappIsLoaded = true;
|
|
11
|
+
}
|
|
12
|
+
isStartiappLoaded() {
|
|
13
|
+
return this.startiappIsLoaded;
|
|
14
|
+
}
|
|
15
|
+
setAppUrl(url) {
|
|
16
|
+
AppIntegration.setAppUrl(url);
|
|
17
|
+
}
|
|
18
|
+
version() {
|
|
19
|
+
const promise = new Promise((resolve, reject) => {
|
|
20
|
+
this.resolveVersion = resolve;
|
|
21
|
+
AppIntegration.version();
|
|
22
|
+
});
|
|
23
|
+
return promise;
|
|
24
|
+
}
|
|
25
|
+
appInForegroundEventRecievedEvent() {
|
|
26
|
+
this.dispatchEvent(new CustomEvent('appInForeground'));
|
|
27
|
+
}
|
|
28
|
+
versionResult(result) {
|
|
29
|
+
this.resolveVersion(result);
|
|
30
|
+
}
|
|
31
|
+
openExternalBrowser(url) {
|
|
32
|
+
AppIntegration.openExternalBrowser(url);
|
|
33
|
+
}
|
|
34
|
+
downloadFile(url, fileName) {
|
|
35
|
+
AppIntegration.download(url, fileName);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const Biometrics: IBiometrics;
|
|
2
|
+
declare type BiometricsEvents = "";
|
|
3
|
+
export interface IBiometrics {
|
|
4
|
+
/** Start scanning for biometrics */
|
|
5
|
+
scan(title: string, reason: string): Promise<boolean>;
|
|
6
|
+
/** Get the type of biometrics used */
|
|
7
|
+
getAuthenticationType(): Promise<string>;
|
|
8
|
+
/** Set the content to be secured */
|
|
9
|
+
setSecuredContent(content: string | object): void;
|
|
10
|
+
/** Get the secured content */
|
|
11
|
+
getSecuredContent(title: string, reason: string): Promise<object>;
|
|
12
|
+
/** Check if there is any secured content */
|
|
13
|
+
hasSecureContent(): Promise<boolean>;
|
|
14
|
+
/** Remove the secured content */
|
|
15
|
+
removeSecuredContent(): void;
|
|
16
|
+
/** Listen for biometrics events */
|
|
17
|
+
addEventListener(type: BiometricsEvents, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Biometrics = void 0;
|
|
4
|
+
exports.Biometrics = new class extends EventTarget {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.defaultScanTitle = "Prove you have fingers!";
|
|
8
|
+
this.defaultScanReason = "Can't let you in if you don't.";
|
|
9
|
+
}
|
|
10
|
+
scan(title = this.defaultScanTitle, reason = this.defaultScanReason) {
|
|
11
|
+
const promise = new Promise((resolve, reject) => {
|
|
12
|
+
this.resolveScan = resolve;
|
|
13
|
+
try {
|
|
14
|
+
if (!BiometricsIntegration) {
|
|
15
|
+
reject('Biometrics virker kun i starti.app');
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
BiometricsIntegration.startScanning(title, reason);
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
reject(e);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return promise;
|
|
25
|
+
}
|
|
26
|
+
startScanningResult(result) {
|
|
27
|
+
this.resolveScan(result);
|
|
28
|
+
}
|
|
29
|
+
getAuthenticationType() {
|
|
30
|
+
const promise = new Promise((resolve, reject) => {
|
|
31
|
+
this.resolveAuthType = resolve;
|
|
32
|
+
try {
|
|
33
|
+
if (!BiometricsIntegration) {
|
|
34
|
+
reject('Biometrics virker kun i starti.app');
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
BiometricsIntegration.getAuthenticationType();
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
reject(e);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return promise;
|
|
44
|
+
}
|
|
45
|
+
getAuthenticationTypeResult(result) {
|
|
46
|
+
this.resolveAuthType(result);
|
|
47
|
+
}
|
|
48
|
+
setSecuredContent(content) {
|
|
49
|
+
if (!BiometricsIntegration)
|
|
50
|
+
throw new Error('Biometrics virker kun i starti.app');
|
|
51
|
+
BiometricsIntegration.setSecuredContent(JSON.stringify(content));
|
|
52
|
+
}
|
|
53
|
+
getSecuredContent(title = this.defaultScanTitle, reason = this.defaultScanReason) {
|
|
54
|
+
const promise = new Promise((resolve, reject) => {
|
|
55
|
+
this.resolveGetContent = resolve;
|
|
56
|
+
try {
|
|
57
|
+
if (!BiometricsIntegration) {
|
|
58
|
+
reject('Biometrics virker kun i starti.app');
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
BiometricsIntegration.getSecuredContent(title, reason);
|
|
62
|
+
}
|
|
63
|
+
catch (e) {
|
|
64
|
+
reject(e);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
return promise;
|
|
68
|
+
}
|
|
69
|
+
getSecuredContentResult(result) {
|
|
70
|
+
this.resolveGetContent(JSON.parse(result));
|
|
71
|
+
}
|
|
72
|
+
hasSecureContent() {
|
|
73
|
+
const promise = new Promise((resolve, reject) => {
|
|
74
|
+
this.resolveHasSecureContent = resolve;
|
|
75
|
+
try {
|
|
76
|
+
if (!BiometricsIntegration) {
|
|
77
|
+
reject('Biometrics virker kun i starti.app');
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
BiometricsIntegration.hasSecuredContent();
|
|
81
|
+
}
|
|
82
|
+
catch (e) {
|
|
83
|
+
reject(e);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
return promise;
|
|
87
|
+
}
|
|
88
|
+
hasSecureContentResult(result) {
|
|
89
|
+
this.resolveHasSecureContent(result);
|
|
90
|
+
}
|
|
91
|
+
removeSecuredContent() {
|
|
92
|
+
if (!BiometricsIntegration)
|
|
93
|
+
throw new Error('Biometrics virker kun i starti.app');
|
|
94
|
+
BiometricsIntegration.removeSecuredContent();
|
|
95
|
+
}
|
|
96
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
import { IPushNotification } from './pushnotification';
|
|
3
|
-
import { IQrScanner } from './qrscanner';
|
|
4
|
-
export default class startiapp {
|
|
1
|
+
declare const startiapp: {
|
|
5
2
|
/** Basic calls to the app. */
|
|
6
|
-
|
|
3
|
+
App: import("./app").IApp;
|
|
7
4
|
/** The QR- and barcode scanning functionality. */
|
|
8
|
-
|
|
5
|
+
QrScanner: import("./qrscanner").IQrScanner;
|
|
6
|
+
/** The NFC scanning functionality. */
|
|
7
|
+
NfcScanner: import("./nfc").INFC;
|
|
8
|
+
/** The biomatric functionality. */
|
|
9
|
+
Biometrics: import("./biometrics").IBiometrics;
|
|
9
10
|
/** Access to push notifications using Firebase. */
|
|
10
|
-
|
|
11
|
-
/** When all integrations in the app are ready we should call initialize(). */
|
|
12
|
-
static onIntegrationsAreReady?: () => void;
|
|
11
|
+
PushNotification: import("./pushnotification").IPushNotification;
|
|
13
12
|
/** Call this method to initialize the starti.app API integration. This method should be called AFTER all integrations are ready (see onIntegrationsAreReady). */
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
initialize(): void;
|
|
14
|
+
addEventListener(type: StartiappEvents, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
15
|
+
dispatchEvent(event: Event): boolean;
|
|
16
|
+
removeEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
17
|
+
};
|
|
18
|
+
declare type StartiappEvents = "integrationsAreReady" | "appError";
|
|
19
|
+
export default startiapp;
|
package/dist/index.js
CHANGED
|
@@ -1,30 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const app_1 = require("./app");
|
|
4
|
+
const biometrics_1 = require("./biometrics");
|
|
5
|
+
const nfc_1 = require("./nfc");
|
|
4
6
|
const pushnotification_1 = require("./pushnotification");
|
|
5
7
|
const qrscanner_1 = require("./qrscanner");
|
|
6
8
|
const untypedWindow = window;
|
|
7
9
|
untypedWindow.appIntegrationsAreReady = () => {
|
|
8
10
|
app_1.App.setStartiappIsLoaded();
|
|
9
|
-
|
|
10
|
-
startiapp.onIntegrationsAreReady();
|
|
11
|
+
startiapp.dispatchEvent(new CustomEvent('integrationsAreReady'));
|
|
11
12
|
};
|
|
12
13
|
untypedWindow.App = app_1.App;
|
|
13
14
|
untypedWindow.QrScanner = qrscanner_1.QrScanner;
|
|
14
15
|
untypedWindow.PushNotification = pushnotification_1.PushNotification;
|
|
15
|
-
|
|
16
|
+
untypedWindow.NFC = nfc_1.NFC;
|
|
17
|
+
untypedWindow.Biometrics = biometrics_1.Biometrics;
|
|
18
|
+
untypedWindow.appErrorEvent = (data) => {
|
|
19
|
+
startiapp.dispatchEvent(new CustomEvent('appError', { detail: data }));
|
|
20
|
+
};
|
|
21
|
+
const startiapp = new class extends EventTarget {
|
|
22
|
+
constructor() {
|
|
23
|
+
super(...arguments);
|
|
24
|
+
/** Basic calls to the app. */
|
|
25
|
+
this.App = app_1.App;
|
|
26
|
+
/** The QR- and barcode scanning functionality. */
|
|
27
|
+
this.QrScanner = qrscanner_1.QrScanner;
|
|
28
|
+
/** The NFC scanning functionality. */
|
|
29
|
+
this.NfcScanner = nfc_1.NFC;
|
|
30
|
+
/** The biomatric functionality. */
|
|
31
|
+
this.Biometrics = biometrics_1.Biometrics;
|
|
32
|
+
/** Access to push notifications using Firebase. */
|
|
33
|
+
this.PushNotification = pushnotification_1.PushNotification;
|
|
34
|
+
}
|
|
16
35
|
/** Call this method to initialize the starti.app API integration. This method should be called AFTER all integrations are ready (see onIntegrationsAreReady). */
|
|
17
|
-
|
|
36
|
+
initialize() {
|
|
37
|
+
if (AppIntegration === undefined)
|
|
38
|
+
throw new Error('The starti.app API integration is not available.');
|
|
18
39
|
if (app_1.App.isStartiappLoaded())
|
|
19
|
-
// @ts-ignore
|
|
20
40
|
AppIntegration.webAppIsReady();
|
|
21
41
|
}
|
|
22
|
-
|
|
42
|
+
addEventListener(type, callback, options) {
|
|
43
|
+
super.addEventListener(type, callback, options);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
23
46
|
exports.default = startiapp;
|
|
24
|
-
/** Basic calls to the app. */
|
|
25
|
-
startiapp.App = app_1.App;
|
|
26
|
-
/** The QR- and barcode scanning functionality. */
|
|
27
|
-
startiapp.QrScanner = qrscanner_1.QrScanner;
|
|
28
|
-
/** Access to push notifications using Firebase. */
|
|
29
|
-
startiapp.PushNotification = pushnotification_1.PushNotification;
|
|
30
47
|
untypedWindow.startiapp = startiapp;
|
package/dist/nfc.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const NFC: INFC;
|
|
2
|
+
declare type NFCEvents = "nfcTagScanned";
|
|
3
|
+
export interface INFC {
|
|
4
|
+
/** Listen for events */
|
|
5
|
+
addEventListener(type: NFCEvents, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
6
|
+
/** Check if the device supports NFC */
|
|
7
|
+
isNFCSupported(): Promise<boolean>;
|
|
8
|
+
/** Start scanning for NFC tags */
|
|
9
|
+
startNFCReader(): Promise<StartiappResult>;
|
|
10
|
+
/** Stop scanning for NFC tags */
|
|
11
|
+
stopNFCReader(): Promise<boolean>;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
package/dist/nfc.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NFC = void 0;
|
|
4
|
+
exports.NFC = new class extends EventTarget {
|
|
5
|
+
isNFCSupported() {
|
|
6
|
+
const promise = new Promise((resolve, reject) => {
|
|
7
|
+
this.resolveNFCSupported = resolve;
|
|
8
|
+
try {
|
|
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
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return promise;
|
|
20
|
+
}
|
|
21
|
+
isNFCSupportedResult(result) {
|
|
22
|
+
this.resolveNFCSupported(result);
|
|
23
|
+
}
|
|
24
|
+
startNFCReader() {
|
|
25
|
+
const promise = new Promise((resolve, reject) => {
|
|
26
|
+
this.resolveStartNFCReader = resolve;
|
|
27
|
+
try {
|
|
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
|
+
}
|
|
37
|
+
});
|
|
38
|
+
return promise;
|
|
39
|
+
}
|
|
40
|
+
startNFCReaderResult(result) {
|
|
41
|
+
this.resolveStartNFCReader(result);
|
|
42
|
+
}
|
|
43
|
+
stopNFCReader() {
|
|
44
|
+
const promise = new Promise((resolve, reject) => {
|
|
45
|
+
this.resolveStopNFCReader = resolve;
|
|
46
|
+
try {
|
|
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
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return promise;
|
|
58
|
+
}
|
|
59
|
+
stopListeningResult(result) {
|
|
60
|
+
this.resolveStopNFCReader(result);
|
|
61
|
+
}
|
|
62
|
+
nfcTagResultRecievedEvent(message) {
|
|
63
|
+
const event = new CustomEvent('nfcTagScanned', {
|
|
64
|
+
detail: message,
|
|
65
|
+
});
|
|
66
|
+
this.dispatchEvent(event);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export declare const PushNotification: IPushNotification;
|
|
2
|
+
declare type PushNotificationEvents = "tokenReceived" | "notificationReceived";
|
|
2
3
|
export interface IPushNotification {
|
|
3
|
-
/** Called with the token used to send push notifications to the current device. */
|
|
4
|
-
onTokenReceived?: (token: string) => void;
|
|
5
|
-
/** Called with the notification that has been received by the mobile. The content of notification is the content that has been sent from the backend. There will also be a special property called appWasLaunchedFromNotification which indicated wether the app entered the foreground because a notification as pressed on the device or wether the app already was in the foreground when the notification was received. */
|
|
6
|
-
onNotificationReceived?: (notification: any) => void;
|
|
7
4
|
/** This method should be called when the user want’s to receive push notifications. */
|
|
8
5
|
initialize(): Promise<boolean>;
|
|
9
6
|
/** This method returns the token which should be used to send push notifications. */
|
|
10
7
|
getLastPublishedToken(): Promise<string>;
|
|
8
|
+
/** Listen for events */
|
|
9
|
+
addEventListener(type: PushNotificationEvents, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
11
10
|
}
|
|
11
|
+
export {};
|
package/dist/pushnotification.js
CHANGED
|
@@ -1,36 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PushNotification = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
exports.PushNotification = new class extends EventTarget {
|
|
5
|
+
initialize() {
|
|
6
6
|
const promise = new Promise((resolve, reject) => {
|
|
7
7
|
this.resolveBoolean = resolve;
|
|
8
|
-
// @ts-ignore
|
|
9
8
|
PushNotificationIntegration.initialize();
|
|
10
9
|
});
|
|
11
10
|
return promise;
|
|
12
11
|
}
|
|
13
|
-
|
|
12
|
+
initializeResult(result) {
|
|
14
13
|
this.resolveBoolean(result);
|
|
15
14
|
}
|
|
16
|
-
|
|
15
|
+
getLastPublishedToken() {
|
|
17
16
|
const promise = new Promise((resolve, reject) => {
|
|
18
17
|
this.resolveString = resolve;
|
|
19
|
-
// @ts-ignore
|
|
20
18
|
PushNotificationIntegration.getLastPublishedToken();
|
|
21
19
|
});
|
|
22
20
|
return promise;
|
|
23
21
|
}
|
|
24
|
-
|
|
22
|
+
getLastPublishedTokenResult(token) {
|
|
25
23
|
this.resolveString(token);
|
|
26
24
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
this.onTokenReceived(token);
|
|
25
|
+
tokenReceivedEvent(token) {
|
|
26
|
+
this.dispatchEvent(new CustomEvent('tokenReceived', { detail: token }));
|
|
30
27
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
notificationReceivedEvent(notification) {
|
|
29
|
+
this.dispatchEvent(new CustomEvent('notificationReceived', { detail: notification }));
|
|
30
|
+
}
|
|
31
|
+
subscribeToTopics(topics) {
|
|
32
|
+
PushNotificationIntegration.firebasePushNotificationSubscribeToTopics(topics);
|
|
33
|
+
}
|
|
34
|
+
unsubscribeFromTopics(topics) {
|
|
35
|
+
PushNotificationIntegration.firebasePushNotificationTopicsUnsubscribe(topics);
|
|
34
36
|
}
|
|
35
37
|
};
|
|
36
|
-
exports.PushNotification = PushNotification;
|
package/dist/qrscanner.d.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
export declare const QrScanner: IQrScanner;
|
|
2
|
+
declare type QrScannerEvents = "";
|
|
2
3
|
export interface IQrScanner {
|
|
3
4
|
/** Opens the camera on the phone og starts scanning after QR- and barcodes. When the camera has scanned a code the camera will be closed the user will be back on the website. */
|
|
4
5
|
scan(): Promise<string>;
|
|
6
|
+
/** Listen for events */
|
|
7
|
+
addEventListener(type: QrScannerEvents, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
8
|
+
/** Checks if the phone has granted access to camera */
|
|
9
|
+
isCameraAccessGranted(): Promise<boolean>;
|
|
10
|
+
/** Requests access to the phone camera */
|
|
11
|
+
requestCameraAccess(): Promise<boolean>;
|
|
5
12
|
}
|
|
13
|
+
export {};
|
package/dist/qrscanner.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.QrScanner = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
exports.QrScanner = new class extends EventTarget {
|
|
5
|
+
scan() {
|
|
6
6
|
const promise = new Promise((resolve, reject) => {
|
|
7
|
-
this.
|
|
7
|
+
this.resolveScan = resolve;
|
|
8
8
|
try {
|
|
9
|
-
|
|
10
|
-
if (!qrScannerIntegration) {
|
|
9
|
+
if (!QrScannerIntegration) {
|
|
11
10
|
resolve('Scanner virker kun i starti.app');
|
|
12
11
|
return;
|
|
13
12
|
}
|
|
14
|
-
|
|
13
|
+
QrScannerIntegration.startQrCodeScanner();
|
|
15
14
|
}
|
|
16
15
|
catch (e) {
|
|
17
16
|
reject(e);
|
|
@@ -19,8 +18,45 @@ const QrScanner = class {
|
|
|
19
18
|
});
|
|
20
19
|
return promise;
|
|
21
20
|
}
|
|
22
|
-
|
|
23
|
-
this.
|
|
21
|
+
qrResultRecievedEvent(message) {
|
|
22
|
+
this.resolveScan(message);
|
|
23
|
+
}
|
|
24
|
+
isCameraAccessGranted() {
|
|
25
|
+
const promise = new Promise((resolve, reject) => {
|
|
26
|
+
this.resolveCameraAccessGranted = resolve;
|
|
27
|
+
try {
|
|
28
|
+
if (!QrScannerIntegration) {
|
|
29
|
+
reject('Scanner virker kun i starti.app');
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
QrScannerIntegration.isCameraAccessGranted();
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
reject(e);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
return promise;
|
|
39
|
+
}
|
|
40
|
+
isCameraAccessGrantedResult(result) {
|
|
41
|
+
this.resolveCameraAccessGranted(result);
|
|
42
|
+
}
|
|
43
|
+
requestCameraAccess() {
|
|
44
|
+
const promise = new Promise((resolve, reject) => {
|
|
45
|
+
this.resolveRequestCameraAccess = resolve;
|
|
46
|
+
try {
|
|
47
|
+
if (!QrScannerIntegration) {
|
|
48
|
+
reject('Scanner virker kun i starti.app');
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
QrScannerIntegration.requestCameraAccess();
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
reject(e);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return promise;
|
|
58
|
+
}
|
|
59
|
+
requestCameraAccessResult(result) {
|
|
60
|
+
this.resolveRequestCameraAccess(result);
|
|
24
61
|
}
|
|
25
62
|
};
|
|
26
|
-
exports.QrScanner = QrScanner;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "starti.app",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.16",
|
|
4
4
|
"description": "Use this package for easy communication with the starti.app API.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -21,4 +21,4 @@
|
|
|
21
21
|
"build:prod": "webpack --mode=production --node-env=production",
|
|
22
22
|
"watch": "webpack --watch"
|
|
23
23
|
}
|
|
24
|
-
}
|
|
24
|
+
}
|
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
|
|
1
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var i in r)("object"==typeof exports?exports:e)[i]=r[i]}}(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)}version(){return new Promise(((e,t)=>{this.resolveVersion=e,AppIntegration.version()}))}appInForegroundEventRecievedEvent(){this.dispatchEvent(new CustomEvent("appInForeground"))}versionResult(e){this.resolveVersion(e)}openExternalBrowser(e){AppIntegration.openExternalBrowser(e)}downloadFile(e,t){AppIntegration.download(e,t)}}},1:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Biometrics=void 0,t.Biometrics=new class extends EventTarget{constructor(){super(...arguments),this.defaultScanTitle="Prove you have fingers!",this.defaultScanReason="Can't let you in if you don't."}scan(e=this.defaultScanTitle,t=this.defaultScanReason){return new Promise(((r,i)=>{this.resolveScan=r;try{if(!BiometricsIntegration)return void i("Biometrics virker kun i starti.app");BiometricsIntegration.startScanning(e,t)}catch(e){i(e)}}))}startScanningResult(e){this.resolveScan(e)}getAuthenticationType(){return new Promise(((e,t)=>{this.resolveAuthType=e;try{if(!BiometricsIntegration)return void t("Biometrics virker kun i starti.app");BiometricsIntegration.getAuthenticationType()}catch(e){t(e)}}))}getAuthenticationTypeResult(e){this.resolveAuthType(e)}setSecuredContent(e){if(!BiometricsIntegration)throw new Error("Biometrics virker kun i starti.app");BiometricsIntegration.setSecuredContent(JSON.stringify(e))}getSecuredContent(e=this.defaultScanTitle,t=this.defaultScanReason){return new Promise(((r,i)=>{this.resolveGetContent=r;try{if(!BiometricsIntegration)return void i("Biometrics virker kun i starti.app");BiometricsIntegration.getSecuredContent(e,t)}catch(e){i(e)}}))}getSecuredContentResult(e){this.resolveGetContent(JSON.parse(e))}hasSecureContent(){return new Promise(((e,t)=>{this.resolveHasSecureContent=e;try{if(!BiometricsIntegration)return void t("Biometrics virker kun i starti.app");BiometricsIntegration.hasSecuredContent()}catch(e){t(e)}}))}hasSecureContentResult(e){this.resolveHasSecureContent(e)}removeSecuredContent(){if(!BiometricsIntegration)throw new Error("Biometrics virker kun i starti.app");BiometricsIntegration.removeSecuredContent()}}},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:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PushNotification=void 0,t.PushNotification=new class extends EventTarget{initialize(){return new Promise(((e,t)=>{this.resolveBoolean=e,PushNotificationIntegration.initialize()}))}initializeResult(e){this.resolveBoolean(e)}getLastPublishedToken(){return new Promise(((e,t)=>{this.resolveString=e,PushNotificationIntegration.getLastPublishedToken()}))}getLastPublishedTokenResult(e){this.resolveString(e)}tokenReceivedEvent(e){this.dispatchEvent(new CustomEvent("tokenReceived",{detail:e}))}notificationReceivedEvent(e){this.dispatchEvent(new CustomEvent("notificationReceived",{detail:e}))}subscribeToTopics(e){PushNotificationIntegration.firebasePushNotificationSubscribeToTopics(e)}unsubscribeFromTopics(e){PushNotificationIntegration.firebasePushNotificationTopicsUnsubscribe(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)=>{this.resolveScan=e;try{if(!QrScannerIntegration)return void e("Scanner virker kun i starti.app");QrScannerIntegration.startQrCodeScanner()}catch(e){t(e)}}))}qrResultRecievedEvent(e){this.resolveScan(e)}isCameraAccessGranted(){return new Promise(((e,t)=>{this.resolveCameraAccessGranted=e;try{if(!QrScannerIntegration)return void t("Scanner virker kun i starti.app");QrScannerIntegration.isCameraAccessGranted()}catch(e){t(e)}}))}isCameraAccessGrantedResult(e){this.resolveCameraAccessGranted(e)}requestCameraAccess(){return new Promise(((e,t)=>{this.resolveRequestCameraAccess=e;try{if(!QrScannerIntegration)return void t("Scanner virker kun i starti.app");QrScannerIntegration.requestCameraAccess()}catch(e){t(e)}}))}requestCameraAccessResult(e){this.resolveRequestCameraAccess(e)}}}},t={};function r(i){var n=t[i];if(void 0!==n)return n.exports;var s=t[i]={exports:{}};return e[i](s,s.exports,r),s.exports}var i={};return(()=>{var e=i;Object.defineProperty(e,"__esModule",{value:!0});const t=r(752),n=r(1),s=r(983),o=r(681),a=r(952),c=window;c.appIntegrationsAreReady=()=>{t.App.setStartiappIsLoaded(),u.dispatchEvent(new CustomEvent("integrationsAreReady"))},c.App=t.App,c.QrScanner=a.QrScanner,c.PushNotification=o.PushNotification,c.NFC=s.NFC,c.Biometrics=n.Biometrics,c.appErrorEvent=e=>{u.dispatchEvent(new CustomEvent("appError",{detail:e}))};const u=new class extends EventTarget{constructor(){super(...arguments),this.App=t.App,this.QrScanner=a.QrScanner,this.NfcScanner=s.NFC,this.Biometrics=n.Biometrics,this.PushNotification=o.PushNotification}initialize(){if(void 0===AppIntegration)throw new Error("The starti.app API integration is not available.");t.App.isStartiappLoaded()&&AppIntegration.webAppIsReady()}addEventListener(e,t,r){super.addEventListener(e,t,r)}};e.default=u,c.startiapp=u})(),i})()));
|