@riocrypto/common 1.0.558 → 1.0.560

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.
@@ -4,8 +4,8 @@ export declare class CryptoAsset extends Asset {
4
4
  rawSymbol: Crypto;
5
5
  constructor(rawSymbol: Crypto);
6
6
  getImageUri(): string;
7
- getName(): "Ethereum" | "USDC (Ethereum)" | "USDC (Polygon)";
8
- getSymbol(): "USDC (Ethereum)" | "USDC (Polygon)" | "ETH";
9
- getGasSymbol(): "ETH" | "MATIC";
7
+ getName(): Crypto.BTC | "Ethereum" | "USDC (Ethereum)" | "USDC (Polygon)";
8
+ getSymbol(): Crypto.BTC | "USDC (Ethereum)" | "USDC (Polygon)" | "ETH";
9
+ getGasSymbol(): Crypto.BTC | "ETH" | "MATIC";
10
10
  getDescription(): string;
11
11
  }
@@ -0,0 +1,8 @@
1
+ import { CustomError } from "./custom-error";
2
+ export declare class MissingCPFError extends CustomError {
3
+ statusCode: number;
4
+ constructor();
5
+ serializeErrors(): {
6
+ message: string;
7
+ }[];
8
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MissingCPFError = void 0;
4
+ const custom_error_1 = require("./custom-error");
5
+ class MissingCPFError extends custom_error_1.CustomError {
6
+ constructor() {
7
+ super("User is missing CPF");
8
+ this.statusCode = 401;
9
+ Object.setPrototypeOf(this, MissingCPFError.prototype);
10
+ }
11
+ serializeErrors() {
12
+ return [{ message: "User is missing CPF" }];
13
+ }
14
+ }
15
+ exports.MissingCPFError = MissingCPFError;
@@ -0,0 +1,2 @@
1
+ import { Crypto } from "../types/crypto";
2
+ export declare const isValidCryptoAddress: (address: string, crypto: Crypto) => boolean;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isValidCryptoAddress = void 0;
4
+ const crypto_1 = require("../types/crypto");
5
+ const isValidCryptoAddress = (address, crypto) => {
6
+ const bitcoinPattern = /^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$/;
7
+ const ethereumPattern = /^0x[a-fA-F0-9]{40}$/;
8
+ switch (crypto) {
9
+ case crypto_1.Crypto.BTC:
10
+ return bitcoinPattern.test(address);
11
+ case crypto_1.Crypto.ETH || crypto_1.Crypto.USDC || crypto_1.Crypto.USDCPolygon:
12
+ return ethereumPattern.test(address);
13
+ default:
14
+ return false;
15
+ }
16
+ };
17
+ exports.isValidCryptoAddress = isValidCryptoAddress;
package/build/index.d.ts CHANGED
@@ -32,6 +32,7 @@ export * from "./errors/rio-settings-already-exists-error";
32
32
  export * from "./errors/wrong-security-answer-error";
33
33
  export * from "./errors/partner-auth-already-exists-error";
34
34
  export * from "./errors/partner-auth-not-found-error";
35
+ export * from "./errors/missing-cpf-error";
35
36
  export * from "./events/base-listener";
36
37
  export * from "./events/base-publisher";
37
38
  export * from "./events/subjects";
@@ -143,4 +144,5 @@ export * from "./classes/PayoutMethodAsset";
143
144
  export * from "./classes/USStateAsset";
144
145
  export * from "./classes/WyrePaymentMethodAsset";
145
146
  export * from "./helpers/get-user-from-client-helper";
147
+ export * from "./helpers/validate-address";
146
148
  export * from "./clients/rio-client";
package/build/index.js CHANGED
@@ -48,6 +48,7 @@ __exportStar(require("./errors/rio-settings-already-exists-error"), exports);
48
48
  __exportStar(require("./errors/wrong-security-answer-error"), exports);
49
49
  __exportStar(require("./errors/partner-auth-already-exists-error"), exports);
50
50
  __exportStar(require("./errors/partner-auth-not-found-error"), exports);
51
+ __exportStar(require("./errors/missing-cpf-error"), exports);
51
52
  __exportStar(require("./events/base-listener"), exports);
52
53
  __exportStar(require("./events/base-publisher"), exports);
53
54
  __exportStar(require("./events/subjects"), exports);
@@ -159,4 +160,5 @@ __exportStar(require("./classes/PayoutMethodAsset"), exports);
159
160
  __exportStar(require("./classes/USStateAsset"), exports);
160
161
  __exportStar(require("./classes/WyrePaymentMethodAsset"), exports);
161
162
  __exportStar(require("./helpers/get-user-from-client-helper"), exports);
163
+ __exportStar(require("./helpers/validate-address"), exports);
162
164
  __exportStar(require("./clients/rio-client"), exports);
@@ -1,4 +1,5 @@
1
1
  export declare enum Crypto {
2
+ BTC = "BTC",
2
3
  ETH = "ETH",
3
4
  USDC = "USDC",
4
5
  USDCPolygon = "USDC_POLYGON"
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.Crypto = void 0;
6
6
  var Crypto;
7
7
  (function (Crypto) {
8
- // BTC = "BTC",
8
+ Crypto["BTC"] = "BTC";
9
9
  Crypto["ETH"] = "ETH";
10
10
  Crypto["USDC"] = "USDC";
11
11
  Crypto["USDCPolygon"] = "USDC_POLYGON";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common",
3
- "version": "1.0.558",
3
+ "version": "1.0.560",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",