@telia-ace/widget-id-hub 1.1.120-rc.1 → 1.1.120-rc.11

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.
@@ -0,0 +1,25 @@
1
+ type TunnistusResult = {
2
+ completionData?: {
3
+ user: {
4
+ givenName: string;
5
+ name: string;
6
+ ssn: string;
7
+ surname: string;
8
+ };
9
+ };
10
+ idhubEIDToken?: string;
11
+ orderRef: string;
12
+ status: string;
13
+ substatus?: string;
14
+ };
15
+ export declare class IDHubClient {
16
+ private url;
17
+ private maxRetries;
18
+ private orderRef;
19
+ private tunnistusUrl;
20
+ constructor(config: any);
21
+ auth(): Promise<string | undefined>;
22
+ collectPolling(): Promise<TunnistusResult>;
23
+ collect(): Promise<TunnistusResult>;
24
+ }
25
+ export {};
package/index.d.ts CHANGED
@@ -1 +1 @@
1
- export { IDHubPlugin } from './plugin';
1
+ export { IDHubClient } from './id-hub-client';
package/index.js CHANGED
@@ -1 +1,12 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=async u=>{console.log("Register ID Hub plugin")};exports.IDHubPlugin=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class i{constructor(e){this.url="",this.maxRetries=300,this.orderRef="",this.tunnistusUrl="",this.url=`${e.idHubUrl}/${e.idHubCustomerKey}/${e.idHubOrgKey}/${e.idHubEidType.toLowerCase()}`,this.maxRetries=e.idHubMaxRetries}async auth(){console.log("\x1B[31mID-Hub \x1B[32m - Initializing auth");try{const t=await(await fetch(this.url+"/auth",{headers:{accept:"application/json","accept-language":"sv-SE,sv;q=0.9,en-US;q=0.8,en;q=0.7","content-type":"application/json"},body:`{
2
+ "clientName": "idhub-web-1.0.0",
3
+ "register": {
4
+ "clientType": "ACEWIDGET",
5
+ "agentId": "ACEWIDGET",
6
+ "userName": "ACEWIDGET"
7
+ }
8
+ }`,method:"POST"})).json();return console.log("\x1B[31mID-Hub \x1B[32m - Initializing result",t),this.tunnistusUrl=t.tunnistusURL,this.orderRef=t.orderRef,this.tunnistusUrl}catch{return}}async collectPolling(){let e=this.maxRetries,t;do await new Promise(s=>setTimeout(s,1e3)),t=await this.collect(),e--;while(t.status=="pending"&&e>0);return t}async collect(){if(this.orderRef==="")throw new Error("OrderRef is missing");const t=await(await fetch(this.url+"/collect",{headers:{accept:"application/json","accept-language":"sv-SE,sv;q=0.9,en-US;q=0.8,en;q=0.7","content-type":"application/json"},body:`{
9
+ "clientName": "idhub-web-1.0.0",
10
+ "orderRef": "${this.orderRef}",
11
+ "method": "auth"
12
+ }`,method:"POST"})).json();return console.log("\x1B[31mID-Hub \x1B[32m - Collect result",t),t}}exports.IDHubClient=i;
package/index.mjs CHANGED
@@ -1,6 +1,57 @@
1
- const o = async (n) => {
2
- console.log("Register ID Hub plugin");
3
- };
1
+ class n {
2
+ constructor(e) {
3
+ this.url = "", this.maxRetries = 300, this.orderRef = "", this.tunnistusUrl = "", this.url = `${e.idHubUrl}/${e.idHubCustomerKey}/${e.idHubOrgKey}/${e.idHubEidType.toLowerCase()}`, this.maxRetries = e.idHubMaxRetries;
4
+ }
5
+ async auth() {
6
+ console.log("\x1B[31mID-Hub \x1B[32m - Initializing auth");
7
+ try {
8
+ const t = await (await fetch(this.url + "/auth", {
9
+ headers: {
10
+ accept: "application/json",
11
+ "accept-language": "sv-SE,sv;q=0.9,en-US;q=0.8,en;q=0.7",
12
+ "content-type": "application/json"
13
+ },
14
+ body: `{
15
+ "clientName": "idhub-web-1.0.0",
16
+ "register": {
17
+ "clientType": "ACEWIDGET",
18
+ "agentId": "ACEWIDGET",
19
+ "userName": "ACEWIDGET"
20
+ }
21
+ }`,
22
+ method: "POST"
23
+ })).json();
24
+ return console.log("\x1B[31mID-Hub \x1B[32m - Initializing result", t), this.tunnistusUrl = t.tunnistusURL, this.orderRef = t.orderRef, this.tunnistusUrl;
25
+ } catch {
26
+ return;
27
+ }
28
+ }
29
+ async collectPolling() {
30
+ let e = this.maxRetries, t;
31
+ do
32
+ await new Promise((s) => setTimeout(s, 1e3)), t = await this.collect(), e--;
33
+ while (t.status == "pending" && e > 0);
34
+ return t;
35
+ }
36
+ async collect() {
37
+ if (this.orderRef === "")
38
+ throw new Error("OrderRef is missing");
39
+ const t = await (await fetch(this.url + "/collect", {
40
+ headers: {
41
+ accept: "application/json",
42
+ "accept-language": "sv-SE,sv;q=0.9,en-US;q=0.8,en;q=0.7",
43
+ "content-type": "application/json"
44
+ },
45
+ body: `{
46
+ "clientName": "idhub-web-1.0.0",
47
+ "orderRef": "${this.orderRef}",
48
+ "method": "auth"
49
+ }`,
50
+ method: "POST"
51
+ })).json();
52
+ return console.log("\x1B[31mID-Hub \x1B[32m - Collect result", t), t;
53
+ }
54
+ }
4
55
  export {
5
- o as IDHubPlugin
56
+ n as IDHubClient
6
57
  };
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@telia-ace/widget-id-hub",
3
- "version": "1.1.120-rc.1",
3
+ "version": "1.1.120-rc.11",
4
4
  "dependencies": {
5
- "@telia-ace/widget-core-flamingo": "1.1.120-rc.1"
5
+ "@telia-ace/widget-core-flamingo": "1.1.120-rc.11"
6
6
  },
7
7
  "main": "./index.js",
8
8
  "module": "./index.mjs",
package/plugin.d.ts CHANGED
@@ -1,2 +1 @@
1
- import { Application } from '../../core/src/index.ts';
2
- export declare const IDHubPlugin: (_app: Application) => Promise<void>;
1
+ export declare const IDHubPlugin: () => Promise<void>;