@koralabs/kora-labs-common 4.0.10 → 4.0.12

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.
@@ -1,3 +1,3 @@
1
- export declare const IS_PRODUCTION: boolean;
2
1
  export declare const IS_SERVER: boolean;
2
+ export declare const IS_PRODUCTION: boolean;
3
3
  export declare const AUTH_GRANT_DURATION: number;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  var _a, _b;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.AUTH_GRANT_DURATION = exports.IS_SERVER = exports.IS_PRODUCTION = void 0;
5
- exports.IS_PRODUCTION = ((_a = process.env.NODE_ENV) === null || _a === void 0 ? void 0 : _a.trim()) === 'production' && ((_b = process.env.NETWORK) === null || _b === void 0 ? void 0 : _b.toLowerCase()) == 'mainnet';
4
+ exports.AUTH_GRANT_DURATION = exports.IS_PRODUCTION = exports.IS_SERVER = void 0;
6
5
  exports.IS_SERVER = (typeof process !== 'undefined') && (typeof process.versions.node !== 'undefined');
6
+ exports.IS_PRODUCTION = exports.IS_SERVER ? (((_a = process.env.NODE_ENV) === null || _a === void 0 ? void 0 : _a.trim()) === 'production' && ((_b = process.env.NETWORK) === null || _b === void 0 ? void 0 : _b.toLowerCase()) == 'mainnet') : !(window.location.host.includes('preview.') || window.location.host.includes('preprod.'));
7
7
  exports.AUTH_GRANT_DURATION = 1000 * 60 * 60 * 24 * 30; // 30 days
package/handles/api.js CHANGED
@@ -18,7 +18,7 @@ class HandlesApi {
18
18
  throw new Error("handle is required");
19
19
  }
20
20
  const handleJson = await this.apiRequest(`/handles/${handle}`);
21
- // This should be coming ffrom the API. The API needs to start setting this
21
+ // This should be coming from the API. The API needs to start setting this
22
22
  handleJson.policy = 'f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a';
23
23
  return handleJson;
24
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koralabs/kora-labs-common",
3
- "version": "4.0.10",
3
+ "version": "4.0.12",
4
4
  "description": "Kora Labs Common Utilities",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -39,8 +39,9 @@
39
39
  "typescript": "^4.7.3"
40
40
  },
41
41
  "dependencies": {
42
+ "bech32": "^2.0.0",
42
43
  "boolean": "^3.2.0",
43
44
  "cbor": "^9.0.2",
44
45
  "pluralize": "^8.0.0"
45
46
  }
46
- }
47
+ }
@@ -4,3 +4,4 @@ export declare function getRandomCodeVerifier(length: number): Promise<string>;
4
4
  export declare const sha256: (plain: string) => Promise<ArrayBuffer>;
5
5
  export declare function base64urlencode(a: ArrayBuffer): string;
6
6
  export declare function getChallengeFromVerifier(verifier: string): Promise<string>;
7
+ export declare const decodeAddress: (address: string) => string | null;
@@ -23,7 +23,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getChallengeFromVerifier = exports.base64urlencode = exports.sha256 = exports.getRandomCodeVerifier = exports.dec2hex = exports.getNativeCrypto = void 0;
26
+ exports.decodeAddress = exports.getChallengeFromVerifier = exports.base64urlencode = exports.sha256 = exports.getRandomCodeVerifier = exports.dec2hex = exports.getNativeCrypto = void 0;
27
+ const bech32_1 = require("bech32");
27
28
  const constants_1 = require("../../constants");
28
29
  // var verifier = await getRandomCodeVerifier(64);
29
30
  // var challenge = await getChallengeFromVerifier(verifier);
@@ -71,3 +72,14 @@ async function getChallengeFromVerifier(verifier) {
71
72
  return base64encoded;
72
73
  }
73
74
  exports.getChallengeFromVerifier = getChallengeFromVerifier;
75
+ const decodeAddress = (address) => {
76
+ try {
77
+ const addressWords = bech32_1.bech32.decode(address, address.length);
78
+ const payload = bech32_1.bech32.fromWords(addressWords.words);
79
+ return `${Buffer.from(payload).toString('hex')}`;
80
+ }
81
+ catch (error) {
82
+ return null;
83
+ }
84
+ };
85
+ exports.decodeAddress = decodeAddress;