capacitor-environment-checker 0.1.0
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/CHANGELOG.md +10 -0
- package/CapacitorEnvironmentChecker.podspec +13 -0
- package/LICENSE +21 -0
- package/Package.swift +27 -0
- package/README.md +58 -0
- package/android/build.gradle +30 -0
- package/android/src/main/java/com/guidg/environmentchecker/EnvironmentCheckerPlugin.kt +17 -0
- package/dist/definitions.d.ts +7 -0
- package/dist/definitions.d.ts.map +1 -0
- package/dist/definitions.js +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/web.d.ts +6 -0
- package/dist/web.d.ts.map +1 -0
- package/dist/web.js +6 -0
- package/ios/Sources/EnvironmentCheckerPlugin/EnvironmentCheckerPlugin.swift +16 -0
- package/ios/Tests/EnvironmentCheckerPluginTests/EnvironmentCheckerPluginTests.swift +8 -0
- package/package.json +72 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [0.1.0] - 2026-03-20
|
|
6
|
+
- Initial public release.
|
|
7
|
+
- Added isTestFlight() API with typed response.
|
|
8
|
+
- Implemented iOS TestFlight detection via sandboxReceipt heuristic.
|
|
9
|
+
- Added deterministic safe fallback for Android and Web (always false).
|
|
10
|
+
- Added lint/build/test CI workflow.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Pod::Spec.new do |s|
|
|
2
|
+
s.name = 'CapacitorEnvironmentChecker'
|
|
3
|
+
s.version = '0.1.0'
|
|
4
|
+
s.summary = 'Capacitor plugin to detect whether an iOS app is running via TestFlight.'
|
|
5
|
+
s.license = 'MIT'
|
|
6
|
+
s.homepage = 'https://github.com/guidg/capacitor-environment-checker'
|
|
7
|
+
s.author = { 'guidg' => 'guidg@users.noreply.github.com' }
|
|
8
|
+
s.source = { :git => 'https://github.com/guidg/capacitor-environment-checker.git', :tag => s.version.to_s }
|
|
9
|
+
s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
10
|
+
s.ios.deployment_target = '13.0'
|
|
11
|
+
s.dependency 'Capacitor'
|
|
12
|
+
s.swift_version = '5.9'
|
|
13
|
+
end
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 guidg
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/Package.swift
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// swift-tools-version:5.9
|
|
2
|
+
import PackageDescription
|
|
3
|
+
|
|
4
|
+
let package = Package(
|
|
5
|
+
name: "EnvironmentCheckerPlugin",
|
|
6
|
+
platforms: [.iOS(.v13)],
|
|
7
|
+
products: [
|
|
8
|
+
.library(name: "EnvironmentCheckerPlugin", targets: ["EnvironmentCheckerPlugin"])
|
|
9
|
+
],
|
|
10
|
+
dependencies: [
|
|
11
|
+
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "6.0.0")
|
|
12
|
+
],
|
|
13
|
+
targets: [
|
|
14
|
+
.target(
|
|
15
|
+
name: "EnvironmentCheckerPlugin",
|
|
16
|
+
dependencies: [
|
|
17
|
+
.product(name: "Capacitor", package: "capacitor-swift-pm")
|
|
18
|
+
],
|
|
19
|
+
path: "ios/Sources/EnvironmentCheckerPlugin"
|
|
20
|
+
),
|
|
21
|
+
.testTarget(
|
|
22
|
+
name: "EnvironmentCheckerPluginTests",
|
|
23
|
+
dependencies: ["EnvironmentCheckerPlugin"],
|
|
24
|
+
path: "ios/Tests/EnvironmentCheckerPluginTests"
|
|
25
|
+
)
|
|
26
|
+
]
|
|
27
|
+
)
|
package/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# capacitor-environment-checker
|
|
2
|
+
|
|
3
|
+
Capacitor plugin to detect whether an iOS app is running via TestFlight, with safe fallbacks for Android and Web.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i capacitor-environment-checker
|
|
9
|
+
npx cap sync
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import EnvironmentChecker from 'capacitor-environment-checker';
|
|
16
|
+
|
|
17
|
+
const { isTestFlight } = await EnvironmentChecker.isTestFlight();
|
|
18
|
+
console.log('isTestFlight:', isTestFlight);
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## API
|
|
22
|
+
|
|
23
|
+
### isTestFlight()
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
isTestFlight(): Promise<{ isTestFlight: boolean }>;
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Returns whether the app is running via TestFlight.
|
|
30
|
+
|
|
31
|
+
## Platform behavior
|
|
32
|
+
|
|
33
|
+
- iOS: uses sandbox receipt heuristic (`sandboxReceipt`) to infer TestFlight.
|
|
34
|
+
- Android: always returns `false` in v0.1.0.
|
|
35
|
+
- Web: always returns `false` in v0.1.0.
|
|
36
|
+
|
|
37
|
+
## Why Android/Web return false
|
|
38
|
+
|
|
39
|
+
`isTestFlight` is an iOS-specific concept. For v0.1.0, Android and Web are deterministic fallbacks to keep cross-platform code safe and predictable.
|
|
40
|
+
|
|
41
|
+
## Troubleshooting
|
|
42
|
+
|
|
43
|
+
- Method not found after install:
|
|
44
|
+
- Run `npx cap sync`.
|
|
45
|
+
- Rebuild native projects.
|
|
46
|
+
- iOS unexpected value:
|
|
47
|
+
- Validate whether app receipt is sandbox receipt.
|
|
48
|
+
- Ensure you are testing through the intended distribution flow.
|
|
49
|
+
|
|
50
|
+
## Compatibility
|
|
51
|
+
|
|
52
|
+
- Capacitor: `6+`
|
|
53
|
+
- TypeScript: supported
|
|
54
|
+
|
|
55
|
+
## Notes
|
|
56
|
+
|
|
57
|
+
- This plugin does not collect personal data.
|
|
58
|
+
- This plugin does not call external services.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
apply plugin: 'com.android.library'
|
|
2
|
+
|
|
3
|
+
android {
|
|
4
|
+
namespace "com.guidg.environmentchecker"
|
|
5
|
+
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 34
|
|
6
|
+
|
|
7
|
+
defaultConfig {
|
|
8
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
|
|
9
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 34
|
|
10
|
+
versionCode 1
|
|
11
|
+
versionName "0.1"
|
|
12
|
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
lintOptions {
|
|
16
|
+
abortOnError false
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
repositories {
|
|
21
|
+
google()
|
|
22
|
+
mavenCentral()
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
dependencies {
|
|
26
|
+
implementation project(':capacitor-android')
|
|
27
|
+
testImplementation "junit:junit:4.13.2"
|
|
28
|
+
androidTestImplementation "androidx.test.ext:junit:1.2.1"
|
|
29
|
+
androidTestImplementation "androidx.test.espresso:espresso-core:3.6.1"
|
|
30
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package com.guidg.environmentchecker
|
|
2
|
+
|
|
3
|
+
import com.getcapacitor.JSObject
|
|
4
|
+
import com.getcapacitor.Plugin
|
|
5
|
+
import com.getcapacitor.PluginCall
|
|
6
|
+
import com.getcapacitor.PluginMethod
|
|
7
|
+
import com.getcapacitor.annotation.CapacitorPlugin
|
|
8
|
+
|
|
9
|
+
@CapacitorPlugin(name = "EnvironmentChecker")
|
|
10
|
+
class EnvironmentCheckerPlugin : Plugin() {
|
|
11
|
+
@PluginMethod
|
|
12
|
+
fun isTestFlight(call: PluginCall) {
|
|
13
|
+
val result = JSObject()
|
|
14
|
+
result.put("isTestFlight", false)
|
|
15
|
+
call.resolve(result)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../src/definitions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,wBAAwB;IACvC,YAAY,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAC7C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAE9D,QAAA,MAAM,kBAAkB,0BAEtB,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAC9B,eAAe,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { registerPlugin } from '@capacitor/core';
|
|
2
|
+
const EnvironmentChecker = registerPlugin('EnvironmentChecker', {
|
|
3
|
+
web: () => import('./web').then((m) => new m.EnvironmentCheckerWeb()),
|
|
4
|
+
});
|
|
5
|
+
export * from './definitions';
|
|
6
|
+
export { EnvironmentChecker };
|
|
7
|
+
export default EnvironmentChecker;
|
package/dist/web.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
import type { EnvironmentCheckerPlugin, IsTestFlightResult } from './definitions';
|
|
3
|
+
export declare class EnvironmentCheckerWeb extends WebPlugin implements EnvironmentCheckerPlugin {
|
|
4
|
+
isTestFlight(): Promise<IsTestFlightResult>;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAElF,qBAAa,qBAAsB,SAAQ,SAAU,YAAW,wBAAwB;IAChF,YAAY,IAAI,OAAO,CAAC,kBAAkB,CAAC;CAGlD"}
|
package/dist/web.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Capacitor
|
|
2
|
+
import Foundation
|
|
3
|
+
|
|
4
|
+
@objc(EnvironmentCheckerPlugin)
|
|
5
|
+
public class EnvironmentCheckerPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
6
|
+
public let identifier = "EnvironmentCheckerPlugin"
|
|
7
|
+
public let jsName = "EnvironmentChecker"
|
|
8
|
+
public let pluginMethods: [CAPPluginMethod] = [
|
|
9
|
+
CAPPluginMethod(name: "isTestFlight", returnType: CAPPluginReturnPromise)
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
@objc public func isTestFlight(_ call: CAPPluginCall) {
|
|
13
|
+
let isTestFlight = Bundle.main.appStoreReceiptURL?.lastPathComponent == "sandboxReceipt"
|
|
14
|
+
call.resolve(["isTestFlight": isTestFlight])
|
|
15
|
+
}
|
|
16
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "capacitor-environment-checker",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Capacitor plugin to detect whether an iOS app is running via TestFlight, with safe fallbacks for Android and Web.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"android/src/main/",
|
|
17
|
+
"android/build.gradle",
|
|
18
|
+
"dist/",
|
|
19
|
+
"ios/Sources/",
|
|
20
|
+
"ios/Tests/",
|
|
21
|
+
"Package.swift",
|
|
22
|
+
"CapacitorEnvironmentChecker.podspec",
|
|
23
|
+
"README.md",
|
|
24
|
+
"CHANGELOG.md",
|
|
25
|
+
"LICENSE"
|
|
26
|
+
],
|
|
27
|
+
"keywords": [
|
|
28
|
+
"capacitor",
|
|
29
|
+
"capacitor-plugin",
|
|
30
|
+
"ios",
|
|
31
|
+
"testflight"
|
|
32
|
+
],
|
|
33
|
+
"author": "guidg",
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "git+https://github.com/guidg/capacitor-environment-checker.git"
|
|
38
|
+
},
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/guidg/capacitor-environment-checker/issues"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://github.com/guidg/capacitor-environment-checker#readme",
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsc -p tsconfig.json",
|
|
45
|
+
"clean": "rm -rf dist",
|
|
46
|
+
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
47
|
+
"test": "vitest run",
|
|
48
|
+
"verify": "npm run lint && npm run build && npm run test"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"@capacitor/core": "^6.0.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@eslint/js": "^9.23.0",
|
|
55
|
+
"@capacitor/android": "^6.2.0",
|
|
56
|
+
"@capacitor/core": "^6.2.0",
|
|
57
|
+
"@capacitor/ios": "^6.2.0",
|
|
58
|
+
"@typescript-eslint/eslint-plugin": "^8.30.1",
|
|
59
|
+
"@typescript-eslint/parser": "^8.30.1",
|
|
60
|
+
"eslint": "^9.23.0",
|
|
61
|
+
"typescript": "^5.8.2",
|
|
62
|
+
"vitest": "^3.0.8"
|
|
63
|
+
},
|
|
64
|
+
"capacitor": {
|
|
65
|
+
"ios": {
|
|
66
|
+
"src": "ios"
|
|
67
|
+
},
|
|
68
|
+
"android": {
|
|
69
|
+
"src": "android"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|