core-3nweb-client-lib 0.26.0 → 0.27.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/build/api-defs/asmail.d.ts +1 -1
- package/build/api-defs/files.d.ts +278 -69
- package/build/core/app-files.js +7 -7
- package/build/core/asmail/config/common.js +2 -2
- package/build/core/asmail/config/index.js +2 -2
- package/build/core/asmail/config/published-intro-key.js +1 -1
- package/build/core/asmail/delivery/common.js +7 -7
- package/build/core/asmail/delivery/index.js +5 -5
- package/build/core/asmail/delivery/msg.js +4 -4
- package/build/core/asmail/delivery/per-recipient-wip.js +1 -1
- package/build/core/asmail/inbox/attachments/fs.js +5 -1
- package/build/core/asmail/inbox/cached-msgs.js +1 -1
- package/build/core/asmail/inbox/inbox-events.js +4 -4
- package/build/core/asmail/inbox/index.js +10 -10
- package/build/core/asmail/inbox/msg-downloader.js +1 -1
- package/build/core/asmail/inbox/msg-indexing.js +1 -1
- package/build/core/asmail/inbox/msg-on-disk.js +5 -5
- package/build/core/asmail/index.d.ts +3 -3
- package/build/core/asmail/index.js +13 -8
- package/build/core/asmail/key-verification.js +5 -5
- package/build/core/asmail/keyring/common.js +7 -6
- package/build/core/asmail/keyring/correspondent-keys.js +8 -7
- package/build/core/asmail/keyring/id-to-email-map.js +2 -1
- package/build/core/asmail/keyring/index.d.ts +7 -8
- package/build/core/asmail/keyring/index.js +15 -14
- package/build/core/asmail/keyring/keyring-storage.js +2 -1
- package/build/core/asmail/msg/opener.js +3 -3
- package/build/core/asmail/msg/packer.js +13 -13
- package/build/core/asmail/sending-params/own-params.js +2 -2
- package/build/core/asmail/sending-params/params-from-others.js +1 -1
- package/build/core/id-manager.js +6 -3
- package/build/core/index.d.ts +2 -1
- package/build/core/index.js +14 -14
- package/build/core/sign-in.js +5 -5
- package/build/core/sign-up.js +9 -9
- package/build/core/storage/common/json-saving.js +2 -2
- package/build/core/storage/common/obj-info-file.d.ts +12 -4
- package/build/core/storage/common/obj-info-file.js +66 -34
- package/build/core/storage/common/utils.d.ts +2 -0
- package/build/core/storage/common/utils.js +32 -0
- package/build/core/storage/index.d.ts +3 -17
- package/build/core/storage/index.js +56 -76
- package/build/core/storage/local/obj-files-gc.d.ts +2 -0
- package/build/core/storage/local/obj-files-gc.js +49 -37
- package/build/core/storage/local/obj-files.d.ts +4 -7
- package/build/core/storage/local/obj-files.js +7 -10
- package/build/core/storage/local/obj-status.d.ts +12 -6
- package/build/core/storage/local/obj-status.js +24 -9
- package/build/core/storage/local/storage.d.ts +9 -6
- package/build/core/storage/local/storage.js +29 -18
- package/build/core/storage/synced/downloader.js +1 -1
- package/build/core/storage/synced/obj-files-gc.d.ts +5 -1
- package/build/core/storage/synced/obj-files-gc.js +91 -37
- package/build/core/storage/synced/obj-files.d.ts +42 -36
- package/build/core/storage/synced/obj-files.js +178 -147
- package/build/core/storage/synced/obj-status.d.ts +87 -85
- package/build/core/storage/synced/obj-status.js +463 -259
- package/build/core/storage/synced/remote-events.d.ts +11 -12
- package/build/core/storage/synced/remote-events.js +73 -56
- package/build/core/storage/synced/storage.d.ts +18 -9
- package/build/core/storage/synced/storage.js +108 -48
- package/build/core/storage/synced/upload-header-file.d.ts +4 -0
- package/build/core/storage/synced/upload-header-file.js +64 -0
- package/build/core/storage/synced/upsyncer.d.ts +12 -7
- package/build/core/storage/synced/upsyncer.js +204 -280
- package/build/core/storage/system-folders/apps-data.d.ts +16 -0
- package/build/core/storage/system-folders/apps-data.js +110 -0
- package/build/core/storage/system-folders/index.d.ts +18 -0
- package/build/core/storage/system-folders/index.js +77 -0
- package/build/core-ipc/common-caps.js +3 -3
- package/build/core-ipc/generic.js +8 -8
- package/build/core-ipc/startup-caps.js +2 -2
- package/build/cryptors.js +6 -2
- package/build/ipc-via-protobuf/asmail-cap.js +58 -57
- package/build/ipc-via-protobuf/bytes.js +16 -17
- package/build/ipc-via-protobuf/connector-clients-side.d.ts +3 -0
- package/build/ipc-via-protobuf/connector-clients-side.js +61 -24
- package/build/ipc-via-protobuf/connector-services-side.js +10 -10
- package/build/ipc-via-protobuf/connector.js +4 -4
- package/build/ipc-via-protobuf/file.d.ts +48 -12
- package/build/ipc-via-protobuf/file.js +474 -126
- package/build/ipc-via-protobuf/fs.d.ts +8 -0
- package/build/ipc-via-protobuf/fs.js +577 -142
- package/build/ipc-via-protobuf/log-cap.js +2 -2
- package/build/ipc-via-protobuf/mailerid.js +3 -3
- package/build/ipc-via-protobuf/protobuf-msg.d.ts +1 -0
- package/build/ipc-via-protobuf/protobuf-msg.js +11 -7
- package/build/ipc-via-protobuf/startup-cap.js +21 -21
- package/build/ipc-via-protobuf/storage-cap.js +12 -12
- package/build/ipc.js +7 -2
- package/build/lib-client/3nstorage/exceptions.d.ts +3 -0
- package/build/lib-client/3nstorage/exceptions.js +13 -1
- package/build/lib-client/3nstorage/service.d.ts +15 -2
- package/build/lib-client/3nstorage/service.js +104 -38
- package/build/lib-client/3nstorage/util/file-based-json.d.ts +2 -1
- package/build/lib-client/3nstorage/util/file-based-json.js +1 -1
- package/build/lib-client/3nstorage/xsp-fs/attrs.js +17 -17
- package/build/lib-client/3nstorage/xsp-fs/common.d.ts +42 -18
- package/build/lib-client/3nstorage/xsp-fs/common.js +29 -19
- package/build/lib-client/3nstorage/xsp-fs/file-node.d.ts +1 -0
- package/build/lib-client/3nstorage/xsp-fs/file-node.js +17 -13
- package/build/lib-client/3nstorage/xsp-fs/file.d.ts +31 -6
- package/build/lib-client/3nstorage/xsp-fs/file.js +73 -25
- package/build/lib-client/3nstorage/xsp-fs/folder-node-serialization.js +4 -4
- package/build/lib-client/3nstorage/xsp-fs/folder-node.d.ts +24 -11
- package/build/lib-client/3nstorage/xsp-fs/folder-node.js +575 -179
- package/build/lib-client/3nstorage/xsp-fs/fs.d.ts +35 -4
- package/build/lib-client/3nstorage/xsp-fs/fs.js +231 -110
- package/build/lib-client/3nstorage/xsp-fs/link-node.d.ts +1 -0
- package/build/lib-client/3nstorage/xsp-fs/link-node.js +7 -2
- package/build/lib-client/3nstorage/xsp-fs/node-in-fs.d.ts +30 -24
- package/build/lib-client/3nstorage/xsp-fs/node-in-fs.js +229 -123
- package/build/lib-client/3nstorage/xsp-fs/node-persistence.d.ts +1 -1
- package/build/lib-client/3nstorage/xsp-fs/node-persistence.js +17 -18
- package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v1.js +3 -3
- package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v2.js +53 -53
- package/build/lib-client/3nweb-signup.js +4 -4
- package/build/lib-client/asmail/recipient.js +15 -15
- package/build/lib-client/asmail/sender.js +22 -22
- package/build/lib-client/asmail/service-config.js +3 -3
- package/build/lib-client/cryptor/cryptor-in-worker.js +18 -16
- package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
- package/build/lib-client/cryptor/cryptor.js +4 -2
- package/build/lib-client/cryptor/cryptor.wasm +0 -0
- package/build/lib-client/cryptor/in-proc-js.js +1 -1
- package/build/lib-client/cryptor/in-proc-wasm.js +6 -6
- package/build/lib-client/cryptor/worker-js.js +2 -2
- package/build/lib-client/cryptor/worker-wasm.js +2 -2
- package/build/lib-client/files-select.js +1 -1
- package/build/lib-client/files.d.ts +1 -1
- package/build/lib-client/files.js +71 -6
- package/build/lib-client/fs-collection.js +1 -1
- package/build/lib-client/fs-sync-utils.d.ts +5 -0
- package/build/lib-client/fs-sync-utils.js +61 -0
- package/build/lib-client/fs-view.d.ts +14 -0
- package/build/lib-client/fs-view.js +33 -0
- package/build/lib-client/key-derivation.js +1 -1
- package/build/lib-client/local-files/dev-file-sink.js +9 -9
- package/build/lib-client/local-files/dev-file-src.js +2 -2
- package/build/lib-client/local-files/device-fs.d.ts +1 -1
- package/build/lib-client/local-files/device-fs.js +56 -54
- package/build/lib-client/logging/log-to-file.d.ts +1 -1
- package/build/lib-client/logging/log-to-file.js +7 -7
- package/build/lib-client/mailer-id/login.js +7 -7
- package/build/lib-client/mailer-id/provisioner.js +12 -12
- package/build/lib-client/objs-on-disk/file-writing-proc.js +3 -3
- package/build/lib-client/objs-on-disk/obj-folders.js +31 -31
- package/build/lib-client/objs-on-disk/obj-on-disk.d.ts +13 -2
- package/build/lib-client/objs-on-disk/obj-on-disk.js +24 -9
- package/build/lib-client/request-utils.d.ts +1 -0
- package/build/lib-client/request-utils.js +13 -13
- package/build/lib-client/server-events.d.ts +3 -3
- package/build/lib-client/server-events.js +9 -8
- package/build/lib-client/service-locator.js +10 -10
- package/build/lib-client/user-with-mid-session.js +7 -7
- package/build/lib-client/user-with-pkl-session.js +25 -25
- package/build/lib-client/ws-utils.js +2 -2
- package/build/lib-common/async-cryptor-wrap.js +4 -4
- package/build/lib-common/async-fs-node.d.ts +5 -3
- package/build/lib-common/async-fs-node.js +16 -16
- package/build/lib-common/byte-streaming/pipe.js +1 -1
- package/build/lib-common/byte-streaming/wrapping.js +13 -13
- package/build/lib-common/canonical-address.js +1 -1
- package/build/lib-common/exceptions/error.d.ts +1 -0
- package/build/lib-common/exceptions/error.js +7 -6
- package/build/lib-common/exceptions/file.js +4 -0
- package/build/lib-common/ipc/ws-ipc.js +2 -2
- package/build/lib-common/mid-sigs-NaCl-Ed.js +14 -14
- package/build/lib-common/objs-on-disk/file-layout.d.ts +19 -0
- package/build/lib-common/objs-on-disk/file-layout.js +130 -12
- package/build/lib-common/objs-on-disk/obj-file.d.ts +13 -2
- package/build/lib-common/objs-on-disk/obj-file.js +96 -35
- package/build/lib-common/objs-on-disk/utils.d.ts +1 -0
- package/build/lib-common/objs-on-disk/utils.js +3 -3
- package/build/lib-common/objs-on-disk/v1-obj-file-format.js +14 -14
- package/build/lib-common/processes/labelled-exec-pools.d.ts +1 -1
- package/build/lib-common/processes/labelled-exec-pools.js +1 -1
- package/build/lib-common/processes/pressure.js +2 -2
- package/build/lib-common/processes/synced.js +1 -1
- package/build/lib-common/processes/timeout.js +2 -2
- package/build/lib-common/random-node.js +7 -7
- package/build/lib-common/service-api/3nstorage/owner.d.ts +95 -39
- package/build/lib-common/service-api/3nstorage/owner.js +82 -40
- package/build/lib-common/service-api/asmail/delivery.js +2 -2
- package/build/lib-common/service-api/asmail/retrieval.js +1 -1
- package/build/lib-common/timed-cache.d.ts +1 -0
- package/build/lib-common/timed-non-weak-cache.d.ts +1 -0
- package/build/lib-common/timed-non-weak-cache.js +11 -0
- package/build/lib-common/utils-for-observables.js +4 -4
- package/build/lib-common/weak-cache.d.ts +1 -0
- package/build/lib-common/weak-cache.js +12 -1
- package/build/lib-index.d.ts +2 -1
- package/build/lib-index.js +10 -7
- package/build/protos/asmail.proto.js +12955 -7496
- package/build/protos/file.proto.js +4867 -2744
- package/build/protos/fs.proto.js +9227 -3768
- package/package.json +6 -5
- package/protos/file.proto +91 -19
- package/protos/fs.proto +107 -8
|
@@ -55,7 +55,7 @@ class ServiceUser {
|
|
|
55
55
|
return this.uri;
|
|
56
56
|
}
|
|
57
57
|
set serviceURI(uriString) {
|
|
58
|
-
const u = url_1.parse(uriString);
|
|
58
|
+
const u = (0, url_1.parse)(uriString);
|
|
59
59
|
if (u.protocol !== 'https:') {
|
|
60
60
|
throw new Error("Url protocol must be https.");
|
|
61
61
|
}
|
|
@@ -82,40 +82,40 @@ class ServiceUser {
|
|
|
82
82
|
if (rep.status == loginApi.start.SC.ok) {
|
|
83
83
|
// set sessionid
|
|
84
84
|
if (!rep.data || (typeof rep.data.sessionId !== 'string')) {
|
|
85
|
-
throw request_utils_1.makeException(rep, 'Malformed reply to starting session');
|
|
85
|
+
throw (0, request_utils_1.makeException)(rep, 'Malformed reply to starting session');
|
|
86
86
|
}
|
|
87
87
|
this.sessionId = rep.data.sessionId;
|
|
88
88
|
// set server public key
|
|
89
89
|
if (typeof rep.data.serverPubKey !== 'string') {
|
|
90
|
-
throw request_utils_1.makeException(rep, 'Malformed reply: serverPubKey string is missing.');
|
|
90
|
+
throw (0, request_utils_1.makeException)(rep, 'Malformed reply: serverPubKey string is missing.');
|
|
91
91
|
}
|
|
92
92
|
try {
|
|
93
93
|
this.serverPubKey = buffer_utils_1.base64.open(rep.data.serverPubKey);
|
|
94
94
|
if (this.serverPubKey.length !== ecma_nacl_1.box.KEY_LENGTH) {
|
|
95
|
-
throw request_utils_1.makeException(rep, 'Malformed reply: server\'s key has a wrong size.');
|
|
95
|
+
throw (0, request_utils_1.makeException)(rep, 'Malformed reply: server\'s key has a wrong size.');
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
catch (err) {
|
|
99
|
-
throw request_utils_1.makeException(rep, `Malformed reply: bad serverPubKey string. Error: ${('string' === typeof err) ? err : err.message}`);
|
|
99
|
+
throw (0, request_utils_1.makeException)(rep, `Malformed reply: bad serverPubKey string. Error: ${('string' === typeof err) ? err : err.message}`);
|
|
100
100
|
}
|
|
101
101
|
// get encrypted session key from json body
|
|
102
102
|
if (typeof rep.data.sessionKey !== 'string') {
|
|
103
|
-
throw request_utils_1.makeException(rep, 'Malformed reply: sessionKey string is missing.');
|
|
103
|
+
throw (0, request_utils_1.makeException)(rep, 'Malformed reply: sessionKey string is missing.');
|
|
104
104
|
}
|
|
105
105
|
try {
|
|
106
106
|
this.encChallenge = buffer_utils_1.base64.open(rep.data.sessionKey);
|
|
107
107
|
if (this.encChallenge.length !==
|
|
108
108
|
(ecma_nacl_1.secret_box.NONCE_LENGTH + ecma_nacl_1.secret_box.KEY_LENGTH)) {
|
|
109
|
-
throw request_utils_1.makeException(rep, `Malformed reply: byte chunk with session key has a wrong size.`);
|
|
109
|
+
throw (0, request_utils_1.makeException)(rep, `Malformed reply: byte chunk with session key has a wrong size.`);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
catch (err) {
|
|
113
|
-
throw request_utils_1.makeException(rep, `Malformed reply: bad sessionKey string. Error: ${(typeof err === 'string') ? err : err.message}`);
|
|
113
|
+
throw (0, request_utils_1.makeException)(rep, `Malformed reply: bad sessionKey string. Error: ${(typeof err === 'string') ? err : err.message}`);
|
|
114
114
|
}
|
|
115
115
|
// get key derivation parameters for a default key
|
|
116
116
|
if (!keyId) {
|
|
117
117
|
if (typeof rep.data.keyDerivParams !== 'object') {
|
|
118
|
-
throw request_utils_1.makeException(rep, `Malformed reply: keyDerivParams string is missing.`);
|
|
118
|
+
throw (0, request_utils_1.makeException)(rep, `Malformed reply: keyDerivParams string is missing.`);
|
|
119
119
|
}
|
|
120
120
|
this.keyDerivationParams = rep.data.keyDerivParams;
|
|
121
121
|
}
|
|
@@ -124,11 +124,11 @@ class ServiceUser {
|
|
|
124
124
|
(rep.status === loginApi.start.SC.redirect)) {
|
|
125
125
|
const rd = rep.data;
|
|
126
126
|
if (!rd || ('string' !== typeof rd.redirect)) {
|
|
127
|
-
throw request_utils_1.makeException(rep, 'Malformed reply');
|
|
127
|
+
throw (0, request_utils_1.makeException)(rep, 'Malformed reply');
|
|
128
128
|
}
|
|
129
129
|
// refuse second redirect
|
|
130
130
|
if (this.redirectedFrom !== undefined) {
|
|
131
|
-
throw request_utils_1.makeException(rep, `Redirected too many times. First redirect was from ${this.redirectedFrom} to ${this.serviceURI}. Second and forbidden redirect is to ${rd.redirect}`);
|
|
131
|
+
throw (0, request_utils_1.makeException)(rep, `Redirected too many times. First redirect was from ${this.redirectedFrom} to ${this.serviceURI}. Second and forbidden redirect is to ${rd.redirect}`);
|
|
132
132
|
}
|
|
133
133
|
// set params
|
|
134
134
|
this.redirectedFrom = this.serviceURI;
|
|
@@ -137,19 +137,19 @@ class ServiceUser {
|
|
|
137
137
|
return this.startSession(keyId);
|
|
138
138
|
}
|
|
139
139
|
else if (rep.status === loginApi.start.SC.unknownUser) {
|
|
140
|
-
const exc = request_utils_1.makeException(rep);
|
|
140
|
+
const exc = (0, request_utils_1.makeException)(rep);
|
|
141
141
|
exc.unknownUser = true;
|
|
142
142
|
throw exc;
|
|
143
143
|
}
|
|
144
144
|
else {
|
|
145
|
-
throw request_utils_1.makeException(rep, 'Unexpected status');
|
|
145
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
openSessionKey(dhsharedKeyCalc) {
|
|
149
|
-
assert_1.assert(!!this.encChallenge);
|
|
149
|
+
(0, assert_1.assert)(!!this.encChallenge);
|
|
150
150
|
const dhsharedKey = dhsharedKeyCalc();
|
|
151
|
-
const nonce = buffer_utils_1.makeUint8ArrayCopy(this.encChallenge.subarray(0, ecma_nacl_1.secret_box.NONCE_LENGTH));
|
|
152
|
-
const sessionKey = buffer_utils_1.makeUint8ArrayCopy(this.encChallenge.subarray(ecma_nacl_1.secret_box.NONCE_LENGTH));
|
|
151
|
+
const nonce = (0, buffer_utils_1.makeUint8ArrayCopy)(this.encChallenge.subarray(0, ecma_nacl_1.secret_box.NONCE_LENGTH));
|
|
152
|
+
const sessionKey = (0, buffer_utils_1.makeUint8ArrayCopy)(this.encChallenge.subarray(ecma_nacl_1.secret_box.NONCE_LENGTH));
|
|
153
153
|
// encrypted challenge has session key packaged into WN format, with
|
|
154
154
|
// poly part cut out. Therefore, usual open method will not do as it
|
|
155
155
|
// does poly check. We should recall that cipher is a stream with data
|
|
@@ -168,15 +168,15 @@ class ServiceUser {
|
|
|
168
168
|
this.serverVerificationBytes =
|
|
169
169
|
this.serverVerificationBytes.subarray(0, ecma_nacl_1.secret_box.POLY_LENGTH);
|
|
170
170
|
ecma_nacl_1.nonce.advanceOddly(nonce);
|
|
171
|
-
this.encryptor = session_encryptor_1.makeSessionEncryptor(sessionKey, nonce);
|
|
171
|
+
this.encryptor = (0, session_encryptor_1.makeSessionEncryptor)(sessionKey, nonce);
|
|
172
172
|
// encrypt session key for completion of login exchange
|
|
173
173
|
this.encChallenge = this.encryptor.pack(sessionKey);
|
|
174
174
|
// cleanup arrays
|
|
175
175
|
ecma_nacl_1.arrays.wipe(dhsharedKey, nonce, sessionKey);
|
|
176
176
|
}
|
|
177
177
|
async completeLoginExchange() {
|
|
178
|
-
assert_1.assert(!!this.encChallenge);
|
|
179
|
-
assert_1.assert(!!this.serverVerificationBytes);
|
|
178
|
+
(0, assert_1.assert)(!!this.encChallenge);
|
|
179
|
+
(0, assert_1.assert)(!!this.serverVerificationBytes);
|
|
180
180
|
const rep = await this.net.doBinaryRequest({
|
|
181
181
|
url: `${this.serviceURI}${this.loginUrlPart}${loginApi.complete.URL_END}`,
|
|
182
182
|
method: loginApi.complete.method,
|
|
@@ -186,22 +186,22 @@ class ServiceUser {
|
|
|
186
186
|
this.encChallenge = undefined;
|
|
187
187
|
if (rep.status === loginApi.complete.SC.ok) {
|
|
188
188
|
// compare bytes to check, if server can be trusted
|
|
189
|
-
if (ecma_nacl_1.compareVectors(rep.data, this.serverVerificationBytes)) {
|
|
189
|
+
if ((0, ecma_nacl_1.compareVectors)(rep.data, this.serverVerificationBytes)) {
|
|
190
190
|
this.serverVerificationBytes = undefined;
|
|
191
191
|
}
|
|
192
192
|
else {
|
|
193
|
-
const exc = request_utils_1.makeException(rep);
|
|
193
|
+
const exc = (0, request_utils_1.makeException)(rep);
|
|
194
194
|
exc.serverNotTrusted = true;
|
|
195
195
|
throw exc;
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
else if (rep.status === loginApi.complete.SC.authFailed) {
|
|
199
|
-
const exc = request_utils_1.makeException(rep);
|
|
199
|
+
const exc = (0, request_utils_1.makeException)(rep);
|
|
200
200
|
exc.cryptoResponseNotAccepted = true;
|
|
201
201
|
throw exc;
|
|
202
202
|
}
|
|
203
203
|
else {
|
|
204
|
-
throw request_utils_1.makeException(rep, 'Unexpected status');
|
|
204
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
207
|
/**
|
|
@@ -216,7 +216,7 @@ class ServiceUser {
|
|
|
216
216
|
*/
|
|
217
217
|
async login(keyId) {
|
|
218
218
|
await this.startSession(keyId);
|
|
219
|
-
assert_1.assert(!!this.serverPubKey);
|
|
219
|
+
(0, assert_1.assert)(!!this.serverPubKey);
|
|
220
220
|
return {
|
|
221
221
|
keyParams: this.keyDerivationParams,
|
|
222
222
|
serverPKey: this.serverPubKey,
|
|
@@ -245,7 +245,7 @@ class ServiceUser {
|
|
|
245
245
|
this.encryptor = undefined;
|
|
246
246
|
}
|
|
247
247
|
else {
|
|
248
|
-
throw request_utils_1.makeException(rep, 'Unexpected status');
|
|
248
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
251
|
}
|
|
@@ -28,8 +28,8 @@ function openSocket(url, sessionId) {
|
|
|
28
28
|
const headers = {};
|
|
29
29
|
headers[request_utils_1.SESSION_ID_HEADER] = sessionId;
|
|
30
30
|
const ws = new WebSocket(url, { headers, agent: https_1.globalAgent });
|
|
31
|
-
const opening = deferred_1.defer();
|
|
32
|
-
const initOnError = err => opening.reject(http_1.makeConnectionException(url, undefined, `Cannot open websocket connection due to error: ${err.message}`));
|
|
31
|
+
const opening = (0, deferred_1.defer)();
|
|
32
|
+
const initOnError = err => opening.reject((0, http_1.makeConnectionException)(url, undefined, `Cannot open websocket connection due to error: ${err.message}`));
|
|
33
33
|
const onNonOkReply = (req, res) => {
|
|
34
34
|
const errReply = {
|
|
35
35
|
url,
|
|
@@ -52,8 +52,8 @@ function makeEncryptor(cryptor, key, nextNonce, delta) {
|
|
|
52
52
|
else if ((delta < 1) || (delta > 255)) {
|
|
53
53
|
throw new Error("Given delta is out of bounds.");
|
|
54
54
|
}
|
|
55
|
-
key = buffer_utils_1.makeUint8ArrayCopy(key);
|
|
56
|
-
nextNonce = buffer_utils_1.makeUint8ArrayCopy(nextNonce);
|
|
55
|
+
key = (0, buffer_utils_1.makeUint8ArrayCopy)(key);
|
|
56
|
+
nextNonce = (0, buffer_utils_1.makeUint8ArrayCopy)(nextNonce);
|
|
57
57
|
let counter = 0;
|
|
58
58
|
const counterMax = Math.floor(0xfffffffffffff / delta);
|
|
59
59
|
const encryptor = {
|
|
@@ -65,7 +65,7 @@ function makeEncryptor(cryptor, key, nextNonce, delta) {
|
|
|
65
65
|
throw new Error(`This encryptor has been used too many times. Further use may lead to duplication of nonces.`);
|
|
66
66
|
}
|
|
67
67
|
const c = await cryptor.formatWN.pack(m, nextNonce, key);
|
|
68
|
-
xsp_files_1.advanceNonce(nextNonce, delta);
|
|
68
|
+
(0, xsp_files_1.advanceNonce)(nextNonce, delta);
|
|
69
69
|
counter += 1;
|
|
70
70
|
return c;
|
|
71
71
|
},
|
|
@@ -101,7 +101,7 @@ function makeDecryptor(cryptor, key) {
|
|
|
101
101
|
if (key.length !== 32) {
|
|
102
102
|
throw new Error(`Key array key should have 32 elements (bytes) in it, but it is ${key.length} elements long.`);
|
|
103
103
|
}
|
|
104
|
-
key = buffer_utils_1.makeUint8ArrayCopy(key);
|
|
104
|
+
key = (0, buffer_utils_1.makeUint8ArrayCopy)(key);
|
|
105
105
|
const decryptor = {
|
|
106
106
|
open: (c) => {
|
|
107
107
|
if (!key) {
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
2
4
|
import * as fs from 'fs';
|
|
3
5
|
import { Readable, Writable } from 'stream';
|
|
4
6
|
export { Stats } from 'fs';
|
|
5
7
|
export { FileException } from './exceptions/file';
|
|
6
8
|
export declare function readFile(filename: string, options: {
|
|
7
|
-
encoding:
|
|
9
|
+
encoding: BufferEncoding;
|
|
8
10
|
flag?: string;
|
|
9
11
|
}): Promise<string>;
|
|
10
12
|
export declare function readFile(filename: string, options?: {
|
|
11
13
|
flag?: string;
|
|
12
14
|
}): Promise<Buffer>;
|
|
13
15
|
export declare function writeFile(path: string, data: any, options?: {
|
|
14
|
-
encoding?:
|
|
16
|
+
encoding?: BufferEncoding;
|
|
15
17
|
mode?: string;
|
|
16
18
|
flag?: string;
|
|
17
19
|
}): Promise<void>;
|
|
18
20
|
export declare function appendFile(path: string, data: any, options?: {
|
|
19
|
-
encoding?:
|
|
21
|
+
encoding?: BufferEncoding;
|
|
20
22
|
mode?: string;
|
|
21
23
|
flag?: string;
|
|
22
24
|
}): Promise<void>;
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.ensureFolderExists = exports.copyTree = exports.copyFile = exports.streamFromFile = exports.rmDirWithContent = exports.read = exports.streamToExistingFile = exports.append = exports.write = exports.getFolderContentSize = exports.getFileSize = exports.existsFileSync = exports.existsFolderSync = exports.existsFolder = exports.createEmptyFile = exports.writeFromBuf = exports.readToBuf = exports.ftruncate = exports.truncate = exports.rename = exports.unlink = exports.rmdir = exports.readdir = exports.fstat = exports.stat = exports.lstat = exports.readlink = exports.symlink = exports.close = exports.open = exports.mkdir = exports.appendFile = exports.writeFile = exports.readFile = void 0;
|
|
19
|
+
exports.ensureFolderExists = exports.copyTree = exports.copyFile = exports.streamFromFile = exports.rmDirWithContent = exports.read = exports.streamToExistingFile = exports.append = exports.write = exports.getFolderContentSize = exports.getFileSize = exports.existsFileSync = exports.existsFolderSync = exports.existsFolder = exports.createEmptyFile = exports.writeFromBuf = exports.readToBuf = exports.ftruncate = exports.truncate = exports.rename = exports.unlink = exports.rmdir = exports.readdir = exports.fstat = exports.stat = exports.lstat = exports.readlink = exports.symlink = exports.close = exports.open = exports.mkdir = exports.appendFile = exports.writeFile = exports.readFile = exports.Stats = void 0;
|
|
20
20
|
const fs = require("fs");
|
|
21
21
|
const fs_1 = require("fs");
|
|
22
22
|
const file_1 = require("./exceptions/file");
|
|
@@ -28,7 +28,7 @@ const path_1 = require("path");
|
|
|
28
28
|
var fs_2 = require("fs");
|
|
29
29
|
Object.defineProperty(exports, "Stats", { enumerable: true, get: function () { return fs_2.Stats; } });
|
|
30
30
|
function makeFileExceptionFromNodes(nodeExc) {
|
|
31
|
-
return file_1.makeFileException(nodeExc.code, nodeExc.path);
|
|
31
|
+
return (0, file_1.makeFileException)(nodeExc.code, nodeExc.path);
|
|
32
32
|
}
|
|
33
33
|
function readFile(path, options) {
|
|
34
34
|
return new Promise((resolve, reject) => {
|
|
@@ -307,7 +307,7 @@ async function readToBuf(fd, pos, buf) {
|
|
|
307
307
|
while (bytesRead < buf.length) {
|
|
308
308
|
const bNum = await readOrig(fd, buf, bytesRead, buf.length - bytesRead, pos);
|
|
309
309
|
if (bNum === 0) {
|
|
310
|
-
throw file_1.makeFileException(file_1.Code.endOfFile, '<file descriptor>');
|
|
310
|
+
throw (0, file_1.makeFileException)(file_1.Code.endOfFile, '<file descriptor>');
|
|
311
311
|
}
|
|
312
312
|
bytesRead += bNum;
|
|
313
313
|
pos += bNum;
|
|
@@ -379,7 +379,7 @@ async function existsFolder(path) {
|
|
|
379
379
|
return true;
|
|
380
380
|
}
|
|
381
381
|
else {
|
|
382
|
-
throw file_1.makeFileException(file_1.Code.notDirectory, path);
|
|
382
|
+
throw (0, file_1.makeFileException)(file_1.Code.notDirectory, path);
|
|
383
383
|
}
|
|
384
384
|
}
|
|
385
385
|
catch (e) {
|
|
@@ -396,11 +396,11 @@ exports.existsFolder = existsFolder;
|
|
|
396
396
|
*/
|
|
397
397
|
function existsFolderSync(path) {
|
|
398
398
|
try {
|
|
399
|
-
if (fs_1.statSync(path).isDirectory()) {
|
|
399
|
+
if ((0, fs_1.statSync)(path).isDirectory()) {
|
|
400
400
|
return true;
|
|
401
401
|
}
|
|
402
402
|
else {
|
|
403
|
-
throw file_1.makeFileException(file_1.Code.notDirectory, path);
|
|
403
|
+
throw (0, file_1.makeFileException)(file_1.Code.notDirectory, path);
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
406
|
catch (e) {
|
|
@@ -417,11 +417,11 @@ exports.existsFolderSync = existsFolderSync;
|
|
|
417
417
|
*/
|
|
418
418
|
function existsFileSync(path) {
|
|
419
419
|
try {
|
|
420
|
-
if (fs_1.statSync(path).isFile()) {
|
|
420
|
+
if ((0, fs_1.statSync)(path).isFile()) {
|
|
421
421
|
return true;
|
|
422
422
|
}
|
|
423
423
|
else {
|
|
424
|
-
throw file_1.makeFileException(file_1.Code.notFile, path);
|
|
424
|
+
throw (0, file_1.makeFileException)(file_1.Code.notFile, path);
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
427
|
catch (e) {
|
|
@@ -532,7 +532,7 @@ async function streamToExistingFile(filePath, pos, len, src, bufSize) {
|
|
|
532
532
|
let bytesWritten = 0;
|
|
533
533
|
let bytesRead = 0;
|
|
534
534
|
const buf = new bytes_fifo_buffer_1.BytesFIFOBuffer();
|
|
535
|
-
let deferred = deferred_1.defer();
|
|
535
|
+
let deferred = (0, deferred_1.defer)();
|
|
536
536
|
let doneReading = false;
|
|
537
537
|
const complete = (err) => {
|
|
538
538
|
if (!deferred) {
|
|
@@ -569,7 +569,7 @@ async function streamToExistingFile(filePath, pos, len, src, bufSize) {
|
|
|
569
569
|
if (!bytesToWrite) {
|
|
570
570
|
return;
|
|
571
571
|
}
|
|
572
|
-
await writeToExistingFile(filePath, pos, buffer_utils_1.toBuffer(bytesToWrite));
|
|
572
|
+
await writeToExistingFile(filePath, pos, (0, buffer_utils_1.toBuffer)(bytesToWrite));
|
|
573
573
|
pos += bytesToWrite.length;
|
|
574
574
|
bytesWritten += bytesToWrite.length;
|
|
575
575
|
if (bytesWritten < len) {
|
|
@@ -586,7 +586,7 @@ async function streamToExistingFile(filePath, pos, len, src, bufSize) {
|
|
|
586
586
|
if (doneReading) {
|
|
587
587
|
return;
|
|
588
588
|
}
|
|
589
|
-
complete(file_1.makeFileException(file_1.Code.endOfFile, '<input stream>'));
|
|
589
|
+
complete((0, file_1.makeFileException)(file_1.Code.endOfFile, '<input stream>'));
|
|
590
590
|
});
|
|
591
591
|
src.on('error', (err) => {
|
|
592
592
|
complete(err);
|
|
@@ -614,7 +614,7 @@ async function read(fd, pos, buf) {
|
|
|
614
614
|
while (bytesRead < buf.length) {
|
|
615
615
|
const bNum = await readOrig(fd, buf, bytesRead, buf.length - bytesRead, pos);
|
|
616
616
|
if (bNum === 0) {
|
|
617
|
-
throw file_1.makeFileException(file_1.Code.endOfFile, '<file descriptor>');
|
|
617
|
+
throw (0, file_1.makeFileException)(file_1.Code.endOfFile, '<file descriptor>');
|
|
618
618
|
}
|
|
619
619
|
bytesRead += bNum;
|
|
620
620
|
pos += bNum;
|
|
@@ -729,8 +729,8 @@ exports.streamFromFile = streamFromFile;
|
|
|
729
729
|
*/
|
|
730
730
|
function copyFile(src, dst, overwrite = false, dstMode = '660') {
|
|
731
731
|
return new Promise((resolve, reject) => {
|
|
732
|
-
const srcStream = fs_1.createReadStream(src);
|
|
733
|
-
const dstStream = fs_1.createWriteStream(dst, {
|
|
732
|
+
const srcStream = (0, fs_1.createReadStream)(src);
|
|
733
|
+
const dstStream = (0, fs_1.createWriteStream)(dst, {
|
|
734
734
|
mode: parseInt(dstMode, 8),
|
|
735
735
|
flags: (overwrite ? 'w' : 'wx')
|
|
736
736
|
});
|
|
@@ -773,8 +773,8 @@ async function copyTree(src, dst, fileOverwrite = false) {
|
|
|
773
773
|
const srcFNames = await readdir(src);
|
|
774
774
|
const cpTasks = [];
|
|
775
775
|
for (const fName of srcFNames) {
|
|
776
|
-
const srcPath = path_1.join(src, fName);
|
|
777
|
-
const dstPath = path_1.join(dst, fName);
|
|
776
|
+
const srcPath = (0, path_1.join)(src, fName);
|
|
777
|
+
const dstPath = (0, path_1.join)(dst, fName);
|
|
778
778
|
const task = stat(srcPath)
|
|
779
779
|
.then((stats) => {
|
|
780
780
|
if (stats.isFile()) {
|
|
@@ -29,7 +29,7 @@ const sink_utils_1 = require("../obj-streaming/sink-utils");
|
|
|
29
29
|
* Default value is 64K.
|
|
30
30
|
*/
|
|
31
31
|
async function pipe(src, sink, progressCB = undefined, closeSink = true, bufSize = 64 * 1024) {
|
|
32
|
-
const contSink = sink_utils_1.makeContinuousSink(sink);
|
|
32
|
+
const contSink = (0, sink_utils_1.makeContinuousSink)(sink);
|
|
33
33
|
try {
|
|
34
34
|
let buf = await src.read(bufSize);
|
|
35
35
|
let bytesPiped = 0;
|
|
@@ -21,11 +21,11 @@ const synced_1 = require("../processes/synced");
|
|
|
21
21
|
function wrapAndSyncFileSink(sink) {
|
|
22
22
|
const syncProc = new synced_1.SingleProc();
|
|
23
23
|
const w = {
|
|
24
|
-
done: synced_1.makeSyncedFunc(syncProc, sink, sink.done),
|
|
25
|
-
getSize: synced_1.makeSyncedFunc(syncProc, sink, sink.getSize),
|
|
26
|
-
showLayout: synced_1.makeSyncedFunc(syncProc, sink, sink.showLayout),
|
|
27
|
-
splice: synced_1.makeSyncedFunc(syncProc, sink, sink.splice),
|
|
28
|
-
truncate: synced_1.makeSyncedFunc(syncProc, sink, sink.truncate)
|
|
24
|
+
done: (0, synced_1.makeSyncedFunc)(syncProc, sink, sink.done),
|
|
25
|
+
getSize: (0, synced_1.makeSyncedFunc)(syncProc, sink, sink.getSize),
|
|
26
|
+
showLayout: (0, synced_1.makeSyncedFunc)(syncProc, sink, sink.showLayout),
|
|
27
|
+
splice: (0, synced_1.makeSyncedFunc)(syncProc, sink, sink.splice),
|
|
28
|
+
truncate: (0, synced_1.makeSyncedFunc)(syncProc, sink, sink.truncate)
|
|
29
29
|
};
|
|
30
30
|
return w;
|
|
31
31
|
}
|
|
@@ -33,10 +33,10 @@ exports.wrapAndSyncFileSink = wrapAndSyncFileSink;
|
|
|
33
33
|
function wrapAndSyncSource(src) {
|
|
34
34
|
const syncProc = new synced_1.SingleProc();
|
|
35
35
|
const w = {
|
|
36
|
-
getPosition: synced_1.makeSyncedFunc(syncProc, src, src.getPosition),
|
|
37
|
-
getSize: synced_1.makeSyncedFunc(syncProc, src, src.getSize),
|
|
38
|
-
read: synced_1.makeSyncedFunc(syncProc, src, src.read),
|
|
39
|
-
seek: synced_1.makeSyncedFunc(syncProc, src, src.seek)
|
|
36
|
+
getPosition: (0, synced_1.makeSyncedFunc)(syncProc, src, src.getPosition),
|
|
37
|
+
getSize: (0, synced_1.makeSyncedFunc)(syncProc, src, src.getSize),
|
|
38
|
+
read: (0, synced_1.makeSyncedFunc)(syncProc, src, src.read),
|
|
39
|
+
seek: (0, synced_1.makeSyncedFunc)(syncProc, src, src.seek)
|
|
40
40
|
};
|
|
41
41
|
return w;
|
|
42
42
|
}
|
|
@@ -44,10 +44,10 @@ exports.wrapAndSyncSource = wrapAndSyncSource;
|
|
|
44
44
|
function wrapAndSyncFileSource(src) {
|
|
45
45
|
const syncProc = new synced_1.SingleProc();
|
|
46
46
|
const w = {
|
|
47
|
-
getPosition: synced_1.makeSyncedFunc(syncProc, src, src.getPosition),
|
|
48
|
-
getSize: synced_1.makeSyncedFunc(syncProc, src, src.getSize),
|
|
49
|
-
read: synced_1.makeSyncedFunc(syncProc, src, src.read),
|
|
50
|
-
seek: synced_1.makeSyncedFunc(syncProc, src, src.seek),
|
|
47
|
+
getPosition: (0, synced_1.makeSyncedFunc)(syncProc, src, src.getPosition),
|
|
48
|
+
getSize: (0, synced_1.makeSyncedFunc)(syncProc, src, src.getSize),
|
|
49
|
+
read: (0, synced_1.makeSyncedFunc)(syncProc, src, src.read),
|
|
50
|
+
seek: (0, synced_1.makeSyncedFunc)(syncProc, src, src.seek),
|
|
51
51
|
};
|
|
52
52
|
return w;
|
|
53
53
|
}
|
|
@@ -2,4 +2,5 @@ export interface ErrorWithCause extends Error {
|
|
|
2
2
|
cause: any;
|
|
3
3
|
}
|
|
4
4
|
export declare function errWithCause(cause: any, message: string): ErrorWithCause;
|
|
5
|
+
export declare function recursiveErrJSONify(err: web3n.RuntimeException): any;
|
|
5
6
|
export declare function stringifyErr(err: any): string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2016 - 2017, 2020 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2016 - 2017, 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
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
You should have received a copy of the GNU General Public License along with
|
|
16
16
|
this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.stringifyErr = exports.errWithCause = void 0;
|
|
18
|
+
exports.stringifyErr = exports.recursiveErrJSONify = exports.errWithCause = void 0;
|
|
19
19
|
function errWithCause(cause, message) {
|
|
20
20
|
const err = new Error(message);
|
|
21
21
|
err.cause = cause;
|
|
@@ -25,13 +25,13 @@ function errWithCause(cause, message) {
|
|
|
25
25
|
return err;
|
|
26
26
|
}
|
|
27
27
|
exports.errWithCause = errWithCause;
|
|
28
|
-
function
|
|
28
|
+
function recursiveErrJSONify(err) {
|
|
29
29
|
if (!err || (typeof err !== 'object') || Array.isArray(err)) {
|
|
30
30
|
return err;
|
|
31
31
|
}
|
|
32
32
|
else if (err.runtimeException) {
|
|
33
33
|
if (err.cause) {
|
|
34
|
-
err.cause =
|
|
34
|
+
err.cause = recursiveErrJSONify(err.cause);
|
|
35
35
|
}
|
|
36
36
|
return err;
|
|
37
37
|
}
|
|
@@ -41,16 +41,17 @@ function recursiveJSONify(err) {
|
|
|
41
41
|
stack: err.stack
|
|
42
42
|
};
|
|
43
43
|
if (err.cause) {
|
|
44
|
-
jsonErr.cause =
|
|
44
|
+
jsonErr.cause = recursiveErrJSONify(err.cause);
|
|
45
45
|
}
|
|
46
46
|
return jsonErr;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
+
exports.recursiveErrJSONify = recursiveErrJSONify;
|
|
49
50
|
function stringifyErr(err) {
|
|
50
51
|
if (!err) {
|
|
51
52
|
return '';
|
|
52
53
|
}
|
|
53
|
-
let json =
|
|
54
|
+
let json = recursiveErrJSONify(err);
|
|
54
55
|
let errStr;
|
|
55
56
|
if (!json || (typeof json !== 'object') || err.runtimeException) {
|
|
56
57
|
try {
|
|
@@ -34,6 +34,7 @@ exports.Code = {
|
|
|
34
34
|
notImplemented: 'ENOSYS',
|
|
35
35
|
isEndless: 'is-endless',
|
|
36
36
|
storageClosed: 'storage-closed',
|
|
37
|
+
versionMismatch: 'version-mismatch',
|
|
37
38
|
};
|
|
38
39
|
Object.freeze(exports.Code);
|
|
39
40
|
function makeFileException(code, path, cause) {
|
|
@@ -92,6 +93,9 @@ function makeFileException(code, path, cause) {
|
|
|
92
93
|
else if (code === exports.Code.storageClosed) {
|
|
93
94
|
err.storageClosed = true;
|
|
94
95
|
}
|
|
96
|
+
else if (code === exports.Code.versionMismatch) {
|
|
97
|
+
err.versionMismatch = true;
|
|
98
|
+
}
|
|
95
99
|
return err;
|
|
96
100
|
}
|
|
97
101
|
exports.makeFileException = makeFileException;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
You should have received a copy of the GNU General Public License along with
|
|
16
16
|
this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.makeSubscriber = void 0;
|
|
18
|
+
exports.makeSubscriber = exports.makeEventfulServer = void 0;
|
|
19
19
|
const generic_ipc_1 = require("./generic-ipc");
|
|
20
20
|
var generic_ipc_2 = require("./generic-ipc");
|
|
21
21
|
Object.defineProperty(exports, "makeEventfulServer", { enumerable: true, get: function () { return generic_ipc_2.makeEventfulServer; } });
|
|
@@ -111,7 +111,7 @@ function onError(ws, observers) {
|
|
|
111
111
|
}
|
|
112
112
|
function makeSubscriber(ws, ipcChannel) {
|
|
113
113
|
const comm = makeJsonCommPoint(ws);
|
|
114
|
-
return generic_ipc_1.makeSubscribingClient(ipcChannel, comm);
|
|
114
|
+
return (0, generic_ipc_1.makeSubscribingClient)(ipcChannel, comm);
|
|
115
115
|
}
|
|
116
116
|
exports.makeSubscriber = makeSubscriber;
|
|
117
117
|
Object.freeze(exports);
|
|
@@ -132,7 +132,7 @@ var idProvider;
|
|
|
132
132
|
idProvider.KID_BYTES_LENGTH = 9;
|
|
133
133
|
idProvider.MAX_USER_CERT_VALIDITY = 24 * 60 * 60;
|
|
134
134
|
function makeSelfSignedCert(address, validityPeriod, sjkey, arrFactory) {
|
|
135
|
-
const skey = jwkeys_1.keyFromJson(sjkey, exports.KEY_USE.ROOT, ecma_nacl_1.signing.JWK_ALG_NAME, ecma_nacl_1.signing.SECRET_KEY_LENGTH);
|
|
135
|
+
const skey = (0, jwkeys_1.keyFromJson)(sjkey, exports.KEY_USE.ROOT, ecma_nacl_1.signing.JWK_ALG_NAME, ecma_nacl_1.signing.SECRET_KEY_LENGTH);
|
|
136
136
|
const pkey = {
|
|
137
137
|
use: sjkey.use,
|
|
138
138
|
alg: sjkey.alg,
|
|
@@ -161,7 +161,7 @@ var idProvider;
|
|
|
161
161
|
const rootPair = genSignKeyPair(exports.KEY_USE.ROOT, idProvider.KID_BYTES_LENGTH, random, arrFactory);
|
|
162
162
|
const now = Math.floor(Date.now() / 1000);
|
|
163
163
|
const rootCert = makeCert(rootPair.pkey, address, address, now, now + validityPeriod, rootPair.skey, arrFactory);
|
|
164
|
-
return { cert: rootCert, skey: jwkeys_1.keyToJson(rootPair.skey) };
|
|
164
|
+
return { cert: rootCert, skey: (0, jwkeys_1.keyToJson)(rootPair.skey) };
|
|
165
165
|
}
|
|
166
166
|
idProvider.generateRootKey = generateRootKey;
|
|
167
167
|
/**
|
|
@@ -178,11 +178,11 @@ var idProvider;
|
|
|
178
178
|
if (validityPeriod < 1) {
|
|
179
179
|
throw new Error(`Illegal validity period: ${validityPeriod}`);
|
|
180
180
|
}
|
|
181
|
-
const rootKey = jwkeys_1.keyFromJson(rootJKey, exports.KEY_USE.ROOT, ecma_nacl_1.signing.JWK_ALG_NAME, ecma_nacl_1.signing.SECRET_KEY_LENGTH);
|
|
181
|
+
const rootKey = (0, jwkeys_1.keyFromJson)(rootJKey, exports.KEY_USE.ROOT, ecma_nacl_1.signing.JWK_ALG_NAME, ecma_nacl_1.signing.SECRET_KEY_LENGTH);
|
|
182
182
|
const provPair = genSignKeyPair(exports.KEY_USE.PROVIDER, idProvider.KID_BYTES_LENGTH, random, arrFactory);
|
|
183
183
|
const now = Math.floor(Date.now() / 1000);
|
|
184
184
|
const rootCert = makeCert(provPair.pkey, address, address, now, now + validityPeriod, rootKey, arrFactory);
|
|
185
|
-
return { cert: rootCert, skey: jwkeys_1.keyToJson(provPair.skey) };
|
|
185
|
+
return { cert: rootCert, skey: (0, jwkeys_1.keyToJson)(provPair.skey) };
|
|
186
186
|
}
|
|
187
187
|
idProvider.generateProviderKey = generateProviderKey;
|
|
188
188
|
/**
|
|
@@ -202,7 +202,7 @@ var idProvider;
|
|
|
202
202
|
if ((validityPeriod < 1) || (validityPeriod > idProvider.MAX_USER_CERT_VALIDITY)) {
|
|
203
203
|
throw new Error(`Given certificate validity is illegal: ${validityPeriod}`);
|
|
204
204
|
}
|
|
205
|
-
let signKey = jwkeys_1.keyFromJson(signJKey, exports.KEY_USE.PROVIDER, ecma_nacl_1.signing.JWK_ALG_NAME, ecma_nacl_1.signing.SECRET_KEY_LENGTH);
|
|
205
|
+
let signKey = (0, jwkeys_1.keyFromJson)(signJKey, exports.KEY_USE.PROVIDER, ecma_nacl_1.signing.JWK_ALG_NAME, ecma_nacl_1.signing.SECRET_KEY_LENGTH);
|
|
206
206
|
signJKey = undefined;
|
|
207
207
|
if (!arrFactory) {
|
|
208
208
|
arrFactory = ecma_nacl_1.arrays.makeFactory();
|
|
@@ -247,7 +247,7 @@ var relyingParty;
|
|
|
247
247
|
(function (relyingParty) {
|
|
248
248
|
const minValidityPeriodForCert = 20 * 60;
|
|
249
249
|
function verifyCertAndGetPubKey(signedCert, use, validAt, arrFactory, issuer, issuerPKey) {
|
|
250
|
-
const cert = jwkeys_1.getKeyCert(signedCert);
|
|
250
|
+
const cert = (0, jwkeys_1.getKeyCert)(signedCert);
|
|
251
251
|
if ((validAt < (cert.issuedAt - minValidityPeriodForCert))
|
|
252
252
|
|| (cert.expiresAt <= validAt)) {
|
|
253
253
|
throw makeTimeMismatchException(`Certificate is not valid at a given moment ${validAt}, cause it is issued at ${cert.issuedAt}, and expires at ${cert.expiresAt}`);
|
|
@@ -265,7 +265,7 @@ var relyingParty;
|
|
|
265
265
|
let sig;
|
|
266
266
|
let load;
|
|
267
267
|
try {
|
|
268
|
-
pkey = jwkeys_1.keyFromJson(cert.cert.publicKey, use, ecma_nacl_1.signing.JWK_ALG_NAME, ecma_nacl_1.signing.PUBLIC_KEY_LENGTH);
|
|
268
|
+
pkey = (0, jwkeys_1.keyFromJson)(cert.cert.publicKey, use, ecma_nacl_1.signing.JWK_ALG_NAME, ecma_nacl_1.signing.PUBLIC_KEY_LENGTH);
|
|
269
269
|
sig = buffer_utils_1.base64.open(signedCert.sig);
|
|
270
270
|
load = buffer_utils_1.base64.open(signedCert.load);
|
|
271
271
|
}
|
|
@@ -292,7 +292,7 @@ var relyingParty;
|
|
|
292
292
|
// root certificate must be valid when provider's certificate was issued
|
|
293
293
|
let rootValidityMoment;
|
|
294
294
|
try {
|
|
295
|
-
rootValidityMoment = jwkeys_1.getKeyCert(certs.prov).issuedAt;
|
|
295
|
+
rootValidityMoment = (0, jwkeys_1.getKeyCert)(certs.prov).issuedAt;
|
|
296
296
|
}
|
|
297
297
|
catch (err) {
|
|
298
298
|
throw makeMalformedCertsException(`Provider's certificate is malformed`, err);
|
|
@@ -305,7 +305,7 @@ var relyingParty;
|
|
|
305
305
|
// provider's certificate must be valid when user's certificate was issued
|
|
306
306
|
let provValidityMoment;
|
|
307
307
|
try {
|
|
308
|
-
provValidityMoment = jwkeys_1.getKeyCert(certs.user).issuedAt;
|
|
308
|
+
provValidityMoment = (0, jwkeys_1.getKeyCert)(certs.user).issuedAt;
|
|
309
309
|
}
|
|
310
310
|
catch (err) {
|
|
311
311
|
throw makeMalformedCertsException(`User's certificate is malformed`, err);
|
|
@@ -389,7 +389,7 @@ var relyingParty;
|
|
|
389
389
|
}
|
|
390
390
|
let cert;
|
|
391
391
|
try {
|
|
392
|
-
cert = jwkeys_1.getKeyCert(keyCert);
|
|
392
|
+
cert = (0, jwkeys_1.getKeyCert)(keyCert);
|
|
393
393
|
}
|
|
394
394
|
catch (err) {
|
|
395
395
|
throw makeMalformedCertsException(`Cannot read certificate`, err);
|
|
@@ -428,7 +428,7 @@ var relyingParty;
|
|
|
428
428
|
// time moment, for which user's certificate chain must be valid
|
|
429
429
|
let chainValidityMoment;
|
|
430
430
|
try {
|
|
431
|
-
chainValidityMoment = jwkeys_1.getKeyCert(pubKeyCert).issuedAt;
|
|
431
|
+
chainValidityMoment = (0, jwkeys_1.getKeyCert)(pubKeyCert).issuedAt;
|
|
432
432
|
}
|
|
433
433
|
catch (err) {
|
|
434
434
|
throw makeMalformedCertsException(`Cannot read certificate`, err);
|
|
@@ -443,11 +443,11 @@ var relyingParty;
|
|
|
443
443
|
})(relyingParty = exports.relyingParty || (exports.relyingParty = {}));
|
|
444
444
|
Object.freeze(relyingParty);
|
|
445
445
|
function correlateSKeyWithItsCert(skey, cert) {
|
|
446
|
-
const pkey = jwkeys_1.keyFromJson(cert.cert.publicKey, skey.use, ecma_nacl_1.signing.JWK_ALG_NAME, ecma_nacl_1.signing.PUBLIC_KEY_LENGTH);
|
|
446
|
+
const pkey = (0, jwkeys_1.keyFromJson)(cert.cert.publicKey, skey.use, ecma_nacl_1.signing.JWK_ALG_NAME, ecma_nacl_1.signing.PUBLIC_KEY_LENGTH);
|
|
447
447
|
if (!((pkey.kid === skey.kid)
|
|
448
448
|
&& (pkey.use === skey.use)
|
|
449
449
|
&& (pkey.alg === skey.alg)
|
|
450
|
-
&& ecma_nacl_1.compareVectors(ecma_nacl_1.signing.extract_pkey(skey.k), pkey.k))) {
|
|
450
|
+
&& (0, ecma_nacl_1.compareVectors)(ecma_nacl_1.signing.extract_pkey(skey.k), pkey.k))) {
|
|
451
451
|
throw new Error("Key does not correspond to certificate.");
|
|
452
452
|
}
|
|
453
453
|
}
|
|
@@ -471,7 +471,7 @@ var user;
|
|
|
471
471
|
* keys.
|
|
472
472
|
*/
|
|
473
473
|
function makeMailerIdSigner(signKey, userCert, provCert, assertionValidity = user.MAX_SIG_VALIDITY, arrFactory) {
|
|
474
|
-
const certificate = jwkeys_1.getKeyCert(userCert);
|
|
474
|
+
const certificate = (0, jwkeys_1.getKeyCert)(userCert);
|
|
475
475
|
if (signKey.use !== exports.KEY_USE.SIGN) {
|
|
476
476
|
throw new Error(`Given key ${signKey.kid} has incorrect use: ${signKey.use}`);
|
|
477
477
|
}
|