@protobase/ui 0.56.0 → 0.57.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/app/native-auth-fetch.js +4 -37
- package/dist/package.js +1 -1
- package/dist/shell/assets/{app-DrOo6wZj.js → app-jQHHhHJP.js} +8 -8
- package/dist/shell/assets/{index-CjJ51o6g.js → index-CcS6KzFZ.js} +2 -2
- package/dist/shell/assets/{records-map-UKebN_oz.js → records-map-BIyhfExT.js} +2 -2
- package/dist/shell/assets/{shared-protobase-ui-n3H5TbSx.js → shared-protobase-ui-Cu5RuHwA.js} +2 -2
- package/dist/shell/index.html +3 -3
- package/dist/shell/protobase.shell.json +2 -2
- package/dist/shell/protobase.sw.js +2 -2
- package/dist/shell-source-maps/assets/app-jQHHhHJP.js.map +1 -0
- package/dist/shell-source-maps/assets/{index-CjJ51o6g.js.map → index-CcS6KzFZ.js.map} +1 -1
- package/dist/shell-source-maps/assets/{records-map-UKebN_oz.js.map → records-map-BIyhfExT.js.map} +1 -1
- package/dist/shell-source-maps/assets/{shared-protobase-ui-n3H5TbSx.js.map → shared-protobase-ui-Cu5RuHwA.js.map} +1 -1
- package/package.json +4 -4
- package/dist/shell-source-maps/assets/app-DrOo6wZj.js.map +0 -1
|
@@ -11,47 +11,15 @@ const nullBodyStatuses = [
|
|
|
11
11
|
const encodedSeparator = /%2f|%5c/i;
|
|
12
12
|
const isPlatform = (platform) => Object.hasOwn(capacitorOrigin, platform);
|
|
13
13
|
const allowedUrl = (url, apiOrigin) => url.origin === apiOrigin && !url.username && !url.password && url.pathname.startsWith(`${authBasePath}/`) && !encodedSeparator.test(url.pathname);
|
|
14
|
-
/**
|
|
15
|
-
* The native call of a sign-in request: on Android Protobase's own ProtobaseAuth plugin, which checks the address,
|
|
16
|
-
* names the Capacitor origin, refuses redirects and keeps Set-Cookie from the page itself; on iOS, until it has that
|
|
17
|
-
* plugin too, Capacitor's native HTTP with the origin named here.
|
|
18
|
-
*/
|
|
19
|
-
const nativeAuthCall = (platform, { url, method, headers, data }) => {
|
|
20
|
-
const withData = data === void 0 ? {} : { data };
|
|
21
|
-
if (platform === "android") return [
|
|
22
|
-
"ProtobaseAuth",
|
|
23
|
-
"request",
|
|
24
|
-
{
|
|
25
|
-
url,
|
|
26
|
-
method,
|
|
27
|
-
headers,
|
|
28
|
-
...withData
|
|
29
|
-
}
|
|
30
|
-
];
|
|
31
|
-
return [
|
|
32
|
-
"CapacitorHttp",
|
|
33
|
-
"request",
|
|
34
|
-
{
|
|
35
|
-
url,
|
|
36
|
-
method,
|
|
37
|
-
headers: {
|
|
38
|
-
...headers,
|
|
39
|
-
origin: capacitorOrigin[platform]
|
|
40
|
-
},
|
|
41
|
-
...withData,
|
|
42
|
-
responseType: "text",
|
|
43
|
-
disableRedirects: true
|
|
44
|
-
}
|
|
45
|
-
];
|
|
46
|
-
};
|
|
47
14
|
const bodyOf = ({ status, headers, data }) => {
|
|
48
15
|
if (nullBodyStatuses.includes(status)) return null;
|
|
49
16
|
if (Object.entries(headers).some(([name, value]) => name.toLowerCase() === "content-type" && value.startsWith("application/json"))) return JSON.stringify(data);
|
|
50
17
|
return typeof data === "string" ? data : JSON.stringify(data);
|
|
51
18
|
};
|
|
52
19
|
/**
|
|
53
|
-
* A `fetch` for the app's sign-in, at `<apiOrigin>/api/auth/...` only, through native HTTP
|
|
54
|
-
*
|
|
20
|
+
* A `fetch` for the app's sign-in, at `<apiOrigin>/api/auth/...` only, through native HTTP in Protobase's own
|
|
21
|
+
* ProtobaseAuth plugin, which checks the address again, refuses redirects and keeps Set-Cookie from the page itself:
|
|
22
|
+
* the session cookie lives in the device's cookie jar, which native HTTP sends and keeps, and the request names the
|
|
55
23
|
* Capacitor origin of the platform, which the server trusts for sign-in with a mobile section. The page cannot set
|
|
56
24
|
* `Cookie`, so the cookie comes from the native jar alone. Any other address is refused before the bridge is called.
|
|
57
25
|
*/
|
|
@@ -63,13 +31,12 @@ const nativeAuthFetch = (bridge, apiOrigin) => {
|
|
|
63
31
|
const url = new URL(request.url);
|
|
64
32
|
if (!allowedUrl(url, apiOrigin)) throw new Error(`Native sign-in requests go to ${apiOrigin}${authBasePath}/ only, not ${request.url}`);
|
|
65
33
|
const withBody = request.method !== "GET" && request.method !== "HEAD";
|
|
66
|
-
const
|
|
34
|
+
const answer = await bridge.nativePromise("ProtobaseAuth", "request", {
|
|
67
35
|
url: url.href,
|
|
68
36
|
method: request.method,
|
|
69
37
|
headers: Object.fromEntries(request.headers),
|
|
70
38
|
...withBody && { data: await request.text() }
|
|
71
39
|
});
|
|
72
|
-
const answer = await bridge.nativePromise(...call);
|
|
73
40
|
const headers = Object.entries(answer.headers).filter(([name]) => name.toLowerCase() !== "set-cookie");
|
|
74
41
|
return new Response(bodyOf(answer), {
|
|
75
42
|
status: answer.status,
|
package/dist/package.js
CHANGED