@synoi/gateway-lite 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/LICENSE ADDED
@@ -0,0 +1,195 @@
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 made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
48
+ in the Work by the copyright owner or by an individual or Legal Entity
49
+ authorized to submit on behalf of the copyright owner. For the purposes
50
+ of this definition, "submitted" means any form of electronic, verbal,
51
+ or written communication sent to the Licensor or its representatives,
52
+ including but not limited to communication on electronic mailing lists,
53
+ source code control systems, and issue tracking systems that are managed
54
+ by, or on behalf of, the Licensor for the purpose of discussing and
55
+ improving the Work, but excluding communication that is conspicuously
56
+ marked or designated in writing by the copyright owner as "Not a
57
+ Contribution."
58
+
59
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
60
+ whom a Contribution has been received by the Licensor and included
61
+ within the Work.
62
+
63
+ 2. Grant of Copyright License. Subject to the terms and conditions of
64
+ this License, each Contributor hereby grants to You a perpetual,
65
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
66
+ copyright license to reproduce, prepare Derivative Works of,
67
+ publicly display, publicly perform, sublicense, and distribute the
68
+ Work and such Derivative Works in Source or Object form.
69
+
70
+ 3. Grant of Patent License. Subject to the terms and conditions of
71
+ this License, each Contributor hereby grants to You a perpetual,
72
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
73
+ (except as stated in this section) patent license to make, have made,
74
+ use, offer to sell, sell, import, and otherwise transfer the Work,
75
+ where such license applies only to those patent claims licensable
76
+ by such Contributor that are necessarily infringed by their
77
+ Contribution(s) alone or by the combined work of their Contribution(s)
78
+ with the Work to which such Contribution(s) was submitted. If You
79
+ institute patent litigation against any entity (including a cross-claim
80
+ or counterclaim in a lawsuit) alleging that the Work or any
81
+ Contribution embodied within the Work constitutes direct or contributory
82
+ patent infringement, then any patent licenses granted to You under
83
+ this License for that Work shall terminate as of the date such
84
+ litigation is filed.
85
+
86
+ 4. Redistribution. You may reproduce and distribute copies of the
87
+ Work or Derivative Works thereof in any medium, with or without
88
+ modifications, and in Source or Object form, provided that You
89
+ meet the following conditions:
90
+
91
+ (a) You must give any other recipients of the Work or Derivative
92
+ Works a copy of this License; and
93
+
94
+ (b) You must cause any modified files to carry prominent notices
95
+ stating that You changed the files; and
96
+
97
+ (c) You must retain, in the Source form of any Derivative Works
98
+ that You distribute, all copyright, patent, trademark, and
99
+ attribution notices from the Source form of the Work,
100
+ excluding those notices that do not pertain to any part of
101
+ the Derivative Works; and
102
+
103
+ (d) If the Work includes a "NOTICE" text file as part of its
104
+ distribution, You must include a readable copy of the
105
+ attribution notices contained within such NOTICE file, in
106
+ at least one of the following places: within a NOTICE text
107
+ file distributed as part of the Derivative Works; within
108
+ the Source form or documentation, if provided along with the
109
+ Derivative Works; or, within a display generated by the
110
+ Derivative Works, if and wherever such third-party notices
111
+ normally appear. The contents of the NOTICE file are for
112
+ informational purposes only and do not modify the License.
113
+ You may add Your own attribution notices within Derivative
114
+ Works that You distribute, alongside or in addition to the
115
+ NOTICE text from the Work, provided that such additional
116
+ attribution notices cannot be construed as modifying the
117
+ License.
118
+
119
+ You may add Your own license statement for Your modifications and
120
+ may provide additional grant of rights to use, copy, modify, merge,
121
+ publish, distribute, sublicense, and/or sell copies of the
122
+ Contribution, either on an unapproved or approved basis, and you
123
+ may elect to apply the Apache License to such modifications.
124
+
125
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
126
+ any Contribution intentionally submitted for inclusion in the Work
127
+ by You to the Licensor shall be under the terms and conditions of
128
+ this License, without any additional terms or conditions.
129
+ Notwithstanding the above, nothing herein shall supersede or modify
130
+ the terms of any separate license agreement you may have executed
131
+ with Licensor regarding such Contributions.
132
+
133
+ 6. Trademarks. This License does not grant permission to use the trade
134
+ names, trademarks, service marks, or product names of the Licensor,
135
+ except as required for reasonable and customary use in describing the
136
+ origin of the Work and reproducing the content of the NOTICE file.
137
+
138
+ 7. Disclaimer of Warranty. Unless required by applicable law or
139
+ agreed to in writing, Licensor provides the Work (and each
140
+ Contributor provides its Contributions) on an "AS IS" BASIS,
141
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
142
+ implied, including, without limitation, any warranties or conditions
143
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
144
+ PARTICULAR PURPOSE. You are solely responsible for determining the
145
+ appropriateness of using or reproducing the Work and assume any
146
+ risks associated with Your exercise of permissions under this License.
147
+
148
+ 8. Limitation of Liability. In no event and under no legal theory,
149
+ whether in tort (including negligence), contract, or otherwise,
150
+ unless required by applicable law (such as deliberate and grossly
151
+ negligent acts) or agreed to in writing, shall any Contributor be
152
+ liable to You for damages, including any direct, indirect, special,
153
+ incidental, or exemplary damages of any character arising as a
154
+ result of this License or out of the use or inability to use the
155
+ Work (including but not limited to damages for loss of goodwill,
156
+ work stoppage, computer failure or malfunction, or all other
157
+ commercial damages or losses), even if such Contributor has been
158
+ advised of the possibility of such damages.
159
+
160
+ 9. Accepting Warranty or Liability. While redistributing the Work or
161
+ Derivative Works thereof, You may choose to offer, and charge a fee
162
+ for, acceptance of support, warranty, indemnity, or other liability
163
+ obligations and/or rights consistent with this License. However, in
164
+ accepting such obligations, You may offer such conditions only on
165
+ Your own behalf and on Your sole responsibility, not on behalf of
166
+ any other Contributor, and only if You agree to indemnify, defend,
167
+ and hold each Contributor harmless for any liability incurred by,
168
+ or claims asserted against, such Contributor by reason of your
169
+ accepting any such warranty or additional liability.
170
+
171
+ END OF TERMS AND CONDITIONS
172
+
173
+ APPENDIX: How to apply the Apache License to your work.
174
+
175
+ To apply the Apache License to your work, attach the following
176
+ boilerplate notice, with the fields enclosed by brackets "[]"
177
+ replaced with your own identifying information. (Don't include
178
+ the brackets!) The text should be enclosed in the appropriate
179
+ comment syntax for the format in use. Please consult an
180
+ EXPLANATION document at apache.org for clarification of the
181
+ specific license version.
182
+
183
+ Copyright [yyyy] [name of copyright owner]
184
+
185
+ Licensed under the Apache License, Version 2.0 (the "License");
186
+ you may not use this file except in compliance with the License.
187
+ You may obtain a copy of the License at
188
+
189
+ http://www.apache.org/licenses/LICENSE-2.0
190
+
191
+ Unless required by applicable law or agreed to in writing, software
192
+ distributed under the License is distributed on an "AS IS" BASIS,
193
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
194
+ See the License for the specific language governing permissions and
195
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,185 @@
1
+ # @synoi/gateway-lite
2
+
3
+ SynOI Gateway Lite: a self-hosted local daemon for governed-action approval with
4
+ operator-owned, self-signed receipts. No account, no managed key custody, no
5
+ network call required to run it.
6
+
7
+ **Status: PARTIAL-against-test-keys, PARTIAL-pending-Security+Adversary-panel.**
8
+ See "What gets signed, and by whom" and "Where the key lives, and who else can
9
+ use it" below before relying on this for anything beyond local dogfood.
10
+
11
+ ## What this is
12
+
13
+ A single process that:
14
+
15
+ 1. Accepts a governed action from your code (`gate()` via `@synoi/sdk` in local mode,
16
+ or a raw `POST /local/gate`).
17
+ 2. Shows it to you, the operator, in a local dashboard for approve/deny.
18
+ 3. Signs a receipt for the decision with a key generated once on your own machine
19
+ and never transmitted anywhere.
20
+
21
+ It excludes, at the architecture level (not just by policy), every premium channel
22
+ adapter (Composio, Slack, SMS, voice, n8n/Zapier, home automation, AR overlay, and
23
+ the 23 MCP shim integrations), the control-plane / license client, and the KMS
24
+ managed-custody signing tier (the AWS Secrets Manager-backed key provider the full
25
+ gateway uses in production). Those are the paid, hosted product; this package
26
+ literally cannot reach any of that code -- verified two ways in the source repo's
27
+ CI, not by inspection: (1) a dependency-graph assertion over daemon.ts's actual
28
+ TypeScript import graph, and (2) a byte-level content scan of the REAL packed
29
+ tarball (the exact bytes `npm install @synoi/gateway-lite` would fetch) that fails if
30
+ any shipped JavaScript (.js) file contains an AWS SDK reference anywhere,
31
+ comments included. The
32
+ KMS provider is a complete, working AWS Secrets Manager client -- it lives in its
33
+ own source module, reached by the full gateway only through a runtime
34
+ `require()` call, and that module is never compiled into this package: it is not
35
+ merely unused, it is structurally absent from what you install.
36
+
37
+ ## Quickstart
38
+
39
+ ```bash
40
+ npm i @synoi/sdk
41
+ npx @synoi/gateway-lite
42
+ ```
43
+
44
+ The daemon listens on `http://127.0.0.1:8787` by default (override with
45
+ `SYNOI_LITE_PORT`). Open `http://127.0.0.1:8787/local/dashboard` in a browser to
46
+ enroll your operator identity (a keypair generated in the browser via the Web
47
+ Crypto API; the private key never leaves it) and approve/deny pending actions.
48
+
49
+ From your application:
50
+
51
+ ```ts
52
+ import { gate } from '@synoi/sdk'
53
+
54
+ await gate({
55
+ action_kind: 'command',
56
+ args: { to: 'ops@example.com', subject: 'deploy complete' },
57
+ daemonUrl: 'http://127.0.0.1:8787', // or SYNOI_DAEMON_URL env
58
+ }, async () => {
59
+ // runs only if the operator approves
60
+ await sendEmail(...)
61
+ })
62
+ ```
63
+
64
+ ## What gets signed, and by whom
65
+
66
+ The first time the daemon runs, it generates a single Ed25519 keypair for you, the
67
+ operator. Every decision receipt after that is self-signed with that SAME key using
68
+ `@synoi/gap`'s `receipt()` one-liner -- the single-Ed25519 self-sign CDRO shape,
69
+ `receipt_scheme: "synoi.receipt/gap-selfsign"`. Verify any receipt offline with the
70
+ published `@synoi/verify` package:
71
+
72
+ ```ts
73
+ import { verifyReceiptByScheme } from '@synoi/verify'
74
+
75
+ const result = await verifyReceiptByScheme({
76
+ receipt, // fetched from GET /local/receipts/:oid
77
+ gap_ed25519_pub: pubkey, // the 32-byte raw public key (see "Where the key lives" below)
78
+ })
79
+ // result.valid === true, result.scheme === 'gap-selfsign'
80
+ ```
81
+
82
+ **Honest disclosure:** this proves the receipt was signed by, and has not been
83
+ altered since, the key on YOUR machine. It does not yet prove that key belongs to
84
+ a trustworthy party to anyone else -- a neutral, third-party-hosted resolver
85
+ (`oid.synoi.systems`) is planned but not live. Do not describe a self-signed
86
+ receipt as "independently verified."
87
+
88
+ ### Where the key lives, and who else can use it
89
+
90
+ **Any process running as your OS user account can sign as the operator using this
91
+ key. This key has no managed custody and no account recovery: if it is lost, it is
92
+ gone, and there is no SynOI-side way to get it back or re-sign past receipts under
93
+ a continuous identity.** This is the tradeoff of self-hosting with no managed
94
+ service in the loop; it is not a bug to be fixed later, it is what "no account, no
95
+ network call" means.
96
+
97
+ The daemon tries to reduce the blast radius of that tradeoff by wrapping the key
98
+ with your OS's own credential store where one is available:
99
+
100
+ - **Windows** -- DPAPI (`System.Security.Cryptography.ProtectedData`,
101
+ current-user scope). The private key is written to
102
+ `SYNOI_DATA_DIR/lite-signing-key.dpapi` as ciphertext only your Windows user
103
+ account can decrypt; `SYNOI_DATA_DIR/lite-signing-key.json` holds only the
104
+ public key and metadata.
105
+ - **macOS** -- the system Keychain, via the `security` command-line tool every
106
+ macOS install ships with (implemented per documented behavior; not yet
107
+ executable-tested on this platform; the daemon prints the actual path
108
+ taken, and any fallback, on every boot).
109
+ - **Linux** -- `secret-tool` (libsecret / gnome-keyring). Requires a running
110
+ secret-service provider, which is normal on a desktop session and often ABSENT
111
+ on a minimal/headless/server install -- that is an expected reason to hit the
112
+ fallback below, not a bug (implemented per documented behavior; not yet
113
+ executable-tested on this platform; the daemon prints the actual path
114
+ taken, and any fallback, on every boot).
115
+
116
+ **Important:** the OS keystore protects the key from OTHER user accounts on the
117
+ same machine. It does NOT protect the key from other processes running as YOUR
118
+ OWN account -- any of those can still ask the OS to unwrap it, same as they could
119
+ read any other file you own. Treat the machine and your OS login as the trust
120
+ boundary, not this daemon.
121
+
122
+ If no OS keystore is available (or it fails), the daemon falls back to a plaintext
123
+ JSON file at `SYNOI_DATA_DIR/lite-signing-key.json` (`private_key_hex` present
124
+ directly), protected by whatever your OS's own file permissions provide: POSIX
125
+ mode `0600` on macOS/Linux (kernel-enforced), or a Windows ACL restricted to your
126
+ account only (`icacls ... /grant:r <you>:F`, applied automatically -- note that
127
+ POSIX mode bits like `0600` are silently a no-op on Windows NTFS, which is why
128
+ this is a real ACL call, not just a mode flag). The daemon prints which path it
129
+ took, and any fallback reason, on every boot.
130
+
131
+ ## Environment variables
132
+
133
+ | Variable | Purpose | Default |
134
+ |---|---|---|
135
+ | `SYNOI_LITE_PORT` / `PORT` | Listen port | `8787` |
136
+ | `SYNOI_DATA_DIR` | Where the operator signing key, enrollment record, and SQLite store live | `~/.synoi` |
137
+ | `SYNOI_ALLOW_EPHEMERAL_KEYS` | Currently required for `POST /local/gate` to accept the bootstrap hero-bundle OID `capbundle/1` without a real capability-grant record (lite has no grant-issuance ceremony yet). NOT needed for key generation, receipt signing, or the operator-enrollment record, which survive a restart on the persisted operator key regardless of this variable. Set `true`; this requirement is expected to be removed once a real grant ceremony ships. | required for `POST /local/gate`, no default |
138
+ | `SYNOI_DASHBOARD_DIR` | Serve a built portal SPA instead of the built-in self-contained HTML dashboard | unset (uses the built-in dashboard) |
139
+
140
+ The daemon boots with zero AWS credentials, zero control-plane URL, and zero
141
+ license key -- there is nothing in the shipped package that could reach any of
142
+ those: no reachable import, and (independently checked) no AWS-SDK-related byte
143
+ sequence anywhere in the packed tarball (enforced by CI, see "Architecture"
144
+ below).
145
+
146
+ ## Architecture (why this is small)
147
+
148
+ This package is NOT a slice of the full SynOI gateway shipped to a subdirectory.
149
+ It bundles only the source files `src/daemon.ts` actually imports, transitively,
150
+ in the gateway's monorepo -- 18 files, six runtime npm dependencies (`express`,
151
+ `better-sqlite3`, `@synoi/gap`, `@synoi/sraid`, `@noble/curves`,
152
+ `@noble/post-quantum`), no channel adapters, no license client, no cloud SDK of
153
+ any kind. The gateway repo's CI checks this two ways, both required to pass
154
+ before a build is produced:
155
+
156
+ 1. A dependency-graph assertion over `daemon.ts`'s real TypeScript import graph
157
+ (`ts.createProgram`, not a regex), asserting it never reaches the channel
158
+ adapters, the license client, the KMS-hybrid signing tier, or the AWS
159
+ Secrets Manager key provider module.
160
+ 2. A byte-level content scan of the ACTUAL packed tarball (a real `npm pack`,
161
+ extracted and read file by file, not `--dry-run`'s file-name listing):
162
+ fails if any shipped `.js` file contains an AWS-SDK-related string anywhere,
163
+ including inside comments. This is the check that would have caught what
164
+ the dependency-graph assertion alone could not: a file can be legitimately
165
+ reachable (this package's own key-provider module is; it backs the
166
+ self-host key-generation path) while a DIFFERENT class defined in the same
167
+ file carries a cloud-SDK reference that a pure import-graph walk cannot
168
+ see. The fix was to move that class into its own module, reached only by
169
+ a runtime `require()` the static graph walk does not follow -- so its
170
+ compiled output, and the SDK reference inside it, never enter this
171
+ package's `dist/` at all.
172
+
173
+ This package's own build step refuses to produce a build if either assertion
174
+ would fail.
175
+
176
+ ## Repository
177
+
178
+ This package currently lives in `packages/gateway-lite/` of the `synoi-gateway`
179
+ repository (private) pending extraction to a dedicated public repository before
180
+ first publish. That extraction, and the first `npm publish`, are human-gated
181
+ steps not taken by this build.
182
+
183
+ ## License
184
+
185
+ Apache-2.0
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env node
2
+ 'use strict'
3
+
4
+ /**
5
+ * bin/synoi-gateway-lite.js -- the `npx @synoi/gateway-lite` / `synoi-gateway-lite` entrypoint.
6
+ *
7
+ * Calls startLiteDaemon() explicitly rather than relying on dist/daemon.js's
8
+ * `if (require.main === module)` guard: that guard is true only when
9
+ * dist/daemon.js itself is the process's initially-run script, which is NOT
10
+ * the case here -- this bin wrapper is the initially-run script, and it
11
+ * require()s daemon.js as a module. Same reason src/index.ts's equivalent
12
+ * guard does not fire when the gateway is required as a library (embed.ts).
13
+ *
14
+ * No em dashes. No AI attribution.
15
+ */
16
+
17
+ const { startLiteDaemon } = require('../dist/daemon.js')
18
+
19
+ startLiteDaemon().catch((err) => {
20
+ process.stderr.write(`[synoi-gateway-lite] FATAL: ${err && err.stack ? err.stack : String(err)}\n`)
21
+ process.exit(1)
22
+ })