@brucewayne1939/sword-security 0.0.4 → 0.0.6

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,68 @@ Sync native files
22
22
  npx cap sync
23
23
  ```
24
24
 
25
+ ## Usage
26
+
27
+ Add the following to your `app.component.ts`:
28
+
29
+ ```typescript
30
+ import { Security } from 'sword-security';
31
+
32
+ @Component({
33
+ // ...
34
+ })
35
+ export class AppComponent implements OnInit {
36
+ securityPopupOpen = false;
37
+
38
+ constructor(private alertController: AlertController) {}
39
+
40
+ async ngOnInit() {
41
+ await this.checkDeviceSecurity();
42
+
43
+ App.addListener('appStateChange', async ({ isActive }) => {
44
+ if (isActive) {
45
+ console.log('App resumed');
46
+ await this.checkDeviceSecurity();
47
+ }
48
+ });
49
+ }
50
+
51
+ async checkDeviceSecurity() {
52
+ try {
53
+ const rootResult = await Security.isRooted();
54
+ const devResult = await Security.isDeveloperModeEnabled();
55
+ console.log('Rooted:', rootResult.rooted);
56
+ console.log('Developer Mode:', devResult.enabled);
57
+
58
+ const insecure = rootResult.rooted || devResult.enabled;
59
+
60
+ if (insecure && !this.securityPopupOpen) {
61
+ this.securityPopupOpen = true;
62
+
63
+ const alert = await this.alertController.create({
64
+ header: 'Security Warning',
65
+ message: 'Developer options, USB debugging, or root access detected. Please disable them to continue.',
66
+ backdropDismiss: false,
67
+ buttons: [
68
+ {
69
+ text: 'Open Settings',
70
+ handler: async () => {
71
+ this.securityPopupOpen = false;
72
+ await Security.openDeveloperSettings();
73
+ }
74
+ }
75
+ ]
76
+ });
77
+
78
+ await alert.present();
79
+ }
80
+ } catch (err) {
81
+ console.error(err);
82
+ }
83
+ }
84
+ }
85
+ ```
86
+
25
87
  ## API
26
88
 
27
89
  <docgen-index></docgen-index>
@@ -1,4 +1,4 @@
1
1
  import type { SecurityPlugin } from './definitions';
2
- declare const Security: SecurityPlugin;
2
+ declare const SecurityPlugin: SecurityPlugin;
3
3
  export * from './definitions';
4
- export { Security };
4
+ export { SecurityPlugin };
package/dist/esm/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { registerPlugin } from '@capacitor/core';
2
- const Security = registerPlugin('Security', {
2
+ const SecurityPlugin = registerPlugin('SecurityPlugin', {
3
3
  web: () => import('./web').then((m) => new m.SecurityWeb()),
4
4
  });
5
5
  export * from './definitions';
6
- export { Security };
6
+ export { SecurityPlugin };
7
7
  //# sourceMappingURL=index.js.map
@@ -1 +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"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,cAAc,GAAG,cAAc,CAAiB,gBAAgB,EAAE;IACtE,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,cAAc,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { SecurityPlugin } from './definitions';\n\nconst SecurityPlugin = registerPlugin<SecurityPlugin>('SecurityPlugin', {\n web: () => import('./web').then((m) => new m.SecurityWeb()),\n});\n\nexport * from './definitions';\nexport { SecurityPlugin };\n"]}
@@ -2,7 +2,7 @@
2
2
 
3
3
  var core = require('@capacitor/core');
4
4
 
5
- const Security = core.registerPlugin('Security', {
5
+ const SecurityPlugin = core.registerPlugin('SecurityPlugin', {
6
6
  web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.SecurityWeb()),
7
7
  });
8
8
 
@@ -25,5 +25,5 @@ var web = /*#__PURE__*/Object.freeze({
25
25
  SecurityWeb: SecurityWeb
26
26
  });
27
27
 
28
- exports.Security = Security;
28
+ exports.SecurityPlugin = SecurityPlugin;
29
29
  //# sourceMappingURL=plugin.cjs.js.map
@@ -1 +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 async openDeveloperSettings() {\n console.warn('Not supported on web');\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,IAAI,MAAM,qBAAqB,GAAG;AAClC,QAAQ,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC;AAC5C,IAAI;AACJ;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst SecurityPlugin = registerPlugin('SecurityPlugin', {\n web: () => import('./web').then((m) => new m.SecurityWeb()),\n});\nexport * from './definitions';\nexport { SecurityPlugin };\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 async openDeveloperSettings() {\n console.warn('Not supported on web');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,cAAc,GAAGA,mBAAc,CAAC,gBAAgB,EAAE;AACxD,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,IAAI,MAAM,qBAAqB,GAAG;AAClC,QAAQ,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC;AAC5C,IAAI;AACJ;;;;;;;;;"}
package/dist/plugin.js CHANGED
@@ -1,7 +1,7 @@
1
1
  var capacitorExample = (function (exports, core) {
2
2
  'use strict';
3
3
 
4
- const Security = core.registerPlugin('Security', {
4
+ const SecurityPlugin = core.registerPlugin('SecurityPlugin', {
5
5
  web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.SecurityWeb()),
6
6
  });
7
7
 
@@ -24,7 +24,7 @@ var capacitorExample = (function (exports, core) {
24
24
  SecurityWeb: SecurityWeb
25
25
  });
26
26
 
27
- exports.Security = Security;
27
+ exports.SecurityPlugin = SecurityPlugin;
28
28
 
29
29
  return exports;
30
30
 
@@ -1 +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 async openDeveloperSettings() {\n console.warn('Not supported on web');\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,IAAI,MAAM,qBAAqB,GAAG;IAClC,QAAQ,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC;IAC5C,IAAI;IACJ;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst SecurityPlugin = registerPlugin('SecurityPlugin', {\n web: () => import('./web').then((m) => new m.SecurityWeb()),\n});\nexport * from './definitions';\nexport { SecurityPlugin };\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 async openDeveloperSettings() {\n console.warn('Not supported on web');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,cAAc,GAAGA,mBAAc,CAAC,gBAAgB,EAAE;IACxD,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,IAAI,MAAM,qBAAqB,GAAG;IAClC,QAAQ,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC;IAC5C,IAAI;IACJ;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brucewayne1939/sword-security",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "this plugin enables the app to use security features",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",