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 +1 -1
- package/server.d.ts +2 -2
- package/src/server/github.js +4 -1
package/package.json
CHANGED
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)
|
|
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;
|
package/src/server/github.js
CHANGED
|
@@ -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
|
|
114
|
+
return permission?.permission === 'admin' || permission?.permission === 'write';
|
|
112
115
|
}
|
|
113
116
|
|
|
114
117
|
async function hmac(value) {
|