@elvix.is/sdk 0.5.0 → 0.5.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.
- package/dist/react.js +14 -5
- package/package.json +1 -1
package/dist/react.js
CHANGED
|
@@ -193,6 +193,15 @@ function authInit() {
|
|
|
193
193
|
const token = getElvixToken();
|
|
194
194
|
return token ? { headers: { authorization: `Bearer ${token}` }, credentials: "omit" } : { headers: {}, credentials: "include" };
|
|
195
195
|
}
|
|
196
|
+
function isSameOrigin(baseUrl) {
|
|
197
|
+
if (!baseUrl) return true;
|
|
198
|
+
if (typeof window === "undefined") return true;
|
|
199
|
+
try {
|
|
200
|
+
return new URL(baseUrl, window.location.href).origin === window.location.origin;
|
|
201
|
+
} catch {
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
196
205
|
|
|
197
206
|
// src/react/elvix-sign-in.tsx
|
|
198
207
|
function ElvixSignIn({
|
|
@@ -228,7 +237,7 @@ function ElvixSignIn({
|
|
|
228
237
|
const res = await fetch(`${ctx.baseUrl}/api/auth/otp/start`, {
|
|
229
238
|
method: "POST",
|
|
230
239
|
headers: { "content-type": "application/json" },
|
|
231
|
-
credentials: "include",
|
|
240
|
+
credentials: isSameOrigin(ctx.baseUrl) ? "include" : "omit",
|
|
232
241
|
body: JSON.stringify({
|
|
233
242
|
email: email.trim(),
|
|
234
243
|
intent: "app",
|
|
@@ -257,7 +266,7 @@ function ElvixSignIn({
|
|
|
257
266
|
const res = await fetch(`${ctx.baseUrl}/api/auth/otp/verify`, {
|
|
258
267
|
method: "POST",
|
|
259
268
|
headers: { "content-type": "application/json" },
|
|
260
|
-
credentials: "include",
|
|
269
|
+
credentials: isSameOrigin(ctx.baseUrl) ? "include" : "omit",
|
|
261
270
|
body: JSON.stringify({ challengeId, code: code.trim() })
|
|
262
271
|
});
|
|
263
272
|
const body = await res.json();
|
|
@@ -682,7 +691,7 @@ function ElvixSessions({
|
|
|
682
691
|
useEffect4(() => {
|
|
683
692
|
if (!ctx.app) return;
|
|
684
693
|
fetch(`${ctx.baseUrl}/api/account/apps/${ctx.app.applicationId}/sessions`, {
|
|
685
|
-
|
|
694
|
+
...authInit()
|
|
686
695
|
}).then((r) => r.json()).then((j) => {
|
|
687
696
|
if (j.success && j.data) setRows(j.data.sessions);
|
|
688
697
|
else setError("load_failed");
|
|
@@ -880,7 +889,7 @@ function ElvixAddressBook({
|
|
|
880
889
|
function reload() {
|
|
881
890
|
if (!ctx.app) return;
|
|
882
891
|
fetch(`${ctx.baseUrl}/api/account/apps/${ctx.app.applicationId}/addresses`, {
|
|
883
|
-
|
|
892
|
+
...authInit()
|
|
884
893
|
}).then((r) => r.json()).then((j) => {
|
|
885
894
|
if (j.success && j.data) setRows(j.data.addresses);
|
|
886
895
|
else setError("load_failed");
|
|
@@ -940,7 +949,7 @@ function ElvixLegalEntities({
|
|
|
940
949
|
function reload() {
|
|
941
950
|
if (!ctx.app) return;
|
|
942
951
|
fetch(`${ctx.baseUrl}/api/account/apps/${ctx.app.applicationId}/legal-entities`, {
|
|
943
|
-
|
|
952
|
+
...authInit()
|
|
944
953
|
}).then((r) => r.json()).then((j) => {
|
|
945
954
|
if (j.success && j.data) setRows(j.data.entities);
|
|
946
955
|
else setError("load_failed");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elvix.is/sdk",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Official elvix SDK. Drop-in React components, server helpers, and an MCP server so AI coding agents integrate elvix on the first try.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://elvix.is",
|