@riocrypto/common-server 1.0.2362 → 1.0.2367

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.
@@ -27,9 +27,7 @@ class CoincoverClient {
27
27
  return address;
28
28
  };
29
29
  this.getResidenceCountry = (user) => {
30
- var _a, _b;
31
- const highestOnboardingCountry = (0, common_1.getHighestOnboardingStatus)(user).country;
32
- return (_b = (_a = user.onboarding[highestOnboardingCountry]) === null || _a === void 0 ? void 0 : _a.address) === null || _b === void 0 ? void 0 : _b.country;
30
+ return user.address.country;
33
31
  };
34
32
  if ([common_1.RioEnv.Development, common_1.RioEnv.Production].includes(process.env.RIO_ENV)) {
35
33
  this.baseUrl = "https://api.txm.coincover.com";
@@ -3,19 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getTaxRate = void 0;
4
4
  const common_1 = require("@riocrypto/common");
5
5
  const getTaxRate = (user, country, fiat, processor) => {
6
- var _a, _b, _c, _d;
6
+ var _a, _b;
7
7
  let taxRate = 0;
8
8
  if ((fiat === common_1.Fiat.MXN && processor === common_1.Processor.SPEI) ||
9
9
  (fiat === common_1.Fiat.MXN && processor === common_1.Processor.SPEI_NVIO) ||
10
10
  (fiat === common_1.Fiat.MXN && processor === common_1.Processor.SPEI_STP) ||
11
11
  (fiat === common_1.Fiat.USD && processor === common_1.Processor.SPID)) {
12
12
  if (country === common_1.Country.Mexico &&
13
- ((_b = (_a = user === null || user === void 0 ? void 0 : user.onboarding[country]) === null || _a === void 0 ? void 0 : _a.address) === null || _b === void 0 ? void 0 : _b.country) === common_1.CountryOfOrigin.Mexico) {
13
+ ((_a = user === null || user === void 0 ? void 0 : user.address) === null || _a === void 0 ? void 0 : _a.country) === common_1.CountryOfOrigin.Mexico) {
14
14
  taxRate = 0.16;
15
15
  }
16
16
  }
17
17
  if (fiat === common_1.Fiat.PEN && processor === common_1.Processor.Interbank) {
18
- if (((_d = (_c = user === null || user === void 0 ? void 0 : user.onboarding[country]) === null || _c === void 0 ? void 0 : _c.address) === null || _d === void 0 ? void 0 : _d.country) === common_1.CountryOfOrigin.Peru) {
18
+ if (((_b = user === null || user === void 0 ? void 0 : user.address) === null || _b === void 0 ? void 0 : _b.country) === common_1.CountryOfOrigin.Peru) {
19
19
  taxRate = 0.18;
20
20
  }
21
21
  }
@@ -109,7 +109,6 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
109
109
  const accessToken = (_b = req.cookies) === null || _b === void 0 ? void 0 : _b.accessToken;
110
110
  if (apiKey || accessToken) {
111
111
  promises.push((() => __awaiter(void 0, void 0, void 0, function* () {
112
- var _c, _d, _e, _f, _g, _h;
113
112
  const Auth = yield (0, auth_1.buildAuth)(mongoose);
114
113
  let authId = null;
115
114
  if (apiKey) {
@@ -165,9 +164,7 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
165
164
  req.user = user;
166
165
  }
167
166
  else if (authorizationTypes.includes(common_1.AuthorizationType.User)) {
168
- if (((_d = (_c = user.onboarding) === null || _c === void 0 ? void 0 : _c.MX) === null || _d === void 0 ? void 0 : _d.status) === common_1.OnboardingStatus.Approved ||
169
- ((_f = (_e = user.onboarding) === null || _e === void 0 ? void 0 : _e.PE) === null || _f === void 0 ? void 0 : _f.status) === common_1.OnboardingStatus.Approved ||
170
- ((_h = (_g = user.onboarding) === null || _g === void 0 ? void 0 : _g.US) === null || _h === void 0 ? void 0 : _h.status) === common_1.OnboardingStatus.Approved) {
167
+ if (user.onboarding.status === common_1.OnboardingStatus.Approved) {
171
168
  req.user = user;
172
169
  }
173
170
  }
@@ -1,50 +1,5 @@
1
- import { OnboardingStatus, PlatformFeeRange, UserAttribute, UserType, CountryOfOrigin, RiskTier, ImmigrationStatus, Country, Fiat, Side, Crypto } from "@riocrypto/common";
1
+ import { OnboardingStatus, PlatformFeeRange, UserAttribute, UserType, CountryOfOrigin, RiskTier, Country, Fiat, Side, Crypto } from "@riocrypto/common";
2
2
  import { Mongoose, Model, Document } from "mongoose";
3
- interface OnboardingBase {
4
- aipriseBusinessProfileId?: string;
5
- aipriseUserProfileId?: string;
6
- }
7
- type OnboardingCountryData = {
8
- [country in CountryOfOrigin]?: {
9
- status?: OnboardingStatus;
10
- hasAcceptedTerms?: boolean;
11
- onboardingId?: string;
12
- bridgeId?: string;
13
- personalId?: string;
14
- taxId?: string;
15
- immigrationStatus?: ImmigrationStatus;
16
- individualIdentityVerification?: {
17
- status?: "passed" | "failed" | "review";
18
- };
19
- legalRepresentative?: {
20
- firstName?: string;
21
- middleName?: string;
22
- lastName?: string;
23
- secondLastName?: string;
24
- verificationStatus?: "passed" | "failed" | "review";
25
- email?: string;
26
- };
27
- files?: {
28
- certificateOfIncorporation?: string;
29
- KYCReport?: string;
30
- taxTranscript?: string;
31
- proofOfAddress?: string;
32
- businessRegistration?: string;
33
- taxIdentificationCertificate?: string;
34
- legalRepresentativeIdPowerOfAttorney?: string;
35
- personalIdentificationCertificate?: string;
36
- extraFiles?: string[];
37
- };
38
- address?: {
39
- street1?: string;
40
- street2?: string;
41
- city?: string;
42
- state?: string;
43
- postalCode?: string;
44
- country?: CountryOfOrigin;
45
- };
46
- };
47
- };
48
3
  interface UserAttrs {
49
4
  createdAt: Date;
50
5
  authIds?: string[];
@@ -114,7 +69,24 @@ interface UserAttrs {
114
69
  };
115
70
  };
116
71
  authorizedPhoneNumbers?: string[];
117
- onboarding?: OnboardingBase & OnboardingCountryData;
72
+ onboarding: {
73
+ country: Country;
74
+ aipriseBusinessProfileId?: string;
75
+ aipriseUserProfileId?: string;
76
+ bridgeCustomerId?: string;
77
+ aipriseBusinessVerificationSessionUrl?: string;
78
+ aipriseUserVerificationSessionUrl?: string;
79
+ status: OnboardingStatus;
80
+ hasAcceptedTerms: boolean;
81
+ };
82
+ address: {
83
+ street1?: string;
84
+ street2?: string;
85
+ city?: string;
86
+ state?: string;
87
+ postalCode?: string;
88
+ country?: CountryOfOrigin;
89
+ };
118
90
  invoicing?: {
119
91
  MX: {
120
92
  shouldInvoice: boolean;
@@ -210,7 +182,24 @@ interface UserDoc extends Document {
210
182
  };
211
183
  };
212
184
  authorizedPhoneNumbers?: string[];
213
- onboarding?: OnboardingBase & OnboardingCountryData;
185
+ onboarding: {
186
+ country: Country;
187
+ aipriseBusinessProfileId?: string;
188
+ aipriseUserProfileId?: string;
189
+ bridgeCustomerId?: string;
190
+ aipriseBusinessVerificationSessionUrl?: string;
191
+ aipriseUserVerificationSessionUrl?: string;
192
+ status: OnboardingStatus;
193
+ hasAcceptedTerms: boolean;
194
+ };
195
+ address: {
196
+ street1?: string;
197
+ street2?: string;
198
+ city?: string;
199
+ state?: string;
200
+ postalCode?: string;
201
+ country?: CountryOfOrigin;
202
+ };
214
203
  invoicing?: {
215
204
  MX: {
216
205
  shouldInvoice: boolean;
@@ -48,6 +48,9 @@ const buildUser = (mongoose) => {
48
48
  type: String,
49
49
  },
50
50
  ],
51
+ address: {
52
+ type: Object,
53
+ },
51
54
  brokerId: {
52
55
  type: String,
53
56
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.2362",
3
+ "version": "1.0.2367",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "@google-cloud/secret-manager": "^5.3.0",
29
29
  "@google-cloud/storage": "^6.9.5",
30
30
  "@hyperdx/node-opentelemetry": "^0.7.0",
31
- "@riocrypto/common": "^1.0.2080",
31
+ "@riocrypto/common": "^1.0.2089",
32
32
  "@types/express": "^4.17.13",
33
33
  "axios": "^1.7.4",
34
34
  "crypto-js": "^4.2.0",