@matterfact/embed 0.2.0 → 0.2.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.
Files changed (2) hide show
  1. package/README.md +120 -11
  2. package/package.json +5 -6
package/README.md CHANGED
@@ -1,18 +1,127 @@
1
1
  # @matterfact/embed
2
2
 
3
- Drop-in loader for the matterfact assistant. See `examples/` for usage; the
4
- CDN stub is built from `src/embed.ts`.
3
+ Put the matterfact agent inside your web app. It renders in a sandboxed cross-origin
4
+ iframe we serve, can see the page it's on, and lets your users ask about what's in front
5
+ of them. Apache-2.0.
6
+
7
+ ```bash
8
+ npm install @matterfact/embed
9
+ ```
10
+
11
+ You'll need a **publishable key** (`pk_live_…`) from matterfact and the **origins** it may
12
+ be embedded on — origins are matched exactly (scheme + host + port), and an unregistered
13
+ one renders nothing.
14
+
15
+ ## Add the widget
16
+
17
+ ### React
18
+
19
+ ```tsx
20
+ 'use client';
21
+ import { MatterfactAgent } from '@matterfact/embed/react';
22
+
23
+ <MatterfactAgent
24
+ publishableKey="pk_live_…"
25
+ widgetOrigin="https://app.matterfact.com"
26
+ surface="orders"
27
+ />;
28
+ ```
29
+
30
+ Ships types. In the Next.js App Router it needs a `'use client'` boundary.
31
+
32
+ ### Script tag
33
+
34
+ ```html
35
+ <script
36
+ type="module"
37
+ src="https://app.matterfact.com/embed/embed.js"
38
+ data-key="pk_live_…"
39
+ data-origin="https://app.matterfact.com"
40
+ data-surface="orders"
41
+ ></script>
42
+ ```
43
+
44
+ `type="module"` is required — the loader is an ES module. `src` (where the loader is
45
+ served) and `data-origin` (where the chat is served) are different things.
46
+
47
+ ## Where it renders
48
+
49
+ By default: a floating launcher in the corner, draggable, with a right-click menu.
50
+
51
+ Prefer it in **your own** side panel, drawer or tab? Add `inline` — it renders where you
52
+ put it and fills that space, sized by your CSS. No launcher is drawn and it never resizes
53
+ itself; showing/hiding your panel is the open/close control.
54
+
55
+ ```tsx
56
+ <aside className="w-[380px] border-l">
57
+ <MatterfactAgent inline publishableKey="pk_live_…" />
58
+ </aside>
59
+ ```
60
+
61
+ Script-tag equivalent: `data-container="#your-panel"`.
62
+
63
+ ## Signing users in
64
+
65
+ By default the widget runs its own sign-in in a popup (the only way an embedded frame can
66
+ get a real first-party session). If your app already holds an identity this matterfact
67
+ deployment trusts, hand the token over for silent sign-in:
68
+
69
+ ```tsx
70
+ <MatterfactAgent getAuthToken={() => auth.currentUser?.getIdToken() ?? null} />
71
+ ```
72
+
73
+ ```js
74
+ // script tag
75
+ window.matterfact = { getEmbedAuthToken: () => getToken() };
76
+ ```
77
+
78
+ We verify the token either way — this skips a redundant login, it doesn't bypass auth.
79
+
80
+ ## What the agent can see
81
+
82
+ Nothing until a user opens the chat; then a semantic snapshot of the **visible** page.
83
+ Never captured, with no setting to enable it: keystrokes, input/textarea values, passwords,
84
+ cookies, storage, the raw DOM, screenshots, network traffic, or anything inside
85
+ `data-mf-private`. PII is scrubbed in the browser before anything leaves the page. The
86
+ exact per-turn payload is inspectable in the widget's "what can it see?" panel.
87
+
88
+ Declare what your page is, and it rides on every turn:
89
+
90
+ ```js
91
+ window.matterfact = {
92
+ context: {
93
+ route: '/orders/:id',
94
+ description: 'Acme order 8813 — 3 items, unpaid',
95
+ entities: [{ kind: 'x:order', id: '8813', label: 'Acme order' }],
96
+ },
97
+ };
98
+ ```
5
99
 
6
100
  ## Microphone / dictation
7
101
 
8
- The widget's composer supports voice dictation. The loader grants the iframe
9
- `allow="microphone"`, so the browser will prompt inside the widget as usual.
102
+ The composer supports voice dictation; the loader grants the iframe `allow="microphone"`.
103
+ If your site sends a `Permissions-Policy` response header that denies `microphone`, the
104
+ browser blocks the widget's mic regardless — add
105
+ `microphone=(self "https://app.matterfact.com")` (or your widget origin) to that header.
106
+
107
+ ## Debugging a live embed
108
+
109
+ Add `?mfdev=1` to your page's URL to open a panel showing exactly what the widget sends —
110
+ on a real deployment, no dev build. It grants nothing.
111
+
112
+ ## Security model
113
+
114
+ - The publishable key is public and useless alone; the boundary is the user holding a
115
+ matterfact identity obtained through sign-in.
116
+ - Origin pinning is a misconfiguration guard, not a security boundary.
117
+ - The page snapshot is untrusted reference data to the agent — grounding, never
118
+ instructions.
119
+
120
+ ## Full guide
121
+
122
+ The complete integration reference — endpoints, single-tenant Entra setup, troubleshooting
123
+ — is served to partners at [app.matterfact.com/docs/api](https://app.matterfact.com/docs/api).
10
124
 
11
- One caveat for host pages: if your site sends a `Permissions-Policy` response
12
- header that denies `microphone`, the browser blocks the widget's mic access
13
- too and the composer shows "Microphone access denied". Allow the feature (or
14
- omit it from the header) to enable dictation, e.g.
15
- `Permissions-Policy: microphone=(self "https://app.matterfact.com")`.
125
+ ## License
16
126
 
17
- Note: changes to the loader (including this grant) reach host pages only when
18
- the package is rebuilt and the CDN copy republished.
127
+ Apache-2.0 © Matterfact, Inc.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matterfact/embed",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "The matterfact embeddable agent: mount the chat in a cross-origin iframe (a <script> loader for any site, or a <MatterfactAgent> React component) and give the agent eyes on the host page.",
5
5
  "license": "Apache-2.0",
6
6
  "private": false,
@@ -8,11 +8,6 @@
8
8
  "publishConfig": {
9
9
  "access": "public"
10
10
  },
11
- "repository": {
12
- "type": "git",
13
- "url": "git+https://github.com/matterfact-inc/nexicon-frontend.git",
14
- "directory": "packages/embed"
15
- },
16
11
  "files": [
17
12
  "dist"
18
13
  ],
@@ -52,5 +47,9 @@
52
47
  "esbuild": "^0.25.10",
53
48
  "react": "^18.3.1",
54
49
  "tsup": "^8.5.0"
50
+ },
51
+ "homepage": "https://app.matterfact.com/docs/api",
52
+ "bugs": {
53
+ "url": "https://app.matterfact.com/docs/api"
55
54
  }
56
55
  }