webext-schema 5.1.2 → 5.1.4

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/index.js CHANGED
@@ -7,9 +7,9 @@
7
7
  */
8
8
 
9
9
  /* api */
10
+ import process from 'node:process';
10
11
  import { logErr, throwErr } from './modules/common.js';
11
12
  import { parseCommand } from './modules/update.js';
12
- import process from 'node:process';
13
13
  export { Schema } from './modules/schema.js';
14
14
 
15
15
  /* process */
@@ -3,10 +3,10 @@
3
3
  */
4
4
 
5
5
  /* api */
6
- import { fileURLToPath } from 'node:url';
7
- import { getType, isString } from './common.js';
8
6
  import fs, { promises as fsPromise } from 'node:fs';
9
7
  import path from 'node:path';
8
+ import { fileURLToPath } from 'node:url';
9
+ import { getType, isString } from './common.js';
10
10
  import { IS_WIN } from './constant.js';
11
11
 
12
12
  /* constants */
package/modules/schema.js CHANGED
@@ -3,16 +3,19 @@
3
3
  */
4
4
 
5
5
  /* api */
6
- import { CHAR } from './constant.js';
7
- import { convertUriToFilePath } from './file-util.js';
8
- import { getType, isObjectNotEmpty, isString } from './common.js';
9
- import camelize from 'camelize';
10
- import decamelize from 'decamelize';
11
6
  import fs from 'node:fs';
12
7
  import path from 'node:path';
8
+ import camelize from 'camelize';
9
+ import decamelize from 'decamelize';
13
10
  import sinon from 'sinon';
11
+ import { getType, isObjectNotEmpty, isString } from './common.js';
12
+ import { convertUriToFilePath } from './file-util.js';
13
+ import { CHAR } from './constant.js';
14
14
 
