proto.io 0.0.227 → 0.0.228
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/dist/adapters/file/aliyun-oss.d.ts +3 -3
- package/dist/adapters/file/database.d.ts +2 -2
- package/dist/adapters/file/filesystem.d.ts +3 -3
- package/dist/adapters/file/google-cloud-storage.d.ts +3 -3
- package/dist/adapters/storage/postgres.d.ts +1 -1
- package/dist/client.d.ts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +18 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -18
- package/dist/index.mjs.map +1 -1
- package/dist/internals/{base-DSo02iAX.d.ts → base-CW4QHAo3.d.ts} +2 -2
- package/dist/internals/{base-DSo02iAX.d.ts.map → base-CW4QHAo3.d.ts.map} +1 -1
- package/dist/internals/{chunk-BhwfdCdq.d.ts → chunk-DPgxK2_o.d.ts} +3 -3
- package/dist/internals/{chunk-BhwfdCdq.d.ts.map → chunk-DPgxK2_o.d.ts.map} +1 -1
- package/dist/internals/index-BWZIV3_T.mjs.map +1 -1
- package/dist/internals/{index-Cj45GkKv.d.ts → index-CywcwPk-.d.ts} +2 -2
- package/dist/internals/{index-Cj45GkKv.d.ts.map → index-CywcwPk-.d.ts.map} +1 -1
- package/dist/internals/{index-1ZK5N4yb.d.ts → index-h4KGKuhq.d.ts} +5 -5
- package/dist/internals/{index-1ZK5N4yb.d.ts.map → index-h4KGKuhq.d.ts.map} +1 -1
- package/dist/internals/index-vOFh8pVc.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { P as ProtoService } from '../../internals/index-
|
|
1
|
+
import { P as ProtoService } from '../../internals/index-h4KGKuhq.js';
|
|
2
2
|
import OSS from 'ali-oss';
|
|
3
|
-
import { a as FileStorageOptions } from '../../internals/base-
|
|
4
|
-
import { F as FileChunkStorageBase } from '../../internals/chunk-
|
|
3
|
+
import { a as FileStorageOptions } from '../../internals/base-CW4QHAo3.js';
|
|
4
|
+
import { F as FileChunkStorageBase } from '../../internals/chunk-DPgxK2_o.js';
|
|
5
5
|
import '@o2ter/utils-js';
|
|
6
6
|
import 'jsonwebtoken';
|
|
7
7
|
import '@o2ter/server-js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as TSchema, P as ProtoService } from '../../internals/index-
|
|
2
|
-
import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/base-
|
|
1
|
+
import { T as TSchema, P as ProtoService } from '../../internals/index-h4KGKuhq.js';
|
|
2
|
+
import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/base-CW4QHAo3.js';
|
|
3
3
|
import '@o2ter/utils-js';
|
|
4
4
|
import 'jsonwebtoken';
|
|
5
5
|
import '@o2ter/server-js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProtoService } from '../../internals/index-
|
|
2
|
-
import { a as FileStorageOptions } from '../../internals/base-
|
|
3
|
-
import { F as FileChunkStorageBase } from '../../internals/chunk-
|
|
1
|
+
import { P as ProtoService } from '../../internals/index-h4KGKuhq.js';
|
|
2
|
+
import { a as FileStorageOptions } from '../../internals/base-CW4QHAo3.js';
|
|
3
|
+
import { F as FileChunkStorageBase } from '../../internals/chunk-DPgxK2_o.js';
|
|
4
4
|
import '@o2ter/utils-js';
|
|
5
5
|
import 'jsonwebtoken';
|
|
6
6
|
import '@o2ter/server-js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as _google_cloud_storage from '@google-cloud/storage';
|
|
2
2
|
import { File, Storage } from '@google-cloud/storage';
|
|
3
|
-
import { P as ProtoService } from '../../internals/index-
|
|
4
|
-
import { a as FileStorageOptions } from '../../internals/base-
|
|
5
|
-
import { F as FileChunkStorageBase } from '../../internals/chunk-
|
|
3
|
+
import { P as ProtoService } from '../../internals/index-h4KGKuhq.js';
|
|
4
|
+
import { a as FileStorageOptions } from '../../internals/base-CW4QHAo3.js';
|
|
5
|
+
import { F as FileChunkStorageBase } from '../../internals/chunk-DPgxK2_o.js';
|
|
6
6
|
import '@o2ter/utils-js';
|
|
7
7
|
import 'jsonwebtoken';
|
|
8
8
|
import '@o2ter/server-js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Pool, PoolClient, PoolConfig } from 'pg';
|
|
2
|
-
import { c as TValueWithoutObject, T as TSchema, q as TValueWithUndefined, r as TValue, t as TUpdateOp, F as FieldSelectorExpression, Q as QueryExpression, R as RelationOptions, u as QuerySelector, v as DecodedQuery, w as FindOptions, x as DecodedSortOption, y as QueryAccumulator, I as InsertOptions, z as TStorage, A as TransactionOptions, k as TObject, B as QueryRandomOptions, C as TPubSub } from '../../internals/index-
|
|
2
|
+
import { c as TValueWithoutObject, T as TSchema, q as TValueWithUndefined, r as TValue, t as TUpdateOp, F as FieldSelectorExpression, Q as QueryExpression, R as RelationOptions, u as QuerySelector, v as DecodedQuery, w as FindOptions, x as DecodedSortOption, y as QueryAccumulator, I as InsertOptions, z as TStorage, A as TransactionOptions, k as TObject, B as QueryRandomOptions, C as TPubSub } from '../../internals/index-h4KGKuhq.js';
|
|
3
3
|
import * as _o2ter_utils_js from '@o2ter/utils-js';
|
|
4
4
|
import { asyncStream } from '@o2ter/utils-js';
|
|
5
5
|
import 'jsonwebtoken';
|
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProtoClient } from './internals/index-
|
|
2
|
-
export { c as classExtends } from './internals/index-
|
|
3
|
-
export { D as DeserializeOptions, S as SerializeOptions, e as TNumber, f as TSerializable, g as deserialize, s as serialize } from './internals/index-
|
|
1
|
+
import { P as ProtoClient } from './internals/index-CywcwPk-.js';
|
|
2
|
+
export { c as classExtends } from './internals/index-CywcwPk-.js';
|
|
3
|
+
export { D as DeserializeOptions, S as SerializeOptions, e as TNumber, f as TSerializable, g as deserialize, s as serialize } from './internals/index-h4KGKuhq.js';
|
|
4
4
|
export { Decimal } from 'decimal.js';
|
|
5
5
|
import '@o2ter/utils-js';
|
|
6
6
|
import 'socket.io-client';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as socket_io from 'socket.io';
|
|
2
2
|
import { Router } from 'express';
|
|
3
3
|
import { Server } from '@o2ter/server-js';
|
|
4
|
-
import { P as ProtoService, a as ProtoServiceOptions, b as ProtoServiceKeyOptions, T as TSchema, c as TValueWithoutObject } from './internals/index-
|
|
5
|
-
export { D as DeserializeOptions, S as SerializeOptions, d as TFileStorage, e as TNumber, f as TSerializable, g as deserialize, s as serialize } from './internals/index-
|
|
4
|
+
import { P as ProtoService, a as ProtoServiceOptions, b as ProtoServiceKeyOptions, T as TSchema, c as TValueWithoutObject } from './internals/index-h4KGKuhq.js';
|
|
5
|
+
export { D as DeserializeOptions, S as SerializeOptions, d as TFileStorage, e as TNumber, f as TSerializable, g as deserialize, s as serialize } from './internals/index-h4KGKuhq.js';
|
|
6
6
|
import Decimal from 'decimal.js';
|
|
7
7
|
export { Decimal } from 'decimal.js';
|
|
8
|
-
export { P as ProtoClient, c as classExtends } from './internals/index-
|
|
8
|
+
export { P as ProtoClient, c as classExtends } from './internals/index-CywcwPk-.js';
|
|
9
9
|
import '@o2ter/utils-js';
|
|
10
10
|
import 'jsonwebtoken';
|
|
11
11
|
import 'lodash';
|
package/dist/index.js
CHANGED
|
@@ -704,7 +704,7 @@ const passwordHash = async (alg, password, options) => {
|
|
|
704
704
|
...options
|
|
705
705
|
};
|
|
706
706
|
};
|
|
707
|
-
const
|
|
707
|
+
const verifyPassword = async (alg, password, options) => {
|
|
708
708
|
if (!_.isString(options.salt))
|
|
709
709
|
return false;
|
|
710
710
|
if (!_.isString(options.derivedKey))
|
|
@@ -901,7 +901,7 @@ class ProtoInternal {
|
|
|
901
901
|
}
|
|
902
902
|
return callback(proxy(payload ?? proto));
|
|
903
903
|
}
|
|
904
|
-
async
|
|
904
|
+
async verifyPassword(proto, user, password, options) {
|
|
905
905
|
if (!user.id)
|
|
906
906
|
throw Error('Invalid user object');
|
|
907
907
|
const _user = await proto.InsecureQuery('User')
|
|
@@ -909,7 +909,7 @@ class ProtoInternal {
|
|
|
909
909
|
.includes('_id', 'password')
|
|
910
910
|
.first(options);
|
|
911
911
|
const { alg, ...opts } = _user?.get('password') ?? {};
|
|
912
|
-
return
|
|
912
|
+
return verifyPassword(alg, password, opts);
|
|
913
913
|
}
|
|
914
914
|
async setPassword(proto, user, password, options) {
|
|
915
915
|
if (!user.id)
|
|
@@ -950,8 +950,8 @@ class ProtoInternal {
|
|
|
950
950
|
}
|
|
951
951
|
return object;
|
|
952
952
|
}
|
|
953
|
-
|
|
954
|
-
const { nonce, attributes, maxUploadSize, } = (_.isString(token) ? this.
|
|
953
|
+
verifyUploadToken(proto, token, isMaster) {
|
|
954
|
+
const { nonce, attributes, maxUploadSize, } = (_.isString(token) ? this.jwtVerify(token, 'upload') ?? {} : {});
|
|
955
955
|
if (!isMaster && !nonce)
|
|
956
956
|
throw Error('Upload token is required');
|
|
957
957
|
return {
|
|
@@ -964,7 +964,7 @@ class ProtoInternal {
|
|
|
964
964
|
const data = object[_private.PVK].extra.data;
|
|
965
965
|
if (_.isNil(data))
|
|
966
966
|
throw Error('Invalid file object');
|
|
967
|
-
const { nonce, attributes = {}, maxUploadSize = this.options.maxUploadSize, } = options?.uploadToken ? this.
|
|
967
|
+
const { nonce, attributes = {}, maxUploadSize = this.options.maxUploadSize, } = options?.uploadToken ? this.verifyUploadToken(proto, options.uploadToken, options.master) : {};
|
|
968
968
|
if (nonce) {
|
|
969
969
|
const found = await proto.Query('File').equalTo('nonce', nonce).first({ master: true });
|
|
970
970
|
if (found)
|
|
@@ -1071,7 +1071,7 @@ class ProtoInternal {
|
|
|
1071
1071
|
})();
|
|
1072
1072
|
return jwt.sign(payload, this.options.jwtToken, opts);
|
|
1073
1073
|
}
|
|
1074
|
-
|
|
1074
|
+
jwtVerify(token, options = {}) {
|
|
1075
1075
|
try {
|
|
1076
1076
|
const opts = (() => {
|
|
1077
1077
|
switch (options) {
|
|
@@ -1207,7 +1207,7 @@ class ProtoInternal {
|
|
|
1207
1207
|
obj.set('data', params);
|
|
1208
1208
|
obj.set('user', user);
|
|
1209
1209
|
await obj.save({ master: true });
|
|
1210
|
-
this.jobRunner.
|
|
1210
|
+
this.jobRunner.executeJob(proto);
|
|
1211
1211
|
return obj;
|
|
1212
1212
|
}
|
|
1213
1213
|
}
|
|
@@ -1269,7 +1269,7 @@ class JobRunner {
|
|
|
1269
1269
|
job.set('completedAt', new Date());
|
|
1270
1270
|
await job.save({ master: true });
|
|
1271
1271
|
}
|
|
1272
|
-
async
|
|
1272
|
+
async executeJob(proto) {
|
|
1273
1273
|
if (this._running || this._stopped)
|
|
1274
1274
|
return;
|
|
1275
1275
|
this._running = true;
|
|
@@ -1299,7 +1299,7 @@ class JobRunner {
|
|
|
1299
1299
|
finally {
|
|
1300
1300
|
clearInterval(timer);
|
|
1301
1301
|
}
|
|
1302
|
-
this.
|
|
1302
|
+
this.executeJob(proto);
|
|
1303
1303
|
})();
|
|
1304
1304
|
}
|
|
1305
1305
|
this._running = false;
|
|
@@ -1333,7 +1333,7 @@ class JobRunner {
|
|
|
1333
1333
|
const _sessionWithToken = async (proto, token) => {
|
|
1334
1334
|
if (_.isEmpty(token))
|
|
1335
1335
|
return;
|
|
1336
|
-
const payload = proto[_private.PVK].
|
|
1336
|
+
const payload = proto[_private.PVK].jwtVerify(token, 'login') ?? {};
|
|
1337
1337
|
if (!_.isString(payload.sessionId) || _.isEmpty(payload.sessionId))
|
|
1338
1338
|
return;
|
|
1339
1339
|
const session = await proto.Query('_Session')
|
|
@@ -1492,8 +1492,8 @@ const scheduleOp = {
|
|
|
1492
1492
|
expireDocument: async (proto) => {
|
|
1493
1493
|
await proto.gc();
|
|
1494
1494
|
},
|
|
1495
|
-
|
|
1496
|
-
proto[_private.PVK].jobRunner.
|
|
1495
|
+
executeJob: async (proto) => {
|
|
1496
|
+
proto[_private.PVK].jobRunner.executeJob(proto);
|
|
1497
1497
|
},
|
|
1498
1498
|
};
|
|
1499
1499
|
const schedule = (proto) => {
|
|
@@ -1702,8 +1702,8 @@ class ProtoService extends index.ProtoType {
|
|
|
1702
1702
|
if (req.res)
|
|
1703
1703
|
await signUser(this, req.res, undefined, options);
|
|
1704
1704
|
}
|
|
1705
|
-
|
|
1706
|
-
return this[_private.PVK].
|
|
1705
|
+
verifyPassword(user, password, options) {
|
|
1706
|
+
return this[_private.PVK].verifyPassword(this, user, password, options);
|
|
1707
1707
|
}
|
|
1708
1708
|
setPassword(user, password, options) {
|
|
1709
1709
|
return this[_private.PVK].setPassword(this, user, password, options);
|
|
@@ -1790,8 +1790,8 @@ class ProtoService extends index.ProtoType {
|
|
|
1790
1790
|
jwtSign(payload, options) {
|
|
1791
1791
|
return this[_private.PVK].jwtSign(payload, options);
|
|
1792
1792
|
}
|
|
1793
|
-
|
|
1794
|
-
return this[_private.PVK].
|
|
1793
|
+
jwtVerify(token, options = {}) {
|
|
1794
|
+
return this[_private.PVK].jwtVerify(token, options);
|
|
1795
1795
|
}
|
|
1796
1796
|
notify(data) {
|
|
1797
1797
|
return this[_private.PVK].notify(this, data);
|
|
@@ -2284,7 +2284,7 @@ var filesRoute = (router, proto) => {
|
|
|
2284
2284
|
await response(res, async () => {
|
|
2285
2285
|
const payload = proto.connect(req);
|
|
2286
2286
|
const uploadToken = req.header(_const.UPLOAD_TOKEN_HEADER_NAME);
|
|
2287
|
-
const { maxUploadSize } = payload[_private.PVK].
|
|
2287
|
+
const { maxUploadSize } = payload[_private.PVK].verifyUploadToken(payload, uploadToken, payload.isMaster);
|
|
2288
2288
|
const { attributes, file } = await decodeFormStream(req, (file, info) => proto.fileStorage.create(proto, file, info, maxUploadSize));
|
|
2289
2289
|
try {
|
|
2290
2290
|
const obj = payload.Object('File');
|