@e-mc/types 0.7.19 → 0.7.21

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/constant.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export const enum INTERNAL {
2
- VERSION = '0.7.19',
2
+ VERSION = '0.7.21',
3
3
  TEMP_DIR = 'tmp',
4
4
  CJS = '__cjs__'
5
5
  }
package/index.js CHANGED
@@ -146,7 +146,6 @@ function recurseObject(data, parseString, completed, cache) {
146
146
  }
147
147
  return data;
148
148
  }
149
- const convertScrypt = (key, iv, data) => crypto.scryptSync(key, iv, Math.ceil(data.length / 16) * 16);
150
149
  const isFunction = (value) => typeof value === 'function';
151
150
  var LOG_TYPE;
152
151
  (function (LOG_TYPE) {
@@ -720,8 +719,10 @@ function coerceObject(data, parseString, cache) {
720
719
  const removeQuotes = (content) => content.trim().replace(/^["']/g, '').replace(/["']$/g, '').trim();
721
720
  const errorCreate = () => errorValue('Invalid parameters', match[2].trim());
722
721
  switch (match[1]) {
723
- case 'Date':
724
- return new Date(match[2].replace(/["']/g, '').trim());
722
+ case 'Date': {
723
+ const text = match[2].replace(/["']/g, '').trim();
724
+ return text ? new Date(text) : new Date();
725
+ }
725
726
  case 'URL':
726
727
  case 'RegExp': {
727
728
  const pattern = /^("[^"]+"|'[^']+'|[^\s,]+)(?:\s*,\s*("[^"]+"|'[^']+'|\S+))?$/.exec(match[2].trim());
@@ -830,23 +831,29 @@ function getEncoding(value, fallback = 'utf-8') {
830
831
  exports.getEncoding = getEncoding;
831
832
  function encryptUTF8(algorithm, key, iv, data, encoding = 'hex') {
832
833
  if (checkCipherType(algorithm) && isString(data)) {
834
+ let result;
833
835
  try {
834
- const gcm = crypto.createCipheriv(algorithm, convertScrypt(key, iv, data), iv);
835
- return gcm.update(data, 'utf-8', encoding) + gcm.final(encoding);
836
+ const gcm = crypto.createCipheriv(algorithm, crypto.scryptSync(key, iv, 32), iv);
837
+ result = gcm.update(data, 'utf8', encoding);
838
+ result += gcm.final(encoding);
836
839
  }
837
840
  catch {
838
841
  }
842
+ return result;
839
843
  }
840
844
  }
841
845
  exports.encryptUTF8 = encryptUTF8;
842
846
  function decryptUTF8(algorithm, key, iv, data, encoding = 'hex') {
843
847
  if (checkCipherType(algorithm) && isString(data)) {
848
+ let result;
844
849
  try {
845
- const gcm = crypto.createDecipheriv(algorithm, convertScrypt(key, iv, data), iv);
846
- return gcm.update(data, encoding, 'utf-8') + gcm.final('utf-8');
850
+ const gcm = crypto.createDecipheriv(algorithm, crypto.scryptSync(key, iv, 32), iv);
851
+ result = gcm.update(data, encoding, 'utf8');
852
+ result += gcm.final('utf8');
847
853
  }
848
854
  catch {
849
855
  }
856
+ return result;
850
857
  }
851
858
  }
852
859
  exports.decryptUTF8 = decryptUTF8;
package/lib/index.d.ts CHANGED
@@ -104,6 +104,7 @@ declare namespace functions {
104
104
  }
105
105
 
106
106
  interface ImageConstructor<T extends IHost = IHost, U extends ImageModule = ImageModule> extends ModuleConstructor {
107
+ /** @deprecated */
107
108
  readonly REGEXP_SIZERANGE: RegExp;
108
109
  transform(file: string, command: string, options?: TransformOptions): Promise<Null<Buffer> | string>;
109
110
  clamp(value: unknown, min?: number, max?: number): number;
@@ -285,7 +286,7 @@ declare namespace functions {
285
286
  createServer(port: number, secure?: Null<SecureOptions>, active?: boolean): Null<ws.Server>;
286
287
  shutdown(): void;
287
288
  setTimeout(value: NumString): void;
288
- checkTimeout(client: ws): boolean;
289
+ checkTimeout(client: ws.WebSocket): boolean;
289
290
  readonly prototype: IWatch<T, U, V, W>;
290
291
  new(module?: V): IWatch<T, U, V, W>;
291
292
  new(interval?: number, port?: number, securePort?: number, extensions?: unknown[]): IWatch<T, U, V, W>;
package/lib/watch.d.ts CHANGED
@@ -58,8 +58,8 @@ export interface IFileGroup<T extends ExternalAsset = ExternalAsset> extends IAb
58
58
 
59
59
  export interface FileGroupConstructor<T extends ExternalAsset = ExternalAsset> {
60
60
  CONNECTION_TIMEOUT: number;
61
- CLIENT_SESSION: Map<ws, number>;
62
- checkTimeout(client: ws): boolean;
61
+ CLIENT_SESSION: Map<ws.WebSocket, number>;
62
+ checkTimeout(client: ws.WebSocket): boolean;
63
63
  cloneAsset(asset: T): T;
64
64
  readonly prototype: IFileGroup<T>;
65
65
  new(uri: string, assets: T[], abortable: boolean): IFileGroup<T>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/types",
3
- "version": "0.7.19",
3
+ "version": "0.7.21",
4
4
  "description": "Type definitions for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",