@kawanua/license-sdk 1.1.0 → 1.1.1

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.
@@ -0,0 +1,26 @@
1
+ name: Publish Package
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ permissions:
9
+ id-token: write # Required for OIDC
10
+ contents: read
11
+
12
+ jobs:
13
+ publish:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v6
17
+
18
+ - uses: actions/setup-node@v6
19
+ with:
20
+ node-version: '24'
21
+ registry-url: 'https://registry.npmjs.org'
22
+ package-manager-cache: false # never use caching in release builds
23
+ - run: npm ci
24
+ - run: npm run build --if-present
25
+ - run: npm test
26
+ - run: npm publish # Or: npm stage publish
package/README.md CHANGED
@@ -50,6 +50,64 @@ KawanuaLicense.init({
50
50
  });
51
51
  ```
52
52
 
53
+ #### React
54
+
55
+ ```jsx
56
+ import { useEffect, useState } from 'react';
57
+
58
+ function App() {
59
+ const [license, setLicense] = useState(null);
60
+
61
+ useEffect(() => {
62
+ KawanuaLicense.init({
63
+ token: window.__LICENSE_TOKEN__, // inject dari server-side rendering
64
+ onReady: (state) => setLicense(state),
65
+ });
66
+ return () => KawanuaLicense.destroy();
67
+ }, []);
68
+
69
+ if (!license) return <p>Memverifikasi lisensi...</p>;
70
+
71
+ return (
72
+ <div>
73
+ <h1>Dashboard</h1>
74
+ {KawanuaLicense.can('api_access') && <ApiSection />}
75
+ <p>Plan: {license.plan}</p>
76
+ </div>
77
+ );
78
+ }
79
+ ```
80
+
81
+ #### Vue 3
82
+
83
+ ```js
84
+ import { onMounted, onUnmounted } from 'vue';
85
+
86
+ onMounted(() => {
87
+ KawanuaLicense.init({
88
+ token: import.meta.env.VITE_LICENSE_TOKEN,
89
+ onReady: (state) => { license.value = state; },
90
+ });
91
+ });
92
+ onUnmounted(() => KawanuaLicense.destroy());
93
+ ```
94
+
95
+ #### Vanilla JS
96
+
97
+ ```html
98
+ <script src="https://cdn.kawanua.id/sdk/license.min.js"></script>
99
+ <script>
100
+ KawanuaLicense.init({
101
+ token: document.querySelector('meta[name="license-token"]').content,
102
+ onReady: (state) => {
103
+ if (!KawanuaLicense.can('white_label')) {
104
+ document.getElementById('footer-branding').style.display = 'block';
105
+ }
106
+ },
107
+ });
108
+ </script>
109
+ ```
110
+
53
111
  ### Mengecek Akses Fitur
54
112
 
55
113
  Setelah inisialisasi berhasil, kamu bisa mengecek apakah sebuah fitur diperbolehkan:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kawanua/license-sdk",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Drop-in SDK untuk klien yang menggunakan lisensi Kawanua.",
5
5
  "keywords": [
6
6
  "kawanua",