Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@based/opts

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@based/opts - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

2

dist/index.js

@@ -1,1 +0,1 @@

var h=Object.create;var D=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var te=Object.getOwnPropertyNames;var re=Object.getPrototypeOf,ne=Object.prototype.hasOwnProperty;var _=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),le=(e,t)=>{for(var r in t)D(e,r,{get:t[r],enumerable:!0})},F=(e,t,r,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of te(t))!ne.call(e,o)&&o!==r&&D(e,o,{get:()=>t[o],enumerable:!(l=ee(t,o))||l.enumerable});return e};var R=(e,t,r)=>(r=e!=null?h(re(e)):{},F(t||!e||!e.__esModule?D(r,"default",{value:e,enumerable:!0}):r,e)),oe=e=>F(D({},"__esModule",{value:!0}),e);var b=_(K=>{"use strict";Object.defineProperty(K,"__esModule",{value:!0});var fe=(e,t=5381)=>{let r=e.length;for(;r;){let l=e.charCodeAt(--r);t=t*33^l}return t};K.default=fe});var A=_(m=>{"use strict";var se=m&&m.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(m,"__esModule",{value:!0});var c=se(b()),v=(e,t=5381,r=52711)=>{if(Array.isArray(e))for(let l=0;l<e.length;l++){let o=e[l],u=typeof o;if(u==="string"){let n=l+":"+o;t=c.default(n,t),r=c.default(n,r)}else if(u==="number"){let n=l+"n:"+o;t=c.default(n,t),r=c.default(n,r)}else if(u==="object")if(o===null){let n=l+"v:null";t=c.default(n,t),r=c.default(n,r)}else{let n=v(o,t,r);t=c.default(l+"o:",n[0]),r=c.default(l+"o:",n[1])}else if(u==="boolean"){let n=l+"b:"+(o?"true":"false");t=c.default(n,t),r=c.default(n,r)}}else for(let l in e){let o=e[l],u=typeof o;if(u==="string"){let n=l+":"+o;t=c.default(n,t),r=c.default(n,r)}else if(u==="number"){let n=l+"n:"+o;t=c.default(n,t),r=c.default(n,r)}else if(u==="object")if(o===null){let n=l+"v:null";t=c.default(n,t),r=c.default(n,r)}else{let n=v(o,t,r);t=c.default(l+"o:",n[0]),r=c.default(l+"o:",n[1])}else if(u==="boolean"){let n=l+"b:"+(o?"true":"false");t=c.default(n,t),r=c.default(n,r)}}return[t,r]};m.default=v});var P=_(O=>{"use strict";var ie=O&&O.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(O,"__esModule",{value:!0});var ce=ie(A()),ae=e=>{let t=ce.default(e);return(t[0]>>>0)*4096+t[1]};O.default=ae});var I=_(j=>{"use strict";var E=j&&j.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(j,"__esModule",{value:!0});var de=E(P()),$=E(b()),_e=(e,t)=>{let r;if(typeof e=="object"?e===null?r=0:r=de.default(e):typeof e=="boolean"?r=($.default(e?":true":":false")>>>0)*4096:typeof e=="number"?r=($.default("n:"+e)>>>0)*4096+($.default("n:"+e,52711)>>>0):r=($.default(e)>>>0)*4096+($.default(e,52711)>>>0),t){let l=Math.ceil(Math.log10(r+1));if(l<t)return r*Math.pow(10,t-l)}return r};j.default=_e});var L=_(M=>{"use strict";var N=M&&M.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(M,"__esModule",{value:!0});var W=N(I()),S=N(b()),ge=N(P()),G=H(),ye="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",J=e=>{let t="",r;do r=e%62,t=ye.charAt(r)+t,e=Math.floor(e/62);while(e>0);return t},be=(e,t,r)=>{let l;if(typeof e=="object")if(e===null)l=0;else if(t&&t>9&&e.constructor===Array){let n="",f=e.length;for(let s=0;s<f;s++)n+=J(r&&e[s]&&typeof e[s]=="object"?G.hashObjectIgnoreKeyOrder(e[s]):W.default(e[s]));let a=n.length;if(a<t)n+="x",a+1<t&&(n+=new Array(t-a).join("0"));else if(a>t)return n.slice(0,t);return n}else l=(r?G.hashObjectIgnoreKeyOrder(e):ge.default(e))>>>0;else typeof e=="boolean"?l=S.default(e?":true":":false")*4096:typeof e=="number"?l=(S.default("n:"+e)>>>0)*4096:l=S.default(e)>>>0;let o=J(l),u=o.length;return u<t&&(o+="x",u+1<t&&(o+=new Array(t-u).join("0"))),o};M.default=be});var B=_(q=>{"use strict";var pe=q&&q.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(q,"__esModule",{value:!0});var i=pe(b()),x=(e,t=5381,r=52711)=>{if(Array.isArray(e)){let l="__len:"+e.length+1;t=i.default(l,t),r=i.default(l,r);for(let o=0;o<e.length;o++){let u=e[o],n=typeof u;if(n==="string"){let f=o+":"+u;t=i.default(f,t),r=i.default(f,r)}else if(n==="number"){let f=o+"n:"+u;t=i.default(f,t),r=i.default(f,r)}else if(n==="object")if(u===null){let f=o+"v:null";t=i.default(f,t),r=i.default(f,r)}else{let f=x(u,t,r),a=o+"o:";t=i.default(a,f[0]),r=i.default(a,f[1])}else if(n==="boolean"){let f=o+"b:"+(u?"true":"false");t=i.default(f,t),r=i.default(f,r)}}}else{let l=Object.keys(e).sort(),o="__len:"+l.length+1;t=i.default(o,t),r=i.default(o,r);for(let u=0;u<l.length;u++){let n=l[u],f=e[n],a=typeof f;if(a==="string"){let s=n+":"+f;t=i.default(s,t),r=i.default(s,r)}else if(a==="number"){let s=n+"n:"+f;t=i.default(s,t),r=i.default(s,r)}else if(a==="object")if(f===null){let s=n+"v:null";t=i.default(s,t),r=i.default(s,r)}else{let s=x(f,t,r),C=n+"o:";t=i.default(C,s[0]),r=i.default(C,s[1])}else if(a==="boolean"){let s=n+"b:"+(f?"true":"false");t=i.default(s,t),r=i.default(s,r)}}}return[t,r]};q.default=x});var Q=_(w=>{"use strict";var me=w&&w.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(w,"__esModule",{value:!0});var Oe=me(B()),$e=e=>{let t=Oe.default(e);return(t[0]>>>0)*4096+(t[1]>>>0)};w.default=$e});var H=_(d=>{"use strict";var g=d&&d.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(d,"__esModule",{value:!0});var je=g(I());d.hash=je.default;var Me=g(L());d.hashCompact=Me.default;var qe=g(P());d.hashObject=qe.default;var we=g(Q());d.hashObjectIgnoreKeyOrder=we.default;var Ce=g(B());d.hashObjectIgnoreKeyOrderNest=Ce.default;var De=g(A());d.hashObjectNest=De.default;var Pe=g(b());d.stringHash=Pe.default});var He={};le(He,{default:()=>Ne,genCache:()=>U,getServicePort:()=>k});module.exports=oe(He);var V=R(require("cross-fetch")),p=require("@saulx/utils");var ue=e=>{let t=5381,r=e.length;for(;r;)t=t*33^e.charCodeAt(--r);let l=t>>>0;for(;l>65535;)l=l/10;return Math.round(l)},k=(e,t,r,l,o="allServices",u=0)=>ue(`${o}-${e}-${t}-${r}-${l}-${u}`);var X=R(H()),ke=Array.from(Array(10)).map((e,t)=>String(t)),Ke=["localhost","based.io","based.dev","@based","/env-hub","admin","hub","-",",",".","?"],Y=e=>e||"@based/env-hub",{encode:ve}=(0,p.createEncoder)(Ke,ke),U=e=>{let t={name:Y(e.name)};e.key&&e.optionalKey?t.optionalKey=e.key:e.key&&(t.key=e.key);let r=t.optionalKey?`${t.name},${t.key}?`:t.key?`${t.name},${t.key}`:t.name;return ve(r)},Ae=async(e,t,r)=>{try{let l=Math.floor(Math.random()*1e4),o=await(0,V.default)(`${e}/status/${l}`,{headers:{"sequence-id":U(t),...t.headers}});if(o.ok){let u=o.headers.get("x-request-id");if(!u)return 1;let{decode:n}=(0,p.createEncoder)(Se,u.slice(0,6).split("")),f=n(u.slice(6)).split(","),a=[];for(let y=0;y<Math.floor(f.length/2);y++)a.push([f[y],encodeURIComponent(f[f.length-1-y])]);let[s,C]=a[~~(Math.random()*a.length)];return r?`${/^https/.test(e)?"https":"http"}://${s}`:`${/^https/.test(e)?"wss":"ws"}://${s}/${C}`}else return!1}catch{return!1}},T=/^ws/,Ie=({cluster:e="production",org:t,project:r,env:l,name:o})=>{if(e==="local")return[`http://localhost:${k(t,r,l,Y(o).includes("env-")?"@based/env-hub-discovery":"@based/hub-discovery","allServices")}`];let u=`-${(0,X.stringHash)(`${e}:${t}:${r}:${l}`).toString(36)}`;e&&e!=="production"&&(u+=`-${e}`),u+="-status";let n=`${t}-${r}-${l}`,f=n.length+u.length;return f>63&&(n=n.substring(0,63-f)),[`https://${n}${u}.based.dev`]},Z=async(e,t=!1,r=0)=>{if(e.url){let o;return typeof e.url=="function"?o=await e.url():o=e.url,t&&o&&T.test(o)?o.replace(T,"http"):o}let l=e.discoveryUrls||Ie(e);for(let o=0;o<l.length;o++){let u=l[o],n=await Promise.race([Ae(u,e,t),(0,p.wait)(3e3)]);if(n===1||!n&&o===l.length-1)return await(0,p.wait)(Math.min(r*r*50+500,5e3)),Z(e,t,++r);if(n)return n}},Se=[",",".based.dev","localhost:","localhost","based.io","based.dev","@based","/env-hub","admin","hub","900","90","443","80",":","%","/","=","<","?","."],z=Z;var Ne=async(e,t)=>z(e,t);0&&(module.exports={genCache,getServicePort});
var z=Object.create;var w=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var te=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var b=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ne=(e,t)=>{for(var r in t)w(e,r,{get:t[r],enumerable:!0})},U=(e,t,r,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of ee(t))!re.call(e,u)&&u!==r&&w(e,u,{get:()=>t[u],enumerable:!(l=h(t,u))||l.enumerable});return e};var E=(e,t,r)=>(r=e!=null?z(te(e)):{},U(t||!e||!e.__esModule?w(r,"default",{value:e,enumerable:!0}):r,e)),le=e=>U(w({},"__esModule",{value:!0}),e);var p=b(v=>{"use strict";Object.defineProperty(v,"__esModule",{value:!0});var oe=(e,t=5381)=>{let r=e.length;for(;r;){let l=e.charCodeAt(--r);t=t*33^l}return t};v.default=oe});var S=b(y=>{"use strict";var fe=y&&y.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(y,"__esModule",{value:!0});var c=fe(p()),I=(e,t=5381,r=52711)=>{if(Array.isArray(e))for(let l=0;l<e.length;l++){let u=e[l],o=typeof u;if(o==="string"){let n=l+":"+u;t=c.default(n,t),r=c.default(n,r)}else if(o==="number"){let n=l+"n:"+u;t=c.default(n,t),r=c.default(n,r)}else if(o==="object")if(u===null){let n=l+"v:null";t=c.default(n,t),r=c.default(n,r)}else{let n=I(u,t,r);t=c.default(l+"o:",n[0]),r=c.default(l+"o:",n[1])}else if(o==="boolean"){let n=l+"b:"+(u?"true":"false");t=c.default(n,t),r=c.default(n,r)}}else for(let l in e){let u=e[l],o=typeof u;if(o==="string"){let n=l+":"+u;t=c.default(n,t),r=c.default(n,r)}else if(o==="number"){let n=l+"n:"+u;t=c.default(n,t),r=c.default(n,r)}else if(o==="object")if(u===null){let n=l+"v:null";t=c.default(n,t),r=c.default(n,r)}else{let n=I(u,t,r);t=c.default(l+"o:",n[0]),r=c.default(l+"o:",n[1])}else if(o==="boolean"){let n=l+"b:"+(u?"true":"false");t=c.default(n,t),r=c.default(n,r)}}return[t,r]};y.default=I});var D=b(O=>{"use strict";var se=O&&O.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(O,"__esModule",{value:!0});var ie=se(S()),ce=e=>{let t=ie.default(e);return(t[0]>>>0)*4096+t[1]};O.default=ce});var A=b(j=>{"use strict";var R=j&&j.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(j,"__esModule",{value:!0});var de=R(D()),m=R(p()),ae=(e,t)=>{let r;if(typeof e=="object"?e===null?r=0:r=de.default(e):typeof e=="boolean"?r=(m.default(e?":true":":false")>>>0)*4096:typeof e=="number"?r=(m.default("n:"+e)>>>0)*4096+(m.default("n:"+e,52711)>>>0):r=(m.default(e)>>>0)*4096+(m.default(e,52711)>>>0),t){let l=Math.ceil(Math.log10(r+1));if(l<t)return r*Math.pow(10,t-l)}return r};j.default=ae});var G=b(M=>{"use strict";var N=M&&M.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(M,"__esModule",{value:!0});var F=N(A()),K=N(p()),_e=N(D()),V=k(),be="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",W=e=>{let t="",r;do r=e%62,t=be.charAt(r)+t,e=Math.floor(e/62);while(e>0);return t},ge=(e,t,r)=>{let l;if(typeof e=="object")if(e===null)l=0;else if(t&&t>9&&e.constructor===Array){let n="",f=e.length;for(let s=0;s<f;s++)n+=W(r&&e[s]&&typeof e[s]=="object"?V.hashObjectIgnoreKeyOrder(e[s]):F.default(e[s]));let d=n.length;if(d<t)n+="x",d+1<t&&(n+=new Array(t-d).join("0"));else if(d>t)return n.slice(0,t);return n}else l=(r?V.hashObjectIgnoreKeyOrder(e):_e.default(e))>>>0;else typeof e=="boolean"?l=K.default(e?":true":":false")*4096:typeof e=="number"?l=(K.default("n:"+e)>>>0)*4096:l=K.default(e)>>>0;let u=W(l),o=u.length;return o<t&&(u+="x",o+1<t&&(u+=new Array(t-o).join("0"))),u};M.default=ge});var B=b($=>{"use strict";var pe=$&&$.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty($,"__esModule",{value:!0});var i=pe(p()),H=(e,t=5381,r=52711)=>{if(Array.isArray(e)){let l="__len:"+e.length+1;t=i.default(l,t),r=i.default(l,r);for(let u=0;u<e.length;u++){let o=e[u],n=typeof o;if(n==="string"){let f=u+":"+o;t=i.default(f,t),r=i.default(f,r)}else if(n==="number"){let f=u+"n:"+o;t=i.default(f,t),r=i.default(f,r)}else if(n==="object")if(o===null){let f=u+"v:null";t=i.default(f,t),r=i.default(f,r)}else{let f=H(o,t,r),d=u+"o:";t=i.default(d,f[0]),r=i.default(d,f[1])}else if(n==="boolean"){let f=u+"b:"+(o?"true":"false");t=i.default(f,t),r=i.default(f,r)}}}else{let l=Object.keys(e).sort(),u="__len:"+l.length+1;t=i.default(u,t),r=i.default(u,r);for(let o=0;o<l.length;o++){let n=l[o],f=e[n],d=typeof f;if(d==="string"){let s=n+":"+f;t=i.default(s,t),r=i.default(s,r)}else if(d==="number"){let s=n+"n:"+f;t=i.default(s,t),r=i.default(s,r)}else if(d==="object")if(f===null){let s=n+"v:null";t=i.default(s,t),r=i.default(s,r)}else{let s=H(f,t,r),_=n+"o:";t=i.default(_,s[0]),r=i.default(_,s[1])}else if(d==="boolean"){let s=n+"b:"+(f?"true":"false");t=i.default(s,t),r=i.default(s,r)}}}return[t,r]};$.default=H});var J=b(q=>{"use strict";var ye=q&&q.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(q,"__esModule",{value:!0});var Oe=ye(B()),me=e=>{let t=Oe.default(e);return(t[0]>>>0)*4096+(t[1]>>>0)};q.default=me});var k=b(a=>{"use strict";var g=a&&a.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(a,"__esModule",{value:!0});var je=g(A());a.hash=je.default;var Me=g(G());a.hashCompact=Me.default;var $e=g(D());a.hashObject=$e.default;var qe=g(J());a.hashObjectIgnoreKeyOrder=qe.default;var Ce=g(B());a.hashObjectIgnoreKeyOrderNest=Ce.default;var we=g(S());a.hashObjectNest=we.default;var De=g(p());a.stringHash=De.default});var Ke={};ne(Ke,{default:()=>Ae,genCache:()=>x,getServicePort:()=>P});module.exports=le(Ke);var Q=E(require("cross-fetch")),C=require("@saulx/utils");var ue=e=>{let t=5381,r=e.length;for(;r;)t=t*33^e.charCodeAt(--r);let l=t>>>0;for(;l>65535;)l=l/10;return Math.round(l)},P=(e,t,r,l,u="allServices",o=0)=>ue(`${u}-${e}-${t}-${r}-${l}-${o}`);var T=E(k()),X=e=>e||"@based/env-hub",Pe={"@based/env-hub":0,"@based/env-admin-hub":1,"@based/admin-hub":2,"@based/machine-hub":3},x=e=>{let t=Pe[X(e.name)],r=Math.floor(Math.random()*1e4),l=t+""+r;return e.key?l+"/"+e.optionalKey?e.key+"$":e.key:l},ve=async(e,t,r)=>{try{let l=await(0,Q.default)(`${e}/status/${x(t)}`,{headers:t.headers});if(l.ok){let u=l.headers.get("x-request-id");if(!u)return 1;let{decode:o}=(0,C.createEncoder)(Se,u.slice(0,6).split("")),n=o(u.slice(6)).split(","),f=[];for(let _=0;_<Math.floor(n.length/2);_++)f.push([n[_],encodeURIComponent(n[n.length-1-_])]);let[d,s]=f[~~(Math.random()*f.length)];return r?`${/^https/.test(e)?"https":"http"}://${d}`:`${/^https/.test(e)?"wss":"ws"}://${d}/${s}`}else return!1}catch{return!1}},L=/^ws/,Ie=({cluster:e="production",org:t,project:r,env:l,name:u})=>{if(e==="local")return[`http://localhost:${P(t,r,l,X(u).includes("env-")?"@based/env-hub-discovery":"@based/hub-discovery","allServices")}`];let o=`-${(0,T.stringHash)(`${e}:${t}:${r}:${l}`).toString(36)}`;e&&e!=="production"&&(o+=`-${e}`),o+="-status";let n=`${t}-${r}-${l}`,f=n.length+o.length;return f>63&&(n=n.substring(0,63-f)),[`https://${n}${o}.based.dev`]},Y=async(e,t=!1,r=0)=>{if(e.url){let u;return typeof e.url=="function"?u=await e.url():u=e.url,t&&u&&L.test(u)?u.replace(L,"http"):u}let l=e.discoveryUrls||Ie(e);for(let u=0;u<l.length;u++){let o=l[u],n=await Promise.race([ve(o,e,t),(0,C.wait)(3e3)]);if(n===1||!n&&u===l.length-1)return await(0,C.wait)(Math.min(r*r*50+500,5e3)),Y(e,t,++r);if(n)return n}},Se=[",",".based.dev","localhost:","localhost","based.io","based.dev","@based","/env-hub","admin","hub","900","90","443","80",":","%","/","=","<","?","."],Z=Y;var Ae=async(e,t)=>Z(e,t);0&&(module.exports={genCache,getServicePort});
{
"name": "@based/opts",
"version": "0.3.0",
"version": "0.4.0",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "source": "src/index.ts",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc