@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 +1 -1
- package/dist/server.mjs +45 -22
- package/dist/verifyToken.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/server.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});async function
|
|
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
|
|
1
|
+
async function E(i) {
|
|
2
2
|
const {
|
|
3
|
-
apiKey:
|
|
4
|
-
user:
|
|
5
|
-
apiUrl:
|
|
6
|
-
} =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
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,
|
|
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"}
|