15
15
  export class Schema {
16
+ /* private */
17
+ #channel;
18
+
16
19
  /**
17
20
  * construct
18
21
  *
@@ -24,7 +27,7 @@ export class Schema {
24
27
  */
25
28
  constructor(...args) {
26
29
  const [arg1, arg2] = args;
27
- this._channel =
30
+ this.#channel =
28
31
  isString(arg1) && /(?:(?:centra|mai)l|beta|esr|release)/.test(arg1)
29
32
  ? arg1
30
33
  : 'beta';
@@ -40,12 +43,12 @@ export class Schema {
40
43
 
41
44
  /* getter / setter */
42
45
  get channel() {
43
- return this._channel;
46
+ return this.#channel;
44
47
  }
45
48
 
46
49
  set channel(ch) {
47
50
  if (isString(ch) && /(?:(?:centra|mai)l|beta|esr|release)/.test(ch)) {
48
- this._channel = ch;
51
+ this.#channel = ch;
49
52
  }
50
53
  }
51
54
 
@@ -264,9 +267,9 @@ export class Schema {
264
267
  * @returns {object} - schema
265
268
  */
266
269
  _parseSchemaContent() {
267
- const fileName = this._channel === 'mail' ? 'mailext.json' : 'webext.json';
270
+ const fileName = this.#channel === 'mail' ? 'mailext.json' : 'webext.json';
268
271
  const dirName = path.dirname(convertUriToFilePath(import.meta.url));
269
- const file = path.join(dirName, '../', 'schemas', this._channel, fileName);
272
+ const file = path.join(dirName, '../', 'schemas', this.#channel, fileName);
270
273
  const content = fs.readFileSync(file, {
271
274
  encoding: CHAR,
272
275
  flag: 'r'
package/modules/update.js CHANGED
@@ -3,13 +3,13 @@
3
3
  */
4
4
 
5
5
  /* api */
6
- import { CHAR, INDENT } from './constant.js';
7
- import JSON5 from 'json5';
8
- import { createFile } from './file-util.js';
9
- import { getType, isString } from './common.js';
10
- import { program as commander } from 'commander';
11
6
  import path from 'node:path';
12
7
  import process from 'node:process';
8
+ import JSON5 from 'json5';
9
+ import { program as commander } from 'commander';
10
+ import { getType, isString } from './common.js';
11
+ import { createFile } from './file-util.js';
12
+ import { CHAR, INDENT } from './constant.js';
13
13
 
14
14
  /* constants */
15
15
  const DIR_CWD = process.cwd();
package/package.json CHANGED
@@ -11,7 +11,10 @@
11
11
  },
12
12
  "type": "module",
13
13
  "main": "index.js",
14
+ "types": "types/index.d.ts",
14
15
  "dependencies": {
16
+ "@types/node": "^18.14.0",
17
+ "@types/sinon": "^10.0.13",
15
18
  "camelize": "^1.0.1",
16
19
  "commander": "^10.0.0",
17
20
  "decamelize": "^6.0.0",
@@ -30,9 +33,11 @@
30
33
  "eslint-plugin-unicorn": "^45.0.2",
31
34
  "mocha": "^10.2.0",
32
35
  "npm-run-all": "^4.1.5",
36
+ "typescript": "^4.9.5",
33
37
  "undici": "^5.19.1"
34
38
  },
35
39
  "scripts": {
40
+ "build": "npm run tsc && npm run lint && npm run test",
36
41
  "lint": "eslint --fix .",
37
42
  "start": "node index",
38
43
  "test": "npm run test-central",
@@ -41,6 +46,7 @@
41
46
  "test-esr": "c8 mocha --require=test/mocha/setup.js --channel=esr --exit test/*.test.js",
42
47
  "test-release": "c8 mocha --require=test/mocha/setup.js --channel=release --exit test/*.test.js",
43
48
  "test_all": "npm-run-all -s test-*",
49
+ "tsc": "node -e \"fs.rmSync('types',{recursive:true,force:true})\" && npx tsc",
44
50
  "update": "node index update -i",
45
51
  "update-beta": "node index update --channel=beta -i",
46
52
  "update-central": "node index update --channel=central -i",
@@ -48,5 +54,5 @@
48
54
  "update-mail": "node index update --channel=mail -i",
49
55
  "update-release": "node index update --channel=release -i"
50
56
  },
51
- "version": "5.1.2"
57
+ "version": "5.1.4"
52
58
  }
@@ -9721,13 +9721,24 @@
9721
9721
  }
9722
9722
  ]
9723
9723
  },
9724
+ {
9725
+ "$extend": "OptionalPermission",
9726
+ "choices": [
9727
+ {
9728
+ "type": "string",
9729
+ "enum": [
9730
+ "declarativeNetRequestFeedback"
9731
+ ],
9732
+ "min_manifest_version": 3
9733
+ }
9734
+ ]
9735
+ },
9724
9736
  {
9725
9737
  "$extend": "PermissionNoPrompt",
9726
9738
  "choices": [
9727
9739
  {
9728
9740
  "type": "string",
9729
9741
  "enum": [
9730
- "declarativeNetRequestFeedback",
9731
9742
  "declarativeNetRequestWithHostAccess"
9732
9743
  ],
9733
9744
  "min_manifest_version": 3
@@ -10426,6 +10437,11 @@
10426
10437
  }
10427
10438
  ],
10428
10439
  "properties": {
10440
+ "DYNAMIC_RULESET_ID": {
10441
+ "type": "string",
10442
+ "value": "_dynamic",
10443
+ "description": "Ruleset ID for the dynamic rules added by the extension."
10444
+ },
10429
10445
  "GUARANTEED_MINIMUM_STATIC_RULES": {
10430
10446
  "type": "number",
10431
10447
  "description": "The minimum number of static rules guaranteed to an extension across its enabled static rulesets. Any rules above this limit will count towards the global static rule limit."
@@ -10441,6 +10457,11 @@
10441
10457
  "MAX_NUMBER_OF_DYNAMIC_AND_SESSION_RULES": {
10442
10458
  "type": "number",
10443
10459
  "description": "The maximum number of dynamic and session rules an extension can add. NOTE: in the Firefox we are enforcing this limit to the session and dynamic rules count separately, instead of enforcing it to the rules count for both combined as the Chrome implementation does."
10460
+ },
10461
+ "SESSION_RULESET_ID": {
10462
+ "type": "string",
10463
+ "value": "_session",
10464
+ "description": "Ruleset ID for the session-scoped rules added by the extension."
10444
10465
  }
10445
10466
  }
10446
10467
  }
@@ -12405,7 +12426,7 @@
12405
12426
  "mainthreadio",
12406
12427
  "fileio",
12407
12428
  "fileioall",
12408
- "noiostacks",
12429
+ "nomarkerstacks",
12409
12430
  "screenshots",
12410
12431
  "seqstyle",
12411
12432
  "stackwalk",
@@ -13562,6 +13583,14 @@
13562
13583
  "$ref": "ExtensionURL"
13563
13584
  }
13564
13585
  },
13586
+ "type": {
13587
+ "optional": true,
13588
+ "type": "string",
13589
+ "enum": [
13590
+ "module",
13591
+ "classic"
13592
+ ]
13593
+ },
13565
13594
  "persistent": {
13566
13595
  "optional": true,
13567
13596
  "type": "boolean",
@@ -20138,6 +20167,26 @@
20138
20167
  },
20139
20168
  "description": "list of reasons that cause the request to be considered weak, if state is \"weak\"",
20140
20169
  "optional": true
20170
+ },
20171
+ "usedEch": {
20172
+ "type": "boolean",
20173
+ "description": "True if the TLS connection used Encrypted Client Hello.",
20174
+ "optional": true
20175
+ },
20176
+ "usedDelegatedCredentials": {
20177
+ "type": "boolean",
20178
+ "description": "True if the TLS connection used Delegated Credentials.",
20179
+ "optional": true
20180
+ },
20181
+ "usedOcsp": {
20182
+ "type": "boolean",
20183
+ "description": "True if the TLS connection made OCSP requests.",
20184
+ "optional": true
20185
+ },
20186
+ "usedPrivateDns": {
20187
+ "type": "boolean",
20188
+ "description": "True if the TLS connection used a privacy-preserving DNS transport like DNS-over-HTTPS.",
20189
+ "optional": true
20141
20190
  }
20142
20191
  }
