@frankieone/one-sdk 0.5.5-rc → 0.6.5-rc
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 +38 -36
- package/dist/commit.txt +2 -2
- package/dist/esm/modules/common/constants.d.ts +1 -0
- package/dist/esm/modules/common/constants.js +2 -0
- package/dist/esm/modules/common/constants.js.map +1 -1
- package/dist/esm/modules/common/modules/{runIfWhen.d.ts → HOF.d.ts} +17 -2
- package/dist/esm/modules/common/modules/{runIfWhen.js → HOF.js} +22 -3
- package/dist/esm/modules/common/modules/HOF.js.map +1 -0
- package/dist/esm/modules/common/modules/LocalStorage.d.ts +6 -0
- package/dist/esm/modules/common/modules/LocalStorage.js +21 -0
- package/dist/esm/modules/common/modules/LocalStorage.js.map +1 -0
- package/dist/esm/modules/common/modules/env2url.d.ts +6 -1
- package/dist/esm/modules/common/modules/env2url.js +17 -1
- package/dist/esm/modules/common/modules/env2url.js.map +1 -1
- package/dist/esm/modules/common/modules/url.d.ts +5 -0
- package/dist/esm/modules/common/modules/url.js +10 -0
- package/dist/esm/modules/common/modules/url.js.map +1 -0
- package/dist/esm/modules/common/types/Configuration.d.ts +15 -0
- package/dist/esm/modules/federation/constants.d.ts +2 -0
- package/dist/esm/modules/federation/constants.js +3 -0
- package/dist/esm/modules/federation/constants.js.map +1 -0
- package/dist/esm/modules/federation/index.d.ts +3 -0
- package/dist/esm/modules/federation/index.js +69 -0
- package/dist/esm/modules/federation/index.js.map +1 -0
- package/dist/esm/modules/federation/parseConfiguration.d.ts +2 -0
- package/dist/esm/modules/federation/parseConfiguration.js +43 -0
- package/dist/esm/modules/federation/parseConfiguration.js.map +1 -0
- package/dist/esm/modules/federation/types/events.d.ts +4 -0
- package/dist/esm/modules/federation/types/events.js +2 -0
- package/dist/esm/modules/federation/types/events.js.map +1 -0
- package/dist/esm/modules/federation/types/module.d.ts +8 -0
- package/dist/esm/modules/federation/types/module.js +2 -0
- package/dist/esm/modules/federation/types/module.js.map +1 -0
- package/dist/esm/modules/federation/types/wrapper.d.ts +18 -0
- package/dist/esm/modules/federation/types/wrapper.js +2 -0
- package/dist/esm/modules/federation/types/wrapper.js.map +1 -0
- package/dist/esm/modules/federation/vendors/Singpass.d.ts +8 -0
- package/dist/esm/modules/federation/vendors/Singpass.js +110 -0
- package/dist/esm/modules/federation/vendors/Singpass.js.map +1 -0
- package/dist/esm/modules/frankie-client/DummyFrankieApiClient.d.ts +28 -22
- package/dist/esm/modules/frankie-client/DummyFrankieApiClient.js +47 -45
- package/dist/esm/modules/frankie-client/DummyFrankieApiClient.js.map +1 -1
- package/dist/esm/modules/frankie-client/FrankieApiClient.d.ts +6 -8
- package/dist/esm/modules/frankie-client/FrankieApiClient.js +10 -25
- package/dist/esm/modules/frankie-client/FrankieApiClient.js.map +1 -1
- package/dist/esm/modules/frankie-client/clients/ApplicantClient.js +7 -11
- package/dist/esm/modules/frankie-client/clients/ApplicantClient.js.map +1 -1
- package/dist/esm/modules/frankie-client/clients/BaseClient.d.ts +1 -3
- package/dist/esm/modules/frankie-client/clients/BaseClient.js +4 -3
- package/dist/esm/modules/frankie-client/clients/BaseClient.js.map +1 -1
- package/dist/esm/modules/frankie-client/clients/FederationClient.d.ts +11 -0
- package/dist/esm/modules/frankie-client/clients/FederationClient.js +24 -0
- package/dist/esm/modules/frankie-client/clients/FederationClient.js.map +1 -0
- package/dist/esm/modules/frankie-client/clients/StorageClient.d.ts +10 -0
- package/dist/esm/modules/frankie-client/clients/StorageClient.js +23 -0
- package/dist/esm/modules/frankie-client/clients/StorageClient.js.map +1 -0
- package/dist/esm/modules/frankie-client/index.d.ts +8 -2
- package/dist/esm/modules/frankie-client/index.js +23 -32
- package/dist/esm/modules/frankie-client/index.js.map +1 -1
- package/dist/esm/modules/frankie-client/mocks/federation/index.d.ts +4 -0
- package/dist/esm/modules/frankie-client/mocks/federation/index.js +32 -0
- package/dist/esm/modules/frankie-client/mocks/federation/index.js.map +1 -0
- package/dist/esm/modules/frankie-client/mocks/index.js +4 -0
- package/dist/esm/modules/frankie-client/mocks/index.js.map +1 -1
- package/dist/esm/modules/frankie-client/mocks/individual/loadIndividual.d.ts +1 -1
- package/dist/esm/modules/frankie-client/mocks/individual/loadIndividual.js +2 -2
- package/dist/esm/modules/frankie-client/mocks/individual/loadIndividual.js.map +1 -1
- package/dist/esm/modules/index.d.ts +15 -3
- package/dist/esm/modules/index.js +18 -9
- package/dist/esm/modules/index.js.map +1 -1
- package/dist/esm/modules/individual/actions/search.js +4 -5
- package/dist/esm/modules/individual/actions/search.js.map +1 -1
- package/dist/esm/modules/individual/types/events.d.ts +1 -1
- package/dist/esm/modules/meta.json +1 -1
- package/dist/esm/modules/ocr/actions/start.js +6 -14
- package/dist/esm/modules/ocr/actions/start.js.map +1 -1
- package/dist/esm/modules/sdk/index.js +3 -1
- package/dist/esm/modules/sdk/index.js.map +1 -1
- package/dist/esm/modules/sdk/initialisation/componentLoader.js +1 -1
- package/dist/esm/modules/sdk/initialisation/componentLoader.js.map +1 -1
- package/dist/esm/modules/sdk/initialisation/configurationParser.js +4 -7
- package/dist/esm/modules/sdk/initialisation/configurationParser.js.map +1 -1
- package/dist/esm/modules/sdk/initialisation/sharedDependencies.d.ts +2 -1
- package/dist/esm/modules/sdk/initialisation/sharedDependencies.js +4 -4
- package/dist/esm/modules/sdk/initialisation/sharedDependencies.js.map +1 -1
- package/dist/esm/modules/sdk/types/components.d.ts +2 -2
- package/dist/esm/modules/sdk/types/configuration.d.ts +17 -26
- package/dist/esm/modules/sdk/types/configuration.js.map +1 -1
- package/dist/esm/modules/sdk/types/module.d.ts +1 -1
- package/dist/esm/modules/session/SessionContext.d.ts +55 -0
- package/dist/esm/modules/session/SessionContext.js +90 -0
- package/dist/esm/modules/session/SessionContext.js.map +1 -0
- package/dist/esm/modules/session/constants.d.ts +3 -0
- package/dist/esm/modules/session/constants.js +4 -0
- package/dist/esm/modules/session/constants.js.map +1 -0
- package/dist/esm/modules/session/index.d.ts +6 -0
- package/dist/esm/modules/session/index.js +70 -0
- package/dist/esm/modules/session/index.js.map +1 -0
- package/dist/esm/modules/session/types/module.d.ts +5 -0
- package/dist/esm/modules/session/types/module.js +2 -0
- package/dist/esm/modules/session/types/module.js.map +1 -0
- package/dist/esm/types/Primitives.d.ts +1 -0
- package/dist/release.txt +1 -1
- package/dist/umd/commit.txt +1 -0
- package/dist/umd/device-sardine.js +1 -1
- package/dist/umd/oneSdk.umd.js +1 -1
- package/dist/umd/oneSdk.umd.js.map +1 -1
- package/dist/umd/release.txt +1 -0
- package/dist/umd/version.txt +1 -0
- package/dist/version.txt +2 -2
- package/package.json +12 -9
- package/dist/esm/modules/common/modules/runIfWhen.js.map +0 -1
- package/dist/esm/modules/common/types/Session.d.ts +0 -16
- package/dist/esm/modules/common/types/Session.js +0 -2
- package/dist/esm/modules/common/types/Session.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# Frankieone
|
|
1
|
+
# Frankieone OneSDK
|
|
2
2
|
|
|
3
|
-
This is the Typescript codebase for
|
|
3
|
+
This is the Typescript codebase for OneSDK
|
|
4
4
|
|
|
5
5
|
## System requirements
|
|
6
6
|
|
|
@@ -13,16 +13,19 @@ This list is incomplete.
|
|
|
13
13
|
|
|
14
14
|
This is not a monorepo. This codebase is split in directories, but has no concept of npm workspaces, or any sort of monorepo utilities to use
|
|
15
15
|
|
|
16
|
-
- `modules`, where the codebase for the
|
|
17
|
-
- **The entry file for the
|
|
18
|
-
- `apps`, where subdirectories contain the codebase for applications related to
|
|
19
|
-
- `
|
|
20
|
-
|
|
16
|
+
- `modules`, where the codebase for the OneSDK is decoupled in "modules".
|
|
17
|
+
- **The entry file for the OneSDK build is the module `modules/index.ts`**
|
|
18
|
+
- `apps`, where subdirectories contain the codebase for applications related to OneSDK. These Apps are mailny used for testing and validating the OneSDK in different environments and build systems. These are the application packages.
|
|
19
|
+
- `playground` A React application used for executing the local OneSDK source code, used for the development of the OneSDK.
|
|
20
|
+
Given this project imports the OneSDK modules directly, it uses the `modules` folder as a [TypeScript reference](https://www.typescriptlang.org/docs/handbook/project-references.html). Read more in "OneSDK Playground".
|
|
21
|
+
- `raw-js` A very basic Javascript project which uses the CDN release of the OneSDK, executed as a `UMD` module and injected in the browser as `window.oneSdk`.
|
|
22
|
+
- `raw-ts` A very basic TypeScript project which uses the NPM release of the OneSDK.
|
|
23
|
+
- `npm-import` An attempt to reproduce a non standard build system using Rollup. This is experimental and aims to reproduce Westpacs build system used with the OneSDK.
|
|
21
24
|
- `tests` Where jest tests go. Try to keep the file structure as similar to the `modules` directory as possible.
|
|
22
25
|
|
|
23
26
|
## Modules
|
|
24
27
|
|
|
25
|
-
|
|
28
|
+
OneSDK modules are a way to easily increase the OneSDK functionalities. They are defined as objects exposing an `initialise` method that returns a `context` object.
|
|
26
29
|
Once the module is initialised, the returned context object offers access to the internal state and functionalities of that instance of the module.
|
|
27
30
|
|
|
28
31
|
Module definition:
|
|
@@ -44,10 +47,10 @@ export type BaseModuleOptions<InstanceName extends string = string> = SharedStat
|
|
|
44
47
|
export type SharedState = {
|
|
45
48
|
globalEventHub: EventHub<GlobalEvents>;
|
|
46
49
|
frankieClient: FrankieApiClient;
|
|
47
|
-
oneSdkInstance:
|
|
50
|
+
oneSdkInstance: OneSDKContext;
|
|
48
51
|
recipe: RecipeParsed;
|
|
49
52
|
session: SessionMeta;
|
|
50
|
-
} & Required<Omit<
|
|
53
|
+
} & Required<Omit<OneSDKRootParameters, "session">>;
|
|
51
54
|
```
|
|
52
55
|
|
|
53
56
|
A Module Context always exposes at minimum the event hub methods "on" and "off":
|
|
@@ -61,7 +64,7 @@ export type ModuleContext<
|
|
|
61
64
|
|
|
62
65
|
### Components
|
|
63
66
|
|
|
64
|
-
The
|
|
67
|
+
The OneSDK exposes a method called `component(moduleName, options)`, which will 1) retrieve the module from the dictionary of modules present in `@common/constants`, 2) initialise/instantiate it with the provided options and 3) store the context object and the instance name in a dictionary of instances. The instance name is provided as the parameter `options.instanceName` and defaults to the parameter `moduleName`.
|
|
65
68
|
|
|
66
69
|
> A component is the combination of an instantiated module's context object and the instance name assigned to it. Check the file `@module/sdk/types/components.ts`.
|
|
67
70
|
|
|
@@ -71,7 +74,7 @@ Only one instance is created per each combination of `moduleName` and `options.i
|
|
|
71
74
|
|
|
72
75
|
### Lazy loading
|
|
73
76
|
|
|
74
|
-
Components are supposed to lighten the
|
|
77
|
+
Components are supposed to lighten the OneSDK loading time by loading any necessary extra code asynchronously. Although the interface of a component isn't asynchronous, as its context object is provided immediately to the developer, the bulk of its source code is loaded as soon as the module identifies which vendor code it's supposed to load. In most cases it will then load a wrapper for that vendor containing any vendor source code or logic associated with initialising the integration with their service.
|
|
75
78
|
|
|
76
79
|
- A `module` directory is expected to have the following structure
|
|
77
80
|
|
|
@@ -93,7 +96,7 @@ _Caching strategies for asynchronous modules may be documented, where we give de
|
|
|
93
96
|
|
|
94
97
|
Description on how to create new modules here. <b style="color:red">TODO</b>
|
|
95
98
|
|
|
96
|
-
Some
|
|
99
|
+
Some OneSDK modules will be initialised automatically during the OneSDK initialisation and exposed via methods on the OneSDK instance directly. Besides their invocation, they are no different to modules invoked as "components".
|
|
97
100
|
|
|
98
101
|
The Modules directory can also contain utilities, such as the `FrankieApiClient`, which abstracts integration to BFF and the more general `common` directory, where common types and small utilities are provided.
|
|
99
102
|
|
|
@@ -106,7 +109,7 @@ This BFF client is split in modules that cover different use cases. Some of them
|
|
|
106
109
|
3. "OCR", for running OCR in scans
|
|
107
110
|
4. "IDV", for initialising sessions with vendors and running liveness and facial similarity checks
|
|
108
111
|
|
|
109
|
-
Not all
|
|
112
|
+
Not all OneSDK modules need all those clients and for that reason, they may be invoked asynchronously as well. There are two ways to fetch an API Client module:
|
|
110
113
|
|
|
111
114
|
1. Synchronously (which will bundle the source code with the current source code)
|
|
112
115
|
|
|
@@ -132,7 +135,7 @@ RXJS (Reactive Extension for Javascript) allows us to build declarative, data dr
|
|
|
132
135
|
|
|
133
136
|
Due to its popularity, RXJS is native to Angular, easily supported by Vue with an official plugin and easily adopted by React with custom hooks. Since it's built in plain Javascript, any framework can find ways to integrate with it.
|
|
134
137
|
|
|
135
|
-
In
|
|
138
|
+
In OneSDK we will use it to implement internal reactive state, which is used to propagate change as data streams, instead of static values. The entire application will then be aligned with a single source of truth, instead of manual updates that would be required if using events. At the same time, simple use cases require imperative options which, due to the lack of conceptual challenges, are much easier to understand. We aim to offer both alternatives: A reactive and an imperative.
|
|
136
139
|
|
|
137
140
|
The class `ReactiveStore` extends RXJS observables to offer a developer friendly way to read and right from the internal state.
|
|
138
141
|
|
|
@@ -228,9 +231,9 @@ type ReadonlyAccessors<T> = {
|
|
|
228
231
|
1. Following RXJS's own style guide, Reactive data, either our **custom Accessors or instances of the ReactiveStore class should contain a trailing dollar sign "$"**, as seen above.
|
|
229
232
|
2. **Computed properties**, which are readonly data extracted and transformed from other reactive data, **should also contain a leading underscore "\_"**.
|
|
230
233
|
|
|
231
|
-
##
|
|
234
|
+
## TypeScript setup
|
|
232
235
|
|
|
233
|
-
Even though this is not a Monorepo, the directories `modules`,
|
|
236
|
+
Even though this is not a Monorepo, the directories `modules`, and `apps/*` each have their own `tsconfig.json` file, making each of them an independent TypeScript project. Each tsconfig.json file extends a common tsconfig.base.json file in the root of the repository, where most of the typescript configuration lies. This pattern ensures each project uses a configuration compatible to the other.
|
|
234
237
|
|
|
235
238
|
These typescript projects aren't exactly independent and the tsconfig.base.json file actually shares common path aliases
|
|
236
239
|
|
|
@@ -241,8 +244,8 @@ These typescript projects aren't exactly independent and the tsconfig.base.json
|
|
|
241
244
|
|
|
242
245
|
These path aliases had to be hard copied into the common/vite.config.ts file until I find a plugin to do this automatically. <b style="color: red">TODO</b>
|
|
243
246
|
|
|
244
|
-
@frankieone/one-sdk allows the React app to import
|
|
245
|
-
@module and @static are used by the
|
|
247
|
+
@frankieone/one-sdk allows the React app to import OneSDK as if it came from npm. What really happens is that typescript maps directly to OneSDK in your local filesystem, allowing for all sorts of development perks, such as change detections for hot reloading and others.
|
|
248
|
+
@module and @static are used by the OneSDK modules to refer to their own resources.
|
|
246
249
|
@types are local types and type utilities available to the entire repository
|
|
247
250
|
|
|
248
251
|
This configuration doesn't need to be shared as they affect different TS projects separately, so they could be split across the specific tsconfig.json files. Since this works as well and makes the configuration a bit easier to understand, I decided to leave it as is for now. <b style="color: red">TODO</b>
|
|
@@ -255,20 +258,20 @@ To avoid conflicts during development, all **dev** dependencies for `apps` were
|
|
|
255
258
|
|
|
256
259
|
### Shared dependencies
|
|
257
260
|
|
|
258
|
-
The shared repository has deep and convoluted dependencies which makes it nearly impossible and undesirable to include the entire shared package into the dependencies of
|
|
261
|
+
The shared repository has deep and convoluted dependencies which makes it nearly impossible and undesirable to include the entire shared package into the dependencies of OneSDK. For that reason, the necessary files were hard copied and pasted into different folders in `modules/common/shared/`. These should be eventually replaced with new and cleaner implementations.
|
|
259
262
|
|
|
260
263
|
## Bundling
|
|
261
264
|
|
|
262
|
-
The **
|
|
265
|
+
The **OneSDK modules and assets** are bundled by webpack as UMD scripts, ready to be loaded and run directly on browsers via cdn servers. On the same `build` script, a second compilation is run by `tsc`, where the typescript compiler generates a folder `dist/esm` where ES Modules are generated along with their respective file declarations. This directory is meant to be deployed to the NPM repository for application development, which still needs to be run on a browser or browser-like environment (Native Webviews).
|
|
263
266
|
|
|
264
267
|
The Playground `cdn` app is prepared for deployment using Vite and generates index.html, index.js and index.css files.
|
|
265
|
-
The `react` app also uses Vite, but so far is only used to validate importing the
|
|
268
|
+
The `react` app also uses Vite, but so far is only used to validate importing the OneSDK as ES Module. No artifacts are generated for it.
|
|
266
269
|
|
|
267
270
|
Both `cdn` and `react` mostly share common configurations, defined in `apps/common/vite.config.js`.
|
|
268
271
|
|
|
269
272
|
Each of these bundlers need to be aware of Typescript paths described in **Typescript setup**, otherwise they are not going to work once built.
|
|
270
273
|
|
|
271
|
-
- For the main
|
|
274
|
+
- For the main OneSDK bundler, we use webpack.config.js with a resolution plugin `TsConfigPathsPlugin`
|
|
272
275
|
- For react and cdn apps, we use a common bundler configuration in `apps/common/vite.config.js`, with paths manually defined (which could be also simplified with a plugin, but this is good enough for now) <b style="color: red">TODO</b>
|
|
273
276
|
|
|
274
277
|
## Getting started
|
|
@@ -299,20 +302,20 @@ There's still not a common modern standard of how to access environment variable
|
|
|
299
302
|
|
|
300
303
|
Since our Javascript codebase is of type `module` (package.json > type), other advanced `import.meta` variables, such as `import.meta.url` are available at build time.
|
|
301
304
|
|
|
302
|
-
##
|
|
305
|
+
## OneSDK Playground
|
|
303
306
|
|
|
304
|
-
|
|
307
|
+
The Playground is where we can work on and validate features being developed. In the future we can also make it available to the Frankie team to test the OneSDK themselves. It's implemented as a React App and imports the OneSDK modules directly from the source code, using the same entry point customers would from the NPM Registry. For that to work, the OneSDK `modules` folder contains two tsconfig files, the main `tsconfig.json`, which builds the OneSDK bundle for NPM and `tsconfig.composite.json`, which allows other typescript projects present in the same repo to import it as if they belong to the same project. This is done by adding the `composite: true` option to the latter tsconfig file and by including `"reference":[{ path: "../relative-to/modules/tsconfig.composite.json" }]` in the project that needs access to OneSDK modules locally.
|
|
305
308
|
|
|
306
|
-
To run the
|
|
309
|
+
To run the playground you should run the following script
|
|
307
310
|
|
|
308
311
|
```
|
|
309
|
-
npm run dev
|
|
312
|
+
npm run dev
|
|
310
313
|
```
|
|
311
314
|
|
|
312
315
|
## Content Security Policy
|
|
313
316
|
|
|
314
317
|
Use the CDN playground during development to find out if a new integration requires special [content security policies](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP).
|
|
315
|
-
Any request that fails due to missing policy should be added to the list of policies in `apps/cdn/index.html` and then documented in the official
|
|
318
|
+
Any request that fails due to missing policy should be added to the list of policies in `apps/cdn/index.html` and then documented in the official OneSDK documentation.
|
|
316
319
|
|
|
317
320
|
## Build and Release process
|
|
318
321
|
|
|
@@ -320,9 +323,9 @@ We have two types of deployment: `development` and `production`. For both type o
|
|
|
320
323
|
|
|
321
324
|
1. run tests and type check the code base
|
|
322
325
|
2. build the sdk as both UMD and Typed ESModules into the `dist/umd` and `dist/esm` directories, respectively
|
|
323
|
-
3. build the Playground into `apps/
|
|
326
|
+
3. build the Playground into `apps/playground/dist` directory
|
|
324
327
|
4. deploy the UMD build to the "assets" S3 bucket, into the namespace defined by either the branch or tag name
|
|
325
|
-
5. deploy the ESM build to npm, with the version defined
|
|
328
|
+
5. deploy the ESM build to npm, with the version defined in package.json
|
|
326
329
|
6. deploy the Playground to the "playground" S3 bucket
|
|
327
330
|
|
|
328
331
|
The UMD build is done by Webpack, whilst the ESM build is done solely by the Typescript compiler. For that reason, ESM has no extra pre-processing and all `.json` imports need to be converted to `.ts` files exporting the JSON content as Typescript values.
|
|
@@ -377,10 +380,9 @@ First run `npm run dev` and then run this debug script. You'll be able to positi
|
|
|
377
380
|
| fresh | Fresh installs all dependencies and generates the modules/meta.json file. |
|
|
378
381
|
| test | Run all tests. |
|
|
379
382
|
| refactor | Watches for both typescript errors and unit tests failures in parallel. Useful for refactoring code. |
|
|
380
|
-
| build:dev | Builds
|
|
381
|
-
| dev | Runs React app for developing the
|
|
383
|
+
| build:dev | Builds OneSDK in development mode (without minifying it, which allows us to visually debug the build). |
|
|
384
|
+
| dev | Runs React app for developing the OneSDK as a module import (with typescript types available and all that). |
|
|
382
385
|
| dev --dist | Same script as above, but with the --dist option. Runs ESM Javascript from `dist` folder, instead of source code. |
|
|
383
|
-
| dev:cdn | Runs CDN app for developing the Playground and testing the OneSdk served through CDN. |
|
|
384
386
|
|
|
385
387
|
## Scripts you shouldn't call directly, but are used by other scripts in the background
|
|
386
388
|
|
|
@@ -389,9 +391,9 @@ First run `npm run dev` and then run this debug script. You'll be able to positi
|
|
|
389
391
|
| lint:staged | Runs linting before committing. [More info here.](https://github.com/okonet/lint-staged) |
|
|
390
392
|
| start:react-app | Runs React app in dev mode. Aliased by script "dev" |
|
|
391
393
|
| start:cdn-app | Runs the CDN app in dev mode. Used by script "dev:cdn" |
|
|
392
|
-
| build | Builds
|
|
393
|
-
| watch | Watches for changes in the
|
|
394
|
-
| watch-tsc | Watches for changes in the
|
|
394
|
+
| build | Builds OneSDK for production, also generating type declarations. This is used by the pipeline. |
|
|
395
|
+
| watch | Watches for changes in the OneSDK source code and rebuilds it when one occurs. Used by script "dev:cdn" |
|
|
396
|
+
| watch-tsc | Watches for changes in the OneSDK source code and type checks it. Used by script "refactor" |
|
|
395
397
|
| tsc-check | Runs type check in the entire code base once. Used by the pipeline |
|
|
396
398
|
| eslint-check | Runs eslint checks in the entire code base once. Used by the pipeline |
|
|
397
399
|
|
package/dist/commit.txt
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
89f3802a120e0ea6bb6fca58eb99daf22b86bd6b
|
|
2
|
+
89f3802a120e0ea6bb6fca58eb99daf22b86bd6b
|
|
@@ -2,6 +2,7 @@ export declare const PublicModules: {
|
|
|
2
2
|
readonly biometrics: import("../biometrics").BiometricsModule;
|
|
3
3
|
readonly device: import("../device").DeviceModule;
|
|
4
4
|
readonly ocr: import("../ocr/types").OcrModule;
|
|
5
|
+
readonly federation: import("../federation/types/module").FederationModule;
|
|
5
6
|
};
|
|
6
7
|
export declare type ModulesDictionary = typeof PublicModules;
|
|
7
8
|
export declare type ModuleNames = keyof ModulesDictionary;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { biometricsModule } from "../biometrics";
|
|
2
2
|
import { deviceModule } from "../device";
|
|
3
|
+
import { federationModule } from "../federation";
|
|
3
4
|
import { ocrModule } from "../ocr";
|
|
4
5
|
export const PublicModules = {
|
|
5
6
|
biometrics: biometricsModule,
|
|
6
7
|
device: deviceModule,
|
|
7
8
|
ocr: ocrModule,
|
|
9
|
+
federation: federationModule,
|
|
8
10
|
};
|
|
9
11
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../modules/common/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,UAAU,EAAE,gBAAgB;IAC5B,MAAM,EAAE,YAAY;IACpB,GAAG,EAAE,SAAS;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../modules/common/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,UAAU,EAAE,gBAAgB;IAC5B,MAAM,EAAE,YAAY;IACpB,GAAG,EAAE,SAAS;IACd,UAAU,EAAE,gBAAgB;CACpB,CAAC"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { KeyOf } from "../../../types/index.js";
|
|
2
2
|
import { EventHub, EventsDictionary, ExtendedEvents } from "./eventHub";
|
|
3
|
-
declare type Runnable =
|
|
3
|
+
declare type Runnable = (...args: any[]) => any;
|
|
4
|
+
/**
|
|
5
|
+
* Ensures only one level of promises is provided
|
|
6
|
+
*/
|
|
7
|
+
declare type AsyncShallow<Value> = Promise<Awaited<Value>>;
|
|
8
|
+
declare type AsyncFunction<F extends Runnable> = (...args: Parameters<F>) => AsyncShallow<ReturnType<F>>;
|
|
4
9
|
declare type Options<Callback extends Runnable, Events extends EventsDictionary> = {
|
|
5
10
|
condition: () => boolean;
|
|
6
11
|
run: Callback;
|
|
@@ -17,5 +22,15 @@ declare type Options<Callback extends Runnable, Events extends EventsDictionary>
|
|
|
17
22
|
*
|
|
18
23
|
* @returns a function that takes the same parameters as "run" and returns a promise with the same results returned by "run"
|
|
19
24
|
*/
|
|
20
|
-
export declare const runIfWhen: <Callback extends Runnable, Events extends EventsDictionary>(opt: Options<Callback, Events>) => Callback
|
|
25
|
+
export declare const runIfWhen: <Callback extends Runnable, Events extends EventsDictionary>(opt: Options<Callback, Events>) => AsyncFunction<Callback>;
|
|
26
|
+
/**
|
|
27
|
+
* runOnce
|
|
28
|
+
* - takes a function and an error message and returns an equivalent function that
|
|
29
|
+
* can only be called once. The second time the function is called, an error is thrown
|
|
30
|
+
* containing the provided error message.
|
|
31
|
+
* @param func The function to be run
|
|
32
|
+
* @param errorMessage An error message if the function is called twice
|
|
33
|
+
* @returns The provided function
|
|
34
|
+
*/
|
|
35
|
+
export declare const runOnce: <Func extends Runnable>(func: Func, errorMessage: string) => Func;
|
|
21
36
|
export {};
|
|
@@ -19,7 +19,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
19
19
|
*
|
|
20
20
|
* @returns a function that takes the same parameters as "run" and returns a promise with the same results returned by "run"
|
|
21
21
|
*/
|
|
22
|
-
export const runIfWhen = (opt) => (
|
|
22
|
+
export const runIfWhen = (opt) => (...args) => new Promise((resolve) => {
|
|
23
23
|
if (opt.condition())
|
|
24
24
|
resolve(opt.run(...args));
|
|
25
25
|
else {
|
|
@@ -27,5 +27,24 @@ export const runIfWhen = (opt) => ((...args) => new Promise((resolve) => {
|
|
|
27
27
|
resolve(opt.run(...args));
|
|
28
28
|
}));
|
|
29
29
|
}
|
|
30
|
-
})
|
|
31
|
-
|
|
30
|
+
});
|
|
31
|
+
/**
|
|
32
|
+
* runOnce
|
|
33
|
+
* - takes a function and an error message and returns an equivalent function that
|
|
34
|
+
* can only be called once. The second time the function is called, an error is thrown
|
|
35
|
+
* containing the provided error message.
|
|
36
|
+
* @param func The function to be run
|
|
37
|
+
* @param errorMessage An error message if the function is called twice
|
|
38
|
+
* @returns The provided function
|
|
39
|
+
*/
|
|
40
|
+
export const runOnce = (func, errorMessage) => {
|
|
41
|
+
let wasCalled = false;
|
|
42
|
+
return ((...args) => {
|
|
43
|
+
if (wasCalled)
|
|
44
|
+
throw new Error(errorMessage);
|
|
45
|
+
const result = func(...args);
|
|
46
|
+
wasCalled = true;
|
|
47
|
+
return result;
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=HOF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HOF.js","sourceRoot":"","sources":["../../../../../modules/common/modules/HOF.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,mHAAmH;;;;;;;;;;AAkBnH;;;;;;;;;GASG;AAEH,MAAM,CAAC,MAAM,SAAS,GACpB,CACE,GAA8B,EACL,EAAE,CAC7B,CAAC,GAAG,IAAI,EAAE,EAAE,CACV,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,CAAC;AAEP;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAwB,IAAU,EAAE,YAAoB,EAAQ,EAAE;IACvF,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,OAAO,CAAC,CAAC,GAAG,IAAI,EAAE,EAAE;QAClB,IAAI,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;QAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;QAC7B,SAAS,GAAG,IAAI,CAAC;QACjB,OAAO,MAAM,CAAC;IAChB,CAAC,CAAS,CAAC;AACb,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export class LocalStorage {
|
|
2
|
+
store(key, value) {
|
|
3
|
+
window.sessionStorage.setItem(key, JSON.stringify(value));
|
|
4
|
+
}
|
|
5
|
+
retrieve(key) {
|
|
6
|
+
// May fail parsing and throw exception
|
|
7
|
+
const value = window.sessionStorage.getItem(key);
|
|
8
|
+
if (!value)
|
|
9
|
+
return null;
|
|
10
|
+
return JSON.parse(value);
|
|
11
|
+
}
|
|
12
|
+
delete(key) {
|
|
13
|
+
window.sessionStorage.removeItem(key);
|
|
14
|
+
}
|
|
15
|
+
retrieveAndDelete(key) {
|
|
16
|
+
const value = this.retrieve(key);
|
|
17
|
+
this.delete(key);
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=LocalStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalStorage.js","sourceRoot":"","sources":["../../../../../modules/common/modules/LocalStorage.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,YAAY;IACvB,KAAK,CAAC,GAAW,EAAE,KAAc;QAC/B,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;IAC5D,CAAC;IAED,QAAQ,CAAO,GAAW;QACxB,uCAAuC;QACvC,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjD,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC;QACxB,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAED,MAAM,CAAC,GAAW;QAChB,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IACxC,CAAC;IAED,iBAAiB,CAAO,GAAW;QACjC,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAO,GAAG,CAAC,CAAC;QACvC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjB,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
|
|
@@ -5,6 +5,11 @@ export declare enum ENVIRONMENTS {
|
|
|
5
5
|
uat = "uat",
|
|
6
6
|
demo = "demo",
|
|
7
7
|
qa = "qa",
|
|
8
|
-
|
|
8
|
+
staging = "staging",
|
|
9
|
+
staging2 = "staging2",
|
|
10
|
+
staging3 = "staging3",
|
|
11
|
+
staging4 = "staging4",
|
|
12
|
+
staging5 = "staging5",
|
|
13
|
+
staging6 = "staging6"
|
|
9
14
|
}
|
|
10
15
|
export declare const env2url: (env: ENVIRONMENTS) => string;
|
|
@@ -6,7 +6,12 @@ export var ENVIRONMENTS;
|
|
|
6
6
|
ENVIRONMENTS["uat"] = "uat";
|
|
7
7
|
ENVIRONMENTS["demo"] = "demo";
|
|
8
8
|
ENVIRONMENTS["qa"] = "qa";
|
|
9
|
+
ENVIRONMENTS["staging"] = "staging";
|
|
10
|
+
ENVIRONMENTS["staging2"] = "staging2";
|
|
11
|
+
ENVIRONMENTS["staging3"] = "staging3";
|
|
9
12
|
ENVIRONMENTS["staging4"] = "staging4";
|
|
13
|
+
ENVIRONMENTS["staging5"] = "staging5";
|
|
14
|
+
ENVIRONMENTS["staging6"] = "staging6";
|
|
10
15
|
})(ENVIRONMENTS || (ENVIRONMENTS = {}));
|
|
11
16
|
export const env2url = (env) => {
|
|
12
17
|
switch (env.toLowerCase()) {
|
|
@@ -14,9 +19,20 @@ export const env2url = (env) => {
|
|
|
14
19
|
case "development":
|
|
15
20
|
case "dev":
|
|
16
21
|
return "https://backend.latest.frankiefinancial.io";
|
|
17
|
-
case "
|
|
22
|
+
case "staging":
|
|
23
|
+
return "https://backend.staging.latest.frankiefinancial.io";
|
|
24
|
+
case "staging2":
|
|
25
|
+
return "https://backend.staging2.latest.frankiefinancial.io";
|
|
18
26
|
case "staging3":
|
|
19
27
|
return "https://backend.staging3.latest.frankiefinancial.io";
|
|
28
|
+
case "staging4":
|
|
29
|
+
return "https://backend.staging4.latest.frankiefinancial.io";
|
|
30
|
+
case "staging5":
|
|
31
|
+
return "https://backend.staging5.latest.frankiefinancial.io";
|
|
32
|
+
case "staging6":
|
|
33
|
+
return "https://backend.staging6.latest.frankiefinancial.io";
|
|
34
|
+
case "qa":
|
|
35
|
+
return "https://backend.qa.frankiefinancial.io";
|
|
20
36
|
case "demo":
|
|
21
37
|
return "https://backend.demo.frankiefinancial.io";
|
|
22
38
|
case "uat":
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env2url.js","sourceRoot":"","sources":["../../../../../modules/common/modules/env2url.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"env2url.js","sourceRoot":"","sources":["../../../../../modules/common/modules/env2url.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,YAaX;AAbD,WAAY,YAAY;IACtB,2CAA2B,CAAA;IAC3B,+BAAe,CAAA;IACf,yCAAyB,CAAA;IACzB,2BAAW,CAAA;IACX,6BAAa,CAAA;IACb,yBAAS,CAAA;IACT,mCAAmB,CAAA;IACnB,qCAAqB,CAAA;IACrB,qCAAqB,CAAA;IACrB,qCAAqB,CAAA;IACrB,qCAAqB,CAAA;IACrB,qCAAqB,CAAA;AACvB,CAAC,EAbW,YAAY,KAAZ,YAAY,QAavB;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,SAAS;YACZ,OAAO,oDAAoD,CAAC;QAC9D,KAAK,UAAU;YACb,OAAO,qDAAqD,CAAC;QAC/D,KAAK,UAAU;YACb,OAAO,qDAAqD,CAAC;QAC/D,KAAK,UAAU;YACb,OAAO,qDAAqD,CAAC;QAC/D,KAAK,UAAU;YACb,OAAO,qDAAqD,CAAC;QAC/D,KAAK,UAAU;YACb,OAAO,qDAAqD,CAAC;QAC/D,KAAK,IAAI;YACP,OAAO,wCAAwC,CAAC;QAClD,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,KAAK,OAAO;YACV,OAAO,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC;QAC3C;YACE,OAAO,mBAAmB,GAAG,6BAA6B,CAAC;KAC9D;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module exposes functionality for both Authentication (login) and Authorization (data access)
|
|
3
|
+
*/
|
|
4
|
+
export function getURLParams() {
|
|
5
|
+
return new URLSearchParams(window.location.search);
|
|
6
|
+
}
|
|
7
|
+
export function redirectTo(url) {
|
|
8
|
+
window.location.href = url.href;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../../../../modules/common/modules/url.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,UAAU,YAAY;IAC1B,OAAO,IAAI,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACrD,CAAC;AACD,MAAM,UAAU,UAAU,CAAC,GAAQ;IACjC,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;AAClC,CAAC"}
|
|
@@ -22,4 +22,19 @@ export declare type RecipeConfiguration = {
|
|
|
22
22
|
tx_id: string;
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
|
+
idps?: {
|
|
26
|
+
singpass?: {
|
|
27
|
+
environment: "production" | "sandbox" | "test";
|
|
28
|
+
client_id: string;
|
|
29
|
+
attributes: string;
|
|
30
|
+
purpose: string;
|
|
31
|
+
state: string;
|
|
32
|
+
redirect_url: string;
|
|
33
|
+
};
|
|
34
|
+
google?: {
|
|
35
|
+
redirect_url: string;
|
|
36
|
+
clientId: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
federation?: keyof RecipeConfiguration["idps"];
|
|
25
40
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../modules/federation/constants.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,UAAU,CAAU,CAAC"}
|
|
@@ -0,0 +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 { SdkMode } from "..";
|
|
11
|
+
import { mkEventHub, mkEventListener } from "../common";
|
|
12
|
+
import { mkFrankieClient } from "../frankie-client";
|
|
13
|
+
import { resolveMode } from "../sdk/initialisation/configurationParser";
|
|
14
|
+
import { sessionModule } from "../session";
|
|
15
|
+
import { parseConfiguration } from "./parseConfiguration";
|
|
16
|
+
export const federationModule = {
|
|
17
|
+
initialise(options) {
|
|
18
|
+
options = parseConfiguration(options);
|
|
19
|
+
// The two lines below will replace the session provided on OneSDK initialisation with
|
|
20
|
+
// any existing session stored in the local storage.
|
|
21
|
+
// A new frankie client is created with the new session and also replaces the existing client
|
|
22
|
+
// NOTE: Any component referencing Frankie Client from this point on will now refer to this new instance of FrankieApiClient
|
|
23
|
+
// TODO: Consider if we should isolate the stored session to this component only
|
|
24
|
+
// That would mean that the OneSDK could use two different sessions at the same time, including two different sessionId
|
|
25
|
+
// NOTE: When in Dummy mode the optional provided session is kept as is
|
|
26
|
+
if (resolveMode(options).modeName !== SdkMode.DUMMY) {
|
|
27
|
+
options.session = sessionModule.initialise(Object.assign(Object.assign({}, options), { session: {
|
|
28
|
+
token: options.session.token,
|
|
29
|
+
persist: true,
|
|
30
|
+
} }));
|
|
31
|
+
options.frankieClient = mkFrankieClient(Object.assign(Object.assign({}, options), { session: options.session, validateToken: false }));
|
|
32
|
+
options.globalEventHub.emit("info", {
|
|
33
|
+
message: options.session.isTakenFromStorage()
|
|
34
|
+
? "Found existing token in storage. Using it as new session."
|
|
35
|
+
: "No token found in storage. Using provided token for this session.",
|
|
36
|
+
payload: {
|
|
37
|
+
sessionId: options.session.sessionId,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
const eventHub = mkEventHub();
|
|
42
|
+
let vendorWrapper;
|
|
43
|
+
const start = () => {
|
|
44
|
+
const vendorOptions = Object.assign(Object.assign({}, options), { eventHub });
|
|
45
|
+
// If vendor wrapper was already loaded, call its authorize method
|
|
46
|
+
if (vendorWrapper)
|
|
47
|
+
return void vendorWrapper.authorize(vendorOptions);
|
|
48
|
+
// If it wasn't loaded yet, load it first and then re-call method "start" automatically
|
|
49
|
+
loadVendorWrapper(options)
|
|
50
|
+
.then((wrapper) => {
|
|
51
|
+
vendorWrapper = wrapper;
|
|
52
|
+
start();
|
|
53
|
+
})
|
|
54
|
+
.catch((error) => {
|
|
55
|
+
eventHub.emit("error", error);
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
return Object.assign(Object.assign({}, mkEventListener(eventHub)), { start });
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
function loadVendorWrapper(options) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
let vendor;
|
|
64
|
+
if (options.recipe.federation === "singpass")
|
|
65
|
+
vendor = yield import(/* webpackChunkName: 'federation-singpass' */ "./vendors/Singpass");
|
|
66
|
+
return vendor.wrapper;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../modules/federation/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAO1D,MAAM,CAAC,MAAM,gBAAgB,GAAqB;IAChD,UAAU,CAAC,OAAO;QAChB,OAAO,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;QACtC,sFAAsF;QACtF,oDAAoD;QACpD,6FAA6F;QAC7F,4HAA4H;QAC5H,gFAAgF;QAChF,6HAA6H;QAC7H,uEAAuE;QACvE,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,KAAK,EAAE;YACnD,OAAO,CAAC,OAAO,GAAG,aAAa,CAAC,UAAU,iCACrC,OAAO,KACV,OAAO,EAAE;oBACP,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK;oBAC5B,OAAO,EAAE,IAAI;iBACd,IACD,CAAC;YACH,OAAO,CAAC,aAAa,GAAG,eAAe,iCAClC,OAAO,KACV,OAAO,EAAE,OAAO,CAAC,OAAO,EACxB,aAAa,EAAE,KAAK,IACpB,CAAC;YAEH,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE;gBAClC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,kBAAkB,EAAE;oBAC3C,CAAC,CAAC,2DAA2D;oBAC7D,CAAC,CAAC,mEAAmE;gBACvE,OAAO,EAAE;oBACP,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,SAAS;iBACrC;aACF,CAAC,CAAC;SACJ;QAED,MAAM,QAAQ,GAAG,UAAU,EAAU,CAAC;QACtC,IAAI,aAA4B,CAAC;QAEjC,MAAM,KAAK,GAAqC,GAAG,EAAE;YACnD,MAAM,aAAa,mCAAQ,OAAO,KAAE,QAAQ,GAAE,CAAC;YAE/C,kEAAkE;YAClE,IAAI,aAAa;gBAAE,OAAO,KAAK,aAAa,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;YACtE,uFAAuF;YACvF,iBAAiB,CAAC,OAAO,CAAC;iBACvB,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;gBAChB,aAAa,GAAG,OAAO,CAAC;gBACxB,KAAK,EAAE,CAAC;YACV,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;gBACf,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAChC,CAAC,CAAC,CAAC;QACP,CAAC,CAAC;QACF,uCACK,eAAe,CAAC,QAAQ,CAAC,KAC5B,KAAK,IACL;IACJ,CAAC;CACF,CAAC;AAEF,SAAe,iBAAiB,CAAC,OAAgB;;QAC/C,IAAI,MAAqB,CAAC;QAC1B,IAAI,OAAO,CAAC,MAAM,CAAC,UAAU,KAAK,UAAU;YAC1C,MAAM,GAAG,MAAM,MAAM,CAAC,6CAA6C,CAAC,oBAAoB,CAAC,CAAC;QAC5F,OAAO,MAAM,CAAC,OAAO,CAAC;IACxB,CAAC;CAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export function parseConfiguration(options) {
|
|
3
|
+
const individual = options.oneSdkInstance.individual();
|
|
4
|
+
const isPreloaded = individual.isPreloaded();
|
|
5
|
+
// Preloaded entities aren't allowed to be federated
|
|
6
|
+
if (isPreloaded)
|
|
7
|
+
throw new Error("Federation component initialised with an existing entity. Initialise your session using a reference to a non existing entity.");
|
|
8
|
+
// General
|
|
9
|
+
if (!options.recipe.federation)
|
|
10
|
+
throw new Error("Missing 'recipe.federation'");
|
|
11
|
+
if (!options.recipe.idps)
|
|
12
|
+
throw new Error("Missing 'recipe.idps' dictionary");
|
|
13
|
+
if (!options.recipe.idps[options.recipe.federation])
|
|
14
|
+
throw new Error(`Idp '${options.recipe.federation}' missing from 'recipe.idps' configuration`);
|
|
15
|
+
// SINGPASS
|
|
16
|
+
if (options.recipe.federation === "singpass")
|
|
17
|
+
validateSingpassIdpConfiguration(options.recipe.idps.singpass);
|
|
18
|
+
return options;
|
|
19
|
+
}
|
|
20
|
+
function validateSingpassIdpConfiguration(singpass) {
|
|
21
|
+
let redirect_url = z
|
|
22
|
+
.string({
|
|
23
|
+
required_error: "'singpass.redirect_url' is required",
|
|
24
|
+
})
|
|
25
|
+
.url("The specified 'singpass.redirect_url' needs to be a valid URL");
|
|
26
|
+
// If environment is production, require redirect url to use the secure https:// protocol
|
|
27
|
+
if (singpass.environment === "production")
|
|
28
|
+
redirect_url = redirect_url.startsWith("https://", {
|
|
29
|
+
message: "When 'singpass.environment' is 'production', the specified 'singpass.redirect_url' needs to be a secure https URL",
|
|
30
|
+
});
|
|
31
|
+
const environment = z.enum(["production", "sandbox", "test"], { required_error: "Invalid 'singpass.environment'" });
|
|
32
|
+
try {
|
|
33
|
+
z.object({
|
|
34
|
+
redirect_url,
|
|
35
|
+
environment,
|
|
36
|
+
}).parse(singpass);
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
throw new Error(e.issues[0].message);
|
|
40
|
+
}
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=parseConfiguration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseConfiguration.js","sourceRoot":"","sources":["../../../../modules/federation/parseConfiguration.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,UAAU,kBAAkB,CAAC,OAAgB;IACjD,MAAM,UAAU,GAAG,OAAO,CAAC,cAAc,CAAC,UAAU,EAAE,CAAC;IACvD,MAAM,WAAW,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC;IAE7C,oDAAoD;IACpD,IAAI,WAAW;QACb,MAAM,IAAI,KAAK,CACb,+HAA+H,CAChI,CAAC;IAEJ,UAAU;IACV,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU;QAAE,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IAC/E,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IAC9E,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC;QACjD,MAAM,IAAI,KAAK,CAAC,QAAQ,OAAO,CAAC,MAAM,CAAC,UAAU,4CAA4C,CAAC,CAAC;IAEjG,WAAW;IACX,IAAI,OAAO,CAAC,MAAM,CAAC,UAAU,KAAK,UAAU;QAAE,gCAAgC,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAE7G,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,gCAAgC,CACvC,QAA8D;IAE9D,IAAI,YAAY,GAAG,CAAC;SACjB,MAAM,CAAC;QACN,cAAc,EAAE,qCAAqC;KACtD,CAAC;SACD,GAAG,CAAC,+DAA+D,CAAC,CAAC;IAExE,yFAAyF;IACzF,IAAI,QAAQ,CAAC,WAAW,KAAK,YAAY;QACvC,YAAY,GAAG,YAAY,CAAC,UAAU,CAAC,UAAU,EAAE;YACjD,OAAO,EACL,mHAAmH;SACtH,CAAC,CAAC;IAEL,MAAM,WAAW,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,EAAE,cAAc,EAAE,gCAAgC,EAAE,CAAC,CAAC;IAEpH,IAAI;QACF,CAAC,CAAC,MAAM,CAAC;YACP,YAAY;YACZ,WAAW;SACZ,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;KACpB;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;KACtC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../../../../modules/federation/types/events.ts"],"names":[],"mappings":""}
|