@bardioc/app-sdk 1.0.0 → 1.0.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/README.md CHANGED
@@ -113,7 +113,7 @@ response body as `details`.
113
113
  ```ts
114
114
  import { installDevHost, isDevStandalone } from '@bardioc/app-sdk/dev';
115
115
 
116
- if (isDevStandalone()) installDevHost({ appId: 'my-app' });
116
+ if (isDevStandalone()) installDevHost();
117
117
  ```
118
118
 
119
119
  The dev host answers the same contract as the Bardioc host: BFF calls go through the dev-auth
package/dist/dev-idb.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { AppMethods, IdbEntry, Params } from './contract.js';
2
2
  type In<K extends keyof AppMethods> = Params<AppMethods[K]>;
3
3
  /** The host's app storage, kept in this browser's IndexedDB while running standalone. */
4
- export declare function devIdb(appId: string): {
4
+ export declare function devIdb(): {
5
5
  get: ({ store, key }: In<"idb.get">) => Promise<IdbEntry<unknown> | null>;
6
6
  put: ({ store, key, value }: In<"idb.put">) => Promise<void>;
7
7
  delete: ({ store, key }: In<"idb.delete">) => Promise<void>;
package/dist/dev-idb.js CHANGED
@@ -12,11 +12,11 @@ function open(name) {
12
12
  }
13
13
  const toEntry = ({ key, value, updatedAt }) => ({ key, value, updatedAt });
14
14
  /** The host's app storage, kept in this browser's IndexedDB while running standalone. */
15
- export function devIdb(appId) {
15
+ export function devIdb() {
16
16
  // Opened on first use: most apps never touch their store.
17
17
  let db;
18
18
  const entries = async (mode) => {
19
- db ??= open(`bardioc-dev:${appId}`);
19
+ db ??= open('bardioc-dev');
20
20
  return (await db).transaction(ENTRIES, mode).objectStore(ENTRIES);
21
21
  };
22
22
  return {
package/dist/dev.d.ts CHANGED
@@ -2,17 +2,13 @@ import { type HostHandlers } from './serve.js';
2
2
  export declare function isInsideIframe(): boolean;
3
3
  export declare function isDevStandalone(): boolean;
4
4
  export interface DevHostOptions {
5
- /** The app's manifest id, handed to the app as `context.appId`. */
6
- appId: string;
7
- /** The app's ogit/Auth/Application id, sent as `X-App-ID` on scoped calls; defaults to `appId`. */
8
- clientId?: string;
9
5
  /** Where the dev-auth proxy answers `/rest`. Default: `/rest` on this origin. */
10
6
  apiBaseUrl?: string;
11
7
  }
12
8
  /** The dev host's answers to every app method. */
13
- export declare function devHandlers({ appId, clientId, apiBaseUrl, }: DevHostOptions): HostHandlers;
9
+ export declare function devHandlers({ apiBaseUrl }?: DevHostOptions): HostHandlers;
14
10
  /**
15
11
  * Stands in for the host while the app runs standalone in development: `connect()` reaches it
16
12
  * the way it reaches the host, and BFF calls go through the dev-auth proxy.
17
13
  */
18
- export declare function installDevHost(options: DevHostOptions): () => void;
14
+ export declare function installDevHost(options?: DevHostOptions): () => void;
package/dist/dev.js CHANGED
@@ -23,8 +23,8 @@ const unavailable = () => {
23
23
  throw new BardiocError('unavailable', 'Installed apps live in the Bardioc host');
24
24
  };
25
25
  /** The dev host's answers to every app method. */
26
- export function devHandlers({ appId, clientId = appId, apiBaseUrl = '/rest', }) {
27
- const idb = devIdb(appId);
26
+ export function devHandlers({ apiBaseUrl = '/rest' } = {}) {
27
+ const idb = devIdb();
28
28
  const request = async ({ path, method = 'GET', body, contentType, scopeId, scopePolicy }, signal) => {
29
29
  if (scopePolicy === 'required' && !scopeId) {
30
30
  throw new BardiocError('invalid', 'scopeId is required: a dev session has no instance');
@@ -32,10 +32,9 @@ export function devHandlers({ appId, clientId = appId, apiBaseUrl = '/rest', })
32
32
  const headers = new Headers({ 'X-Requested-With': 'XMLHttpRequest' });
33
33
  if (contentType && body !== undefined)
34
34
  headers.set('Content-Type', contentType);
35
- if (scopeId) {
35
+ // No X-App-ID: a dev app claims no app token and runs on the user's own.
36
+ if (scopeId)
36
37
  headers.set('X-Scope-ID', scopeId);
37
- headers.set('X-App-ID', clientId);
38
- }
39
38
  const encoded = contentType === 'application/json' ? JSON.stringify(body) : body;
40
39
  const response = await fetch(`${apiBaseUrl}${path}`, {
41
40
  method,
@@ -90,9 +89,9 @@ const osConfig = () => ({
90
89
  * Stands in for the host while the app runs standalone in development: `connect()` reaches it
91
90
  * the way it reaches the host, and BFF calls go through the dev-auth proxy.
92
91
  */
93
- export function installDevHost(options) {
92
+ export function installDevHost(options = {}) {
94
93
  const handlers = devHandlers(options);
95
- const context = () => ({ appId: options.appId, host: 'dev', osConfig: osConfig() });
94
+ const context = () => ({ appId: 'dev', host: 'dev', osConfig: osConfig() });
96
95
  let connection;
97
96
  const stopAccepting = acceptApp({
98
97
  source: () => window,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bardioc/app-sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "SDK for building apps for Bardioc",
5
5
  "license": "MIT",
6
6
  "private": false,