diff --git a/SPEC/NAME.md b/SPEC/NAME.md index ecb7a041..e6705953 100644 --- a/SPEC/NAME.md +++ b/SPEC/NAME.md @@ -25,9 +25,12 @@ Although not listed in the documentation, all the following APIs that actually r lifetime: // string - Time duration of the record. Default: 24h ttl: // string - Time duration this record should be cached key: // string - Name of the key to be used. Default: 'self' + allowOffline: // bool - When offline, save the IPNS record to the the local datastore without broadcasting to the network instead of simply failing. } ``` +Note: `allowOffline` option is not yet implemented in js-ipfs. See tracking issue [ipfs/js-ipfs#1997](https://github.com/ipfs/js-ipfs/issues/1997). + **Returns** | Type | Description | diff --git a/src/miscellaneous/resolve.js b/src/miscellaneous/resolve.js index 9971e681..b52f4f7d 100644 --- a/src/miscellaneous/resolve.js +++ b/src/miscellaneous/resolve.js @@ -106,8 +106,8 @@ module.exports = (createCommon, options) => { const [{ path }] = await ipfs.add(Buffer.from('should resolve a record recursive === true')) const { id: keyId } = await ipfs.key.gen('key-name', { type: 'rsa', size: 2048 }) - await ipfs.name.publish(path, { 'allow-offline': true }) - await ipfs.name.publish(`/ipns/${nodeId}`, { 'allow-offline': true, key: 'key-name', resolve: false }) + await ipfs.name.publish(path, { allowOffline: true }) + await ipfs.name.publish(`/ipns/${nodeId}`, { allowOffline: true, key: 'key-name', resolve: false }) return expect(await ipfs.resolve(`/ipns/${keyId}`, { recursive: true })) .to.eq(`/ipfs/${path}`) diff --git a/src/name/publish.js b/src/name/publish.js index a851aec2..40e7f21e 100644 --- a/src/name/publish.js +++ b/src/name/publish.js @@ -43,7 +43,7 @@ module.exports = (createCommon, options) => { const value = fixture.cid - ipfs.name.publish(value, { 'allow-offline': true }, (err, res) => { + ipfs.name.publish(value, { allowOffline: true }, (err, res) => { expect(err).to.not.exist() expect(res).to.exist() expect(res.name).to.equal(nodeId) @@ -55,7 +55,7 @@ module.exports = (createCommon, options) => { it('should publish correctly with the lifetime option and resolve', async () => { const [{ path }] = await ipfs.add(Buffer.from('should publish correctly with the lifetime option and resolve')) - await ipfs.name.publish(path, { 'allow-offline': true, resolve: false, lifetime: '2h' }) + await ipfs.name.publish(path, { allowOffline: true, resolve: false, lifetime: '2h' }) return expect(await ipfs.name.resolve(`/ipns/${nodeId}`)).to.eq(`/ipfs/${path}`) }) @@ -70,7 +70,7 @@ module.exports = (createCommon, options) => { lifetime: '1m', ttl: '10s', key: 'self', - 'allow-offline': true + allowOffline: true } ipfs.name.publish(value, options, (err, res) => { @@ -92,7 +92,7 @@ module.exports = (createCommon, options) => { lifetime: '24h', ttl: '10s', key: keyName, - 'allow-offline': true + allowOffline: true } ipfs.key.gen(keyName, { type: 'rsa', size: 2048 }, function (err, key) { diff --git a/src/name/resolve.js b/src/name/resolve.js index be0e0d7a..5537e83e 100644 --- a/src/name/resolve.js +++ b/src/name/resolve.js @@ -39,8 +39,8 @@ module.exports = (createCommon, options) => { const { id: keyId } = await ipfs.key.gen('key-name-default', { type: 'rsa', size: 2048 }) - await ipfs.name.publish(path, { 'allow-offline': true }) - await ipfs.name.publish(`/ipns/${nodeId}`, { 'allow-offline': true, key: 'key-name-default' }) + await ipfs.name.publish(path, { allowOffline: true }) + await ipfs.name.publish(`/ipns/${nodeId}`, { allowOffline: true, key: 'key-name-default' }) return expect(await ipfs.name.resolve(`/ipns/${keyId}`)) .to.eq(`/ipfs/${path}`) @@ -50,7 +50,7 @@ module.exports = (createCommon, options) => { this.timeout(20 * 1000) const [{ path }] = await ipfs.add(Buffer.from('should resolve a record from cidv1b32')) const { id: peerId } = await ipfs.id() - await ipfs.name.publish(path, { 'allow-offline': true }) + await ipfs.name.publish(path, { allowOffline: true }) // Represent Peer ID as CIDv1 Base32 // https://github.com/libp2p/specs/blob/master/RFC/0001-text-peerid-cid.md @@ -62,7 +62,7 @@ module.exports = (createCommon, options) => { it('should resolve a record recursive === false', async () => { const [{ path }] = await ipfs.add(Buffer.from('should resolve a record recursive === false')) - await ipfs.name.publish(path, { 'allow-offline': true }) + await ipfs.name.publish(path, { allowOffline: true }) return expect(await ipfs.name.resolve(`/ipns/${nodeId}`, { recursive: false })) .to.eq(`/ipfs/${path}`) }) @@ -74,8 +74,8 @@ module.exports = (createCommon, options) => { const { id: keyId } = await ipfs.key.gen('key-name', { type: 'rsa', size: 2048 }) - await ipfs.name.publish(path, { 'allow-offline': true }) - await ipfs.name.publish(`/ipns/${nodeId}`, { 'allow-offline': true, key: 'key-name' }) + await ipfs.name.publish(path, { allowOffline: true }) + await ipfs.name.publish(`/ipns/${nodeId}`, { allowOffline: true, key: 'key-name' }) return expect(await ipfs.name.resolve(`/ipns/${keyId}`, { recursive: true })) .to.eq(`/ipfs/${path}`) @@ -88,8 +88,8 @@ module.exports = (createCommon, options) => { const { id: keyId } = await ipfs.key.gen('key-name-remainder-default', { type: 'rsa', size: 2048 }) - await ipfs.name.publish(path, { 'allow-offline': true }) - await ipfs.name.publish(`/ipns/${nodeId}`, { 'allow-offline': true, key: 'key-name-remainder-default' }) + await ipfs.name.publish(path, { allowOffline: true }) + await ipfs.name.publish(`/ipns/${nodeId}`, { allowOffline: true, key: 'key-name-remainder-default' }) return expect(await ipfs.name.resolve(`/ipns/${keyId}/remainder/file.txt`)) .to.eq(`/ipfs/${path}/remainder/file.txt`) @@ -97,7 +97,7 @@ module.exports = (createCommon, options) => { it('should resolve a record recursive === false with remainder', async () => { const [{ path }] = await ipfs.add(Buffer.from('should resolve a record recursive = false with remainder')) - await ipfs.name.publish(path, { 'allow-offline': true }) + await ipfs.name.publish(path, { allowOffline: true }) return expect(await ipfs.name.resolve(`/ipns/${nodeId}/remainder/file.txt`, { recursive: false })) .to.eq(`/ipfs/${path}/remainder/file.txt`) }) @@ -109,8 +109,8 @@ module.exports = (createCommon, options) => { const { id: keyId } = await ipfs.key.gen('key-name-remainder', { type: 'rsa', size: 2048 }) - await ipfs.name.publish(path, { 'allow-offline': true }) - await ipfs.name.publish(`/ipns/${nodeId}`, { 'allow-offline': true, key: 'key-name-remainder' }) + await ipfs.name.publish(path, { allowOffline: true }) + await ipfs.name.publish(`/ipns/${nodeId}`, { allowOffline: true, key: 'key-name-remainder' }) return expect(await ipfs.name.resolve(`/ipns/${keyId}/remainder/file.txt`, { recursive: true })) .to.eq(`/ipfs/${path}/remainder/file.txt`) @@ -120,7 +120,7 @@ module.exports = (createCommon, options) => { const publishOptions = { lifetime: '100ms', ttl: '10s', - 'allow-offline': true + allowOffline: true } // we add new data instead of re-using fixture to make sure lifetime handling doesn't break