@riocrypto/common-server 1.0.968 → 1.0.970

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/index.d.ts CHANGED
@@ -16,6 +16,7 @@ export * from "./middlewares/not-sandbox";
16
16
  export * from "./services/apiKey";
17
17
  export * from "./services/password";
18
18
  export * from "./models/admin-auth";
19
+ export * from "./models/admin";
19
20
  export * from "./models/auth";
20
21
  export * from "./models/bank-payout";
21
22
  export * from "./models/bank-payment";
@@ -36,6 +37,7 @@ export * from "./models/bridge-customer";
36
37
  export * from "./models/bridge-transfer";
37
38
  export * from "./models/bridge-external-account";
38
39
  export * from "./models/bridge-liquidation-address";
40
+ export * from "./models/admin-task";
39
41
  export * from "./clients/bitstamp-client";
40
42
  export * from "./clients/ccxt-client";
41
43
  export * from "./clients/kushki-client";
package/build/index.js CHANGED
@@ -32,6 +32,7 @@ __exportStar(require("./middlewares/not-sandbox"), exports);
32
32
  __exportStar(require("./services/apiKey"), exports);
33
33
  __exportStar(require("./services/password"), exports);
34
34
  __exportStar(require("./models/admin-auth"), exports);
35
+ __exportStar(require("./models/admin"), exports);
35
36
  __exportStar(require("./models/auth"), exports);
36
37
  __exportStar(require("./models/bank-payout"), exports);
37
38
  __exportStar(require("./models/bank-payment"), exports);
@@ -52,6 +53,7 @@ __exportStar(require("./models/bridge-customer"), exports);
52
53
  __exportStar(require("./models/bridge-transfer"), exports);
53
54
  __exportStar(require("./models/bridge-external-account"), exports);
54
55
  __exportStar(require("./models/bridge-liquidation-address"), exports);
56
+ __exportStar(require("./models/admin-task"), exports);
55
57
  __exportStar(require("./clients/bitstamp-client"), exports);
56
58
  __exportStar(require("./clients/ccxt-client"), exports);
57
59
  __exportStar(require("./clients/kushki-client"), exports);
@@ -1,15 +1,16 @@
1
+ import { AdminTaskType } from "@riocrypto/common";
1
2
  import { Mongoose, Model, Document } from "mongoose";
2
3
  interface AdminTaskAttrs {
3
- email: string;
4
- password: string;
5
- previousPasswords?: string[];
6
- authenticatorSecret?: string;
4
+ type: AdminTaskType;
5
+ createdAt: Date;
6
+ orderId?: string;
7
+ userId?: string;
7
8
  }
8
9
  interface AdminTaskDoc extends Document {
9
- email: string;
10
- password: string;
11
- previousPasswords?: string[];
12
- authenticatorSecret?: string;
10
+ type: AdminTaskType;
11
+ createdAt: Date;
12
+ orderId?: string;
13
+ userId?: string;
13
14
  }
