@openma/matter-gitlab 0.0.0-stage → 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/LICENSE +202 -0
- package/README.md +10 -2
- package/dist/bond/index.d.ts +304 -0
- package/dist/bond/index.js +638 -0
- package/dist/bond/index.js.map +1 -0
- package/package.json +29 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Support. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or support.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025 Open Managed Agents Contributors
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
package/README.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@openma/matter-gitlab`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
GitLab for OpenMatter. Covers gitlab.com and self-managed GitLab.
|
|
4
|
+
|
|
5
|
+
| Import | Contents |
|
|
6
|
+
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------ |
|
|
7
|
+
| `@openma/matter-gitlab/bond` | Bond provider: OAuth (PKCE) user links, bot credentials, request classification, attribution, receive-pack parsing |
|
|
8
|
+
|
|
9
|
+
The Bond kernel it plugs into is `@openma/matter/bond`. See
|
|
10
|
+
[docs/BONDS.md](https://github.com/openma-ai/OpenMatter/blob/main/docs/BONDS.md)
|
|
11
|
+
for the flow, token custody, and security notes.
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import { BondProvider, ProviderError, SecretRef, TokenGrant } from "@openma/matter/bond";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
//#region src/bond/http.d.ts
|
|
4
|
+
type Fetch = typeof globalThis.fetch;
|
|
5
|
+
/**
|
|
6
|
+
* Normalizes a GitLab instance URL to its canonical https origin. Rejects
|
|
7
|
+
* plain http except for loopback hosts, and rejects paths, credentials,
|
|
8
|
+
* queries, and fragments.
|
|
9
|
+
*/
|
|
10
|
+
declare const canonicalOrigin: (input: string) => string;
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/bond/oauth.d.ts
|
|
13
|
+
/**
|
|
14
|
+
* What discovery verified. OAuth calls always use the instance's fixed
|
|
15
|
+
* `/oauth/authorize`, `/oauth/token`, and `/oauth/revoke` under `origin`, so
|
|
16
|
+
* discovery returns no endpoints that callers might follow elsewhere.
|
|
17
|
+
*/
|
|
18
|
+
interface GitLabInstance {
|
|
19
|
+
readonly origin: string;
|
|
20
|
+
/** Whether the instance enables the device authorization grant. */
|
|
21
|
+
readonly deviceFlow: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Reads OIDC discovery and requires authorization code with PKCE S256 and
|
|
25
|
+
* refresh tokens, and an issuer equal to the instance origin. Device flow is
|
|
26
|
+
* recorded when present; GitLab can disable it per instance.
|
|
27
|
+
*/
|
|
28
|
+
declare const discoverInstance: (origin: string, fetchImpl?: Fetch) => Effect.Effect<GitLabInstance, ProviderError>;
|
|
29
|
+
interface Pkce {
|
|
30
|
+
readonly verifier: string;
|
|
31
|
+
readonly challenge: string;
|
|
32
|
+
readonly method: "S256";
|
|
33
|
+
}
|
|
34
|
+
/** A fresh PKCE verifier and its S256 challenge. Keep the verifier server-side. */
|
|
35
|
+
declare const createPkce: () => Effect.Effect<Pkce>;
|
|
36
|
+
interface AuthorizationUrlInput {
|
|
37
|
+
readonly origin: string;
|
|
38
|
+
readonly clientId: string;
|
|
39
|
+
readonly redirectUri: string;
|
|
40
|
+
readonly scopes: readonly string[];
|
|
41
|
+
/** Signed, single-use state bound to the user and ProviderApp. */
|
|
42
|
+
readonly state: string;
|
|
43
|
+
readonly codeChallenge: string;
|
|
44
|
+
}
|
|
45
|
+
declare const authorizationUrl: (input: AuthorizationUrlInput) => string;
|
|
46
|
+
interface OAuthClient {
|
|
47
|
+
readonly origin: string;
|
|
48
|
+
readonly clientId: string;
|
|
49
|
+
/** Absent for public clients. */
|
|
50
|
+
readonly clientSecret?: string;
|
|
51
|
+
readonly fetch?: Fetch;
|
|
52
|
+
/** ISO now, for computing expiry. */
|
|
53
|
+
readonly clock?: () => string;
|
|
54
|
+
}
|
|
55
|
+
/** Exchanges an authorization code. A wrong verifier does not consume the code on GitLab. */
|
|
56
|
+
declare const exchangeCode: (client: OAuthClient, input: {
|
|
57
|
+
readonly code: string;
|
|
58
|
+
readonly redirectUri: string;
|
|
59
|
+
readonly codeVerifier: string;
|
|
60
|
+
}) => Effect.Effect<TokenGrant, ProviderError, never>;
|
|
61
|
+
/**
|
|
62
|
+
* Refreshes a user token. GitLab rotates both tokens and invalidates the old
|
|
63
|
+
* access token immediately, and does not detect refresh-token reuse, so the
|
|
64
|
+
* caller must hold the Bond refresh lease.
|
|
65
|
+
*/
|
|
66
|
+
declare const refreshAccessToken: (client: OAuthClient, refreshToken: string) => Effect.Effect<TokenGrant, ProviderError, never>;
|
|
67
|
+
/**
|
|
68
|
+
* Revokes one access or refresh token. GitLab (Doorkeeper) stores an access
|
|
69
|
+
* token and its refresh token as one record, so revoking either ends that
|
|
70
|
+
* pair only. Other tokens the same user holds for the same application keep
|
|
71
|
+
* working: on a live instance, revoking the previous token after a relink left
|
|
72
|
+
* the new one valid.
|
|
73
|
+
*/
|
|
74
|
+
declare const revokeToken: (client: OAuthClient, token: string) => Effect.Effect<undefined, ProviderError, never>;
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/bond/tokens.d.ts
|
|
77
|
+
/** `GET /api/v4/user`. Numeric `id` is the stable key; the rest is display data. */
|
|
78
|
+
interface GitLabUser {
|
|
79
|
+
readonly id: string;
|
|
80
|
+
readonly username: string;
|
|
81
|
+
readonly name: string;
|
|
82
|
+
readonly commitEmail?: string;
|
|
83
|
+
readonly bot: boolean;
|
|
84
|
+
readonly identities: readonly {
|
|
85
|
+
readonly provider: string;
|
|
86
|
+
readonly externUid: string;
|
|
87
|
+
}[];
|
|
88
|
+
}
|
|
89
|
+
/** `GET /api/v4/personal_access_tokens/self`. Works for personal, project, and group access tokens. */
|
|
90
|
+
interface GitLabTokenInfo {
|
|
91
|
+
readonly id: string;
|
|
92
|
+
readonly name: string;
|
|
93
|
+
readonly active: boolean;
|
|
94
|
+
readonly revoked: boolean;
|
|
95
|
+
readonly scopes: readonly string[];
|
|
96
|
+
/** `YYYY-MM-DD`, or undefined for a token without expiry. */
|
|
97
|
+
readonly expiresAt?: string;
|
|
98
|
+
readonly userId: string;
|
|
99
|
+
}
|
|
100
|
+
declare const readUser: (origin: string, token: string, fetchImpl?: Fetch) => Effect.Effect<GitLabUser, ProviderError>;
|
|
101
|
+
declare const readTokenInfo: (origin: string, token: string, fetchImpl?: Fetch) => Effect.Effect<GitLabTokenInfo, ProviderError>;
|
|
102
|
+
/** `DELETE /api/v4/personal_access_tokens/self`: a token revokes itself. */
|
|
103
|
+
declare const revokeSelfToken: (origin: string, token: string, fetchImpl?: Fetch) => Effect.Effect<void, ProviderError>;
|
|
104
|
+
interface TokenPolicy {
|
|
105
|
+
readonly allowedScopes: readonly string[];
|
|
106
|
+
readonly maxLifetimeDays: number;
|
|
107
|
+
/** ISO now. */
|
|
108
|
+
readonly now: string;
|
|
109
|
+
}
|
|
110
|
+
type TokenProblem = "inactive" | "revoked" | "no_expiry" | "expired" | "lifetime_exceeded" | "scope_not_allowed" | "not_a_bot" | "is_a_bot" | "user_mismatch";
|
|
111
|
+
/** End of the UTC expiry day, which is when GitLab stops accepting the token. */
|
|
112
|
+
declare const tokenExpiryInstant: (expiresAt: string) => string;
|
|
113
|
+
/**
|
|
114
|
+
* Checks a pasted personal access token: active, scopes within the allowed
|
|
115
|
+
* set, an expiry within the maximum lifetime, and a human owner.
|
|
116
|
+
*/
|
|
117
|
+
declare const validatePersonalAccessToken: (info: GitLabTokenInfo, user: GitLabUser, policy: TokenPolicy) => readonly TokenProblem[];
|
|
118
|
+
/**
|
|
119
|
+
* Checks a bot credential registered as an Installation: the same token
|
|
120
|
+
* checks, plus `bot: true` on its user. A human account's token is never
|
|
121
|
+
* accepted as an app principal.
|
|
122
|
+
*/
|
|
123
|
+
declare const validateBotCredential: (info: GitLabTokenInfo, user: GitLabUser, policy: TokenPolicy) => readonly TokenProblem[];
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/bond/classify.d.ts
|
|
126
|
+
type GitLabOperation = "fetch" | "push" | "read" | "open_mr" | "comment_mr";
|
|
127
|
+
/**
|
|
128
|
+
* A normalized project reference. Paths are lower-cased and stripped of
|
|
129
|
+
* `.git`; numeric IDs stay numeric. Both forms name one project only after
|
|
130
|
+
* the application resolves them through GitLab.
|
|
131
|
+
*/
|
|
132
|
+
type ProjectRef = {
|
|
133
|
+
readonly kind: "id";
|
|
134
|
+
readonly id: number;
|
|
135
|
+
} | {
|
|
136
|
+
readonly kind: "path";
|
|
137
|
+
readonly path: string;
|
|
138
|
+
};
|
|
139
|
+
type GitLabRequestClass = {
|
|
140
|
+
readonly allow: true;
|
|
141
|
+
readonly projectRef: ProjectRef;
|
|
142
|
+
readonly operation: GitLabOperation;
|
|
143
|
+
/** `git` for smart HTTP, `rest` for `/api/v4`. */
|
|
144
|
+
readonly surface: "git" | "rest";
|
|
145
|
+
/**
|
|
146
|
+
* For `rest`: the validated path after `/api/v4/projects/<ref>`, to
|
|
147
|
+
* append to the resolved numeric project ID. For `open_mr`, the proxy
|
|
148
|
+
* must also check the body with `mergeRequestBodyProblem`.
|
|
149
|
+
*/
|
|
150
|
+
readonly restTail?: string;
|
|
151
|
+
} | {
|
|
152
|
+
readonly allow: false;
|
|
153
|
+
readonly reason: string;
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Classifies one request in GitLab's own URL shape. Allows git smart HTTP
|
|
157
|
+
* fetch and push, REST reads of a project, merge request creation, and
|
|
158
|
+
* merge request notes. Denies GraphQL, LFS, archives, raw files, and every
|
|
159
|
+
* other route.
|
|
160
|
+
*/
|
|
161
|
+
declare const classifyGitLabRequest: (method: string, url: string | URL) => GitLabRequestClass;
|
|
162
|
+
/**
|
|
163
|
+
* GitLab lets `POST /projects/:id/merge_requests` name another project in
|
|
164
|
+
* `target_project_id`, so the URL alone does not bound where the merge
|
|
165
|
+
* request opens. Returns the reason to deny, or undefined when the body
|
|
166
|
+
* targets the classified project.
|
|
167
|
+
*
|
|
168
|
+
* Pass the parsed JSON object or form body and the numeric ID the URL's
|
|
169
|
+
* project reference resolved to, then forward the body you checked
|
|
170
|
+
* (re-serialized), never the raw bytes: parsers disagree on repeated keys.
|
|
171
|
+
* For the same reason a form that repeats `target_project_id`, or uses a
|
|
172
|
+
* variant such as `target_project_id[]`, is denied.
|
|
173
|
+
*/
|
|
174
|
+
declare const mergeRequestBodyProblem: (body: unknown, resolvedProjectId: number) => string | undefined;
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region src/bond/receive-pack.d.ts
|
|
177
|
+
declare const ZERO_OID: string;
|
|
178
|
+
interface ReceivePackCommand {
|
|
179
|
+
readonly oldId: string;
|
|
180
|
+
readonly newId: string;
|
|
181
|
+
readonly ref: string;
|
|
182
|
+
}
|
|
183
|
+
interface ReceivePackHead {
|
|
184
|
+
readonly commands: readonly ReceivePackCommand[];
|
|
185
|
+
readonly capabilities: readonly string[];
|
|
186
|
+
readonly options: readonly string[];
|
|
187
|
+
/** Bytes consumed by the head. The pack starts here. */
|
|
188
|
+
readonly headLength: number;
|
|
189
|
+
}
|
|
190
|
+
type ReceivePackParse = {
|
|
191
|
+
readonly _tag: "Complete";
|
|
192
|
+
readonly head: ReceivePackHead;
|
|
193
|
+
} | {
|
|
194
|
+
readonly _tag: "Incomplete";
|
|
195
|
+
} | {
|
|
196
|
+
readonly _tag: "Malformed";
|
|
197
|
+
readonly reason: string;
|
|
198
|
+
};
|
|
199
|
+
/** Bounds on a hostile head. Exceeding one is Malformed, never Incomplete. */
|
|
200
|
+
interface ReceivePackLimits {
|
|
201
|
+
/** Default 1 MiB. */
|
|
202
|
+
readonly maxHeadBytes?: number;
|
|
203
|
+
/** Default 1000. */
|
|
204
|
+
readonly maxCommands?: number;
|
|
205
|
+
/** Default 100. */
|
|
206
|
+
readonly maxOptions?: number;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* A strict subset of `git check-ref-format`: a full `refs/` name with no
|
|
210
|
+
* control characters, no characters git forbids, no empty, dot-leading, or
|
|
211
|
+
* `.lock` components, no `..`, and no `@{`.
|
|
212
|
+
*/
|
|
213
|
+
declare const isValidRefName: (ref: string) => boolean;
|
|
214
|
+
interface ReceivePackHeadParser {
|
|
215
|
+
/** Feeds the next chunk of the request body. */
|
|
216
|
+
readonly push: (chunk: Uint8Array) => ReceivePackParse;
|
|
217
|
+
/**
|
|
218
|
+
* Bytes after the head in the chunk that completed it: the start of the
|
|
219
|
+
* pack. Later chunks are not buffered; stream them upstream directly.
|
|
220
|
+
*/
|
|
221
|
+
readonly remainder: () => Uint8Array;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Incremental receive-pack head parser. Each byte is examined once, and only
|
|
225
|
+
* an unfinished pkt-line is buffered, so a head fed in many small chunks
|
|
226
|
+
* costs linear time. Capabilities are the union over every command line, as
|
|
227
|
+
* in git's `read_head`: a client cannot hide `push-options` behind a later
|
|
228
|
+
* line without them.
|
|
229
|
+
*/
|
|
230
|
+
declare const makeReceivePackHeadParser: (limits?: ReceivePackLimits) => ReceivePackHeadParser;
|
|
231
|
+
/**
|
|
232
|
+
* Parses as much of the receive-pack head as `bytes` holds. A convenience
|
|
233
|
+
* for a buffered prefix; streaming proxies should use
|
|
234
|
+
* `makeReceivePackHeadParser` and feed chunks as they arrive.
|
|
235
|
+
*/
|
|
236
|
+
declare const parseReceivePackHead: (bytes: Uint8Array, limits?: ReceivePackLimits) => ReceivePackParse;
|
|
237
|
+
interface PushPolicy {
|
|
238
|
+
/** The project's default branch name, refreshed from GitLab by project ID. */
|
|
239
|
+
readonly defaultBranch: string;
|
|
240
|
+
/** Allow pushing to the default branch. Default false. */
|
|
241
|
+
readonly allowDefaultBranch?: boolean;
|
|
242
|
+
/** Only branches with this prefix may be updated, when set. */
|
|
243
|
+
readonly branchPrefix?: string;
|
|
244
|
+
/** Label every merge request created by push option must carry. */
|
|
245
|
+
readonly requiredMergeRequestLabel: string;
|
|
246
|
+
/** Whether `merge_request.*` options are allowed at all (the `open_mr` grant). */
|
|
247
|
+
readonly allowMergeRequestOptions: boolean;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Returns the reason a push is denied, or undefined when it is allowed.
|
|
251
|
+
* Denies tags and other non-branch refs, deletions, the default branch, and
|
|
252
|
+
* any push option outside the merge request allow-list. GitLab still applies
|
|
253
|
+
* its own branch protection afterwards.
|
|
254
|
+
*/
|
|
255
|
+
declare const evaluatePush: (head: ReceivePackHead, policy: PushPolicy) => string | undefined;
|
|
256
|
+
//#endregion
|
|
257
|
+
//#region src/bond/attribution.d.ts
|
|
258
|
+
interface CommitIdentity {
|
|
259
|
+
readonly name: string;
|
|
260
|
+
readonly email: string;
|
|
261
|
+
}
|
|
262
|
+
/** The commit author for a GitLab user: their name and `commit_email`. */
|
|
263
|
+
declare const commitAuthor: (user: {
|
|
264
|
+
readonly name: string;
|
|
265
|
+
readonly username: string;
|
|
266
|
+
readonly commitEmail?: string;
|
|
267
|
+
}) => CommitIdentity;
|
|
268
|
+
/** `Assisted-by: <app> <session URL>`, added to every commit. */
|
|
269
|
+
declare const assistedByTrailer: (appName: string, sessionUrl: string) => string;
|
|
270
|
+
/** `Co-authored-by` for a participant or, with the app principal, the requester. */
|
|
271
|
+
declare const coAuthoredByTrailer: (who: CommitIdentity) => string;
|
|
272
|
+
/** Description footer for merge requests and comments. */
|
|
273
|
+
declare const mergeRequestFooter: (input: {
|
|
274
|
+
readonly appName: string;
|
|
275
|
+
readonly sessionUrl: string;
|
|
276
|
+
/** Username of the requesting user; set when the app principal authors. */
|
|
277
|
+
readonly requestedBy?: string;
|
|
278
|
+
}) => string;
|
|
279
|
+
/** `git push -o` options that create a labelled merge request. */
|
|
280
|
+
declare const mergeRequestPushOptions: (input: {
|
|
281
|
+
readonly target: string;
|
|
282
|
+
readonly title: string;
|
|
283
|
+
readonly description: string;
|
|
284
|
+
readonly label: string;
|
|
285
|
+
}) => readonly string[];
|
|
286
|
+
//#endregion
|
|
287
|
+
//#region src/bond/provider.d.ts
|
|
288
|
+
interface GitLabBondProviderOptions {
|
|
289
|
+
readonly fetch?: Fetch;
|
|
290
|
+
readonly clock?: () => string;
|
|
291
|
+
/** Resolves `oauth.clientSecret` references. Omit for public clients. */
|
|
292
|
+
readonly resolveSecret?: (ref: SecretRef) => Effect.Effect<string, unknown>;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Bond's GitLab provider. A configured `oauth.clientSecret` requires
|
|
296
|
+
* `resolveSecret`; the provider never silently degrades to a public client. GitLab has no delegation marker, so user-principal
|
|
297
|
+
* writes need the ProviderApp's `allowUserPrincipalOutput`. The app principal
|
|
298
|
+
* is a registered bot credential stored on the Installation; GitLab 17.1
|
|
299
|
+
* cannot rotate it from the bot itself, so an administrator replaces it.
|
|
300
|
+
*/
|
|
301
|
+
declare const makeGitLabBondProvider: (options?: GitLabBondProviderOptions) => BondProvider;
|
|
302
|
+
//#endregion
|
|
303
|
+
export { type AuthorizationUrlInput, type CommitIdentity, type Fetch, type GitLabBondProviderOptions, type GitLabInstance, type GitLabOperation, type GitLabRequestClass, type GitLabTokenInfo, type GitLabUser, type OAuthClient, type Pkce, type ProjectRef, type PushPolicy, type ReceivePackCommand, type ReceivePackHead, type ReceivePackHeadParser, type ReceivePackLimits, type ReceivePackParse, type TokenPolicy, type TokenProblem, ZERO_OID, assistedByTrailer, authorizationUrl, canonicalOrigin, classifyGitLabRequest, coAuthoredByTrailer, commitAuthor, createPkce, discoverInstance, evaluatePush, exchangeCode, isValidRefName, makeGitLabBondProvider, makeReceivePackHeadParser, mergeRequestBodyProblem, mergeRequestFooter, mergeRequestPushOptions, parseReceivePackHead, readTokenInfo, readUser, refreshAccessToken, revokeSelfToken, revokeToken, tokenExpiryInstant, validateBotCredential, validatePersonalAccessToken };
|
|
304
|
+
//# sourceMappingURL=index.d.ts.map
|