auditreach-cli 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 +202 -0
- package/README.md +233 -0
- package/dist/audit-log/chain-verifier.d.ts +9 -0
- package/dist/audit-log/chain-verifier.d.ts.map +1 -0
- package/dist/audit-log/chain-verifier.js +79 -0
- package/dist/audit-log/chain-verifier.js.map +1 -0
- package/dist/audit-log/hash-chain-writer.d.ts +16 -0
- package/dist/audit-log/hash-chain-writer.d.ts.map +1 -0
- package/dist/audit-log/hash-chain-writer.js +49 -0
- package/dist/audit-log/hash-chain-writer.js.map +1 -0
- package/dist/auth/credential-store.d.ts +24 -0
- package/dist/auth/credential-store.d.ts.map +1 -0
- package/dist/auth/credential-store.js +50 -0
- package/dist/auth/credential-store.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +74 -0
- package/dist/cli.js.map +1 -0
- package/dist/clients/reddit-client.d.ts +33 -0
- package/dist/clients/reddit-client.d.ts.map +1 -0
- package/dist/clients/reddit-client.js +153 -0
- package/dist/clients/reddit-client.js.map +1 -0
- package/dist/clients/youtube-client.d.ts +16 -0
- package/dist/clients/youtube-client.d.ts.map +1 -0
- package/dist/clients/youtube-client.js +77 -0
- package/dist/clients/youtube-client.js.map +1 -0
- package/dist/commands/auth.d.ts +8 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +90 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/search.d.ts +14 -0
- package/dist/commands/search.d.ts.map +1 -0
- package/dist/commands/search.js +112 -0
- package/dist/commands/search.js.map +1 -0
- package/dist/commands/verify-log.d.ts +5 -0
- package/dist/commands/verify-log.d.ts.map +1 -0
- package/dist/commands/verify-log.js +19 -0
- package/dist/commands/verify-log.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +62 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/util/crypto.d.ts +16 -0
- package/dist/util/crypto.d.ts.map +1 -0
- package/dist/util/crypto.js +40 -0
- package/dist/util/crypto.js.map +1 -0
- package/dist/util/prompt.d.ts +11 -0
- package/dist/util/prompt.d.ts.map +1 -0
- package/dist/util/prompt.js +67 -0
- package/dist/util/prompt.js.map +1 -0
- package/package.json +62 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
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 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 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 those 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
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# auditreach
|
|
4
|
+
|
|
5
|
+
Research Reddit and YouTube from your AI agent using only official APIs, your own keys, and a log that proves exactly what you queried and why it was allowed.
|
|
6
|
+
|
|
7
|
+
[](https://github.com/RudrenduPaul/auditreach/actions/workflows/ci.yml)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
[](package.json)
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
<!-- TODO: record a real terminal demo (asciinema or a short GIF) and embed it here.
|
|
14
|
+
Capture script: run the two commands under "What it does" below against a real
|
|
15
|
+
Reddit search-app credential, in a clean terminal, ~15-20s total. Save as
|
|
16
|
+
docs/demo.gif and replace this comment with:
|
|
17
|
+
 -->
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
There's no published npm package yet -- clone and build directly, verified working end to end:
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
git clone https://github.com/RudrenduPaul/auditreach.git
|
|
25
|
+
cd auditreach
|
|
26
|
+
npm install
|
|
27
|
+
npm run build
|
|
28
|
+
node dist/cli.js search --platform reddit --query "your query"
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Table of contents
|
|
32
|
+
|
|
33
|
+
- [Why auditreach exists](#why-auditreach-exists)
|
|
34
|
+
- [How it compares](#how-it-compares)
|
|
35
|
+
- [What it does](#what-it-does)
|
|
36
|
+
- [Getting started](#getting-started)
|
|
37
|
+
- [Platform coverage](#platform-coverage)
|
|
38
|
+
- [Result limits](#result-limits)
|
|
39
|
+
- [What is a "consent basis," honestly](#what-is-a-consent-basis-honestly)
|
|
40
|
+
- [FAQ](#faq)
|
|
41
|
+
- [Self-hosting / local-only by default](#self-hosting--local-only-by-default)
|
|
42
|
+
- [Development](#development)
|
|
43
|
+
- [Security](#security)
|
|
44
|
+
- [Success stories](#success-stories)
|
|
45
|
+
- [Contributing](#contributing)
|
|
46
|
+
- [License](#license)
|
|
47
|
+
|
|
48
|
+
## Why auditreach exists
|
|
49
|
+
|
|
50
|
+
A consultancy we talked to had an AI research agent pulling social sentiment for a client report. It worked well until the client's legal team asked, in writing, what authority the data collection was under. The honest answer was "a browser cookie session," because the tool they were using authenticates by importing a logged-in session and scraping as if it were a real user. That works. It is also not an answer you can put in a compliance memo, and it is the exact pattern Reddit sued Anthropic and SerpApi over in 2025, and the same pattern that got Pushshift's public API access shut down by Reddit back in 2024.
|
|
51
|
+
|
|
52
|
+
[Agent-Reach](https://github.com/Panniantong/Agent-Reach) is not a bad tool. It has real traction (55k+ stars) because cookie-based scraping genuinely covers more ground than any official API does today, at zero API cost. But "covers more ground" and "an agency's client can pass a compliance review" are two different bars, and nothing was built specifically to clear the second one.
|
|
53
|
+
|
|
54
|
+
auditreach is the CLI we wished existed instead. It talks to Reddit and YouTube only through their official, documented APIs, using your own API keys -- never a shared pool -- and every single query writes a hash-chained entry to a local audit log: which platform, which endpoint, which scope, and a plain-language line explaining the consent/ToS basis for that specific call. No cookie import. No session-token reuse. No code path that could even pretend to be a logged-in human.
|
|
55
|
+
|
|
56
|
+
We are not trying to out-cover Agent-Reach's six platforms. auditreach is narrower on purpose, for the buyer who structurally can't use a cookie-based tool at all.
|
|
57
|
+
|
|
58
|
+
## How it compares
|
|
59
|
+
|
|
60
|
+
| | **auditreach** | **Agent-Reach** | **snoowrap** |
|
|
61
|
+
| ---------------------------- | ------------------------------ | ------------------------------------------------------- | --------------------------------------------------- |
|
|
62
|
+
| Access model | Official API only, BYO-key | Cookie/session import, "zero API fees" | Official API, BYO-key |
|
|
63
|
+
| Platform coverage (v0.1) | Reddit, YouTube | Twitter, Reddit, YouTube, GitHub, Bilibili, XiaoHongShu | Reddit only |
|
|
64
|
+
| Consent/audit log | Hash-chained, per-query, local | None | None |
|
|
65
|
+
| Maintenance status | Active (this release) | Active, 55k stars | **Archived** since Feb 2023 |
|
|
66
|
+
| License | Apache 2.0 | MIT | MIT |
|
|
67
|
+
| Runtime deps (Reddit client) | 0 -- native `fetch` | n/a (Python, browser-session based) | `request`, `request-promise`, `ws` (all deprecated) |
|
|
68
|
+
|
|
69
|
+
Numbers measured directly against each repo's public GitHub metadata and, for the dependency comparison, against `snoowrap`'s own published `package.json` as of this writing -- reproducible by anyone with `gh api repos/<owner>/<repo>`.
|
|
70
|
+
|
|
71
|
+
We started building auditreach's Reddit client on top of `snoowrap`, the most-used Reddit API wrapper in the Node ecosystem. Installing it pulled in `request`, `request-promise`, `form-data`, and `har-validator` -- a dependency chain with **4 CRITICAL** and multiple HIGH severity advisories, none of which snoowrap can fix because the project has been archived since 2023. We rewrote the Reddit client as a direct `fetch`-based OAuth2 client against Reddit's own documented REST endpoints instead: same functionality, zero of those CVEs, zero extra runtime dependencies. `npm audit --audit-level=high` on this repo returns clean.
|
|
72
|
+
|
|
73
|
+
## What it does
|
|
74
|
+
|
|
75
|
+
node dist/cli.js search --platform reddit --query "agent memory poisoning" --subreddit MachineLearning
|
|
76
|
+
|
|
77
|
+
AuditReach v0.1 -- Official-API Research CLI
|
|
78
|
+
Platform: Reddit | Auth: OAuth script-app grant, read-only, public-subreddit scope
|
|
79
|
+
|
|
80
|
+
Fetching... (official API, rate-limit aware)
|
|
81
|
+
✓ 14 results returned (Reddit API Terms -- public content, official API, read-only script-app credentials)
|
|
82
|
+
|
|
83
|
+
RESULTS (14)
|
|
84
|
+
[1] "How are people testing for memory poisoning in long-running agents?"
|
|
85
|
+
u/some_researcher · 2026-07-05T14:22:00.000Z
|
|
86
|
+
https://reddit.com/r/MachineLearning/comments/...
|
|
87
|
+
...
|
|
88
|
+
|
|
89
|
+
Audit log entry written: ar_2026-07-12_9f3c2a
|
|
90
|
+
Consent basis: Reddit API Terms -- public content, official API, read-only script-app credentials
|
|
91
|
+
Full results: ./auditreach-results-2026-07-12.json
|
|
92
|
+
Full audit trail: ./auditreach.log.jsonl
|
|
93
|
+
|
|
94
|
+
Every entry in `auditreach.log.jsonl` is hash-chained -- each entry's hash is computed from its own content, and the next entry references it. Editing, deleting, or reordering an entry breaks the chain:
|
|
95
|
+
|
|
96
|
+
$ node dist/cli.js verify-log
|
|
97
|
+
Verifying ./auditreach.log.jsonl...
|
|
98
|
+
✓ Chain intact: 14 entries, no gaps, no tampering detected.
|
|
99
|
+
|
|
100
|
+
# after someone hand-edits a line in the log file:
|
|
101
|
+
$ node dist/cli.js verify-log
|
|
102
|
+
Verifying ./auditreach.log.jsonl...
|
|
103
|
+
✗ Chain broken at entry 3 (ar_2026-07-12_9f3c2a): entry ar_2026-07-12_9f3c2a hash does not
|
|
104
|
+
match its own content -- entry was edited after being written
|
|
105
|
+
|
|
106
|
+
See `docs/security-review-2026-07-12.md` for how the tamper-detection path was verified.
|
|
107
|
+
|
|
108
|
+
## Getting started
|
|
109
|
+
|
|
110
|
+
**1. Install:** see [Install](#install) above -- clone and build, `npm install -g` isn't available yet.
|
|
111
|
+
|
|
112
|
+
**2. Set up credentials for the platform you want to search (BYO-key -- your own, never ours):**
|
|
113
|
+
|
|
114
|
+
node dist/cli.js auth --platform reddit
|
|
115
|
+
# Prompts for Client ID, Client secret, username, password.
|
|
116
|
+
# Create a script-app at https://www.reddit.com/prefs/apps first.
|
|
117
|
+
|
|
118
|
+
node dist/cli.js auth --platform youtube
|
|
119
|
+
# Prompts for an API key.
|
|
120
|
+
# Create one at https://console.cloud.google.com/apis/credentials
|
|
121
|
+
|
|
122
|
+
All credentials are stored in your OS keychain (`@napi-rs/keyring`), never in a config file, never transmitted anywhere except the platform's own official auth endpoint. Once credentials are set, verify them without running a real search:
|
|
123
|
+
|
|
124
|
+
node dist/cli.js auth --platform reddit --verify
|
|
125
|
+
|
|
126
|
+
**3. Search:**
|
|
127
|
+
|
|
128
|
+
node dist/cli.js search --platform reddit --query "your query" --subreddit some_subreddit
|
|
129
|
+
node dist/cli.js search --platform youtube --query "your query" --channel @SomeChannel
|
|
130
|
+
|
|
131
|
+
Honest note on setup time: getting your own API credentials from Reddit and Google takes a few minutes the first time -- this is slower than Agent-Reach's cookie-import flow (which just reuses a browser session you already have) by design. BYOK means the setup cost is real, not hidden.
|
|
132
|
+
|
|
133
|
+
## Platform coverage
|
|
134
|
+
|
|
135
|
+
| Platform | API used | Status | Known constraint |
|
|
136
|
+
| ----------- | ----------------------------------------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
137
|
+
| Reddit | Reddit API (OAuth2 password grant, direct REST) | Shipped | Rate limits are generally workable for real research volumes |
|
|
138
|
+
| YouTube | YouTube Data API v3 (`googleapis`) | Shipped | Quota-based (10,000 units/day default), generally workable |
|
|
139
|
+
| X (Twitter) | X API v2 | **Not yet shipped** | X's official API pricing and post-volume caps have been widely reported as prohibitive for small teams doing meaningful research since the 2023 pricing changes. Deferred until a real user needs it enough to fund working around that constraint -- shipping it half-working would undercut the entire "honest about what official APIs can and can't do" premise this tool is built on. |
|
|
140
|
+
|
|
141
|
+
## Result limits
|
|
142
|
+
|
|
143
|
+
`--max-results <n>` controls how many items a single `search` call returns. Leave it off and auditreach silently applies a default of 25 -- the same shape of surprise PRAW's `get_comments()` had for years ([praw#119](https://github.com/praw-dev/praw/issues/119)): a caller who does not already know to pass the flag gets a quietly truncated result set.
|
|
144
|
+
|
|
145
|
+
| Platform | Default (flag omitted) | Maximum (`--max-results`) |
|
|
146
|
+
| -------- | ---------------------- | ------------------------- |
|
|
147
|
+
| Reddit | 25 | 100 |
|
|
148
|
+
| YouTube | 25 | 50 |
|
|
149
|
+
|
|
150
|
+
Values above the cap are silently clamped to it. For Reddit, `--before`/`--after` let you page past a single call's results using the real cursor Reddit's own response returns (see [Success stories](#success-stories)); YouTube has no equivalent yet. Whenever the number of items returned equals the limit that was actually applied, whether that is the silent default or an explicit `--max-results` value, auditreach prints a warning to stderr telling you more results may exist and how to raise `--max-results` (up to the platform cap).
|
|
151
|
+
|
|
152
|
+
## What is a "consent basis," honestly
|
|
153
|
+
|
|
154
|
+
The `consent_basis` field on every audit-log entry names the specific platform API terms and auth mechanism used for that query. It certifies that the request went through the platform's official, documented API surface under the credentials you supplied. **It does not certify that your specific use case is legally sufficient for your jurisdiction or contract** -- that determination is yours to make, informed by an accurate, complete, tamper-evident record of what actually happened.
|
|
155
|
+
|
|
156
|
+
## FAQ
|
|
157
|
+
|
|
158
|
+
**Does auditreach store my Reddit or YouTube credentials anywhere?**
|
|
159
|
+
No. Credentials go straight into your OS keychain through `@napi-rs/keyring` (`src/auth/credential-store.ts`). There is no config file, no environment variable, and no code path that writes a raw credential to disk.
|
|
160
|
+
|
|
161
|
+
**How many results does a search return by default, and can I get more?**
|
|
162
|
+
25, silently, unless you pass `--max-results` -- see [Result limits](#result-limits). The hard cap is 100 for Reddit and 50 for YouTube. A stderr warning fires whenever a search actually hits the applied limit, whether that's the silent default or an explicit value you passed.
|
|
163
|
+
|
|
164
|
+
**Can I page past Reddit's result cap?**
|
|
165
|
+
Yes, for Reddit: `search()` reads the real `after`/`before` cursor out of Reddit's own response and exposes `--before`/`--after` flags to page in either direction. See the [praw#614 success story](#success-stories) for why this exists.
|
|
166
|
+
|
|
167
|
+
**Does auditreach support X (Twitter)?**
|
|
168
|
+
Not yet. X API v2's pricing and post-volume caps have been prohibitive for small teams doing real research since the 2023 changes. See [Platform coverage](#platform-coverage) for the full reasoning.
|
|
169
|
+
|
|
170
|
+
**How do I check my credentials are still valid without running a real search?**
|
|
171
|
+
`node dist/cli.js auth --platform reddit --verify` (or `--platform youtube`). It performs the minimal authenticated check and reports pass or fail, with no `--query` needed, no results file written, and no audit-log entry appended.
|
|
172
|
+
|
|
173
|
+
**Is the audit log actually tamper-evident, or just a log file?**
|
|
174
|
+
Tamper-evident: each entry's hash is computed from its own content and the next entry references it, so `verify-log` can point to the exact entry a hand-edit broke. See the demo under [What it does](#what-it-does).
|
|
175
|
+
|
|
176
|
+
## Self-hosting / local-only by default
|
|
177
|
+
|
|
178
|
+
Nothing about auditreach requires a hosted account or server. Every command runs entirely on your machine; the audit log is a plain file you own. This is the same flow as [Install](#install) above:
|
|
179
|
+
|
|
180
|
+
git clone https://github.com/RudrenduPaul/auditreach.git
|
|
181
|
+
cd auditreach
|
|
182
|
+
npm install
|
|
183
|
+
npm run build
|
|
184
|
+
node dist/cli.js search --platform reddit --query "..."
|
|
185
|
+
|
|
186
|
+
## Development
|
|
187
|
+
|
|
188
|
+
npm install
|
|
189
|
+
npm run lint # ESLint
|
|
190
|
+
npm run format # Prettier check
|
|
191
|
+
npm run typecheck # tsc --noEmit --strict
|
|
192
|
+
npm run test:coverage # vitest, 66 tests, 95.4% statement coverage
|
|
193
|
+
|
|
194
|
+
See `CONTRIBUTING.md` for the rules on adding a new platform client -- the short version: official API only, honest rate-limit disclosure, tests that mock the network boundary, never anything that reads or writes a raw credential outside `src/auth/credential-store.ts`.
|
|
195
|
+
|
|
196
|
+
## Security
|
|
197
|
+
|
|
198
|
+
See `SECURITY.md` for the vulnerability disclosure policy and `docs/security-review-2026-07-12.md` for the pre-launch OWASP/STRIDE review (zero CRITICAL/HIGH findings; one moderate, non-directly-reachable supply-chain advisory that has since been resolved -- `npm audit` on this repo currently returns zero vulnerabilities). GitHub secret scanning and push protection are enabled on this repo.
|
|
199
|
+
|
|
200
|
+
## Success stories
|
|
201
|
+
|
|
202
|
+
Four real issues reported against `praw-dev/praw` -- PRAW, Reddit's official Python API
|
|
203
|
+
wrapper, and the closest thing this project has to prior art -- root-caused against
|
|
204
|
+
auditreach's own source and used to close genuine gaps in this tool before it had a
|
|
205
|
+
single outside user. Each line below is tied to the actual report that prompted it.
|
|
206
|
+
|
|
207
|
+
- **[praw#614](https://github.com/praw-dev/praw/issues/614)** (@mananwason) -- asked how
|
|
208
|
+
to read the before/after pagination cursor off Reddit's search response to page past
|
|
209
|
+
its ~1,000-result cap; PRAW itself never solved this. `search()` now extracts the real
|
|
210
|
+
cursor from Reddit's response and returns it as `SearchOutcome.nextCursor`, plus
|
|
211
|
+
`--before`/`--after` flags to page in either direction.
|
|
212
|
+
- **[praw#1939](https://github.com/praw-dev/praw/issues/1939)** (@Auditormadness9) -- hit
|
|
213
|
+
an undiagnosed 400 error caused by a subreddit name that still carried a leading `r/`
|
|
214
|
+
prefix. Search errors now name that specific cause when it's the likely culprit:
|
|
215
|
+
previously the CLI just returned a bare status code and left the guessing to you.
|
|
216
|
+
- **[praw#984](https://github.com/praw-dev/praw/issues/984)** (@MaxMatti) -- asked for a
|
|
217
|
+
simple way to check whether Reddit bot credentials were still valid, without PRAW's
|
|
218
|
+
confusing `getMe()`-recursion workaround. `auditreach auth --platform reddit --verify`
|
|
219
|
+
does exactly that now: one lightweight check, no search required, nothing written to
|
|
220
|
+
disk.
|
|
221
|
+
- **[praw#119](https://github.com/praw-dev/praw/issues/119)** (@nsp) -- hit PRAW's
|
|
222
|
+
historic silent 25-result default, discoverable only by reading an unrelated base
|
|
223
|
+
class's docstring; PRAW's own maintainer admitted he "wasn't sure the best way to make
|
|
224
|
+
this clear." `--help` and this README now state the real default and per-platform
|
|
225
|
+
caps, and a runtime warning fires whenever a search actually got truncated.
|
|
226
|
+
|
|
227
|
+
## Contributing
|
|
228
|
+
|
|
229
|
+
See `CONTRIBUTING.md` for the rules on adding a new platform client. Short version: official API only, honest rate-limit disclosure, tests that mock the network boundary, never a code path that reads or writes a raw credential outside `src/auth/credential-store.ts`.
|
|
230
|
+
|
|
231
|
+
## License
|
|
232
|
+
|
|
233
|
+
Apache 2.0. See `LICENSE`.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ChainVerificationResult } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Re-derives every entry's hash from its own content and checks it against
|
|
4
|
+
* the stored hash, then checks each entry's prev_entry_hash against the
|
|
5
|
+
* previous entry's actual hash. Either check failing means the log was
|
|
6
|
+
* edited, reordered, or an entry was deleted after the fact.
|
|
7
|
+
*/
|
|
8
|
+
export declare function verifyAuditLogChain(logPath?: string): Promise<ChainVerificationResult>;
|
|
9
|
+
//# sourceMappingURL=chain-verifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain-verifier.d.ts","sourceRoot":"","sources":["../../src/audit-log/chain-verifier.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAiB,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAa1E;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,GAAE,MAA+B,GACvC,OAAO,CAAC,uBAAuB,CAAC,CA8DlC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { access, constants } from "node:fs";
|
|
3
|
+
import { promisify } from "node:util";
|
|
4
|
+
import { computeEntryHash } from "./hash-chain-writer.js";
|
|
5
|
+
import { DEFAULT_AUDIT_LOG_PATH } from "./hash-chain-writer.js";
|
|
6
|
+
const accessAsync = promisify(access);
|
|
7
|
+
async function fileExists(path) {
|
|
8
|
+
try {
|
|
9
|
+
await accessAsync(path, constants.F_OK);
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Re-derives every entry's hash from its own content and checks it against
|
|
18
|
+
* the stored hash, then checks each entry's prev_entry_hash against the
|
|
19
|
+
* previous entry's actual hash. Either check failing means the log was
|
|
20
|
+
* edited, reordered, or an entry was deleted after the fact.
|
|
21
|
+
*/
|
|
22
|
+
export async function verifyAuditLogChain(logPath = DEFAULT_AUDIT_LOG_PATH) {
|
|
23
|
+
if (!(await fileExists(logPath))) {
|
|
24
|
+
return {
|
|
25
|
+
valid: true,
|
|
26
|
+
totalEntries: 0,
|
|
27
|
+
brokenAtEntryId: null,
|
|
28
|
+
brokenAtIndex: null,
|
|
29
|
+
reason: "no log file yet -- nothing to verify",
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const content = await readFile(logPath, "utf8");
|
|
33
|
+
const lines = content.split("\n").filter((line) => line.trim().length > 0);
|
|
34
|
+
let expectedPrevHash = null;
|
|
35
|
+
for (let i = 0; i < lines.length; i++) {
|
|
36
|
+
let entry;
|
|
37
|
+
try {
|
|
38
|
+
entry = JSON.parse(lines[i]);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return {
|
|
42
|
+
valid: false,
|
|
43
|
+
totalEntries: lines.length,
|
|
44
|
+
brokenAtEntryId: null,
|
|
45
|
+
brokenAtIndex: i,
|
|
46
|
+
reason: `line ${i + 1} is not valid JSON`,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (entry.prev_entry_hash !== expectedPrevHash) {
|
|
50
|
+
return {
|
|
51
|
+
valid: false,
|
|
52
|
+
totalEntries: lines.length,
|
|
53
|
+
brokenAtEntryId: entry.entry_id,
|
|
54
|
+
brokenAtIndex: i,
|
|
55
|
+
reason: `entry ${entry.entry_id} references prev_entry_hash that does not match the actual prior entry -- chain broken or reordered`,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
const { entry_hash, ...rest } = entry;
|
|
59
|
+
const recomputed = computeEntryHash(rest);
|
|
60
|
+
if (recomputed !== entry_hash) {
|
|
61
|
+
return {
|
|
62
|
+
valid: false,
|
|
63
|
+
totalEntries: lines.length,
|
|
64
|
+
brokenAtEntryId: entry.entry_id,
|
|
65
|
+
brokenAtIndex: i,
|
|
66
|
+
reason: `entry ${entry.entry_id} hash does not match its own content -- entry was edited after being written`,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
expectedPrevHash = entry_hash;
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
valid: true,
|
|
73
|
+
totalEntries: lines.length,
|
|
74
|
+
brokenAtEntryId: null,
|
|
75
|
+
brokenAtIndex: null,
|
|
76
|
+
reason: null,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=chain-verifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain-verifier.js","sourceRoot":"","sources":["../../src/audit-log/chain-verifier.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AuditLogEntry, UnhashedAuditLogEntry } from "../types.js";
|
|
2
|
+
export declare const DEFAULT_AUDIT_LOG_PATH = "./auditreach.log.jsonl";
|
|
3
|
+
/**
|
|
4
|
+
* Reads the last line of the log file to find the previous entry's hash.
|
|
5
|
+
* Returns null if the log doesn't exist yet or is empty -- that's the
|
|
6
|
+
* legitimate state for the very first entry in a chain.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getLastEntryHash(logPath?: string): Promise<string | null>;
|
|
9
|
+
export declare function computeEntryHash(entry: UnhashedAuditLogEntry): string;
|
|
10
|
+
/**
|
|
11
|
+
* Appends one hash-chained entry to the local audit log. This is the only
|
|
12
|
+
* write path into the log -- entries are never edited or deleted in place,
|
|
13
|
+
* which is what makes `verify-log` a meaningful tamper check.
|
|
14
|
+
*/
|
|
15
|
+
export declare function appendAuditLogEntry(entryWithoutHash: UnhashedAuditLogEntry, logPath?: string): Promise<AuditLogEntry>;
|
|
16
|
+
//# sourceMappingURL=hash-chain-writer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash-chain-writer.d.ts","sourceRoot":"","sources":["../../src/audit-log/hash-chain-writer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAExE,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAW/D;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,GAAE,MAA+B,GACvC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAYxB;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,MAAM,CAIrE;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,gBAAgB,EAAE,qBAAqB,EACvC,OAAO,GAAE,MAA+B,GACvC,OAAO,CAAC,aAAa,CAAC,CAKxB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { appendFile, readFile } from "node:fs/promises";
|
|
2
|
+
import { constants } from "node:fs";
|
|
3
|
+
import { access } from "node:fs/promises";
|
|
4
|
+
import { canonicalJson, sha256Hex } from "../util/crypto.js";
|
|
5
|
+
export const DEFAULT_AUDIT_LOG_PATH = "./auditreach.log.jsonl";
|
|
6
|
+
async function fileExists(path) {
|
|
7
|
+
try {
|
|
8
|
+
await access(path, constants.F_OK);
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Reads the last line of the log file to find the previous entry's hash.
|
|
17
|
+
* Returns null if the log doesn't exist yet or is empty -- that's the
|
|
18
|
+
* legitimate state for the very first entry in a chain.
|
|
19
|
+
*/
|
|
20
|
+
export async function getLastEntryHash(logPath = DEFAULT_AUDIT_LOG_PATH) {
|
|
21
|
+
if (!(await fileExists(logPath))) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const content = await readFile(logPath, "utf8");
|
|
25
|
+
const lines = content.split("\n").filter((line) => line.trim().length > 0);
|
|
26
|
+
if (lines.length === 0) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
const lastLine = lines[lines.length - 1];
|
|
30
|
+
const lastEntry = JSON.parse(lastLine);
|
|
31
|
+
return lastEntry.entry_hash;
|
|
32
|
+
}
|
|
33
|
+
export function computeEntryHash(entry) {
|
|
34
|
+
// prev_entry_hash is already a field on `entry`, so canonicalJson alone
|
|
35
|
+
// links this entry to the previous one -- no need to fold it in twice.
|
|
36
|
+
return sha256Hex(canonicalJson(entry));
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Appends one hash-chained entry to the local audit log. This is the only
|
|
40
|
+
* write path into the log -- entries are never edited or deleted in place,
|
|
41
|
+
* which is what makes `verify-log` a meaningful tamper check.
|
|
42
|
+
*/
|
|
43
|
+
export async function appendAuditLogEntry(entryWithoutHash, logPath = DEFAULT_AUDIT_LOG_PATH) {
|
|
44
|
+
const entry_hash = computeEntryHash(entryWithoutHash);
|
|
45
|
+
const fullEntry = { ...entryWithoutHash, entry_hash };
|
|
46
|
+
await appendFile(logPath, JSON.stringify(fullEntry) + "\n", "utf8");
|
|
47
|
+
return fullEntry;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=hash-chain-writer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash-chain-writer.js","sourceRoot":"","sources":["../../src/audit-log/hash-chain-writer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG7D,MAAM,CAAC,MAAM,sBAAsB,GAAG,wBAAwB,CAAC;AAE/D,KAAK,UAAU,UAAU,CAAC,IAAY;IACpC,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,UAAkB,sBAAsB;IAExC,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAChD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC3E,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAW,CAAC;IACnD,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAkB,CAAC;IACxD,OAAO,SAAS,CAAC,UAAU,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAA4B;IAC3D,wEAAwE;IACxE,uEAAuE;IACvE,OAAO,SAAS,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;AACzC,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,gBAAuC,EACvC,UAAkB,sBAAsB;IAExC,MAAM,UAAU,GAAG,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IACtD,MAAM,SAAS,GAAkB,EAAE,GAAG,gBAAgB,EAAE,UAAU,EAAE,CAAC;IACrE,MAAM,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC;IACpE,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Platform } from "../types.js";
|
|
2
|
+
export type RedditCredentialKey = "clientId" | "clientSecret" | "username" | "password";
|
|
3
|
+
export type YoutubeCredentialKey = "apiKey";
|
|
4
|
+
export type CredentialKey = RedditCredentialKey | YoutubeCredentialKey;
|
|
5
|
+
/**
|
|
6
|
+
* All credential I/O goes through this module. It is the one place allowed
|
|
7
|
+
* to touch a raw secret -- callers get it back only to hand directly to an
|
|
8
|
+
* API client's auth constructor, never to log, print, or serialize it.
|
|
9
|
+
*/
|
|
10
|
+
export declare function setCredential(platform: Platform, key: CredentialKey, value: string): void;
|
|
11
|
+
export declare function getCredential(platform: Platform, key: CredentialKey): string | null;
|
|
12
|
+
export declare function deleteCredential(platform: Platform, key: CredentialKey): boolean;
|
|
13
|
+
export interface RedditCredentials {
|
|
14
|
+
clientId: string;
|
|
15
|
+
clientSecret: string;
|
|
16
|
+
username: string;
|
|
17
|
+
password: string;
|
|
18
|
+
}
|
|
19
|
+
export interface YoutubeCredentials {
|
|
20
|
+
apiKey: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function getRedditCredentials(): RedditCredentials | null;
|
|
23
|
+
export declare function getYoutubeCredentials(): YoutubeCredentials | null;
|
|
24
|
+
//# sourceMappingURL=credential-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-store.d.ts","sourceRoot":"","sources":["../../src/auth/credential-store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI5C,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG,cAAc,GAAG,UAAU,GAAG,UAAU,CAAC;AACxF,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CAAC;AAC5C,MAAM,MAAM,aAAa,GAAG,mBAAmB,GAAG,oBAAoB,CAAC;AAMvE;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAGzF;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,CAOnF;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,aAAa,GAAG,OAAO,CAOhF;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,oBAAoB,IAAI,iBAAiB,GAAG,IAAI,CAS/D;AAED,wBAAgB,qBAAqB,IAAI,kBAAkB,GAAG,IAAI,CAMjE"}
|