@frankieone/one-sdk 0.6.7-rc.1 → 0.7.0-alpha

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.
Files changed (212) hide show
  1. package/README.md +1 -1
  2. package/dist/commit.txt +2 -2
  3. package/dist/esm/modules/biometrics/{types/events.d.ts → events.d.ts} +2 -2
  4. package/dist/esm/modules/biometrics/events.js.map +1 -0
  5. package/dist/esm/modules/biometrics/index.d.ts +12 -3
  6. package/dist/esm/modules/biometrics/index.js +58 -75
  7. package/dist/esm/modules/biometrics/index.js.map +1 -1
  8. package/dist/esm/modules/biometrics/parseConfiguration.d.ts +2 -4
  9. package/dist/esm/modules/biometrics/parseConfiguration.js +0 -1
  10. package/dist/esm/modules/biometrics/parseConfiguration.js.map +1 -1
  11. package/dist/esm/modules/biometrics/vendors/OcrLabs/Liveness.js.map +1 -0
  12. package/dist/esm/modules/biometrics/vendors/OcrLabs/index.d.ts +4 -0
  13. package/dist/esm/modules/biometrics/{wrappers → vendors}/OcrLabs/index.js +15 -20
  14. package/dist/esm/modules/biometrics/vendors/OcrLabs/index.js.map +1 -0
  15. package/dist/esm/modules/biometrics/vendors/OcrLabs/nolint_liveness-v3.1.1.min.umd.js.map +1 -0
  16. package/dist/esm/modules/biometrics/vendors/dummy-biometrics/green-tick-svg.js.map +1 -0
  17. package/dist/esm/modules/biometrics/vendors/dummy-biometrics/index.d.ts +3 -0
  18. package/dist/esm/modules/biometrics/{wrappers → vendors}/dummy-biometrics/index.js +10 -16
  19. package/dist/esm/modules/biometrics/vendors/dummy-biometrics/index.js.map +1 -0
  20. package/dist/esm/modules/common/index.d.ts +4 -3
  21. package/dist/esm/modules/common/index.js +4 -3
  22. package/dist/esm/modules/common/index.js.map +1 -1
  23. package/dist/esm/modules/common/modules/HOF.d.ts +7 -18
  24. package/dist/esm/modules/common/modules/HOF.js +26 -9
  25. package/dist/esm/modules/common/modules/HOF.js.map +1 -1
  26. package/dist/esm/modules/common/modules/eventHub.d.ts +2 -2
  27. package/dist/esm/modules/common/modules/vendorLoading.d.ts +69 -45
  28. package/dist/esm/modules/common/modules/vendorLoading.js +134 -67
  29. package/dist/esm/modules/common/modules/vendorLoading.js.map +1 -1
  30. package/dist/esm/modules/common/types/Accessors.d.ts +3 -3
  31. package/dist/esm/modules/common/types/RecipeConfiguration.js +2 -0
  32. package/dist/esm/modules/common/types/RecipeConfiguration.js.map +1 -0
  33. package/dist/esm/modules/configuration.d.ts +18 -0
  34. package/dist/esm/modules/configuration.js +16 -0
  35. package/dist/esm/modules/configuration.js.map +1 -0
  36. package/dist/esm/modules/device/constants.d.ts +1 -1
  37. package/dist/esm/modules/device/constants.js +8 -1
  38. package/dist/esm/modules/device/constants.js.map +1 -1
  39. package/dist/esm/modules/device/{types/events.d.ts → events.d.ts} +3 -4
  40. package/dist/esm/modules/device/events.js.map +1 -0
  41. package/dist/esm/modules/device/index.d.ts +22 -3
  42. package/dist/esm/modules/device/index.js +64 -84
  43. package/dist/esm/modules/device/index.js.map +1 -1
  44. package/dist/esm/modules/device/parseConfiguration.d.ts +2 -5
  45. package/dist/esm/modules/device/parseConfiguration.js +3 -4
  46. package/dist/esm/modules/device/parseConfiguration.js.map +1 -1
  47. package/dist/esm/modules/device/vendors/Sardine.d.ts +3 -2
  48. package/dist/esm/modules/device/vendors/Sardine.js +36 -34
  49. package/dist/esm/modules/device/vendors/Sardine.js.map +1 -1
  50. package/dist/esm/modules/device/vendors/Threatmetrix/index.d.ts +3 -2
  51. package/dist/esm/modules/device/vendors/Threatmetrix/index.js +18 -30
  52. package/dist/esm/modules/device/vendors/Threatmetrix/index.js.map +1 -1
  53. package/dist/esm/modules/federation/events.js.map +1 -0
  54. package/dist/esm/modules/federation/index.d.ts +12 -3
  55. package/dist/esm/modules/federation/index.js +46 -65
  56. package/dist/esm/modules/federation/index.js.map +1 -1
  57. package/dist/esm/modules/federation/parseConfiguration.d.ts +2 -2
  58. package/dist/esm/modules/federation/parseConfiguration.js +9 -9
  59. package/dist/esm/modules/federation/parseConfiguration.js.map +1 -1
  60. package/dist/esm/modules/federation/vendors/Singpass.d.ts +4 -3
  61. package/dist/esm/modules/federation/vendors/Singpass.js +16 -23
  62. package/dist/esm/modules/federation/vendors/Singpass.js.map +1 -1
  63. package/dist/esm/modules/frankie-client/index.d.ts +2 -2
  64. package/dist/esm/modules/frankie-client/index.js +8 -4
  65. package/dist/esm/modules/frankie-client/index.js.map +1 -1
  66. package/dist/esm/modules/index.d.ts +8 -3
  67. package/dist/esm/modules/index.js +19 -1
  68. package/dist/esm/modules/index.js.map +1 -1
  69. package/dist/esm/modules/individual/actions/documents.d.ts +1 -1
  70. package/dist/esm/modules/individual/actions/emitEvents.d.ts +1 -1
  71. package/dist/esm/modules/individual/actions/search.d.ts +1 -1
  72. package/dist/esm/modules/individual/actions/search.js.map +1 -1
  73. package/dist/esm/modules/individual/actions/submit.d.ts +2 -2
  74. package/dist/esm/modules/individual/actions/submit.js.map +1 -1
  75. package/dist/esm/modules/individual/{types/events.d.ts → events.d.ts} +1 -1
  76. package/dist/esm/modules/individual/events.js.map +1 -0
  77. package/dist/esm/modules/individual/index.d.ts +29 -2
  78. package/dist/esm/modules/individual/index.js +66 -67
  79. package/dist/esm/modules/individual/index.js.map +1 -1
  80. package/dist/esm/modules/meta.json +1 -1
  81. package/dist/esm/modules/ocr/actions/start.d.ts +2 -2
  82. package/dist/esm/modules/ocr/{types/events.d.ts → events.d.ts} +2 -2
  83. package/dist/esm/modules/ocr/events.js.map +1 -0
  84. package/dist/esm/modules/ocr/index.d.ts +29 -8
  85. package/dist/esm/modules/ocr/index.js +45 -52
  86. package/dist/esm/modules/ocr/index.js.map +1 -1
  87. package/dist/esm/modules/sdk/index.d.ts +1 -1
  88. package/dist/esm/modules/sdk/index.js +11 -11
  89. package/dist/esm/modules/sdk/index.js.map +1 -1
  90. package/dist/esm/modules/sdk/initialisation/componentLoader.d.ts +1 -1
  91. package/dist/esm/modules/sdk/initialisation/componentLoader.js +24 -10
  92. package/dist/esm/modules/sdk/initialisation/componentLoader.js.map +1 -1
  93. package/dist/esm/modules/sdk/initialisation/configurationParser.d.ts +9 -10
  94. package/dist/esm/modules/sdk/initialisation/configurationParser.js +39 -20
  95. package/dist/esm/modules/sdk/initialisation/configurationParser.js.map +1 -1
  96. package/dist/esm/modules/sdk/initialisation/sharedDependencies.d.ts +2 -3
  97. package/dist/esm/modules/sdk/initialisation/sharedDependencies.js +6 -4
  98. package/dist/esm/modules/sdk/initialisation/sharedDependencies.js.map +1 -1
  99. package/dist/esm/modules/sdk/types/{events.d.ts → globalEvents.d.ts} +2 -2
  100. package/dist/esm/modules/sdk/types/globalEvents.js +2 -0
  101. package/dist/esm/modules/sdk/types/globalEvents.js.map +1 -0
  102. package/dist/esm/modules/sdk/types/index.d.ts +5 -4
  103. package/dist/esm/modules/sdk/types/index.js +5 -4
  104. package/dist/esm/modules/sdk/types/index.js.map +1 -1
  105. package/dist/esm/modules/sdk/types/oneSDK.d.ts +13 -0
  106. package/dist/esm/modules/sdk/types/oneSDK.js +2 -0
  107. package/dist/esm/modules/sdk/types/oneSDK.js.map +1 -0
  108. package/dist/esm/modules/sdk/types/oneSDKModules.d.ts +82 -0
  109. package/dist/esm/modules/sdk/types/oneSDKModules.js +2 -0
  110. package/dist/esm/modules/sdk/types/oneSDKModules.js.map +1 -0
  111. package/dist/esm/modules/sdk/types/{configuration.d.ts → oneSDKParameters.d.ts} +6 -20
  112. package/dist/esm/modules/sdk/types/oneSDKParameters.js +8 -0
  113. package/dist/esm/modules/sdk/types/oneSDKParameters.js.map +1 -0
  114. package/dist/esm/modules/sdk/types/oneSDKVendorWrappers.d.ts +11 -0
  115. package/dist/esm/modules/sdk/types/oneSDKVendorWrappers.js +2 -0
  116. package/dist/esm/modules/sdk/types/oneSDKVendorWrappers.js.map +1 -0
  117. package/dist/esm/modules/session/SessionContext.d.ts +4 -1
  118. package/dist/esm/modules/session/SessionContext.js +6 -0
  119. package/dist/esm/modules/session/SessionContext.js.map +1 -1
  120. package/dist/esm/modules/session/index.d.ts +4 -5
  121. package/dist/esm/modules/session/index.js +21 -23
  122. package/dist/esm/modules/session/index.js.map +1 -1
  123. package/dist/esm/types/Primitives.d.ts +9 -1
  124. package/dist/esm/types/Utilities.d.ts +12 -0
  125. package/dist/release.txt +2 -2
  126. package/dist/umd/biometrics-dummy.js +1 -1
  127. package/dist/umd/biometrics-dummy.js.map +1 -1
  128. package/dist/umd/biometrics-ocrlabs.js +1 -1
  129. package/dist/umd/biometrics-ocrlabs.js.map +1 -1
  130. package/dist/umd/device-sardine.js +1 -1
  131. package/dist/umd/device-sardine.js.map +1 -1
  132. package/dist/umd/device-threatmetrix.js +1 -1
  133. package/dist/umd/device-threatmetrix.js.map +1 -1
  134. package/dist/umd/oneSdk.umd.js +1 -1
  135. package/dist/umd/oneSdk.umd.js.map +1 -1
  136. package/dist/version.txt +2 -2
  137. package/package.json +1 -1
  138. package/dist/esm/modules/biometrics/types/events.js.map +0 -1
  139. package/dist/esm/modules/biometrics/types/index.d.ts +0 -3
  140. package/dist/esm/modules/biometrics/types/index.js +0 -4
  141. package/dist/esm/modules/biometrics/types/index.js.map +0 -1
  142. package/dist/esm/modules/biometrics/types/module.d.ts +0 -8
  143. package/dist/esm/modules/biometrics/types/module.js +0 -2
  144. package/dist/esm/modules/biometrics/types/module.js.map +0 -1
  145. package/dist/esm/modules/biometrics/types/wrapper.d.ts +0 -19
  146. package/dist/esm/modules/biometrics/types/wrapper.js +0 -2
  147. package/dist/esm/modules/biometrics/types/wrapper.js.map +0 -1
  148. package/dist/esm/modules/biometrics/wrappers/OcrLabs/Liveness.js.map +0 -1
  149. package/dist/esm/modules/biometrics/wrappers/OcrLabs/index.d.ts +0 -3
  150. package/dist/esm/modules/biometrics/wrappers/OcrLabs/index.js.map +0 -1
  151. package/dist/esm/modules/biometrics/wrappers/OcrLabs/nolint_liveness-v3.1.1.min.umd.js.map +0 -1
  152. package/dist/esm/modules/biometrics/wrappers/dummy-biometrics/green-tick-svg.js.map +0 -1
  153. package/dist/esm/modules/biometrics/wrappers/dummy-biometrics/index.d.ts +0 -2
  154. package/dist/esm/modules/biometrics/wrappers/dummy-biometrics/index.js.map +0 -1
  155. package/dist/esm/modules/common/constants.d.ts +0 -8
  156. package/dist/esm/modules/common/constants.js +0 -11
  157. package/dist/esm/modules/common/constants.js.map +0 -1
  158. package/dist/esm/modules/common/types/Configuration.js +0 -2
  159. package/dist/esm/modules/common/types/Configuration.js.map +0 -1
  160. package/dist/esm/modules/device/types/events.js.map +0 -1
  161. package/dist/esm/modules/device/types/index.d.ts +0 -3
  162. package/dist/esm/modules/device/types/index.js +0 -4
  163. package/dist/esm/modules/device/types/index.js.map +0 -1
  164. package/dist/esm/modules/device/types/module.d.ts +0 -13
  165. package/dist/esm/modules/device/types/module.js +0 -2
  166. package/dist/esm/modules/device/types/module.js.map +0 -1
  167. package/dist/esm/modules/device/types/wrapper.d.ts +0 -34
  168. package/dist/esm/modules/device/types/wrapper.js +0 -2
  169. package/dist/esm/modules/device/types/wrapper.js.map +0 -1
  170. package/dist/esm/modules/federation/types/events.js.map +0 -1
  171. package/dist/esm/modules/federation/types/module.d.ts +0 -8
  172. package/dist/esm/modules/federation/types/module.js +0 -2
  173. package/dist/esm/modules/federation/types/module.js.map +0 -1
  174. package/dist/esm/modules/federation/types/wrapper.d.ts +0 -18
  175. package/dist/esm/modules/federation/types/wrapper.js +0 -2
  176. package/dist/esm/modules/federation/types/wrapper.js.map +0 -1
  177. package/dist/esm/modules/individual/types/events.js.map +0 -1
  178. package/dist/esm/modules/individual/types/index.d.ts +0 -2
  179. package/dist/esm/modules/individual/types/index.js +0 -3
  180. package/dist/esm/modules/individual/types/index.js.map +0 -1
  181. package/dist/esm/modules/individual/types/module.d.ts +0 -31
  182. package/dist/esm/modules/individual/types/module.js +0 -2
  183. package/dist/esm/modules/individual/types/module.js.map +0 -1
  184. package/dist/esm/modules/ocr/types/events.js.map +0 -1
  185. package/dist/esm/modules/ocr/types/index.d.ts +0 -2
  186. package/dist/esm/modules/ocr/types/index.js +0 -3
  187. package/dist/esm/modules/ocr/types/index.js.map +0 -1
  188. package/dist/esm/modules/ocr/types/module.d.ts +0 -26
  189. package/dist/esm/modules/ocr/types/module.js +0 -2
  190. package/dist/esm/modules/ocr/types/module.js.map +0 -1
  191. package/dist/esm/modules/sdk/types/components.d.ts +0 -25
  192. package/dist/esm/modules/sdk/types/components.js +0 -2
  193. package/dist/esm/modules/sdk/types/components.js.map +0 -1
  194. package/dist/esm/modules/sdk/types/configuration.js +0 -38
  195. package/dist/esm/modules/sdk/types/configuration.js.map +0 -1
  196. package/dist/esm/modules/sdk/types/events.js +0 -2
  197. package/dist/esm/modules/sdk/types/events.js.map +0 -1
  198. package/dist/esm/modules/sdk/types/module.d.ts +0 -16
  199. package/dist/esm/modules/sdk/types/module.js +0 -2
  200. package/dist/esm/modules/sdk/types/module.js.map +0 -1
  201. /package/dist/esm/modules/biometrics/{types/events.js → events.js} +0 -0
  202. /package/dist/esm/modules/biometrics/{wrappers → vendors}/OcrLabs/Liveness.d.ts +0 -0
  203. /package/dist/esm/modules/biometrics/{wrappers → vendors}/OcrLabs/Liveness.js +0 -0
  204. /package/dist/esm/modules/biometrics/{wrappers → vendors}/OcrLabs/nolint_liveness-v3.1.1.min.umd.js +0 -0
  205. /package/dist/esm/modules/biometrics/{wrappers → vendors}/dummy-biometrics/green-tick-svg.d.ts +0 -0
  206. /package/dist/esm/modules/biometrics/{wrappers → vendors}/dummy-biometrics/green-tick-svg.js +0 -0
  207. /package/dist/esm/modules/common/types/{Configuration.d.ts → RecipeConfiguration.d.ts} +0 -0
  208. /package/dist/esm/modules/device/{types/events.js → events.js} +0 -0
  209. /package/dist/esm/modules/federation/{types/events.d.ts → events.d.ts} +0 -0
  210. /package/dist/esm/modules/federation/{types/events.js → events.js} +0 -0
  211. /package/dist/esm/modules/individual/{types/events.js → events.js} +0 -0
  212. /package/dist/esm/modules/ocr/{types/events.js → events.js} +0 -0
