@telia-ace/widget-id-hub 1.1.123-rc.9 → 1.1.124-rc.0
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/id-hub-client.d.ts +2 -1
- package/index.d.ts +1 -0
- package/index.js +1 -1
- package/index.mjs +9 -12
- package/package.json +2 -2
package/id-hub-client.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { IDHubStatus, AuthResponse, CollectResponse } from './types';
|
|
2
|
+
import { Auth } from 'libs/core/src/types';
|
|
2
3
|
export declare class IDHubClient {
|
|
3
4
|
private readonly url;
|
|
4
5
|
private readonly maxRetries;
|
|
5
6
|
private readonly config;
|
|
6
7
|
private orderRef;
|
|
7
|
-
constructor(config:
|
|
8
|
+
constructor(config: Auth);
|
|
8
9
|
auth(): Promise<AuthResponse>;
|
|
9
10
|
collect(): Promise<CollectResponse>;
|
|
10
11
|
cancel(): Promise<{
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var a=(s=>(s.Tunnistus="tunnistus",s.BankId="bankid",s.Freja="freja",s))(a||{}),r=(s=>(s.Pending="pending",s.Authenticated="authenticated",s.Error="error",s))(r||{});class
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var a=(s=>(s.Tunnistus="tunnistus",s.BankId="bankid",s.Freja="freja",s))(a||{}),r=(s=>(s.Pending="pending",s.Authenticated="authenticated",s.Error="error",s))(r||{});class i{constructor(e){this.orderRef="",this.config=e,this.url=`${e.idHubUrl}/${e.idHubCustomerKey}/${e.idHubOrgKey}/${e.idHubEidType}`,this.maxRetries=e.idHubMaxRetries??300}async auth(){try{const e=await fetch(`${this.url}/auth`,{headers:i.getHeaders(),body:JSON.stringify({clientName:"idhub-web-1.0.0",register:{clientType:"ACEWIDGET",agentId:"",userName:""}}),method:"POST"});if(!e.ok)return{status:r.Error,errorMessage:`Auth failed with response: ${e.status} ${e.statusText}`};const t=await e.json();switch(this.orderRef=t.orderRef,this.config.idHubEidType){case a.Tunnistus:return{tunnistusURL:t.tunnistusURL,status:r.Pending};case a.BankId:return{autoStartToken:t.autoStartToken,status:r.Pending};case a.Freja:throw new Error(`${a.Freja} is not implemented`);default:throw new Error(`The service ${this.config.idHubEidType} is not implemented`)}}catch(e){return{status:r.Error,errorMessage:`Auth failed. Error: ${e}`}}}async collect(){for(let e=0;e<this.maxRetries;e++){await new Promise(n=>setTimeout(n,1e3));const t=await this.collectOnce();if(t&&t.status!==r.Pending)return t}return{status:r.Error}}async cancel(){try{return this.orderRef?(await fetch(`${this.url}/cancel`,{headers:i.getHeaders(),body:JSON.stringify({clientName:"idhub-web-1.0.0",orderRef:this.orderRef,method:"auth"}),method:"POST"}),{}):{status:r.Error,errorMessage:"Missing order reference."}}catch(e){return{status:r.Error,errorMessage:`Cancel failed. Error: ${e}`}}}static getHeaders(){return{accept:"application/json","accept-language":"sv-SE,sv;q=0.9,en-US;q=0.8,en;q=0.7","content-type":"application/json"}}async collectOnce(){try{if(!this.orderRef)return{status:r.Error,errorMessage:"Missing order reference."};const e=await fetch(`${this.url}/collect`,{headers:i.getHeaders(),body:JSON.stringify({clientName:"idhub-web-1.0.0",orderRef:this.orderRef,method:"auth"}),method:"POST"});if(!e.ok)return{status:r.Error,errorMessage:`Collect failed with response: ${e.status} ${e.statusText}`};const t=await e.json();return t.status===r.Error?{status:r.Error,subStatus:t.subStatus??void 0}:t}catch(e){return{status:r.Error,errorMessage:`Collect failed. Error: ${e}`}}}}exports.IDHubAuthService=a;exports.IDHubClient=i;exports.IDHubStatus=r;
|
package/index.mjs
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
var a = /* @__PURE__ */ ((s) => (s.Tunnistus = "tunnistus", s.BankId = "bankid", s.Freja = "freja", s))(a || {}), r = /* @__PURE__ */ ((s) => (s.Pending = "pending", s.Authenticated = "authenticated", s.Error = "error", s))(r || {});
|
|
2
|
-
class
|
|
2
|
+
class i {
|
|
3
3
|
constructor(e) {
|
|
4
|
-
this.orderRef = "", e = {
|
|
5
|
-
...e,
|
|
6
|
-
idHubEidType: typeof (e == null ? void 0 : e.idHubEidType) == "string" ? e.idHubEidType.toLowerCase() : e.idHubEidType
|
|
7
|
-
}, this.config = e, this.url = `${e == null ? void 0 : e.idHubUrl}/${e == null ? void 0 : e.idHubCustomerKey}/${e == null ? void 0 : e.idHubOrgKey}/${e == null ? void 0 : e.idHubEidType}`, this.maxRetries = e.idHubMaxRetries ?? 300;
|
|
4
|
+
this.orderRef = "", this.config = e, this.url = `${e.idHubUrl}/${e.idHubCustomerKey}/${e.idHubOrgKey}/${e.idHubEidType}`, this.maxRetries = e.idHubMaxRetries ?? 300;
|
|
8
5
|
}
|
|
9
6
|
// ==========
|
|
10
7
|
// ID-HUB API
|
|
@@ -12,13 +9,13 @@ class u {
|
|
|
12
9
|
async auth() {
|
|
13
10
|
try {
|
|
14
11
|
const e = await fetch(`${this.url}/auth`, {
|
|
15
|
-
headers:
|
|
12
|
+
headers: i.getHeaders(),
|
|
16
13
|
body: JSON.stringify({
|
|
17
14
|
clientName: "idhub-web-1.0.0",
|
|
18
15
|
register: {
|
|
19
16
|
clientType: "ACEWIDGET",
|
|
20
|
-
agentId: "
|
|
21
|
-
userName: "
|
|
17
|
+
agentId: "",
|
|
18
|
+
userName: ""
|
|
22
19
|
}
|
|
23
20
|
}),
|
|
24
21
|
method: "POST"
|
|
@@ -56,7 +53,7 @@ class u {
|
|
|
56
53
|
}
|
|
57
54
|
async collect() {
|
|
58
55
|
for (let e = 0; e < this.maxRetries; e++) {
|
|
59
|
-
await new Promise((
|
|
56
|
+
await new Promise((n) => setTimeout(n, 1e3));
|
|
60
57
|
const t = await this.collectOnce();
|
|
61
58
|
if (t && t.status !== r.Pending)
|
|
62
59
|
return t;
|
|
@@ -66,7 +63,7 @@ class u {
|
|
|
66
63
|
async cancel() {
|
|
67
64
|
try {
|
|
68
65
|
return this.orderRef ? (await fetch(`${this.url}/cancel`, {
|
|
69
|
-
headers:
|
|
66
|
+
headers: i.getHeaders(),
|
|
70
67
|
body: JSON.stringify({
|
|
71
68
|
clientName: "idhub-web-1.0.0",
|
|
72
69
|
orderRef: this.orderRef,
|
|
@@ -102,7 +99,7 @@ class u {
|
|
|
102
99
|
errorMessage: "Missing order reference."
|
|
103
100
|
};
|
|
104
101
|
const e = await fetch(`${this.url}/collect`, {
|
|
105
|
-
headers:
|
|
102
|
+
headers: i.getHeaders(),
|
|
106
103
|
body: JSON.stringify({
|
|
107
104
|
clientName: "idhub-web-1.0.0",
|
|
108
105
|
orderRef: this.orderRef,
|
|
@@ -130,6 +127,6 @@ class u {
|
|
|
130
127
|
}
|
|
131
128
|
export {
|
|
132
129
|
a as IDHubAuthService,
|
|
133
|
-
|
|
130
|
+
i as IDHubClient,
|
|
134
131
|
r as IDHubStatus
|
|
135
132
|
};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telia-ace/widget-id-hub",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.124-rc.0",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@telia-ace/widget-core-flamingo": "1.1.123
|
|
5
|
+
"@telia-ace/widget-core-flamingo": "1.1.123"
|
|
6
6
|
},
|
|
7
7
|
"main": "./index.js",
|
|
8
8
|
"module": "./index.mjs",
|