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.1.1 to 0.2.0

2

dist/index.js

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

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