Skip to content

Commit a6bb3b5

Browse files
authored
refactor(tauri) rename whitelist to allowlist, ref #645 (#858)
* refactor(tauri) rename `whitelist` to `allowlist`, ref #645 * chore(changes) add changefile
1 parent cbd14c3 commit a6bb3b5

11 files changed

Lines changed: 83 additions & 75 deletions

File tree

.changes/refactor-whitelist.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri": minor
3+
---
4+
5+
Renaming `whitelist` to `allowlist` (see #645).

cli/tauri.js/src/helpers/tauri-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const getTauriConfig = (cfg: Partial<TauriConfig>): TauriConfig => {
4141
frameworks: []
4242
}
4343
},
44-
whitelist: {
44+
allowlist: {
4545
all: false
4646
},
4747
window: {

cli/tauri.js/src/runner.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class Runner {
8484

8585
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
8686
const cargoManifest = this.__getManifest() as any as CargoManifest
87-
this.__whitelistApi(cfg, cargoManifest)
87+
this.__allowlistApi(cfg, cargoManifest)
8888
this.__rewriteManifest(cargoManifest as unknown as toml.JsonMap)
8989

9090
const runningDevServer = devPath.startsWith('http')
@@ -248,7 +248,7 @@ class Runner {
248248
}
249249

250250
const cargoManifest = this.__getManifest()
251-
this.__whitelistApi(cfg, cargoManifest as unknown as CargoManifest)
251+
this.__allowlistApi(cfg, cargoManifest as unknown as CargoManifest)
252252
this.__rewriteManifest(cargoManifest)
253253

254254
const inlinedAssets = (await this.__parseHtml(cfg, cfg.build.distDir)).inlinedAssets
@@ -507,24 +507,24 @@ class Runner {
507507
}, WATCHER_INTERVAL * 2)
508508
}
509509

510-
__whitelistApi(
510+
__allowlistApi(
511511
cfg: TauriConfig,
512512
manifest: CargoManifest
513513
): void {
514514
const tomlFeatures = []
515515

516-
if (cfg.tauri.whitelist.all) {
516+
if (cfg.tauri.allowlist.all) {
517517
tomlFeatures.push('all-api')
518518
} else {
519519
const toKebabCase = (value: string): string => {
520520
return value.replace(/([a-z])([A-Z])/g, '$1-$2')
521521
.replace(/\s+/g, '-')
522522
.toLowerCase()
523523
}
524-
const whitelist = Object.keys(cfg.tauri.whitelist).filter(
525-
w => cfg.tauri.whitelist[String(w)]
524+
const allowlist = Object.keys(cfg.tauri.allowlist).filter(
525+
w => cfg.tauri.allowlist[String(w)]
526526
)
527-
tomlFeatures.push(...whitelist.map(toKebabCase))
527+
tomlFeatures.push(...allowlist.map(toKebabCase))
528528
}
529529

530530
if (cfg.tauri.cli) {

cli/tauri.js/src/template/defaultConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default {
3232
},
3333
exceptionDomain: ''
3434
},
35-
whitelist: {
35+
allowlist: {
3636
all: true
3737
},
3838
window: {

cli/tauri.js/src/types/config.schema.json

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,22 @@
277277
],
278278
"description": "tauri root configuration object",
279279
"properties": {
280+
"allowlist": {
281+
"additionalProperties": {
282+
"type": "boolean"
283+
},
284+
"defaultProperties": [
285+
],
286+
"properties": {
287+
"all": {
288+
"type": "boolean"
289+
}
290+
},
291+
"required": [
292+
"all"
293+
],
294+
"type": "object"
295+
},
280296
"bundle": {
281297
"additionalProperties": false,
282298
"defaultProperties": [
@@ -440,22 +456,6 @@
440456
},
441457
"type": "object"
442458
},
443-
"whitelist": {
444-
"additionalProperties": {
445-
"type": "boolean"
446-
},
447-
"defaultProperties": [
448-
],
449-
"properties": {
450-
"all": {
451-
"type": "boolean"
452-
}
453-
},
454-
"required": [
455-
"all"
456-
],
457-
"type": "object"
458-
},
459459
"window": {
460460
"additionalProperties": false,
461461
"defaultProperties": [
@@ -484,11 +484,11 @@
484484
}
485485
},
486486
"required": [
487+
"allowlist",
487488
"bundle",
488489
"embeddedServer",
489490
"inliner",
490491
"security",
491-
"whitelist",
492492
"window"
493493
],
494494
"type": "object"

cli/tauri.js/src/types/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ export interface TauriConfig {
271271
}
272272
exceptionDomain?: string
273273
}
274-
whitelist: {
274+
allowlist: {
275275
all: boolean
276276
[index: string]: boolean
277277
}

cli/tauri.js/src/types/config.validator.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,22 @@ export const TauriConfigSchema = {
287287
],
288288
"description": "tauri root configuration object",
289289
"properties": {
290+
"allowlist": {
291+
"additionalProperties": {
292+
"type": "boolean"
293+
},
294+
"defaultProperties": [
295+
],
296+
"properties": {
297+
"all": {
298+
"type": "boolean"
299+
}
300+
},
301+
"required": [
302+
"all"
303+
],
304+
"type": "object"
305+
},
290306
"bundle": {
291307
"additionalProperties": false,
292308
"defaultProperties": [
@@ -450,22 +466,6 @@ export const TauriConfigSchema = {
450466
},
451467
"type": "object"
452468
},
453-
"whitelist": {
454-
"additionalProperties": {
455-
"type": "boolean"
456-
},
457-
"defaultProperties": [
458-
],
459-
"properties": {
460-
"all": {
461-
"type": "boolean"
462-
}
463-
},
464-
"required": [
465-
"all"
466-
],
467-
"type": "object"
468-
},
469469
"window": {
470470
"additionalProperties": false,
471471
"defaultProperties": [
@@ -494,11 +494,11 @@ export const TauriConfigSchema = {
494494
}
495495
},
496496
"required": [
497+
"allowlist",
497498
"bundle",
498499
"embeddedServer",
499500
"inliner",
500501
"security",
501-
"whitelist",
502502
"window"
503503
],
504504
"type": "object"

cli/tauri.js/test/jest/fixtures/app/src-tauri/tauri.conf.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"distDir": "../dist"
55
},
66
"tauri": {
7-
"whitelist": {
7+
"allowlist": {
88
"all": true
99
},
1010
"bundle": {
@@ -15,4 +15,4 @@
1515
"title": "Fixture"
1616
}
1717
}
18-
}
18+
}

tauri/examples/communication/src-tauri/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"icons/32x32.png", "icons/128x128.png", "icons/128x128@2x.png", "icons/icon.icns", "icons/icon.ico"
4747
]
4848
},
49-
"whitelist": {
49+
"allowlist": {
5050
"all": true
5151
},
5252
"window": {

0 commit comments

Comments
 (0)