@frankieone/one-sdk 0.1.0-poc.17 → 0.1.0-poc.18
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/README.md +1 -25
- package/dist/commit.txt +1 -0
- package/dist/esm/modules/common/constants.d.ts +4 -0
- package/dist/esm/modules/common/constants.js +5 -0
- package/dist/esm/modules/common/constants.js.map +1 -0
- package/dist/esm/modules/common/index.d.ts +7 -0
- package/dist/esm/modules/common/index.js +8 -0
- package/dist/esm/modules/common/index.js.map +1 -0
- package/dist/{types/models/utils → esm/modules/common/modules}/base64.d.ts +11 -11
- package/dist/esm/modules/common/modules/base64.js +37 -0
- package/dist/esm/modules/common/modules/base64.js.map +1 -0
- package/dist/esm/modules/common/modules/env2url.d.ts +9 -0
- package/dist/esm/modules/common/modules/env2url.js +30 -0
- package/dist/esm/modules/common/modules/env2url.js.map +1 -0
- package/dist/esm/modules/common/modules/eventHub.d.ts +8 -0
- package/dist/esm/modules/common/modules/eventHub.js +16 -0
- package/dist/esm/modules/common/modules/eventHub.js.map +1 -0
- package/dist/esm/modules/common/modules/loadAsyncAsset.d.ts +1 -0
- package/dist/esm/modules/common/modules/loadAsyncAsset.js +9 -0
- package/dist/esm/modules/common/modules/loadAsyncAsset.js.map +1 -0
- package/dist/esm/modules/common/modules/merge.d.ts +1 -0
- package/dist/esm/modules/common/modules/merge.js +2 -0
- package/dist/esm/modules/common/modules/merge.js.map +1 -0
- package/dist/esm/modules/common/types/Configuration.d.ts +22 -0
- package/dist/esm/modules/common/types/Configuration.js +2 -0
- package/dist/esm/modules/common/types/Configuration.js.map +1 -0
- package/dist/esm/modules/device/constants.d.ts +4 -0
- package/dist/esm/modules/device/constants.js +4 -0
- package/dist/esm/modules/device/constants.js.map +1 -0
- package/dist/esm/modules/device/index.d.ts +4 -0
- package/dist/esm/modules/device/index.js +95 -0
- package/dist/esm/modules/device/index.js.map +1 -0
- package/dist/esm/modules/device/parseConfiguration.d.ts +5 -0
- package/dist/esm/modules/device/parseConfiguration.js +15 -0
- package/dist/esm/modules/device/parseConfiguration.js.map +1 -0
- package/dist/esm/modules/device/types/events.d.ts +30 -0
- package/dist/esm/modules/device/types/events.js +2 -0
- package/dist/esm/modules/device/types/events.js.map +1 -0
- package/dist/esm/modules/device/types/index.d.ts +3 -0
- package/dist/esm/modules/device/types/index.js +4 -0
- package/dist/esm/modules/device/types/index.js.map +1 -0
- package/dist/esm/modules/device/types/module.d.ts +15 -0
- package/dist/esm/modules/device/types/module.js +2 -0
- package/dist/esm/modules/device/types/module.js.map +1 -0
- package/dist/esm/modules/device/types/vendor.d.ts +33 -0
- package/dist/esm/modules/device/types/vendor.js +2 -0
- package/dist/esm/modules/device/types/vendor.js.map +1 -0
- package/dist/esm/modules/device/vendors/Sardine.d.ts +19 -0
- package/dist/esm/modules/device/vendors/Sardine.js +63 -0
- package/dist/esm/modules/device/vendors/Sardine.js.map +1 -0
- package/dist/esm/modules/device/vendors/Threatmetrix/fp-clientlib-v4.d.ts +11 -0
- package/dist/esm/modules/device/vendors/Threatmetrix/fp-clientlib-v4.js +87 -0
- package/dist/esm/modules/device/vendors/Threatmetrix/fp-clientlib-v4.js.map +1 -0
- package/dist/esm/modules/device/vendors/Threatmetrix/index.d.ts +3 -0
- package/dist/esm/modules/device/vendors/Threatmetrix/index.js +45 -0
- package/dist/esm/modules/device/vendors/Threatmetrix/index.js.map +1 -0
- package/dist/esm/modules/frankie-client/DummyFrankieApiClient.d.ts +12 -0
- package/dist/esm/modules/frankie-client/DummyFrankieApiClient.js +29 -0
- package/dist/esm/modules/frankie-client/DummyFrankieApiClient.js.map +1 -0
- package/dist/esm/modules/frankie-client/FrankieApiClient.d.ts +24 -0
- package/dist/esm/modules/frankie-client/FrankieApiClient.js +74 -0
- package/dist/esm/modules/frankie-client/FrankieApiClient.js.map +1 -0
- package/dist/esm/modules/frankie-client/index.d.ts +14 -0
- package/dist/esm/modules/frankie-client/index.js +14 -0
- package/dist/esm/modules/frankie-client/index.js.map +1 -0
- package/dist/esm/modules/index.d.ts +15 -0
- package/dist/esm/modules/index.js +14 -0
- package/dist/esm/modules/index.js.map +1 -0
- package/dist/esm/modules/sdk/ComponentLoader.d.ts +12 -0
- package/dist/esm/modules/sdk/ComponentLoader.js +56 -0
- package/dist/esm/modules/sdk/ComponentLoader.js.map +1 -0
- package/dist/esm/modules/sdk/index.d.ts +4 -0
- package/dist/esm/modules/sdk/index.js +22 -0
- package/dist/esm/modules/sdk/index.js.map +1 -0
- package/dist/esm/modules/sdk/onInitialisation.d.ts +2 -0
- package/dist/esm/modules/sdk/onInitialisation.js +68 -0
- package/dist/esm/modules/sdk/onInitialisation.js.map +1 -0
- package/dist/esm/modules/sdk/types.d.ts +101 -0
- package/dist/esm/modules/sdk/types.js +2 -0
- package/dist/esm/modules/sdk/types.js.map +1 -0
- package/dist/esm/types/Utilities.d.ts +2 -0
- package/dist/esm/types/Utilities.js +2 -0
- package/dist/esm/types/Utilities.js.map +1 -0
- package/dist/esm/types/index.d.ts +1 -0
- package/dist/esm/types/index.js +2 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/release.txt +1 -0
- package/dist/umd/device-sardine.js +2 -0
- package/dist/umd/device-sardine.js.map +1 -0
- package/dist/umd/device-threatmetrix.js +2 -0
- package/dist/umd/device-threatmetrix.js.map +1 -0
- package/dist/umd/oneSdk.umd.js +3 -0
- package/dist/umd/oneSdk.umd.js.LICENSE.txt +8 -0
- package/dist/umd/oneSdk.umd.js.map +1 -0
- package/package.json +84 -54
- package/dist/index.esm.js +0 -2
- package/dist/index.esm.js.map +0 -1
- package/dist/index.umd.js +0 -2
- package/dist/index.umd.js.map +0 -1
- package/dist/types/api/ExternalIdvClient.d.ts +0 -19
- package/dist/types/api/FrankieApiClient.d.ts +0 -54
- package/dist/types/api/index.d.ts +0 -1
- package/dist/types/facades/POC/reactComponent.d.ts +0 -644
- package/dist/types/facades/POC/routing.d.ts +0 -3
- package/dist/types/facades/POC/viewWrapper.d.ts +0 -4
- package/dist/types/facades/POC/webEntry.d.ts +0 -6
- package/dist/types/index.d.ts +0 -11
- package/dist/types/models/Address.d.ts +0 -67
- package/dist/types/models/Admin.d.ts +0 -1295
- package/dist/types/models/Applicant.d.ts +0 -115
- package/dist/types/models/CheckSummary.d.ts +0 -164
- package/dist/types/models/ConfigurationReader.d.ts +0 -7
- package/dist/types/models/Core.d.ts +0 -2725
- package/dist/types/models/Document.d.ts +0 -112
- package/dist/types/models/General.d.ts +0 -196
- package/dist/types/models/Organisation.d.ts +0 -36
- package/dist/types/models/Profile.d.ts +0 -27
- package/dist/types/models/SupportingDocument.d.ts +0 -95
- package/dist/types/models/User.d.ts +0 -27
- package/dist/types/models/index.d.ts +0 -14
- package/dist/types/models/transformers/apiState.d.ts +0 -23
- package/dist/types/models/utils/address.d.ts +0 -2
- package/dist/types/models/utils/buildCycleUtils.d.ts +0 -1
- package/dist/types/models/utils/constants.d.ts +0 -75
- package/dist/types/models/utils/date.d.ts +0 -5
- package/dist/types/models/utils/getCountryDetails.d.ts +0 -9
- package/dist/types/models/utils/getDocumentDetails.d.ts +0 -8
- package/dist/types/models/utils/helper.d.ts +0 -4
- package/dist/types/models/utils/index.d.ts +0 -11
- package/dist/types/models/utils/isEmpty.d.ts +0 -5
- package/dist/types/models/utils/sanitiser.d.ts +0 -8
- package/dist/types/modules/router/ReactDictionaryRouter.d.ts +0 -15
- package/dist/types/modules/router/common/routing.d.ts +0 -25
- package/dist/types/modules/store/ReactInMemoryStore.d.ts +0 -24
- package/dist/types/uiComponents/reactWeb.d.ts +0 -8
- package/dist/types/utils/base64.d.ts +0 -11
- package/dist/types/utils/env2Url.d.ts +0 -1
package/README.md
CHANGED
|
@@ -1,25 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
### npm
|
|
4
|
-
|
|
5
|
-
`one-sdk` will be published as npm package within @frankieone scope. The complete package name will match to [package.json](./package.json)'s name field.
|
|
6
|
-
|
|
7
|
-
### CDN
|
|
8
|
-
|
|
9
|
-
The `umd` version of bundle will be deployed to aws [s3](https://aws.amazon.com/s3/) and served by the [cloudfront](https://aws.amazon.com/cloudfront/) as CDN.
|
|
10
|
-
|
|
11
|
-
The CDN URL is composed with following https://{base-url}/{version}/{file-name}
|
|
12
|
-
|
|
13
|
-
#### base-url
|
|
14
|
-
|
|
15
|
-
The base-url to be confirmed as we do not have a production environment set up yet. We are using portal dev environment for the time being during the poc stage.
|
|
16
|
-
|
|
17
|
-
base-url: `latest.frankiefinancial.io/one-sdk/`
|
|
18
|
-
|
|
19
|
-
#### version
|
|
20
|
-
|
|
21
|
-
This version matches to [package.json](./package.json)'s version field.
|
|
22
|
-
|
|
23
|
-
#### file-name
|
|
24
|
-
|
|
25
|
-
Finale bundle and minified file and map: `one-sdk.umd.js`, `one-sdk.umd.js.map`
|
|
1
|
+
# FrankieOne's OneSdk
|
package/dist/commit.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2b14edeb3eec1e6f184652b6cc8a8d90fe91118d
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../modules/common/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,MAAM,EAAE,YAAY;CACZ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./modules/loadAsyncAsset";
|
|
2
|
+
export * from "./modules/eventHub";
|
|
3
|
+
export * from "./modules/base64";
|
|
4
|
+
export * from "./modules/env2url";
|
|
5
|
+
export * from "./modules/merge";
|
|
6
|
+
export * from "./types/Configuration";
|
|
7
|
+
export * from "./constants";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../modules/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Buffer } from "buffer";
|
|
3
|
-
export declare function stringToBase64(s: string): string;
|
|
4
|
-
export declare function bufferToBase64(b: Buffer): string;
|
|
5
|
-
export declare function base64ToString(bs: string): string;
|
|
6
|
-
export declare function bufferToString(b: Buffer): string;
|
|
7
|
-
export declare function hexToByteString(hex: string): string;
|
|
8
|
-
export declare function hexToBytes(hex: string): number[];
|
|
9
|
-
export declare function bytesToBase64(byt: number[]): string;
|
|
10
|
-
export declare function bufferToByteString(buff: Buffer): number[];
|
|
11
|
-
export declare function stringToByteString(str: string): number[];
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Buffer } from "buffer";
|
|
3
|
+
export declare function stringToBase64(s: string): string;
|
|
4
|
+
export declare function bufferToBase64(b: Buffer): string;
|
|
5
|
+
export declare function base64ToString(bs: string): string;
|
|
6
|
+
export declare function bufferToString(b: Buffer): string;
|
|
7
|
+
export declare function hexToByteString(hex: string): string;
|
|
8
|
+
export declare function hexToBytes(hex: string): number[];
|
|
9
|
+
export declare function bytesToBase64(byt: number[]): string;
|
|
10
|
+
export declare function bufferToByteString(buff: Buffer): number[];
|
|
11
|
+
export declare function stringToByteString(str: string): number[];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import convertHex from "convert-hex";
|
|
2
|
+
import { Buffer } from "buffer";
|
|
3
|
+
export function stringToBase64(s) {
|
|
4
|
+
return bufferToBase64(Buffer.from(s, "utf8"));
|
|
5
|
+
}
|
|
6
|
+
export function bufferToBase64(b) {
|
|
7
|
+
return b.toString("base64");
|
|
8
|
+
}
|
|
9
|
+
export function base64ToString(bs) {
|
|
10
|
+
return Buffer.from(bs, "base64").toString("utf8");
|
|
11
|
+
}
|
|
12
|
+
export function bufferToString(b) {
|
|
13
|
+
return b.toString("utf8");
|
|
14
|
+
}
|
|
15
|
+
export function hexToByteString(hex) {
|
|
16
|
+
const bytes = hexToBytes(hex);
|
|
17
|
+
const buffer = Buffer.from(bytes);
|
|
18
|
+
return bufferToString(buffer);
|
|
19
|
+
}
|
|
20
|
+
export function hexToBytes(hex) {
|
|
21
|
+
const bytes = convertHex.hexToBytes(hex);
|
|
22
|
+
return bytes;
|
|
23
|
+
}
|
|
24
|
+
export function bytesToBase64(byt) {
|
|
25
|
+
const buffer = Buffer.from(byt);
|
|
26
|
+
return bufferToBase64(buffer);
|
|
27
|
+
}
|
|
28
|
+
export function bufferToByteString(buff) {
|
|
29
|
+
const bytes = Array.from(buff);
|
|
30
|
+
return bytes;
|
|
31
|
+
}
|
|
32
|
+
export function stringToByteString(str) {
|
|
33
|
+
const buffer = Buffer.from(str);
|
|
34
|
+
const bytes = bufferToByteString(buffer);
|
|
35
|
+
return bytes;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=base64.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64.js","sourceRoot":"","sources":["../../../../../modules/common/modules/base64.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,UAAU,cAAc,CAAC,CAAS;IACtC,OAAO,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AAChD,CAAC;AACD,MAAM,UAAU,cAAc,CAAC,CAAS;IACtC,OAAO,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC9B,CAAC;AACD,MAAM,UAAU,cAAc,CAAC,EAAU;IACvC,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACpD,CAAC;AACD,MAAM,UAAU,cAAc,CAAC,CAAS;IACtC,OAAO,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC;AACD,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,MAAM,KAAK,GAAa,UAAU,CAAC,GAAG,CAAC,CAAC;IACxC,MAAM,MAAM,GAAW,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1C,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC;AACD,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,MAAM,KAAK,GAAa,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IACnD,OAAO,KAAK,CAAC;AACf,CAAC;AACD,MAAM,UAAU,aAAa,CAAC,GAAa;IACzC,MAAM,MAAM,GAAW,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxC,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC;AACD,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,OAAO,KAAK,CAAC;AACf,CAAC;AACD,MAAM,UAAU,kBAAkB,CAAC,GAAW;IAC5C,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChC,MAAM,KAAK,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;IACzC,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export var ENVIRONMENTS;
|
|
2
|
+
(function (ENVIRONMENTS) {
|
|
3
|
+
ENVIRONMENTS["development"] = "development";
|
|
4
|
+
ENVIRONMENTS["local"] = "local";
|
|
5
|
+
ENVIRONMENTS["production"] = "production";
|
|
6
|
+
ENVIRONMENTS["uat"] = "uat";
|
|
7
|
+
ENVIRONMENTS["demo"] = "demo";
|
|
8
|
+
ENVIRONMENTS["qa"] = "qa";
|
|
9
|
+
})(ENVIRONMENTS || (ENVIRONMENTS = {}));
|
|
10
|
+
export const env2url = (env) => {
|
|
11
|
+
switch (env.toLowerCase()) {
|
|
12
|
+
case "latest":
|
|
13
|
+
case "development":
|
|
14
|
+
case "dev":
|
|
15
|
+
return "https://backend.latest.frankiefinancial.io";
|
|
16
|
+
case "qa":
|
|
17
|
+
case "staging3":
|
|
18
|
+
return "https://backend.staging3.latest.frankiefinancial.io";
|
|
19
|
+
case "demo":
|
|
20
|
+
return "https://backend.demo.frankiefinancial.io";
|
|
21
|
+
case "uat":
|
|
22
|
+
return "https://backend.kycaml.uat.frankiefinancial.io";
|
|
23
|
+
case "prod":
|
|
24
|
+
case "production":
|
|
25
|
+
return `https://backend.kycaml.frankiefinancial.io`;
|
|
26
|
+
default:
|
|
27
|
+
return `https://backend.${env}.latest.frankiefinancial.io`;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=env2url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env2url.js","sourceRoot":"","sources":["../../../../../modules/common/modules/env2url.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,YAOX;AAPD,WAAY,YAAY;IACtB,2CAA2B,CAAA;IAC3B,+BAAe,CAAA;IACf,yCAAyB,CAAA;IACzB,2BAAW,CAAA;IACX,6BAAa,CAAA;IACb,yBAAS,CAAA;AACX,CAAC,EAPW,YAAY,KAAZ,YAAY,QAOvB;AACD,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,GAAiB,EAAE,EAAE;IAC3C,QAAQ,GAAG,CAAC,WAAW,EAAE,EAAE;QACzB,KAAK,QAAQ,CAAC;QACd,KAAK,aAAa,CAAC;QACnB,KAAK,KAAK;YACR,OAAO,4CAA4C,CAAC;QACtD,KAAK,IAAI,CAAC;QACV,KAAK,UAAU;YACb,OAAO,qDAAqD,CAAC;QAC/D,KAAK,MAAM;YACT,OAAO,0CAA0C,CAAC;QACpD,KAAK,KAAK;YACR,OAAO,gDAAgD,CAAC;QAC1D,KAAK,MAAM,CAAC;QACZ,KAAK,YAAY;YACf,OAAO,4CAA4C,CAAC;QACtD;YACE,OAAO,mBAAmB,GAAG,6BAA6B,CAAC;KAC9D;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function mkEventHub<Events extends EventsDictionary>(): EventHub<Events>;
|
|
2
|
+
export declare type EventsDictionary = Record<string, unknown[]>;
|
|
3
|
+
export declare type EventListener<Arguments extends unknown[]> = (...args: Arguments) => void;
|
|
4
|
+
export declare type EventHub<ModuleEvents extends EventsDictionary = Record<string, unknown[]>> = {
|
|
5
|
+
on: <EventName extends keyof ModuleEvents>(eventName: EventName, listener: EventListener<ModuleEvents[EventName]>) => void;
|
|
6
|
+
off: <EventName extends keyof ModuleEvents>(eventName: EventName, listener: EventListener<ModuleEvents[EventName]>) => void;
|
|
7
|
+
emit: <EventName extends keyof ModuleEvents>(eventName: EventName, ...args: ModuleEvents[EventName]) => void;
|
|
8
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import EE from "event-emitter";
|
|
2
|
+
export function mkEventHub() {
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
4
|
+
const Emitter = function () { };
|
|
5
|
+
EE(Emitter.prototype);
|
|
6
|
+
const emitter = new Emitter();
|
|
7
|
+
const originalEmit = emitter.emit;
|
|
8
|
+
const emit = (eventName, args) => originalEmit.apply(emitter, [eventName, ...args]);
|
|
9
|
+
return Object.assign(emitter, {
|
|
10
|
+
emit: (eventName, ...args) => {
|
|
11
|
+
emit(eventName, args);
|
|
12
|
+
emit("*", [{ eventName, arguments: args }]);
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=eventHub.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventHub.js","sourceRoot":"","sources":["../../../../../modules/common/modules/eventHub.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,eAAe,CAAC;AAE/B,MAAM,UAAU,UAAU;IACxB,gEAAgE;IAChE,MAAM,OAAO,GAAG,cAAa,CAAC,CAAC;IAC/B,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACtB,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAC9B,MAAM,YAAY,GAAG,OAAO,CAAC,IAAwB,CAAC;IACtD,MAAM,IAAI,GAAG,CAAC,SAAiB,EAAE,IAAe,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;IACvG,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE;QAC5B,IAAI,EAAE,CAAC,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE;YAC3B,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YACtB,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC9C,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function loadAsyncAsset(url: string, type?: "script" | "style"): Promise<void>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import loader from "load-script-promise";
|
|
2
|
+
export function loadAsyncAsset(url, type = "script") {
|
|
3
|
+
if (type === "script")
|
|
4
|
+
return loader.loadScript(url);
|
|
5
|
+
if (type === "style")
|
|
6
|
+
return loader.loadCSS(url);
|
|
7
|
+
return Promise.reject("No valid loader type");
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=loadAsyncAsset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadAsyncAsset.js","sourceRoot":"","sources":["../../../../../modules/common/modules/loadAsyncAsset.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,qBAAqB,CAAC;AAEzC,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAA2B,QAAQ;IAC7E,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IACrD,IAAI,IAAI,KAAK,OAAO;QAAE,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACjD,OAAO,OAAO,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as merge } from "lodash.merge";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.js","sourceRoot":"","sources":["../../../../../modules/common/modules/merge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Vendor } from "../../device";
|
|
2
|
+
export declare type RecipeConfiguration = {
|
|
3
|
+
name?: string;
|
|
4
|
+
device?: {
|
|
5
|
+
provider: {
|
|
6
|
+
name: Vendor;
|
|
7
|
+
clientID: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
ocr?: {
|
|
11
|
+
provider: {
|
|
12
|
+
name: "ocrlabs";
|
|
13
|
+
tx_id: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
biometrics?: {
|
|
17
|
+
provider: {
|
|
18
|
+
name: "ocrlabs";
|
|
19
|
+
tx_id: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Configuration.js","sourceRoot":"","sources":["../../../../../modules/common/types/Configuration.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const VendorList: readonly ["sardine", "threatmetrix"];
|
|
2
|
+
export declare const ActivityTypeList: readonly ["REGISTRATION", "LOGIN", "LOGOUT"];
|
|
3
|
+
export declare type Vendor = typeof VendorList[number];
|
|
4
|
+
export declare type ActivityType = typeof ActivityTypeList[number];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../modules/device/constants.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,SAAS,EAAE,cAAc,CAAU,CAAC;AAC/D,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,cAAc,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { mkEventHub } from "../common";
|
|
2
|
+
import { validateConfiguration } from "./parseConfiguration";
|
|
3
|
+
export * from "./types";
|
|
4
|
+
export * from "./constants";
|
|
5
|
+
const loadVendorSdk = async (vendor) => {
|
|
6
|
+
let moduleLoader; /** Expects file with interface { wrapper: VendorWrapper } */
|
|
7
|
+
if (vendor === "sardine")
|
|
8
|
+
moduleLoader = import(/* webpackChunkName: 'device-sardine' */ "./vendors/Sardine");
|
|
9
|
+
if (vendor === "threatmetrix")
|
|
10
|
+
moduleLoader = import(/* webpackChunkName: 'device-threatmetrix' */ "./vendors/Threatmetrix");
|
|
11
|
+
if (!moduleLoader)
|
|
12
|
+
throw new Error(`Vendor not recognised: '${vendor}'`);
|
|
13
|
+
return moduleLoader.then((module) => module.wrapper);
|
|
14
|
+
};
|
|
15
|
+
export const deviceModule = {
|
|
16
|
+
initialise(options) {
|
|
17
|
+
/**
|
|
18
|
+
* All the oneSdk components expose a synchronous "ModuleContext" object whose properties
|
|
19
|
+
* need to be declared outside the asynchronous "main" function. They are then "passed down" to be used by the main function.
|
|
20
|
+
*
|
|
21
|
+
* This keeps all modules initialisation signatures uniform.
|
|
22
|
+
* The "main" function is assynchronous and will return data in form of events.
|
|
23
|
+
*
|
|
24
|
+
* The set function allows customer to make "late" changes to internal module data (after initialisation options).
|
|
25
|
+
* Things such as set "username/email/applicant reference" as soon as they are discovered
|
|
26
|
+
* The on and off functions allow customers to listen for internal lifecycle events
|
|
27
|
+
*/
|
|
28
|
+
// Validate configuration or interrupt flow by throwing error.
|
|
29
|
+
options = validateConfiguration(options);
|
|
30
|
+
// Create a new event hub separated from the global event hub to be distributed across the modules's lifecycle
|
|
31
|
+
// Maybe we should just use the one event hub passed in the options object for all the modules of the one sdk?
|
|
32
|
+
// For that the events dictionary for all modules would need to be centralised
|
|
33
|
+
// const eventHub = options.globalEventHub; <-- this
|
|
34
|
+
const eventHub = mkEventHub(); // <--instead of this
|
|
35
|
+
const { recipe, globalEventHub } = options;
|
|
36
|
+
let vendorContext = null;
|
|
37
|
+
// main will trigger the following procedure
|
|
38
|
+
// - determine vendor from recipe configuration
|
|
39
|
+
// - load vendor sdk (async)
|
|
40
|
+
// - initialise vendor session (async)
|
|
41
|
+
// - initialise vendor sdk (async)
|
|
42
|
+
// - provide vendor context object as soon as sdk is initialised.
|
|
43
|
+
// - Vendor context API is the same for all vendors. All the particularities are implemented within the vendor wrapper
|
|
44
|
+
const main = async () => {
|
|
45
|
+
const provider = recipe.device.provider.name;
|
|
46
|
+
vendorContext = await loadVendorSdk(provider)
|
|
47
|
+
.then((sdk) => sdk.initialise({ ...options, eventHub }))
|
|
48
|
+
.then((context) => {
|
|
49
|
+
eventHub.emit("vendor_sdk_loaded", { vendor: provider });
|
|
50
|
+
return context;
|
|
51
|
+
})
|
|
52
|
+
.catch((errorObject) => {
|
|
53
|
+
eventHub.emit("vendor_sdk_failed_loading", { vendor: provider, errorObject });
|
|
54
|
+
return null;
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
// reemit/transform events
|
|
58
|
+
eventHub.on("value_set", ({ key, value }) => {
|
|
59
|
+
// when event "value_set" happens for activity type,
|
|
60
|
+
// reemit event as the more meaninful "activity_started"
|
|
61
|
+
if (key === "activityType")
|
|
62
|
+
eventHub.emit("activity_started", { activityType: value });
|
|
63
|
+
});
|
|
64
|
+
const startActivity = async (activityType) => {
|
|
65
|
+
vendorContext.set("activityType", activityType);
|
|
66
|
+
};
|
|
67
|
+
if (!vendorContext)
|
|
68
|
+
main();
|
|
69
|
+
else
|
|
70
|
+
globalEventHub.emit("warning", { message: "Double initialisation of Device module detected." });
|
|
71
|
+
return {
|
|
72
|
+
on: (...args) => void eventHub.on(...args),
|
|
73
|
+
off: (...args) => void eventHub.off(...args),
|
|
74
|
+
// Experiment: If calling startActivity on a uninitialised vendor, it will first automatically
|
|
75
|
+
// wait for the event vendor_sdk_loaded and then try again
|
|
76
|
+
// Not sure we're still going to use method "startActivity", TBD
|
|
77
|
+
startActivity: runIfWhen({
|
|
78
|
+
run: startActivity,
|
|
79
|
+
condition: () => Boolean(vendorContext),
|
|
80
|
+
elseWaitFor: "vendor_sdk_loaded",
|
|
81
|
+
eventHub,
|
|
82
|
+
}),
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
const runIfWhen = (opt) => ((...args) => new Promise((resolve) => {
|
|
87
|
+
if (opt.condition())
|
|
88
|
+
resolve(opt.run(...args));
|
|
89
|
+
else {
|
|
90
|
+
opt.eventHub.on(opt.elseWaitFor, async () => {
|
|
91
|
+
resolve(opt.run(...args));
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}));
|
|
95
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../modules/device/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { BaseModuleOptions } from "../sdk/types";
|
|
2
|
+
import { UserModuleOptions } from "./types";
|
|
3
|
+
declare type AllConfiguration = BaseModuleOptions & UserModuleOptions;
|
|
4
|
+
export declare function validateConfiguration(options: AllConfiguration): AllConfiguration;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function validateConfiguration(options) {
|
|
2
|
+
const { globalEventHub, recipe } = options;
|
|
3
|
+
const interruptWithError = mkErrorEmitter(globalEventHub, options);
|
|
4
|
+
if (!recipe.device)
|
|
5
|
+
interruptWithError("Missing device configuration.");
|
|
6
|
+
return options;
|
|
7
|
+
}
|
|
8
|
+
const mkErrorEmitter = (globalEventHub, options) => (message) => {
|
|
9
|
+
globalEventHub.emit("error", {
|
|
10
|
+
message: `${message} look for 'payload' in the 'error' event.`,
|
|
11
|
+
payload: options,
|
|
12
|
+
});
|
|
13
|
+
throw new Error(message);
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=parseConfiguration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseConfiguration.js","sourceRoot":"","sources":["../../../../modules/device/parseConfiguration.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,qBAAqB,CAAC,OAAyB;IAC7D,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC3C,MAAM,kBAAkB,GAAG,cAAc,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAEnE,IAAI,CAAC,MAAM,CAAC,MAAM;QAAE,kBAAkB,CAAC,+BAA+B,CAAC,CAAC;IACxE,OAAO,OAAO,CAAC;AACjB,CAAC;AACD,MAAM,cAAc,GAAG,CAAC,cAAsC,EAAE,OAAyB,EAAE,EAAE,CAAC,CAAC,OAAe,EAAE,EAAE;IAChH,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE;QAC3B,OAAO,EAAE,GAAG,OAAO,2CAA2C;QAC9D,OAAO,EAAE,OAAO;KACjB,CAAC,CAAC;IACH,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;AAC3B,CAAC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { RecipeConfiguration } from "../../common";
|
|
2
|
+
import { ActivityType, Vendor } from "../constants";
|
|
3
|
+
export declare type Events = {
|
|
4
|
+
configuration_loaded: [RecipeConfiguration];
|
|
5
|
+
activity_started: [{
|
|
6
|
+
activityType: ActivityType;
|
|
7
|
+
}];
|
|
8
|
+
device_details_extracted: [{
|
|
9
|
+
device: Record<string, string | number | object>;
|
|
10
|
+
}];
|
|
11
|
+
completed: [Core["DeviceDetailsObject"]];
|
|
12
|
+
vendor_sdk_loaded: [{
|
|
13
|
+
vendor: Vendor;
|
|
14
|
+
}];
|
|
15
|
+
vendor_sdk_failed_loading: [{
|
|
16
|
+
vendor: Vendor;
|
|
17
|
+
errorObject: any;
|
|
18
|
+
}];
|
|
19
|
+
session_data_generated: [{
|
|
20
|
+
session: Record<string, any>;
|
|
21
|
+
}];
|
|
22
|
+
value_set: [{
|
|
23
|
+
key: string;
|
|
24
|
+
value: unknown;
|
|
25
|
+
}];
|
|
26
|
+
};
|
|
27
|
+
interface Core {
|
|
28
|
+
DeviceDetailsObject: Record<string, never>;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../../../../modules/device/types/events.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/device/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseModuleOptions } from "../../sdk/types";
|
|
2
|
+
import { EventHub } from "../../common";
|
|
3
|
+
import { ActivityType } from "../constants";
|
|
4
|
+
import { Events } from "./events";
|
|
5
|
+
export interface DeviceModule {
|
|
6
|
+
initialise: (o: BaseModuleOptions & UserModuleOptions) => DeviceModuleContext;
|
|
7
|
+
}
|
|
8
|
+
export interface UserModuleOptions {
|
|
9
|
+
page: string;
|
|
10
|
+
}
|
|
11
|
+
export interface DeviceModuleContext extends Omit<EventHub<Events>, "emit"> {
|
|
12
|
+
startActivity: StartActivityFunction;
|
|
13
|
+
}
|
|
14
|
+
export declare type StartActivityFunction = (activityType: ActivityType) => Promise<void>;
|
|
15
|
+
export declare type EndActivityFunction = () => Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../../../../modules/device/types/module.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { EventHub } from "../../common";
|
|
2
|
+
import { ActivityType, Vendor } from "../constants";
|
|
3
|
+
import { Events } from "./events";
|
|
4
|
+
import { BaseModuleOptions } from "../../sdk/types";
|
|
5
|
+
import { UserModuleOptions } from "./module";
|
|
6
|
+
export interface WrapperModule {
|
|
7
|
+
wrapper: VendorWrapper;
|
|
8
|
+
}
|
|
9
|
+
export interface VendorWrapper {
|
|
10
|
+
readonly vendor: Vendor;
|
|
11
|
+
initialise(o: VendorOptions): Promise<VendorContext>;
|
|
12
|
+
}
|
|
13
|
+
export interface SetOptions {
|
|
14
|
+
activityType: ActivityType;
|
|
15
|
+
entityId: string;
|
|
16
|
+
}
|
|
17
|
+
export interface VendorContext {
|
|
18
|
+
readonly vendor: Vendor;
|
|
19
|
+
set<Key extends keyof SetOptions>(key: Key, value: SetOptions[Key]): void;
|
|
20
|
+
}
|
|
21
|
+
export interface AdditionalDeviceInternalDependencies {
|
|
22
|
+
eventHub: EventHub<Events>;
|
|
23
|
+
}
|
|
24
|
+
export interface SessionData {
|
|
25
|
+
frankieClientID: string;
|
|
26
|
+
customerID: string;
|
|
27
|
+
vendorSessionID: string;
|
|
28
|
+
}
|
|
29
|
+
export declare type VendorOptions = BaseModuleOptions & UserModuleOptions & AdditionalDeviceInternalDependencies;
|
|
30
|
+
export declare type VendorLoaderOptions = {
|
|
31
|
+
module: VendorOptions;
|
|
32
|
+
session: SessionData;
|
|
33
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vendor.js","sourceRoot":"","sources":["../../../../../modules/device/types/vendor.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { VendorWrapper } from "../types/vendor";
|
|
2
|
+
declare const wrapper: VendorWrapper;
|
|
3
|
+
export { wrapper };
|
|
4
|
+
interface SardineSdkOptions {
|
|
5
|
+
clientId: string;
|
|
6
|
+
userIdHash: string;
|
|
7
|
+
flow: string;
|
|
8
|
+
partnerID: string;
|
|
9
|
+
sessionKey: string;
|
|
10
|
+
}
|
|
11
|
+
declare global {
|
|
12
|
+
interface Window {
|
|
13
|
+
_Sardine: {
|
|
14
|
+
createContext(...args: unknown[]): {
|
|
15
|
+
updateConfig(config: Partial<SardineSdkOptions>): void;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { loadAsyncAsset } from "../../common";
|
|
2
|
+
import { v4 as uuid } from "uuid";
|
|
3
|
+
const wrapper = {
|
|
4
|
+
vendor: "sardine",
|
|
5
|
+
async initialise(options) {
|
|
6
|
+
// create session with backend
|
|
7
|
+
const sessionData = await initialiseSardineSession(options);
|
|
8
|
+
options.eventHub.emit("session_data_generated", {
|
|
9
|
+
session: sessionData,
|
|
10
|
+
});
|
|
11
|
+
// initialise sardine sdk
|
|
12
|
+
const sardineContext = await asyncLoadSardine({
|
|
13
|
+
module: options,
|
|
14
|
+
session: sessionData,
|
|
15
|
+
});
|
|
16
|
+
// listen for events, if there are any in the frontend
|
|
17
|
+
// maybe we should implement our own events by websockets, if no frontend events are emitted
|
|
18
|
+
return sardineContext;
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
export { wrapper };
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
23
|
+
async function initialiseSardineSession(options) {
|
|
24
|
+
return {
|
|
25
|
+
customerID: options.session.customerChildID ?? options.session.customerID,
|
|
26
|
+
frankieClientID: options.recipe.device.provider.clientID,
|
|
27
|
+
vendorSessionID: uuid(), // will come from a backend call
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
async function asyncLoadSardine(options) {
|
|
31
|
+
const { mode } = options.module;
|
|
32
|
+
const isProd = mode === "production";
|
|
33
|
+
const sardineHost = isProd ? "api.sardine.ai" : "api.dev.sardine.ai";
|
|
34
|
+
const url = `https://${sardineHost}/assets/loader.min.js`;
|
|
35
|
+
await loadAsyncAsset(url);
|
|
36
|
+
const sardineContext = window._Sardine.createContext({
|
|
37
|
+
clientId: options.session.frankieClientID,
|
|
38
|
+
partnerID: options.session.customerID,
|
|
39
|
+
sessionKey: options.session.vendorSessionID,
|
|
40
|
+
parentElement: document.body,
|
|
41
|
+
environment: isProd ? "production" : "development",
|
|
42
|
+
onDeviceResponse: function (data) {
|
|
43
|
+
options.module.eventHub.emit("device_details_extracted", {
|
|
44
|
+
device: data,
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
vendor: "sardine",
|
|
50
|
+
set(key, value) {
|
|
51
|
+
const mappedKey = mapF2S[key];
|
|
52
|
+
if (mappedKey) {
|
|
53
|
+
sardineContext.updateConfig({ [mappedKey]: value });
|
|
54
|
+
options.module.eventHub.emit("value_set", { key, value });
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const mapF2S = {
|
|
60
|
+
entityId: "userIdHash",
|
|
61
|
+
activityType: "flow",
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=Sardine.js.map
|