@proveanything/smartlinks 1.14.3 → 1.14.5
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/dist/api/auth.js +7 -2
- package/dist/api/authKit.js +21 -7
- package/dist/docs/API_SUMMARY.md +1 -1
- package/dist/docs/scanner-container.md +1 -0
- package/dist/docs/widgets.md +1 -0
- package/docs/API_SUMMARY.md +1 -1
- package/docs/widgets.md +1 -0
- package/package.json +1 -1
package/dist/api/auth.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { post, request, setBearerToken, getApiHeaders, hasAuthCredentials, isProxyEnabled } from "../http";
|
|
1
|
+
import { post, request, setBearerToken, getApiHeaders, hasAuthCredentials, isProxyEnabled, invalidateCache } from "../http";
|
|
2
2
|
import { SmartlinksApiError } from "../types/error";
|
|
3
3
|
const DEFAULT_AUTH_LOCATION_CACHE_KEY = 'smartlinks.auth.location';
|
|
4
4
|
const DEFAULT_AUTH_LOCATION_TTL_MS = 30 * 60 * 1000;
|
|
@@ -80,6 +80,7 @@ export var auth;
|
|
|
80
80
|
async function login(email, password) {
|
|
81
81
|
const res = await post("/public/auth/login", { email, password });
|
|
82
82
|
setBearerToken(res.bearerToken);
|
|
83
|
+
invalidateCache();
|
|
83
84
|
return res;
|
|
84
85
|
}
|
|
85
86
|
auth.login = login;
|
|
@@ -88,6 +89,7 @@ export var auth;
|
|
|
88
89
|
*/
|
|
89
90
|
function logout() {
|
|
90
91
|
setBearerToken(undefined);
|
|
92
|
+
invalidateCache();
|
|
91
93
|
}
|
|
92
94
|
auth.logout = logout;
|
|
93
95
|
/**
|
|
@@ -103,6 +105,7 @@ export var auth;
|
|
|
103
105
|
const result = await post("/public/auth/verify", {}, headers);
|
|
104
106
|
if (token && result.valid) {
|
|
105
107
|
setBearerToken(token);
|
|
108
|
+
invalidateCache();
|
|
106
109
|
}
|
|
107
110
|
return result;
|
|
108
111
|
}
|
|
@@ -131,8 +134,10 @@ export var auth;
|
|
|
131
134
|
async function registerUser(user) {
|
|
132
135
|
// Use the provided token, or the one from getApiHeaders
|
|
133
136
|
const res = await post("/public/auth/register", user);
|
|
134
|
-
if (res.bearerToken)
|
|
137
|
+
if (res.bearerToken) {
|
|
135
138
|
setBearerToken(res.bearerToken);
|
|
139
|
+
invalidateCache();
|
|
140
|
+
}
|
|
136
141
|
return res;
|
|
137
142
|
}
|
|
138
143
|
auth.registerUser = registerUser;
|
package/dist/api/authKit.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { request, post, put, del, setBearerToken } from "../http";
|
|
1
|
+
import { request, post, put, del, setBearerToken, invalidateCache } from "../http";
|
|
2
2
|
/**
|
|
3
3
|
* Namespace containing helper functions for the new AuthKit API.
|
|
4
4
|
* Legacy collection-based authKit helpers retained (marked as *Legacy*).
|
|
@@ -11,8 +11,10 @@ export var authKit;
|
|
|
11
11
|
/** Login with email + password (public). */
|
|
12
12
|
async function login(clientId, email, password) {
|
|
13
13
|
const res = await post(`/authkit/${encodeURIComponent(clientId)}/auth/login`, { email, password });
|
|
14
|
-
if (res.token)
|
|
14
|
+
if (res.token) {
|
|
15
15
|
setBearerToken(res.token);
|
|
16
|
+
invalidateCache();
|
|
17
|
+
}
|
|
16
18
|
return res;
|
|
17
19
|
}
|
|
18
20
|
authKit.login = login;
|
|
@@ -24,16 +26,20 @@ export var authKit;
|
|
|
24
26
|
/** Google OAuth login via ID token (public). */
|
|
25
27
|
async function googleLogin(clientId, idToken) {
|
|
26
28
|
const res = await post(`/authkit/${encodeURIComponent(clientId)}/auth/google`, { idToken });
|
|
27
|
-
if (res.token)
|
|
29
|
+
if (res.token) {
|
|
28
30
|
setBearerToken(res.token);
|
|
31
|
+
invalidateCache();
|
|
32
|
+
}
|
|
29
33
|
return res;
|
|
30
34
|
}
|
|
31
35
|
authKit.googleLogin = googleLogin;
|
|
32
36
|
/** Google OAuth login via server-side authorization code (public). */
|
|
33
37
|
async function googleCodeLogin(clientId, code, redirectUri) {
|
|
34
38
|
const res = await post(`/authkit/${encodeURIComponent(clientId)}/auth/google-code`, { code, redirectUri });
|
|
35
|
-
if (res.token)
|
|
39
|
+
if (res.token) {
|
|
36
40
|
setBearerToken(res.token);
|
|
41
|
+
invalidateCache();
|
|
42
|
+
}
|
|
37
43
|
return res;
|
|
38
44
|
}
|
|
39
45
|
authKit.googleCodeLogin = googleCodeLogin;
|
|
@@ -45,8 +51,10 @@ export var authKit;
|
|
|
45
51
|
/** Verify a magic link token and authenticate/create the user (public). */
|
|
46
52
|
async function verifyMagicLink(clientId, token) {
|
|
47
53
|
const res = await post(`/authkit/${encodeURIComponent(clientId)}/auth/magic-link/verify`, { token });
|
|
48
|
-
if (res.token)
|
|
54
|
+
if (res.token) {
|
|
49
55
|
setBearerToken(res.token);
|
|
56
|
+
invalidateCache();
|
|
57
|
+
}
|
|
50
58
|
return res;
|
|
51
59
|
}
|
|
52
60
|
authKit.verifyMagicLink = verifyMagicLink;
|
|
@@ -59,6 +67,7 @@ export var authKit;
|
|
|
59
67
|
async function verifyPhoneCode(clientId, phoneNumber, code) {
|
|
60
68
|
const res = await post(`/authkit/${encodeURIComponent(clientId)}/auth/phone/verify`, { phoneNumber, code });
|
|
61
69
|
setBearerToken(res.token);
|
|
70
|
+
invalidateCache();
|
|
62
71
|
return res;
|
|
63
72
|
}
|
|
64
73
|
authKit.verifyPhoneCode = verifyPhoneCode;
|
|
@@ -82,6 +91,7 @@ export var authKit;
|
|
|
82
91
|
async function exchangeWhatsAppSession(clientId, token, sessionKey) {
|
|
83
92
|
const res = await post(`/authkit/${encodeURIComponent(clientId)}/auth/whatsapp/exchange-session`, { token, sessionKey });
|
|
84
93
|
setBearerToken(res.token);
|
|
94
|
+
invalidateCache();
|
|
85
95
|
return res;
|
|
86
96
|
}
|
|
87
97
|
authKit.exchangeWhatsAppSession = exchangeWhatsAppSession;
|
|
@@ -143,8 +153,10 @@ export var authKit;
|
|
|
143
153
|
/** Update the authenticated user's profile and replace the bearer token when refreshed claims are returned. */
|
|
144
154
|
async function updateProfile(clientId, data) {
|
|
145
155
|
const res = await post(`/authkit/${encodeURIComponent(clientId)}/account/update-profile`, data);
|
|
146
|
-
if (res.token)
|
|
156
|
+
if (res.token) {
|
|
147
157
|
setBearerToken(res.token);
|
|
158
|
+
invalidateCache();
|
|
159
|
+
}
|
|
148
160
|
return res;
|
|
149
161
|
}
|
|
150
162
|
authKit.updateProfile = updateProfile;
|
|
@@ -158,8 +170,10 @@ export var authKit;
|
|
|
158
170
|
authKit.changeEmail = changeEmail;
|
|
159
171
|
async function verifyEmailChange(clientId, token) {
|
|
160
172
|
const res = await post(`/authkit/${encodeURIComponent(clientId)}/account/verify-email-change`, { token });
|
|
161
|
-
if (res.token)
|
|
173
|
+
if (res.token) {
|
|
162
174
|
setBearerToken(res.token);
|
|
175
|
+
invalidateCache();
|
|
176
|
+
}
|
|
163
177
|
return res;
|
|
164
178
|
}
|
|
165
179
|
authKit.verifyEmailChange = verifyEmailChange;
|
package/dist/docs/API_SUMMARY.md
CHANGED
|
@@ -389,6 +389,7 @@ The host exposes these libraries on `window` — your container build **must ext
|
|
|
389
389
|
| `react-dom` | `window.ReactDOM` |
|
|
390
390
|
| `react/jsx-runtime` | `window.jsxRuntime` |
|
|
391
391
|
| `@proveanything/smartlinks` | `window.SL` |
|
|
392
|
+
| `@proveanything/smartlinks-auth-ui` | `window.SmartlinksAuthUI` |
|
|
392
393
|
| `class-variance-authority` | `window.CVA` |
|
|
393
394
|
| `react-router-dom` | `window.ReactRouterDOM` |
|
|
394
395
|
| `@tanstack/react-query` | `window.ReactQuery` |
|
package/dist/docs/widgets.md
CHANGED
|
@@ -581,6 +581,7 @@ The widget bundle does **not** include these libraries—the parent app must pro
|
|
|
581
581
|
|---------|------------------|
|
|
582
582
|
| `react`, `react-dom` | Parent's React context |
|
|
583
583
|
| `@proveanything/smartlinks` | Passed via props as `SL` |
|
|
584
|
+
| `@proveanything/smartlinks-auth-ui` | Auth UI components (also available globally as `window.SmartlinksAuthUI`) |
|
|
584
585
|
| `tailwind-merge` | Utility for merging Tailwind classes |
|
|
585
586
|
| `clsx` | Utility for conditional class names |
|
|
586
587
|
| `class-variance-authority` | Utility for component variants |
|
package/docs/API_SUMMARY.md
CHANGED
package/docs/widgets.md
CHANGED
|
@@ -581,6 +581,7 @@ The widget bundle does **not** include these libraries—the parent app must pro
|
|
|
581
581
|
|---------|------------------|
|
|
582
582
|
| `react`, `react-dom` | Parent's React context |
|
|
583
583
|
| `@proveanything/smartlinks` | Passed via props as `SL` |
|
|
584
|
+
| `@proveanything/smartlinks-auth-ui` | Auth UI components (also available globally as `window.SmartlinksAuthUI`) |
|
|
584
585
|
| `tailwind-merge` | Utility for merging Tailwind classes |
|
|
585
586
|
| `clsx` | Utility for conditional class names |
|
|
586
587
|
| `class-variance-authority` | Utility for component variants |
|