hypercore-fetch 9.0.7 → 9.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.js +5 -5
  2. package/package.json +2 -2
  3. package/test.js +20 -0
package/index.js CHANGED
@@ -280,7 +280,7 @@ export default async function makeHyperFetch ({
280
280
  try {
281
281
  const drive = await getDriveFromKey(key, true)
282
282
 
283
- return { body: drive.core.url }
283
+ return { body: drive.url }
284
284
  } catch (e) {
285
285
  if (e.message === ERROR_KEY_NOT_CREATED) {
286
286
  return {
@@ -305,7 +305,7 @@ export default async function makeHyperFetch ({
305
305
 
306
306
  const drive = await getDriveFromKey(key, false)
307
307
 
308
- return { body: drive.core.url }
308
+ return { body: drive.url }
309
309
  })
310
310
 
311
311
  router.put('hyper://*/**', async function putFiles (request) {
@@ -384,7 +384,7 @@ export default async function makeHyperFetch ({
384
384
  const isDirectory = pathname.endsWith('/')
385
385
 
386
386
  const drive = await getDrive(`hyper://${hostname}`)
387
- const fullURL = new URL(pathname, drive.core.url).href
387
+ const fullURL = new URL(pathname, drive.url).href
388
388
 
389
389
  const resHeaders = {
390
390
  ETag: `${drive.version}`,
@@ -491,7 +491,7 @@ export default async function makeHyperFetch ({
491
491
  const isDirectory = pathname.endsWith('/')
492
492
 
493
493
  const drive = await getDrive(`hyper://${hostname}`)
494
- const fullURL = new URL(pathname, drive.core.url).href
494
+ const fullURL = new URL(pathname, drive.url).href
495
495
 
496
496
  if (isDirectory) {
497
497
  const resHeaders = {
@@ -556,7 +556,7 @@ async function serveFile (headers, drive, pathname) {
556
556
  const isRanged = headers.get('Range') || ''
557
557
  const contentType = getMimeType(pathname)
558
558
 
559
- const fullURL = new URL(pathname, drive.core.url).href
559
+ const fullURL = new URL(pathname, drive.url).href
560
560
 
561
561
  const entry = await drive.entry(pathname)
562
562
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore-fetch",
3
- "version": "9.0.7",
3
+ "version": "9.0.8",
4
4
  "description": "Implementation of Fetch that uses the Dat SDK for loading p2p content",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "devDependencies": {
34
34
  "@rangermauve/fetch-event-source": "^1.0.3",
35
- "hyper-sdk": "^4.1.1",
35
+ "hyper-sdk": "^4.2.3",
36
36
  "standard": "^17.0.0",
37
37
  "tape": "^5.2.2"
38
38
  }
package/test.js CHANGED
@@ -446,6 +446,26 @@ test('EventSource extension messages', async (t) => {
446
446
  t.ok(lastEventId, 'Event contained peer ID')
447
447
  })
448
448
 
449
+ test('Resolve DNS', async (t) => {
450
+ const loadResponse = await fetch('hyper://example2.mauve.moe/')
451
+
452
+ const entries = await loadResponse.json()
453
+
454
+ t.pass('Loaded contents and ')
455
+ })
456
+
457
+ test('Error on invalid hostname', async (t) => {
458
+ const loadResponse = await fetch('hyper://example/')
459
+
460
+ console.log(loadResponse.status)
461
+
462
+ if(loadResponse.ok) {
463
+ throw new Error('Loading without DNS or a public key should have failed')
464
+ } else {
465
+ t.pass("Invalid names led to an error")
466
+ }
467
+ })
468
+
449
469
  async function checkResponse (response, t, successMessage = 'Response OK') {
450
470
  if (!response.ok) {
451
471
  const message = await response.text()