@arcteninc/core 0.0.66 → 0.0.67

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/dist/server.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});async function a(t){const{apiKey:o,user:r,apiUrl:n="https://api.arcten.com"}=t,e=await fetch(`${n}/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:o,user:r})});if(!e.ok){const i=await e.json().catch(()=>({}));throw new Error(i.error||`Failed to verify token: ${e.statusText}`)}return e.json()}exports.verifyToken=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});async function h(i){const{apiKey:c,user:l,apiUrl:m="https://api.arcten.com"}=i,o=3,d=1e4;let s=null;for(let t=0;t<o;t++)try{const r=new AbortController,n=setTimeout(()=>r.abort(),d);try{const e=await fetch(`${m}/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:c,user:l}),signal:r.signal});if(clearTimeout(n),!e.ok){const a=await e.json().catch(()=>({}));throw new Error(a.error||`Failed to verify token: ${e.statusText}`)}return e.json()}catch(e){if(clearTimeout(n),(e.name==="AbortError"||e.code==="UND_ERR_SOCKET"||e.message?.includes("fetch failed")||e.message?.includes("other side closed")||e.message?.includes("ECONNRESET")||e.message?.includes("ETIMEDOUT"))&&t<o-1){const f=Math.min(1e3*Math.pow(2,t),5e3);await new Promise(T=>setTimeout(T,f)),s=e;continue}throw e}}catch(r){if(s=r,t===o-1||!r.code)break}const u=s instanceof Error?s.message:"Failed to verify token";throw new Error(`Failed to verify token after ${o} attempts: ${u}`)}exports.verifyToken=h;
package/dist/server.mjs CHANGED
@@ -1,26 +1,49 @@
1
- async function s(e) {
1
+ async function E(i) {
2
2
  const {
3
- apiKey: o,
4
- user: r,
5
- apiUrl: n = "https://api.arcten.com"
6
- } = e, t = await fetch(`${n}/token`, {
7
- method: "POST",
8
- headers: {
9
- "Content-Type": "application/json"
10
- },
11
- body: JSON.stringify({
12
- apiKey: o,
13
- user: r
14
- })
15
- });
16
- if (!t.ok) {
17
- const a = await t.json().catch(() => ({}));
18
- throw new Error(
19
- a.error || `Failed to verify token: ${t.statusText}`
20
- );
21
- }
22
- return t.json();
3
+ apiKey: c,
4
+ user: l,
5
+ apiUrl: m = "https://api.arcten.com"
6
+ } = i, o = 3, d = 1e4;
7
+ let s = null;
8
+ for (let t = 0; t < o; t++)
9
+ try {
10
+ const r = new AbortController(), n = setTimeout(() => r.abort(), d);
11
+ try {
12
+ const e = await fetch(`${m}/token`, {
13
+ method: "POST",
14
+ headers: {
15
+ "Content-Type": "application/json"
16
+ },
17
+ body: JSON.stringify({
18
+ apiKey: c,
19
+ user: l
20
+ }),
21
+ signal: r.signal
22
+ });
23
+ if (clearTimeout(n), !e.ok) {
24
+ const a = await e.json().catch(() => ({}));
25
+ throw new Error(
26
+ a.error || `Failed to verify token: ${e.statusText}`
27
+ );
28
+ }
29
+ return e.json();
30
+ } catch (e) {
31
+ if (clearTimeout(n), (e.name === "AbortError" || e.code === "UND_ERR_SOCKET" || e.message?.includes("fetch failed") || e.message?.includes("other side closed") || e.message?.includes("ECONNRESET") || e.message?.includes("ETIMEDOUT")) && t < o - 1) {
32
+ const u = Math.min(1e3 * Math.pow(2, t), 5e3);
33
+ await new Promise((h) => setTimeout(h, u)), s = e;
34
+ continue;
35
+ }
36
+ throw e;
37
+ }
38
+ } catch (r) {
39
+ if (s = r, t === o - 1 || !r.code)
40
+ break;
41
+ }
42
+ const f = s instanceof Error ? s.message : "Failed to verify token";
43
+ throw new Error(
44
+ `Failed to verify token after ${o} attempts: ${f}`
45
+ );
23
46
  }
24
47
  export {
25
- s as verifyToken
48
+ E as verifyToken
26
49
  };
@@ -1 +1 @@
1
- {"version":3,"file":"verifyToken.d.ts","sourceRoot":"","sources":["../src/verifyToken.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,WAAW,CAC/B,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,aAAa,CAAC,CA0BxB"}
1
+ {"version":3,"file":"verifyToken.d.ts","sourceRoot":"","sources":["../src/verifyToken.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,WAAW,CAC/B,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,aAAa,CAAC,CAgFxB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcteninc/core",
3
- "version": "0.0.66",
3
+ "version": "0.0.67",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",