forges 0.0.0 → 0.1.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/LICENCE +21 -0
- package/README.md +72 -0
- package/dist/azure-devops/index.d.mts +2 -0
- package/dist/azure-devops/index.mjs +1 -0
- package/dist/azure-devops-DwQvL4TV.mjs +1355 -0
- package/dist/bitbucket/index.d.mts +2 -0
- package/dist/bitbucket/index.mjs +1 -0
- package/dist/bitbucket-CpcfJlYi.mjs +1171 -0
- package/dist/crypto-CQNEyYHD.mjs +156 -0
- package/dist/cursor-origin/index.d.mts +2 -0
- package/dist/cursor-origin/index.mjs +1 -0
- package/dist/cursor-origin-BhqYx2oW.mjs +980 -0
- package/dist/define-B2_4ob2i.d.mts +307 -0
- package/dist/define-D3yEXtKK.mjs +2276 -0
- package/dist/env.d.mts +46 -0
- package/dist/env.mjs +283 -0
- package/dist/fake/index.d.mts +227 -0
- package/dist/fake/index.mjs +1001 -0
- package/dist/fetch-D4pSRvvA.d.mts +1723 -0
- package/dist/forgejo/index.d.mts +2 -0
- package/dist/forgejo/index.mjs +1 -0
- package/dist/forgejo-BCefbHUN.mjs +2005 -0
- package/dist/gitea/index.d.mts +2 -0
- package/dist/gitea/index.mjs +22 -0
- package/dist/gitee/index.d.mts +2 -0
- package/dist/gitee/index.mjs +1 -0
- package/dist/gitee-CA-f7Rs8.mjs +1272 -0
- package/dist/github/index.d.mts +2 -0
- package/dist/github/index.mjs +1 -0
- package/dist/github-B0umL8_f.mjs +3259 -0
- package/dist/gitlab/index.d.mts +2 -0
- package/dist/gitlab/index.mjs +1 -0
- package/dist/gitlab-Bsr__Z0C.mjs +2378 -0
- package/dist/graphql-D7uGzZTf.mjs +366 -0
- package/dist/index-BQ6VS31s.d.mts +32 -0
- package/dist/index-C-jz9Mo3.d.mts +16 -0
- package/dist/index-C4fYzmK3.d.mts +102 -0
- package/dist/index-CQiIX4SH.d.mts +27 -0
- package/dist/index-CTj5gQzl.d.mts +35 -0
- package/dist/index-CliBWzOF.d.mts +23 -0
- package/dist/index-Cz_y-t3d.d.mts +36 -0
- package/dist/index-DEt25E1w.d.mts +77 -0
- package/dist/index-DIuS0EOy.d.mts +43 -0
- package/dist/index-uSpsMCrC.d.mts +26 -0
- package/dist/index.d.mts +41 -0
- package/dist/index.mjs +13 -0
- package/dist/kit.d.mts +183 -0
- package/dist/kit.mjs +4 -0
- package/dist/provider-CoZ7cCxp.d.mts +1439 -0
- package/dist/provider-Ed1YhkQN.mjs +169 -0
- package/dist/pushin/index.d.mts +2 -0
- package/dist/pushin/index.mjs +1 -0
- package/dist/pushin-CkxgJ2cU.mjs +343 -0
- package/dist/schema/Actor.json +96 -0
- package/dist/schema/AlertSupport.json +49 -0
- package/dist/schema/AuthKind.json +15 -0
- package/dist/schema/Branch.json +31 -0
- package/dist/schema/ChangedFile.json +58 -0
- package/dist/schema/Check.json +169 -0
- package/dist/schema/CheckRef.json +114 -0
- package/dist/schema/CheckState.json +14 -0
- package/dist/schema/ChecksSummary.json +34 -0
- package/dist/schema/CiJob.json +186 -0
- package/dist/schema/CiJobRef.json +132 -0
- package/dist/schema/CiRun.json +234 -0
- package/dist/schema/CiRunRef.json +103 -0
- package/dist/schema/CodeFragment.json +19 -0
- package/dist/schema/CodeMatch.json +128 -0
- package/dist/schema/Collaborator.json +169 -0
- package/dist/schema/Comment.json +336 -0
- package/dist/schema/CommentRef.json +158 -0
- package/dist/schema/Commit.json +307 -0
- package/dist/schema/CommitRef.json +104 -0
- package/dist/schema/CommitSignature.json +118 -0
- package/dist/schema/Comparison.json +355 -0
- package/dist/schema/Cursor.json +21 -0
- package/dist/schema/EventAction.json +33 -0
- package/dist/schema/EventDetail.json +649 -0
- package/dist/schema/EventKind.json +26 -0
- package/dist/schema/FileContent.json +73 -0
- package/dist/schema/FileStatus.json +15 -0
- package/dist/schema/ForgeCapabilities.json +737 -0
- package/dist/schema/ForgeEvent.json +789 -0
- package/dist/schema/ForgeInstance.json +7 -0
- package/dist/schema/ForgeKind.json +32 -0
- package/dist/schema/ForgeWarning.json +49 -0
- package/dist/schema/ForgeWarningCode.json +7 -0
- package/dist/schema/GetManyResult.json +699 -0
- package/dist/schema/Installation.json +131 -0
- package/dist/schema/InstallationToken.json +31 -0
- package/dist/schema/KnownForgeKind.json +19 -0
- package/dist/schema/Label.json +22 -0
- package/dist/schema/MergeMethod.json +14 -0
- package/dist/schema/Milestone.json +40 -0
- package/dist/schema/Notification.json +498 -0
- package/dist/schema/NotificationReason.json +28 -0
- package/dist/schema/NotificationRef.json +60 -0
- package/dist/schema/NotificationSubject.json +376 -0
- package/dist/schema/PerKind.json +49 -0
- package/dist/schema/PullBranches.json +125 -0
- package/dist/schema/PushCommit.json +24 -0
- package/dist/schema/Reaction.json +148 -0
- package/dist/schema/ReactionContent.json +17 -0
- package/dist/schema/ReactionSummary.json +70 -0
- package/dist/schema/Release.json +286 -0
- package/dist/schema/ReleaseAsset.json +169 -0
- package/dist/schema/ReleaseAssetRef.json +138 -0
- package/dist/schema/ReleaseRef.json +107 -0
- package/dist/schema/Repo.json +354 -0
- package/dist/schema/RepoFeatures.json +35 -0
- package/dist/schema/RepoPermissions.json +35 -0
- package/dist/schema/RepoRef.json +77 -0
- package/dist/schema/RepoRole.json +15 -0
- package/dist/schema/RepoVisibility.json +12 -0
- package/dist/schema/Review.json +371 -0
- package/dist/schema/ReviewComment.json +280 -0
- package/dist/schema/ReviewCommentInput.json +34 -0
- package/dist/schema/ReviewRef.json +158 -0
- package/dist/schema/ReviewState.json +15 -0
- package/dist/schema/Reviewer.json +133 -0
- package/dist/schema/SecurityAlert.json +219 -0
- package/dist/schema/SecurityAlertKind.json +14 -0
- package/dist/schema/SecurityAlertRef.json +122 -0
- package/dist/schema/SecuritySeverity.json +14 -0
- package/dist/schema/SourceKind.json +12 -0
- package/dist/schema/SubscriptionState.json +12 -0
- package/dist/schema/Support.json +23 -0
- package/dist/schema/Tag.json +25 -0
- package/dist/schema/TextLimits.json +18 -0
- package/dist/schema/Thread.json +653 -0
- package/dist/schema/ThreadKind.json +14 -0
- package/dist/schema/ThreadRef.json +131 -0
- package/dist/schema/ThreadStack.json +146 -0
- package/dist/schema/ThreadState.json +13 -0
- package/dist/schema/TreeEntry.json +46 -0
- package/dist/schema/TreeEntryType.json +13 -0
- package/dist/schema/UpsertCommentResult.json +355 -0
- package/dist/schema/User.json +123 -0
- package/dist/schema/Webhook.json +188 -0
- package/dist/schema/WebhookDeliveryRecord.json +173 -0
- package/dist/schema/WebhookDeliveryRef.json +135 -0
- package/dist/schema/WebhookRef.json +105 -0
- package/dist/schema/index.d.mts +4 -0
- package/dist/schema/index.mjs +3219 -0
- package/dist/tangled/index.d.mts +2 -0
- package/dist/tangled/index.mjs +1 -0
- package/dist/tangled-ChdPmiv-.mjs +1570 -0
- package/dist/testing/index.d.mts +123 -0
- package/dist/testing/index.mjs +242 -0
- package/dist/webhooks-rn9-8lxT.mjs +70 -0
- package/package.json +115 -3
- package/dist/.gitkeep +0 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
//#region src/crypto.ts
|
|
2
|
+
const encoder = new TextEncoder();
|
|
3
|
+
function toBytes(value) {
|
|
4
|
+
return typeof value === "string" ? encoder.encode(value) : value;
|
|
5
|
+
}
|
|
6
|
+
function toHex(buffer) {
|
|
7
|
+
return [...new Uint8Array(buffer)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
8
|
+
}
|
|
9
|
+
/** Base64 for arbitrary bytes, a byte at a time so a large buffer cannot overflow the call stack. */
|
|
10
|
+
function toBase64(bytes) {
|
|
11
|
+
let binary = "";
|
|
12
|
+
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
13
|
+
return btoa(binary);
|
|
14
|
+
}
|
|
15
|
+
function toBase64Url(input) {
|
|
16
|
+
return (typeof input === "string" ? btoa(input) : toBase64(input)).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
|
|
17
|
+
}
|
|
18
|
+
async function hmacSha256(secret, body) {
|
|
19
|
+
const key = await crypto.subtle.importKey("raw", toBytes(secret), {
|
|
20
|
+
name: "HMAC",
|
|
21
|
+
hash: "SHA-256"
|
|
22
|
+
}, false, ["sign"]);
|
|
23
|
+
return crypto.subtle.sign("HMAC", key, toBytes(body));
|
|
24
|
+
}
|
|
25
|
+
/** Lowercase hex HMAC-SHA256 of `body` under `secret`. */
|
|
26
|
+
async function hmacSha256Hex(secret, body) {
|
|
27
|
+
return toHex(await hmacSha256(secret, body));
|
|
28
|
+
}
|
|
29
|
+
/** Constant-time comparison of two ASCII strings. */
|
|
30
|
+
function timingSafeEqual(a, b) {
|
|
31
|
+
if (a.length !== b.length) return false;
|
|
32
|
+
let mismatch = 0;
|
|
33
|
+
for (let index = 0; index < a.length; index++) mismatch |= a.charCodeAt(index) ^ b.charCodeAt(index);
|
|
34
|
+
return mismatch === 0;
|
|
35
|
+
}
|
|
36
|
+
function decodePem(pem) {
|
|
37
|
+
const pkcs1 = pem.includes("BEGIN RSA PRIVATE KEY");
|
|
38
|
+
const body = pem.replace(/-----(?:BEGIN|END)[^-]+-----/g, "").replace(/\s+/g, "");
|
|
39
|
+
const binary = atob(body);
|
|
40
|
+
const der = new Uint8Array(binary.length);
|
|
41
|
+
for (let index = 0; index < binary.length; index++) der[index] = binary.charCodeAt(index);
|
|
42
|
+
return {
|
|
43
|
+
der,
|
|
44
|
+
pkcs1
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function derLength(length) {
|
|
48
|
+
if (length < 128) return [length];
|
|
49
|
+
const bytes = [];
|
|
50
|
+
let remaining = length;
|
|
51
|
+
while (remaining > 0) {
|
|
52
|
+
bytes.unshift(remaining & 255);
|
|
53
|
+
remaining >>= 8;
|
|
54
|
+
}
|
|
55
|
+
return [128 | bytes.length, ...bytes];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Wraps a PKCS#1 RSA key in a PKCS#8 `PrivateKeyInfo`. GitHub App keys are
|
|
59
|
+
* distributed as PKCS#1, which Web Crypto cannot import directly.
|
|
60
|
+
*/
|
|
61
|
+
function pkcs1ToPkcs8(der) {
|
|
62
|
+
const algorithm = [
|
|
63
|
+
48,
|
|
64
|
+
13,
|
|
65
|
+
6,
|
|
66
|
+
9,
|
|
67
|
+
42,
|
|
68
|
+
134,
|
|
69
|
+
72,
|
|
70
|
+
134,
|
|
71
|
+
247,
|
|
72
|
+
13,
|
|
73
|
+
1,
|
|
74
|
+
1,
|
|
75
|
+
1,
|
|
76
|
+
5,
|
|
77
|
+
0
|
|
78
|
+
];
|
|
79
|
+
const octetString = [
|
|
80
|
+
4,
|
|
81
|
+
...derLength(der.length),
|
|
82
|
+
...der
|
|
83
|
+
];
|
|
84
|
+
const contents = [
|
|
85
|
+
2,
|
|
86
|
+
1,
|
|
87
|
+
0,
|
|
88
|
+
...algorithm,
|
|
89
|
+
...octetString
|
|
90
|
+
];
|
|
91
|
+
return new Uint8Array([
|
|
92
|
+
48,
|
|
93
|
+
...derLength(contents.length),
|
|
94
|
+
...contents
|
|
95
|
+
]);
|
|
96
|
+
}
|
|
97
|
+
/** Signs an RS256 JWT with a PEM-encoded RSA private key. */
|
|
98
|
+
async function signRs256Jwt(privateKeyPem, claims) {
|
|
99
|
+
const { der, pkcs1 } = decodePem(privateKeyPem);
|
|
100
|
+
const key = await crypto.subtle.importKey("pkcs8", pkcs1 ? pkcs1ToPkcs8(der) : der, {
|
|
101
|
+
name: "RSASSA-PKCS1-v1_5",
|
|
102
|
+
hash: "SHA-256"
|
|
103
|
+
}, false, ["sign"]);
|
|
104
|
+
const payload = `${toBase64Url(JSON.stringify({
|
|
105
|
+
alg: "RS256",
|
|
106
|
+
typ: "JWT"
|
|
107
|
+
}))}.${toBase64Url(JSON.stringify(claims))}`;
|
|
108
|
+
const signature = await crypto.subtle.sign("RSASSA-PKCS1-v1_5", key, encoder.encode(payload));
|
|
109
|
+
return `${payload}.${toBase64Url(new Uint8Array(signature))}`;
|
|
110
|
+
}
|
|
111
|
+
/** The value of a header, whatever the casing of `name`, from a `Headers` object or a plain record. */
|
|
112
|
+
function headerValue(headers, name) {
|
|
113
|
+
if (headers instanceof Headers) return headers.get(name) ?? void 0;
|
|
114
|
+
const lower = name.toLowerCase();
|
|
115
|
+
for (const [key, value] of Object.entries(headers)) if (key.toLowerCase() === lower) return value;
|
|
116
|
+
}
|
|
117
|
+
/** A request body as text. */
|
|
118
|
+
function bodyText(body) {
|
|
119
|
+
return typeof body === "string" ? body : new TextDecoder().decode(body);
|
|
120
|
+
}
|
|
121
|
+
/** Lowercase hex SHA-256 of `body`. */
|
|
122
|
+
async function sha256Hex(body) {
|
|
123
|
+
return toHex(await crypto.subtle.digest("SHA-256", toBytes(body)));
|
|
124
|
+
}
|
|
125
|
+
/** Signs an EdDSA (Ed25519) JWT with a PKCS#8 PEM private key. `kid` goes in the JOSE header. */
|
|
126
|
+
async function signEdDsaJwt(privateKeyPem, claims, kid) {
|
|
127
|
+
const key = await crypto.subtle.importKey("pkcs8", decodePem(privateKeyPem).der, { name: "Ed25519" }, false, ["sign"]);
|
|
128
|
+
const payload = `${toBase64Url(JSON.stringify({
|
|
129
|
+
alg: "EdDSA",
|
|
130
|
+
typ: "JWT",
|
|
131
|
+
...kid ? { kid } : {}
|
|
132
|
+
}))}.${toBase64Url(JSON.stringify(claims))}`;
|
|
133
|
+
const signature = await crypto.subtle.sign("Ed25519", key, encoder.encode(payload));
|
|
134
|
+
return `${payload}.${toBase64Url(new Uint8Array(signature))}`;
|
|
135
|
+
}
|
|
136
|
+
/** Verifies an Ed25519 signature (base64) over `data` with a JWK public key. */
|
|
137
|
+
async function verifyEd25519(jwk, data, signatureBase64) {
|
|
138
|
+
try {
|
|
139
|
+
const key = await crypto.subtle.importKey("jwk", {
|
|
140
|
+
kty: jwk.kty,
|
|
141
|
+
crv: jwk.crv,
|
|
142
|
+
x: jwk.x
|
|
143
|
+
}, { name: "Ed25519" }, false, ["verify"]);
|
|
144
|
+
const binary = atob(signatureBase64);
|
|
145
|
+
const signature = Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
146
|
+
return await crypto.subtle.verify("Ed25519", key, signature, toBytes(data));
|
|
147
|
+
} catch {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/** Base64 HMAC-SHA256 of `body` under `secret`. */
|
|
152
|
+
async function hmacSha256Base64(secret, body) {
|
|
153
|
+
return toBase64(new Uint8Array(await hmacSha256(secret, body)));
|
|
154
|
+
}
|
|
155
|
+
//#endregion
|
|
156
|
+
export { sha256Hex as a, timingSafeEqual as c, hmacSha256Hex as i, toBase64 as l, headerValue as n, signEdDsaJwt as o, hmacSha256Base64 as r, signRs256Jwt as s, bodyText as t, verifyEd25519 as u };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as ORIGIN_API_VERSION, n as cursorOrigin, r as cursorOriginLite } from "../cursor-origin-BhqYx2oW.mjs";
|