@declarion/embed 0.64.0 → 0.65.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/README.md +9 -9
- package/dist/server.d.ts +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ package is the typed integration layer for both sides:
|
|
|
12
12
|
iframe, runs the auth handshake, auto-resizes, mirrors navigation.
|
|
13
13
|
- **React binding** (`@declarion/embed/react`) - `<DeclarionEmbed />`.
|
|
14
14
|
- **Server helper** (`@declarion/embed/server`) - `createEmbedSession`, the
|
|
15
|
-
Node-side mint call. Keeps the `
|
|
15
|
+
Node-side mint call. Keeps the `dcl_` API key out of browser code.
|
|
16
16
|
|
|
17
17
|
The host installs only `@declarion/embed`; it does **not** depend on
|
|
18
18
|
`@declarion/react` (the full Declarion UI SDK).
|
|
@@ -31,15 +31,15 @@ npm install @declarion/embed
|
|
|
31
31
|
1. The host backend mints a short-lived, scoped token for a target tenant and
|
|
32
32
|
user with
|
|
33
33
|
`createEmbedSession` (`@declarion/embed/server`), which calls the
|
|
34
|
-
`auth.create_embed_session` action with a server-held `
|
|
34
|
+
`auth.create_embed_session` action with a server-held `dcl_` API key.
|
|
35
35
|
2. The host frontend embeds a screen with `createDeclarionEmbed` or
|
|
36
36
|
`<DeclarionEmbed />`, passing a `getToken` callback that fetches a token
|
|
37
37
|
from the host backend.
|
|
38
38
|
3. The SDK runs a `postMessage` handshake: the iframe asks for a token, the
|
|
39
39
|
SDK delivers it, and refreshes it whenever the iframe reports expiry.
|
|
40
40
|
|
|
41
|
-
The `
|
|
42
|
-
least-privilege `
|
|
41
|
+
The `dcl_` API key never leaves the host backend. For multi-tenant hosts, use a
|
|
42
|
+
least-privilege `dcl_` key key whose service-account owner holds only
|
|
43
43
|
`action:auth.create_embed_session`; tenant-scoped keys can mint only in their
|
|
44
44
|
own tenant.
|
|
45
45
|
|
|
@@ -107,10 +107,10 @@ export function CasesPanel({ tenant, user, route }) {
|
|
|
107
107
|
```ts
|
|
108
108
|
import { createEmbedSession } from "@declarion/embed/server";
|
|
109
109
|
|
|
110
|
-
// In a host backend route. The
|
|
110
|
+
// In a host backend route. The dcl_ API key is read from server config.
|
|
111
111
|
const session = await createEmbedSession({
|
|
112
112
|
declarionOrigin: "https://app.example.com",
|
|
113
|
-
// Prefer a least-privilege
|
|
113
|
+
// Prefer a least-privilege dcl_ key whose owner holds only
|
|
114
114
|
// action:auth.create_embed_session. Keep it server-side only.
|
|
115
115
|
apiKey: process.env.DECLARION_EMBED_API_KEY!,
|
|
116
116
|
tenantCode: "acme", // target tenant
|
|
@@ -122,7 +122,7 @@ const session = await createEmbedSession({
|
|
|
122
122
|
|
|
123
123
|
Hosts on a non-Node backend call the
|
|
124
124
|
`POST /api/actions/auth.create_embed_session` action over HTTP directly with
|
|
125
|
-
the same `
|
|
125
|
+
the same `dcl_` API key in the `Authorization` header.
|
|
126
126
|
|
|
127
127
|
## Script tag (no build step)
|
|
128
128
|
|
|
@@ -241,12 +241,12 @@ contract:
|
|
|
241
241
|
`createDeclarionEmbed` (any framework) and supplies the async `getToken`
|
|
242
242
|
callback. The SDK owns the iframe, the `ready` -> `set-token` handshake,
|
|
243
243
|
resize, navigation, and token refresh.
|
|
244
|
-
- **Host backend** - holds the `
|
|
244
|
+
- **Host backend** - holds the `dcl_` API key (server-side only) and mints
|
|
245
245
|
short-lived, scoped embed tokens with `createEmbedSession` from
|
|
246
246
|
`@declarion/embed/server`. Your `getToken` callback fetches one from your
|
|
247
247
|
own backend endpoint.
|
|
248
248
|
|
|
249
|
-
The `
|
|
249
|
+
The `dcl_` key never leaves your server; the browser only ever holds a
|
|
250
250
|
short-lived, scoped embed token. That split is the entire security model -
|
|
251
251
|
keep `@declarion/embed/server` out of any browser bundle.
|
|
252
252
|
|
package/dist/server.d.ts
CHANGED
|
@@ -12,13 +12,13 @@ export interface CreateEmbedSessionOptions {
|
|
|
12
12
|
*/
|
|
13
13
|
readonly declarionOrigin: string;
|
|
14
14
|
/**
|
|
15
|
-
* The `
|
|
15
|
+
* The `dcl_`-prefixed Declarion API key. The trust anchor for the mint
|
|
16
16
|
* call. MUST be held server-side only; never ship it to a browser.
|
|
17
17
|
*/
|
|
18
18
|
readonly apiKey: string;
|
|
19
19
|
/**
|
|
20
|
-
* The target tenant to mint the embed session in. A tenant-scoped `
|
|
21
|
-
* key may name only its own tenant; a `_global` `
|
|
20
|
+
* The target tenant to mint the embed session in. A tenant-scoped `dcl_`
|
|
21
|
+
* key may name only its own tenant; a `_global` `dcl_` key may name any
|
|
22
22
|
* tenant (one key for a multi-tenant host).
|
|
23
23
|
*/
|
|
24
24
|
readonly tenantCode: string;
|
|
@@ -60,7 +60,7 @@ export declare class EmbedSessionError extends Error {
|
|
|
60
60
|
* Mint a short-lived, scoped embed session token for a host-asserted user.
|
|
61
61
|
*
|
|
62
62
|
* Calls `POST /api/actions/auth.create_embed_session` on the Declarion
|
|
63
|
-
* deployment, authenticating with the server-held `
|
|
63
|
+
* deployment, authenticating with the server-held `dcl_` API key, and returns
|
|
64
64
|
* the `{ token, expires_at }` the host hands to the iframe (typically as the
|
|
65
65
|
* `getToken` result of `createDeclarionEmbed` / `<DeclarionEmbed />`).
|
|
66
66
|
*
|