@frankieone/one-sdk 0.3.2-rc.4 → 0.4.1-rc.0
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/cjs/modules/common/modules/eventHub.d.ts +1 -1
- package/dist/cjs/modules/common/modules/runIfWhen.d.ts +21 -0
- package/dist/cjs/modules/common/modules/runIfWhen.js +35 -0
- package/dist/cjs/modules/common/modules/runIfWhen.js.map +1 -0
- package/dist/cjs/modules/device/index.js +10 -18
- package/dist/cjs/modules/device/index.js.map +1 -1
- package/dist/cjs/modules/device/types/module.d.ts +4 -2
- package/dist/cjs/modules/device/types/wrapper.d.ts +2 -1
- package/dist/cjs/modules/device/vendors/Sardine.js +1 -0
- package/dist/cjs/modules/device/vendors/Sardine.js.map +1 -1
- package/dist/cjs/modules/index.d.ts +3 -1
- package/dist/cjs/modules/index.js +7 -1
- package/dist/cjs/modules/index.js.map +1 -1
- package/dist/cjs/modules/individual/actions/submit.d.ts +1 -1
- package/dist/commit.txt +1 -1
- package/dist/esm/modules/common/modules/eventHub.d.ts +1 -1
- package/dist/esm/modules/common/modules/runIfWhen.d.ts +21 -0
- package/dist/esm/modules/common/modules/runIfWhen.js +31 -0
- package/dist/esm/modules/common/modules/runIfWhen.js.map +1 -0
- package/dist/esm/modules/device/index.js +10 -18
- package/dist/esm/modules/device/index.js.map +1 -1
- package/dist/esm/modules/device/types/module.d.ts +4 -2
- package/dist/esm/modules/device/types/wrapper.d.ts +2 -1
- package/dist/esm/modules/device/vendors/Sardine.js +1 -0
- package/dist/esm/modules/device/vendors/Sardine.js.map +1 -1
- package/dist/esm/modules/index.d.ts +3 -1
- package/dist/esm/modules/index.js +5 -0
- package/dist/esm/modules/index.js.map +1 -1
- package/dist/esm/modules/individual/actions/submit.d.ts +1 -1
- package/dist/umd/device-sardine.js +1 -1
- package/dist/umd/device-sardine.js.map +1 -1
- package/dist/umd/oneSdk.umd.js +1 -1
- package/dist/umd/oneSdk.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -20,7 +20,7 @@ export declare type CommonEvents = {
|
|
|
20
20
|
}];
|
|
21
21
|
};
|
|
22
22
|
export declare type EventListenerCallback<Arguments extends unknown[]> = (...args: Arguments) => void;
|
|
23
|
-
declare type ExtendedEvents<Events> = Events & CommonEvents;
|
|
23
|
+
export declare type ExtendedEvents<Events> = Events & CommonEvents;
|
|
24
24
|
declare type EventNamesOf<Events extends EventsDictionary> = KeyOf<Events>;
|
|
25
25
|
export declare type EventHub<ModuleEvents extends EventsDictionary = Record<string, unknown[]>> = {
|
|
26
26
|
on: <EventName extends EventNamesOf<ExtendedEvents<ModuleEvents>>>(eventName: EventName, listener: EventListenerCallback<ExtendedEvents<ModuleEvents>[EventName]>) => void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { KeyOf } from "../../../types/index.js";
|
|
2
|
+
import { EventHub, EventsDictionary, ExtendedEvents } from "./eventHub";
|
|
3
|
+
declare type Runnable = <Args extends unknown[], Retype>(...args: Args) => Promise<Retype | void>;
|
|
4
|
+
declare type Options<Callback extends Runnable, Events extends EventsDictionary> = {
|
|
5
|
+
condition: () => boolean;
|
|
6
|
+
run: Callback;
|
|
7
|
+
elseWaitFor: KeyOf<ExtendedEvents<Events>>;
|
|
8
|
+
eventHub: EventHub<Events>;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* runIfWhen
|
|
12
|
+
* - runs the function "run" if "condition" is true,
|
|
13
|
+
* - otherwise it will wait for the event "elseWaitFor" to be emitted by "eventHub" to run the function
|
|
14
|
+
* @param run main function to be run
|
|
15
|
+
* @param condition function returning a boolean
|
|
16
|
+
* @param elseWaitFor string with the name of the event to trigger a retry
|
|
17
|
+
*
|
|
18
|
+
* @returns a function that takes the same parameters as "run" and returns a promise with the same results returned by "run"
|
|
19
|
+
*/
|
|
20
|
+
export declare const runIfWhen: <Callback extends Runnable, Events extends EventsDictionary>(opt: Options<Callback, Events>) => Callback;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// TODO -- decouple it from eventHub
|
|
3
|
+
// TODO -- instead of automatically running the function on the callback event, it should check the condition again
|
|
4
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
5
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
6
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
7
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
8
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
9
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
10
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.runIfWhen = void 0;
|
|
15
|
+
/**
|
|
16
|
+
* runIfWhen
|
|
17
|
+
* - runs the function "run" if "condition" is true,
|
|
18
|
+
* - otherwise it will wait for the event "elseWaitFor" to be emitted by "eventHub" to run the function
|
|
19
|
+
* @param run main function to be run
|
|
20
|
+
* @param condition function returning a boolean
|
|
21
|
+
* @param elseWaitFor string with the name of the event to trigger a retry
|
|
22
|
+
*
|
|
23
|
+
* @returns a function that takes the same parameters as "run" and returns a promise with the same results returned by "run"
|
|
24
|
+
*/
|
|
25
|
+
const runIfWhen = (opt) => ((...args) => new Promise((resolve) => {
|
|
26
|
+
if (opt.condition())
|
|
27
|
+
resolve(opt.run(...args));
|
|
28
|
+
else {
|
|
29
|
+
opt.eventHub.on(opt.elseWaitFor, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
+
resolve(opt.run(...args));
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
}));
|
|
34
|
+
exports.runIfWhen = runIfWhen;
|
|
35
|
+
//# sourceMappingURL=runIfWhen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runIfWhen.js","sourceRoot":"","sources":["../../../../../modules/common/modules/runIfWhen.ts"],"names":[],"mappings":";AAAA,oCAAoC;AACpC,mHAAmH;;;;;;;;;;;;AAYnH;;;;;;;;;GASG;AAEI,MAAM,SAAS,GAAG,CACvB,GAA8B,EACpB,EAAE,CACZ,CAAC,CAAC,GAAG,IAAe,EAAE,EAAE,CACtB,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;IACtB,IAAI,GAAG,CAAC,SAAS,EAAE;QAAE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;SAC1C;QACH,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,GAAS,EAAE;YAC1C,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QAC5B,CAAC,CAAA,CAAC,CAAC;KACJ;AACH,CAAC,CAAC,CAAa,CAAC;AAXP,QAAA,SAAS,aAWF"}
|
|
@@ -78,6 +78,7 @@ exports.deviceModule = {
|
|
|
78
78
|
// Maybe we should just use the one event hub passed in the options object for all the modules of the one sdk?
|
|
79
79
|
const eventHub = (0, common_1.mkEventHub)();
|
|
80
80
|
let vendorContext = null;
|
|
81
|
+
/** Define context methods */
|
|
81
82
|
// main will trigger the following procedure
|
|
82
83
|
// - determine vendor from recipe configuration
|
|
83
84
|
// - load vendor sdk (async)
|
|
@@ -98,28 +99,19 @@ exports.deviceModule = {
|
|
|
98
99
|
return null;
|
|
99
100
|
});
|
|
100
101
|
});
|
|
101
|
-
//
|
|
102
|
+
// const startActivity = async (activityType: ActivityType) => {
|
|
103
|
+
// vendorContext.set("activityType", activityType);
|
|
104
|
+
// };
|
|
105
|
+
/** reemit/map/transform events below */
|
|
106
|
+
// value_set: when the value for a field is confirmed by the vendor wrapper to be set
|
|
102
107
|
eventHub.on("value_set", ({ key, value }) => {
|
|
103
|
-
//
|
|
104
|
-
// reemit event as the more meaninful "activity_started"
|
|
108
|
+
// When activityType is set, emit another more specific event "activity_started"
|
|
105
109
|
if (key === "activityType")
|
|
106
110
|
eventHub.emit("activity_started", { activityType: value });
|
|
107
111
|
});
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (!vendorContext && isConfigurationValid)
|
|
112
|
-
main();
|
|
113
|
-
return Object.assign({}, (0, common_1.mkEventListener)(eventHub));
|
|
112
|
+
return Object.assign(Object.assign({}, (0, common_1.mkEventListener)(eventHub)), {
|
|
113
|
+
// wrap main function to prevent returning a promise
|
|
114
|
+
start: () => void main() });
|
|
114
115
|
},
|
|
115
116
|
};
|
|
116
|
-
const runIfWhen = (opt) => ((...args) => new Promise((resolve) => {
|
|
117
|
-
if (opt.condition())
|
|
118
|
-
resolve(opt.run(...args));
|
|
119
|
-
else {
|
|
120
|
-
opt.eventHub.on(opt.elseWaitFor, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
121
|
-
resolve(opt.run(...args));
|
|
122
|
-
}));
|
|
123
|
-
}
|
|
124
|
-
}));
|
|
125
117
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../modules/device/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../modules/device/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6D;AAE7D,6DAA6D;AAG7D,8CAA4B;AAC5B,0CAAwB;AAExB,MAAM,aAAa,GAAG,CAAO,MAAc,EAA0B,EAAE;IACrE,IAAI,YAAY,CAAC,CAAC,6DAA6D;IAC/E,IAAI,MAAM,KAAK,SAAS;QAAE,YAAY,qDAAU,wCAAwC,CAAC,m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IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;gBAChB,QAAQ,CAAC,IAAI,CAAC,mBAAmB,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;gBACzD,OAAO,OAAO,CAAC;YACjB,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,WAAW,EAAE,EAAE;gBACrB,QAAQ,CAAC,IAAI,CAAC,2BAA2B,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,CAAC;gBAC9E,OAAO,IAAI,CAAC;YACd,CAAC,CAAC,CAAC;QACP,CAAC,CAAA,CAAC;QAEF,gEAAgE;QAChE,qDAAqD;QACrD,KAAK;QAEL,wCAAwC;QAExC,qFAAqF;QACrF,QAAQ,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE;YAC1C,iFAAiF;YACjF,IAAI,GAAG,KAAK,cAAc;gBAAE,QAAQ,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,YAAY,EAAE,KAAqB,EAAE,CAAC,CAAC;QACzG,CAAC,CAAC,CAAC;QAEH,uCACK,IAAA,wBAAe,EAAC,QAAQ,CAAC;YAC5B,oDAAoD;YACpD,KAAK,EAAE,GAAG,EAAE,CAAC,KAAK,IAAI,EAAE,IACxB;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -7,6 +7,8 @@ export interface DeviceModule {
|
|
|
7
7
|
export interface DeviceModuleOptions {
|
|
8
8
|
activityType: ActivityType;
|
|
9
9
|
}
|
|
10
|
-
export declare type DeviceModuleContext = ModuleContext<{
|
|
11
|
-
|
|
10
|
+
export declare type DeviceModuleContext = ModuleContext<{
|
|
11
|
+
start: StartActivityFunction;
|
|
12
|
+
}, Events>;
|
|
13
|
+
export declare type StartActivityFunction = () => Promise<void>;
|
|
12
14
|
export declare type EndActivityFunction = () => Promise<void>;
|
|
@@ -2,6 +2,7 @@ import { EventHub } from "../../common";
|
|
|
2
2
|
import { BaseModuleOptions } from "../../sdk/types";
|
|
3
3
|
import { ActivityType, Vendor } from "../constants";
|
|
4
4
|
import { Events } from "./events";
|
|
5
|
+
import { DeviceModuleOptions } from "./module";
|
|
5
6
|
export interface WrapperModule {
|
|
6
7
|
wrapper: VendorWrapper;
|
|
7
8
|
}
|
|
@@ -17,7 +18,7 @@ export interface VendorContext {
|
|
|
17
18
|
readonly vendor: Vendor;
|
|
18
19
|
set<Key extends keyof SetOptions>(key: Key, value: SetOptions[Key]): void;
|
|
19
20
|
}
|
|
20
|
-
export interface AdditionalDeviceInternalDependencies {
|
|
21
|
+
export interface AdditionalDeviceInternalDependencies extends DeviceModuleOptions {
|
|
21
22
|
eventHub: EventHub<Events>;
|
|
22
23
|
}
|
|
23
24
|
export interface SessionData {
|
|
@@ -60,6 +60,7 @@ function asyncLoadSardine(options) {
|
|
|
60
60
|
sessionKey: options.session.vendorSessionID,
|
|
61
61
|
environment,
|
|
62
62
|
parentElement: document.body,
|
|
63
|
+
flow: options.module.activityType,
|
|
63
64
|
onDeviceResponse: function (data) {
|
|
64
65
|
options.module.eventHub.emit("device_characteristics_extracted", {
|
|
65
66
|
deviceCharacteristics: data,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sardine.js","sourceRoot":"","sources":["../../../../../modules/device/vendors/Sardine.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAgD;AAChD,+BAAkC;AAGrB,QAAA,OAAO,GAAkB;IACpC,MAAM,EAAE,SAAS;IACX,UAAU,CAAC,OAAsB;;YACrC,8BAA8B;YAC9B,MAAM,WAAW,GAAG,MAAM,wBAAwB,CAAC,OAAO,CAAC,CAAC;YAC5D,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,wBAAwB,EAAE;gBAC9C,OAAO,EAAE,WAAW;aACrB,CAAC,CAAC;YACH,yBAAyB;YACzB,MAAM,cAAc,GAAG,MAAM,gBAAgB,CAAC;gBAC5C,MAAM,EAAE,OAAO;gB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CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;oBACpD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;iBAC3D;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CAAA;AACD,MAAM,MAAM,GAAG;IACb,QAAQ,EAAE,YAAY;IACtB,YAAY,EAAE,MAAM;CACrB,CAAC"}
|
|
@@ -5,7 +5,9 @@ import { SdkModes } from "./sdk/types";
|
|
|
5
5
|
* Explicitly Export types (with type-only exports) and enums (without "type") at the root when importing into a typescript project via npm
|
|
6
6
|
* https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export { ENVIRONMENTS } from "./common";
|
|
9
|
+
export type { Accessors, mkEventHub, ReadonlyAccessors } from "./common";
|
|
10
|
+
export type { CheckSummary } from "./common/shared/models/CheckSummary";
|
|
9
11
|
export type { DeviceModule, DeviceModuleContext as DeviceModuleContext, Events as DeviceModuleEvents, } from "./device";
|
|
10
12
|
export type { FrankieApiClient } from "./frankie-client";
|
|
11
13
|
export { Status as OCRStatus } from "./ocr";
|
|
@@ -23,12 +23,18 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.SdkMode = exports.OCRStatus = void 0;
|
|
26
|
+
exports.SdkMode = exports.OCRStatus = exports.ENVIRONMENTS = void 0;
|
|
27
27
|
const utils = __importStar(require("./common"));
|
|
28
28
|
const frankie_client_1 = require("./frankie-client");
|
|
29
29
|
const sdk_1 = require("./sdk");
|
|
30
30
|
const types_1 = require("./sdk/types");
|
|
31
31
|
Object.defineProperty(exports, "SdkMode", { enumerable: true, get: function () { return types_1.SdkModes; } });
|
|
32
|
+
/**
|
|
33
|
+
* Explicitly Export types (with type-only exports) and enums (without "type") at the root when importing into a typescript project via npm
|
|
34
|
+
* https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export
|
|
35
|
+
*/
|
|
36
|
+
var common_1 = require("./common");
|
|
37
|
+
Object.defineProperty(exports, "ENVIRONMENTS", { enumerable: true, get: function () { return common_1.ENVIRONMENTS; } });
|
|
32
38
|
var ocr_1 = require("./ocr");
|
|
33
39
|
Object.defineProperty(exports, "OCRStatus", { enumerable: true, get: function () { return ocr_1.Status; } });
|
|
34
40
|
// Exported OneSdk object
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../modules/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAAwC;AACxC,2DAA0D;AAC1D,+BAA+B;AAC/B,uCAAuC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../modules/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAAwC;AACxC,2DAA0D;AAC1D,+BAA+B;AAC/B,uCAAuC;AAiBlB,wFAjBZ,gBAAQ,OAiBW;AAf5B;;;GAGG;AACH,yCAA8C;AAArC,sGAAA,YAAY,OAAA;AASrB,mCAAkD;AAAzC,gGAAA,MAAM,OAAa;AAI5B,yBAAyB;AACzB,4DAA4D;AAC5D,sDAAsD;AACtD,6BAA6B;AAC7B,oDAAoD;AACpD,kBAAe,MAAM,CAAC,MAAM,CAAC,YAAM,CAAC,UAAU,EAAE;IAC9C,gBAAgB,EAAhB,iCAAgB;IAChB,KAAK;IACL,KAAK,EAAE,gBAAQ;CAChB,CAAC,CAAC"}
|
|
@@ -12,4 +12,4 @@ export declare const mkSubmitMethod: (deps: {
|
|
|
12
12
|
documents$: Accessors<Document[]>;
|
|
13
13
|
}) => <T extends boolean>(o?: {
|
|
14
14
|
verify: T;
|
|
15
|
-
}) => Promise<T extends true ? import("
|
|
15
|
+
}) => Promise<T extends true ? import("../..").CheckSummary : true>;
|
package/dist/commit.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
9d0068a5bd2185e65c9310ca53f36d1d7245217c
|
|
@@ -20,7 +20,7 @@ export declare type CommonEvents = {
|
|
|
20
20
|
}];
|
|
21
21
|
};
|
|
22
22
|
export declare type EventListenerCallback<Arguments extends unknown[]> = (...args: Arguments) => void;
|
|
23
|
-
declare type ExtendedEvents<Events> = Events & CommonEvents;
|
|
23
|
+
export declare type ExtendedEvents<Events> = Events & CommonEvents;
|
|
24
24
|
declare type EventNamesOf<Events extends EventsDictionary> = KeyOf<Events>;
|
|
25
25
|
export declare type EventHub<ModuleEvents extends EventsDictionary = Record<string, unknown[]>> = {
|
|
26
26
|
on: <EventName extends EventNamesOf<ExtendedEvents<ModuleEvents>>>(eventName: EventName, listener: EventListenerCallback<ExtendedEvents<ModuleEvents>[EventName]>) => void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { KeyOf } from "../../../types/index.js";
|
|
2
|
+
import { EventHub, EventsDictionary, ExtendedEvents } from "./eventHub";
|
|
3
|
+
declare type Runnable = <Args extends unknown[], Retype>(...args: Args) => Promise<Retype | void>;
|
|
4
|
+
declare type Options<Callback extends Runnable, Events extends EventsDictionary> = {
|
|
5
|
+
condition: () => boolean;
|
|
6
|
+
run: Callback;
|
|
7
|
+
elseWaitFor: KeyOf<ExtendedEvents<Events>>;
|
|
8
|
+
eventHub: EventHub<Events>;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* runIfWhen
|
|
12
|
+
* - runs the function "run" if "condition" is true,
|
|
13
|
+
* - otherwise it will wait for the event "elseWaitFor" to be emitted by "eventHub" to run the function
|
|
14
|
+
* @param run main function to be run
|
|
15
|
+
* @param condition function returning a boolean
|
|
16
|
+
* @param elseWaitFor string with the name of the event to trigger a retry
|
|
17
|
+
*
|
|
18
|
+
* @returns a function that takes the same parameters as "run" and returns a promise with the same results returned by "run"
|
|
19
|
+
*/
|
|
20
|
+
export declare const runIfWhen: <Callback extends Runnable, Events extends EventsDictionary>(opt: Options<Callback, Events>) => Callback;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// TODO -- decouple it from eventHub
|
|
2
|
+
// TODO -- instead of automatically running the function on the callback event, it should check the condition again
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* runIfWhen
|
|
14
|
+
* - runs the function "run" if "condition" is true,
|
|
15
|
+
* - otherwise it will wait for the event "elseWaitFor" to be emitted by "eventHub" to run the function
|
|
16
|
+
* @param run main function to be run
|
|
17
|
+
* @param condition function returning a boolean
|
|
18
|
+
* @param elseWaitFor string with the name of the event to trigger a retry
|
|
19
|
+
*
|
|
20
|
+
* @returns a function that takes the same parameters as "run" and returns a promise with the same results returned by "run"
|
|
21
|
+
*/
|
|
22
|
+
export const runIfWhen = (opt) => ((...args) => new Promise((resolve) => {
|
|
23
|
+
if (opt.condition())
|
|
24
|
+
resolve(opt.run(...args));
|
|
25
|
+
else {
|
|
26
|
+
opt.eventHub.on(opt.elseWaitFor, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
+
resolve(opt.run(...args));
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
}));
|
|
31
|
+
//# sourceMappingURL=runIfWhen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runIfWhen.js","sourceRoot":"","sources":["../../../../../modules/common/modules/runIfWhen.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,mHAAmH;;;;;;;;;;AAYnH;;;;;;;;;GASG;AAEH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,GAA8B,EACpB,EAAE,CACZ,CAAC,CAAC,GAAG,IAAe,EAAE,EAAE,CACtB,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;IACtB,IAAI,GAAG,CAAC,SAAS,EAAE;QAAE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;SAC1C;QACH,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,GAAS,EAAE;YAC1C,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QAC5B,CAAC,CAAA,CAAC,CAAC;KACJ;AACH,CAAC,CAAC,CAAa,CAAC"}
|
|
@@ -49,6 +49,7 @@ export const deviceModule = {
|
|
|
49
49
|
// Maybe we should just use the one event hub passed in the options object for all the modules of the one sdk?
|
|
50
50
|
const eventHub = mkEventHub();
|
|
51
51
|
let vendorContext = null;
|
|
52
|
+
/** Define context methods */
|
|
52
53
|
// main will trigger the following procedure
|
|
53
54
|
// - determine vendor from recipe configuration
|
|
54
55
|
// - load vendor sdk (async)
|
|
@@ -69,28 +70,19 @@ export const deviceModule = {
|
|
|
69
70
|
return null;
|
|
70
71
|
});
|
|
71
72
|
});
|
|
72
|
-
//
|
|
73
|
+
// const startActivity = async (activityType: ActivityType) => {
|
|
74
|
+
// vendorContext.set("activityType", activityType);
|
|
75
|
+
// };
|
|
76
|
+
/** reemit/map/transform events below */
|
|
77
|
+
// value_set: when the value for a field is confirmed by the vendor wrapper to be set
|
|
73
78
|
eventHub.on("value_set", ({ key, value }) => {
|
|
74
|
-
//
|
|
75
|
-
// reemit event as the more meaninful "activity_started"
|
|
79
|
+
// When activityType is set, emit another more specific event "activity_started"
|
|
76
80
|
if (key === "activityType")
|
|
77
81
|
eventHub.emit("activity_started", { activityType: value });
|
|
78
82
|
});
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (!vendorContext && isConfigurationValid)
|
|
83
|
-
main();
|
|
84
|
-
return Object.assign({}, mkEventListener(eventHub));
|
|
83
|
+
return Object.assign(Object.assign({}, mkEventListener(eventHub)), {
|
|
84
|
+
// wrap main function to prevent returning a promise
|
|
85
|
+
start: () => void main() });
|
|
85
86
|
},
|
|
86
87
|
};
|
|
87
|
-
const runIfWhen = (opt) => ((...args) => new Promise((resolve) => {
|
|
88
|
-
if (opt.condition())
|
|
89
|
-
resolve(opt.run(...args));
|
|
90
|
-
else {
|
|
91
|
-
opt.eventHub.on(opt.elseWaitFor, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
92
|
-
resolve(opt.run(...args));
|
|
93
|
-
}));
|
|
94
|
-
}
|
|
95
|
-
}));
|
|
96
88
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../modules/device/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../modules/device/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAE7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAG7D,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AAExB,MAAM,aAAa,GAAG,CAAO,MAAc,EAA0B,EAAE;IACrE,IAAI,YAAY,CAAC,CAAC,6DAA6D;IAC/E,IAAI,MAAM,KAAK,SAAS;QAAE,YAAY,GAAG,MAAM,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AAE,QAAQ,IAAG,CAAC;iBACvD,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;gBAChB,QAAQ,CAAC,IAAI,CAAC,mBAAmB,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;gBACzD,OAAO,OAAO,CAAC;YACjB,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,WAAW,EAAE,EAAE;gBACrB,QAAQ,CAAC,IAAI,CAAC,2BAA2B,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,CAAC;gBAC9E,OAAO,IAAI,CAAC;YACd,CAAC,CAAC,CAAC;QACP,CAAC,CAAA,CAAC;QAEF,gEAAgE;QAChE,qDAAqD;QACrD,KAAK;QAEL,wCAAwC;QAExC,qFAAqF;QACrF,QAAQ,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE;YAC1C,iFAAiF;YACjF,IAAI,GAAG,KAAK,cAAc;gBAAE,QAAQ,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,YAAY,EAAE,KAAqB,EAAE,CAAC,CAAC;QACzG,CAAC,CAAC,CAAC;QAEH,uCACK,eAAe,CAAC,QAAQ,CAAC;YAC5B,oDAAoD;YACpD,KAAK,EAAE,GAAG,EAAE,CAAC,KAAK,IAAI,EAAE,IACxB;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -7,6 +7,8 @@ export interface DeviceModule {
|
|
|
7
7
|
export interface DeviceModuleOptions {
|
|
8
8
|
activityType: ActivityType;
|
|
9
9
|
}
|
|
10
|
-
export declare type DeviceModuleContext = ModuleContext<{
|
|
11
|
-
|
|
10
|
+
export declare type DeviceModuleContext = ModuleContext<{
|
|
11
|
+
start: StartActivityFunction;
|
|
12
|
+
}, Events>;
|
|
13
|
+
export declare type StartActivityFunction = () => Promise<void>;
|
|
12
14
|
export declare type EndActivityFunction = () => Promise<void>;
|
|
@@ -2,6 +2,7 @@ import { EventHub } from "../../common";
|
|
|
2
2
|
import { BaseModuleOptions } from "../../sdk/types";
|
|
3
3
|
import { ActivityType, Vendor } from "../constants";
|
|
4
4
|
import { Events } from "./events";
|
|
5
|
+
import { DeviceModuleOptions } from "./module";
|
|
5
6
|
export interface WrapperModule {
|
|
6
7
|
wrapper: VendorWrapper;
|
|
7
8
|
}
|
|
@@ -17,7 +18,7 @@ export interface VendorContext {
|
|
|
17
18
|
readonly vendor: Vendor;
|
|
18
19
|
set<Key extends keyof SetOptions>(key: Key, value: SetOptions[Key]): void;
|
|
19
20
|
}
|
|
20
|
-
export interface AdditionalDeviceInternalDependencies {
|
|
21
|
+
export interface AdditionalDeviceInternalDependencies extends DeviceModuleOptions {
|
|
21
22
|
eventHub: EventHub<Events>;
|
|
22
23
|
}
|
|
23
24
|
export interface SessionData {
|
|
@@ -57,6 +57,7 @@ function asyncLoadSardine(options) {
|
|
|
57
57
|
sessionKey: options.session.vendorSessionID,
|
|
58
58
|
environment,
|
|
59
59
|
parentElement: document.body,
|
|
60
|
+
flow: options.module.activityType,
|
|
60
61
|
onDeviceResponse: function (data) {
|
|
61
62
|
options.module.eventHub.emit("device_characteristics_extracted", {
|
|
62
63
|
deviceCharacteristics: data,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sardine.js","sourceRoot":"","sources":["../../../../../modules/device/vendors/Sardine.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAGlC,MAAM,CAAC,MAAM,OAAO,GAAkB;IACpC,MAAM,EAAE,SAAS;IACX,UAAU,CAAC,OAAsB;;YACrC,8BAA8B;YAC9B,MAAM,WAAW,GAAG,MAAM,wBAAwB,CAAC,OAAO,CAAC,CAAC;YAC5D,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,wBAAwB,EAAE;gBAC9C,OAAO,EA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C;QACH,OAAO;YACL,MAAM,EAAE,SAAS;YACjB,GAAG,CAAC,GAAG,EAAE,KAAK;gBACZ,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;gBAC9B,IAAI,SAAS,EAAE;oBACb,cAAc,CAAC,YAAY,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;oBACpD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;iBAC3D;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CAAA;AACD,MAAM,MAAM,GAAG;IACb,QAAQ,EAAE,YAAY;IACtB,YAAY,EAAE,MAAM;CACrB,CAAC"}
|
|
@@ -5,7 +5,9 @@ import { SdkModes } from "./sdk/types";
|
|
|
5
5
|
* Explicitly Export types (with type-only exports) and enums (without "type") at the root when importing into a typescript project via npm
|
|
6
6
|
* https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export { ENVIRONMENTS } from "./common";
|
|
9
|
+
export type { Accessors, mkEventHub, ReadonlyAccessors } from "./common";
|
|
10
|
+
export type { CheckSummary } from "./common/shared/models/CheckSummary";
|
|
9
11
|
export type { DeviceModule, DeviceModuleContext as DeviceModuleContext, Events as DeviceModuleEvents, } from "./device";
|
|
10
12
|
export type { FrankieApiClient } from "./frankie-client";
|
|
11
13
|
export { Status as OCRStatus } from "./ocr";
|
|
@@ -2,6 +2,11 @@ import * as utils from "./common";
|
|
|
2
2
|
import { FrankieApiClient } from "./frankie-client";
|
|
3
3
|
import { oneSdk } from "./sdk";
|
|
4
4
|
import { SdkModes } from "./sdk/types";
|
|
5
|
+
/**
|
|
6
|
+
* Explicitly Export types (with type-only exports) and enums (without "type") at the root when importing into a typescript project via npm
|
|
7
|
+
* https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export
|
|
8
|
+
*/
|
|
9
|
+
export { ENVIRONMENTS } from "./common";
|
|
5
10
|
export { Status as OCRStatus } from "./ocr";
|
|
6
11
|
export { SdkModes as SdkMode };
|
|
7
12
|
// Exported OneSdk object
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../modules/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../modules/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAS9C,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,EAAE,QAAQ,IAAI,OAAO,EAAE,CAAC;AAE/B,yBAAyB;AACzB,4DAA4D;AAC5D,sDAAsD;AACtD,6BAA6B;AAC7B,oDAAoD;AACpD,eAAe,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE;IAC9C,gBAAgB;IAChB,KAAK;IACL,KAAK,EAAE,QAAQ;CAChB,CAAC,CAAC"}
|
|
@@ -12,4 +12,4 @@ export declare const mkSubmitMethod: (deps: {
|
|
|
12
12
|
documents$: Accessors<Document[]>;
|
|
13
13
|
}) => <T extends boolean>(o?: {
|
|
14
14
|
verify: T;
|
|
15
|
-
}) => Promise<T extends true ? import("
|
|
15
|
+
}) => Promise<T extends true ? import("../..").CheckSummary : true>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkOneSdk=self.webpackChunkOneSdk||[]).push([[513],{6661:(e,n,i)=>{i.r(n),i.d(n,{wrapper:()=>r});var t=i(4726),s=i(4586),o=function(e,n,i,t){return new(i||(i=Promise))((function(s,o){function r(e){try{a(t.next(e))}catch(e){o(e)}}function c(e){try{a(t.throw(e))}catch(e){o(e)}}function a(e){var n;e.done?s(e.value):(n=e.value,n instanceof i?n:new i((function(e){e(n)}))).then(r,c)}a((t=t.apply(e,n||[])).next())}))};const r={vendor:"sardine",initialise(e){return o(this,void 0,void 0,(function*(){const n=yield function(e){var n;return o(this,void 0,void 0,(function*(){return{customerID:null!==(n=e.session.customerChildID)&&void 0!==n?n:e.session.customerID,frankieClientID:e.recipe.deviceCharacteristics.provider.clientID,vendorSessionID:(0,s.Z)(),environment:e.recipe.deviceCharacteristics.provider.environment}}))}(e);e.eventHub.emit("session_data_generated",{session:n});const i=yield function(e){return o(this,void 0,void 0,(function*(){const n=e.session.environment,i=function(e){return"production"===e?"api.sardine.ai":"api.sandbox.sardine.ai"}(n),s=`https://${i}/assets/loader.min.js`;yield(0,t.loadAsyncAsset)(s);const o=window._Sardine.createContext({clientId:e.session.frankieClientID,sessionKey:e.session.vendorSessionID,environment:n,parentElement:document.body,onDeviceResponse:function(n){e.module.eventHub.emit("device_characteristics_extracted",{deviceCharacteristics:n})}});return{vendor:"sardine",set(n,i){const t=c[n];t&&(o.updateConfig({[t]:i}),e.module.eventHub.emit("value_set",{key:n,value:i}))}}}))}({module:e,session:n});return i}))}},c={entityId:"userIdHash",activityType:"flow"}}}]);
|
|
1
|
+
"use strict";(self.webpackChunkOneSdk=self.webpackChunkOneSdk||[]).push([[513],{6661:(e,n,i)=>{i.r(n),i.d(n,{wrapper:()=>r});var t=i(4726),s=i(4586),o=function(e,n,i,t){return new(i||(i=Promise))((function(s,o){function r(e){try{a(t.next(e))}catch(e){o(e)}}function c(e){try{a(t.throw(e))}catch(e){o(e)}}function a(e){var n;e.done?s(e.value):(n=e.value,n instanceof i?n:new i((function(e){e(n)}))).then(r,c)}a((t=t.apply(e,n||[])).next())}))};const r={vendor:"sardine",initialise(e){return o(this,void 0,void 0,(function*(){const n=yield function(e){var n;return o(this,void 0,void 0,(function*(){return{customerID:null!==(n=e.session.customerChildID)&&void 0!==n?n:e.session.customerID,frankieClientID:e.recipe.deviceCharacteristics.provider.clientID,vendorSessionID:(0,s.Z)(),environment:e.recipe.deviceCharacteristics.provider.environment}}))}(e);e.eventHub.emit("session_data_generated",{session:n});const i=yield function(e){return o(this,void 0,void 0,(function*(){const n=e.session.environment,i=function(e){return"production"===e?"api.sardine.ai":"api.sandbox.sardine.ai"}(n),s=`https://${i}/assets/loader.min.js`;yield(0,t.loadAsyncAsset)(s);const o=window._Sardine.createContext({clientId:e.session.frankieClientID,sessionKey:e.session.vendorSessionID,environment:n,parentElement:document.body,flow:e.module.activityType,onDeviceResponse:function(n){e.module.eventHub.emit("device_characteristics_extracted",{deviceCharacteristics:n})}});return{vendor:"sardine",set(n,i){const t=c[n];t&&(o.updateConfig({[t]:i}),e.module.eventHub.emit("value_set",{key:n,value:i}))}}}))}({module:e,session:n});return i}))}},c={entityId:"userIdHash",activityType:"flow"}}}]);
|
|
2
2
|
//# sourceMappingURL=device-sardine.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device-sardine.js","mappings":"2bAIO,MAAMA,EAAyB,CACpCC,OAAQ,UACFC,WAAWC,G,yCAEf,MAAMC,QAgBV,SAAwCD,G,+CACtC,MAAO,CACLE,WAA2C,QAA/B,EAAAF,EAAQG,QAAQC,uBAAe,QAAIJ,EAAQG,QAAQD,WAC/DG,gBAAiBL,EAAQM,OAAOC,sBAAsBC,SAASC,SAC/DC,iBAAiB,SACjBC,YAAaX,EAAQM,O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Q6B,OAAOhB,SAASC,KAAK,mCAAoC,CAC/DP,sBAAuByB,GAE3B,IAEF,MAAO,CACLlC,OAAQ,UACRmC,IAAIC,EAAKC,GACP,MAAMC,EAAYC,EAAOH,GACrBE,IACFrB,EAAeuB,aAAa,CAAE,CAACF,GAAYD,IAC3CnC,EAAQ6B,OAAOhB,SAASC,KAAK,YAAa,CAAEoB,MAAKC,UAErD,EAEJ,G,CAlDiCI,CAAiB,CAC5CV,OAAQ7B,EACRG,QAASF,IAIX,OAAOc,CACT,G,GA4CIsB,EAAS,CACbG,SAAU,aACVV,aAAc,O","sources":["webpack://OneSdk/./modules/device/vendors/Sardine.ts"],"sourcesContent":["import { loadAsyncAsset } from \"@module/common\";\nimport { v4 as uuid } from \"uuid\";\nimport { SessionData, VendorContext, VendorLoaderOptions, VendorOptions, VendorWrapper } from \"../types\";\n\nexport const wrapper: VendorWrapper = {\n vendor: \"sardine\",\n async initialise(options: VendorOptions): Promise<VendorContext> {\n // create session with backend\n const sessionData = await initialiseSardineSession(options);\n options.eventHub.emit(\"session_data_generated\", {\n session: sessionData,\n });\n // initialise sardine sdk\n const sardineContext = await asyncLoadSardine({\n module: options,\n session: sessionData,\n });\n // listen for events, if there are any in the frontend\n // maybe we should implement our own events by websockets, if no frontend events are emitted\n return sardineContext;\n },\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nasync function initialiseSardineSession(options: VendorOptions): Promise<SessionData> {\n return {\n customerID: options.session.customerChildID ?? options.session.customerID,\n frankieClientID: options.recipe.deviceCharacteristics.provider.clientID,\n vendorSessionID: uuid(),\n environment: options.recipe.deviceCharacteristics.provider.environment,\n };\n}\nfunction resolveSardineHost(environment: SardineEnvironment) {\n if (environment === \"production\") return \"api.sardine.ai\";\n return \"api.sandbox.sardine.ai\";\n}\nasync function asyncLoadSardine(options: VendorLoaderOptions): Promise<VendorContext> {\n const environment = options.session.environment as SardineEnvironment;\n const sardineHost = resolveSardineHost(environment);\n const url = `https://${sardineHost}/assets/loader.min.js`;\n await loadAsyncAsset(url);\n const sardineContext = window._Sardine.createContext({\n clientId: options.session.frankieClientID,\n sessionKey: options.session.vendorSessionID,\n environment,\n parentElement: document.body,\n flow: options.module.activityType,\n onDeviceResponse: function (data: Record<string, string | number | object>) {\n options.module.eventHub.emit(\"device_characteristics_extracted\", {\n deviceCharacteristics: data,\n });\n },\n });\n return {\n vendor: \"sardine\",\n set(key, value) {\n const mappedKey = mapF2S[key];\n if (mappedKey) {\n sardineContext.updateConfig({ [mappedKey]: value });\n options.module.eventHub.emit(\"value_set\", { key, value });\n }\n },\n };\n}\nconst mapF2S = {\n entityId: \"userIdHash\",\n activityType: \"flow\",\n};\n\n// Sardine specific types\n// Initialisation options that Sardine SDK expects (not all required)\ninterface SardineSdkOptions {\n clientId: string;\n userIdHash: string;\n flow: string;\n partnerID: string;\n sessionKey: string;\n}\ninterface InitialisationOptions extends SardineSdkOptions {\n onDeviceResponse: (d: unknown) => void;\n environment: SardineEnvironment;\n parentElement: HTMLElement;\n}\nexport type SardineEnvironment = \"production\" | \"sandbox\";\ndeclare global {\n interface Window {\n _Sardine: {\n createContext(args: Partial<InitialisationOptions>): {\n updateConfig(config: Partial<SardineSdkOptions>): void;\n };\n };\n }\n}\n"],"names":["wrapper","vendor","initialise","options","sessionData","customerID","session","customerChildID","frankieClientID","recipe","deviceCharacteristics","provider","clientID","vendorSessionID","environment","initialiseSardineSession","eventHub","emit","sardineContext","sardineHost","resolveSardineHost","url","loadAsyncAsset","window","_Sardine","createContext","clientId","sessionKey","parentElement","document","body","flow","module","activityType","onDeviceResponse","data","set","key","value","mappedKey","mapF2S","updateConfig","asyncLoadSardine","entityId"],"sourceRoot":""}
|