@oblax/platform-browser 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.
@@ -0,0 +1,17 @@
1
+ import type { OblaxModulePlugin } from '@oblax/core';
2
+ import { BrowserPlatform } from './platform.js';
3
+ export { BrowserPlatform } from './platform.js';
4
+ /**
5
+ * Browser platform factory.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * const oblax = new Oblax({
10
+ * endpoint: 'https://api.my-app.oblax.io',
11
+ * clientId: 'my-web-app',
12
+ * modules: [PlatformBrowser(), Auth()],
13
+ * })
14
+ * ```
15
+ */
16
+ export declare function PlatformBrowser(): OblaxModulePlugin<'platform', BrowserPlatform>;
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAE/C;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,IAAI,iBAAiB,CAAC,UAAU,EAAE,eAAe,CAAC,CAKhF"}
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ import { BrowserPlatform } from './platform.js';
2
+ export { BrowserPlatform } from './platform.js';
3
+ /**
4
+ * Browser platform factory.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * const oblax = new Oblax({
9
+ * endpoint: 'https://api.my-app.oblax.io',
10
+ * clientId: 'my-web-app',
11
+ * modules: [PlatformBrowser(), Auth()],
12
+ * })
13
+ * ```
14
+ */
15
+ export function PlatformBrowser() {
16
+ return {
17
+ name: 'platform',
18
+ create: () => new BrowserPlatform(),
19
+ };
20
+ }
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAE/C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,eAAe,EAAE;KACpC,CAAA;AACH,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { AuthPayload, CredentialDelivery, OblaxPlatform } from '@oblax/core';
2
+ /**
3
+ * Browser platform.
4
+ *
5
+ * Auth strategy: HTTP-only cookies set by the server.
6
+ * The browser attaches the cookie automatically on every cross-origin request
7
+ * when `credentials: 'include'` is present — no token storage in JS memory,
8
+ * which protects against XSS.
9
+ *
10
+ * Suitable for: vanilla JS, React, Vue, Angular, Svelte, React Native Web.
11
+ */
12
+ export declare class BrowserPlatform implements OblaxPlatform {
13
+ /** Credentials arrive as HTTP-only cookies set by the server. */
14
+ readonly credentialDelivery: CredentialDelivery;
15
+ /**
16
+ * Called by the HTTP client when a 401 is received.
17
+ * The auth module overwrites this after initialization to wire in
18
+ * `session.refresh()`. Default: no-op (returns false).
19
+ */
20
+ onTokenExpired: () => Promise<boolean>;
21
+ prepareRequest(init: RequestInit): Promise<RequestInit>;
22
+ onAuthSuccess(_payload: AuthPayload): Promise<void>;
23
+ onAuthClear(): Promise<void>;
24
+ getRefreshToken(): Promise<string | null>;
25
+ }
26
+ //# sourceMappingURL=platform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEjF;;;;;;;;;GASG;AACH,qBAAa,eAAgB,YAAW,aAAa;IACnD,iEAAiE;IACjE,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,CAAW;IAE1D;;;;OAIG;IACH,cAAc,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAA+B;IAE/D,cAAc,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAKvD,aAAa,CAAC,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAInD,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,eAAe,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAKhD"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Browser platform.
3
+ *
4
+ * Auth strategy: HTTP-only cookies set by the server.
5
+ * The browser attaches the cookie automatically on every cross-origin request
6
+ * when `credentials: 'include'` is present — no token storage in JS memory,
7
+ * which protects against XSS.
8
+ *
9
+ * Suitable for: vanilla JS, React, Vue, Angular, Svelte, React Native Web.
10
+ */
11
+ export class BrowserPlatform {
12
+ constructor() {
13
+ /** Credentials arrive as HTTP-only cookies set by the server. */
14
+ this.credentialDelivery = 'cookie';
15
+ /**
16
+ * Called by the HTTP client when a 401 is received.
17
+ * The auth module overwrites this after initialization to wire in
18
+ * `session.refresh()`. Default: no-op (returns false).
19
+ */
20
+ this.onTokenExpired = () => Promise.resolve(false);
21
+ }
22
+ async prepareRequest(init) {
23
+ return { ...init, credentials: 'include' };
24
+ }
25
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
26
+ async onAuthSuccess(_payload) {
27
+ // No-op: the server sets the HTTP-only cookie in the Set-Cookie response header.
28
+ }
29
+ async onAuthClear() {
30
+ // No-op: cookie expiry is handled server-side via the logout endpoint.
31
+ }
32
+ async getRefreshToken() {
33
+ // Browser platforms use HTTP-only cookies; the refresh token is never
34
+ // exposed to JavaScript.
35
+ return null;
36
+ }
37
+ }
38
+ //# sourceMappingURL=platform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,MAAM,OAAO,eAAe;IAA5B;QACE,iEAAiE;QACxD,uBAAkB,GAAuB,QAAQ,CAAA;QAE1D;;;;WAIG;QACH,mBAAc,GAA2B,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAoBvE,CAAC;IAlBC,KAAK,CAAC,cAAc,CAAC,IAAiB;QACpC,OAAO,EAAE,GAAG,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,CAAA;IAC5C,CAAC;IAED,6DAA6D;IAC7D,KAAK,CAAC,aAAa,CAAC,QAAqB;QACvC,iFAAiF;IACnF,CAAC;IAED,KAAK,CAAC,WAAW;QACf,uEAAuE;IACzE,CAAC;IAED,KAAK,CAAC,eAAe;QACnB,sEAAsE;QACtE,yBAAyB;QACzB,OAAO,IAAI,CAAA;IACb,CAAC;CACF"}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@oblax/platform-browser",
3
+ "version": "1.0.0",
4
+ "description": "Oblax SDK — browser platform (cookie-based auth)",
5
+ "license": "MIT",
6
+ "author": {
7
+ "name": "Oblax SDK for JavaScript Team",
8
+ "url": "https://docs.oblax.io/docs/getting-started/your-first-sdk-call"
9
+ },
10
+ "homepage": "https://github.com/oblaxio/oblax-sdk-js#readme",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/oblaxio/oblax-sdk-js.git",
14
+ "directory": "packages/platform-browser"
15
+ },
16
+ "bugs": {
17
+ "url": "https://github.com/oblaxio/oblax-sdk-js/issues"
18
+ },
19
+ "keywords": [
20
+ "oblax",
21
+ "sdk",
22
+ "platform",
23
+ "browser"
24
+ ],
25
+ "type": "module",
26
+ "main": "./dist/index.js",
27
+ "types": "./dist/index.d.ts",
28
+ "exports": {
29
+ ".": {
30
+ "import": "./dist/index.js",
31
+ "types": "./dist/index.d.ts"
32
+ }
33
+ },
34
+ "files": [
35
+ "dist"
36
+ ],
37
+ "publishConfig": {
38
+ "access": "public"
39
+ },
40
+ "peerDependencies": {
41
+ "@oblax/core": "1.0.0"
42
+ },
43
+ "devDependencies": {
44
+ "typescript": "^5.5.0",
45
+ "@oblax/core": "1.0.0"
46
+ },
47
+ "scripts": {
48
+ "build": "tsc --build tsconfig.json",
49
+ "typecheck": "tsc --build tsconfig.json --dry",
50
+ "clean": "rm -rf dist tsconfig.tsbuildinfo"
51
+ }
52
+ }