tevrocsdk 0.1.22 → 0.1.24
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 +60 -4
- package/package.json +4 -2
- package/tevroc-sdk.esm.js +2947 -2836
- package/tevroc-sdk.min.js +1 -1
- package/tevroc-sdk.umd.js +2953 -2844
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ Option 2: CDN (recommended)
|
|
|
32
32
|
<script src="https://unpkg.com/tevrocsdk@latest/tevroc-sdk.min.js"></script>
|
|
33
33
|
<script>
|
|
34
34
|
const tevroc = Tevroc.createClient({
|
|
35
|
-
baseUrl: "https://
|
|
35
|
+
baseUrl: "https://api.tevrocsdk.example.com"
|
|
36
36
|
});
|
|
37
37
|
</script>
|
|
38
38
|
```
|
|
@@ -44,7 +44,9 @@ Option 2: CDN (recommended)
|
|
|
44
44
|
import { createClient } from "tevrocsdk";
|
|
45
45
|
|
|
46
46
|
const tevroc = createClient({
|
|
47
|
-
baseUrl: "
|
|
47
|
+
baseUrl: "https://api.tevrocsdk.example.com",
|
|
48
|
+
appId: "tevroc-portal",
|
|
49
|
+
appName: "Tevroc Portal",
|
|
48
50
|
});
|
|
49
51
|
```
|
|
50
52
|
|
|
@@ -52,8 +54,10 @@ You can also pass an existing token:
|
|
|
52
54
|
|
|
53
55
|
```js
|
|
54
56
|
const tevroc = createClient({
|
|
55
|
-
baseUrl: "https://
|
|
56
|
-
token: localStorage.getItem("
|
|
57
|
+
baseUrl: "https://api.tevrocsdk.example.com",
|
|
58
|
+
token: localStorage.getItem("tevroc_access_token"),
|
|
59
|
+
appId: "tevroc-portal",
|
|
60
|
+
appName: "Tevroc Portal",
|
|
57
61
|
});
|
|
58
62
|
```
|
|
59
63
|
|
|
@@ -69,6 +73,31 @@ const { token, user } = await tevroc.auth.login({
|
|
|
69
73
|
const me = await tevroc.auth.me();
|
|
70
74
|
```
|
|
71
75
|
|
|
76
|
+
## Google login
|
|
77
|
+
|
|
78
|
+
```js
|
|
79
|
+
// Start Google auth flow in web or mobile.
|
|
80
|
+
await tevroc.auth.googleLogin({
|
|
81
|
+
appId: "tevroc-portal",
|
|
82
|
+
appName: "Tevroc Portal",
|
|
83
|
+
serviceUrl: "https://services.tevrocsdk.example.com",
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// Subscribe to login events from the SDK.
|
|
87
|
+
tevroc.auth.onGoogleLogin((user, error) => {
|
|
88
|
+
if (error) {
|
|
89
|
+
console.error("Google login failed", error);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
console.log("Google user profile:", user);
|
|
94
|
+
// Optionally exchange the user object with your API after callback.
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// Alternative helper: loginWithProvider redirects after success.
|
|
98
|
+
await tevroc.auth.loginWithProvider("google", "/dashboard");
|
|
99
|
+
```
|
|
100
|
+
|
|
72
101
|
## Entities
|
|
73
102
|
|
|
74
103
|
Entities are dynamic, like the Base44 SDK.
|
|
@@ -111,6 +140,33 @@ await tevroc.functions.invoke("ping", { hello: "world" });
|
|
|
111
140
|
await tevroc.functions.ping({ hello: "world" });
|
|
112
141
|
```
|
|
113
142
|
|
|
143
|
+
## Yoco payment
|
|
144
|
+
|
|
145
|
+
```js
|
|
146
|
+
// Create a payment flow for the amount in ZAR.
|
|
147
|
+
await tevroc.payments.create({
|
|
148
|
+
amountZAR: 50.0,
|
|
149
|
+
appId: "tevroc-portal",
|
|
150
|
+
mode: "web",
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// Listen for payment status updates.
|
|
154
|
+
const unsubscribe = tevroc.payments.onstatus((status, error) => {
|
|
155
|
+
if (error) {
|
|
156
|
+
console.error("Payment listener error", error);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
console.log("Payment status:", status);
|
|
161
|
+
|
|
162
|
+
if (status === "success") {
|
|
163
|
+
// Payment succeeded.
|
|
164
|
+
} else if (status === "failed") {
|
|
165
|
+
// Payment failed or was canceled.
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
```
|
|
169
|
+
|
|
114
170
|
## Core integrations
|
|
115
171
|
|
|
116
172
|
```js
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tevrocsdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.24",
|
|
4
4
|
"description": "JavaScript SDK for the Tevroc API.",
|
|
5
5
|
"main": "./tevroc-sdk.umd.js",
|
|
6
6
|
"module": "./tevroc-sdk.esm.js",
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
"worker",
|
|
12
12
|
"api" ,
|
|
13
13
|
"tauri",
|
|
14
|
-
"capacitor"
|
|
14
|
+
"capacitor",
|
|
15
|
+
"YOCO" ,
|
|
16
|
+
"google Auth"
|
|
15
17
|
],
|
|
16
18
|
"license": "MIT"
|
|
17
19
|
}
|