@unveil/vk 0.3.0 → 0.4.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/README.md CHANGED
@@ -4,6 +4,8 @@ Fetch GitHub account activity and analyze it for automation patterns
4
4
 
5
5
  This is the batteries-included wrapper around [`@unveil/identity`](https://github.com/unveil-project/identity). Give it a username and it does the GitHub API calls for you, then hands the result to the scoring engine.
6
6
 
7
+ It talks to the GitHub REST API with native `fetch` and has no dependencies beyond `@unveil/identity`, so it runs the same in Node, Deno, Bun, the browser and edge runtimes.
8
+
7
9
  Both packages are the logic behind [AgentScan](https://agentscan.netlify.app), a tool for analyzing GitHub account behavior to detect potential AI agents and automated activity. The results are indicators, not verdicts.
8
10
 
9
11
  ### Install
@@ -36,7 +38,7 @@ analyze(username, {
36
38
  });
37
39
  ```
38
40
 
39
- `token` is passed straight to Octokit. Without it you are on the unauthenticated
41
+ `token` is sent as `Authorization: Bearer`. Without it you are on the unauthenticated
40
42
  rate limit, which is 60 requests per hour for the whole IP — and each `analyze`
41
43
  call spends 4 of them. With a token you get 5000 per hour. The token needs no
42
44
  scopes; all the data read here is public.
@@ -72,8 +74,9 @@ analysis reports lower `confidence` to match.
72
74
  ### Errors
73
75
 
74
76
  `analyze` rejects instead of returning a partial result. A missing user, a
75
- revoked token or an exhausted rate limit all come back as the Octokit error, so
76
- you can read `status` off it:
77
+ revoked token or an exhausted rate limit all come back as a plain `Error`
78
+ carrying GitHub's own message, with the `status` and `url` of the failed request
79
+ attached to it:
77
80
 
78
81
  ```js
79
82
  try {
@@ -85,6 +88,8 @@ try {
85
88
  }
86
89
  ```
87
90
 
91
+ Network failures reject with whatever `fetch` threw, untouched.
92
+
88
93
  ### Which package do I want?
89
94
 
90
95
  Use **`@unveil/vk`** when you have a username and want an answer.
package/dist/index.d.mts CHANGED
@@ -9,6 +9,11 @@ type AnalyzeReturn = {
9
9
  events: GitHubEvent[];
10
10
  eventsCount: number;
11
11
  };
12
+ declare class GitHubError extends Error {
13
+ readonly status: number;
14
+ readonly url: string;
15
+ constructor(message: string, status: number, url: string);
16
+ }
12
17
  declare function analyze(username: string, options?: AnalyzeOptions): Promise<AnalyzeReturn>;
13
18
  //#endregion
14
- export { AnalyzeOptions, AnalyzeReturn, analyze };
19
+ export { AnalyzeOptions, AnalyzeReturn, GitHubError, analyze };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{identify as e}from"@unveil/identity";import{Octokit as t}from"octokit";async function n(n,r){let i=new t({auth:r?.token}),{data:a}=await i.rest.users.getByUsername({username:n}),o=Array.from({length:3},(e,t)=>i.rest.activity.listPublicEventsForUser({username:n,per_page:100,page:t+1})),s=(await Promise.all(o)).flatMap(e=>e.data);return{analysis:e({user:a,events:s}),events:r?.showEvents?s:[],eventsCount:s.length}}export{n as analyze};
1
+ import{identify as e}from"@unveil/identity";var t=class extends Error{status;url;constructor(e,t,n){super(e),this.name=`GitHubError`,this.status=t,this.url=n}};async function n(e){try{let t=await e.json();if(t?.message)return t.message}catch{}return`${e.status} ${e.statusText}`}async function r(e,r){let i=`https://api.github.com${e}`,a={Accept:`application/vnd.github+json`,"X-GitHub-Api-Version":`2022-11-28`,"User-Agent":`unveil-vk`};r&&(a.Authorization=`Bearer ${r}`);let o=await fetch(i,{headers:a});if(!o.ok)throw new t(await n(o),o.status,i);return await o.json()}async function i(t,n){let i=n?.token,a=encodeURIComponent(t),o=await r(`/users/${a}`,i),s=Array.from({length:3},(e,t)=>r(`/users/${a}/events/public?per_page=100&page=${t+1}`,i)),c=(await Promise.all(s)).flat();return{analysis:e({user:o,events:c}),events:n?.showEvents?c:[],eventsCount:c.length}}export{t as GitHubError,i as analyze};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unveil/vk",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Fetch GitHub account activity and analyze it for automation patterns",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@11.22.0",
@@ -43,7 +43,6 @@
43
43
  "vitest": "^4.1.10"
44
44
  },
45
45
  "dependencies": {
46
- "@unveil/identity": "^2.0.2",
47
- "octokit": "^5.0.5"
46
+ "@unveil/identity": "^2.0.2"
48
47
  }
49
48
  }