14
15
  interface AdminTaskModel extends Model<AdminTaskDoc> {
15
16
  build(attrs: AdminTaskAttrs): AdminTaskDoc;
@@ -1,37 +1,24 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.buildAdminTask = void 0;
13
- const password_1 = require("../services/password");
14
4
  const buildAdminTask = (mongoose) => {
15
5
  // if model is already defined, return it
16
6
  if (mongoose.models.AdminTask) {
17
7
  return mongoose.model("AdminTask");
18
8
  }
19
- const AdminSchema = new mongoose.Schema({
20
- email: {
9
+ const AdminTaskSchema = new mongoose.Schema({
10
+ type: {
21
11
  type: String,
22
12
  required: true,
23
13
  },
24
- password: {
25
- type: String,
14
+ createdAt: {
15
+ type: mongoose.Schema.Types.Date,
26
16
  required: true,
27
17
  },
28
- previousPasswords: [
29
- {
30
- type: String,
31
- required: false,
32
- },
33
- ],
34
- authenticatorSecret: {
18
+ orderId: {
19
+ type: String,
20
+ },
21
+ userId: {
35
22
  type: String,
36
23
  },
37
24
  }, {
@@ -46,19 +33,10 @@ const buildAdminTask = (mongoose) => {
46
33
  },
47
34
  },
48
35
  });
49
- AdminSchema.pre("save", function (done) {
50
- return __awaiter(this, void 0, void 0, function* () {
51
- if (this.isModified("password")) {
52
- const hashed = yield password_1.Password.toHash(this.get("password"));
53
- this.set("password", hashed);
54
- }
55
- done();
56
- });
57
- });
58
- AdminSchema.statics.build = (attrs) => {
36
+ AdminTaskSchema.statics.build = (attrs) => {
59
37
  return new AdminTask(attrs);
60
38
  };
61
- const AdminTask = mongoose.model("AdminTask", AdminSchema);
39
+ const AdminTask = mongoose.model("AdminTask", AdminTaskSchema);
62
40
  return AdminTask;
63
41
  };
64
42
  exports.buildAdminTask = buildAdminTask;
@@ -0,0 +1,24 @@
1
+ import { AdminTaskType } from "@riocrypto/common";
2
+ import { Mongoose, Model, Document } from "mongoose";
3
+ interface AdminAttrs {
4
+ createdAt: Date;
5
+ adminAuthIds?: string[];
6
+ name: string;
7
+ email: string;
8
+ assignedTaskTypes: AdminTaskType[];
9
+ privileges: string[];
10
+ }
11
+ interface AdminModel extends Model<AdminDoc> {
12
+ build(attrs: AdminAttrs): AdminDoc;
13
+ }
14
+ interface AdminDoc extends Document {
15
+ _id: string;
16
+ createdAt: Date;
17
+ adminAuthIds?: string[];
18
+ name: string;
19
+ email: string;
20
+ assignedTaskTypes: AdminTaskType[];
21
+ privileges: string[];
22
+ }
23
+ declare const buildAdmin: (mongoose: Mongoose) => AdminModel;
24
+ export { buildAdmin, AdminDoc };
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildAdmin = void 0;
4
+ const buildAdmin = (mongoose) => {
5
+ // if model is already defined, return it
6
+ if (mongoose.models.Admin) {
7
+ return mongoose.model("Admin");
8
+ }
9
+ const AdminSchema = new mongoose.Schema({
10
+ authIds: [
11
+ {
12
+ type: String,
13
+ },
14
+ ],
15
+ createdAt: {
16
+ type: mongoose.Schema.Types.Date,
17
+ required: true,
18
+ },
19
+ name: {
20
+ type: String,
21
+ required: true,
22
+ },
23
+ email: {
24
+ type: String,
25
+ required: true,
26
+ },
27
+ privileges: [
28
+ {
29
+ type: String,
30
+ required: true,
31
+ },
32
+ ],
33
+ assignedTaskTypes: [
34
+ {
35
+ type: String,
36
+ required: true,
37
+ },
38
+ ],
39
+ }, {
40
+ toJSON: {
41
+ transform(doc, ret) {
42
+ ret.id = ret._id.valueOf();
43
+ delete ret._id;
44
+ delete ret.__v;
45
+ },
46
+ },
47
+ });
48
+ AdminSchema.statics.build = (attrs) => {
49
+ return new Admin(attrs);
50
+ };
51
+ const Admin = mongoose.model("Admin", AdminSchema);
52
+ return Admin;
53
+ };
54
+ exports.buildAdmin = buildAdmin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.968",
3
+ "version": "1.0.970",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -24,7 +24,7 @@
24
24
  "@aws-sdk/client-s3": "^3.297.0",
25
25
  "@everapi/currencyapi-js": "^1.0.6",
26
26
  "@google-cloud/storage": "^6.9.5",
27
- "@riocrypto/common": "^1.0.832",
27
+ "@riocrypto/common": "^1.0.834",
28
28
  "@types/express": "^4.17.13",
29
29
  "axios": "^0.27.2",
30
30
  "ccxt": "^3.0.30",