Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* eslint-disable no-console */
'use strict'
const ky = require('ky-universal').default
const errcode = require('err-code')
const debug = require('debug')
const { Record } = require('libp2p-record')
const { keyToBase32 } = require('./utils')
const log = debug('ipfs:ipns:workers-datastore')
log.error = debug('ipfs:ipns:workers-datastore:error')
// Workers datastore aims to mimic the same encoding as routing when storing records
// to the local datastore
class WorkersDataStore {
/**
* Put a key value pair into the datastore
* @param {Buffer} key identifier of the value.
* @param {Buffer} value value to be stored.
* @returns {Promise}
'use strict'
const ipns = require('ipns')
const ky = require('ky-universal').default
const { Record } = require('libp2p-record')
const dnsSocket = require('dns-socket')
const dnsPacket = require('dns-packet')
const Cid = require('cids')
const errcode = require('err-code')
const debug = require('debug')
const log = debug('ipfs:ipns:workers-api-datastore')
log.error = debug('ipfs:ipns:workers-api:error')
// DNS datastore aims to mimic the same encoding as routing when storing records
// to the local datastore
class DNSDataStore {
constructor (repo) {
this._repo = repo
}
/* eslint-disable no-console */
'use strict'
const ky = require('ky-universal').default
const errcode = require('err-code')
const debug = require('debug')
const { dohBinary, keyToBase32 } = require('./utils')
const log = debug('ipfs:ipns:mdns-datastore')
log.error = debug('ipfs:ipns:mdns-datastore:error')
// DNS datastore aims to mimic the same encoding as routing when storing records
// to the local datastore
class MDNSDataStore {
constructor (options) {
this.options = options
}
/**
* Put a key value pair into the datastore
* @param {Buffer} key identifier of the value.
'use strict'
/* eslint-env browser */
const ky = require('ky-universal').default
const { isBrowser, isWebWorker } = require('ipfs-utils/src/env')
const toUri = require('multiaddr-to-uri')
const errorHandler = require('./error-handler')
const mergeOptions = require('merge-options').bind({ ignoreUndefined: true })
const parseDuration = require('parse-duration')
// Set default configuration and call create function with them
module.exports = create => config => {
config = config || {}
if (typeof config === 'string') {
config = { apiAddr: config }
} else if (config.constructor && config.constructor.isMultiaddr) {
config = { apiAddr: config }
} else {
config = { ...config }
/* eslint-disable no-console */
'use strict'
const ipns = require('ipns')
const { Record } = require('libp2p-record')
const dnsPacket = require('dns-packet')
const Cid = require('cids')
const errcode = require('err-code')
const debug = require('debug')
const ky = require('ky-universal').default
const log = debug('ipfs:ipns:doh')
log.error = debug('ipfs:ipns:doh:error')
async function dohBinary (url, domain, key) {
const start = Date.now()
const keyStr = keyToBase32(key)
const buf = dnsPacket.encode({
type: 'query',
questions: [{
type: 'TXT',
name: `${keyStr}.${domain}`
}]
})
const result = await ky
'use strict'
const kyDefault = require('ky-universal').default
const toIterable = require('./lib/stream-to-iterable')
module.exports = (config) => {
const add = require('./add')(config)
return async function * addFromURL (url, options) {
options = options || {}
const { body } = await kyDefault.get(url)
const input = {
path: decodeURIComponent(new URL(url).pathname.split('/').pop() || ''),
content: toIterable(body)
}
yield * add(input, options)
'use strict'
const multiaddr = require('multiaddr')
const merge = require('merge-options').bind({ ignoreUndefined: true })
const debug = require('debug')
const kyOriginal = require('ky-universal').default
const ky = kyOriginal.extend({ timeout: false })
const daemonLog = {
info: debug('ipfsd-ctl:client:stdout'),
err: debug('ipfsd-ctl:client:stderr')
}
/** @typedef {import("./index").ControllerOptions} ControllerOptions */
/**
* Controller for remote nodes
* @class
*/
class Client {
/**
* @constructor