@rathnasgala/cli 0.0.15 → 0.0.16

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": "@rathnasgala/cli",
3
- "version": "0.0.15",
3
+ "version": "0.0.16",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src"
@@ -52,9 +52,23 @@ export async function exchangeGithubAuthorization({
52
52
  return payload.authorization;
53
53
  }
54
54
 
55
- export async function listAuthorizedRepositories({ apiBaseUrl, authorization, fetchImpl = fetch }) {
55
+ /**
56
+ * Both credentials are required, and they are not interchangeable.
57
+ *
58
+ * The endpoint is `.authenticated()` and its handler takes the Gala principal, so the bearer says
59
+ * who is asking; `GitHub-Authorization` is the short-lived capability that says what they may see.
60
+ * Sending only the capability gets a bare 401 from the security filter, before any handler runs —
61
+ * which reads as "your GitHub authorization was refused" and is nothing of the kind.
62
+ */
63
+ export async function listAuthorizedRepositories({
64
+ apiBaseUrl, authorization, galaAccessToken, fetchImpl = fetch
65
+ }) {
56
66
  const response = await fetchImpl(endpoint(apiBaseUrl, '/v1/auth/github/repositories'), {
57
- headers: { accept: 'application/json', 'GitHub-Authorization': authorization }
67
+ headers: {
68
+ accept: 'application/json',
69
+ authorization: `Bearer ${galaAccessToken}`,
70
+ 'GitHub-Authorization': authorization
71
+ }
58
72
  });
59
73
  if (!response.ok) {
60
74
  throw new Error(`Authorized repository lookup failed with HTTP ${response.status}`);
@@ -80,7 +94,7 @@ export async function resolveInstallationId({
80
94
  });
81
95
  // null means the App is not installed yet, which the caller turns into an instruction.
82
96
  if (authorization == null) return null;
83
- const repositories = await list({ apiBaseUrl, authorization, fetchImpl });
97
+ const repositories = await list({ apiBaseUrl, authorization, galaAccessToken, fetchImpl });
84
98
  const wanted = String(owner).toLowerCase();
85
99
  for (const repository of repositories) {
86
100
  if (String(repository?.owner).toLowerCase() !== wanted) continue;