@capgo/capacitor-ssl-pinning 8.1.2 → 8.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/README.md CHANGED
@@ -22,6 +22,20 @@ The most complete doc is available here: https://capgo.app/docs/plugins/ssl-pinn
22
22
 
23
23
  ## Install
24
24
 
25
+ You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:
26
+
27
+ ```bash
28
+ npx skills add https://github.com/cap-go/capacitor-skills --skill capacitor-plugins
29
+ ```
30
+
31
+ Then use the following prompt:
32
+
33
+ ```text
34
+ Use the `capacitor-plugins` skill from `cap-go/capacitor-skills` to install the `@capgo/capacitor-ssl-pinning` plugin in my project.
35
+ ```
36
+
37
+ If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:
38
+
25
39
  ```bash
26
40
  bun add @capgo/capacitor-ssl-pinning
27
41
  bunx cap sync
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-ssl-pinning",
3
- "version": "8.1.2",
3
+ "version": "8.1.4",
4
4
  "description": "Capacitor SSL pinning plugin for Android and iOS that integrates with CapacitorHttp.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -53,7 +53,10 @@
53
53
  "check:wiring": "node scripts/check-capacitor-plugin-wiring.mjs",
54
54
  "prepare:certs": "bun run scripts/prepare-certs.mjs",
55
55
  "capacitor:sync:before": "bun run prepare:certs",
56
- "capacitor:update:before": "bun run prepare:certs"
56
+ "capacitor:update:before": "bun run prepare:certs",
57
+ "example:install": "cd example-app && bun install --frozen-lockfile",
58
+ "example:build": "bun run build && cd example-app && bun install --frozen-lockfile && bun run build",
59
+ "example:capgo:deploy": "bun run example:build && bun scripts/deploy-example-capgo.mjs"
57
60
  },
58
61
  "devDependencies": {
59
62
  "@capacitor/android": "^8.0.0",
@@ -0,0 +1,117 @@
1
+ #!/usr/bin/env node
2
+ import { existsSync, readFileSync } from 'node:fs';
3
+ import { dirname, resolve } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+ import { spawnSync } from 'node:child_process';
6
+
7
+ const __dirname = dirname(fileURLToPath(import.meta.url));
8
+ const repoRoot = resolve(__dirname, '..');
9
+ const appDir = resolve(repoRoot, 'example-app');
10
+ const rootPackageJson = JSON.parse(readFileSync(resolve(repoRoot, 'package.json'), 'utf8'));
11
+ const examplePackageJson = JSON.parse(readFileSync(resolve(appDir, 'package.json'), 'utf8'));
12
+ const tsConfigPath = resolve(appDir, 'capacitor.config.ts');
13
+ const jsonConfigPath = resolve(appDir, 'capacitor.config.json');
14
+ const configPath = existsSync(tsConfigPath) ? tsConfigPath : existsSync(jsonConfigPath) ? jsonConfigPath : null;
15
+
16
+ if (!configPath) {
17
+ console.error(
18
+ 'Missing Capacitor config. Expected example-app/capacitor.config.ts or example-app/capacitor.config.json.',
19
+ );
20
+ process.exit(1);
21
+ }
22
+
23
+ const configText = readFileSync(configPath, 'utf8');
24
+
25
+ function readConfigString(key, fallback) {
26
+ const match = configText.match(new RegExp(`['"]?${key}['"]?\\s*[:=]\\s*['"]([^'"]+)['"]`));
27
+ return match?.[1] ?? fallback;
28
+ }
29
+
30
+ function runCapgo(args, allowFailure = false) {
31
+ const token = process.env.CAPGO_TOKEN;
32
+ const fullArgs = ['@capgo/cli@8.5.3', ...args];
33
+ if (token) {
34
+ fullArgs.push('--apikey', token);
35
+ }
36
+ const result = spawnSync('bunx', fullArgs, {
37
+ cwd: appDir,
38
+ stdio: 'inherit',
39
+ env: process.env,
40
+ });
41
+ if (!allowFailure && result.status !== 0) {
42
+ process.exit(result.status ?? 1);
43
+ }
44
+ return result.status ?? 1;
45
+ }
46
+
47
+ const appId = process.env.CAPGO_APP_ID || readConfigString('appId');
48
+ const appName = process.env.CAPGO_APP_NAME || readConfigString('appName', rootPackageJson.name);
49
+ const webDir = process.env.CAPGO_WEB_DIR || readConfigString('webDir', 'dist');
50
+ const distDir = resolve(appDir, webDir);
51
+ const channel = process.env.CAPGO_CHANNEL || process.argv[2] || 'production';
52
+ function usableVersion(version) {
53
+ return version && version !== '0.0.0' ? version : undefined;
54
+ }
55
+
56
+ const bundle =
57
+ process.env.CAPGO_BUNDLE || usableVersion(examplePackageJson.version) || usableVersion(rootPackageJson.version);
58
+ const comment =
59
+ process.env.CAPGO_COMMENT ||
60
+ (process.env.GITHUB_RUN_NUMBER ? `${appName} run ${process.env.GITHUB_RUN_NUMBER}` : `${appName} ${bundle}`);
61
+ const iconPath = process.env.CAPGO_ICON || resolve(appDir, 'assets', 'capgo-icon.png');
62
+
63
+ if (!appId) {
64
+ console.error('Missing Capgo app id. Set CAPGO_APP_ID or example-app/capacitor.config.* appId.');
65
+ process.exit(1);
66
+ }
67
+
68
+ if (!existsSync(distDir)) {
69
+ console.error(`Missing example app bundle at ${distDir}. Run bun run example:build first.`);
70
+ process.exit(1);
71
+ }
72
+
73
+ if (!bundle) {
74
+ console.error(
75
+ 'Missing Capgo bundle version. Set CAPGO_BUNDLE or add a version to example-app/package.json or package.json.',
76
+ );
77
+ process.exit(1);
78
+ }
79
+
80
+ const appArgs = [appId, '--name', appName];
81
+ if (existsSync(iconPath)) {
82
+ appArgs.push('--icon', iconPath);
83
+ }
84
+
85
+ const setStatus = runCapgo(['app', 'set', ...appArgs], true);
86
+ if (setStatus !== 0) {
87
+ runCapgo(['app', 'add', ...appArgs]);
88
+ }
89
+
90
+ console.log(`Deploying ${appId} to Capgo channel "${channel}"`);
91
+ const channelArgs = ['channel', 'add', channel, appId];
92
+ if (channel === 'production') {
93
+ channelArgs.push('--default');
94
+ }
95
+ runCapgo(channelArgs, true);
96
+
97
+ runCapgo([
98
+ 'bundle',
99
+ 'upload',
100
+ appId,
101
+ '--bundle',
102
+ bundle,
103
+ '--path',
104
+ webDir,
105
+ '--channel',
106
+ channel,
107
+ '--package-json',
108
+ 'package.json,../package.json',
109
+ '--node-modules',
110
+ 'node_modules,../node_modules',
111
+ '--delta',
112
+ '--no-key',
113
+ '--ignore-checksum-check',
114
+ '--version-exists-ok',
115
+ '--comment',
116
+ comment,
117
+ ]);