@telia-ace/widget-id-hub 1.1.120-rc.18 → 1.1.120-rc.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.js +1 -1
  2. package/index.mjs +10 -7
  3. package/package.json +2 -2
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 u{constructor(e){this.orderRef="",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.toLowerCase()}`,this.maxRetries=e.idHubMaxRetries??300}async auth(){try{const e=await fetch(`${this.url}/auth`,{headers:u.getHeaders(),body:JSON.stringify({clientName:"idhub-web-1.0.0",register:{clientType:"ACEWIDGET",agentId:"ACEWIDGET",userName:"ACEWIDGET"}}),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(i=>setTimeout(i,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:u.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:u.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=u;exports.IDHubStatus=r;
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 u{constructor(e){this.orderRef="",e={...e,idHubEidType:typeof(e==null?void 0:e.idHubEidType)=="string"?e.idHubEidType.toLowerCase():e.idHubEidType},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}async auth(){try{const e=await fetch(`${this.url}/auth`,{headers:u.getHeaders(),body:JSON.stringify({clientName:"idhub-web-1.0.0",register:{clientType:"ACEWIDGET",agentId:"ACEWIDGET",userName:"ACEWIDGET"}}),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(i=>setTimeout(i,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:u.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:u.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=u;exports.IDHubStatus=r;
package/index.mjs CHANGED
@@ -1,7 +1,10 @@
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 i {
2
+ class u {
3
3
  constructor(e) {
4
- this.orderRef = "", 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.toLowerCase()}`, this.maxRetries = e.idHubMaxRetries ?? 300;
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;
5
8
  }
6
9
  // ==========
7
10
  // ID-HUB API
@@ -9,7 +12,7 @@ class i {
9
12
  async auth() {
10
13
  try {
11
14
  const e = await fetch(`${this.url}/auth`, {
12
- headers: i.getHeaders(),
15
+ headers: u.getHeaders(),
13
16
  body: JSON.stringify({
14
17
  clientName: "idhub-web-1.0.0",
15
18
  register: {
@@ -53,7 +56,7 @@ class i {
53
56
  }
54
57
  async collect() {
55
58
  for (let e = 0; e < this.maxRetries; e++) {
56
- await new Promise((n) => setTimeout(n, 1e3));
59
+ await new Promise((i) => setTimeout(i, 1e3));
57
60
  const t = await this.collectOnce();
58
61
  if (t && t.status !== r.Pending)
59
62
  return t;
@@ -63,7 +66,7 @@ class i {
63
66
  async cancel() {
64
67
  try {
65
68
  return this.orderRef ? (await fetch(`${this.url}/cancel`, {
66
- headers: i.getHeaders(),
69
+ headers: u.getHeaders(),
67
70
  body: JSON.stringify({
68
71
  clientName: "idhub-web-1.0.0",
69
72
  orderRef: this.orderRef,
@@ -99,7 +102,7 @@ class i {
99
102
  errorMessage: "Missing order reference."
100
103
  };
101
104
  const e = await fetch(`${this.url}/collect`, {
102
- headers: i.getHeaders(),
105
+ headers: u.getHeaders(),
103
106
  body: JSON.stringify({
104
107
  clientName: "idhub-web-1.0.0",
105
108
  orderRef: this.orderRef,
@@ -127,6 +130,6 @@ class i {
127
130
  }
128
131
  export {
129
132
  a as IDHubAuthService,
130
- i as IDHubClient,
133
+ u as IDHubClient,
131
134
  r as IDHubStatus
132
135
  };
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@telia-ace/widget-id-hub",
3
- "version": "1.1.120-rc.18",
3
+ "version": "1.1.120-rc.19",
4
4
  "dependencies": {
5
- "@telia-ace/widget-core-flamingo": "1.1.120-rc.18"
5
+ "@telia-ace/widget-core-flamingo": "1.1.120-rc.19"
6
6
  },
7
7
  "main": "./index.js",
8
8
  "module": "./index.mjs",