@@ -0,0 +1,18 @@
1
+ /** MODULE TYPES */
2
+ export declare type PublicModuleName = "biometrics" | "device" | "ocr" | "federation";
3
+ export declare type PrivateModuleName = "individual";
4
+ export declare type PreInitialisationModuleName = "session";
5
+ /** MODULES DICTIONARY */
6
+ export declare const ModulesDictionary: {
7
+ readonly biometrics: import("./sdk").ModuleInitialiseFunction<"biometrics", import("./biometrics").BiometricsModuleContext, void>;
8
+ readonly device: import("./sdk").ModuleInitialiseFunction<"device", import("./device").DeviceModuleContext, import("./device").DeviceModuleOptions>;
9
+ readonly ocr: import("./sdk").ModuleInitialiseFunction<"ocr", import("./ocr").OcrModuleContext, void>;
10
+ readonly federation: import("./sdk").ModuleInitialiseFunction<"federation", import("./federation").FederationModuleContext, void>;
11
+ readonly individual: import("./sdk").ModuleInitialiseFunction<"individual", import("./individual").IndividualModuleContext, void>;
12
+ readonly session: import("./sdk").ModuleInitialiseFunction<"session", import("./session/SessionContext").SessionContext, void>;
13
+ };
14
+ export declare type ModulesDictionary = typeof ModulesDictionary;
15
+ export declare type PublicModulesDictionary = Pick<ModulesDictionary, PublicModuleName>;
16
+ export declare type PrivateModulesDictionary = Pick<ModulesDictionary, PrivateModuleName>;
17
+ export declare type PreInitialisationModulesDictionary = Pick<ModulesDictionary, PreInitialisationModuleName>;
18
+ export declare type AllModules = PublicModuleName | PrivateModuleName | PreInitialisationModuleName;
@@ -0,0 +1,16 @@
1
+ import { initialise as biometricsModule } from "./biometrics";
2
+ import { initialise as deviceModule } from "./device";
3
+ import { initialise as federationModule } from "./federation";
4
+ import { initialise as ocrModule } from "./ocr";
5
+ import { initialise as sessionModule } from "./session";
6
+ import { initialise as individualModule } from "./individual";
7
+ /** MODULES DICTIONARY */
8
+ export const ModulesDictionary = {
9
+ biometrics: biometricsModule,
10
+ device: deviceModule,
11
+ ocr: ocrModule,
12
+ federation: federationModule,
13
+ individual: individualModule,
14
+ session: sessionModule,
15
+ };
16
+ //# sourceMappingURL=configuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../../modules/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,UAAU,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,UAAU,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAapE,yBAAyB;AAEzB,MAAM,CAAC,MAAM,iBAAiB,GAAU;IACtC,UAAU,EAAE,gBAAgB;IAC5B,MAAM,EAAE,YAAY;IACpB,GAAG,EAAE,SAAS;IACd,UAAU,EAAE,gBAAgB;IAC5B,UAAU,EAAE,gBAAgB;IAC5B,OAAO,EAAE,aAAa;CACvB,CAAC"}
@@ -1,4 +1,4 @@
1
1
  export declare const VendorList: readonly ["sardine", "threatmetrix"];
