@monad-inc/embed 0.1.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 ADDED
@@ -0,0 +1,21 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@monad-inc/embed` will be documented in this
4
+ file. The format is based on [Keep a Changelog](https://keepachangelog.com/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/).
6
+
7
+ ## [0.1.0] - 2026-05-26
8
+
9
+ ### Added
10
+
11
+ - Initial release of the `@monad-inc/embed/connect` host SDK
12
+ (`createConnectorFrame`) for embedding Monad's connector-config UI as a
13
+ secure cross-origin iframe.
14
+ - Lifecycle helpers: `buildDevNullPipeline`, `findIntegrationPipeline`,
15
+ `setIntegrationEnabled`, `disableIntegration`, `enableIntegration`,
16
+ `deleteIntegration`.
17
+ - Cleanup policy presets: `CLEANUP_FULL`, `CLEANUP_KEEP_OUTPUT`,
18
+ `CLEANUP_PIPELINE_ONLY`.
19
+ - Postmessage protocol exports: `PROTOCOL_SOURCE`, `PROTOCOL_VERSION`,
20
+ `FrameMessage`, `HostMessage`, `InitMessage`.
21
+ - ESM + CJS dual build with TypeScript declarations.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,5 @@
1
+ Monad Embed
2
+ Copyright 2026 Monad Inc.
3
+
4
+ This product includes software developed at Monad Inc.
5
+ (https://www.monad.com/).
package/README.md ADDED
@@ -0,0 +1,160 @@
1
+ # @monad-inc/embed
2
+
3
+ Tools for embedding Monad's UI in your own app via a secure cross-origin
4
+ iframe. Functionality is exposed through subpath modules; the **connect**
5
+ module — imported from `@monad-inc/embed/connect` — is the host-side SDK
6
+ for Monad's connector-config UI.
7
+
8
+ The customer's page calls `createConnectorFrame()`; the form and every
9
+ secret typed into it run inside a Monad-hosted iframe, so the host's
10
+ JavaScript never sees credential material — only a connector id reference
11
+ comes back. The isolation model is analogous to Stripe Elements and Plaid
12
+ Link.
13
+
14
+ The connect module also ships a small lifecycle harness — isomorphic
15
+ helpers for the host's backend to build, enable, disable, and delete a
16
+ connector's pipeline against Monad's REST API.
17
+
18
+ Zero runtime dependencies.
19
+
20
+ ## Installation
21
+
22
+ ```sh
23
+ npm install @monad-inc/embed
24
+ ```
25
+
26
+ The connect SDK is imported from the `@monad-inc/embed/connect` subpath
27
+ (see below).
28
+
29
+ ## Quick start
30
+
31
+ The session token travels in a `postMessage` after a `ready` handshake,
32
+ never in the iframe URL, so it stays out of browser history and the
33
+ `Referer` header. Mint it from the host's backend (`POST
34
+ /v1/embed/sessions` with the long-lived API key) and hand it to the
35
+ browser as `sessionToken`:
36
+
37
+ ```ts
38
+ import { createConnectorFrame } from '@monad-inc/embed/connect';
39
+
40
+ const frame = createConnectorFrame({
41
+ container: '#connector-modal-body',
42
+ frameOrigin: 'https://embed.monad.com', // a Monad-controlled origin
43
+ apiBase: 'https://api.monad.com',
44
+ organizationId: 'org_abc123',
45
+ typeId: 'aws-cloudtrail',
46
+ kind: 'input',
47
+ sessionToken,
48
+ appearance: { colorPrimary: '#007dc1' },
49
+ onSave: ({ id }) => {
50
+ /* connector created — id is safe to keep */
51
+ },
52
+ onCancel: () => frame.destroy(),
53
+ onError: (msg) => showError(msg)
54
+ });
55
+ ```
56
+
57
+ ## API reference
58
+
59
+ ### Iframe embedder
60
+
61
+ - `createConnectorFrame(options: ConnectorFrameOptions): ConnectorFrame`
62
+ — mounts the iframe inside `options.container` and returns a handle
63
+ with `destroy()`.
64
+ - Types: `ConnectorFrameOptions`, `ConnectorFrame`, `Appearance`,
65
+ `ComponentKind`.
66
+ - Protocol exports: `PROTOCOL_SOURCE`, `PROTOCOL_VERSION`,
67
+ `FrameMessage`, `HostMessage`, `InitMessage`.
68
+
69
+ ### Lifecycle harness
70
+
71
+ Each helper takes a `MonadRequest` thunk the host implements once,
72
+ wrapping its API key and base URL:
73
+
74
+ ```ts
75
+ import {
76
+ buildDevNullPipeline,
77
+ findIntegrationPipeline,
78
+ disableIntegration,
79
+ enableIntegration,
80
+ deleteIntegration,
81
+ CLEANUP_FULL,
82
+ type MonadRequest
83
+ } from '@monad-inc/embed/connect';
84
+
85
+ const request: MonadRequest = (path, init) =>
86
+ fetch(`${API_BASE}${path}`, {
87
+ ...init,
88
+ headers: {
89
+ Authorization: `ApiKey ${apiKey}`,
90
+ 'Content-Type': 'application/json',
91
+ ...init?.headers
92
+ }
93
+ }).then(async (r) => {
94
+ if (!r.ok) throw new Error(await r.text());
95
+ const text = await r.text();
96
+ return text ? JSON.parse(text) : undefined;
97
+ });
98
+
99
+ const built = await buildDevNullPipeline({ request, org, inputId, inputName });
100
+ const resolved = await findIntegrationPipeline({ request, org, inputId });
101
+
102
+ await disableIntegration({ request, org, pipelineId: resolved.pipelineId });
103
+ await enableIntegration({ request, org, pipelineId: resolved.pipelineId });
104
+ await deleteIntegration({
105
+ request,
106
+ org,
107
+ pipelineId: resolved.pipelineId,
108
+ inputId,
109
+ outputId: resolved.outputId,
110
+ cleanup: CLEANUP_FULL
111
+ });
112
+ ```
113
+
114
+ Exports: `buildDevNullPipeline`, `findIntegrationPipeline`,
115
+ `setIntegrationEnabled`, `disableIntegration`, `enableIntegration`,
116
+ `deleteIntegration`. Cleanup presets: `CLEANUP_FULL`,
117
+ `CLEANUP_KEEP_OUTPUT`, `CLEANUP_PIPELINE_ONLY`. Types: `MonadRequest`,
118
+ `ResolvedIntegration`, `CleanupPolicy`, `BuiltPipeline`, and the
119
+ per-helper option types.
120
+
121
+ #### Cleanup policies
122
+
123
+ | Policy | Pipeline | Input | Output |
124
+ | ----------------------- | -------- | ------ | ------ |
125
+ | `CLEANUP_FULL` | delete | delete | delete |
126
+ | `CLEANUP_KEEP_OUTPUT` | delete | delete | keep |
127
+ | `CLEANUP_PIPELINE_ONLY` | delete | keep | keep |
128
+
129
+ Or pass your own `{ pipeline?, input?, output? }`. A flag left
130
+ undefined defaults to delete.
131
+
132
+ ## Theming
133
+
134
+ The iframe accepts an `appearance` object of design tokens (e.g.
135
+ `colorPrimary`, `colorBackground`, `borderRadius`) that the embedded
136
+ form applies to its own styles. For deeper customization, pass
137
+ `stylesheets: [url, …]`; the iframe loads them in order. The list is
138
+ all-or-nothing — providing any URL replaces Monad's default stylesheet
139
+ rather than layering on top of it, so include the full token set you
140
+ want.
141
+
142
+ ## Browser support
143
+
144
+ Modern evergreen browsers (Chrome, Edge, Firefox, Safari). The package
145
+ ships both ESM and CJS builds plus `.d.ts` types. `createConnectorFrame`
146
+ is browser-only — it injects an `<iframe>` and uses `postMessage`.
147
+ The lifecycle helpers are isomorphic and run wherever the host holds
148
+ its API key (almost always its backend). Importing the package in
149
+ Node is safe; the browser code only touches `window`/`document` when
150
+ `createConnectorFrame` is called.
151
+
152
+ ## Versioning
153
+
154
+ `0.x` is pre-stable. Minor releases may include breaking API changes.
155
+ The package will move to `1.0.0` once the API is committed to long-term
156
+ compatibility. See `CHANGELOG.md` for release notes.
157
+
158
+ ## License
159
+
160
+ Apache-2.0 © Monad Inc. See `LICENSE` and `NOTICE`.
package/USAGE.md ADDED
@@ -0,0 +1,173 @@
1
+ # Using `@monad-inc/embed/connect`
2
+
3
+ Host-side SDK for embedding Monad's connector-config UI into your own
4
+ product. The form runs inside a Monad-hosted iframe — every secret a
5
+ user types (AWS keys, OAuth tokens, etc.) stays on Monad's origin and
6
+ is never visible to your application's JavaScript. Same isolation
7
+ model as Stripe Elements and Plaid Link.
8
+
9
+ ---
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ npm install @monad-inc/embed
15
+ ```
16
+
17
+ ESM and CJS builds ship side-by-side, with full TypeScript types.
18
+ Zero runtime dependencies.
19
+
20
+ ---
21
+
22
+ ## How it works
23
+
24
+ Two pieces of code: a **session-mint endpoint on your backend** mints
25
+ a short-lived, team-scoped token from your long-lived Monad API key,
26
+ and a **`createConnectorFrame()` call on your frontend** mounts the
27
+ iframe using that token. Both shown below.
28
+
29
+ ---
30
+
31
+ ## Step 1 — Mint a session token from your backend
32
+
33
+ Your backend exchanges its long-lived Monad API key for a short-lived,
34
+ team-scoped session token, then hands that token to your frontend.
35
+
36
+ Example (any HTTP framework — shown here as a Next.js Route Handler):
37
+
38
+ ```ts
39
+ // app/api/monad/session/route.ts
40
+ export async function POST(req: Request) {
41
+ const { teamId } = await req.json(); // your tenant → Monad team mapping
42
+
43
+ const r = await fetch('https://app.monad.com/api/v3/sessions', {
44
+ method: 'POST',
45
+ headers: {
46
+ 'Content-Type': 'application/json',
47
+ Authorization: `ApiKey ${process.env.MONAD_API_KEY}`
48
+ },
49
+ body: JSON.stringify({
50
+ organization_id: teamId,
51
+ ttl_seconds: 1800
52
+ })
53
+ });
54
+ const { session_token, expires_at } = await r.json();
55
+ return Response.json({ session_token, expires_at, organizationId: teamId });
56
+ }
57
+ ```
58
+
59
+ Returns:
60
+
61
+ ```json
62
+ {
63
+ "session_token": "eyJhbGc…",
64
+ "expires_at": "2026-05-26T18:30:00Z",
65
+ "organizationId": "7f93b302-fdb8-40e9-83c5-f9e555b91477"
66
+ }
67
+ ```
68
+
69
+ The `session_token` is what your frontend hands to `createConnectorFrame`.
70
+ **Never put your long-lived `MONAD_API_KEY` in browser code.**
71
+
72
+ ---
73
+
74
+ ## Step 2 — Mount the iframe on your frontend
75
+
76
+ ```ts
77
+ import { createConnectorFrame } from '@monad-inc/embed/connect';
78
+
79
+ // Fetch a fresh session from your own backend.
80
+ const { session_token, organizationId } = await fetch('/api/monad/session', {
81
+ method: 'POST',
82
+ body: JSON.stringify({ teamId: currentUser.teamId })
83
+ }).then((r) => r.json());
84
+
85
+ const frame = createConnectorFrame({
86
+ container: '#monad-connector-mount',
87
+ sessionToken: session_token,
88
+ organizationId,
89
+ kind: 'input', // 'input' or 'output'
90
+ typeId: 'aws-cloudtrail', // see the connector catalog
91
+ onSave: ({ id }) => {
92
+ console.log('connector created', id);
93
+ frame.destroy();
94
+ },
95
+ onCancel: () => frame.destroy()
96
+ });
97
+ ```
98
+
99
+ That's it. The form renders inside the iframe; the user fills it in
100
+ and clicks Save; you get a connector `id` back. The iframe handles
101
+ its own Save / Test connection / Cancel buttons — your page only
102
+ controls the surrounding chrome.
103
+
104
+ ---
105
+
106
+ ## `createConnectorFrame` options
107
+
108
+ | Option | Type | Required | Default | Description |
109
+ | ---------------- | ---------------------------- | -------- | ----------------------------- | ------------------------------------------------------------------------------------ |
110
+ | `container` | `HTMLElement \| string` | ✅ | — | Element (or CSS selector) the iframe is appended to. |
111
+ | `sessionToken` | `string` | ✅ | — | Short-lived token from `POST /v3/sessions` (your backend mints this). |
112
+ | `organizationId` | `string` | ✅ | — | Monad team org id the session is scoped to. Same value you passed to `/v3/sessions`. |
113
+ | `kind` | `'input' \| 'output'` | ✅ | — | Which catalog the connector belongs to. |
114
+ | `typeId` | `string` | ✅ | — | Connector type slug, e.g. `'aws-cloudtrail'`, `'okta-systemlog'`. |
115
+ | `existingId` | `string` | ⛔ | — | Pass to edit an existing connector. Omit to create a new one. |
116
+ | `displayName` | `string` | ⛔ | the connector type's name | Title shown in the iframe header. |
117
+ | `appearance` | `Appearance` | ⛔ | Monad defaults | Theming tokens (see below). |
118
+ | `synthetic` | `boolean` | ⛔ | `false` | Exposes Monad's internal synthetic-data toggle. Keep off in production. |
119
+ | `frameOrigin` | `string` | ⛔ | `https://app.monad.com/embed` | Override only for non-prod testing. |
120
+ | `apiBase` | `string` | ⛔ | `https://app.monad.com/api` | Override only for non-prod testing. |
121
+ | `onSave` | `(c: { id, name? }) => void` | ⛔ | — | Fired when the user saves successfully. |
122
+ | `onCancel` | `() => void` | ⛔ | — | Fired when the user cancels. |
123
+ | `onError` | `(message: string) => void` | ⛔ | — | Fired on a save / test / load failure. |
124
+
125
+ Returns a handle:
126
+
127
+ ```ts
128
+ const frame = createConnectorFrame({ ... });
129
+ frame.destroy(); // remove the iframe + listeners
130
+ ```
131
+
132
+ ---
133
+
134
+ ## Theming with `appearance`
135
+
136
+ Six tokens, applied as CSS custom properties inside the iframe.
137
+
138
+ ```ts
139
+ createConnectorFrame({
140
+ ...,
141
+ appearance: {
142
+ colorPrimary: '#10b981', // primary buttons, focus rings
143
+ colorText: '#0d1b2a', // body text + derived muted/faint shades
144
+ colorBackground: '#ffffff',
145
+ colorBorder: '#d4d9e0',
146
+ fontFamily: "'Inter', system-ui, sans-serif",
147
+ borderRadius: '8px',
148
+ },
149
+ });
150
+ ```
151
+
152
+ These are the only theming knobs. The iframe runs cross-origin, so
153
+ your stylesheets cannot bleed in — by design. If you need more
154
+ control than these six tokens give, file an issue.
155
+
156
+ ---
157
+
158
+ ## Security model
159
+
160
+ - **Cross-origin iframe.** The form runs on `app.monad.com`, not
161
+ on your domain. Browser same-origin policy means your JavaScript
162
+ cannot read the iframe's DOM or any value the user types.
163
+ - **Session tokens are short-lived.** Default 30 min, scoped to a
164
+ single team. Compromise of a session token is bounded; compromise
165
+ of the long-lived API key is not — keep it on your backend.
166
+ - **postMessage with strict origin checks.** Every message between
167
+ your page and the iframe is validated against the expected origin
168
+ in both directions.
169
+ - **`SameSite=Lax` cookies.** Any cookies you set on your own domain
170
+ do not travel into the Monad iframe regardless of origin sharing.
171
+ - **No host JavaScript in the iframe.** You cannot inject script or
172
+ CSS; the only customization channel is the six `appearance`
173
+ tokens.