@brucewayne1939/sword-security 0.0.3

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/Package.swift ADDED
@@ -0,0 +1,28 @@
1
+ // swift-tools-version: 5.9
2
+ import PackageDescription
3
+
4
+ let package = Package(
5
+ name: "SwordSecurity",
6
+ platforms: [.iOS(.v15)],
7
+ products: [
8
+ .library(
9
+ name: "SwordSecurity",
10
+ targets: ["ExamplePlugin"])
11
+ ],
12
+ dependencies: [
13
+ .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0")
14
+ ],
15
+ targets: [
16
+ .target(
17
+ name: "ExamplePlugin",
18
+ dependencies: [
19
+ .product(name: "Capacitor", package: "capacitor-swift-pm"),
20
+ .product(name: "Cordova", package: "capacitor-swift-pm")
21
+ ],
22
+ path: "ios/Sources/ExamplePlugin"),
23
+ .testTarget(
24
+ name: "ExamplePluginTests",
25
+ dependencies: ["ExamplePlugin"],
26
+ path: "ios/Tests/ExamplePluginTests")
27
+ ]
28
+ )
package/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # sword-security
2
+
3
+ this plugin enables the app to use security features
4
+
5
+ ## Install
6
+
7
+ To use npm
8
+
9
+ ```bash
10
+ npm install sword-security
11
+ ````
12
+
13
+ To use yarn
14
+
15
+ ```bash
16
+ yarn add sword-security
17
+ ```
18
+
19
+ Sync native files
20
+
21
+ ```bash
22
+ npx cap sync
23
+ ```
24
+
25
+ ## API
26
+
27
+ <docgen-index></docgen-index>
28
+
29
+ <docgen-api>
30
+ <!-- run docgen to generate docs from the source -->
31
+ <!-- More info: https://github.com/ionic-team/capacitor-docgen -->
32
+ </docgen-api>
@@ -0,0 +1,17 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = 'SwordSecurity'
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.license = package['license']
10
+ s.homepage = package['repository']['url']
11
+ s.author = package['author']
12
+ s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
+ s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
14
+ s.ios.deployment_target = '15.0'
15
+ s.dependency 'Capacitor'
16
+ s.swift_version = '5.1'
17
+ end
@@ -0,0 +1,59 @@
1
+ ext {
2
+ junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
3
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.1'
4
+ androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.3.0'
5
+ androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.7.0'
6
+ }
7
+
8
+ buildscript {
9
+ repositories {
10
+ google()
11
+ mavenCentral()
12
+ }
13
+ dependencies {
14
+ classpath 'com.android.tools.build:gradle:8.13.0'
15
+ }
16
+ }
17
+
18
+ apply plugin: 'com.android.library'
19
+
20
+ android {
21
+ namespace = "com.mycompany.plugins.example"
22
+ compileSdk = project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 36
23
+ defaultConfig {
24
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 24
25
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 36
26
+ versionCode 1
27
+ versionName "1.0"
28
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
29
+ }
30
+ buildTypes {
31
+ release {
32
+ minifyEnabled false
33
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
34
+ }
35
+ }
36
+ lintOptions {
37
+ abortOnError = false
38
+ }
39
+ compileOptions {
40
+ sourceCompatibility JavaVersion.VERSION_21
41
+ targetCompatibility JavaVersion.VERSION_21
42
+ }
43
+ }
44
+
45
+
46
+ repositories {
47
+ google()
48
+ mavenCentral()
49
+ }
50
+
51
+
52
+ dependencies {
53
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
54
+ implementation project(':capacitor-android')
55
+ implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
56
+ testImplementation "junit:junit:$junitVersion"
57
+ androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
58
+ androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
59
+ }
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>
@@ -0,0 +1,11 @@
1
+ package com.mycompany.plugins.example;
2
+
3
+ import com.getcapacitor.Logger;
4
+
5
+ public class Example {
6
+
7
+ public String echo(String value) {
8
+ Logger.info("Echo", value);
9
+ return value;
10
+ }
11
+ }
@@ -0,0 +1,69 @@
1
+ package com.mycompany.plugins.example;
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
+ import java.io.File;
9
+
10
+ @CapacitorPlugin(name = "Security")
11
+ public class SecurityPlugin extends Plugin {
12
+
13
+ private Security implementation = new Security();
14
+
15
+ @PluginMethod
16
+ public void isDeveloperModeEnabled(PluginCall call) {
17
+
18
+ boolean enabled =
19
+ Settings.Global.getInt(
20
+ getContext().getContentResolver(),
21
+ Settings.Global.DEVELOPMENT_SETTINGS_ENABLED,
22
+ 0
23
+ ) != 0;
24
+
25
+ JSObject ret = new JSObject();
26
+ ret.put("enabled", enabled);
27
+
28
+ call.resolve(ret);
29
+ }
30
+
31
+ @PluginMethod
32
+ public void isRooted(PluginCall call) {
33
+
34
+ boolean rooted = checkRootMethod1() || checkRootMethod2();
35
+
36
+ JSObject ret = new JSObject();
37
+ ret.put("rooted", rooted);
38
+
39
+ call.resolve(ret);
40
+ }
41
+
42
+ private boolean checkRootMethod1() {
43
+ String buildTags = android.os.Build.TAGS;
44
+ return buildTags != null && buildTags.contains("test-keys");
45
+ }
46
+
47
+ private boolean checkRootMethod2() {
48
+
49
+ String[] paths = {
50
+ "/system/app/Superuser.apk",
51
+ "/sbin/su",
52
+ "/system/bin/su",
53
+ "/system/xbin/su",
54
+ "/data/local/xbin/su",
55
+ "/data/local/bin/su",
56
+ "/system/sd/xbin/su",
57
+ "/system/bin/failsafe/su",
58
+ "/data/local/su"
59
+ };
60
+
61
+ for (String path : paths) {
62
+ if (new File(path).exists()) {
63
+ return true;
64
+ }
65
+ }
66
+
67
+ return false;
68
+ }
69
+ }
File without changes
@@ -0,0 +1,8 @@
1
+ export interface SecurityPlugin {
2
+ isDeveloperModeEnabled(): Promise<{
3
+ enabled: boolean;
4
+ }>;
5
+ isRooted(): Promise<{
6
+ rooted: boolean;
7
+ }>;
8
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface SecurityPlugin {\n isDeveloperModeEnabled(): Promise<{ enabled: boolean }>;\n isRooted(): Promise<{ rooted: boolean }>;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { SecurityPlugin } from './definitions';
2
+ declare const Security: SecurityPlugin;
3
+ export * from './definitions';
4
+ export { Security };
@@ -0,0 +1,7 @@
1
+ import { registerPlugin } from '@capacitor/core';
2
+ const Security = registerPlugin('Security', {
3
+ web: () => import('./web').then((m) => new m.SecurityWeb()),
4
+ });
5
+ export * from './definitions';
6
+ export { Security };
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,QAAQ,GAAG,cAAc,CAAiB,UAAU,EAAE;IAC1D,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;CAC5D,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { SecurityPlugin } from './definitions';\n\nconst Security = registerPlugin<SecurityPlugin>('Security', {\n web: () => import('./web').then((m) => new m.SecurityWeb()),\n});\n\nexport * from './definitions';\nexport { Security };\n"]}
@@ -0,0 +1,10 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ import type { SecurityPlugin } from './definitions';
3
+ export declare class SecurityWeb extends WebPlugin implements SecurityPlugin {
4
+ isDeveloperModeEnabled(): Promise<{
5
+ enabled: boolean;
6
+ }>;
7
+ isRooted(): Promise<{
8
+ rooted: boolean;
9
+ }>;
10
+ }
@@ -0,0 +1,12 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ export class SecurityWeb extends WebPlugin {
3
+ async isDeveloperModeEnabled() {
4
+ // Web implementation - developer mode is typically not applicable
5
+ return { enabled: false };
6
+ }
7
+ async isRooted() {
8
+ // Web implementation - rooting is not applicable on web
9
+ return { rooted: false };
10
+ }
11
+ }
12
+ //# sourceMappingURL=web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,WAAY,SAAQ,SAAS;IACxC,KAAK,CAAC,sBAAsB;QAC1B,kEAAkE;QAClE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,wDAAwD;QACxD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAC3B,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { SecurityPlugin } from './definitions';\n\nexport class SecurityWeb extends WebPlugin implements SecurityPlugin {\n async isDeveloperModeEnabled(): Promise<{ enabled: boolean }> {\n // Web implementation - developer mode is typically not applicable\n return { enabled: false };\n }\n\n async isRooted(): Promise<{ rooted: boolean }> {\n // Web implementation - rooting is not applicable on web\n return { rooted: false };\n }\n}\n"]}
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ var core = require('@capacitor/core');
4
+
5
+ const Security = core.registerPlugin('Security', {
6
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.SecurityWeb()),
7
+ });
8
+
9
+ class SecurityWeb extends core.WebPlugin {
10
+ async isDeveloperModeEnabled() {
11
+ // Web implementation - developer mode is typically not applicable
12
+ return { enabled: false };
13
+ }
14
+ async isRooted() {
15
+ // Web implementation - rooting is not applicable on web
16
+ return { rooted: false };
17
+ }
18
+ }
19
+
20
+ var web = /*#__PURE__*/Object.freeze({
21
+ __proto__: null,
22
+ SecurityWeb: SecurityWeb
23
+ });
24
+
25
+ exports.Security = Security;
26
+ //# sourceMappingURL=plugin.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Security = registerPlugin('Security', {\n web: () => import('./web').then((m) => new m.SecurityWeb()),\n});\nexport * from './definitions';\nexport { Security };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class SecurityWeb extends WebPlugin {\n async isDeveloperModeEnabled() {\n // Web implementation - developer mode is typically not applicable\n return { enabled: false };\n }\n async isRooted() {\n // Web implementation - rooting is not applicable on web\n return { rooted: false };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,QAAQ,GAAGA,mBAAc,CAAC,UAAU,EAAE;AAC5C,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;AAC/D,CAAC;;ACFM,MAAM,WAAW,SAASC,cAAS,CAAC;AAC3C,IAAI,MAAM,sBAAsB,GAAG;AACnC;AACA,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;AACjC,IAAI;AACJ,IAAI,MAAM,QAAQ,GAAG;AACrB;AACA,QAAQ,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE;AAChC,IAAI;AACJ;;;;;;;;;"}
package/dist/plugin.js ADDED
@@ -0,0 +1,29 @@
1
+ var capacitorExample = (function (exports, core) {
2
+ 'use strict';
3
+
4
+ const Security = core.registerPlugin('Security', {
5
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.SecurityWeb()),
6
+ });
7
+
8
+ class SecurityWeb extends core.WebPlugin {
9
+ async isDeveloperModeEnabled() {
10
+ // Web implementation - developer mode is typically not applicable
11
+ return { enabled: false };
12
+ }
13
+ async isRooted() {
14
+ // Web implementation - rooting is not applicable on web
15
+ return { rooted: false };
16
+ }
17
+ }
18
+
19
+ var web = /*#__PURE__*/Object.freeze({
20
+ __proto__: null,
21
+ SecurityWeb: SecurityWeb
22
+ });
23
+
24
+ exports.Security = Security;
25
+
26
+ return exports;
27
+
28
+ })({}, capacitorExports);
29
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Security = registerPlugin('Security', {\n web: () => import('./web').then((m) => new m.SecurityWeb()),\n});\nexport * from './definitions';\nexport { Security };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class SecurityWeb extends WebPlugin {\n async isDeveloperModeEnabled() {\n // Web implementation - developer mode is typically not applicable\n return { enabled: false };\n }\n async isRooted() {\n // Web implementation - rooting is not applicable on web\n return { rooted: false };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,QAAQ,GAAGA,mBAAc,CAAC,UAAU,EAAE;IAC5C,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;IAC/D,CAAC;;ICFM,MAAM,WAAW,SAASC,cAAS,CAAC;IAC3C,IAAI,MAAM,sBAAsB,GAAG;IACnC;IACA,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;IACjC,IAAI;IACJ,IAAI,MAAM,QAAQ,GAAG;IACrB;IACA,QAAQ,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE;IAChC,IAAI;IACJ;;;;;;;;;;;;;;;"}
@@ -0,0 +1,8 @@
1
+ import Foundation
2
+
3
+ @objc public class Example: NSObject {
4
+ @objc public func echo(_ value: String) -> String {
5
+ print(value)
6
+ return value
7
+ }
8
+ }
@@ -0,0 +1,23 @@
1
+ import Foundation
2
+ import Capacitor
3
+
4
+ /**
5
+ * Please read the Capacitor iOS Plugin Development Guide
6
+ * here: https://capacitorjs.com/docs/plugins/ios
7
+ */
8
+ @objc(ExamplePlugin)
9
+ public class ExamplePlugin: CAPPlugin, CAPBridgedPlugin {
10
+ public let identifier = "ExamplePlugin"
11
+ public let jsName = "Example"
12
+ public let pluginMethods: [CAPPluginMethod] = [
13
+ CAPPluginMethod(name: "echo", returnType: CAPPluginReturnPromise)
14
+ ]
15
+ private let implementation = Example()
16
+
17
+ @objc func echo(_ call: CAPPluginCall) {
18
+ let value = call.getString("value") ?? ""
19
+ call.resolve([
20
+ "value": implementation.echo(value)
21
+ ])
22
+ }
23
+ }
@@ -0,0 +1,15 @@
1
+ import XCTest
2
+ @testable import ExamplePlugin
3
+
4
+ class ExampleTests: XCTestCase {
5
+ func testEcho() {
6
+ // This is an example of a functional test case for a plugin.
7
+ // Use XCTAssert and related functions to verify your tests produce the correct results.
8
+
9
+ let implementation = Example()
10
+ let value = "Hello, World!"
11
+ let result = implementation.echo(value)
12
+
13
+ XCTAssertEqual(value, result)
14
+ }
15
+ }
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "@brucewayne1939/sword-security",
3
+ "version": "0.0.3",
4
+ "description": "this plugin enables the app to use security features",
5
+ "main": "dist/plugin.cjs.js",
6
+ "module": "dist/esm/index.js",
7
+ "types": "dist/esm/index.d.ts",
8
+ "unpkg": "dist/plugin.js",
9
+ "files": [
10
+ "android/src/main/",
11
+ "android/build.gradle",
12
+ "dist/",
13
+ "ios/Sources",
14
+ "ios/Tests",
15
+ "Package.swift",
16
+ "SwordSecurity.podspec"
17
+ ],
18
+ "author": "santkumar rajbhar",
19
+ "license": "MIT",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/santku666/ionic-plugins.git"
23
+ },
24
+ "bugs": {
25
+ "url": "https://github.com/santku666/ionic-plugins/issues"
26
+ },
27
+ "keywords": [
28
+ "capacitor",
29
+ "plugin",
30
+ "native"
31
+ ],
32
+ "scripts": {
33
+ "verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
34
+ "verify:ios": "xcodebuild -scheme SwordSecurity -destination generic/platform=iOS",
35
+ "verify:android": "cd android && ./gradlew clean build test && cd ..",
36
+ "verify:web": "npm run build",
37
+ "lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
38
+ "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
39
+ "eslint": "eslint . --ext ts",
40
+ "prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
41
+ "swiftlint": "node-swiftlint",
42
+ "docgen": "docgen --api ExamplePlugin --output-readme README.md --output-json dist/docs.json",
43
+ "build": "npm run clean && tsc && rollup -c rollup.config.mjs",
44
+ "clean": "rimraf ./dist",
45
+ "watch": "tsc --watch",
46
+ "prepublishOnly": "npm run build"
47
+ },
48
+ "devDependencies": {
49
+ "@capacitor/android": "^8.0.0",
50
+ "@capacitor/core": "^8.0.0",
51
+ "@capacitor/docgen": "^0.3.1",
52
+ "@capacitor/ios": "^8.0.0",
53
+ "@ionic/eslint-config": "^0.4.0",
54
+ "@ionic/prettier-config": "^4.0.0",
55
+ "@ionic/swiftlint-config": "^2.0.0",
56
+ "eslint": "^8.57.1",
57
+ "prettier": "^3.6.2",
58
+ "prettier-plugin-java": "^2.7.7",
59
+ "rimraf": "^6.1.0",
60
+ "rollup": "^4.53.2",
61
+ "swiftlint": "^2.0.0",
62
+ "typescript": "^5.9.3"
63
+ },
64
+ "peerDependencies": {
65
+ "@capacitor/core": ">=8.0.0"
66
+ },
67
+ "prettier": "@ionic/prettier-config",
68
+ "swiftlint": "@ionic/swiftlint-config",
69
+ "eslintConfig": {
70
+ "extends": "@ionic/eslint-config/recommended"
71
+ },
72
+ "capacitor": {
73
+ "ios": {
74
+ "src": "ios"
75
+ },
76
+ "android": {
77
+ "src": "android"
78
+ }
79
+ }
80
+ }