@frankieone/one-sdk 0.5.4-rc.1 → 0.6.5-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.
- package/README.md +483 -481
- package/dist/commit.txt +2 -1
- 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/shared/models/api.d.ts +2 -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/clients/TelemetryEventsClient.js +1 -1
- 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 +88 -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 +2 -1
- 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/version.txt +2 -0
- package/package.json +146 -143
- 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/dist/commit.txt
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
2de870f50fb131e0ce70fb1d8d5f74f744cd5f61
|
|
2
|
+
2de870f50fb131e0ce70fb1d8d5f74f744cd5f61
|
|
@@ -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,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EF,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":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseModuleOptions, ModuleContext } from "../../sdk/types";
|
|
2
|
+
import { Events } from "./events";
|
|
3
|
+
export interface FederationModule {
|
|
4
|
+
initialise: (o: BaseModuleOptions) => FederationModuleContext;
|
|
5
|
+
}
|
|
6
|
+
export declare type FederationModuleContext = ModuleContext<{
|
|
7
|
+
start: () => void;
|
|
8
|
+
}, Events>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../../../../modules/federation/types/module.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { EventHub } from "../../common";
|
|
2
|
+
import { BaseModuleOptions } from "../../sdk/types";
|
|
3
|
+
import { Vendor } from "../constants";
|
|
4
|
+
import { Events } from "./events";
|
|
5
|
+
export interface WrapperModule {
|
|
6
|
+
wrapper: VendorWrapper;
|
|
7
|
+
}
|
|
8
|
+
export interface VendorWrapper {
|
|
9
|
+
readonly vendor: Vendor;
|
|
10
|
+
authorize(o: VendorOptions): Promise<VendorContext>;
|
|
11
|
+
}
|
|
12
|
+
export interface VendorContext {
|
|
13
|
+
readonly vendor: Vendor;
|
|
14
|
+
}
|
|
15
|
+
export interface AdditionalDeviceInternalDependencies {
|
|
16
|
+
eventHub: EventHub<Events>;
|
|
17
|
+
}
|
|
18
|
+
export declare type VendorOptions = BaseModuleOptions & AdditionalDeviceInternalDependencies;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrapper.js","sourceRoot":"","sources":["../../../../../modules/federation/types/wrapper.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RecipeConfiguration } from "../../common";
|
|
2
|
+
import { VendorOptions, VendorWrapper } from "../types/wrapper";
|
|
3
|
+
export declare const wrapper: VendorWrapper;
|
|
4
|
+
export declare function hasAllAuthorisationParams(urlParams: URLSearchParams, options: VendorOptions): boolean;
|
|
5
|
+
export declare type SingpassEnvironment = RecipeConfiguration["idps"]["singpass"]["environment"];
|
|
6
|
+
export declare type SingpassEnvironmentURLDictionary = Record<SingpassEnvironment, string>;
|
|
7
|
+
export declare const singpassURLs: SingpassEnvironmentURLDictionary;
|
|
8
|
+
export declare function getSingpassURL(environment: SingpassEnvironment): URL;
|
|
@@ -0,0 +1,110 @@
|
|
|
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 { OneSDKError } from "../../common";
|
|
11
|
+
import { LocalStorage } from "../../common/modules/LocalStorage";
|
|
12
|
+
import { getURLParams } from "../../common/modules/url";
|
|
13
|
+
import { FederationClient } from "../../frankie-client/clients/FederationClient";
|
|
14
|
+
import { StorageKeys } from "../../session/constants";
|
|
15
|
+
// 302 Service will redirect all responses to 'redirect_uri' with additional parameters added as response results. Expected parameters include:
|
|
16
|
+
// code: this is the authorisation code you will use when calling the token endpoint
|
|
17
|
+
// state: this should be the same state passed in your initial URL.
|
|
18
|
+
// error: if there are any errors encountered, the error code will be given in this parameter.
|
|
19
|
+
// '500' - Unknown or other server side errors.
|
|
20
|
+
// '503' - MyInfo under maintenance. Error description will also be given in error_description parameter.
|
|
21
|
+
// 'access_denied' - When user did not give consent, refer to error_description parameter for the reason.
|
|
22
|
+
// error_description: if error is 'access_denied' i.e. user did not give consent, the description will be 'Resource Owner did not authorize the request'.
|
|
23
|
+
// Note: If user closes the browser window prematurely, there will be no callback to the 'redirect_uri'. Therefore it is important for you to check the 'state' to verify that the transaction is the same.
|
|
24
|
+
export const wrapper = {
|
|
25
|
+
vendor: "singpass",
|
|
26
|
+
authorize(options) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
const urlParams = getURLParams();
|
|
29
|
+
if (hasAllAuthorisationParams(urlParams, options))
|
|
30
|
+
yield submitAuthorization(urlParams, options);
|
|
31
|
+
else
|
|
32
|
+
yield authorize(options);
|
|
33
|
+
return {
|
|
34
|
+
vendor: "singpass",
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
function submitAuthorization(urlParams, options) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
// Submit data to BFF
|
|
42
|
+
const client = new FederationClient(options.frankieClient);
|
|
43
|
+
const clearStoredToken = () => new LocalStorage().delete(StorageKeys.TOKEN);
|
|
44
|
+
const emitError = (e) => {
|
|
45
|
+
options.eventHub.emit("error", new OneSDKError(e.message, e.payload));
|
|
46
|
+
};
|
|
47
|
+
try {
|
|
48
|
+
// If initial request fails, it will contain an object in the form { message, errorCode }
|
|
49
|
+
// On failure, this request interrupts the flow with an error event containing
|
|
50
|
+
// the message and an error payload containing "errorCode" AND clears any stored session
|
|
51
|
+
const { individual, status } = yield client.provideAuthorisation("singpass", urlParams.get("code"));
|
|
52
|
+
// If customer decides to call "approve", submit confirmation to BFF
|
|
53
|
+
// otherwise data will automatically be purged after a few minutes
|
|
54
|
+
const approve = () => {
|
|
55
|
+
client
|
|
56
|
+
.submitCachedData()
|
|
57
|
+
.then(() => {
|
|
58
|
+
options.eventHub.emit("data_extracted_successfully");
|
|
59
|
+
})
|
|
60
|
+
.catch((e) => {
|
|
61
|
+
const { message, errorCode, issues } = e.response.data;
|
|
62
|
+
emitError({ message: `Failed sending confirmation: "${message}"`, payload: { errorCode, issues } });
|
|
63
|
+
})
|
|
64
|
+
.finally(clearStoredToken);
|
|
65
|
+
};
|
|
66
|
+
options.eventHub.emit("results", individual, status, approve);
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
clearStoredToken();
|
|
70
|
+
const { message, errorCode, issues } = e.response.data;
|
|
71
|
+
emitError({ message: `Failed sending authorisation: "${message}"`, payload: { errorCode, issues } });
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function authorize(options) {
|
|
76
|
+
var _a;
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
const singpassConfig = options.recipe.idps.singpass;
|
|
79
|
+
// Set query parameters
|
|
80
|
+
const url = getSingpassURL(singpassConfig.environment);
|
|
81
|
+
url.searchParams.set("client_id", singpassConfig.client_id);
|
|
82
|
+
url.searchParams.set("attributes", singpassConfig.attributes);
|
|
83
|
+
url.searchParams.set("state", options.session.sessionId); // Take at runtime from customer
|
|
84
|
+
url.searchParams.set("redirect_uri", (_a = singpassConfig.redirect_url) !== null && _a !== void 0 ? _a : window.location.href);
|
|
85
|
+
url.searchParams.set("purpose", singpassConfig.purpose);
|
|
86
|
+
// Using FrankieClient for redirection so in dummy mode we can intercept it and fake a redirection
|
|
87
|
+
options.frankieClient.redirect(url);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
export function hasAllAuthorisationParams(urlParams, options) {
|
|
91
|
+
const stateMatches = options.session.sessionId === urlParams.get("state");
|
|
92
|
+
const authCode = urlParams.get("code");
|
|
93
|
+
const error = urlParams.get("error");
|
|
94
|
+
const errorInfo = urlParams.get("error_description");
|
|
95
|
+
if (error)
|
|
96
|
+
throw new Error(errorInfo !== null && errorInfo !== void 0 ? errorInfo : "Internal server error");
|
|
97
|
+
if (authCode && !stateMatches)
|
|
98
|
+
throw new Error("A different session is being used to initialise the OneSDK than the one used at the beginning of the federation flow.");
|
|
99
|
+
return authCode && stateMatches;
|
|
100
|
+
}
|
|
101
|
+
export const singpassURLs = {
|
|
102
|
+
sandbox: "https://sandbox.api.myinfo.gov.sg",
|
|
103
|
+
test: "https://test.api.myinfo.gov.sg",
|
|
104
|
+
production: "https://api.myinfo.gov.sg",
|
|
105
|
+
};
|
|
106
|
+
export function getSingpassURL(environment) {
|
|
107
|
+
const urlString = [singpassURLs[environment], "com/v3/authorise"].join("/");
|
|
108
|
+
return new URL(urlString);
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=Singpass.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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