hypercore-fetch 9.8.0 → 9.9.1
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.
- package/index.js +1 -0
- package/package.json +3 -3
- package/test.js +10 -3
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hypercore-fetch",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.9.1",
|
|
4
4
|
"description": "Implementation of Fetch that uses the Dat SDK for loading p2p content",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"homepage": "https://github.com/RangerMauve/hypercore-fetch#readme",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"event-iterator": "^2.0.0",
|
|
27
|
-
"hyperdrive": "^11.
|
|
27
|
+
"hyperdrive": "^11.8.1",
|
|
28
28
|
"make-fetch": "^3.1.1",
|
|
29
29
|
"mime": "^3.0.0",
|
|
30
30
|
"range-parser": "^1.2.1",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@rangermauve/fetch-event-source": "^1.0.3",
|
|
35
|
-
"hyper-sdk": "^4.
|
|
35
|
+
"hyper-sdk": "^4.4.0",
|
|
36
36
|
"standard": "^17.0.0",
|
|
37
37
|
"tape": "^5.2.2"
|
|
38
38
|
}
|
package/test.js
CHANGED
|
@@ -7,6 +7,7 @@ import { once } from 'events'
|
|
|
7
7
|
import makeHyperFetch from './index.js'
|
|
8
8
|
|
|
9
9
|
const SAMPLE_CONTENT = 'Hello World'
|
|
10
|
+
const DNS_DOMAIN = 'blog.mauve.moe'
|
|
10
11
|
let count = 0
|
|
11
12
|
function next () {
|
|
12
13
|
return count++
|
|
@@ -498,11 +499,17 @@ test('EventSource extension messages', async (t) => {
|
|
|
498
499
|
})
|
|
499
500
|
|
|
500
501
|
test('Resolve DNS', async (t) => {
|
|
501
|
-
const loadResponse = await fetch(
|
|
502
|
+
const loadResponse = await fetch(`hyper://${DNS_DOMAIN}/?noResolve`)
|
|
502
503
|
|
|
503
504
|
const entries = await loadResponse.json()
|
|
504
505
|
|
|
505
506
|
t.ok(entries.length, 'Loaded contents with some files present')
|
|
507
|
+
|
|
508
|
+
const rawLink = loadResponse.headers.get('Link').match(/<(.+)>/)[1]
|
|
509
|
+
const loadRawURLResponse = await fetch(rawLink + '?noResolve')
|
|
510
|
+
|
|
511
|
+
const rawLinkEntries = await loadRawURLResponse.json()
|
|
512
|
+
t.deepEqual(rawLinkEntries, entries, 'Raw link resolves to same content as DNS domain.')
|
|
506
513
|
})
|
|
507
514
|
|
|
508
515
|
test('Doing a `GET` on an invalid domain/public key should cause an error', async (t) => {
|
|
@@ -614,7 +621,7 @@ test('Handle empty string pathname', async (t) => {
|
|
|
614
621
|
})
|
|
615
622
|
|
|
616
623
|
test('Return status 403 Forbidden on attempt to modify read-only hyperdrive', async (t) => {
|
|
617
|
-
const readOnlyURL =
|
|
624
|
+
const readOnlyURL = `hyper://${DNS_DOMAIN}/new-file.txt`
|
|
618
625
|
const putResponse = await fetch(readOnlyURL, { method: 'PUT', body: SAMPLE_CONTENT })
|
|
619
626
|
if (putResponse.ok) {
|
|
620
627
|
throw new Error('PUT file to read-only drive should have failed')
|
|
@@ -633,7 +640,7 @@ test('Return status 403 Forbidden on attempt to modify read-only hyperdrive', as
|
|
|
633
640
|
test('Check hyperdrive writability', async (t) => {
|
|
634
641
|
const created = await nextURL(t)
|
|
635
642
|
|
|
636
|
-
const readOnlyRootDirectory =
|
|
643
|
+
const readOnlyRootDirectory = `hyper://${DNS_DOMAIN}/?noResolve`
|
|
637
644
|
const readOnlyHeadResponse = await fetch(readOnlyRootDirectory, { method: 'HEAD' })
|
|
638
645
|
await checkResponse(readOnlyHeadResponse, t, 'Able to load HEAD')
|
|
639
646
|
const readOnlyHeadersAllow = readOnlyHeadResponse.headers.get('Allow')
|