From ae998f951d712dbf71c0d1e226bf6d8cbae19c49 Mon Sep 17 00:00:00 2001 From: Niklas Higi Date: Mon, 18 Jan 2021 22:12:12 +0100 Subject: [PATCH] Inline NSC XML template This makes it possible to include apk-mitm in a project built with webpack (like APK Lab). --- package.json | 3 +-- res/nsc_mitm.xml | 11 ----------- src/tasks/create-netsec-config.ts | 14 ++++++++++++-- 3 files changed, 13 insertions(+), 15 deletions(-) delete mode 100644 res/nsc_mitm.xml diff --git a/package.json b/package.json index 1302693..db55b48 100644 --- a/package.json +++ b/package.json @@ -22,8 +22,7 @@ "bin": "bin/apk-mitm", "files": [ "bin", - "dist", - "res" + "dist" ], "engines": { "node": ">=10" diff --git a/res/nsc_mitm.xml b/res/nsc_mitm.xml deleted file mode 100644 index 1bc8f00..0000000 --- a/res/nsc_mitm.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/src/tasks/create-netsec-config.ts b/src/tasks/create-netsec-config.ts index 26226e5..2c54641 100644 --- a/src/tasks/create-netsec-config.ts +++ b/src/tasks/create-netsec-config.ts @@ -1,9 +1,19 @@ import * as fs from '../utils/fs' import * as pathUtils from 'path' -const TEMPLATE_PATH = pathUtils.join(__dirname, '../../res/nsc_mitm.xml') +const TEMPLATE = ` + + + + + + + + + +` export default async function createNetworkSecurityConfig(path: string) { await fs.mkdir(pathUtils.dirname(path), { recursive: true }) - await fs.copyFile(TEMPLATE_PATH, path) + await fs.writeFile(path, TEMPLATE, 'utf-8') }