@iglo.tech/iglo.base 0.0.0-stage → 1.0.0
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/CHANGELOG.md +18 -0
- package/LICENSE +18 -0
- package/README.md +778 -2
- package/dist/iglo-base.es.mjs +4 -0
- package/dist/iglo-base.es.mjs.map +34 -0
- package/dist/ssr-astro.es.mjs +4 -0
- package/dist/ssr-astro.es.mjs.map +12 -0
- package/dist/ssr-browser-client.es.mjs +4 -0
- package/dist/ssr-browser-client.es.mjs.map +13 -0
- package/dist/ssr-browser.es.mjs +4 -0
- package/dist/ssr-browser.es.mjs.map +10 -0
- package/dist/ssr-next.es.mjs +4 -0
- package/dist/ssr-next.es.mjs.map +12 -0
- package/dist/ssr-nuxt.es.mjs +4 -0
- package/dist/ssr-nuxt.es.mjs.map +12 -0
- package/dist/ssr-react-router.es.mjs +4 -0
- package/dist/ssr-react-router.es.mjs.map +12 -0
- package/dist/ssr-sveltekit.es.mjs +4 -0
- package/dist/ssr-sveltekit.es.mjs.map +12 -0
- package/dist/ssr.es.mjs +4 -0
- package/dist/ssr.es.mjs.map +22 -0
- package/dist/types/src/Client.d.ts +233 -0
- package/dist/types/src/ClientResponseError.d.ts +22 -0
- package/dist/types/src/index.d.ts +18 -0
- package/dist/types/src/services/BackupService.d.ts +59 -0
- package/dist/types/src/services/BaseService.d.ts +8 -0
- package/dist/types/src/services/BatchService.d.ts +56 -0
- package/dist/types/src/services/CollectionService.d.ts +47 -0
- package/dist/types/src/services/CronService.d.ts +20 -0
- package/dist/types/src/services/CrudService.d.ts +85 -0
- package/dist/types/src/services/FileService.d.ts +19 -0
- package/dist/types/src/services/HealthService.d.ts +16 -0
- package/dist/types/src/services/LogService.d.ts +35 -0
- package/dist/types/src/services/RealtimeService.d.ts +124 -0
- package/dist/types/src/services/RecordService.d.ts +374 -0
- package/dist/types/src/services/SQLService.d.ts +21 -0
- package/dist/types/src/services/SettingsService.d.ts +46 -0
- package/dist/types/src/ssr/adapter.d.ts +133 -0
- package/dist/types/src/ssr/astro.d.ts +27 -0
- package/dist/types/src/ssr/browser-client.d.ts +100 -0
- package/dist/types/src/ssr/browser-token.d.ts +29 -0
- package/dist/types/src/ssr/browser.d.ts +1 -0
- package/dist/types/src/ssr/cache.d.ts +9 -0
- package/dist/types/src/ssr/cookies.d.ts +68 -0
- package/dist/types/src/ssr/csrf.d.ts +38 -0
- package/dist/types/src/ssr/index.d.ts +12 -0
- package/dist/types/src/ssr/next.d.ts +53 -0
- package/dist/types/src/ssr/no-store-fetch.d.ts +7 -0
- package/dist/types/src/ssr/nuxt.d.ts +41 -0
- package/dist/types/src/ssr/oauth2.d.ts +56 -0
- package/dist/types/src/ssr/popup.d.ts +14 -0
- package/dist/types/src/ssr/react-router.d.ts +53 -0
- package/dist/types/src/ssr/renew.d.ts +25 -0
- package/dist/types/src/ssr/server-client.d.ts +83 -0
- package/dist/types/src/ssr/superuser-client.d.ts +24 -0
- package/dist/types/src/ssr/sveltekit.d.ts +44 -0
- package/dist/types/src/ssr/types.d.ts +118 -0
- package/dist/types/src/stores/AsyncAuthStore.d.ts +52 -0
- package/dist/types/src/stores/BaseAuthStore.d.ts +104 -0
- package/dist/types/src/stores/LocalAuthStore.d.ts +48 -0
- package/dist/types/src/tools/cookie.d.ts +31 -0
- package/dist/types/src/tools/dtos.d.ts +122 -0
- package/dist/types/src/tools/formdata.d.ts +30 -0
- package/dist/types/src/tools/jwt.d.ts +14 -0
- package/dist/types/src/tools/legacy.d.ts +2 -0
- package/dist/types/src/tools/loose.d.ts +5 -0
- package/dist/types/src/tools/options.d.ts +91 -0
- package/dist/types/src/tools/refresh.d.ts +3 -0
- package/package.json +73 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
## 1.0.0
|
|
2
|
+
|
|
3
|
+
First release, published as `@iglo.tech/iglo.base` (npm organization `iglo.tech`, public access). Every import path keeps its subpath under this name, for example `@iglo.tech/iglo.base/ssr/browser`.
|
|
4
|
+
|
|
5
|
+
- Forked from the PocketBase JavaScript SDK v0.28.1 (`ff30f71041aeb8107001bb1ac82ad56a4fbeb93c`). ESM-only package (`import PocketBase from "@iglo.tech/iglo.base"`).
|
|
6
|
+
- Strict TypeScript sources without `any` (except deliberately loose public shapes), type tests, tests ported to `bun test`.
|
|
7
|
+
- fixed: loadFromCookie crash on a null cookie value, an upstream bug
|
|
8
|
+
- difference from upstream: a non-string token from a cookie (`loadFromCookie`) or from `AsyncAuthStore`'s initial value becomes `""` instead of preserving the non-string value.
|
|
9
|
+
- difference from upstream: a non-object `@jsonPayload` in `convertFormDataToObject` is skipped instead of spreading primitive characters via `Object.assign`.
|
|
10
|
+
|
|
11
|
+
- SSR server core (`@iglo.tech/iglo.base/ssr`): `createServerClient` per request, resumed from the session cookie, with requests sent `cache: "no-store"` at the fetch layer; `createSuperuserClient` with `impersonate`; `createSessionCache({ ttl, maxEntries, clock })` (LRU, SHA-256 token keys, `ttl` in milliseconds); token lifetimes learned from auth responses, sliding refresh at half the lifetime; single-flight refresh that applies each outcome per request; `pb.auth.verify()`; server sign-in and sign-out write the session cookie; app-origin cookie security (`__Host-` and `Secure` follow the app's own request, not the backend URL); `createRequestCookieAdapter` for Web `Request`/`Response` handlers. The `ssr` entry shares the SDK's classes with `@iglo.tech/iglo.base`, so `instanceof ClientResponseError` agrees across both.
|
|
12
|
+
|
|
13
|
+
- SSR OAuth2 and CSRF (`@iglo.tech/iglo.base/ssr`): `pb.startOAuth2(provider, { callbackUrl, redirectTo?, collection? })` and `pb.completeOAuth2(request)` for the redirect flow, with a 10-minute temporary cookie bound to the state and a typed result (`OAuth2Error` or the server's `ClientResponseError`); on https only the `__Host-` cookie names are read, and providers that return by POST (Sign in with Apple) are refused with `unsupported-provider` (use the popup flow for them); `redirectTo` accepts same-origin paths only; `handlePopupHandOff(request, options)` completes a popup sign-in from a same-origin POST, checked with one `auth-refresh`; `checkCsrf(request, { allowedOrigins? })` and `checkOrigin` reject cross-site state-changing requests that carry the session cookie; an invalid `allowedOrigins` entry throws on every call.
|
|
14
|
+
|
|
15
|
+
- SSR browser client and realtime (`@iglo.tech/iglo.base/ssr`, `@iglo.tech/iglo.base/ssr/browser`): `mintBrowserToken(serverClient, superuser?, { duration? })` mints the page's short token (15 minutes by default, from `impersonate`), the server client's record and iglo.base's clock (`serverTime`) at render, or `null` when nobody is signed in; `handleBrowserTokenRenew(request, options)` is the adapter route that renews it (`POST` only, Origin-checked, session checked with iglo.base, no-cache headers); `createServerClient({ readableCookie: true })` is the fallback without superuser credentials, which writes the session cookie without `HttpOnly`. `createBrowserClient({ url, token?, record?, serverTime?, renewUrl?, handOffUrl?, ... })` returns a `Client` that renews its token before it expires, measured on the server's clock, shares one renewal between parallel callers, signs out on a 401, keeps the token and retries (at most ten times in a row) on a network error or 5xx, and keeps realtime subscriptions authorized: a renewal for the same user resubmits them (`RealtimeService.resubmit()`), a sign-out or a change of user opens a new connection for them (`RealtimeService.reconnect()`, which upstream requires for any change other than the same record; it retries like a dropped connection and does not call `onDisconnect`). Timers are capped below `setTimeout`'s maximum, and successful renewals are at least 30 seconds apart. `handOff()` clears the popup token on any failure. `pb.dispose()` stops its timers. The browser entry is browser-safe and shares the SDK's classes with the main entry.
|
|
16
|
+
- difference from upstream (realtime): when a connection is closed or replaced while its first subscription request is in flight, the continuation of the old connection no longer resolves the pending connects or cancels the next reconnect. Upstream's SDK, when a connection drops during that request, cancels its own retry and stops reconnecting until the app subscribes again; the SDK keeps retrying with the usual backoff.
|
|
17
|
+
|
|
18
|
+
- SSR framework adapters (`@iglo.tech/iglo.base/ssr/next`, `@iglo.tech/iglo.base/ssr/sveltekit`, `@iglo.tech/iglo.base/ssr/nuxt`, `@iglo.tech/iglo.base/ssr/astro`, `@iglo.tech/iglo.base/ssr/react-router`): zero-dependency, server-only subpaths that resume the session per request, write cookies back, run the CSRF check (opt out with `csrf: false`), answer the renew, popup and OAuth2 routes at configurable paths, and expose the page's server client and `mintBrowserToken`. Every response of a request that carries user data (a session cookie, a cookie write, a minted browser token) gets the no-cache headers, including a cookie the handler writes after the adapter's check. The React Router adapter's `session(request)` returns a `headers()` function to call when the route builds its response. The Next.js adapter runs on the Node.js runtime only (`proxy.ts` on Next.js 16). The adapters take the session cache and superuser client from the app, and fail at creation without either superuser credentials or `readableCookie`. Example apps in `examples/nextjs` and `examples/sveltekit` run end to end (`bun run test:examples`), including the OAuth2 sign-in from their login pages.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
Copyright (c) 2022 - present, Gani Georgiev
|
|
3
|
+
Copyright (c) 2026 - present, iglo.base contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
6
|
+
and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
7
|
+
including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
8
|
+
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
|
|
9
|
+
is furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all copies or
|
|
12
|
+
substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
|
15
|
+
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
16
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
17
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|