@koralabs/kora-labs-common 5.1.24 → 5.1.26

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koralabs/kora-labs-common",
3
- "version": "5.1.24",
3
+ "version": "5.1.26",
4
4
  "description": "Kora Labs Common Utilities",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -1,10 +1,4 @@
1
1
  import { AvailabilityResponse, ReservedOrProtected } from '../handles/interfaces';
2
- declare global {
3
- interface String {
4
- includesSingularOrPlural(word: string): boolean;
5
- replaceSingularOrPlural(word: string, replacement: string): string;
6
- }
7
- }
8
2
  export declare class ProtectedWords {
9
3
  static protectedHandles: ReservedOrProtected;
10
4
  static readLock: boolean;
@@ -5,17 +5,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ProtectedWords = void 0;
7
7
  const pluralize_esm_1 = __importDefault(require("pluralize-esm"));
8
- const protectedWords_1 = require("./protectedWords");
9
- const utils_1 = require("../utils");
10
- const interfaces_1 = require("../handles/interfaces");
11
8
  const constants_1 = require("../handles/constants");
12
- String.prototype.includesSingularOrPlural = function (word) {
9
+ const interfaces_1 = require("../handles/interfaces");
10
+ const utils_1 = require("../utils");
11
+ const protectedWords_1 = require("./protectedWords");
12
+ const includesSingularOrPlural = (handle, word) => {
13
13
  const singPlur = ProtectedWords.setSingular(word);
14
- return this.includes(singPlur.singular) || this.includes(singPlur.plural);
14
+ return handle.includes(singPlur.singular) || handle.includes(singPlur.plural);
15
15
  };
16
- String.prototype.replaceSingularOrPlural = function (word, replacement) {
16
+ const replaceSingularOrPlural = (handle, word, replacement) => {
17
17
  const singPlur = ProtectedWords.setSingular(word);
18
- return this.replace(singPlur.singular, replacement).replace(singPlur.plural, replacement);
18
+ return handle.replace(singPlur.singular, replacement).replace(singPlur.plural, replacement);
19
19
  };
20
20
  class ProtectedWords {
21
21
  static async checkAvailability(handle) {
@@ -106,7 +106,7 @@ class ProtectedWords {
106
106
  foundWord = entry.word;
107
107
  return (entry.position == 'any' &&
108
108
  !((_a = entry.exceptions) === null || _a === void 0 ? void 0 : _a.some((exc) => h.includes(exc))) &&
109
- h.includesSingularOrPlural(entry.word));
109
+ includesSingularOrPlural(h, entry.word));
110
110
  })) {
111
111
  return { protected: true, words: [foundWord] };
112
112
  }
@@ -118,7 +118,7 @@ class ProtectedWords {
118
118
  foundWord = entry.word;
119
119
  return (entry.position == 'beginswith' &&
120
120
  h.startsWith(entry.word) &&
121
- !'aeiou'.includes((_a = h.replaceSingularOrPlural(entry.word, '')) === null || _a === void 0 ? void 0 : _a.charAt(0)) &&
121
+ !'aeiou'.includes((_a = replaceSingularOrPlural(h, entry.word, '')) === null || _a === void 0 ? void 0 : _a.charAt(0)) &&
122
122
  !((_b = entry.exceptions) === null || _b === void 0 ? void 0 : _b.some((exc) => h.includes(exc))));
123
123
  })) {
124
124
  return { protected: true, words: [foundWord] };
@@ -138,13 +138,13 @@ class ProtectedWords {
138
138
  let foundWords = '';
139
139
  if (hatespeechEntries.some((entry) => {
140
140
  var _a;
141
- return (h.includesSingularOrPlural(entry.word) &&
141
+ return (includesSingularOrPlural(h, entry.word) &&
142
142
  // It's a hatespeech target and includes a hatespeech modifier (check exceptions)
143
143
  !((_a = entry.exceptions) === null || _a === void 0 ? void 0 : _a.some((exc) => h.includes(exc))) &&
144
144
  hatespeechWords.some((hateWord) => {
145
145
  var _a;
146
146
  foundWords = `${entry.word},${hateWord.word}`;
147
- return (h.replaceSingularOrPlural(entry.word, ' ').includes(hateWord.word) &&
147
+ return (replaceSingularOrPlural(h, entry.word, ' ').includes(hateWord.word) &&
148
148
  !((_a = hateWord.exceptions) === null || _a === void 0 ? void 0 : _a.some((exc) => h.includes(exc))) &&
149
149
  // If it's a vulnerable target, a positive word is fine
150
150
  !(entry.algorithms.includes('vulnerable') && hateWord.canBePositive) &&
@@ -176,13 +176,13 @@ class ProtectedWords {
176
176
  if ([...suggestiveEntries, ...vulnerableEntries].some((entry) => {
177
177
  var _a;
178
178
  // is combined with a suggestive word, or another suggestive entry (from the same badwords list), or it's a modifier + `pp`
179
- return (h.includesSingularOrPlural(entry.word) &&
179
+ return (includesSingularOrPlural(h, entry.word) &&
180
180
  !((_a = entry.exceptions) === null || _a === void 0 ? void 0 : _a.some((exc) => h.includes(exc))) &&
181
181
  (suggestiveWords.some((s) => {
182
182
  var _a;
183
183
  // is combined with a suggestive word (check exceptions)
184
184
  foundWords = `${entry.word},${s.word}`;
185
- return (h.replaceSingularOrPlural(entry.word, ' ').includes(s.word) &&
185
+ return (replaceSingularOrPlural(h, entry.word, ' ').includes(s.word) &&
186
186
  !((_a = s.exceptions) === null || _a === void 0 ? void 0 : _a.some((exc) => h.includes(exc))) &&
187
187
  !(entry.algorithms.includes('vulnerable') && s.canBePositive));
188
188
  }) ||
@@ -191,28 +191,26 @@ class ProtectedWords {
191
191
  // is combined with another suggestive entry from the badwords list (check exceptions)
192
192
  foundWords = `${entry.word},${s.word}`;
193
193
  return (s != entry &&
194
- h.replaceSingularOrPlural(entry.word, ' ').includesSingularOrPlural(s.word) &&
194
+ replaceSingularOrPlural(h, entry.word, ' ') && includesSingularOrPlural(h, s.word) &&
195
195
  !((_a = s.exceptions) === null || _a === void 0 ? void 0 : _a.some((exc) => h.includes(exc))));
196
196
  }) ||
197
- modifiers.some((mod) => h.replaceSingularOrPlural(entry.word, ' ').includes(mod.word) &&
197
+ modifiers.some((mod) => replaceSingularOrPlural(h, entry.word, ' ').includes(mod.word) &&
198
198
  // If it can be a positive modifier, like "love", then vulnerable targets are OK
199
199
  !(entry.algorithms.includes('vulnerable') &&
200
200
  mod.canBePositive &&
201
201
  !specialCaseVulnWords.some((spec) => {
202
202
  // it's a modifier + `pp` - This is a hint that it's not a good phrase like "tinypreteenpp"
203
203
  foundWords = `${entry.word},${mod.word},${spec}`;
204
- return h
205
- .replaceSingularOrPlural(entry.word, ' ')
206
- .replaceSingularOrPlural(mod.word, ' ')
207
- .includes(spec);
204
+ return replaceSingularOrPlural(h, entry.word, ' ') &&
205
+ replaceSingularOrPlural(h, mod.word, ' ') &&
206
+ h.includes(spec);
208
207
  })) &&
209
208
  specialCaseVulnWords.some((spec) => {
210
209
  // it's a modifier + `pp` - This is a hint that it's not a good phrase like "tinypreteenpp"
211
210
  foundWords = `${entry.word},${mod.word},${spec}`;
212
- return h
213
- .replaceSingularOrPlural(entry.word, ' ')
214
- .replaceSingularOrPlural(mod.word, ' ')
215
- .includes(spec);
211
+ return replaceSingularOrPlural(h, entry.word, ' ') &&
212
+ replaceSingularOrPlural(h, mod.word, ' ') &&
213
+ h.includes(spec);
216
214
  }))));
217
215
  })) {
218
216
  return { protected: true, words: foundWords.split(',') };
@@ -329,7 +327,7 @@ class ProtectedWords {
329
327
  // if over 3 chars, check anywhere in the word
330
328
  (m.word.length > 3 &&
331
329
  handle.includes(entry.word) &&
332
- handle.replaceSingularOrPlural(entry.word, ' ').includes(m.word))));
330
+ replaceSingularOrPlural(handle, entry.word, ' ').includes(m.word))));
333
331
  }))) {
334
332
  return { badword: true, words: foundWords.split(',') };
335
333
  }
@@ -37,6 +37,17 @@ export interface AuthGrant {
37
37
  challengeMethod?: ChallengeMethod;
38
38
  revokeReason?: string;
39
39
  }
40
+ export interface MerchOrder {
41
+ tx_id: string;
42
+ holder_address: string;
43
+ workflow_status: string;
44
+ order_status?: string;
45
+ terms_accepted: boolean;
46
+ created_at: number;
47
+ ada_market_value: string;
48
+ lovelace_cost: string;
49
+ order_id?: number;
50
+ }
40
51
  export type Permission = 'subhandle.mint' | 'subhandle.mintmyown' | 'handles.login';
41
52
  export type FriendlyPermissions = Record<string, string>;
42
53
  export type ChallengeMethod = 'sha256' | 'plain';