@theholocron/github-client 1.58.0-alpha.1 → 1.58.0-alpha.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/dist/index.d.mts +14 -1
- package/dist/index.mjs +25 -2
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -411,6 +411,18 @@ interface GitHubUser {
|
|
|
411
411
|
name: string | null;
|
|
412
412
|
email: string | null;
|
|
413
413
|
}
|
|
414
|
+
/** The authenticated user and, for a token that expires, when. */
|
|
415
|
+
interface GitHubUserWithExpiry {
|
|
416
|
+
/** The authenticated user. */
|
|
417
|
+
user: GitHubUser;
|
|
418
|
+
/** When the token stops working, ISO 8601 in UTC. Absent for a token that never expires. */
|
|
419
|
+
expiresAt?: string;
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* The expiry GitHub reports in the `github-authentication-token-expiration` header (`2026-11-19 03:46:04 UTC`) as
|
|
423
|
+
* ISO 8601, or `undefined` when the header is missing or is not a date.
|
|
424
|
+
*/
|
|
425
|
+
export declare function parseTokenExpiration(header: string | null): string | undefined;
|
|
414
426
|
interface GitHubWorkflowRun {
|
|
415
427
|
id: number;
|
|
416
428
|
name: string | null;
|
|
@@ -636,6 +648,7 @@ export declare function createGitHubClient(opts: GitHubClientOptions): {
|
|
|
636
648
|
};
|
|
637
649
|
user: {
|
|
638
650
|
getCurrentUser: () => Promise<GitHubUser>;
|
|
651
|
+
getCurrentUserWithExpiry(): Promise<GitHubUserWithExpiry>;
|
|
639
652
|
};
|
|
640
653
|
workflows: {
|
|
641
654
|
listRuns: (repo: string, filter?: WorkflowRunFilter) => Promise<GitHubWorkflowRun[]>;
|
|
@@ -644,4 +657,4 @@ export declare function createGitHubClient(opts: GitHubClientOptions): {
|
|
|
644
657
|
};
|
|
645
658
|
};
|
|
646
659
|
export type GitHubClient = ReturnType<typeof createGitHubClient>;
|
|
647
|
-
export type { CheckRunAnnotation, CheckRunAnnotationLevel, CheckRunConclusion, CheckRunOutput, CheckRunStatus, CodeScanningSetupResult, CreateCheckRunInput, CreatePagesPayload, CreatePullInput, CreateReviewComment, CreateReviewInput, GitBlob, GitCommit, GitContents, GitHubAppCredentials, GitHubCheckRun, GitHubClientOptions, GitHubContents, GitHubEnvironment, GitHubInstallationWebhookPayload, GitHubIssue, GitHubLabel, GitHubMilestone, GitHubPages, GitHubPublicKey, GitHubPullRequest, GitHubPullRequestCommit, GitHubPullRequestFile, GitHubPullRequestReview, GitHubPullRequestWebhookPayload, GitHubPushWebhookPayload, GitHubRepo, GitHubRuleset, GitHubUser, GitHubVariable, GitHubWebhookHeaders, GitHubWorkflowRun, GitPull, GitRef, GitTree, GitTreeItem, InstallationAccessToken, IssueSearchParams, OrgProperty, PagesBuildStatus, PagesBuildType, PutContentsInput, PutContentsResult, ReviewThread, SecretScope, TeamMember, TeamPermission, UpdateCheckRunInput, UpdatePagesPayload, VariableScope, VariableVisibility, WorkflowRunFilter };
|
|
660
|
+
export type { CheckRunAnnotation, CheckRunAnnotationLevel, CheckRunConclusion, CheckRunOutput, CheckRunStatus, CodeScanningSetupResult, CreateCheckRunInput, CreatePagesPayload, CreatePullInput, CreateReviewComment, CreateReviewInput, GitBlob, GitCommit, GitContents, GitHubAppCredentials, GitHubCheckRun, GitHubClientOptions, GitHubContents, GitHubEnvironment, GitHubInstallationWebhookPayload, GitHubIssue, GitHubLabel, GitHubMilestone, GitHubPages, GitHubPublicKey, GitHubPullRequest, GitHubPullRequestCommit, GitHubPullRequestFile, GitHubPullRequestReview, GitHubPullRequestWebhookPayload, GitHubPushWebhookPayload, GitHubRepo, GitHubRuleset, GitHubUser, GitHubUserWithExpiry, GitHubVariable, GitHubWebhookHeaders, GitHubWorkflowRun, GitPull, GitRef, GitTree, GitTreeItem, InstallationAccessToken, IssueSearchParams, OrgProperty, PagesBuildStatus, PagesBuildType, PutContentsInput, PutContentsResult, ReviewThread, SecretScope, TeamMember, TeamPermission, UpdateCheckRunInput, UpdatePagesPayload, VariableScope, VariableVisibility, WorkflowRunFilter };
|
package/dist/index.mjs
CHANGED
|
@@ -549,8 +549,31 @@ function topics(rest) {
|
|
|
549
549
|
}) };
|
|
550
550
|
}
|
|
551
551
|
// src/user/user.ts
|
|
552
|
+
/**
|
|
553
|
+
* The expiry GitHub reports in the `github-authentication-token-expiration` header (`2026-11-19 03:46:04 UTC`) as
|
|
554
|
+
* ISO 8601, or `undefined` when the header is missing or is not a date.
|
|
555
|
+
*/
|
|
556
|
+
function parseTokenExpiration(header) {
|
|
557
|
+
if (!header) return void 0;
|
|
558
|
+
const time = Date.parse(header.replace(/ UTC$/, "Z").replace(" ", "T"));
|
|
559
|
+
return Number.isNaN(time) ? void 0 : new Date(time).toISOString();
|
|
560
|
+
}
|
|
552
561
|
function user(rest) {
|
|
553
|
-
return {
|
|
562
|
+
return {
|
|
563
|
+
getCurrentUser: () => rest.request("/user"),
|
|
564
|
+
/** The authenticated user plus when the token expires, read from the response header on the same call. */
|
|
565
|
+
async getCurrentUserWithExpiry() {
|
|
566
|
+
let header = null;
|
|
567
|
+
const me = await rest.request("/user", { onResponse: (headers) => {
|
|
568
|
+
header = headers.get("github-authentication-token-expiration");
|
|
569
|
+
} });
|
|
570
|
+
const expiresAt = parseTokenExpiration(header);
|
|
571
|
+
return expiresAt ? {
|
|
572
|
+
user: me,
|
|
573
|
+
expiresAt
|
|
574
|
+
} : { user: me };
|
|
575
|
+
}
|
|
576
|
+
};
|
|
554
577
|
}
|
|
555
578
|
// src/variables/variables.ts
|
|
556
579
|
/** GitHub's maximum page size for this listing is 30, not the usual 100. */
|
|
@@ -871,4 +894,4 @@ function createGitHubClient(opts) {
|
|
|
871
894
|
workflows: workflows(rest)
|
|
872
895
|
};
|
|
873
896
|
}
|
|
874
|
-
export { MAX_CHECK_RUN_ANNOTATIONS, createAppJWT, createGitHubClient, createInstallationClient, getInstallationAccessToken, parseGitHubWebhookHeaders, verifyGitHubWebhookSignature };
|
|
897
|
+
export { MAX_CHECK_RUN_ANNOTATIONS, createAppJWT, createGitHubClient, createInstallationClient, getInstallationAccessToken, parseGitHubWebhookHeaders, parseTokenExpiration, verifyGitHubWebhookSignature };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/github-client",
|
|
3
|
-
"version": "1.58.0-alpha.
|
|
3
|
+
"version": "1.58.0-alpha.2",
|
|
4
4
|
"description": "A TypeScript client for the GitHub REST API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"github",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"dist"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@theholocron/http-client": "^1.58.0-alpha.
|
|
35
|
+
"@theholocron/http-client": "^1.58.0-alpha.2",
|
|
36
36
|
"@theholocron/observability": "^0.6.1-alpha.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"tsdown": "^0.23.3",
|
|
46
46
|
"typescript": "^5.9.3",
|
|
47
47
|
"vitest": "^5.0.5",
|
|
48
|
-
"@theholocron/tsconfig": "^8.9.0-alpha.3",
|
|
49
48
|
"@theholocron/eslint-config": "^8.9.0-alpha.3",
|
|
49
|
+
"@theholocron/tsconfig": "^8.9.0-alpha.3",
|
|
50
50
|
"@theholocron/tsdown-config": "^8.9.0-alpha.3",
|
|
51
51
|
"@theholocron/vitest-config": "^8.9.0-alpha.3"
|
|
52
52
|
},
|