javascript-solid-server 0.0.75 → 0.0.77
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/.claude/settings.local.json +27 -1
- package/README.md +38 -2
- package/bin/jss.js +3 -0
- package/package.json +2 -1
- package/src/auth/middleware.js +6 -3
- package/src/config.js +5 -0
- package/src/handlers/resource.js +104 -6
- package/src/idp/accounts.js +133 -0
- package/src/idp/index.js +65 -0
- package/src/idp/interactions.js +118 -9
- package/src/idp/passkey.js +311 -0
- package/src/idp/views.js +312 -1
- package/src/ldp/headers.js +3 -2
- package/src/mashlib/index.js +107 -0
- package/src/server.js +37 -1
- package/src/storage/filesystem.js +22 -0
- package/test/range.test.js +145 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Range Request Tests
|
|
3
|
+
*
|
|
4
|
+
* Tests HTTP Range header support for partial content delivery.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { describe, it, before, after } from 'node:test';
|
|
8
|
+
import assert from 'node:assert';
|
|
9
|
+
import {
|
|
10
|
+
startTestServer,
|
|
11
|
+
stopTestServer,
|
|
12
|
+
request,
|
|
13
|
+
createTestPod,
|
|
14
|
+
assertStatus
|
|
15
|
+
} from './helpers.js';
|
|
16
|
+
|
|
17
|
+
describe('Range Requests', () => {
|
|
18
|
+
const testContent = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; // 36 bytes
|
|
19
|
+
|
|
20
|
+
before(async () => {
|
|
21
|
+
await startTestServer();
|
|
22
|
+
await createTestPod('rangetest');
|
|
23
|
+
|
|
24
|
+
// Create a test file with known content
|
|
25
|
+
await request('/rangetest/public/test.txt', {
|
|
26
|
+
method: 'PUT',
|
|
27
|
+
headers: { 'Content-Type': 'text/plain' },
|
|
28
|
+
body: testContent,
|
|
29
|
+
auth: 'rangetest'
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
after(async () => {
|
|
34
|
+
await stopTestServer();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe('Accept-Ranges header', () => {
|
|
38
|
+
it('should include Accept-Ranges: bytes for files', async () => {
|
|
39
|
+
const res = await request('/rangetest/public/test.txt');
|
|
40
|
+
assertStatus(res, 200);
|
|
41
|
+
assert.strictEqual(res.headers.get('Accept-Ranges'), 'bytes');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('should include Accept-Ranges: none for containers', async () => {
|
|
45
|
+
const res = await request('/rangetest/public/');
|
|
46
|
+
assertStatus(res, 200);
|
|
47
|
+
assert.strictEqual(res.headers.get('Accept-Ranges'), 'none');
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe('Range header parsing', () => {
|
|
52
|
+
it('should return 206 for valid range bytes=0-9', async () => {
|
|
53
|
+
const res = await request('/rangetest/public/test.txt', {
|
|
54
|
+
headers: { 'Range': 'bytes=0-9' }
|
|
55
|
+
});
|
|
56
|
+
assertStatus(res, 206);
|
|
57
|
+
|
|
58
|
+
const body = await res.text();
|
|
59
|
+
assert.strictEqual(body, 'ABCDEFGHIJ');
|
|
60
|
+
assert.strictEqual(res.headers.get('Content-Range'), 'bytes 0-9/36');
|
|
61
|
+
assert.strictEqual(res.headers.get('Content-Length'), '10');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('should return 206 for open-ended range bytes=30-', async () => {
|
|
65
|
+
const res = await request('/rangetest/public/test.txt', {
|
|
66
|
+
headers: { 'Range': 'bytes=30-' }
|
|
67
|
+
});
|
|
68
|
+
assertStatus(res, 206);
|
|
69
|
+
|
|
70
|
+
const body = await res.text();
|
|
71
|
+
assert.strictEqual(body, '456789');
|
|
72
|
+
assert.strictEqual(res.headers.get('Content-Range'), 'bytes 30-35/36');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('should return 206 for suffix range bytes=-6', async () => {
|
|
76
|
+
const res = await request('/rangetest/public/test.txt', {
|
|
77
|
+
headers: { 'Range': 'bytes=-6' }
|
|
78
|
+
});
|
|
79
|
+
assertStatus(res, 206);
|
|
80
|
+
|
|
81
|
+
const body = await res.text();
|
|
82
|
+
assert.strictEqual(body, '456789');
|
|
83
|
+
assert.strictEqual(res.headers.get('Content-Range'), 'bytes 30-35/36');
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('should clamp end to file size for range exceeding file', async () => {
|
|
87
|
+
const res = await request('/rangetest/public/test.txt', {
|
|
88
|
+
headers: { 'Range': 'bytes=30-1000' }
|
|
89
|
+
});
|
|
90
|
+
assertStatus(res, 206);
|
|
91
|
+
|
|
92
|
+
const body = await res.text();
|
|
93
|
+
assert.strictEqual(body, '456789');
|
|
94
|
+
assert.strictEqual(res.headers.get('Content-Range'), 'bytes 30-35/36');
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
describe('Multi-range requests', () => {
|
|
99
|
+
it('should ignore multi-range and return 200 with full content', async () => {
|
|
100
|
+
const res = await request('/rangetest/public/test.txt', {
|
|
101
|
+
headers: { 'Range': 'bytes=0-5,10-15' }
|
|
102
|
+
});
|
|
103
|
+
// Multi-range is not supported, should fall back to 200
|
|
104
|
+
assertStatus(res, 200);
|
|
105
|
+
|
|
106
|
+
const body = await res.text();
|
|
107
|
+
assert.strictEqual(body, testContent);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
describe('Invalid ranges', () => {
|
|
112
|
+
it('should return 200 for invalid range format', async () => {
|
|
113
|
+
const res = await request('/rangetest/public/test.txt', {
|
|
114
|
+
headers: { 'Range': 'invalid' }
|
|
115
|
+
});
|
|
116
|
+
// Invalid format, ignore Range header
|
|
117
|
+
assertStatus(res, 200);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('should return 200 for non-bytes range unit', async () => {
|
|
121
|
+
const res = await request('/rangetest/public/test.txt', {
|
|
122
|
+
headers: { 'Range': 'chars=0-10' }
|
|
123
|
+
});
|
|
124
|
+
assertStatus(res, 200);
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
describe('RDF resources', () => {
|
|
129
|
+
it('should ignore Range header for RDF resources', async () => {
|
|
130
|
+
// Create an RDF resource
|
|
131
|
+
await request('/rangetest/public/data.jsonld', {
|
|
132
|
+
method: 'PUT',
|
|
133
|
+
headers: { 'Content-Type': 'application/ld+json' },
|
|
134
|
+
body: JSON.stringify({ '@id': '#test', 'http://example.org/name': 'Test' }),
|
|
135
|
+
auth: 'rangetest'
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
const res = await request('/rangetest/public/data.jsonld', {
|
|
139
|
+
headers: { 'Range': 'bytes=0-10' }
|
|
140
|
+
});
|
|
141
|
+
// RDF resources don't support range requests
|
|
142
|
+
assertStatus(res, 200);
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
});
|