@sentry/junior-github 0.256.0 → 0.257.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/SETUP.md +5 -0
- package/dist/{chunk-D75O3CY3.js → chunk-JF4WIM23.js} +20 -0
- package/dist/credential-support.d.ts +7 -0
- package/dist/index.js +14 -2
- package/dist/testing.js +1 -1
- package/package.json +2 -2
package/SETUP.md
CHANGED
|
@@ -19,6 +19,11 @@ In GitHub:
|
|
|
19
19
|
- Workflows: Write
|
|
20
20
|
- Metadata: Read
|
|
21
21
|
|
|
22
|
+
Optional: under account permissions, grant Email addresses: Read. Junior then
|
|
23
|
+
reads the verified emails of a connected GitHub account to link it to a
|
|
24
|
+
person. Without it, Junior links the account only through the person who
|
|
25
|
+
connected it.
|
|
26
|
+
|
|
22
27
|
4. Create the app and generate a private key.
|
|
23
28
|
5. Install the app on the target org/repo(s).
|
|
24
29
|
|
|
@@ -650,6 +650,25 @@ async function resolveUserAccount(tokens) {
|
|
|
650
650
|
...url ? { url } : void 0
|
|
651
651
|
};
|
|
652
652
|
}
|
|
653
|
+
async function listVerifiedUserEmails(tokens) {
|
|
654
|
+
let emails;
|
|
655
|
+
try {
|
|
656
|
+
emails = await githubRequest("https://api.github.com", "/user/emails", {
|
|
657
|
+
token: tokens.accessToken
|
|
658
|
+
});
|
|
659
|
+
} catch (error) {
|
|
660
|
+
if (error instanceof GitHubRequestError && (error.status === 403 || error.status === 404)) {
|
|
661
|
+
return [];
|
|
662
|
+
}
|
|
663
|
+
throw error;
|
|
664
|
+
}
|
|
665
|
+
if (!Array.isArray(emails)) {
|
|
666
|
+
throw new Error("GitHub user emails response is invalid");
|
|
667
|
+
}
|
|
668
|
+
return emails.flatMap(
|
|
669
|
+
(entry) => isRecord(entry) && entry.verified === true && typeof entry.email === "string" && entry.email.trim() ? [entry.email.trim()] : []
|
|
670
|
+
);
|
|
671
|
+
}
|
|
653
672
|
async function tokensWithAccount(tokenSlot, stored, scope) {
|
|
654
673
|
if (stored.account) {
|
|
655
674
|
return { ok: true, tokens: stored };
|
|
@@ -1957,6 +1976,7 @@ export {
|
|
|
1957
1976
|
credentialUnavailable,
|
|
1958
1977
|
githubRepositoryFromUrl,
|
|
1959
1978
|
resolveUserAccount,
|
|
1979
|
+
listVerifiedUserEmails,
|
|
1960
1980
|
issueUserCredential,
|
|
1961
1981
|
issueInstallationToken,
|
|
1962
1982
|
issueInstallationCredential,
|
|
@@ -68,6 +68,13 @@ export declare function credentialUnavailable(message: string): PluginCredential
|
|
|
68
68
|
export declare function githubRepositoryFromUrl(upstreamUrl: URL): GitHubRepository | undefined;
|
|
69
69
|
/** Resolve the GitHub account associated with stored user tokens. */
|
|
70
70
|
export declare function resolveUserAccount(tokens: PluginStoredTokens): Promise<PluginProviderAccount>;
|
|
71
|
+
/**
|
|
72
|
+
* List the email addresses GitHub verified for the user OAuth token.
|
|
73
|
+
*
|
|
74
|
+
* GitHub App user tokens need the App's "Email addresses" user permission.
|
|
75
|
+
* Return an empty list when the App does not have it.
|
|
76
|
+
*/
|
|
77
|
+
export declare function listVerifiedUserEmails(tokens: PluginStoredTokens): Promise<string[]>;
|
|
71
78
|
/** Issue a bounded GitHub user credential for an approved grant. */
|
|
72
79
|
export declare function issueUserCredential(ctx: IssueCredentialHookContext, options: UserCredentialOptions): Promise<PluginCredentialResult>;
|
|
73
80
|
/** Issue a bounded raw token for plugin-owned GitHub API calls. */
|
package/dist/index.js
CHANGED
|
@@ -42,6 +42,7 @@ import {
|
|
|
42
42
|
issueInstallationCredential,
|
|
43
43
|
issueInstallationToken,
|
|
44
44
|
issueUserCredential,
|
|
45
|
+
listVerifiedUserEmails,
|
|
45
46
|
loadCheckSuiteFacts,
|
|
46
47
|
needsCheckSuitePullRequestFacts,
|
|
47
48
|
normalizeGitHubEvents,
|
|
@@ -52,7 +53,7 @@ import {
|
|
|
52
53
|
readGrantPermissions,
|
|
53
54
|
requireEnv,
|
|
54
55
|
resolveUserAccount
|
|
55
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-JF4WIM23.js";
|
|
56
57
|
|
|
57
58
|
// src/plugin.ts
|
|
58
59
|
import {
|
|
@@ -5165,7 +5166,18 @@ function githubPlugin(options = {}) {
|
|
|
5165
5166
|
}
|
|
5166
5167
|
},
|
|
5167
5168
|
async resolveOAuthAccount(ctx) {
|
|
5168
|
-
|
|
5169
|
+
const [account, verifiedEmails] = await Promise.all([
|
|
5170
|
+
resolveUserAccount(ctx.tokens),
|
|
5171
|
+
// Verified emails only help link the account. An email lookup
|
|
5172
|
+
// failure must not block the connection.
|
|
5173
|
+
listVerifiedUserEmails(ctx.tokens).catch((error) => {
|
|
5174
|
+
ctx.log.warn("github.oauth_account.emails_lookup.failed", {
|
|
5175
|
+
"exception.message": error instanceof Error ? error.message : String(error)
|
|
5176
|
+
});
|
|
5177
|
+
return [];
|
|
5178
|
+
})
|
|
5179
|
+
]);
|
|
5180
|
+
return verifiedEmails.length > 0 ? { ...account, verifiedEmails } : account;
|
|
5169
5181
|
},
|
|
5170
5182
|
async issueCredential(ctx) {
|
|
5171
5183
|
try {
|
package/dist/testing.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/junior-github",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.257.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@sinclair/typebox": "^0.34.49",
|
|
32
32
|
"drizzle-orm": "^0.45.2",
|
|
33
33
|
"zod": "^4.5.4",
|
|
34
|
-
"@sentry/junior-plugin-api": "0.
|
|
34
|
+
"@sentry/junior-plugin-api": "0.257.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@oxlint/plugins": "1.79.0",
|