@homeflare/distilled-opnsense 0.2.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.
Files changed (78) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +95 -0
  3. package/dist/credentials.d.ts +39 -0
  4. package/dist/credentials.d.ts.map +1 -0
  5. package/dist/credentials.js +78 -0
  6. package/dist/credentials.js.map +1 -0
  7. package/dist/errors.d.ts +110 -0
  8. package/dist/errors.d.ts.map +1 -0
  9. package/dist/errors.js +63 -0
  10. package/dist/errors.js.map +1 -0
  11. package/dist/index.d.ts +29 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +29 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/protocol.d.ts +13 -0
  16. package/dist/protocol.d.ts.map +1 -0
  17. package/dist/protocol.js +115 -0
  18. package/dist/protocol.js.map +1 -0
  19. package/dist/retry.d.ts +56 -0
  20. package/dist/retry.d.ts.map +1 -0
  21. package/dist/retry.js +49 -0
  22. package/dist/retry.js.map +1 -0
  23. package/dist/services/firewall_alias.d.ts +243 -0
  24. package/dist/services/firewall_alias.d.ts.map +1 -0
  25. package/dist/services/firewall_alias.js +222 -0
  26. package/dist/services/firewall_alias.js.map +1 -0
  27. package/dist/services/firewall_category.d.ts +122 -0
  28. package/dist/services/firewall_category.d.ts.map +1 -0
  29. package/dist/services/firewall_category.js +161 -0
  30. package/dist/services/firewall_category.js.map +1 -0
  31. package/dist/services/firewall_filter.d.ts +289 -0
  32. package/dist/services/firewall_filter.d.ts.map +1 -0
  33. package/dist/services/firewall_filter.js +225 -0
  34. package/dist/services/firewall_filter.js.map +1 -0
  35. package/dist/services/firewall_group.d.ts +122 -0
  36. package/dist/services/firewall_group.d.ts.map +1 -0
  37. package/dist/services/firewall_group.js +154 -0
  38. package/dist/services/firewall_group.js.map +1 -0
  39. package/dist/services/index.d.ts +9 -0
  40. package/dist/services/index.d.ts.map +1 -0
  41. package/dist/services/index.js +10 -0
  42. package/dist/services/index.js.map +1 -0
  43. package/dist/services/quagga_bgp.d.ts +1135 -0
  44. package/dist/services/quagga_bgp.d.ts.map +1 -0
  45. package/dist/services/quagga_bgp.js +1263 -0
  46. package/dist/services/quagga_bgp.js.map +1 -0
  47. package/dist/services/quagga_general.d.ts +55 -0
  48. package/dist/services/quagga_general.d.ts.map +1 -0
  49. package/dist/services/quagga_general.js +48 -0
  50. package/dist/services/quagga_general.js.map +1 -0
  51. package/dist/services/quagga_service.d.ts +60 -0
  52. package/dist/services/quagga_service.d.ts.map +1 -0
  53. package/dist/services/quagga_service.js +77 -0
  54. package/dist/services/quagga_service.js.map +1 -0
  55. package/dist/services/routing_settings.d.ts +192 -0
  56. package/dist/services/routing_settings.d.ts.map +1 -0
  57. package/dist/services/routing_settings.js +169 -0
  58. package/dist/services/routing_settings.js.map +1 -0
  59. package/dist/traits.d.ts +11 -0
  60. package/dist/traits.d.ts.map +1 -0
  61. package/dist/traits.js +11 -0
  62. package/dist/traits.js.map +1 -0
  63. package/package.json +75 -0
  64. package/src/credentials.ts +111 -0
  65. package/src/errors.ts +115 -0
  66. package/src/index.ts +32 -0
  67. package/src/protocol.ts +177 -0
  68. package/src/retry.ts +80 -0
  69. package/src/services/firewall_alias.ts +572 -0
  70. package/src/services/firewall_category.ts +359 -0
  71. package/src/services/firewall_filter.ts +671 -0
  72. package/src/services/firewall_group.ts +350 -0
  73. package/src/services/index.ts +9 -0
  74. package/src/services/quagga_bgp.ts +2955 -0
  75. package/src/services/quagga_general.ts +132 -0
  76. package/src/services/quagga_service.ts +182 -0
  77. package/src/services/routing_settings.ts +419 -0
  78. package/src/traits.ts +36 -0
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/README.md ADDED
@@ -0,0 +1,95 @@
1
+ # @homeflare/distilled-opnsense
2
+
3
+ This package is **not a HomeFlare SDK**. It is an unmodified copy of
4
+ `@distilled.cloud/opnsense`, generated by the
5
+ [distilled](https://github.com/alchemy-run/distilled) pipeline from
6
+ OPNsense's own MVC model XML and API controller PHP — OPNsense publishes no
7
+ OpenAPI/Smithy/GraphQL description of its API at all, so this converter
8
+ reads `opnsense/core`'s `mvc/app/models/OPNsense/<Module>/<Model>.xml` and
9
+ `.../controllers/OPNsense/<Module>/Api/*Controller.php` directly, not the
10
+ shared OpenAPI dialect every other distilled package uses. Published here
11
+ under its own name only because `@distilled.cloud/opnsense` does not exist
12
+ on npm yet — the kit builds it in a local clone of `alchemy-run/distilled`
13
+ but, per house policy, never pushes to that upstream. See
14
+ [`../alchemy/docs/distilled-interim.md`](../alchemy/docs/distilled-interim.md)
15
+ for the full route every distilled-sourced vendor package follows, and why
16
+ this one exists at all.
17
+
18
+ ⛔ **Do not hand-edit anything under `src/`.** The whole point of the route
19
+ above is that this directory is _copied_, not written — a fix belongs in
20
+ the distilled clone's `packages/opnsense/`, regenerated, then copied back
21
+ here.
22
+
23
+ ⚠️ **License.** Apache-2.0, not the kit's usual MIT — this content is a
24
+ redistribution of `alchemy-run/distilled`'s own Apache-2.0-licensed output,
25
+ and relicensing a copy would misstate what it is. See `LICENSE`.
26
+
27
+ ## Provenance and version pin
28
+
29
+ Generated against `opnsense/core` and `opnsense/plugins` tag `26.7.2`. The
30
+ edge firewall's exact installed version has **never been measured live**
31
+ (SSH to the edge is forbidden by house policy; CrowdSec bans the caller's
32
+ IP on a failed probe) — `26.7.2` is inferred, read-only, from a captured
33
+ package list (`os-frr-1.54` matches that one tag's plugin tree exactly) and
34
+ a runbook stating the box runs "26.7.x". See the distilled clone's
35
+ `packages/opnsense/README.md` for the full evidence chain. Patch releases
36
+ inside one OPNsense series essentially never change model/controller shape,
37
+ so this pin's model XML/controller PHP is very likely correct even if the
38
+ edge sits on a different `26.7.x` patch — but it is an inference, not a
39
+ measurement, and should be confirmed on the box before this package is
40
+ trusted for anything consequential.
41
+
42
+ ## What's in it
43
+
44
+ 8 API controllers, 83 operations — Firewall Alias/Category/Group/Filter
45
+ (rules), Routing (Gateways), and the `os-frr` plugin's Quagga/BGP — not
46
+ OPNsense's full ~80 configured modules; see the distilled clone's
47
+ `packages/opnsense/README.md` for the scope table and what was mechanically
48
+ excluded per controller (decorated `get<Item>Action`s, bespoke lifecycle
49
+ actions). `catchTag`-able errors cover OPNsense's three-shape
50
+ 200-with-failure vendor pattern (`{result:"failed"}` validation errors,
51
+ `UserWarningException`/`UserInformationalException` at 200) plus the
52
+ genuine non-2xx shapes (`UserException`, `DispatchException` 404, the
53
+ 401/403/400 auth gate) — see `src/protocol.ts` and `src/errors.ts` for the
54
+ full mapping with citations back to OPNsense's own PHP source.
55
+
56
+ ```ts
57
+ import * as Opnsense from '@distilled.cloud/opnsense'; // aliased onto this package — see docs/distilled-interim.md
58
+ import * as Effect from 'effect/Effect';
59
+
60
+ const program = Opnsense.Services.quagga_general.get({}).pipe(
61
+ Effect.provide(
62
+ Opnsense.credentials({
63
+ apiKey: 'key',
64
+ apiSecret: 'secret',
65
+ baseUrl: 'https://edge.example.com',
66
+ }),
67
+ ),
68
+ );
69
+ ```
70
+
71
+ Kit code never imports `@homeflare/distilled-opnsense` directly — always
72
+ `@distilled.cloud/opnsense` (the alias in `docs/distilled-interim.md`'s
73
+ step 5), once that alias exists. This PR does not add that alias and does
74
+ not declare any Alchemy `Resource`s on top — see "Not done here" below.
75
+
76
+ ## Not done here
77
+
78
+ - **No alias, no Alchemy `Resource`s.** The alias can only resolve once
79
+ this package is actually published to npm; adding Firewall
80
+ Alias/Category/Group/Rule (and later Gateways/BGP) resources on top is a
81
+ follow-up PR, gated in part on two open intent questions in
82
+ `docs/alchemy-ledger-network.md` in the landscape repo.
83
+ - **No live calls of any kind.** This package has never been pointed at a
84
+ real OPNsense instance; `src/protocol.ts`'s decode logic is grounded in
85
+ vendor source and docs, not runtime-verified. `docs/design.md` in the
86
+ distilled clone's `packages/opnsense/` flags a behavioral trap worth
87
+ reading before building a `Resource` around `setAlias`/`setCategory`/
88
+ `setGroup`: renaming an item through those endpoints triggers a
89
+ server-side cascade that rewrites the old name everywhere it's
90
+ referenced elsewhere in `config.xml`, not just inside the renamed row.
91
+
92
+ ## License
93
+
94
+ Apache-2.0 — see `LICENSE`. This package is a redistribution of
95
+ `alchemy-run/distilled`'s own generated output, unmodified.
@@ -0,0 +1,39 @@
1
+ import * as Context from "effect/Context";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Layer from "effect/Layer";
4
+ import * as Redacted from "effect/Redacted";
5
+ /**
6
+ * OPNsense's own path prefix; every generated route's `T.Http({ uri })`
7
+ * already carries it (e.g. `/api/quagga/general/get` — see any
8
+ * `src/services/*.ts`), because it is the vendor's own real wire path, not
9
+ * an artifact of this converter. `buildRequest` in
10
+ * `@distilled.cloud/core/protocol-http` concatenates `baseUrl + uri`
11
+ * verbatim with no de-duplication, so `apiBaseUrl` MUST be the bare origin
12
+ * — appending `API_PATH` here as well produced a real, smoke-test-caught
13
+ * `/api/api/...` request (see `../scripts/smoke.ts` and
14
+ * `../README.md`'s "Known limitations"). `normalizeBaseUrl` therefore
15
+ * STRIPS a trailing `/api` a caller may have included (the doc comment on
16
+ * `Config.apiBaseUrl` below used to invite exactly that input), rather than
17
+ * adding one.
18
+ */
19
+ export declare const API_PATH = "/api";
20
+ /** Normalize an OPNsense origin (or an already-complete `/api` root, accepted for caller convenience) down to the bare origin every generated route's own `uri` already assumes. */
21
+ export declare const normalizeBaseUrl: (baseUrl: string) => string;
22
+ export interface Config {
23
+ readonly apiKey: string;
24
+ readonly apiSecret: Redacted.Redacted<string>;
25
+ /** Bare origin, e.g. `https://edge.homeflare.dev` or `https://10.20.10.1` — a trailing `/api` is accepted and stripped, never doubled with a route's own `/api/...` prefix. */
26
+ readonly apiBaseUrl: string;
27
+ }
28
+ declare const Credentials_base: Context.ServiceClass<Credentials, "OpnsenseCredentials", Effect.Effect<Config, never, never>>;
29
+ export declare class Credentials extends Credentials_base {
30
+ }
31
+ export declare const CredentialsFromEnv: Layer.Layer<Credentials, never, never>;
32
+ /** Convenience layer from a plain key/secret and the box's origin (or API root). */
33
+ export declare const credentials: (config: {
34
+ readonly apiKey: string;
35
+ readonly apiSecret: string | Redacted.Redacted<string>;
36
+ readonly baseUrl: string;
37
+ }) => Layer.Layer<Credentials>;
38
+ export {};
39
+ //# sourceMappingURL=credentials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAG5C;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,QAAQ,SAAS,CAAC;AAE/B,oLAAoL;AACpL,eAAO,MAAM,gBAAgB,YAAa,MAAM,KAAG,MASlD,CAAC;AAEF,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC9C,+KAA+K;IAC/K,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;;AAED,qBAAa,WAAY,SAAQ,gBAGP;CAAG;AAW7B,eAAO,MAAM,kBAAkB,wCAiB9B,CAAC;AAEF,oFAAoF;AACpF,eAAO,MAAM,WAAW,WAAY;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACvD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,KAAG,KAAK,CAAC,KAAK,CAAC,WAAW,CAWxB,CAAC"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * OPNsense credentials — hand-written.
3
+ *
4
+ * OPNsense authenticates its `/api/*` surface with a key/secret pair sent
5
+ * as HTTP Basic auth: `Authorization: Basic base64(key:secret)` — verified
6
+ * both in source (`ApiControllerBase::beforeExecuteRoute`, mirrored at
7
+ * `specs/core/models/Base/ApiControllerBase.php`: it splits the decoded
8
+ * Basic-auth payload on `:` into `apiKey`/`apiSecret`, and works with ANY
9
+ * scheme word before the base64 blob, not just literally `Basic`) and in
10
+ * the vendor's own docs (`opnsense/docs`, `source/development/how-tos/
11
+ * api.rst`: a `curl -u <api-key>:<api-secret>` example against `.../api/...`,
12
+ * and the Python sample's `requests.get(..., auth=(api_key, api_secret))` — `requests`'
13
+ * `auth=` tuple IS HTTP Basic). The secret is generated once per key in the
14
+ * user manager and cannot be re-downloaded, so it is credential-shaped, not
15
+ * password-shaped — `Redacted` like a token, never compared or logged.
16
+ *
17
+ * Self-hosted, like Forgejo: there is no default host, so the edge/router's
18
+ * origin is part of the credential, not a hardcoded base URL.
19
+ */
20
+ import * as EffectConfig from "effect/Config";
21
+ import * as Context from "effect/Context";
22
+ import * as Effect from "effect/Effect";
23
+ import * as Layer from "effect/Layer";
24
+ import * as Redacted from "effect/Redacted";
25
+ import { ConfigError } from "@distilled.cloud/core/errors";
26
+ /**
27
+ * OPNsense's own path prefix; every generated route's `T.Http({ uri })`
28
+ * already carries it (e.g. `/api/quagga/general/get` — see any
29
+ * `src/services/*.ts`), because it is the vendor's own real wire path, not
30
+ * an artifact of this converter. `buildRequest` in
31
+ * `@distilled.cloud/core/protocol-http` concatenates `baseUrl + uri`
32
+ * verbatim with no de-duplication, so `apiBaseUrl` MUST be the bare origin
33
+ * — appending `API_PATH` here as well produced a real, smoke-test-caught
34
+ * `/api/api/...` request (see `../scripts/smoke.ts` and
35
+ * `../README.md`'s "Known limitations"). `normalizeBaseUrl` therefore
36
+ * STRIPS a trailing `/api` a caller may have included (the doc comment on
37
+ * `Config.apiBaseUrl` below used to invite exactly that input), rather than
38
+ * adding one.
39
+ */
40
+ export const API_PATH = "/api";
41
+ /** Normalize an OPNsense origin (or an already-complete `/api` root, accepted for caller convenience) down to the bare origin every generated route's own `uri` already assumes. */
42
+ export const normalizeBaseUrl = (baseUrl) => {
43
+ // A loop, not a trailing-slash regex: that backtracks polynomially on a long
44
+ // run of "/" (CodeQL js/polynomial-redos), the same fix as distilled-netbox's.
45
+ let end = baseUrl.length;
46
+ while (end > 0 && baseUrl.charCodeAt(end - 1) === 47)
47
+ end--;
48
+ const trimmed = baseUrl.slice(0, end);
49
+ return trimmed.endsWith(API_PATH)
50
+ ? trimmed.slice(0, -API_PATH.length)
51
+ : trimmed;
52
+ };
53
+ export class Credentials extends Context.Service()("OpnsenseCredentials") {
54
+ }
55
+ const envConfig = EffectConfig.all({
56
+ // No vendor-standard env var names exist for OPNsense's API (unlike
57
+ // Forgejo's own `FORGEJO_URL`/`FORGEJO_TOKEN`) — these follow this SDK's
58
+ // own naming.
59
+ apiKey: EffectConfig.String("OPNSENSE_API_KEY"),
60
+ apiSecret: EffectConfig.String("OPNSENSE_API_SECRET"),
61
+ baseUrl: EffectConfig.String("OPNSENSE_URL"),
62
+ });
63
+ export const CredentialsFromEnv = Layer.succeed(Credentials, envConfig.pipe(Effect.mapError(() => new ConfigError({
64
+ message: "OPNSENSE_URL, OPNSENSE_API_KEY and OPNSENSE_API_SECRET environment variables are required",
65
+ })), Effect.map(({ apiKey, apiSecret, baseUrl }) => ({
66
+ apiKey,
67
+ apiSecret: Redacted.make(apiSecret),
68
+ apiBaseUrl: normalizeBaseUrl(baseUrl),
69
+ })), Effect.orDie));
70
+ /** Convenience layer from a plain key/secret and the box's origin (or API root). */
71
+ export const credentials = (config) => Layer.succeed(Credentials, Effect.succeed({
72
+ apiKey: config.apiKey,
73
+ apiSecret: typeof config.apiSecret === "string"
74
+ ? Redacted.make(config.apiSecret)
75
+ : config.apiSecret,
76
+ apiBaseUrl: normalizeBaseUrl(config.baseUrl),
77
+ }));
78
+ //# sourceMappingURL=credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials.js","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,YAAY,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE/B,oLAAoL;AACpL,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAe,EAAU,EAAE;IAC1D,6EAA6E;IAC7E,+EAA+E;IAC/E,IAAI,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IACzB,OAAO,GAAG,GAAG,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,EAAE;QAAE,GAAG,EAAE,CAAC;IAC5D,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACtC,OAAO,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAC/B,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC;QACpC,CAAC,CAAC,OAAO,CAAC;AACd,CAAC,CAAC;AASF,MAAM,OAAO,WAAY,SAAQ,OAAO,CAAC,OAAO,EAG7C,CAAC,qBAAqB,CAAC;CAAG;AAE7B,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC;IACjC,oEAAoE;IACpE,yEAAyE;IACzE,cAAc;IACd,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,kBAAkB,CAAC;IAC/C,SAAS,EAAE,YAAY,CAAC,MAAM,CAAC,qBAAqB,CAAC;IACrD,OAAO,EAAE,YAAY,CAAC,MAAM,CAAC,cAAc,CAAC;CAC7C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC,OAAO,CAC7C,WAAW,EACX,SAAS,CAAC,IAAI,CACZ,MAAM,CAAC,QAAQ,CACb,GAAG,EAAE,CACH,IAAI,WAAW,CAAC;IACd,OAAO,EACL,2FAA2F;CAC9F,CAAC,CACL,EACD,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;IAC9C,MAAM;IACN,SAAS,EAAE,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC;IACnC,UAAU,EAAE,gBAAgB,CAAC,OAAO,CAAC;CACtC,CAAC,CAAC,EACH,MAAM,CAAC,KAAK,CACb,CACF,CAAC;AAEF,oFAAoF;AACpF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,MAI3B,EAA4B,EAAE,CAC7B,KAAK,CAAC,OAAO,CACX,WAAW,EACX,MAAM,CAAC,OAAO,CAAC;IACb,MAAM,EAAE,MAAM,CAAC,MAAM;IACrB,SAAS,EACP,OAAO,MAAM,CAAC,SAAS,KAAK,QAAQ;QAClC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;QACjC,CAAC,CAAC,MAAM,CAAC,SAAS;IACtB,UAAU,EAAE,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC;CAC7C,CAAC,CACH,CAAC"}
@@ -0,0 +1,110 @@
1
+ /**
2
+ * OPNsense-specific error types — hand-written.
3
+ *
4
+ * OPNsense is a 200-with-failure vendor (see `protocol.ts`'s module doc):
5
+ * most of what a caller needs to `catchTag` on never reaches an HTTP error
6
+ * status at all. This module's classes are read directly off
7
+ * `src/opnsense/www/api.php` (the `/api/*` front controller — mirrored at
8
+ * `specs/core/models/Base/` is the controller CONTRACT those bodies come
9
+ * from; `api.php` itself is not mirrored, since it is not model/controller
10
+ * source the converter reads, but its four `catch` clauses are exactly the
11
+ * four non-2xx/vendor-exception shapes below):
12
+ *
13
+ * catch UserException → getHttpCode() (500 unless a subclass
14
+ * overrides it) + {errorMessage,
15
+ * errorTitle, errorLevel} — a real
16
+ * business-rule denial (Alias/Category/
17
+ * Group's "in use" checks, Filter's
18
+ * "cannot move" checks), NOT a server
19
+ * fault: never retried.
20
+ * catch DispatchException → 404 {errorMessage} (route/controller/
21
+ * action not found — e.g. a plugin
22
+ * module that isn't installed).
23
+ * catch Error|Exception → 500 {errorMessage: "Unexpected error,
24
+ * check log for details"} (a PHP fault).
25
+ * (not sent) → the ORIGINAL response, when none of
26
+ * the above threw — this is everything
27
+ * else: the 401/403/400 auth/CSRF/JSON
28
+ * shapes from `ApiControllerBase::before
29
+ * ExecuteRoute` ({status:<code>,
30
+ * message}, `status` a NUMBER — do not
31
+ * confuse with the unrelated string
32
+ * `status` OPNsense's OWN operations
33
+ * return, e.g. service status/
34
+ * reconfigure) and the 200
35
+ * `{result:"failed", validations?}`
36
+ * shape every `ApiMutableModelController
37
+ * Base` mutation can answer with.
38
+ */
39
+ import * as Schema from "effect/Schema";
40
+ import { ConfigError, Unauthorized, Forbidden, BadRequest, NotFound, InternalServerError } from "@distilled.cloud/core/errors";
41
+ export { ConfigError, Unauthorized, Forbidden, BadRequest, NotFound, InternalServerError, };
42
+ declare const ValidationFailed_base: Schema.Class<ValidationFailed, Schema.TaggedStruct<"ValidationFailed", {
43
+ readonly validations: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
44
+ }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
45
+ "@distilled.cloud/error/categories": {
46
+ BadRequestError: true;
47
+ };
48
+ });
49
+ /** `{"result":"failed", validations?: {...}}` from `ApiMutableModelControllerBase::validate()`/`setBase`/`addBase`/`delBase`/`toggleBase` — always HTTP 200. `validations` is absent for a non-field failure (bad uuid, wrong verb); present and keyed `<prefix>.<field>` → one message or several for a real field error. */
50
+ export declare class ValidationFailed extends ValidationFailed_base {
51
+ }
52
+ declare const OpnsenseUserError_base: Schema.Class<OpnsenseUserError, Schema.TaggedStruct<"OpnsenseUserError", {
53
+ readonly title: Schema.optional<Schema.String>;
54
+ readonly message: Schema.String;
55
+ }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
56
+ "@distilled.cloud/error/categories": {
57
+ BadRequestError: true;
58
+ };
59
+ });
60
+ /** A plain `UserException` (`errorLevel: "error"`, default HTTP 500) — a business-rule denial such as "Alias in use" or "cannot move to the same spot", not a server fault: `Category.withBadRequestError`, never retried. */
61
+ export declare class OpnsenseUserError extends OpnsenseUserError_base {
62
+ }
63
+ declare const OpnsenseUserWarning_base: Schema.Class<OpnsenseUserWarning, Schema.TaggedStruct<"OpnsenseUserWarning", {
64
+ readonly title: Schema.optional<Schema.String>;
65
+ readonly message: Schema.String;
66
+ }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
67
+ "@distilled.cloud/error/categories": {
68
+ BadRequestError: true;
69
+ };
70
+ });
71
+ /** A `UserWarningException` — HTTP 200, but the request did NOT do what was asked (`UserWarningException::getHttpCode()` is hard-coded 200). */
72
+ export declare class OpnsenseUserWarning extends OpnsenseUserWarning_base {
73
+ }
74
+ declare const OpnsenseUserNotice_base: Schema.Class<OpnsenseUserNotice, Schema.TaggedStruct<"OpnsenseUserNotice", {
75
+ readonly title: Schema.optional<Schema.String>;
76
+ readonly message: Schema.String;
77
+ }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
78
+ "@distilled.cloud/error/categories": {
79
+ BadRequestError: true;
80
+ };
81
+ });
82
+ /** A `UserInformationalException` — HTTP 200, an informational abort (e.g. "nothing to do"). */
83
+ export declare class OpnsenseUserNotice extends OpnsenseUserNotice_base {
84
+ }
85
+ declare const UnknownOpnsenseError_base: Schema.Class<UnknownOpnsenseError, Schema.TaggedStruct<"UnknownOpnsenseError", {
86
+ readonly status: Schema.Number;
87
+ readonly body: Schema.Unknown;
88
+ }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
89
+ "@distilled.cloud/error/categories": {
90
+ ServerError: true;
91
+ };
92
+ });
93
+ /** Unmapped failure — a response this SDK's protocol layer could not classify into any of the above (non-JSON body, a shape none of the known cases match). Carries the raw body for later cataloging. */
94
+ export declare class UnknownOpnsenseError extends UnknownOpnsenseError_base {
95
+ }
96
+ declare const OpnsenseParseError_base: Schema.Class<OpnsenseParseError, Schema.TaggedStruct<"OpnsenseParseError", {
97
+ readonly body: Schema.Unknown;
98
+ readonly cause: Schema.Unknown;
99
+ }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
100
+ "@distilled.cloud/error/categories": {
101
+ ParseError: true;
102
+ };
103
+ });
104
+ /** Schema parse error wrapper. */
105
+ export declare class OpnsenseParseError extends OpnsenseParseError_base {
106
+ }
107
+ export type ClientErrors = ValidationFailed | OpnsenseUserError | OpnsenseUserWarning | OpnsenseUserNotice | UnknownOpnsenseError | OpnsenseParseError;
108
+ /** Default errors every generated OPNsense operation carries — see the module doc for where each one comes from. */
109
+ export type DefaultErrors = Unauthorized | Forbidden | BadRequest | NotFound | InternalServerError | ConfigError | ClientErrors;
110
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EACL,WAAW,EACX,YAAY,EACZ,SAAS,EACT,UAAU,EACV,QAAQ,EACR,mBAAmB,EACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,WAAW,EACX,YAAY,EACZ,SAAS,EACT,UAAU,EACV,QAAQ,EACR,mBAAmB,GACpB,CAAC;;;;;;;;AAEF,8TAA8T;AAC9T,qBAAa,gBAAiB,SAAQ,qBAQF;CAAG;;;;;;;;;AAEvC,8NAA8N;AAC9N,qBAAa,iBAAkB,SAAQ,sBAGH;CAAG;;;;;;;;;AAEvC,gJAAgJ;AAChJ,qBAAa,mBAAoB,SAAQ,wBAGL;CAAG;;;;;;;;;AAEvC,gGAAgG;AAChG,qBAAa,kBAAmB,SAAQ,uBAGJ;CAAG;;;;;;;;;AAEvC,0MAA0M;AAC1M,qBAAa,oBAAqB,SAAQ,yBAGV;CAAG;;;;;;;;;AAEnC,kCAAkC;AAClC,qBAAa,kBAAmB,SAAQ,uBAGT;CAAG;AAElC,MAAM,MAAM,YAAY,GACpB,gBAAgB,GAChB,iBAAiB,GACjB,mBAAmB,GACnB,kBAAkB,GAClB,oBAAoB,GACpB,kBAAkB,CAAC;AAEvB,oHAAoH;AACpH,MAAM,MAAM,aAAa,GACrB,YAAY,GACZ,SAAS,GACT,UAAU,GACV,QAAQ,GACR,mBAAmB,GACnB,WAAW,GACX,YAAY,CAAC"}
package/dist/errors.js ADDED
@@ -0,0 +1,63 @@
1
+ /**
2
+ * OPNsense-specific error types — hand-written.
3
+ *
4
+ * OPNsense is a 200-with-failure vendor (see `protocol.ts`'s module doc):
5
+ * most of what a caller needs to `catchTag` on never reaches an HTTP error
6
+ * status at all. This module's classes are read directly off
7
+ * `src/opnsense/www/api.php` (the `/api/*` front controller — mirrored at
8
+ * `specs/core/models/Base/` is the controller CONTRACT those bodies come
9
+ * from; `api.php` itself is not mirrored, since it is not model/controller
10
+ * source the converter reads, but its four `catch` clauses are exactly the
11
+ * four non-2xx/vendor-exception shapes below):
12
+ *
13
+ * catch UserException → getHttpCode() (500 unless a subclass
14
+ * overrides it) + {errorMessage,
15
+ * errorTitle, errorLevel} — a real
16
+ * business-rule denial (Alias/Category/
17
+ * Group's "in use" checks, Filter's
18
+ * "cannot move" checks), NOT a server
19
+ * fault: never retried.
20
+ * catch DispatchException → 404 {errorMessage} (route/controller/
21
+ * action not found — e.g. a plugin
22
+ * module that isn't installed).
23
+ * catch Error|Exception → 500 {errorMessage: "Unexpected error,
24
+ * check log for details"} (a PHP fault).
25
+ * (not sent) → the ORIGINAL response, when none of
26
+ * the above threw — this is everything
27
+ * else: the 401/403/400 auth/CSRF/JSON
28
+ * shapes from `ApiControllerBase::before
29
+ * ExecuteRoute` ({status:<code>,
30
+ * message}, `status` a NUMBER — do not
31
+ * confuse with the unrelated string
32
+ * `status` OPNsense's OWN operations
33
+ * return, e.g. service status/
34
+ * reconfigure) and the 200
35
+ * `{result:"failed", validations?}`
36
+ * shape every `ApiMutableModelController
37
+ * Base` mutation can answer with.
38
+ */
39
+ import * as Schema from "effect/Schema";
40
+ import * as Category from "@distilled.cloud/core/category";
41
+ import { ConfigError, Unauthorized, Forbidden, BadRequest, NotFound, InternalServerError, } from "@distilled.cloud/core/errors";
42
+ export { ConfigError, Unauthorized, Forbidden, BadRequest, NotFound, InternalServerError, };
43
+ /** `{"result":"failed", validations?: {...}}` from `ApiMutableModelControllerBase::validate()`/`setBase`/`addBase`/`delBase`/`toggleBase` — always HTTP 200. `validations` is absent for a non-field failure (bad uuid, wrong verb); present and keyed `<prefix>.<field>` → one message or several for a real field error. */
44
+ export class ValidationFailed extends Schema.TaggedError()("ValidationFailed", {
45
+ validations: Schema.Record(Schema.String, Schema.Union([Schema.String, Schema.Array(Schema.String)])),
46
+ }).pipe(Category.withBadRequestError) {
47
+ }
48
+ /** A plain `UserException` (`errorLevel: "error"`, default HTTP 500) — a business-rule denial such as "Alias in use" or "cannot move to the same spot", not a server fault: `Category.withBadRequestError`, never retried. */
49
+ export class OpnsenseUserError extends Schema.TaggedError()("OpnsenseUserError", { title: Schema.optional(Schema.String), message: Schema.String }).pipe(Category.withBadRequestError) {
50
+ }
51
+ /** A `UserWarningException` — HTTP 200, but the request did NOT do what was asked (`UserWarningException::getHttpCode()` is hard-coded 200). */
52
+ export class OpnsenseUserWarning extends Schema.TaggedError()("OpnsenseUserWarning", { title: Schema.optional(Schema.String), message: Schema.String }).pipe(Category.withBadRequestError) {
53
+ }
54
+ /** A `UserInformationalException` — HTTP 200, an informational abort (e.g. "nothing to do"). */
55
+ export class OpnsenseUserNotice extends Schema.TaggedError()("OpnsenseUserNotice", { title: Schema.optional(Schema.String), message: Schema.String }).pipe(Category.withBadRequestError) {
56
+ }
57
+ /** Unmapped failure — a response this SDK's protocol layer could not classify into any of the above (non-JSON body, a shape none of the known cases match). Carries the raw body for later cataloging. */
58
+ export class UnknownOpnsenseError extends Schema.TaggedError()("UnknownOpnsenseError", { status: Schema.Number, body: Schema.Unknown }).pipe(Category.withServerError) {
59
+ }
60
+ /** Schema parse error wrapper. */
61
+ export class OpnsenseParseError extends Schema.TaggedError()("OpnsenseParseError", { body: Schema.Unknown, cause: Schema.Unknown }).pipe(Category.withParseError) {
62
+ }
63
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EACL,WAAW,EACX,YAAY,EACZ,SAAS,EACT,UAAU,EACV,QAAQ,EACR,mBAAmB,GACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,WAAW,EACX,YAAY,EACZ,SAAS,EACT,UAAU,EACV,QAAQ,EACR,mBAAmB,GACpB,CAAC;AAEF,8TAA8T;AAC9T,MAAM,OAAO,gBAAiB,SAAQ,MAAM,CAAC,WAAW,EAAoB,CAC1E,kBAAkB,EAClB;IACE,WAAW,EAAE,MAAM,CAAC,MAAM,CACxB,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAC3D;CACF,CACF,CAAC,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC;CAAG;AAEvC,8NAA8N;AAC9N,MAAM,OAAO,iBAAkB,SAAQ,MAAM,CAAC,WAAW,EAAqB,CAC5E,mBAAmB,EACnB,EAAE,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,CAClE,CAAC,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC;CAAG;AAEvC,gJAAgJ;AAChJ,MAAM,OAAO,mBAAoB,SAAQ,MAAM,CAAC,WAAW,EAAuB,CAChF,qBAAqB,EACrB,EAAE,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,CAClE,CAAC,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC;CAAG;AAEvC,gGAAgG;AAChG,MAAM,OAAO,kBAAmB,SAAQ,MAAM,CAAC,WAAW,EAAsB,CAC9E,oBAAoB,EACpB,EAAE,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,CAClE,CAAC,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC;CAAG;AAEvC,0MAA0M;AAC1M,MAAM,OAAO,oBAAqB,SAAQ,MAAM,CAAC,WAAW,EAAwB,CAClF,sBAAsB,EACtB,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,CAChD,CAAC,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC;CAAG;AAEnC,kCAAkC;AAClC,MAAM,OAAO,kBAAmB,SAAQ,MAAM,CAAC,WAAW,EAAsB,CAC9E,oBAAoB,EACpB,EAAE,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,CAChD,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC;CAAG"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @distilled.cloud/opnsense — OPNsense firewall API SDK for Effect.
3
+ *
4
+ * `./services` is generated by `scripts/generate.ts` from the Smithy models
5
+ * in `.generated-specs` (written by `scripts/convert.ts` from OPNsense's own
6
+ * model XML + API controller PHP, mirrored under `specs/`). Everything else
7
+ * in this folder is hand-written.
8
+ *
9
+ * One module per API controller in scope — `firewall_alias`,
10
+ * `firewall_category`, `firewall_group`, `firewall_filter`,
11
+ * `routing_settings`, `quagga_general`, `quagga_bgp`, `quagga_service` — see
12
+ * the package README for what each one covers and what was left out.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * import * as Opnsense from "@distilled.cloud/opnsense";
17
+ *
18
+ * const alias = yield* Opnsense.Services.firewall_alias.addAlias({
19
+ * alias: { name: "homeflare_edge", type: "host", content: "10.20.10.1" },
20
+ * });
21
+ * ```
22
+ */
23
+ export * from "./credentials.ts";
24
+ export * from "./errors.ts";
25
+ export * as T from "./traits.ts";
26
+ export { OpnsenseProtocol, type OpnsenseOpError, type OpnsenseOpContext, } from "./protocol.ts";
27
+ export * as Retry from "./retry.ts";
28
+ export * as Services from "./services/index.ts";
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EACL,gBAAgB,EAChB,KAAK,eAAe,EACpB,KAAK,iBAAiB,GACvB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC"}