ipfsd-ctl
Advanced tools
| (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.IpfsdCtl = factory()}(typeof self !== 'undefined' ? self : this, function () { | ||
| "use strict";var IpfsdCtl=(()=>{var J=Object.create;var f=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var M=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty;var d=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),F=(e,t)=>{for(var o in t)f(e,o,{get:t[o],enumerable:!0})},O=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of G(t))!B.call(e,n)&&n!==o&&f(e,n,{get:()=>t[n],enumerable:!(r=q(t,n))||r.enumerable});return e};var E=(e,t,o)=>(o=e!=null?J(M(e)):{},O(t||!e||!e.__esModule?f(o,"default",{value:e,enumerable:!0}):o,e)),V=e=>O(f({},"__esModule",{value:!0}),e);var x=d((it,S)=>{"use strict";S.exports=e=>{if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}});var k=d(($,v)=>{"use strict";var h=x(),{hasOwnProperty:A}=Object.prototype,{propertyIsEnumerable:z}=Object,p=(e,t,o)=>Object.defineProperty(e,t,{value:o,writable:!0,enumerable:!0,configurable:!0}),C=$,P={concatArrays:!1,ignoreUndefined:!1},u=e=>{let t=[];for(let o in e)A.call(e,o)&&t.push(o);if(Object.getOwnPropertySymbols){let o=Object.getOwnPropertySymbols(e);for(let r of o)z.call(e,r)&&t.push(r)}return t};function a(e){return Array.isArray(e)?H(e):h(e)?Q(e):e}function H(e){let t=e.slice(0,0);return u(e).forEach(o=>{p(t,o,a(e[o]))}),t}function Q(e){let t=Object.getPrototypeOf(e)===null?Object.create(null):{};return u(e).forEach(o=>{p(t,o,a(e[o]))}),t}var T=(e,t,o,r)=>(o.forEach(n=>{typeof t[n]>"u"&&r.ignoreUndefined||(n in e&&e[n]!==Object.getPrototypeOf(e)?p(e,n,w(e[n],t[n],r)):p(e,n,a(t[n])))}),e),X=(e,t,o)=>{let r=e.slice(0,0),n=0;return[e,t].forEach(s=>{let l=[];for(let i=0;i<s.length;i++)A.call(s,i)&&(l.push(String(i)),s===e?p(r,n++,s[i]):p(r,n++,a(s[i])));r=T(r,s,u(s).filter(i=>!l.includes(i)),o)}),r};function w(e,t,o){return o.concatArrays&&Array.isArray(e)&&Array.isArray(t)?X(e,t,o):!h(t)||!h(e)?a(t):T(e,t,u(t),o)}v.exports=function(...e){let t=w(a(P),this!==C&&this||{},P),o={_:{}};for(let r of e)if(r!==void 0){if(!h(r))throw new TypeError("`"+r+"` is not an Option Object");o=w(o,{_:r},t)}return o._}});var U=d((pt,_)=>{function Y(){return!!(typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&process.versions.electron||typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent.indexOf("Electron")>=0)}_.exports=Y});var rt={};F(rt,{createFactory:()=>I,createNode:()=>et,createServer:()=>ot});var y=class{options;port;host;constructor(t={port:43134,host:"localhost"}){this.options=t,this.port=this.options.port??43134,this.host=this.options.host??"localhost",console.warn("Server not implemented in the browser")}async start(){return console.warn("Server not implemented in the browser"),this}async stop(){console.warn("Server not implemented in the browser")}},j=y;var N=E(k(),1),R=N.default;var L=E(U(),1),Z=typeof window=="object"&&typeof document=="object"&&document.nodeType===9,K=(0,L.default)();var W=K&&!Z;var D=typeof globalThis.process<"u"&&typeof globalThis.process.release<"u"&&globalThis.process.release.name==="node"&&!K,at=typeof importScripts=="function"&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,lt=typeof globalThis.process<"u"&&typeof globalThis.process.env<"u"&&globalThis.process.env["NODE"+"_"+"ENV"]==="test",ft=typeof navigator<"u"&&navigator.product==="ReactNative";var c=class{options;peerInfo;id;disposable;repo;endpoint;_api;initArgs;startArgs;stopArgs;constructor(t){if(t.rpc==null)throw new Error("Please pass an rpc option");this.options=t,this.endpoint=t.endpoint,this.disposable=t.disposable,this.id=t.id,this.repo=t.repo,t.init!=null&&typeof t.init!="boolean"&&(this.initArgs=t.init),t.start!=null&&typeof t.start!="boolean"&&(this.startArgs=t.start),t.stop!=null&&(this.stopArgs=t.stop)}get api(){if(this._api==null)throw new Error("Not started");return this._api}async info(){let t=await fetch(`${this.endpoint}/info?${new URLSearchParams({id:this.id})}`,{method:"GET"});if(!t.ok)throw new Error(`Error getting remote kubo info - ${await t.text()}`);return t.json()}async init(t){let o=await fetch(`${this.endpoint}/init?${new URLSearchParams({id:this.id})}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({...this.initArgs??{},...t??{}})});if(!o.ok)throw new Error(`Error initializing remote kubo - ${await o.text()}`)}async start(t){let o=await fetch(`${this.endpoint}/start?${new URLSearchParams({id:this.id})}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({...this.startArgs??{},...t??{}})});if(!o.ok)throw new Error(`Error starting remote kubo - ${await o.text()}`);let r=await o.json();this._api=this.options.rpc(r.api)}async stop(t){let o=await fetch(`${this.endpoint}/stop?${new URLSearchParams({id:this.id})}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({...this.stopArgs??{},...t??{}})});if(!o.ok)throw new Error(`Error stopping remote kubo - ${await o.text()}`);this.disposable&&await this.cleanup()}async cleanup(){let t=await fetch(`${this.endpoint}/cleanup?${new URLSearchParams({id:this.id})}`,{method:"POST"});if(!t.ok)throw new Error(`Error cleaning up remote kubo - ${await t.text()}`)}};var b=R.bind({ignoreUndefined:!0}),tt={endpoint:process.env.IPFSD_CTL_SERVER??"http://localhost:43134",remote:!D&&!W,disposable:!0,test:!1,type:"kubo",env:{},args:[],forceKill:!0,forceKillTimeout:5e3},m=class{options;controllers;overrides;constructor(t={},o={}){this.options=b({},tt,t),this.overrides=b({kubo:this.options},o),this.controllers=[]}async spawn(t){let o=t?.type??this.options.type??"kubo",r=b({},this.options,this.overrides[o],t),n;if(o==="kubo")if(r.remote===!0){let l=await(await fetch(`${r.endpoint}/spawn`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({...r,remote:!1})})).json();n=new c({...r,...l})}else n=new c(r);if(n==null)throw new Error(`Unsupported type "${o}" - configured types [${[...new Set([this.options.type,...Object.keys(this.overrides)].filter(Boolean))].join(", ")}]`);return this.controllers.push(n),r.init!==!1&&await n.init(r.init),r.start!==!1&&await n.start(r.start),n}async clean(){await Promise.all(this.controllers.map(async t=>t.stop())),this.controllers=[]}},g=m;function I(e,t){return new g(e,t)}async function et(e){return new g().spawn(e)}var ot=(e,t={},o={})=>{let r;return typeof e=="number"?r=e:e!=null&&(r=e.port),new j({port:r,host:"127.0.0.1"},()=>I(t,o))};return V(rt);})(); | ||
| "use strict";var IpfsdCtl=(()=>{var J=Object.create;var f=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var M=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty;var d=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),F=(e,t)=>{for(var o in t)f(e,o,{get:t[o],enumerable:!0})},O=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of G(t))!B.call(e,n)&&n!==o&&f(e,n,{get:()=>t[n],enumerable:!(r=q(t,n))||r.enumerable});return e};var E=(e,t,o)=>(o=e!=null?J(M(e)):{},O(t||!e||!e.__esModule?f(o,"default",{value:e,enumerable:!0}):o,e)),V=e=>O(f({},"__esModule",{value:!0}),e);var x=d((it,S)=>{"use strict";S.exports=e=>{if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}});var k=d(($,v)=>{"use strict";var h=x(),{hasOwnProperty:A}=Object.prototype,{propertyIsEnumerable:z}=Object,p=(e,t,o)=>Object.defineProperty(e,t,{value:o,writable:!0,enumerable:!0,configurable:!0}),C=$,P={concatArrays:!1,ignoreUndefined:!1},u=e=>{let t=[];for(let o in e)A.call(e,o)&&t.push(o);if(Object.getOwnPropertySymbols){let o=Object.getOwnPropertySymbols(e);for(let r of o)z.call(e,r)&&t.push(r)}return t};function a(e){return Array.isArray(e)?H(e):h(e)?Q(e):e}function H(e){let t=e.slice(0,0);return u(e).forEach(o=>{p(t,o,a(e[o]))}),t}function Q(e){let t=Object.getPrototypeOf(e)===null?Object.create(null):{};return u(e).forEach(o=>{p(t,o,a(e[o]))}),t}var T=(e,t,o,r)=>(o.forEach(n=>{typeof t[n]>"u"&&r.ignoreUndefined||(n in e&&e[n]!==Object.getPrototypeOf(e)?p(e,n,w(e[n],t[n],r)):p(e,n,a(t[n])))}),e),X=(e,t,o)=>{let r=e.slice(0,0),n=0;return[e,t].forEach(s=>{let l=[];for(let i=0;i<s.length;i++)A.call(s,i)&&(l.push(String(i)),s===e?p(r,n++,s[i]):p(r,n++,a(s[i])));r=T(r,s,u(s).filter(i=>!l.includes(i)),o)}),r};function w(e,t,o){return o.concatArrays&&Array.isArray(e)&&Array.isArray(t)?X(e,t,o):!h(t)||!h(e)?a(t):T(e,t,u(t),o)}v.exports=function(...e){let t=w(a(P),this!==C&&this||{},P),o={_:{}};for(let r of e)if(r!==void 0){if(!h(r))throw new TypeError("`"+r+"` is not an Option Object");o=w(o,{_:r},t)}return o._}});var U=d((pt,_)=>{function Y(){return!!(typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&process.versions.electron||typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent.indexOf("Electron")>=0)}_.exports=Y});var rt={};F(rt,{createFactory:()=>I,createNode:()=>et,createServer:()=>ot});var y=class{options;port;host;constructor(t={port:43134,host:"localhost"}){this.options=t,this.port=this.options.port??43134,this.host=this.options.host??"localhost",console.warn("Server not implemented in the browser")}async start(){return console.warn("Server not implemented in the browser"),this}async stop(){console.warn("Server not implemented in the browser")}},j=y;var N=E(k(),1),R=N.default;var L=E(U(),1),Z=typeof window=="object"&&typeof document=="object"&&document.nodeType===9,K=(0,L.default)();var W=K&&!Z;var D=typeof globalThis.process<"u"&&typeof globalThis.process.release<"u"&&globalThis.process.release.name==="node"&&!K,at=typeof importScripts=="function"&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,lt=typeof globalThis.process<"u"&&typeof globalThis.process.env<"u"&&globalThis.process.env["NODE"+"_"+"ENV"]==="test",ft=typeof navigator<"u"&&navigator.product==="ReactNative";var c=class{options;peerInfo;id;disposable;repo;endpoint;_api;initArgs;startArgs;stopArgs;constructor(t){if(t.rpc==null)throw new Error("Please pass an rpc option");this.options=t,this.endpoint=t.endpoint,this.disposable=t.disposable,this.id=t.id,this.repo=t.repo,t.init!=null&&typeof t.init!="boolean"&&(this.initArgs=t.init),t.start!=null&&typeof t.start!="boolean"&&(this.startArgs=t.start),t.stop!=null&&(this.stopArgs=t.stop)}get api(){if(this._api==null)throw new Error("Not started");return this._api}async info(){let t=await fetch(`${this.endpoint}/info?${new URLSearchParams({id:this.id})}`,{method:"GET"});if(!t.ok)throw new Error(`Error getting remote kubo info - ${await t.text()}`);return t.json()}async init(t){let o=await fetch(`${this.endpoint}/init?${new URLSearchParams({id:this.id})}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({...this.initArgs??{},...t??{}})});if(!o.ok)throw new Error(`Error initializing remote kubo - ${await o.text()}`)}async start(t){let o=await fetch(`${this.endpoint}/start?${new URLSearchParams({id:this.id})}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({...this.startArgs??{},...t??{}})});if(!o.ok)throw new Error(`Error starting remote kubo - ${await o.text()}`);let r=await o.json();this._api=this.options.rpc(r.api)}async stop(t){let o=await fetch(`${this.endpoint}/stop?${new URLSearchParams({id:this.id})}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({...this.stopArgs??{},...t??{}})});if(!o.ok)throw new Error(`Error stopping remote kubo - ${await o.text()}`);this.disposable&&await this.cleanup()}async cleanup(){let t=await fetch(`${this.endpoint}/cleanup?${new URLSearchParams({id:this.id})}`,{method:"POST"});if(!t.ok)throw new Error(`Error cleaning up remote kubo - ${await t.text()}`)}};var b=R.bind({ignoreUndefined:!0}),tt={endpoint:process.env.IPFSD_CTL_SERVER??"http://localhost:43134",remote:!D&&!W,disposable:!0,test:!1,type:"kubo",env:{},args:[],forceKill:!0,forceKillTimeout:5e3},m=class{options;controllers;overrides;constructor(t={},o={}){this.options=b({},tt,t),this.overrides=b({kubo:this.options},o),this.controllers=[]}async spawn(t){let o=t?.type??this.options.type??"kubo",r=b({},this.options,this.overrides[o],t),n;if(o==="kubo")if(r.remote===!0){let l=await(await fetch(`${r.endpoint}/spawn`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({...r,remote:!1})})).json();n=new c({...r,...l})}else n=new c(r);if(n==null)throw new Error(`Unsupported type "${o}" - configured types [${[...new Set([this.options.type,...Object.keys(this.overrides)].filter(Boolean))].join(", ")}]`);return this.controllers.push(n),r.init!==!1&&await n.init(r.init),r.start!==!1&&await n.start(r.start),n}async clean(){await Promise.all(this.controllers.map(async t=>t.stop())),this.controllers=[]}},g=m;function I(e,t){return new g(e,t)}async function et(e){return new g().spawn(e)}var ot=(e,t={},o={})=>{let r;return typeof e=="number"?r=e:e!=null&&(r=e.port),new j({port:r,host:"127.0.0.1"},I(t,o))};return V(rt);})(); | ||
| return IpfsdCtl})); |
@@ -1,5 +0,5 @@ | ||
| import type { Factory } from '../index.js'; | ||
| import type { Node, Factory } from '../index.js'; | ||
| import type { Server } from '@hapi/hapi'; | ||
| declare const _default: (server: Server, createFactory: () => Factory | Promise<Factory>) => void; | ||
| declare const _default: (server: Server, ipfsd: Factory, nodes: Record<string, Node>) => void; | ||
| export default _default; | ||
| //# sourceMappingURL=routes.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../../src/endpoint/routes.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAQ,OAAO,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;iCAyBhB,MAAM,iBAAiB,MAAM,OAAO,GAAG,QAAQ,OAAO,CAAC,KAAG,IAAI;AAAtF,wBAqIC"} | ||
| {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../../src/endpoint/routes.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;iCAuBhB,MAAM,SAAS,OAAO,SAAS,OAAO,MAAM,EAAE,IAAI,CAAC,KAAG,IAAI;AAAlF,wBAoIC"} |
@@ -24,4 +24,3 @@ import boom from '@hapi/boom'; | ||
| }; | ||
| const nodes = {}; | ||
| export default (server, createFactory) => { | ||
| export default (server, ipfsd, nodes) => { | ||
| /** | ||
@@ -36,3 +35,2 @@ * Spawn a controller | ||
| try { | ||
| const ipfsd = await createFactory(); | ||
| const id = nanoid(); | ||
@@ -39,0 +37,0 @@ nodes[id] = await ipfsd.spawn({ |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"routes.js","sourceRoot":"","sources":["../../../src/endpoint/routes.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,YAAY,CAAA;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAI/B,MAAM,KAAK,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAA;AAExC,MAAM,YAAY,GAAG;IACnB,QAAQ,EAAE;QACR,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC;YAChB,EAAE,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;SAC5B,CAAC;KACH;CACF,CAAA;AA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,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;gBAE7B,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YAC/B,CAAC;YAAC,OAAO,GAAQ,EAAE,CAAC;gBAClB,UAAU,CAAC,GAAG,CAAC,CAAA;YACjB,CAAC;QACH,CAAC;QACD,OAAO,EAAE,YAAY;KACtB,CAAC,CAAA;IAEF;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC;QACX,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE;YAC5B,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,EAAE,CAAA;YAC3B,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,EAAE,CAAA;YAErC,IAAI,CAAC;gBACH,MAAM,KAAK,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;gBAEhC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YAC/B,CAAC;YAAC,OAAO,GAAQ,EAAE,CAAC;gBAClB,UAAU,CAAC,GAAG,CAAC,CAAA;YACjB,CAAC;QACH,CAAC;QACD,OAAO,EAAE,YAAY;KACtB,CAAC,CAAA;AACJ,CAAC,CAAA"} |
@@ -1,5 +0,2 @@ | ||
| import type { Factory } from '../index.js'; | ||
| interface CreateFactory { | ||
| (): Factory; | ||
| } | ||
| import type { Node, Factory } from '../index.js'; | ||
| export interface ServerInit { | ||
@@ -17,4 +14,5 @@ port?: number; | ||
| host: string; | ||
| private readonly createFactory; | ||
| constructor(options: ServerInit | undefined, createFactory: CreateFactory); | ||
| private readonly ipfsd; | ||
| readonly nodes: Record<string, Node>; | ||
| constructor(options: ServerInit | undefined, factory: Factory); | ||
| /** | ||
@@ -30,4 +28,8 @@ * Start the server | ||
| }): Promise<void>; | ||
| /** | ||
| * Stop any nodes created by this server | ||
| */ | ||
| clean(): Promise<void>; | ||
| } | ||
| export default Server; | ||
| //# sourceMappingURL=server.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/endpoint/server.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAE1C,UAAU,aAAa;IACrB,IAAI,OAAO,CAAA;CACZ;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,cAAM,MAAM;IACV,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAY;IACpC,OAAO,CAAC,MAAM,CAAoB;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACnB,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAe;gBAEhC,OAAO,wBAAiD,EAAE,aAAa,EAAE,aAAa;IAQnG;;OAEG;IACG,KAAK,CAAE,IAAI,SAAY,GAAG,OAAO,CAAC,MAAM,CAAC;IAiB/C;;OAEG;IACG,IAAI,CAAE,OAAO,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAK1D;AAED,eAAe,MAAM,CAAA"} | ||
| {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/endpoint/server.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAEhD,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,cAAM,MAAM;IACV,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAY;IACpC,OAAO,CAAC,MAAM,CAAoB;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACnB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,SAAgB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;gBAE9B,OAAO,wBAAiD,EAAE,OAAO,EAAE,OAAO;IASvF;;OAEG;IACG,KAAK,CAAE,IAAI,SAAY,GAAG,OAAO,CAAC,MAAM,CAAC;IAiB/C;;OAEG;IACG,IAAI,CAAE,OAAO,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAQzD;;OAEG;IACG,KAAK,IAAK,OAAO,CAAC,IAAI,CAAC;CAS9B;AAED,eAAe,MAAM,CAAA"} |
@@ -11,4 +11,5 @@ import Hapi from '@hapi/hapi'; | ||
| host; | ||
| createFactory; | ||
| constructor(options = { port: 43134, host: 'localhost' }, createFactory) { | ||
| ipfsd; | ||
| nodes; | ||
| constructor(options = { port: 43134, host: 'localhost' }, factory) { | ||
| this.options = options; | ||
@@ -18,3 +19,4 @@ this.server = null; | ||
| this.host = this.options.host ?? 'localhost'; | ||
| this.createFactory = createFactory; | ||
| this.ipfsd = factory; | ||
| this.nodes = {}; | ||
| } | ||
@@ -33,3 +35,3 @@ /** | ||
| }); | ||
| routes(this.server, this.createFactory); | ||
| routes(this.server, this.ipfsd, this.nodes); | ||
| await this.server.start(); | ||
@@ -45,5 +47,17 @@ return this; | ||
| } | ||
| await this.clean(); | ||
| } | ||
| /** | ||
| * Stop any nodes created by this server | ||
| */ | ||
| async clean() { | ||
| await this.ipfsd.clean(); | ||
| // remove references to nodes | ||
| for (const key of Object.getOwnPropertyNames(this.nodes)) { | ||
| // eslint-disable-next-line @typescript-eslint/no-dynamic-delete | ||
| delete this.nodes[key]; | ||
| } | ||
| } | ||
| } | ||
| export default Server; | ||
| //# sourceMappingURL=server.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"server.js","sourceR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B,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;AAKtG;;GAEG;AACH,wBAAsB,UAAU,CAAE,OAAO,EAAE,WAAW,GAAG,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;AAMzF;;GAEG;AACH,eAAO,MAAM,YAAY,aAAc,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,mBAAkB,WAAW,GAAG,WAAW,qBAAyB,oBAAoB,KAAQ,MAa/J,CAAA"} |
@@ -146,6 +146,4 @@ /** | ||
| host: '127.0.0.1' | ||
| }, () => { | ||
| return createFactory(factoryOptions, factoryOverrides); | ||
| }); | ||
| }, createFactory(factoryOptions, factoryOverrides)); | ||
| }; | ||
| //# sourceMappingURL=index.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwHG;AAEH,OAAO,MAAM,MAAM,sBAAsB,CAAA;AACzC,OAAO,cAAc,MAAM,cAAc,CAAA;AAGzC,cAAc,iBAAiB,CAAA;AAsI/B,MAAM,UAAU,aAAa,CAAE,OAAqB,EAAE,SAAgC;IACpF,OAAO,IAAI,cAAc,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;AAC/C,CAAC;AAMD,MAAM,CAAC,KAAK,UAAU,UAAU,CAAE,OAAa;IAC7C,MAAM,CAAC,GAAG,IAAI,cAAc,EAAE,CAAA;IAC9B,OAAO,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;AACzB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAmC,EAAE,iBAA4C,EAAE,EAAE,mBAAyC,EAAE,EAAU,EAAE;IACvK,IAAI,IAAwB,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M,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;QAC3B,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;IACrB,CAAC;IAED,OAAO,IAAI,MAAM,CAAC;QAChB,IAAI;QACJ,IAAI,EAAE,WAAW;KAClB,EAAE,aAAa,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC,CAAA;AACrD,CAAC,CAAA"} |
+1
-1
| { | ||
| "name": "ipfsd-ctl", | ||
| "version": "14.0.6", | ||
| "version": "14.1.0", | ||
| "description": "Spawn IPFS Daemons, Kubo or...", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0 OR MIT", |
@@ -29,5 +29,3 @@ import boom from '@hapi/boom' | ||
| const nodes: Record<string, Node> = {} | ||
| export default (server: Server, createFactory: () => Factory | Promise<Factory>): void => { | ||
| export default (server: Server, ipfsd: Factory, nodes: Record<string, Node>): void => { | ||
| /** | ||
@@ -42,3 +40,2 @@ * Spawn a controller | ||
| try { | ||
| const ipfsd = await createFactory() | ||
| const id = nanoid() | ||
@@ -45,0 +42,0 @@ nodes[id] = await ipfsd.spawn({ |
| import Hapi from '@hapi/hapi' | ||
| import routes from './routes.js' | ||
| import type { Factory } from '../index.js' | ||
| import type { Node, Factory } from '../index.js' | ||
| interface CreateFactory { | ||
| (): Factory | ||
| } | ||
| export interface ServerInit { | ||
@@ -22,5 +18,6 @@ port?: number | ||
| public host: string | ||
| private readonly createFactory: CreateFactory | ||
| private readonly ipfsd: Factory | ||
| public readonly nodes: Record<string, Node> | ||
| constructor (options: ServerInit = { port: 43134, host: 'localhost' }, createFactory: CreateFactory) { | ||
| constructor (options: ServerInit = { port: 43134, host: 'localhost' }, factory: Factory) { | ||
| this.options = options | ||
@@ -30,3 +27,4 @@ this.server = null | ||
| this.host = this.options.host ?? 'localhost' | ||
| this.createFactory = createFactory | ||
| this.ipfsd = factory | ||
| this.nodes = {} | ||
| } | ||
@@ -47,3 +45,3 @@ | ||
| routes(this.server, this.createFactory) | ||
| routes(this.server, this.ipfsd, this.nodes) | ||
@@ -62,5 +60,20 @@ await this.server.start() | ||
| } | ||
| await this.clean() | ||
| } | ||
| /** | ||
| * Stop any nodes created by this server | ||
| */ | ||
| async clean (): Promise<void> { | ||
| await this.ipfsd.clean() | ||
| // remove references to nodes | ||
| for (const key of Object.getOwnPropertyNames(this.nodes)) { | ||
| // eslint-disable-next-line @typescript-eslint/no-dynamic-delete | ||
| delete this.nodes[key] | ||
| } | ||
| } | ||
| } | ||
| export default Server |
+1
-3
@@ -289,5 +289,3 @@ /** | ||
| host: '127.0.0.1' | ||
| }, () => { | ||
| return createFactory(factoryOptions, factoryOverrides) | ||
| }) | ||
| }, createFactory(factoryOptions, factoryOverrides)) | ||
| } |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
124422
0.76%2566
0.75%