@generacy-ai/credhelper-daemon 0.0.0-preview-20260507200146
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 +191 -0
- package/README.md +35 -0
- package/dist/bin/credhelper-daemon.d.ts +3 -0
- package/dist/bin/credhelper-daemon.d.ts.map +1 -0
- package/dist/bin/credhelper-daemon.js +94 -0
- package/dist/bin/credhelper-daemon.js.map +1 -0
- package/dist/src/audit/audit-log.d.ts +39 -0
- package/dist/src/audit/audit-log.d.ts.map +1 -0
- package/dist/src/audit/audit-log.js +113 -0
- package/dist/src/audit/audit-log.js.map +1 -0
- package/dist/src/audit/index.d.ts +8 -0
- package/dist/src/audit/index.d.ts.map +1 -0
- package/dist/src/audit/index.js +6 -0
- package/dist/src/audit/index.js.map +1 -0
- package/dist/src/audit/ring-buffer.d.ts +28 -0
- package/dist/src/audit/ring-buffer.d.ts.map +1 -0
- package/dist/src/audit/ring-buffer.js +57 -0
- package/dist/src/audit/ring-buffer.js.map +1 -0
- package/dist/src/audit/sampler.d.ts +15 -0
- package/dist/src/audit/sampler.d.ts.map +1 -0
- package/dist/src/audit/sampler.js +28 -0
- package/dist/src/audit/sampler.js.map +1 -0
- package/dist/src/audit/transport.d.ts +7 -0
- package/dist/src/audit/transport.d.ts.map +1 -0
- package/dist/src/audit/transport.js +29 -0
- package/dist/src/audit/transport.js.map +1 -0
- package/dist/src/audit/types.d.ts +213 -0
- package/dist/src/audit/types.d.ts.map +1 -0
- package/dist/src/audit/types.js +48 -0
- package/dist/src/audit/types.js.map +1 -0
- package/dist/src/backends/cluster-local-backend.d.ts +16 -0
- package/dist/src/backends/cluster-local-backend.d.ts.map +1 -0
- package/dist/src/backends/cluster-local-backend.js +39 -0
- package/dist/src/backends/cluster-local-backend.js.map +1 -0
- package/dist/src/backends/crypto.d.ts +23 -0
- package/dist/src/backends/crypto.d.ts.map +1 -0
- package/dist/src/backends/crypto.js +37 -0
- package/dist/src/backends/crypto.js.map +1 -0
- package/dist/src/backends/env-backend.d.ts +5 -0
- package/dist/src/backends/env-backend.d.ts.map +1 -0
- package/dist/src/backends/env-backend.js +11 -0
- package/dist/src/backends/env-backend.js.map +1 -0
- package/dist/src/backends/factory.d.ts +6 -0
- package/dist/src/backends/factory.d.ts.map +1 -0
- package/dist/src/backends/factory.js +16 -0
- package/dist/src/backends/factory.js.map +1 -0
- package/dist/src/backends/file-store.d.ts +47 -0
- package/dist/src/backends/file-store.d.ts.map +1 -0
- package/dist/src/backends/file-store.js +102 -0
- package/dist/src/backends/file-store.js.map +1 -0
- package/dist/src/backends/index.d.ts +5 -0
- package/dist/src/backends/index.d.ts.map +1 -0
- package/dist/src/backends/index.js +3 -0
- package/dist/src/backends/index.js.map +1 -0
- package/dist/src/backends/types.d.ts +6 -0
- package/dist/src/backends/types.d.ts.map +1 -0
- package/dist/src/backends/types.js +2 -0
- package/dist/src/backends/types.js.map +1 -0
- package/dist/src/config.d.ts +9 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +11 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/control-server.d.ts +19 -0
- package/dist/src/control-server.d.ts.map +1 -0
- package/dist/src/control-server.js +101 -0
- package/dist/src/control-server.js.map +1 -0
- package/dist/src/credential-store.d.ts +15 -0
- package/dist/src/credential-store.d.ts.map +1 -0
- package/dist/src/credential-store.js +34 -0
- package/dist/src/credential-store.js.map +1 -0
- package/dist/src/daemon.d.ts +18 -0
- package/dist/src/daemon.d.ts.map +1 -0
- package/dist/src/daemon.js +103 -0
- package/dist/src/daemon.js.map +1 -0
- package/dist/src/data-server.d.ts +8 -0
- package/dist/src/data-server.d.ts.map +1 -0
- package/dist/src/data-server.js +33 -0
- package/dist/src/data-server.js.map +1 -0
- package/dist/src/docker-allowlist.d.ts +35 -0
- package/dist/src/docker-allowlist.d.ts.map +1 -0
- package/dist/src/docker-allowlist.js +109 -0
- package/dist/src/docker-allowlist.js.map +1 -0
- package/dist/src/docker-bind-mount-guard.d.ts +41 -0
- package/dist/src/docker-bind-mount-guard.d.ts.map +1 -0
- package/dist/src/docker-bind-mount-guard.js +76 -0
- package/dist/src/docker-bind-mount-guard.js.map +1 -0
- package/dist/src/docker-name-resolver.d.ts +18 -0
- package/dist/src/docker-name-resolver.d.ts.map +1 -0
- package/dist/src/docker-name-resolver.js +67 -0
- package/dist/src/docker-name-resolver.js.map +1 -0
- package/dist/src/docker-proxy-handler.d.ts +20 -0
- package/dist/src/docker-proxy-handler.d.ts.map +1 -0
- package/dist/src/docker-proxy-handler.js +201 -0
- package/dist/src/docker-proxy-handler.js.map +1 -0
- package/dist/src/docker-proxy.d.ts +20 -0
- package/dist/src/docker-proxy.d.ts.map +1 -0
- package/dist/src/docker-proxy.js +64 -0
- package/dist/src/docker-proxy.js.map +1 -0
- package/dist/src/docker-upstream.d.ts +12 -0
- package/dist/src/docker-upstream.d.ts.map +1 -0
- package/dist/src/docker-upstream.js +30 -0
- package/dist/src/docker-upstream.js.map +1 -0
- package/dist/src/errors.d.ts +16 -0
- package/dist/src/errors.d.ts.map +1 -0
- package/dist/src/errors.js +61 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/exposure/localhost-proxy.d.ts +33 -0
- package/dist/src/exposure/localhost-proxy.d.ts.map +1 -0
- package/dist/src/exposure/localhost-proxy.js +129 -0
- package/dist/src/exposure/localhost-proxy.js.map +1 -0
- package/dist/src/exposure-renderer.d.ts +59 -0
- package/dist/src/exposure-renderer.d.ts.map +1 -0
- package/dist/src/exposure-renderer.js +128 -0
- package/dist/src/exposure-renderer.js.map +1 -0
- package/dist/src/index.d.ts +11 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +7 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/peer-cred.d.ts +14 -0
- package/dist/src/peer-cred.d.ts.map +1 -0
- package/dist/src/peer-cred.js +35 -0
- package/dist/src/peer-cred.js.map +1 -0
- package/dist/src/plugins/core/api-key.d.ts +3 -0
- package/dist/src/plugins/core/api-key.d.ts.map +1 -0
- package/dist/src/plugins/core/api-key.js +42 -0
- package/dist/src/plugins/core/api-key.js.map +1 -0
- package/dist/src/plugins/core/aws-sts.d.ts +3 -0
- package/dist/src/plugins/core/aws-sts.d.ts.map +1 -0
- package/dist/src/plugins/core/aws-sts.js +143 -0
- package/dist/src/plugins/core/aws-sts.js.map +1 -0
- package/dist/src/plugins/core/env-passthrough.d.ts +3 -0
- package/dist/src/plugins/core/env-passthrough.d.ts.map +1 -0
- package/dist/src/plugins/core/env-passthrough.js +21 -0
- package/dist/src/plugins/core/env-passthrough.js.map +1 -0
- package/dist/src/plugins/core/gcp-service-account.d.ts +3 -0
- package/dist/src/plugins/core/gcp-service-account.d.ts.map +1 -0
- package/dist/src/plugins/core/gcp-service-account.js +54 -0
- package/dist/src/plugins/core/gcp-service-account.js.map +1 -0
- package/dist/src/plugins/core/github-app.d.ts +3 -0
- package/dist/src/plugins/core/github-app.d.ts.map +1 -0
- package/dist/src/plugins/core/github-app.js +86 -0
- package/dist/src/plugins/core/github-app.js.map +1 -0
- package/dist/src/plugins/core/github-pat.d.ts +3 -0
- package/dist/src/plugins/core/github-pat.d.ts.map +1 -0
- package/dist/src/plugins/core/github-pat.js +31 -0
- package/dist/src/plugins/core/github-pat.js.map +1 -0
- package/dist/src/plugins/core/index.d.ts +7 -0
- package/dist/src/plugins/core/index.d.ts.map +1 -0
- package/dist/src/plugins/core/index.js +21 -0
- package/dist/src/plugins/core/index.js.map +1 -0
- package/dist/src/plugins/core/stripe-restricted-key.d.ts +3 -0
- package/dist/src/plugins/core/stripe-restricted-key.d.ts.map +1 -0
- package/dist/src/plugins/core/stripe-restricted-key.js +21 -0
- package/dist/src/plugins/core/stripe-restricted-key.js.map +1 -0
- package/dist/src/scratch-directory.d.ts +11 -0
- package/dist/src/scratch-directory.d.ts.map +1 -0
- package/dist/src/scratch-directory.js +35 -0
- package/dist/src/scratch-directory.js.map +1 -0
- package/dist/src/session-manager.d.ts +37 -0
- package/dist/src/session-manager.d.ts.map +1 -0
- package/dist/src/session-manager.js +366 -0
- package/dist/src/session-manager.js.map +1 -0
- package/dist/src/token-refresher.d.ts +26 -0
- package/dist/src/token-refresher.d.ts.map +1 -0
- package/dist/src/token-refresher.js +78 -0
- package/dist/src/token-refresher.js.map +1 -0
- package/dist/src/types.d.ts +125 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/util/fs.d.ts +9 -0
- package/dist/src/util/fs.d.ts.map +1 -0
- package/dist/src/util/fs.js +32 -0
- package/dist/src/util/fs.js.map +1 -0
- package/dist/src/util/parse-ttl.d.ts +12 -0
- package/dist/src/util/parse-ttl.d.ts.map +1 -0
- package/dist/src/util/parse-ttl.js +36 -0
- package/dist/src/util/parse-ttl.js.map +1 -0
- package/package.json +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding any notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
Copyright 2026 The Generacy AI Authors
|
|
180
|
+
|
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
+
you may not use this file except in compliance with the License.
|
|
183
|
+
You may obtain a copy of the License at
|
|
184
|
+
|
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
+
|
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
+
See the License for the specific language governing permissions and
|
|
191
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# @generacy-ai/credhelper-daemon
|
|
2
|
+
|
|
3
|
+
Runtime daemon for credential session management. HTTP-over-Unix-socket API for beginning and ending credential sessions.
|
|
4
|
+
|
|
5
|
+
## Backends
|
|
6
|
+
|
|
7
|
+
### `env` — Environment Variable Backend
|
|
8
|
+
|
|
9
|
+
Reads secrets directly from `process.env`. Useful for development and CI.
|
|
10
|
+
|
|
11
|
+
### `cluster-local` — Encrypted File Backend
|
|
12
|
+
|
|
13
|
+
Stores credentials in an AES-256-GCM encrypted file at `/var/lib/generacy/credentials.dat`. This is the default backend for v1.5 clusters.
|
|
14
|
+
|
|
15
|
+
- **Master key**: Auto-generated 32-byte key at `/var/lib/generacy/master.key` (mode 0600, uid 1002)
|
|
16
|
+
- **Encryption**: AES-256-GCM with per-credential random 12-byte IV and 16-byte auth tag
|
|
17
|
+
- **Persistence**: JSON envelope with version field; atomic writes via temp-file + fsync + rename
|
|
18
|
+
- **Concurrency**: fd-based advisory locking (no external dependencies)
|
|
19
|
+
- **Interface**: Implements `WritableBackendClient` (extends `BackendClient` with `setSecret`/`deleteSecret`)
|
|
20
|
+
|
|
21
|
+
#### Security Notes
|
|
22
|
+
|
|
23
|
+
- The master key file must be on a persistent volume. If the master key is lost, stored credentials are unrecoverable — delete both files and re-enter credentials via the bootstrap UI.
|
|
24
|
+
- Key rotation is not supported in v1.5. The recovery model is destroy-and-reenter.
|
|
25
|
+
- Master key file permissions (0600) are set on creation. Verify with `ls -la /var/lib/generacy/master.key`.
|
|
26
|
+
- No plaintext secrets appear in logs. Error messages reference credential key names only.
|
|
27
|
+
- The credential store fails closed on corrupt data — it will refuse to start rather than operate on bad data.
|
|
28
|
+
|
|
29
|
+
## Development
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pnpm install
|
|
33
|
+
pnpm test # Run tests
|
|
34
|
+
pnpm build # Build TypeScript
|
|
35
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credhelper-daemon.d.ts","sourceRoot":"","sources":["../../bin/credhelper-daemon.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { loadConfig, ConfigValidationError } from '@generacy-ai/credhelper';
|
|
4
|
+
import { Daemon } from '../src/daemon.js';
|
|
5
|
+
import { CredhelperError } from '../src/errors.js';
|
|
6
|
+
import { CORE_PLUGINS } from '../src/plugins/core/index.js';
|
|
7
|
+
import { DefaultBackendClientFactory } from '../src/backends/factory.js';
|
|
8
|
+
const controlSocketPath = process.env['CREDHELPER_CONTROL_SOCKET'] ??
|
|
9
|
+
'/run/generacy-credhelper/control.sock';
|
|
10
|
+
const sessionsDir = process.env['CREDHELPER_SESSIONS_DIR'] ??
|
|
11
|
+
'/run/generacy-credhelper/sessions';
|
|
12
|
+
const workerUid = parseInt(process.env['CREDHELPER_WORKER_UID'] ?? '1000', 10);
|
|
13
|
+
const workerGid = parseInt(process.env['CREDHELPER_WORKER_GID'] ?? '1000', 10);
|
|
14
|
+
// Build plugin registry from core plugins + future community plugins (#460)
|
|
15
|
+
const pluginMap = new Map();
|
|
16
|
+
for (const plugin of CORE_PLUGINS) {
|
|
17
|
+
pluginMap.set(plugin.type, plugin);
|
|
18
|
+
}
|
|
19
|
+
// Load config from .agency/ directory (Phase 6, #477)
|
|
20
|
+
const agencyDir = process.env['CREDHELPER_AGENCY_DIR'] ??
|
|
21
|
+
resolve(process.cwd(), '.agency');
|
|
22
|
+
let appConfig;
|
|
23
|
+
try {
|
|
24
|
+
appConfig = loadConfig({ agencyDir });
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
if (err instanceof ConfigValidationError) {
|
|
28
|
+
console.error('[credhelper] Config validation failed:');
|
|
29
|
+
for (const e of err.errors) {
|
|
30
|
+
console.error(` - ${e.file}${e.field ? `: field '${e.field}'` : ''} — ${e.message}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
console.error('[credhelper] Failed to load config:', err);
|
|
35
|
+
}
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
const config = {
|
|
39
|
+
controlSocketPath,
|
|
40
|
+
sessionsDir,
|
|
41
|
+
workerUid,
|
|
42
|
+
workerGid,
|
|
43
|
+
daemonUid: 1002,
|
|
44
|
+
backendFactory: new DefaultBackendClientFactory(),
|
|
45
|
+
configLoader: {
|
|
46
|
+
async loadRole(roleId) {
|
|
47
|
+
const role = appConfig.roles.get(roleId);
|
|
48
|
+
if (!role)
|
|
49
|
+
throw new CredhelperError('ROLE_NOT_FOUND', `Role not found: ${roleId}`);
|
|
50
|
+
return role;
|
|
51
|
+
},
|
|
52
|
+
async loadCredential(credentialId) {
|
|
53
|
+
const cred = appConfig.credentials.credentials.find(c => c.id === credentialId);
|
|
54
|
+
if (!cred)
|
|
55
|
+
throw new CredhelperError('CREDENTIAL_NOT_FOUND', `Credential not found: ${credentialId}`);
|
|
56
|
+
return cred;
|
|
57
|
+
},
|
|
58
|
+
async loadBackend(backendId) {
|
|
59
|
+
const backend = appConfig.backends.backends.find(b => b.id === backendId);
|
|
60
|
+
if (!backend)
|
|
61
|
+
throw new CredhelperError('BACKEND_UNREACHABLE', `Backend not found: ${backendId}`);
|
|
62
|
+
return backend;
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
pluginRegistry: {
|
|
66
|
+
getPlugin(credentialType) {
|
|
67
|
+
const plugin = pluginMap.get(credentialType);
|
|
68
|
+
if (!plugin) {
|
|
69
|
+
throw new Error(`No plugin registered for credential type: ${credentialType}`);
|
|
70
|
+
}
|
|
71
|
+
return plugin;
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
sweepIntervalMs: 30000,
|
|
75
|
+
enablePeerCred: true,
|
|
76
|
+
clusterId: process.env['GENERACY_CLUSTER_ID'],
|
|
77
|
+
workerId: process.env['GENERACY_WORKER_ID'] ?? process.env['HOSTNAME'],
|
|
78
|
+
};
|
|
79
|
+
const daemon = new Daemon(config);
|
|
80
|
+
daemon.installSignalHandlers();
|
|
81
|
+
// Handle uncaught exceptions — fail closed
|
|
82
|
+
process.on('uncaughtException', (err) => {
|
|
83
|
+
console.error('[credhelper] Uncaught exception:', err);
|
|
84
|
+
process.exit(1);
|
|
85
|
+
});
|
|
86
|
+
process.on('unhandledRejection', (reason) => {
|
|
87
|
+
console.error('[credhelper] Unhandled rejection:', reason);
|
|
88
|
+
process.exit(1);
|
|
89
|
+
});
|
|
90
|
+
daemon.start().catch((err) => {
|
|
91
|
+
console.error('[credhelper] Fatal startup error:', err);
|
|
92
|
+
process.exit(1);
|
|
93
|
+
});
|
|
94
|
+
//# sourceMappingURL=credhelper-daemon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credhelper-daemon.js","sourceRoot":"","sources":["../../bin/credhelper-daemon.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAA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H,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IAC3B,OAAO,CAAC,KAAK,CAAC,mCAAmC,EAAE,GAAG,CAAC,CAAC;IACxD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { AuditAction, AuditConfig } from './types.js';
|
|
2
|
+
/** Input to the `record()` API — caller provides action-specific fields. */
|
|
3
|
+
export interface AuditRecordInput {
|
|
4
|
+
action: AuditAction;
|
|
5
|
+
sessionId?: string;
|
|
6
|
+
credentialId?: string;
|
|
7
|
+
role?: string;
|
|
8
|
+
pluginId?: string;
|
|
9
|
+
success: boolean;
|
|
10
|
+
errorCode?: string;
|
|
11
|
+
exposureKind?: string;
|
|
12
|
+
proxy?: {
|
|
13
|
+
method: string;
|
|
14
|
+
path: string;
|
|
15
|
+
decision: 'allow' | 'deny';
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Structured audit log with bounded ring buffer, timer-based flush,
|
|
20
|
+
* and HTTP transport to the control-plane.
|
|
21
|
+
*/
|
|
22
|
+
export declare class AuditLog {
|
|
23
|
+
private readonly buffer;
|
|
24
|
+
private readonly config;
|
|
25
|
+
private flushTimer;
|
|
26
|
+
private pendingFlush;
|
|
27
|
+
constructor(config: AuditConfig);
|
|
28
|
+
/** Start the periodic flush timer. */
|
|
29
|
+
start(): void;
|
|
30
|
+
/** Stop the flush timer and perform a final flush. */
|
|
31
|
+
stop(): Promise<void>;
|
|
32
|
+
/** Record an audit entry. Triggers early flush if batch threshold is reached. */
|
|
33
|
+
record(input: AuditRecordInput): void;
|
|
34
|
+
/** Flush buffered entries to the control-plane. */
|
|
35
|
+
flush(): Promise<void>;
|
|
36
|
+
/** Current buffer size (for testing). */
|
|
37
|
+
get size(): number;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=audit-log.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-log.d.ts","sourceRoot":"","sources":["../../../src/audit/audit-log.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAc,WAAW,EAAE,MAAM,YAAY,CAAC;AAQvE,4EAA4E;AAC5E,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,WAAW,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,CAAA;KAAE,CAAC;CACtE;AAED;;;GAGG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyB;IAChD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;IACrC,OAAO,CAAC,UAAU,CAA+C;IACjE,OAAO,CAAC,YAAY,CAA8B;gBAEtC,MAAM,EAAE,WAAW;IAK/B,sCAAsC;IACtC,KAAK,IAAI,IAAI;IASb,sDAAsD;IAChD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ3B,iFAAiF;IACjF,MAAM,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI;IA8BrC,mDAAmD;IAC7C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA8B5B,yCAAyC;IACzC,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { RingBuffer } from './ring-buffer.js';
|
|
2
|
+
import { flushBatch } from './transport.js';
|
|
3
|
+
const DEV_MODE = process.env['NODE_ENV'] !== 'production' ||
|
|
4
|
+
process.env['CREDHELPER_AUDIT_ASSERT'] === '1';
|
|
5
|
+
const MAX_FIELD_LENGTH = 256;
|
|
6
|
+
/**
|
|
7
|
+
* Structured audit log with bounded ring buffer, timer-based flush,
|
|
8
|
+
* and HTTP transport to the control-plane.
|
|
9
|
+
*/
|
|
10
|
+
export class AuditLog {
|
|
11
|
+
buffer;
|
|
12
|
+
config;
|
|
13
|
+
flushTimer = null;
|
|
14
|
+
pendingFlush = null;
|
|
15
|
+
constructor(config) {
|
|
16
|
+
this.config = config;
|
|
17
|
+
this.buffer = new RingBuffer(config.capacity);
|
|
18
|
+
}
|
|
19
|
+
/** Start the periodic flush timer. */
|
|
20
|
+
start() {
|
|
21
|
+
if (this.flushTimer)
|
|
22
|
+
return;
|
|
23
|
+
this.flushTimer = setInterval(() => {
|
|
24
|
+
void this.flush();
|
|
25
|
+
}, this.config.flushIntervalMs);
|
|
26
|
+
// Allow process to exit even if timer is active
|
|
27
|
+
if (this.flushTimer.unref)
|
|
28
|
+
this.flushTimer.unref();
|
|
29
|
+
}
|
|
30
|
+
/** Stop the flush timer and perform a final flush. */
|
|
31
|
+
async stop() {
|
|
32
|
+
if (this.flushTimer) {
|
|
33
|
+
clearInterval(this.flushTimer);
|
|
34
|
+
this.flushTimer = null;
|
|
35
|
+
}
|
|
36
|
+
await this.flush();
|
|
37
|
+
}
|
|
38
|
+
/** Record an audit entry. Triggers early flush if batch threshold is reached. */
|
|
39
|
+
record(input) {
|
|
40
|
+
const entry = {
|
|
41
|
+
timestamp: new Date().toISOString(),
|
|
42
|
+
action: input.action,
|
|
43
|
+
actor: {
|
|
44
|
+
workerId: this.config.workerId,
|
|
45
|
+
...(input.sessionId !== undefined ? { sessionId: input.sessionId } : {}),
|
|
46
|
+
},
|
|
47
|
+
clusterId: this.config.clusterId,
|
|
48
|
+
success: input.success,
|
|
49
|
+
...(input.credentialId !== undefined ? { credentialId: input.credentialId } : {}),
|
|
50
|
+
...(input.role !== undefined ? { role: input.role } : {}),
|
|
51
|
+
...(input.pluginId !== undefined ? { pluginId: input.pluginId } : {}),
|
|
52
|
+
...(input.errorCode !== undefined ? { errorCode: input.errorCode } : {}),
|
|
53
|
+
...(input.exposureKind !== undefined ? { exposureKind: input.exposureKind } : {}),
|
|
54
|
+
...(input.proxy !== undefined ? { proxy: input.proxy } : {}),
|
|
55
|
+
};
|
|
56
|
+
if (DEV_MODE) {
|
|
57
|
+
assertFieldLengths(entry);
|
|
58
|
+
}
|
|
59
|
+
this.buffer.push(entry);
|
|
60
|
+
// Early flush if batch threshold reached
|
|
61
|
+
if (this.buffer.size >= this.config.maxBatchSize) {
|
|
62
|
+
void this.flush();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** Flush buffered entries to the control-plane. */
|
|
66
|
+
async flush() {
|
|
67
|
+
// Prevent concurrent flushes
|
|
68
|
+
if (this.pendingFlush) {
|
|
69
|
+
try {
|
|
70
|
+
await this.pendingFlush;
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
// Already handled by the original caller
|
|
74
|
+
}
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (this.buffer.size === 0)
|
|
78
|
+
return;
|
|
79
|
+
const { entries, dropped } = this.buffer.drain(this.config.maxBatchSize);
|
|
80
|
+
if (entries.length === 0)
|
|
81
|
+
return;
|
|
82
|
+
this.pendingFlush = flushBatch({ entries, droppedSinceLastBatch: dropped }, this.config.controlPlaneSocketPath);
|
|
83
|
+
try {
|
|
84
|
+
await this.pendingFlush;
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
// Transport failure — entries already drained; bounded by ring buffer capacity
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
this.pendingFlush = null;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/** Current buffer size (for testing). */
|
|
94
|
+
get size() {
|
|
95
|
+
return this.buffer.size;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/** Dev-mode assertion: no string field in an audit entry exceeds 256 chars. */
|
|
99
|
+
function assertFieldLengths(entry) {
|
|
100
|
+
const check = (obj, prefix) => {
|
|
101
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
102
|
+
if (typeof value === 'string' && value.length > MAX_FIELD_LENGTH) {
|
|
103
|
+
throw new Error(`Audit field '${prefix}${key}' exceeds ${MAX_FIELD_LENGTH} chars (${value.length}). ` +
|
|
104
|
+
'This may indicate accidental secret leakage.');
|
|
105
|
+
}
|
|
106
|
+
if (typeof value === 'object' && value !== null) {
|
|
107
|
+
check(value, `${prefix}${key}.`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
check(entry, '');
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=audit-log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-log.js","sourceRoot":"","sources":["../../../src/audit/audit-log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAG5C,MAAM,QAAQ,GACZ,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,YAAY;IACxC,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,KAAK,GAAG,CAAC;AAEjD,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAe7B;;;GAGG;AACH,MAAM,OAAO,QAAQ;IACF,MAAM,CAAyB;IAC/B,MAAM,CAAc;IAC7B,UAAU,GAA0C,IAAI,CAAC;IACzD,YAAY,GAAyB,IAAI,CAAC;IAElD,YAAY,MAAmB;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,IAAI,UAAU,CAAa,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC5D,CAAC;IAED,sCAAsC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C,CAAC;IACF,KAAK,CAAC,KAA2C,EAAE,EAAE,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { AuditLog } from './audit-log.js';
|
|
2
|
+
export type { AuditRecordInput } from './audit-log.js';
|
|
3
|
+
export { RingBuffer } from './ring-buffer.js';
|
|
4
|
+
export { AuditSampler } from './sampler.js';
|
|
5
|
+
export { flushBatch } from './transport.js';
|
|
6
|
+
export { AuditActionSchema, AuditEntrySchema, AuditBatchSchema, } from './types.js';
|
|
7
|
+
export type { AuditAction, AuditEntry, AuditBatch, AuditConfig, } from './types.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/audit/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,WAAW,EACX,UAAU,EACV,UAAU,EACV,WAAW,GACZ,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { AuditLog } from './audit-log.js';
|
|
2
|
+
export { RingBuffer } from './ring-buffer.js';
|
|
3
|
+
export { AuditSampler } from './sampler.js';
|
|
4
|
+
export { flushBatch } from './transport.js';
|
|
5
|
+
export { AuditActionSchema, AuditEntrySchema, AuditBatchSchema, } from './types.js';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/audit/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic bounded ring buffer with O(1) push and bulk drain.
|
|
3
|
+
* When capacity is exceeded, the oldest entries are silently dropped.
|
|
4
|
+
*/
|
|
5
|
+
export declare class RingBuffer<T> {
|
|
6
|
+
private readonly capacity;
|
|
7
|
+
private readonly buffer;
|
|
8
|
+
private head;
|
|
9
|
+
private tail;
|
|
10
|
+
private count;
|
|
11
|
+
private dropped;
|
|
12
|
+
constructor(capacity: number);
|
|
13
|
+
/** Push an entry. Drops the oldest if at capacity. */
|
|
14
|
+
push(entry: T): void;
|
|
15
|
+
/**
|
|
16
|
+
* Drain up to `max` entries (FIFO order).
|
|
17
|
+
* Resets the dropped counter after each drain.
|
|
18
|
+
*/
|
|
19
|
+
drain(max: number): {
|
|
20
|
+
entries: T[];
|
|
21
|
+
dropped: number;
|
|
22
|
+
};
|
|
23
|
+
/** Current number of entries in the buffer. */
|
|
24
|
+
get size(): number;
|
|
25
|
+
/** Number of entries dropped since last drain. */
|
|
26
|
+
get droppedCount(): number;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=ring-buffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ring-buffer.d.ts","sourceRoot":"","sources":["../../../src/audit/ring-buffer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,UAAU,CAAC,CAAC;IAOX,OAAO,CAAC,QAAQ,CAAC,QAAQ;IANrC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoB;IAC3C,OAAO,CAAC,IAAI,CAAK;IACjB,OAAO,CAAC,IAAI,CAAK;IACjB,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,OAAO,CAAK;gBAES,QAAQ,EAAE,MAAM;IAK7C,sDAAsD;IACtD,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI;IAYpB;;;OAGG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,OAAO,EAAE,CAAC,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;IAgBrD,+CAA+C;IAC/C,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,kDAAkD;IAClD,IAAI,YAAY,IAAI,MAAM,CAEzB;CACF"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic bounded ring buffer with O(1) push and bulk drain.
|
|
3
|
+
* When capacity is exceeded, the oldest entries are silently dropped.
|
|
4
|
+
*/
|
|
5
|
+
export class RingBuffer {
|
|
6
|
+
capacity;
|
|
7
|
+
buffer;
|
|
8
|
+
head = 0;
|
|
9
|
+
tail = 0;
|
|
10
|
+
count = 0;
|
|
11
|
+
dropped = 0;
|
|
12
|
+
constructor(capacity) {
|
|
13
|
+
this.capacity = capacity;
|
|
14
|
+
if (capacity < 1)
|
|
15
|
+
throw new RangeError('RingBuffer capacity must be >= 1');
|
|
16
|
+
this.buffer = new Array(capacity);
|
|
17
|
+
}
|
|
18
|
+
/** Push an entry. Drops the oldest if at capacity. */
|
|
19
|
+
push(entry) {
|
|
20
|
+
if (this.count === this.capacity) {
|
|
21
|
+
// Overwrite oldest — advance tail
|
|
22
|
+
this.tail = (this.tail + 1) % this.capacity;
|
|
23
|
+
this.dropped++;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
this.count++;
|
|
27
|
+
}
|
|
28
|
+
this.buffer[this.head] = entry;
|
|
29
|
+
this.head = (this.head + 1) % this.capacity;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Drain up to `max` entries (FIFO order).
|
|
33
|
+
* Resets the dropped counter after each drain.
|
|
34
|
+
*/
|
|
35
|
+
drain(max) {
|
|
36
|
+
const n = Math.min(max, this.count);
|
|
37
|
+
const entries = [];
|
|
38
|
+
for (let i = 0; i < n; i++) {
|
|
39
|
+
entries.push(this.buffer[this.tail]);
|
|
40
|
+
this.buffer[this.tail] = undefined;
|
|
41
|
+
this.tail = (this.tail + 1) % this.capacity;
|
|
42
|
+
}
|
|
43
|
+
this.count -= n;
|
|
44
|
+
const droppedCount = this.dropped;
|
|
45
|
+
this.dropped = 0;
|
|
46
|
+
return { entries, dropped: droppedCount };
|
|
47
|
+
}
|
|
48
|
+
/** Current number of entries in the buffer. */
|
|
49
|
+
get size() {
|
|
50
|
+
return this.count;
|
|
51
|
+
}
|
|
52
|
+
/** Number of entries dropped since last drain. */
|
|
53
|
+
get droppedCount() {
|
|
54
|
+
return this.dropped;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=ring-buffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ring-buffer.js","sourceRoot":"","sources":["../../../src/audit/ring-buffer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,OAAO,UAAU;IAOQ;IANZ,MAAM,CAAoB;IACnC,IAAI,GAAG,CAAC,CAAC;IACT,IAAI,GAAG,CAAC,CAAC;IACT,KAAK,GAAG,CAAC,CAAC;IACV,OAAO,GAAG,CAAC,CAAC;IAEpB,YAA6B,QAAgB;QAAhB,aAAQ,GAAR,QAAQ,CAAQ;QAC3C,IAAI,QAAQ,GAAG,CAAC;YAAE,MAAM,IAAI,UAAU,CAAC,kCAAkC,CAAC,CAAC;QAC3E,IAAI,CAAC,MAAM,GAAG,IAAI,KAAK,CAAgB,QAAQ,CAAC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OAAO,EAAE,YAAY,EAAE,CAAC;IAC5C,CAAC;IAED,+CAA+C;IAC/C,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,kDAAkD;IAClD,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic counter-based sampler for proxy audit hooks.
|
|
3
|
+
* Fires every Nth request (default 1/100). The `recordAllProxy`
|
|
4
|
+
* override sets the rate to 100% (fire on every request).
|
|
5
|
+
*/
|
|
6
|
+
export declare class AuditSampler {
|
|
7
|
+
private readonly rate;
|
|
8
|
+
private counter;
|
|
9
|
+
constructor(rate?: number);
|
|
10
|
+
/** Returns true if this request should be recorded. */
|
|
11
|
+
shouldRecord(recordAllProxy?: boolean): boolean;
|
|
12
|
+
/** Reset the internal counter (for testing). */
|
|
13
|
+
reset(): void;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=sampler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sampler.d.ts","sourceRoot":"","sources":["../../../src/audit/sampler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,YAAY;IAGX,OAAO,CAAC,QAAQ,CAAC,IAAI;IAFjC,OAAO,CAAC,OAAO,CAAK;gBAES,IAAI,GAAE,MAAY;IAE/C,uDAAuD;IACvD,YAAY,CAAC,cAAc,CAAC,EAAE,OAAO,GAAG,OAAO;IAU/C,gDAAgD;IAChD,KAAK,IAAI,IAAI;CAGd"}
|