2
- export declare const ActivityTypeList: readonly ["REGISTRATION", "LOGIN"];
2
+ export declare const ActivityTypeList: readonly ["REGISTRATION", "LOGIN", "CRYPTO_DEPOSIT", "CRYPTO_WITHDRAWAL", "FIAT_DEPOSIT", "FIAT_WITHDRAWAL"];
3
3
  export declare type Vendor = typeof VendorList[number];
4
4
  export declare type ActivityType = typeof ActivityTypeList[number];
@@ -1,4 +1,11 @@
1
1
  // hard coded list of supported vendors which maps directly to a vendor wrapper
2
2
  export const VendorList = ["sardine", "threatmetrix"];
3
- export const ActivityTypeList = ["REGISTRATION", "LOGIN"];
3
+ export const ActivityTypeList = [
4
+ "REGISTRATION",
5
+ "LOGIN",
6
+ "CRYPTO_DEPOSIT",
7
+ "CRYPTO_WITHDRAWAL",
8
+ "FIAT_DEPOSIT",
9
+ "FIAT_WITHDRAWAL",
10
+ ];
4
11
  //# sourceMappingURL=constants.js.map
@@ -1 +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,CAAU,CAAC"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../modules/device/constants.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,MAAM,CAAC,MAAM,UAAU,GAAU,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;AAC7D,MAAM,CAAC,MAAM,gBAAgB,GAAU;IACrC,cAAc;IACd,OAAO;IACP,gBAAgB;IAChB,mBAAmB;IACnB,cAAc;IACd,iBAAiB;CAClB,CAAC"}
@@ -1,6 +1,5 @@
1
- import { RecipeConfiguration } from "../../common";
2
- import { ActivityType, Vendor } from "../constants";
3
- import { SessionData } from "./wrapper";
1
+ import { RecipeConfiguration } from "../common";
2
+ import { ActivityType, Vendor } from "./constants";
4
3
  export declare type Events = {
5
4
  configuration_loaded: [RecipeConfiguration];
6
5
  activity_started: [{
@@ -18,7 +17,7 @@ export declare type Events = {
18
17
  errorObject: unknown;
19
18
  }];
20
19
  session_data_generated: [{
21
- session: SessionData;
20
+ session: unknown;
22
21
  }];
23
22
  value_set: [{
24
23
  key: string;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../../../../modules/device/events.ts"],"names":[],"mappings":""}
@@ -1,4 +1,23 @@
1
- import { DeviceModule } from "./types";
1
+ import { EventHub } from "../common";
2
+ import { ModuleContext, ModuleInitialiseFunction } from "../sdk";
3
+ import { ActivityType } from "./constants";
4
+ import { Events } from "./events";
2
5
  export * from "./constants";
3
- export * from "./types";
4
- export declare const deviceModule: DeviceModule;
6
+ export * from "./events";
7
+ export declare const initialise: ModuleInitialiseFunction<"device", DeviceModuleContext, DeviceModuleOptions>;
8
+ export declare type DeviceModuleOptions = {
9
+ activityType: ActivityType;
10
+ };
11
+ export declare type DeviceModuleContext = ModuleContext<{
12
+ start: () => void;
13
+ }, Events>;
14
+ export declare type DeviceWrapperOptions = DeviceModuleOptions & {
15
+ eventHub: EventHub<Events>;
16
+ };
17
+ export declare type DeviceWrapperContext = {
18
+ set<Key extends keyof SetOptions>(key: Key, value: SetOptions[Key]): void;
19
+ };
20
+ export declare type SetOptions = {
21
+ activityType: ActivityType;
22
+ entityId: string;
23
+ };
@@ -1,89 +1,69 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { loadAndInitialiseVendor, mkEventHub, mkEventListener } from "../common";
1
+ import { mkEventHub, mkEventListener, mkVendorLoader } from "../common";
11
2
  import { validateConfiguration } from "./parseConfiguration";
12
3
  export * from "./constants";
13
- export * from "./types";
14
- export const deviceModule = {
15
- initialise(options) {
16
- /**
17
- * All the oneSdk components expose a synchronous "ModuleContext" object whose properties
18
- * need to be declared outside the asynchronous "main" function. They are then "passed down" to be used by the main function.
19
- *
20
- * This keeps all modules initialisation signatures uniform.
21
- * The "main" function is assynchronous and will return data in form of events.
22
- *
23
- * The set function allows customer to make "late" changes to internal module data (after initialisation options).
24
- * Things such as set "username/email/applicant reference" as soon as they are discovered
25
- * The on and off functions allow customers to listen for internal lifecycle events
26
- */
27
- const { globalEventHub } = options;
28
- // Validate configuration or prevent module initialisation by setting
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
- const eventHub = mkEventHub();
33
- let vendorContext = null;
34
- /** Define context methods */
35
- // main will trigger the following procedure
36
- // - determine vendor from recipe configuration
37
- // - load vendor sdk (async)
38
- // - initialise vendor session (async)
39
- // - initialise vendor sdk (async)
40
- // - provide vendor context object as soon as sdk is initialised.
41
- // - Vendor context API is the same for all vendors. All the particularities are implemented within the vendor wrapper
42
- const start = () => {
43
- const vendorName = options.recipe.deviceCharacteristics.provider.name;
44
- loadAndInitialiseVendor({
45
- componentName: "device",
46
- eventHub,
47
- wrapperOptions: Object.assign(Object.assign({}, options), { eventHub }),
48
- vendorName,
49
- moduleOptions: options,
50
- vendorLoader: ({ vendorName }) => __awaiter(this, void 0, void 0, function* () {
51
- let moduleLoader; /** Expects file with interface { wrapper: VendorWrapper } */
52
- if (vendorName === "sardine")
53
- moduleLoader = import(/* webpackChunkName: 'device-sardine' */ "./vendors/Sardine");
54
- if (vendorName === "threatmetrix")
55
- moduleLoader = import(/* webpackChunkName: 'device-threatmetrix' */ "./vendors/Threatmetrix");
56
- if (!moduleLoader)
57
- throw new Error(`Vendor not recognised: '${vendorName}'`);
58
- return moduleLoader.then((module) => module.wrapper);
59
- }),
60
- onSuccess: (context) => {
61
- globalEventHub.emit("telemetry", {
62
- eventName: "DEVICE:MOUNT",
63
- data: { vendor: vendorName },
64
- });
65
- vendorContext = context; // TODO: remove this type casting (doesn't work for ts@6.4)
66
- },
67
- onError: (error) => {
68
- globalEventHub.emit("telemetry", {
69
- eventName: "DEVICE:MOUNT:ERROR",
70
- data: { vendor: vendorName },
71
- error,
72
- });
73
- },
74
- });
75
- };
76
- // const startActivity = async (activityType: ActivityType) => {
77
- // vendorContext.set("activityType", activityType);
78
- // };
79
- /** reemit/map/transform events below */
80
- // value_set: when the value for a field is confirmed by the vendor wrapper to be set
81
- eventHub.on("value_set", ({ key, value }) => {
82
- // When activityType is set, emit another more specific event "activity_started"
83
- if (key === "activityType")
84
- eventHub.emit("activity_started", { activityType: value });
4
+ export * from "./events";
5
+ export const initialise = (shared, options) => {
6
+ /**
7
+ * All the oneSdk components expose a synchronous "ModuleContext" object whose properties
8
+ * need to be declared outside the asynchronous "main" function. They are then "passed down" to be used by the main function.
9
+ *
10
+ * This keeps all modules initialisation signatures uniform.
11
+ * The "main" function is assynchronous and will return data in form of events.
12
+ *
13
+ * The set function allows customer to make "late" changes to internal module data (after initialisation options).
14
+ * Things such as set "username/email/applicant reference" as soon as they are discovered
15
+ * The on and off functions allow customers to listen for internal lifecycle events
16
+ */
17
+ const { globalEventHub } = shared;
18
+ // Validate configuration or prevent module initialisation by throwing an exception
19
+ validateConfiguration(shared);
20
+ // Create a new event hub separated from the global event hub to be distributed across the modules's lifecycle
21
+ // Maybe we should just use the one event hub passed in the options object for all the modules of the one sdk?
22
+ const eventHub = mkEventHub();
23
+ const loadVendor = mkVendorLoader({
24
+ vendorName: shared.recipe.deviceCharacteristics.provider.name,
25
+ sharedConfiguration: shared,
26
+ vendorLoader: {
27
+ sardine: () => import(/* webpackChunkName: 'device-sardine' */ "./vendors/Sardine"),
28
+ threatmetrix: () => import(/* webpackChunkName: 'device-threatmetrix' */ "./vendors/Threatmetrix"),
29
+ },
30
+ });
31
+ /** Define context methods */
32
+ // main will trigger the following procedure
33
+ // - determine vendor from recipe configuration
34
+ // - load vendor sdk (async)
35
+ // - initialise vendor session (async)
36
+ // - initialise vendor sdk (async)
37
+ // - provide vendor context object as soon as sdk is initialised.
38
+ // - Vendor context API is the same for all vendors. All the particularities are implemented within the vendor wrapper
39
+ const start = () => {
40
+ loadVendor({
41
+ vendorWrapperOptions: Object.assign(Object.assign({}, options), { eventHub }),
42
+ onSuccess: (_, { vendorName }) => {
43
+ globalEventHub.emit("telemetry", {
44
+ eventName: "DEVICE:MOUNT",
45
+ data: { vendor: vendorName },
46
+ });
47
+ },
48
+ onError: (error, { vendorName }) => {
49
+ globalEventHub.emit("telemetry", {
50
+ eventName: "DEVICE:MOUNT:ERROR",
51
+ data: { vendor: vendorName },
52
+ error,
53
+ });
54
+ },
85
55
  });
86
- return Object.assign(Object.assign({}, mkEventListener(eventHub)), { start });
87
- },
56
+ };
57
+ // const startActivity = async (activityType: ActivityType) => {
58
+ // vendorContext.set("activityType", activityType);
59
+ // };
60
+ /** reemit/map/transform events below */
61
+ // value_set: when the value for a field is confirmed by the vendor wrapper to be set
62
+ eventHub.on("value_set", ({ key, value }) => {
63
+ // When activityType is set, emit another more specific event "activity_started"
64
+ if (key === "activityType")
65
+ eventHub.emit("activity_started", { activityType: value });
66
+ });
67
+ return Object.assign(Object.assign({}, mkEventListener(eventHub)), { start });
88
68
  };
89
69
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../modules/device/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,uBAAuB,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtF,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAG7D,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AAExB,MAAM,CAAC,MAAM,YAAY,GAAiB;IACxC,UAAU,CAAC,OAAO;QAChB;;;;;;;;;;WAUG;QACH,MAAM,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;QACnC,qEAAqE;QACrE,OAAO,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;QACzC,8GAA8G;QAC9G,8GAA8G;QAC9G,MAAM,QAAQ,GAAG,UAAU,EAAU,CAAC;QACtC,IAAI,aAAa,GAAyB,IAAI,CAAC;QAE/C,6BAA6B;QAE7B,4CAA4C;QAC5C,+CAA+C;QAC/C,4BAA4B;QAC5B,yCAAyC;QACzC,kCAAkC;QAClC,oEAAoE;QACpE,sHAAsH;QACtH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wBAAwB,CAAC;SACnG;KACF,CAAC,CAAC;IACH,6BAA6B;IAE7B,4CAA4C;IAC5C,+CAA+C;IAC/C,4BAA4B;IAC5B,yCAAyC;IACzC,kCAAkC;IAClC,oEAAoE;IACpE,sHAAsH;IACtH,MAAM,KAAK,GAAG,GAAG,EAAE;QACjB,UAAU,CAAC;YACT,oBAAoB,kCAAO,OAAO,KAAE,QAAQ,GAAE;YAC9C,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE;gBAC/B,cAAc,CAAC,IAAI,CAAC,WAAW,EAAE;oBAC/B,SAAS,EAAE,cAAc;oBACzB,IAAI,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE;iBAC7B,CAAC,CAAC;YACL,CAAC;YACD,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE;gBACjC,cAAc,CAAC,IAAI,CAAC,WAAW,EAAE;oBAC/B,SAAS,EAAE,oBAAoB;oBAC/B,IAAI,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE;oBAC5B,KAAK;iBACN,CAAC,CAAC;YACL,CAAC;SACF,CAAC,CAAC;IACL,CAAC,CAAC;IACF,gEAAgE;IAChE,qDAAqD;IACrD,KAAK;IAEL,wCAAwC;IAExC,qFAAqF;IACrF,QAAQ,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE;QAC1C,iFAAiF;QACjF,IAAI,GAAG,KAAK,cAAc;YAAE,QAAQ,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,YAAY,EAAE,KAAqB,EAAE,CAAC,CAAC;IACzG,CAAC,CAAC,CAAC;IAEH,uCACK,eAAe,CAAC,QAAQ,CAAC,KAC5B,KAAK,IACL;AACJ,CAAC,CAAC"}
@@ -1,5 +1,2 @@
1
- import { BaseModuleOptions } from "../sdk/types";
2
- import { DeviceModuleOptions } from "./types";
3
- declare type AllConfiguration = BaseModuleOptions & DeviceModuleOptions;
4
- export declare function validateConfiguration(options: AllConfiguration): AllConfiguration;
5
- export {};
1
+ import { SharedConfiguration } from "../sdk/types";
2
+ export declare function validateConfiguration(shared: SharedConfiguration): void;
@@ -1,8 +1,8 @@
1
1
  import { SdkModes } from "../sdk/types";
2
- export function validateConfiguration(options) {
2
+ export function validateConfiguration(shared) {
3
3
  var _a, _b, _c, _d;
4
- const { recipe } = options;
5
- if (options.mode === SdkModes.DUMMY) {
4
+ const { recipe } = shared;
5
+ if (shared.mode.modeName === SdkModes.DUMMY) {
6
6
  throw new Error("There is no implementation for the device component in 'dummy' mode.");
7
7
  }
8
8
  if (!((_b = (_a = recipe.deviceCharacteristics) === null || _a === void 0 ? void 0 : _a.provider) === null || _b === void 0 ? void 0 : _b.name)) {
@@ -11,6 +11,5 @@ export function validateConfiguration(options) {
11
11
  if (!((_d = (_c = recipe.deviceCharacteristics) === null || _c === void 0 ? void 0 : _c.provider) === null || _d === void 0 ? void 0 : _d.environment)) {
12
12
  throw new Error(`Your account is missing the environment configuration for the device characteristics provider "${recipe.deviceCharacteristics.provider.name}". Please contact FrankieOne support.`);
13
13
  }
14
- return options;
15
14
  }
16
15
  //# sourceMappingURL=parseConfiguration.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parseConfiguration.js","sourceRoot":"","sources":["../../../../modules/device/parseConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAIhE,MAAM,UAAU,qBAAqB,CAAC,OAAyB;;IAC7D,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAE3B,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAC,KAAK,EAAE;QACnC,MAAM,IAAI,KAAK,CAAC,sEAAsE,CAAC,CAAC;KACzF;IACD,IAAI,CAAC,CAAA,MAAA,MAAA,MAAM,CAAC,qBAAqB,0CAAE,QAAQ,0CAAE,IAAI,CAAA,EAAE;QACjD,MAAM,IAAI,KAAK,CACb,+GAA+G,CAChH,CAAC;KACH;IACD,IAAI,CAAC,CAAA,MAAA,MAAA,MAAM,CAAC,qBAAqB,0CAAE,QAAQ,0CAAE,WAAW,CAAA,EAAE;QACxD,MAAM,IAAI,KAAK,CACb,kGAAkG,MAAM,CAAC,qBAAqB,CAAC,QAAQ,CAAC,IAAI,uCAAuC,CACpL,CAAC;KACH;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
1
+ {"version":3,"file":"parseConfiguration.js","sourceRoot":"","sources":["../../../../modules/device/parseConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAuB,MAAM,mBAAmB,CAAC;AAElE,MAAM,UAAU,qBAAqB,CAAC,MAA2B;;IAC/D,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAE1B,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,KAAK,QAAQ,CAAC,KAAK,EAAE;QAC3C,MAAM,IAAI,KAAK,CAAC,sEAAsE,CAAC,CAAC;KACzF;IACD,IAAI,CAAC,CAAA,MAAA,MAAA,MAAM,CAAC,qBAAqB,0CAAE,QAAQ,0CAAE,IAAI,CAAA,EAAE;QACjD,MAAM,IAAI,KAAK,CACb,+GAA+G,CAChH,CAAC;KACH;IACD,IAAI,CAAC,CAAA,MAAA,MAAA,MAAM,CAAC,qBAAqB,0CAAE,QAAQ,0CAAE,WAAW,CAAA,EAAE;QACxD,MAAM,IAAI,KAAK,CACb,kGAAkG,MAAM,CAAC,qBAAqB,CAAC,QAAQ,CAAC,IAAI,uCAAuC,CACpL,CAAC;KACH;AACH,CAAC"}
@@ -1,5 +1,6 @@
1
- import { VendorWrapper } from "../types";
2
- export declare const wrapper: VendorWrapper;
1
+ import { DeviceWrapperContext, DeviceWrapperOptions } from "../../device";
2
+ import { WrapperInitialiseFunction } from "../../sdk";
3
+ export declare const initialise: WrapperInitialiseFunction<DeviceWrapperOptions, DeviceWrapperContext, "async">;
3
4
  interface SardineSdkOptions {
4
5
  clientId: string;
5
6
  userIdHash: string;
@@ -7,37 +7,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { loadAsyncAsset } from "../../common";
10
+ import { loadAsyncAsset, OneSDKError } from "../../common";
11
+ import { ActivityTypeList } from "../../device";
11
12
  import { v4 as uuid } from "uuid";
12
- export const wrapper = {
13
- vendor: "sardine",
14
- initialise(options) {
15
- return __awaiter(this, void 0, void 0, function* () {
16
- // create session with backend
17
- const sessionData = yield initialiseSardineSession(options);
18
- options.eventHub.emit("session_data_generated", {
19
- session: sessionData,
20
- });
21
- // initialise sardine sdk
22
- const sardineContext = yield asyncLoadSardine({
23
- module: options,
24
- session: sessionData,
25
- });
26
- // listen for events, if there are any in the frontend
27
- // maybe we should implement our own events by websockets, if no frontend events are emitted
28
- return sardineContext;
29
- });
30
- },
31
- };
32
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
33
- function initialiseSardineSession(options) {
13
+ import { z } from "zod";
14
+ export const initialise = (shared, options) => __awaiter(void 0, void 0, void 0, function* () {
15
+ // create session with backend
16
+ const sessionData = yield initialiseSardineSession(shared);
17
+ options.eventHub.emit("session_data_generated", {
18
+ session: sessionData,
19
+ });
20
+ // initialise sardine sdk
21
+ const sardineContext = yield asyncLoadSardine(shared, options, sessionData);
22
+ // listen for events, if there are any in the frontend
23
+ // maybe we should implement our own events by websockets, if no frontend events are emitted
24
+ return sardineContext;
25
+ });
26
+ function initialiseSardineSession(shared) {
34
27
  var _a;
35
28
  return __awaiter(this, void 0, void 0, function* () {
36
29
  return {
37
- customerID: (_a = options.session.customerChildID) !== null && _a !== void 0 ? _a : options.session.customerID,
38
- frankieClientID: options.recipe.deviceCharacteristics.provider.clientID,
30
+ customerID: (_a = shared.session.customerChildID) !== null && _a !== void 0 ? _a : shared.session.customerID,
31
+ frankieClientID: shared.recipe.deviceCharacteristics.provider.clientID,
39
32
  vendorSessionID: uuid(),
40
- environment: options.recipe.deviceCharacteristics.provider.environment,
33
+ environment: shared.recipe.deviceCharacteristics.provider.environment,
41
34
  };
42
35
  });
43
36
  }
@@ -46,31 +39,40 @@ function resolveSardineHost(environment) {
46
39
  return "api.sardine.ai";
47
40
  return "api.sandbox.sardine.ai";
48
41
  }
49
- function asyncLoadSardine(options) {
42
+ function asyncLoadSardine(shared, options, sessionData) {
50
43
  return __awaiter(this, void 0, void 0, function* () {
51
- const environment = options.session.environment;
44
+ const environment = sessionData.environment;
52
45
  const sardineHost = resolveSardineHost(environment);
53
46
  const url = `https://${sardineHost}/assets/loader.min.js`;
47
+ try {
48
+ z.string()
49
+ .refine((val) => ActivityTypeList.includes(val), {
50
+ message: `Activity Type should be one of the following: [${ActivityTypeList.join(", ")}]`,
51
+ })
52
+ .parse(options.activityType);
53
+ }
54
+ catch (e) {
55
+ throw new OneSDKError(e.issues[0].message, { receivedActivityType: options.activityType });
56
+ }
54
57
  yield loadAsyncAsset(url);
55
58
  const sardineContext = window._Sardine.createContext({
56
- clientId: options.session.frankieClientID,
57
- sessionKey: options.session.vendorSessionID,
59
+ clientId: sessionData.frankieClientID,
60
+ sessionKey: sessionData.vendorSessionID,
58
61
  environment,
59
62
  parentElement: document.body,
60
- flow: options.module.activityType,
63
+ flow: options.activityType,
61
64
  onDeviceResponse: function (data) {
62
- options.module.eventHub.emit("device_characteristics_extracted", {
65
+ options.eventHub.emit("device_characteristics_extracted", {
63
66
  deviceCharacteristics: data,
64
67
  });
65
68
  },
66
69
  });
67
70
  return {
68
- vendor: "sardine",
69
71
  set(key, value) {
70
72
  const mappedKey = mapF2S[key];
71
73
  if (mappedKey) {
72
74
  sardineContext.updateConfig({ [mappedKey]: value });
73
- options.module.eventHub.emit("value_set", { key, value });
75
+ options.eventHub.emit("value_set", { key, value });
74
76
  }
75
77
  },
76
78
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Sardine.js","sourceRoot":"","sources":["../../../../../modules/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SACF,CAAC;IACJ,CAAC;CAAA;AACD,MAAM,MAAM,GAAG;IACb,QAAQ,EAAE,YAAY;IACtB,YAAY,EAAE,MAAM;CACrB,CAAC"}
@@ -1,2 +1,3 @@
1
- import { VendorWrapper } from "../../types";
2
- export declare const wrapper: VendorWrapper;
1
+ import { DeviceWrapperContext, DeviceWrapperOptions } from "../../../device";
2
+ import { WrapperInitialiseFunction } from "../../../sdk";
3
+ export declare const initialise: WrapperInitialiseFunction<DeviceWrapperOptions, DeviceWrapperContext, "async">;
@@ -9,53 +9,41 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { v4 as uuid } from "uuid";
11
11
  import { threatmetrix as threatmetrixSdk } from "./nolint_fp-clientlib-v4.js";
12
- export const wrapper = {
13
- vendor: "threatmetrix",
14
- initialise(options) {
15
- return __awaiter(this, void 0, void 0, function* () {
16
- // create session with backend
17
- const sessionData = yield initialiseThreatMetrixSession(options);
18
- options.eventHub.emit("session_data_generated", {
19
- session: sessionData,
20
- });
21
- // initialise threatMetrix sdk
22
- const threatmetrixContext = yield asyncLoadThreatMetrix({
23
- module: options,
24
- session: sessionData,
25
- });
26
- // listen for events, if there are any in the frontend
27
- // maybe we should implement our own events by websockets, if no frontend events are emitted
28
- return threatmetrixContext;
29
- });
30
- },
31
- };
32
- function initialiseThreatMetrixSession(options) {
12
+ export const initialise = (shared, options) => __awaiter(void 0, void 0, void 0, function* () {
13
+ // create session with backend
14
+ const sessionData = yield initialiseThreatMetrixSession(shared);
15
+ options.eventHub.emit("session_data_generated", {
16
+ session: sessionData,
17
+ });
18
+ // initialise threatMetrix sdk
19
+ const threatmetrixContext = yield asyncLoadThreatMetrix(shared, options, sessionData);
20
+ // listen for events, if there are any in the frontend
21
+ // maybe we should implement our own events by websockets, if no frontend events are emitted
22
+ return threatmetrixContext;
23
+ });
24
+ function initialiseThreatMetrixSession(shared) {
33
25
  var _a;
34
26
  return __awaiter(this, void 0, void 0, function* () {
35
27
  return {
36
- customerID: (_a = options.session.customerChildID) !== null && _a !== void 0 ? _a : options.session.customerID,
37
- frankieClientID: options.recipe.deviceCharacteristics.provider.clientID,
28
+ customerID: (_a = shared.session.customerChildID) !== null && _a !== void 0 ? _a : shared.session.customerID,
29
+ frankieClientID: shared.recipe.deviceCharacteristics.provider.clientID,
38
30
  vendorSessionID: uuid(),
39
31
  environment: "production",
40
32
  };
41
33
  });
42
34
  }
43
- function asyncLoadThreatMetrix(options) {
35
+ function asyncLoadThreatMetrix(_1, _2, sessionData) {
44
36
  return __awaiter(this, void 0, void 0, function* () {
45
37
  // threatmetrix prefers us to ugligy their interface
46
38
  // to hide the fact threatmetrix is being used
47
39
  // that means that we might need to convert the file below into a module and stactically import it
48
- const { frankieClientID, vendorSessionID } = options.session;
40
+ const { frankieClientID, vendorSessionID } = sessionData;
49
41
  threatmetrixSdk.profile("h.online-metrix.net", frankieClientID, vendorSessionID);
50
42
  return {
51
- vendor: "threatmetrix",
52
- set(key, value) {
43
+ set() {
53
44
  // Not sure what goes here for threatmetrix
54
45
  },
55
46
  };
56
47
  });
57
48
  }
58
- function emitEventForConfigurationUpdate(key, value, { module: { eventHub } }) {
59
- eventHub.emit("value_set", { key, value });
60
- }
61
49
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../modules/device/vendors/Threatmetrix/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,YAAY,IAAI,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9E,MAAM,CAAC,MAAM,OAAO,GAAkB;IACpC,MAAM,EAAE,cAAc;IAChB,UAAU,CAAC,OAAsB;;YACrC,8BAA8B;YAC9B,MAAM,WAAW,GAAG,MAAM,6BAA6B,CAAC,OAAO,CAAC,CAAC;YACjE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,w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}
@@ -1,3 +1,12 @@
1
- import { FederationModule } from "./types/module";
2
- export declare type Options = Parameters<FederationModule["initialise"]>[0];
3
- export declare const federationModule: FederationModule;
1
+ import { EventHub } from "../common";
2
+ import { ModuleContext, ModuleInitialiseFunction } from "../sdk/types";
3
+ import { EmptyObject } from "../../types/index.js";
4
+ import { Events } from "./events";
5
+ export declare const initialise: ModuleInitialiseFunction<"federation", FederationModuleContext>;
6
+ export declare type FederationModuleContext = ModuleContext<{
7
+ start: () => void;
8
+ }, Events>;
9
+ export declare type FederationWrapperOptions = {
10
+ eventHub: EventHub<Events>;
11
+ };
12
+ export declare type FederationWrapperContext = EmptyObject;