core-3nweb-client-lib 0.20.7 → 0.22.0
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/build/api-defs/common-caps.d.ts +0 -1
- package/build/api-defs/files.d.ts +8 -7
- package/build/api-defs/startup.d.ts +0 -1
- package/build/core/asmail/inbox/attachments/fs.d.ts +2 -2
- package/build/core/asmail/inbox/attachments/fs.js +3 -2
- package/build/core/asmail/msg/common.d.ts +2 -2
- package/build/core/asmail/msg/common.js +3 -2
- package/build/core/asmail/msg/opener.d.ts +2 -2
- package/build/core/asmail/msg/opener.js +3 -2
- package/build/core/asmail/msg/packer.d.ts +2 -2
- package/build/core/asmail/msg/packer.js +7 -6
- package/build/core/index.d.ts +3 -3
- package/build/core/index.js +24 -31
- package/build/core/storage/index.js +2 -2
- package/build/core/storage/local/obj-files.js +8 -5
- package/build/core/storage/local/obj-status.js +4 -3
- package/build/core/storage/synced/obj-status.js +4 -3
- package/build/core-ipc/startup-caps.js +0 -3
- package/build/ipc-via-protobuf/bytes.js +1 -1
- package/build/lib-client/3nstorage/xsp-fs/attrs.d.ts +28 -0
- package/build/lib-client/3nstorage/xsp-fs/attrs.js +337 -0
- package/build/lib-client/3nstorage/xsp-fs/common.d.ts +1 -1
- package/build/lib-client/3nstorage/xsp-fs/common.js +3 -2
- package/build/lib-client/3nstorage/xsp-fs/file-node.d.ts +31 -18
- package/build/lib-client/3nstorage/xsp-fs/file-node.js +130 -118
- package/build/lib-client/3nstorage/xsp-fs/file.d.ts +0 -1
- package/build/lib-client/3nstorage/xsp-fs/file.js +14 -49
- package/build/lib-client/3nstorage/xsp-fs/folder-node-serialization.d.ts +1 -1
- package/build/lib-client/3nstorage/xsp-fs/folder-node-serialization.js +95 -91
- package/build/lib-client/3nstorage/xsp-fs/folder-node.d.ts +19 -24
- package/build/lib-client/3nstorage/xsp-fs/folder-node.js +133 -190
- package/build/lib-client/3nstorage/xsp-fs/fs.d.ts +3 -4
- package/build/lib-client/3nstorage/xsp-fs/fs.js +18 -21
- package/build/lib-client/3nstorage/xsp-fs/link-node.d.ts +13 -8
- package/build/lib-client/3nstorage/xsp-fs/link-node.js +46 -38
- package/build/lib-client/3nstorage/xsp-fs/node-in-fs.d.ts +17 -35
- package/build/lib-client/3nstorage/xsp-fs/node-in-fs.js +34 -127
- package/build/lib-client/3nstorage/xsp-fs/node-persistence.d.ts +57 -0
- package/build/lib-client/3nstorage/xsp-fs/node-persistence.js +182 -0
- package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v1.d.ts +3 -0
- package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v1.js +87 -0
- package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v2.d.ts +6 -0
- package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v2.js +1022 -0
- package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
- package/build/lib-client/cryptor/cryptor.wasm +0 -0
- package/build/lib-client/local-files/device-fs.js +7 -3
- package/build/lib-client/objs-on-disk/file-writing-proc.js +3 -2
- package/build/lib-client/objs-on-disk/obj-on-disk.js +8 -7
- package/build/lib-common/big-endian.d.ts +0 -24
- package/build/lib-common/big-endian.js +16 -78
- package/build/lib-common/exceptions/file.js +5 -1
- package/build/lib-common/obj-streaming/sink-utils.d.ts +0 -4
- package/build/lib-common/obj-streaming/sink-utils.js +4 -70
- package/build/lib-common/objs-on-disk/file-layout.js +2 -1
- package/build/lib-common/objs-on-disk/obj-file.js +2 -2
- package/build/lib-common/objs-on-disk/utils.js +2 -1
- package/build/lib-common/objs-on-disk/v1-obj-file-format.js +2 -1
- package/build/lib-index.d.ts +1 -0
- package/build/lib-index.js +3 -0
- package/package.json +2 -2
- package/build/lib-client/files/file-attrs.d.ts +0 -76
- package/build/lib-client/files/file-attrs.js +0 -549
- package/build/lib-client/files/file-layout.d.ts +0 -56
- package/build/lib-client/files/file-layout.js +0 -456
- package/build/lib-client/files/file-sink.d.ts +0 -33
- package/build/lib-client/files/file-sink.js +0 -173
- package/build/lib-client/files/file-source.d.ts +0 -19
- package/build/lib-client/files/file-source.js +0 -115
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2015 - 2018, 2020 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2015 - 2018, 2020, 2022 3NSoft Inc.
|
|
4
4
|
|
|
5
5
|
This program is free software: you can redistribute it and/or modify it under
|
|
6
6
|
the terms of the GNU General Public License as published by the Free Software
|
|
@@ -28,7 +28,6 @@ const buffer_utils_2 = require("../../lib-common/buffer-utils");
|
|
|
28
28
|
const pipe_1 = require("../../lib-common/byte-streaming/pipe");
|
|
29
29
|
const dev_file_src_1 = require("./dev-file-src");
|
|
30
30
|
const dev_file_sink_1 = require("./dev-file-sink");
|
|
31
|
-
const file_source_1 = require("../files/file-source");
|
|
32
31
|
/**
|
|
33
32
|
* This recursively creates folder, or ensures its presence with non-exclusive
|
|
34
33
|
* parameter.
|
|
@@ -411,7 +410,12 @@ class DeviceFS {
|
|
|
411
410
|
throw file_1.maskPathInExc(this.root.length, e);
|
|
412
411
|
});
|
|
413
412
|
const byteSrc = dev_file_src_1.DevFileByteSource.make(pathStr, this.root.length, stats);
|
|
414
|
-
return
|
|
413
|
+
return {
|
|
414
|
+
getPosition: byteSrc.getPosition,
|
|
415
|
+
getSize: async () => (await byteSrc.getSize()).size,
|
|
416
|
+
read: byteSrc.read,
|
|
417
|
+
seek: byteSrc.seek
|
|
418
|
+
};
|
|
415
419
|
}
|
|
416
420
|
async writeBytes(path, bytes, flags = WRITE_NONEXCL_FLAGS) {
|
|
417
421
|
const pathSections = splitPathIntoParts(path);
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
See the GNU General Public License for more details.
|
|
14
14
|
|
|
15
15
|
You should have received a copy of the GNU General Public License along with
|
|
16
|
-
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
17
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
19
|
exports.FileWritingProc = void 0;
|
|
19
20
|
const processes_1 = require("../../lib-common/processes");
|
|
@@ -126,9 +127,9 @@ function combineSegsFrom(segs) {
|
|
|
126
127
|
}
|
|
127
128
|
else if (chunkEnd < sOfs) {
|
|
128
129
|
chunks.push({ ofs: chunkStart, bytes: buffer_utils_1.joinByteArrs(chunkSegs) });
|
|
130
|
+
chunkSegs = [seg];
|
|
129
131
|
chunkStart = sOfs;
|
|
130
132
|
chunkEnd = chunkStart + seg.length;
|
|
131
|
-
chunkSegs.push(seg);
|
|
132
133
|
}
|
|
133
134
|
else {
|
|
134
135
|
throw new Error(`Got missorted segment`);
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
See the GNU General Public License for more details.
|
|
14
14
|
|
|
15
15
|
You should have received a copy of the GNU General Public License along with
|
|
16
|
-
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
17
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
19
|
exports.ObjOnDisk = void 0;
|
|
19
20
|
const buffer_utils_1 = require("../../lib-common/buffer-utils");
|
|
@@ -60,8 +61,10 @@ class ObjOnDisk {
|
|
|
60
61
|
const objFile = await obj_file_1.ObjVersionFile.createNew(path);
|
|
61
62
|
const obj = new ObjOnDisk(objId, version, objFile, downloader, false, getBase);
|
|
62
63
|
const write$ = file_writing_proc_1.FileWritingProc.makeFor(objFile, encSub)
|
|
63
|
-
.pipe(operators_1.tap(
|
|
64
|
-
|
|
64
|
+
.pipe(operators_1.tap({
|
|
65
|
+
complete: () => {
|
|
66
|
+
obj.readable = true;
|
|
67
|
+
}
|
|
65
68
|
}), utils_for_observables_1.flatTap(undefined, () => objFile.removeFile()), utils_for_observables_1.allowOnlySingleStart());
|
|
66
69
|
return { obj, write$ };
|
|
67
70
|
}
|
|
@@ -104,12 +107,10 @@ class ObjOnDisk {
|
|
|
104
107
|
for (const chunk of segsLocations) {
|
|
105
108
|
if ((chunk.type === 'new-on-disk')
|
|
106
109
|
|| (chunk.type === 'base-on-disk')) {
|
|
107
|
-
|
|
108
|
-
bytesAndChunks.push(...chunkBytes);
|
|
110
|
+
bytesAndChunks.push(...(await this.objFile.readSegs(chunk.thisVerOfs, chunk.len)));
|
|
109
111
|
}
|
|
110
112
|
else if (chunk.type === 'base') {
|
|
111
|
-
|
|
112
|
-
bytesAndChunks.push(...baseBytesAndChunks);
|
|
113
|
+
bytesAndChunks.push(...(await this.readBaseBytesFromOtherFilesOnDisk(chunk)));
|
|
113
114
|
}
|
|
114
115
|
else {
|
|
115
116
|
bytesAndChunks.push(chunk);
|
|
@@ -35,18 +35,6 @@ export declare function packUintTo4Bytes(u: number, b: Buffer, i: number): void;
|
|
|
35
35
|
* in 4 bytes of x, starting at index i.
|
|
36
36
|
*/
|
|
37
37
|
export declare function uintFrom4Bytes(x: Uint8Array, i?: number): number;
|
|
38
|
-
/**
|
|
39
|
-
* @param u is an unsigned integer up to 40-bits to be stored big-endian way in
|
|
40
|
-
* 5 bytes.
|
|
41
|
-
*/
|
|
42
|
-
export declare function packUintTo5Bytes(u: number, b: Buffer, i: number): void;
|
|
43
|
-
/**
|
|
44
|
-
* @param x
|
|
45
|
-
* @param i
|
|
46
|
-
* @return unsigned integer (up to 40 bits), stored big-endian way
|
|
47
|
-
* in 5 bytes of x, starting at index i.
|
|
48
|
-
*/
|
|
49
|
-
export declare function uintFrom5Bytes(x: Uint8Array, i?: number): number;
|
|
50
38
|
/**
|
|
51
39
|
* @param u is an unsigned integer up to 48-bits to be stored big-endian way in
|
|
52
40
|
* 6 bytes.
|
|
@@ -59,18 +47,6 @@ export declare function packUintTo6Bytes(u: number, b: Buffer, i: number): void;
|
|
|
59
47
|
* in 6 bytes of x, starting at index i.
|
|
60
48
|
*/
|
|
61
49
|
export declare function uintFrom6Bytes(x: Uint8Array, i?: number): number;
|
|
62
|
-
/**
|
|
63
|
-
* @param u is an unsigned integer up to 53-bits to be stored big-endian way in
|
|
64
|
-
* 7 bytes.
|
|
65
|
-
*/
|
|
66
|
-
export declare function packUintTo7Bytes(u: number, b: Buffer, i: number): void;
|
|
67
|
-
/**
|
|
68
|
-
* @param x
|
|
69
|
-
* @param i
|
|
70
|
-
* @return unsigned integer (up to 53 bits), stored big-endian way
|
|
71
|
-
* in 7 bytes of x, starting at index i.
|
|
72
|
-
*/
|
|
73
|
-
export declare function uintFrom7Bytes(x: Uint8Array, i?: number): number;
|
|
74
50
|
/**
|
|
75
51
|
* @param u is an unsigned integer up to 53-bits to be stored big-endian way in
|
|
76
52
|
* 8 bytes.
|
|
@@ -13,9 +13,10 @@
|
|
|
13
13
|
See the GNU General Public License for more details.
|
|
14
14
|
|
|
15
15
|
You should have received a copy of the GNU General Public License along with
|
|
16
|
-
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
17
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.uintFrom8Bytes = exports.packUintTo8Bytes = exports.
|
|
19
|
+
exports.uintFrom8Bytes = exports.packUintTo8Bytes = exports.uintFrom6Bytes = exports.packUintTo6Bytes = exports.uintFrom4Bytes = exports.packUintTo4Bytes = exports.uintFrom3Bytes = exports.packUintTo3Bytes = exports.uintFrom2Bytes = exports.packUintTo2Bytes = void 0;
|
|
19
20
|
/**
|
|
20
21
|
* @param u is an unsigned integer up to 16-bits to be stored big-endian way in
|
|
21
22
|
* 2 bytes.
|
|
@@ -100,44 +101,12 @@ function uintFrom4Bytes(x, i = 0) {
|
|
|
100
101
|
if (x.length < i + 4) {
|
|
101
102
|
throw new Error('Given array has less than 4 bytes, starting with a given index.');
|
|
102
103
|
}
|
|
103
|
-
|
|
104
|
+
// Note that (x << 24) may produce negative number, probably due to
|
|
105
|
+
// treating intermediate integer as signed, and pulling sign to resulting
|
|
106
|
+
// float number. Hence, we need a bit different operation here.
|
|
107
|
+
return (x[i] * 0x1000000) + ((x[i + 1] << 16) | (x[i + 2] << 8) | x[i + 3]);
|
|
104
108
|
}
|
|
105
109
|
exports.uintFrom4Bytes = uintFrom4Bytes;
|
|
106
|
-
/**
|
|
107
|
-
* @param u is an unsigned integer up to 40-bits to be stored big-endian way in
|
|
108
|
-
* 5 bytes.
|
|
109
|
-
*/
|
|
110
|
-
function packUintTo5Bytes(u, b, i) {
|
|
111
|
-
if (u > 0xffffffffff) {
|
|
112
|
-
throw new Error('Cannot store number bigger than 2^40-1');
|
|
113
|
-
}
|
|
114
|
-
if (b.length < i + 5) {
|
|
115
|
-
throw new Error('Given array has less than 5 bytes, starting with a given index.');
|
|
116
|
-
}
|
|
117
|
-
const h = Math.floor(u / 0x100000000);
|
|
118
|
-
const l = u % 0x100000000;
|
|
119
|
-
b[i] = h;
|
|
120
|
-
b[i + 1] = l >>> 24;
|
|
121
|
-
b[i + 2] = l >>> 16;
|
|
122
|
-
b[i + 3] = l >>> 8;
|
|
123
|
-
b[i + 4] = l;
|
|
124
|
-
}
|
|
125
|
-
exports.packUintTo5Bytes = packUintTo5Bytes;
|
|
126
|
-
/**
|
|
127
|
-
* @param x
|
|
128
|
-
* @param i
|
|
129
|
-
* @return unsigned integer (up to 40 bits), stored big-endian way
|
|
130
|
-
* in 5 bytes of x, starting at index i.
|
|
131
|
-
*/
|
|
132
|
-
function uintFrom5Bytes(x, i = 0) {
|
|
133
|
-
if (x.length < i + 5) {
|
|
134
|
-
throw new Error('Given array has less than 5 bytes, starting with a given index.');
|
|
135
|
-
}
|
|
136
|
-
const h = x[i];
|
|
137
|
-
const l = (x[i + 1] << 24) | (x[i + 2] << 16) | (x[i + 3] << 8) | x[i + 4];
|
|
138
|
-
return (h * 0x100000000 + l);
|
|
139
|
-
}
|
|
140
|
-
exports.uintFrom5Bytes = uintFrom5Bytes;
|
|
141
110
|
/**
|
|
142
111
|
* @param u is an unsigned integer up to 48-bits to be stored big-endian way in
|
|
143
112
|
* 6 bytes.
|
|
@@ -169,48 +138,14 @@ function uintFrom6Bytes(x, i = 0) {
|
|
|
169
138
|
if (x.length < i + 6) {
|
|
170
139
|
throw new Error('Given array has less than 6 bytes, starting with a given index.');
|
|
171
140
|
}
|
|
141
|
+
// Note that (x << 24) may produce negative number, probably due to
|
|
142
|
+
// treating intermediate integer as signed, and pulling sign to resulting
|
|
143
|
+
// float number. Hence, we need a bit different operation here.
|
|
172
144
|
const h = (x[i] << 8) | x[i + 1];
|
|
173
|
-
const l = (x[i
|
|
145
|
+
const l = (x[i] * 0x1000000) + ((x[i + 3] << 16) | (x[i + 4] << 8) | x[i + 5]);
|
|
174
146
|
return (h * 0x100000000 + l);
|
|
175
147
|
}
|
|
176
148
|
exports.uintFrom6Bytes = uintFrom6Bytes;
|
|
177
|
-
/**
|
|
178
|
-
* @param u is an unsigned integer up to 53-bits to be stored big-endian way in
|
|
179
|
-
* 7 bytes.
|
|
180
|
-
*/
|
|
181
|
-
function packUintTo7Bytes(u, b, i) {
|
|
182
|
-
if (u > Number.MAX_SAFE_INTEGER) {
|
|
183
|
-
throw new Error('Cannot store number bigger than 2^53-1');
|
|
184
|
-
}
|
|
185
|
-
if (b.length < i + 7) {
|
|
186
|
-
throw new Error('Given array has less than 7 bytes, starting with a given index.');
|
|
187
|
-
}
|
|
188
|
-
const h = Math.floor(u / 0x100000000);
|
|
189
|
-
const l = u % 0x100000000;
|
|
190
|
-
b[i] = h >>> 16;
|
|
191
|
-
b[i + 1] = h >>> 8;
|
|
192
|
-
b[i + 2] = h;
|
|
193
|
-
b[i + 3] = l >>> 24;
|
|
194
|
-
b[i + 4] = l >>> 16;
|
|
195
|
-
b[i + 5] = l >>> 8;
|
|
196
|
-
b[i + 6] = l;
|
|
197
|
-
}
|
|
198
|
-
exports.packUintTo7Bytes = packUintTo7Bytes;
|
|
199
|
-
/**
|
|
200
|
-
* @param x
|
|
201
|
-
* @param i
|
|
202
|
-
* @return unsigned integer (up to 53 bits), stored big-endian way
|
|
203
|
-
* in 7 bytes of x, starting at index i.
|
|
204
|
-
*/
|
|
205
|
-
function uintFrom7Bytes(x, i = 0) {
|
|
206
|
-
if (x.length < i + 7) {
|
|
207
|
-
throw new Error('Given array has less than 7 bytes, starting with a given index.');
|
|
208
|
-
}
|
|
209
|
-
const h = (x[i] << 16) | (x[i + 1] << 8) | x[i + 2];
|
|
210
|
-
const l = (x[i + 3] << 24) | (x[i + 4] << 16) | (x[i + 5] << 8) | x[i + 6];
|
|
211
|
-
return (h * 0x100000000 + l);
|
|
212
|
-
}
|
|
213
|
-
exports.uintFrom7Bytes = uintFrom7Bytes;
|
|
214
149
|
/**
|
|
215
150
|
* @param u is an unsigned integer up to 53-bits to be stored big-endian way in
|
|
216
151
|
* 8 bytes.
|
|
@@ -244,8 +179,11 @@ function uintFrom8Bytes(x, i = 0) {
|
|
|
244
179
|
if (x.length < i + 8) {
|
|
245
180
|
throw new Error('Given array has less than 8 bytes, starting with a given index.');
|
|
246
181
|
}
|
|
247
|
-
|
|
248
|
-
|
|
182
|
+
// Note that (x << 24) may produce negative number, probably due to
|
|
183
|
+
// treating intermediate integer as signed, and pulling sign to resulting
|
|
184
|
+
// float number. Hence, we need a bit different operation here.
|
|
185
|
+
const h = (x[i] * 0x1000000) + ((x[i + 1] << 16) | (x[i + 2] << 8) | x[i + 3]);
|
|
186
|
+
const l = (x[i + 4] * 0x1000000) + ((x[i + 5] << 16) | (x[i + 6] << 8) | x[i + 7]);
|
|
249
187
|
return (h * 0x100000000 + l);
|
|
250
188
|
}
|
|
251
189
|
exports.uintFrom8Bytes = uintFrom8Bytes;
|
|
@@ -30,7 +30,8 @@ exports.Code = {
|
|
|
30
30
|
ioError: 'EIO',
|
|
31
31
|
concurrentUpdate: 'concurrent-update',
|
|
32
32
|
parsingError: 'parsing-error',
|
|
33
|
-
notImplemented: 'ENOSYS'
|
|
33
|
+
notImplemented: 'ENOSYS',
|
|
34
|
+
isEndless: 'is-endless',
|
|
34
35
|
};
|
|
35
36
|
Object.freeze(exports.Code);
|
|
36
37
|
function makeFileException(code, path, cause) {
|
|
@@ -83,6 +84,9 @@ function makeFileException(code, path, cause) {
|
|
|
83
84
|
else if (code === exports.Code.notImplemented) {
|
|
84
85
|
err.notImplemented = true;
|
|
85
86
|
}
|
|
87
|
+
else if (code === exports.Code.isEndless) {
|
|
88
|
+
err.isEndless = true;
|
|
89
|
+
}
|
|
86
90
|
return err;
|
|
87
91
|
}
|
|
88
92
|
exports.makeFileException = makeFileException;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { SegmentsWriter, Subscribe } from "xsp-files";
|
|
3
1
|
declare type FileByteSink = web3n.files.FileByteSink;
|
|
4
2
|
export declare type ContinuousSink = (bytes: Uint8Array | null, err?: any) => Promise<void>;
|
|
5
3
|
export declare function makeContinuousSink(sink: FileByteSink, start?: number): ContinuousSink;
|
|
6
4
|
export declare function appendFiniteSink(sink: FileByteSink, bytes: Uint8Array, closeSink?: boolean): Promise<void>;
|
|
7
|
-
export declare function encryptBytesToSinkProc(bytes: Uint8Array | Uint8Array[], attrBytes: Buffer, segWriter: SegmentsWriter): Subscribe;
|
|
8
|
-
export declare function encryptAttrsToSinkProc(attrBytes: Buffer, segWriter: SegmentsWriter, baseAttrsSize: number | undefined): Subscribe;
|
|
9
5
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2018, 2020 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2018, 2020, 2022 3NSoft Inc.
|
|
4
4
|
|
|
5
5
|
This program is free software: you can redistribute it and/or modify it under
|
|
6
6
|
the terms of the GNU General Public License as published by the Free Software
|
|
@@ -13,11 +13,10 @@
|
|
|
13
13
|
See the GNU General Public License for more details.
|
|
14
14
|
|
|
15
15
|
You should have received a copy of the GNU General Public License along with
|
|
16
|
-
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
17
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.
|
|
19
|
-
const xsp_files_1 = require("xsp-files");
|
|
20
|
-
const buffer_utils_1 = require("../buffer-utils");
|
|
19
|
+
exports.appendFiniteSink = exports.makeContinuousSink = void 0;
|
|
21
20
|
class ContSink {
|
|
22
21
|
constructor(sink, position) {
|
|
23
22
|
this.sink = sink;
|
|
@@ -54,69 +53,4 @@ async function appendFiniteSink(sink, bytes, closeSink = true) {
|
|
|
54
53
|
}
|
|
55
54
|
}
|
|
56
55
|
exports.appendFiniteSink = appendFiniteSink;
|
|
57
|
-
function encryptBytesToSinkProc(bytes, attrBytes, segWriter) {
|
|
58
|
-
const { sink, sub } = xsp_files_1.makeEncryptingByteSinkWithAttrs(segWriter);
|
|
59
|
-
const writeToSink = async () => {
|
|
60
|
-
try {
|
|
61
|
-
await sink.writeAttrs(attrBytes);
|
|
62
|
-
if (Array.isArray(bytes)) {
|
|
63
|
-
await writeAllByteArrsToSink(bytes, sink);
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
await writeByteArrToSink(bytes, sink);
|
|
67
|
-
}
|
|
68
|
-
await sink.done();
|
|
69
|
-
}
|
|
70
|
-
catch (err) {
|
|
71
|
-
await sink.done(err);
|
|
72
|
-
}
|
|
73
|
-
finally {
|
|
74
|
-
segWriter.destroy();
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
return (obs, backpressure) => {
|
|
78
|
-
const unsub = sub(obs, backpressure);
|
|
79
|
-
writeToSink();
|
|
80
|
-
return unsub;
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
exports.encryptBytesToSinkProc = encryptBytesToSinkProc;
|
|
84
|
-
function encryptAttrsToSinkProc(attrBytes, segWriter, baseAttrsSize) {
|
|
85
|
-
const { sink, sub } = xsp_files_1.makeEncryptingByteSinkWithAttrs(segWriter, baseAttrsSize);
|
|
86
|
-
const writeToSink = async () => {
|
|
87
|
-
try {
|
|
88
|
-
await sink.writeAttrs(attrBytes);
|
|
89
|
-
await sink.done();
|
|
90
|
-
}
|
|
91
|
-
catch (err) {
|
|
92
|
-
await sink.done(err);
|
|
93
|
-
}
|
|
94
|
-
finally {
|
|
95
|
-
segWriter.destroy();
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
return (obs, backpressure) => {
|
|
99
|
-
const unsub = sub(obs, backpressure);
|
|
100
|
-
writeToSink();
|
|
101
|
-
return unsub;
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
exports.encryptAttrsToSinkProc = encryptAttrsToSinkProc;
|
|
105
|
-
async function writeByteArrToSink(bytes, sink) {
|
|
106
|
-
await sink.setSize(bytes.length);
|
|
107
|
-
await sink.freezeLayout();
|
|
108
|
-
await sink.write(0, bytes);
|
|
109
|
-
}
|
|
110
|
-
async function writeAllByteArrsToSink(bytes, sink) {
|
|
111
|
-
await sink.setSize(buffer_utils_1.byteLengthIn(bytes));
|
|
112
|
-
await sink.freezeLayout();
|
|
113
|
-
let pos = 0;
|
|
114
|
-
for (const arr of bytes) {
|
|
115
|
-
if (arr.length === 0) {
|
|
116
|
-
continue;
|
|
117
|
-
}
|
|
118
|
-
await sink.write(pos, arr);
|
|
119
|
-
pos += arr.length;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
56
|
Object.freeze(exports);
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
See the GNU General Public License for more details.
|
|
14
14
|
|
|
15
15
|
You should have received a copy of the GNU General Public License along with
|
|
16
|
-
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
17
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
19
|
exports.ObjVersionBytesLayout = void 0;
|
|
19
20
|
const v1_obj_file_format_1 = require("./v1-obj-file-format");
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
See the GNU General Public License for more details.
|
|
14
14
|
|
|
15
15
|
You should have received a copy of the GNU General Public License along with
|
|
16
|
-
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
17
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
19
|
exports.ObjVersionFile = void 0;
|
|
19
20
|
const fs = require("../async-fs-node");
|
|
@@ -25,7 +26,6 @@ const v1_obj_file_format_1 = require("./v1-obj-file-format");
|
|
|
25
26
|
const fs_1 = require("fs");
|
|
26
27
|
const file_layout_1 = require("./file-layout");
|
|
27
28
|
const big_endian_1 = require("../big-endian");
|
|
28
|
-
global.log = false;
|
|
29
29
|
class ObjVersionFile {
|
|
30
30
|
constructor(path, layout) {
|
|
31
31
|
this.path = path;
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
See the GNU General Public License for more details.
|
|
14
14
|
|
|
15
15
|
You should have received a copy of the GNU General Public License along with
|
|
16
|
-
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
17
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
19
|
exports.makeNoBaseObjPipe = exports.makeObjPipe = exports.chunksInOrderedStream = exports.streamToObjFile = exports.diffToLayout = void 0;
|
|
19
20
|
const processes_1 = require("../processes");
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
See the GNU General Public License for more details.
|
|
14
14
|
|
|
15
15
|
You should have received a copy of the GNU General Public License along with
|
|
16
|
-
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
17
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
19
|
exports.layoutV1 = exports.V1_FILE_START = void 0;
|
|
19
20
|
const big_endian_1 = require("../big-endian");
|
package/build/lib-index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./core-ipc/startup-caps";
|
|
|
4
4
|
export * from "./ipc-via-protobuf/connector";
|
|
5
5
|
export { FileMsg, makeFileCaller, exposeFileService } from "./ipc-via-protobuf/file";
|
|
6
6
|
export { FSMsg, makeFSCaller, exposeFSService } from "./ipc-via-protobuf/fs";
|
|
7
|
+
export { makeLogCaller, exposeLogger } from "./ipc-via-protobuf/log-cap";
|
|
7
8
|
export * from "./core";
|
|
8
9
|
export { makeServiceLocator, ServiceLocatorMaker } from "./lib-client/service-locator";
|
|
9
10
|
export { makeNetClient } from "./lib-client/request-utils";
|
package/build/lib-index.js
CHANGED
|
@@ -36,6 +36,9 @@ Object.defineProperty(exports, "exposeFileService", { enumerable: true, get: fun
|
|
|
36
36
|
var fs_1 = require("./ipc-via-protobuf/fs");
|
|
37
37
|
Object.defineProperty(exports, "makeFSCaller", { enumerable: true, get: function () { return fs_1.makeFSCaller; } });
|
|
38
38
|
Object.defineProperty(exports, "exposeFSService", { enumerable: true, get: function () { return fs_1.exposeFSService; } });
|
|
39
|
+
var log_cap_1 = require("./ipc-via-protobuf/log-cap");
|
|
40
|
+
Object.defineProperty(exports, "makeLogCaller", { enumerable: true, get: function () { return log_cap_1.makeLogCaller; } });
|
|
41
|
+
Object.defineProperty(exports, "exposeLogger", { enumerable: true, get: function () { return log_cap_1.exposeLogger; } });
|
|
39
42
|
__exportStar(require("./core"), exports);
|
|
40
43
|
var service_locator_1 = require("./lib-client/service-locator");
|
|
41
44
|
Object.defineProperty(exports, "makeServiceLocator", { enumerable: true, get: function () { return service_locator_1.makeServiceLocator; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "core-3nweb-client-lib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"description": "3NWeb client core library, embeddable into different environments",
|
|
5
5
|
"main": "build/lib-index.js",
|
|
6
6
|
"types": "build/lib-index.d.ts",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"punycode": "^2.1.1",
|
|
32
32
|
"rxjs": "^6.5.2",
|
|
33
33
|
"ws": "^7.0.0",
|
|
34
|
-
"xsp-files": "^
|
|
34
|
+
"xsp-files": "^4.0.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/jasmine": "^3.9.1",
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
declare type FSEntityType = 'folder-json-v1' | 'link-json-v1' | 'file-v1-continuous' | 'file-v1-w-layout';
|
|
3
|
-
export interface EntityAttrs {
|
|
4
|
-
type: FSEntityType;
|
|
5
|
-
ctime: number;
|
|
6
|
-
mtime: number;
|
|
7
|
-
ext: {
|
|
8
|
-
[name: string]: NamedAttr;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
export interface FileAttrs extends EntityAttrs {
|
|
12
|
-
type: 'file-v1-continuous' | 'file-v1-w-layout';
|
|
13
|
-
size?: number;
|
|
14
|
-
layoutOfs?: number;
|
|
15
|
-
}
|
|
16
|
-
export interface FolderAttrs extends EntityAttrs {
|
|
17
|
-
type: 'folder-json-v1';
|
|
18
|
-
}
|
|
19
|
-
export interface LinkAttrs extends EntityAttrs {
|
|
20
|
-
type: 'link-json-v1';
|
|
21
|
-
}
|
|
22
|
-
export declare type Attrs = FolderAttrs | FileAttrs | LinkAttrs;
|
|
23
|
-
export interface NamedBinaryAttr {
|
|
24
|
-
type: 'named-binary';
|
|
25
|
-
name: string;
|
|
26
|
-
value: Uint8Array;
|
|
27
|
-
}
|
|
28
|
-
export interface NamedStringAttr {
|
|
29
|
-
type: 'named-utf8str';
|
|
30
|
-
name: string;
|
|
31
|
-
value: string;
|
|
32
|
-
}
|
|
33
|
-
export interface NamedJsonAttr {
|
|
34
|
-
type: 'named-json';
|
|
35
|
-
name: string;
|
|
36
|
-
value: any;
|
|
37
|
-
}
|
|
38
|
-
export declare type NamedAttr = NamedBinaryAttr | NamedStringAttr | NamedJsonAttr;
|
|
39
|
-
export declare function attrType(value: any): NamedAttr['type'];
|
|
40
|
-
export declare function makeFileAttrs(now: number): FileAttrs;
|
|
41
|
-
export declare function makeFolderAttrs(now: number): FolderAttrs;
|
|
42
|
-
export declare function makeLinkAttrs(now: number): LinkAttrs;
|
|
43
|
-
export interface ObjFileParsingException extends web3n.RuntimeException {
|
|
44
|
-
type: 'attrs-parsing';
|
|
45
|
-
msg: string;
|
|
46
|
-
}
|
|
47
|
-
declare type XAttrsChanges = web3n.files.XAttrsChanges;
|
|
48
|
-
export declare class AttrsHolder<T extends EntityAttrs> {
|
|
49
|
-
private readonly attrs;
|
|
50
|
-
private modifiable;
|
|
51
|
-
constructor(attrs: T, modifiable?: boolean);
|
|
52
|
-
modifiableCopy(): AttrsHolder<T>;
|
|
53
|
-
static fromBytesReadonly<T extends EntityAttrs>(bytes: Uint8Array): AttrsHolder<T>;
|
|
54
|
-
static fromJSONReadonly<T extends EntityAttrs>(attrs: T): AttrsHolder<T>;
|
|
55
|
-
static makeReadonlyForFile(now: number): AttrsHolder<FileAttrs>;
|
|
56
|
-
static makeReadonlyForFolder(now: number): AttrsHolder<FolderAttrs>;
|
|
57
|
-
static makeReadonlyForLink(now: number): AttrsHolder<LinkAttrs>;
|
|
58
|
-
toBytes(): Buffer;
|
|
59
|
-
setReadonly(): void;
|
|
60
|
-
get isReadonly(): boolean;
|
|
61
|
-
private throwIfReadonly;
|
|
62
|
-
get ctime(): number;
|
|
63
|
-
set ctime(epoch: number);
|
|
64
|
-
get mtime(): number;
|
|
65
|
-
set mtime(epoch: number);
|
|
66
|
-
get type(): T['type'];
|
|
67
|
-
get serializedLen(): number;
|
|
68
|
-
getFileLayoutOfs(): number | undefined;
|
|
69
|
-
getFileSize(): number | undefined;
|
|
70
|
-
setFileLayoutOfs(ofs: number): void;
|
|
71
|
-
setContinuousFileSize(size: number): void;
|
|
72
|
-
getXAttr(xaName: string): any;
|
|
73
|
-
updateXAttrs(changes: XAttrsChanges): void;
|
|
74
|
-
listXAttrs(): string[];
|
|
75
|
-
}
|
|
76
|
-
export {};
|