@riocrypto/common-server 1.0.1212 → 1.0.1214

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.
@@ -0,0 +1,3 @@
1
+ import { User } from "@riocrypto/common";
2
+ import { Request } from "express";
3
+ export declare const canAccessUser: (userToAccess: User, req: Request) => boolean;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.canAccessUser = void 0;
4
+ const canAccessUser = (userToAccess, req) => {
5
+ var _a, _b;
6
+ if (!req.admin &&
7
+ userToAccess.id !== ((_a = req.user) === null || _a === void 0 ? void 0 : _a.id) &&
8
+ userToAccess.brokerId !== ((_b = req.user) === null || _b === void 0 ? void 0 : _b.id)) {
9
+ return false;
10
+ }
11
+ else {
12
+ return true;
13
+ }
14
+ };
15
+ exports.canAccessUser = canAccessUser;
package/build/index.d.ts CHANGED
@@ -64,4 +64,5 @@ export * from "./helpers/get-network-fees";
64
64
  export * from "./helpers/calculate-aggregate-volume-and-revenue";
65
65
  export * from "./helpers/calculate-weekly-volume-and-revenue";
66
66
  export * from "./helpers/get-exchange-rates";
67
+ export * from "./helpers/can-access-user";
67
68
  export * from "./helpers/unescape";
package/build/index.js CHANGED
@@ -80,4 +80,5 @@ __exportStar(require("./helpers/get-network-fees"), exports);
80
80
  __exportStar(require("./helpers/calculate-aggregate-volume-and-revenue"), exports);
81
81
  __exportStar(require("./helpers/calculate-weekly-volume-and-revenue"), exports);
82
82
  __exportStar(require("./helpers/get-exchange-rates"), exports);
83
+ __exportStar(require("./helpers/can-access-user"), exports);
83
84
  __exportStar(require("./helpers/unescape"), exports);
@@ -1,15 +1,20 @@
1
+ import { APIKey } from "@riocrypto/common";
1
2
  import { Mongoose, Model, Document } from "mongoose";
2
3
  interface AdminAuthAttrs {
3
4
  email: string;
4
5
  password: string;
5
6
  previousPasswords?: string[];
6
7
  authenticatorSecret?: string;
8
+ apiKeys?: APIKey[];
9
+ isDisabled?: boolean;
7
10
  }
8
11
  interface AdminAuthDoc extends Document {
9
12
  email: string;
10
13
  password: string;
11
14
  previousPasswords?: string[];
12
15
  authenticatorSecret?: string;
16
+ apiKeys?: APIKey[];
17
+ isDisabled?: boolean;
13
18
  }
14
19
  interface AdminAuthModel extends Model<AdminAuthDoc> {
15
20
  build(attrs: AdminAuthAttrs): AdminAuthDoc;
@@ -34,6 +34,24 @@ const buildAdminAuth = (mongoose) => {
34
34
  authenticatorSecret: {
35
35
  type: String,
36
36
  },
37
+ isDisabled: {
38
+ type: Boolean,
39
+ },
40
+ apiKeys: [
41
+ {
42
+ value: {
43
+ type: String,
44
+ required: true,
45
+ },
46
+ label: {
47
+ type: String,
48
+ },
49
+ id: {
50
+ type: String,
51
+ required: true,
52
+ },
53
+ },
54
+ ],
37
55
  }, {
38
56
  toJSON: {
39
57
  transform(doc, ret) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.1212",
3
+ "version": "1.0.1214",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -26,7 +26,7 @@
26
26
  "@aws-sdk/client-s3": "^3.297.0",
27
27
  "@everapi/currencyapi-js": "^1.0.6",
28
28
  "@google-cloud/storage": "^6.9.5",
29
- "@riocrypto/common": "^1.0.1109",
29
+ "@riocrypto/common": "^1.0.1111",
30
30
  "@types/express": "^4.17.13",
31
31
  "axios": "^0.27.2",
32
32
  "ccxt": "^3.0.30",