Skip to content

Commit

Permalink
refactor(tauri) rename whitelist to allowlist, ref #645 (#858)
Browse files Browse the repository at this point in the history
* refactor(tauri) rename `whitelist` to `allowlist`, ref #645

* chore(changes) add changefile
  • Loading branch information
lucasfernog committed Jul 19, 2020
1 parent cbd14c3 commit a6bb3b5
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 75 deletions.
5 changes: 5 additions & 0 deletions .changes/refactor-whitelist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri": minor
---

Renaming `whitelist` to `allowlist` (see #645).
2 changes: 1 addition & 1 deletion cli/tauri.js/src/helpers/tauri-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const getTauriConfig = (cfg: Partial<TauriConfig>): TauriConfig => {
frameworks: []
}
},
whitelist: {
allowlist: {
all: false
},
window: {
Expand Down
14 changes: 7 additions & 7 deletions cli/tauri.js/src/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class Runner {

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

const runningDevServer = devPath.startsWith('http')
Expand Down Expand Up @@ -248,7 +248,7 @@ class Runner {
}

const cargoManifest = this.__getManifest()
this.__whitelistApi(cfg, cargoManifest as unknown as CargoManifest)
this.__allowlistApi(cfg, cargoManifest as unknown as CargoManifest)
this.__rewriteManifest(cargoManifest)

const inlinedAssets = (await this.__parseHtml(cfg, cfg.build.distDir)).inlinedAssets
Expand Down Expand Up @@ -507,24 +507,24 @@ class Runner {
}, WATCHER_INTERVAL * 2)
}

__whitelistApi(
__allowlistApi(
cfg: TauriConfig,
manifest: CargoManifest
): void {
const tomlFeatures = []

if (cfg.tauri.whitelist.all) {
if (cfg.tauri.allowlist.all) {
tomlFeatures.push('all-api')
} else {
const toKebabCase = (value: string): string => {
return value.replace(/([a-z])([A-Z])/g, '$1-$2')
.replace(/\s+/g, '-')
.toLowerCase()
}
const whitelist = Object.keys(cfg.tauri.whitelist).filter(
w => cfg.tauri.whitelist[String(w)]
const allowlist = Object.keys(cfg.tauri.allowlist).filter(
w => cfg.tauri.allowlist[String(w)]
)
tomlFeatures.push(...whitelist.map(toKebabCase))
tomlFeatures.push(...allowlist.map(toKebabCase))
}

if (cfg.tauri.cli) {
Expand Down
2 changes: 1 addition & 1 deletion cli/tauri.js/src/template/defaultConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default {
},
exceptionDomain: ''
},
whitelist: {
allowlist: {
all: true
},
window: {
Expand Down
34 changes: 17 additions & 17 deletions cli/tauri.js/src/types/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,22 @@
],
"description": "tauri root configuration object",
"properties": {
"allowlist": {
"additionalProperties": {
"type": "boolean"
},
"defaultProperties": [
],
"properties": {
"all": {
"type": "boolean"
}
},
"required": [
"all"
],
"type": "object"
},
"bundle": {
"additionalProperties": false,
"defaultProperties": [
Expand Down Expand Up @@ -440,22 +456,6 @@
},
"type": "object"
},
"whitelist": {
"additionalProperties": {
"type": "boolean"
},
"defaultProperties": [
],
"properties": {
"all": {
"type": "boolean"
}
},
"required": [
"all"
],
"type": "object"
},
"window": {
"additionalProperties": false,
"defaultProperties": [
Expand Down Expand Up @@ -484,11 +484,11 @@
}
},
"required": [
"allowlist",
"bundle",
"embeddedServer",
"inliner",
"security",
"whitelist",
"window"
],
"type": "object"
Expand Down
2 changes: 1 addition & 1 deletion cli/tauri.js/src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export interface TauriConfig {
}
exceptionDomain?: string
}
whitelist: {
allowlist: {
all: boolean
[index: string]: boolean
}
Expand Down
34 changes: 17 additions & 17 deletions cli/tauri.js/src/types/config.validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,22 @@ export const TauriConfigSchema = {
],
"description": "tauri root configuration object",
"properties": {
"allowlist": {
"additionalProperties": {
"type": "boolean"
},
"defaultProperties": [
],
"properties": {
"all": {
"type": "boolean"
}
},
"required": [
"all"
],
"type": "object"
},
"bundle": {
"additionalProperties": false,
"defaultProperties": [
Expand Down Expand Up @@ -450,22 +466,6 @@ export const TauriConfigSchema = {
},
"type": "object"
},
"whitelist": {
"additionalProperties": {
"type": "boolean"
},
"defaultProperties": [
],
"properties": {
"all": {
"type": "boolean"
}
},
"required": [
"all"
],
"type": "object"
},
"window": {
"additionalProperties": false,
"defaultProperties": [
Expand Down Expand Up @@ -494,11 +494,11 @@ export const TauriConfigSchema = {
}
},
"required": [
"allowlist",
"bundle",
"embeddedServer",
"inliner",
"security",
"whitelist",
"window"
],
"type": "object"
Expand Down
4 changes: 2 additions & 2 deletions cli/tauri.js/test/jest/fixtures/app/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"distDir": "../dist"
},
"tauri": {
"whitelist": {
"allowlist": {
"all": true
},
"bundle": {
Expand All @@ -15,4 +15,4 @@
"title": "Fixture"
}
}
}
}
2 changes: 1 addition & 1 deletion tauri/examples/communication/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"icons/32x32.png", "icons/128x128.png", "icons/128x128@2x.png", "icons/icon.icns", "icons/icon.ico"
]
},
"whitelist": {
"allowlist": {
"all": true
},
"window": {
Expand Down
Loading

0 comments on commit a6bb3b5

Please sign in to comment.