starlight-annotations 0.1.1 → 0.1.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starlight-annotations",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "🖍️ Let readers highlight text and leave notes on Starlight docs. Notes are committed to your Git repository.",
5
5
  "license": "MIT",
6
6
  "author": "Alessandro Rosa",
package/server.d.ts CHANGED
@@ -55,8 +55,8 @@ export interface GitHubAuthOptions {
55
55
  /** A long random string that signs the session cookie. */
56
56
  sessionSecret: string;
57
57
  /**
58
- * Who may write. `"collaborators"` (default) checks the reader's permission on `repo`
59
- * with `token`. `"anyone"` accepts every GitHub user.
58
+ * Who may write. `"collaborators"` (default) accepts people with write, maintain or admin
59
+ * access to `repo`, checked with `token`. `"anyone"` accepts every GitHub user.
60
60
  */
61
61
  writers?: 'collaborators' | 'anyone' | string[] | ((profile: { login: string; id: number }) => boolean | Promise<boolean>);
62
62
  repo?: string;
@@ -107,8 +107,11 @@ export function githubAuth({ clientId, clientSecret, sessionSecret, repo, token,
107
107
  if (writers === 'anyone') return true;
108
108
  if (Array.isArray(writers)) return writers.map((login) => login.toLowerCase()).includes(profile.login.toLowerCase());
109
109
  if (typeof writers === 'function') return Boolean(await writers(profile));
110
+ // Only people who can push to the repository. `permission` is the legacy
111
+ // level: maintain counts as write, triage as read. On a public repository
112
+ // GitHub answers "read" for anyone, so read access is not enough.
110
113
  const permission = await api(token, `/repos/${repo}/collaborators/${encodeURIComponent(profile.login)}/permission`, { allow404: true });
111
- return Boolean(permission && permission.permission !== 'none');
114
+ return permission?.permission === 'admin' || permission?.permission === 'write';
112
115
  }
113
116
 
114
117
  async function hmac(value) {