20143
20192
  },
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "include": ["index.js"],
3
+ "compilerOptions": {
4
+ "allowJs": true,
5
+ "allowSyntheticDefaultImports": true,
6
+ "declaration": true,
7
+ "declarationDir": "types",
8
+ "emitDeclarationOnly": true,
9
+ "newLine": "LF",
10
+ "removeComments": true
11
+ }
12
+ }
@@ -0,0 +1 @@
1
+ export { Schema } from "./modules/schema.js";
@@ -0,0 +1,7 @@
1
+ export function throwErr(e: object): never;
2
+ export function logErr(e: object): boolean;
3
+ export function logWarn(msg: any): boolean;
4
+ export function logMsg(msg: any): any;
5
+ export function getType(o: any): string;
6
+ export function isObjectNotEmpty(o: any): boolean;
7
+ export function isString(o: any): boolean;
@@ -0,0 +1,3 @@
1
+ export const CHAR: "utf8";
2
+ export const INDENT: 2;
3
+ export const IS_WIN: boolean;
@@ -0,0 +1,21 @@
1
+ export function convertUriToFilePath(uri: string): string | null;
2
+ export function getAbsPath(file: string): string | null;
3
+ export function getStat(file: string): object;
4
+ export function isDir(dir: string): boolean;
5
+ export function isSubDir(dir: string, baseDir: string): boolean;
6
+ export function isFile(file: string): boolean;
7
+ export function isExecutable(file: string, mask?: number): boolean;
8
+ export function getFileTimestamp(file: string): number;
9
+ export function getFileNameFromFilePath(file: string, subst?: string): string;
10
+ export function removeDir(dir: string, baseDir: string): void;
11
+ export function removeDirectory(dir: string, baseDir: string): void;
12
+ export function createDirectory(dir: string, mode?: number): string;
13
+ export function createFile(file: string, value: string | Buffer | Uint8Array, opt?: {
14
+ encoding?: string;
15
+ flag?: string;
16
+ mode?: number | string;
17
+ }): string;
18
+ export function readFile(file: string, opt?: {
19
+ encoding?: string;
20
+ flag?: string;
21
+ }): string | Buffer;
@@ -0,0 +1,26 @@
1
+ export class Schema {
2
+ constructor(...args?: (string | object)[]);
3
+ _sandbox: sinon.SinonSandbox;
4
+ _importMap: Map<any, any>;
5
+ _refMap: Map<any, any>;
6
+ _browser: {
7
+ _sandbox: sinon.SinonSandbox;
8
+ };
9
+ _schema: any;
10
+ set channel(arg: any);
11
+ get channel(): any;
12
+ _getTargetFromNamespace(key: string): object;
13
+ _assignImportMap(): void;
14
+ _assignRefMap(): void;
15
+ _mockEvents(target: object, events: any[]): object;
16
+ _mockFunctions(target: object, funcs: any[]): object;
17
+ _mockProperties(target: object, props: object, namespace: string): object;
18
+ _mockTypes(target: object, types: any[], namespace: string): object;
19
+ _parseSchemaContent(): object;
20
+ get(name: string): any[];
21
+ getAll(): object;
22
+ list(): any[];
23
+ mock(): object;
24
+ #private;
25
+ }
26
+ import sinon from "sinon";
@@ -0,0 +1,14 @@
1
+ export const ESR_VER: 102;
2
+ export function fetchText(url: string): string;
3
+ export function getChannelUrl(channel: string): string;
4
+ export function getSchemaData(file: string, baseUrl: string): object;
5
+ export function getFileList(baseUrl: string): any[];
6
+ export function getAllSchemaData(baseUrl: string): Promise<any[]>;
7
+ export function getListedSchemaData(baseUrl: string, arr: any[]): Promise<any[]>;
8
+ export function getMailExtSchemaData(baseUrl: string): Promise<any[]>;
9
+ export function createUnifiedSchema(channel: string): object;
10
+ export function saveSchemaFile(channel: string, info: boolean): string;
11
+ export function updateSchemas(cmdOpts?: object): void;
12
+ export function parseCommand(args: any[]): void;
13
+ export { commander };
14
+ import { program as commander } from "commander";