@uapkg/cli 1.1.10 → 1.3.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.
Files changed (165) hide show
  1. package/dist/app/CompositionRoot.d.ts +6 -0
  2. package/dist/app/CompositionRoot.d.ts.map +1 -1
  3. package/dist/app/CompositionRoot.js +16 -0
  4. package/dist/app/CompositionRoot.js.map +1 -1
  5. package/dist/app/UAPKGApplication.d.ts.map +1 -1
  6. package/dist/app/UAPKGApplication.js +62 -2
  7. package/dist/app/UAPKGApplication.js.map +1 -1
  8. package/dist/build/BuildMetadata.d.ts +12 -0
  9. package/dist/build/BuildMetadata.d.ts.map +1 -0
  10. package/dist/build/BuildMetadata.js +6 -0
  11. package/dist/cli/UAPKGCommandLine.d.ts +98 -3
  12. package/dist/cli/UAPKGCommandLine.d.ts.map +1 -1
  13. package/dist/cli/UAPKGCommandLine.js +69 -0
  14. package/dist/cli/UAPKGCommandLine.js.map +1 -1
  15. package/dist/cli/parsing/UAPKGCommandLineParser.d.ts.map +1 -1
  16. package/dist/cli/parsing/UAPKGCommandLineParser.js +8 -1
  17. package/dist/cli/parsing/UAPKGCommandLineParser.js.map +1 -1
  18. package/dist/cli/parsing/UAPKGParserRegistry.d.ts.map +1 -1
  19. package/dist/cli/parsing/UAPKGParserRegistry.js +12 -0
  20. package/dist/cli/parsing/UAPKGParserRegistry.js.map +1 -1
  21. package/dist/cli/parsing/modules/LifecycleCommandModule.d.ts +11 -0
  22. package/dist/cli/parsing/modules/LifecycleCommandModule.d.ts.map +1 -0
  23. package/dist/cli/parsing/modules/LifecycleCommandModule.js +56 -0
  24. package/dist/cli/parsing/modules/LifecycleCommandModule.js.map +1 -0
  25. package/dist/cli/parsing/modules/LoginCommandModule.d.ts +7 -0
  26. package/dist/cli/parsing/modules/LoginCommandModule.d.ts.map +1 -0
  27. package/dist/cli/parsing/modules/LoginCommandModule.js +34 -0
  28. package/dist/cli/parsing/modules/LoginCommandModule.js.map +1 -0
  29. package/dist/cli/parsing/modules/LogoutCommandModule.d.ts +7 -0
  30. package/dist/cli/parsing/modules/LogoutCommandModule.d.ts.map +1 -0
  31. package/dist/cli/parsing/modules/LogoutCommandModule.js +29 -0
  32. package/dist/cli/parsing/modules/LogoutCommandModule.js.map +1 -0
  33. package/dist/cli/parsing/modules/PublishCommandModule.d.ts +7 -0
  34. package/dist/cli/parsing/modules/PublishCommandModule.d.ts.map +1 -0
  35. package/dist/cli/parsing/modules/PublishCommandModule.js +50 -0
  36. package/dist/cli/parsing/modules/PublishCommandModule.js.map +1 -0
  37. package/dist/cli/parsing/modules/RegistryCommandModule.d.ts.map +1 -1
  38. package/dist/cli/parsing/modules/RegistryCommandModule.js +31 -2
  39. package/dist/cli/parsing/modules/RegistryCommandModule.js.map +1 -1
  40. package/dist/cli/parsing/modules/RequestsCommandModule.d.ts +7 -0
  41. package/dist/cli/parsing/modules/RequestsCommandModule.d.ts.map +1 -0
  42. package/dist/cli/parsing/modules/RequestsCommandModule.js +63 -0
  43. package/dist/cli/parsing/modules/RequestsCommandModule.js.map +1 -0
  44. package/dist/cli/parsing/modules/WhoamiCommandModule.d.ts +7 -0
  45. package/dist/cli/parsing/modules/WhoamiCommandModule.d.ts.map +1 -0
  46. package/dist/cli/parsing/modules/WhoamiCommandModule.js +29 -0
  47. package/dist/cli/parsing/modules/WhoamiCommandModule.js.map +1 -0
  48. package/dist/cli-bootstrap.d.ts +2 -0
  49. package/dist/cli-bootstrap.d.ts.map +1 -0
  50. package/dist/cli-bootstrap.js +17 -0
  51. package/dist/cli-bootstrap.js.map +1 -0
  52. package/dist/cli.js +24 -17
  53. package/dist/commands/InstallCommand.d.ts.map +1 -1
  54. package/dist/commands/InstallCommand.js +21 -6
  55. package/dist/commands/InstallCommand.js.map +1 -1
  56. package/dist/commands/LoginCommand.d.ts +17 -0
  57. package/dist/commands/LoginCommand.d.ts.map +1 -0
  58. package/dist/commands/LoginCommand.js +73 -0
  59. package/dist/commands/LoginCommand.js.map +1 -0
  60. package/dist/commands/LogoutCommand.d.ts +15 -0
  61. package/dist/commands/LogoutCommand.d.ts.map +1 -0
  62. package/dist/commands/LogoutCommand.js +38 -0
  63. package/dist/commands/LogoutCommand.js.map +1 -0
  64. package/dist/commands/PackageLifecycleCommand.d.ts +28 -0
  65. package/dist/commands/PackageLifecycleCommand.d.ts.map +1 -0
  66. package/dist/commands/PackageLifecycleCommand.js +143 -0
  67. package/dist/commands/PackageLifecycleCommand.js.map +1 -0
  68. package/dist/commands/PostinstallCandidateBuilder.d.ts +1 -1
  69. package/dist/commands/PostinstallCandidateBuilder.d.ts.map +1 -1
  70. package/dist/commands/PostinstallCandidateBuilder.js +4 -1
  71. package/dist/commands/PostinstallCandidateBuilder.js.map +1 -1
  72. package/dist/commands/PublishCommand.d.ts +32 -0
  73. package/dist/commands/PublishCommand.d.ts.map +1 -0
  74. package/dist/commands/PublishCommand.js +270 -0
  75. package/dist/commands/PublishCommand.js.map +1 -0
  76. package/dist/commands/RegistryCommand.d.ts +13 -3
  77. package/dist/commands/RegistryCommand.d.ts.map +1 -1
  78. package/dist/commands/RegistryCommand.js +115 -11
  79. package/dist/commands/RegistryCommand.js.map +1 -1
  80. package/dist/commands/RequestsCommand.d.ts +21 -0
  81. package/dist/commands/RequestsCommand.d.ts.map +1 -0
  82. package/dist/commands/RequestsCommand.js +98 -0
  83. package/dist/commands/RequestsCommand.js.map +1 -0
  84. package/dist/commands/WhoamiCommand.d.ts +32 -0
  85. package/dist/commands/WhoamiCommand.d.ts.map +1 -0
  86. package/dist/commands/WhoamiCommand.js +75 -0
  87. package/dist/commands/WhoamiCommand.js.map +1 -0
  88. package/dist/commands/add/DependencyAddResolver.d.ts.map +1 -1
  89. package/dist/commands/add/DependencyAddResolver.js +4 -2
  90. package/dist/commands/add/DependencyAddResolver.js.map +1 -1
  91. package/dist/control-plane/AccountManager.d.ts +110 -0
  92. package/dist/control-plane/AccountManager.d.ts.map +1 -0
  93. package/dist/control-plane/AccountManager.js +1014 -0
  94. package/dist/control-plane/AccountManager.js.map +1 -0
  95. package/dist/control-plane/ArtifactObserver.d.ts +24 -0
  96. package/dist/control-plane/ArtifactObserver.d.ts.map +1 -0
  97. package/dist/control-plane/ArtifactObserver.js +63 -0
  98. package/dist/control-plane/ArtifactObserver.js.map +1 -0
  99. package/dist/control-plane/AuthMetadataStore.d.ts +15 -0
  100. package/dist/control-plane/AuthMetadataStore.d.ts.map +1 -0
  101. package/dist/control-plane/AuthMetadataStore.js +116 -0
  102. package/dist/control-plane/AuthMetadataStore.js.map +1 -0
  103. package/dist/control-plane/AuthStoragePaths.d.ts +11 -0
  104. package/dist/control-plane/AuthStoragePaths.d.ts.map +1 -0
  105. package/dist/control-plane/AuthStoragePaths.js +17 -0
  106. package/dist/control-plane/AuthStoragePaths.js.map +1 -0
  107. package/dist/control-plane/AuthenticationSelector.d.ts +21 -0
  108. package/dist/control-plane/AuthenticationSelector.d.ts.map +1 -0
  109. package/dist/control-plane/AuthenticationSelector.js +64 -0
  110. package/dist/control-plane/AuthenticationSelector.js.map +1 -0
  111. package/dist/control-plane/ControlPlaneClient.d.ts +32 -0
  112. package/dist/control-plane/ControlPlaneClient.d.ts.map +1 -0
  113. package/dist/control-plane/ControlPlaneClient.js +280 -0
  114. package/dist/control-plane/ControlPlaneClient.js.map +1 -0
  115. package/dist/control-plane/ControlPlaneEndpoints.d.ts +13 -0
  116. package/dist/control-plane/ControlPlaneEndpoints.d.ts.map +1 -0
  117. package/dist/control-plane/ControlPlaneEndpoints.js +19 -0
  118. package/dist/control-plane/ControlPlaneEndpoints.js.map +1 -0
  119. package/dist/control-plane/ControlPlaneTypes.d.ts +168 -0
  120. package/dist/control-plane/ControlPlaneTypes.d.ts.map +1 -0
  121. package/dist/control-plane/ControlPlaneTypes.js +93 -0
  122. package/dist/control-plane/ControlPlaneTypes.js.map +1 -0
  123. package/dist/control-plane/CredentialStore.d.ts +28 -0
  124. package/dist/control-plane/CredentialStore.d.ts.map +1 -0
  125. package/dist/control-plane/CredentialStore.js +87 -0
  126. package/dist/control-plane/CredentialStore.js.map +1 -0
  127. package/dist/control-plane/DPoPKeyStore.d.ts +11 -0
  128. package/dist/control-plane/DPoPKeyStore.d.ts.map +1 -0
  129. package/dist/control-plane/DPoPKeyStore.js +54 -0
  130. package/dist/control-plane/DPoPKeyStore.js.map +1 -0
  131. package/dist/control-plane/GitHubActionsOidcCredentialProvider.d.ts +6 -0
  132. package/dist/control-plane/GitHubActionsOidcCredentialProvider.d.ts.map +1 -0
  133. package/dist/control-plane/GitHubActionsOidcCredentialProvider.js +67 -0
  134. package/dist/control-plane/GitHubActionsOidcCredentialProvider.js.map +1 -0
  135. package/dist/control-plane/PublishIdempotencyStore.d.ts +18 -0
  136. package/dist/control-plane/PublishIdempotencyStore.d.ts.map +1 -0
  137. package/dist/control-plane/PublishIdempotencyStore.js +71 -0
  138. package/dist/control-plane/PublishIdempotencyStore.js.map +1 -0
  139. package/dist/control-plane/RegistryGrantLock.d.ts +35 -0
  140. package/dist/control-plane/RegistryGrantLock.d.ts.map +1 -0
  141. package/dist/control-plane/RegistryGrantLock.js +199 -0
  142. package/dist/control-plane/RegistryGrantLock.js.map +1 -0
  143. package/dist/control-plane/RegistryTrustResolver.d.ts +17 -0
  144. package/dist/control-plane/RegistryTrustResolver.d.ts.map +1 -0
  145. package/dist/control-plane/RegistryTrustResolver.js +140 -0
  146. package/dist/control-plane/RegistryTrustResolver.js.map +1 -0
  147. package/dist/index.d.ts +16 -3
  148. package/dist/index.d.ts.map +1 -1
  149. package/dist/index.js +16 -2
  150. package/dist/index.js.map +1 -1
  151. package/dist/postinstall/markers/MarkerIntegrityValidator.d.ts +1 -1
  152. package/dist/prompts/InkPromptService.d.ts +1 -0
  153. package/dist/prompts/InkPromptService.d.ts.map +1 -1
  154. package/dist/prompts/InkPromptService.js +20 -0
  155. package/dist/prompts/InkPromptService.js.map +1 -1
  156. package/dist/prompts/PromptService.d.ts +2 -0
  157. package/dist/prompts/PromptService.d.ts.map +1 -1
  158. package/dist/reporting/JsonReporter.d.ts +2 -0
  159. package/dist/reporting/JsonReporter.d.ts.map +1 -1
  160. package/dist/reporting/JsonReporter.js +6 -0
  161. package/dist/reporting/JsonReporter.js.map +1 -1
  162. package/package.json +21 -15
  163. package/dist/cli.d.ts +0 -3
  164. package/dist/cli.d.ts.map +0 -1
  165. package/dist/cli.js.map +0 -1
@@ -0,0 +1,280 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import * as oauth from 'oauth4webapi';
3
+ import { z } from 'zod';
4
+ import { ControlPlaneError, isOAuthScopeToken, isUAPKGCliScope, knownUAPKGCliScopes, OAuthScopeInsufficientError, OAuthScopeUnsupportedError, parseOAuthScopeTokens, UAPKG_CONTROL_PLANE_API, } from './ControlPlaneTypes.js';
5
+ const errorSchema = z.object({
6
+ ok: z.literal(false),
7
+ error: z.object({
8
+ code: z.string(),
9
+ message: z.string(),
10
+ details: z.record(z.string(), z.unknown()).optional(),
11
+ }),
12
+ });
13
+ const insufficientScopeDetailsSchema = z.object({
14
+ requiredScopes: z.array(z.string()),
15
+ missingScopes: z.array(z.string()),
16
+ });
17
+ const accountSchema = z.object({
18
+ id: z.uuid(),
19
+ username: z.string().min(1),
20
+ displayName: z.string().min(1),
21
+ });
22
+ const accountGrantSchema = z.object({
23
+ id: z.uuid(),
24
+ deviceName: z.string().min(1),
25
+ idleExpiresAt: z.iso.datetime(),
26
+ absoluteExpiresAt: z.iso.datetime(),
27
+ scopes: z.array(z.string()),
28
+ });
29
+ const accountResponseSchema = z.object({
30
+ ok: z.literal(true),
31
+ account: accountSchema,
32
+ registry: z.object({
33
+ id: z.uuid(),
34
+ }),
35
+ grant: accountGrantSchema,
36
+ });
37
+ const cliLoginConfirmationResponseSchema = accountResponseSchema.extend({
38
+ grant: accountGrantSchema.extend({
39
+ status: z.enum(['pending', 'active']),
40
+ activationExpiresAt: z.iso.datetime(),
41
+ replacesGrantId: z.uuid().nullable(),
42
+ }),
43
+ });
44
+ const activatedCliLoginResponseSchema = z.object({
45
+ ok: z.literal(true),
46
+ grant: z.object({
47
+ id: z.uuid(),
48
+ status: z.literal('active'),
49
+ replacesGrantId: z.uuid().nullable(),
50
+ }),
51
+ });
52
+ const requestStatusSchema = z.enum([
53
+ 'queued',
54
+ 'checking',
55
+ 'accepted',
56
+ 'ready',
57
+ 'ready_superseded',
58
+ 'rejected',
59
+ 'operationally_failed',
60
+ ]);
61
+ const requestSummarySchema = z
62
+ .object({
63
+ id: z.string().min(1),
64
+ registryId: z.string().min(1),
65
+ kind: z.string().min(1),
66
+ status: requestStatusSchema,
67
+ currentStep: z.string().optional(),
68
+ createdAt: z.number().optional(),
69
+ updatedAt: z.number().optional(),
70
+ payload: z
71
+ .object({
72
+ packageName: z.string().optional(),
73
+ packageVersion: z.string().optional(),
74
+ })
75
+ .passthrough()
76
+ .optional(),
77
+ })
78
+ .passthrough();
79
+ export class ControlPlaneClient {
80
+ apiBaseUrl;
81
+ constructor(apiBaseUrl = UAPKG_CONTROL_PLANE_API) {
82
+ const normalized = new URL(apiBaseUrl).href.replace(/\/+$/, '');
83
+ if (normalized !== UAPKG_CONTROL_PLANE_API) {
84
+ throw new Error(`UAPKG v1 control-plane requests are pinned to ${UAPKG_CONTROL_PLANE_API}.`);
85
+ }
86
+ this.apiBaseUrl = normalized;
87
+ }
88
+ async getSelf(credential, signal) {
89
+ const value = await this.requestJson(credential, 'GET', '/v1/account/self', { signal });
90
+ const parsed = accountResponseSchema.safeParse(value);
91
+ if (!parsed.success) {
92
+ throw new ControlPlaneError('ACCOUNT_SELF_RESPONSE_INVALID', 'The account identity response was invalid.');
93
+ }
94
+ return {
95
+ account: parsed.data.account,
96
+ registry: parsed.data.registry,
97
+ grant: parsed.data.grant,
98
+ };
99
+ }
100
+ async getCliLoginConfirmation(credential, signal) {
101
+ const value = await this.requestJson(credential, 'GET', '/v1/account/cli-login/confirmation', { signal });
102
+ const parsed = cliLoginConfirmationResponseSchema.safeParse(value);
103
+ if (!parsed.success) {
104
+ throw new ControlPlaneError('CLI_LOGIN_CONFIRMATION_RESPONSE_INVALID', 'The CLI login confirmation response was invalid.');
105
+ }
106
+ return {
107
+ account: parsed.data.account,
108
+ registry: parsed.data.registry,
109
+ grant: parsed.data.grant,
110
+ };
111
+ }
112
+ async confirmCliLogin(credential, signal) {
113
+ const value = await this.requestJson(credential, 'POST', '/v1/account/cli-login/confirmation', { signal });
114
+ const parsed = activatedCliLoginResponseSchema.safeParse(value);
115
+ if (!parsed.success) {
116
+ throw new ControlPlaneError('CLI_LOGIN_CONFIRMATION_RESPONSE_INVALID', 'The CLI login confirmation response was invalid.');
117
+ }
118
+ return parsed.data.grant;
119
+ }
120
+ async submitRegistryRequest(credential, operation, submission, options = {}) {
121
+ const value = await this.requestJson(credential, 'POST', `/v1/registry-requests/${encodeURIComponent(operation)}`, {
122
+ body: JSON.stringify(submission),
123
+ headers: {
124
+ 'content-type': 'application/json',
125
+ 'x-uapkg-idempotency-key': options.idempotencyKey ?? randomUUID(),
126
+ ...(options.otp ? { 'x-uapkg-otp': options.otp } : {}),
127
+ },
128
+ });
129
+ const parsed = z
130
+ .object({
131
+ ok: z.literal(true),
132
+ requestId: z.string().min(1),
133
+ status: requestStatusSchema,
134
+ message: z.string(),
135
+ })
136
+ .safeParse(value);
137
+ if (!parsed.success) {
138
+ throw new ControlPlaneError('REGISTRY_REQUEST_RESPONSE_INVALID', 'The publishing request response was invalid.');
139
+ }
140
+ return parsed.data;
141
+ }
142
+ async getRegistryRequest(credential, requestId) {
143
+ const value = await this.requestJson(credential, 'GET', `/v1/registry-requests/${encodeURIComponent(requestId)}`);
144
+ const parsed = z.object({ ok: z.literal(true), request: requestSummarySchema }).safeParse(value);
145
+ if (!parsed.success) {
146
+ throw new ControlPlaneError('REGISTRY_REQUEST_RESPONSE_INVALID', 'The publishing request response was invalid.');
147
+ }
148
+ return parsed.data.request;
149
+ }
150
+ async listRegistryRequests(credential, registryId, status) {
151
+ const query = new URLSearchParams({ registryId });
152
+ if (status)
153
+ query.set('status', status);
154
+ const value = await this.requestJson(credential, 'GET', `/v1/registry-requests?${query}`);
155
+ const parsed = z
156
+ .object({
157
+ ok: z.literal(true),
158
+ recentRequests: z.array(requestSummarySchema).optional(),
159
+ requests: z.array(requestSummarySchema).optional(),
160
+ })
161
+ .safeParse(value);
162
+ if (!parsed.success || (!parsed.data.recentRequests && !parsed.data.requests)) {
163
+ throw new ControlPlaneError('REGISTRY_REQUEST_LIST_RESPONSE_INVALID', 'The publishing request list response was invalid.');
164
+ }
165
+ return parsed.data.recentRequests ?? parsed.data.requests ?? [];
166
+ }
167
+ async requestJson(credential, method, path, init = {}) {
168
+ const url = new URL(path, this.apiBaseUrl);
169
+ const headers = new Headers(init.headers);
170
+ let response;
171
+ if (credential.kind === 'dpop') {
172
+ try {
173
+ response = await this.withDPoPNonceRetry(() => oauth.protectedResourceRequest(credential.accessToken, method, url, headers, init.body, {
174
+ DPoP: credential.dpop,
175
+ signal: boundedRequestSignal(init.signal),
176
+ }));
177
+ }
178
+ catch (error) {
179
+ if (error instanceof oauth.WWWAuthenticateChallengeError) {
180
+ throw await controlPlaneChallengeError(error, credential);
181
+ }
182
+ throw error;
183
+ }
184
+ }
185
+ else {
186
+ headers.set('authorization', `Bearer ${credential.accessToken}`);
187
+ response = await fetch(url, {
188
+ method,
189
+ headers,
190
+ body: init.body,
191
+ redirect: 'error',
192
+ signal: boundedRequestSignal(init.signal),
193
+ });
194
+ }
195
+ const value = await readJson(response);
196
+ if (!response.ok) {
197
+ const parsed = errorSchema.safeParse(value);
198
+ if (parsed.success) {
199
+ throw new ControlPlaneError(parsed.data.error.code, parsed.data.error.message, response.status, parsed.data.error.details);
200
+ }
201
+ throw new ControlPlaneError(`HTTP_${response.status}`, `The UAPKG control plane returned HTTP ${response.status}.`, response.status);
202
+ }
203
+ return value;
204
+ }
205
+ async withDPoPNonceRetry(operation) {
206
+ try {
207
+ return await operation();
208
+ }
209
+ catch (error) {
210
+ if (!oauth.isDPoPNonceError(error))
211
+ throw error;
212
+ return operation();
213
+ }
214
+ }
215
+ }
216
+ function boundedRequestSignal(signal) {
217
+ const timeout = AbortSignal.timeout(30_000);
218
+ return signal ? AbortSignal.any([signal, timeout]) : timeout;
219
+ }
220
+ async function readJson(response) {
221
+ const text = await response.text();
222
+ if (text.trim().length === 0)
223
+ return {};
224
+ try {
225
+ return JSON.parse(text);
226
+ }
227
+ catch (error) {
228
+ throw new ControlPlaneError('CONTROL_PLANE_RESPONSE_NOT_JSON', `The UAPKG control plane returned a non-JSON response (HTTP ${response.status}).`, response.status, undefined, { cause: error });
229
+ }
230
+ }
231
+ async function controlPlaneChallengeError(error, credential) {
232
+ const value = await tryReadJson(error.response);
233
+ const parsed = errorSchema.safeParse(value);
234
+ if (error.status === 403 && parsed.success && parsed.data.error.code === 'OAUTH_SCOPE_INSUFFICIENT') {
235
+ const details = insufficientScopeDetailsSchema.safeParse(parsed.data.error.details);
236
+ if (details.success) {
237
+ const headerRequiredScopeTokens = error.cause.flatMap((challenge) => challenge.scheme === 'dpop' && challenge.parameters.error === 'insufficient_scope'
238
+ ? parseOAuthScopeTokens(challenge.parameters.scope)
239
+ : []);
240
+ const bodyRequiredScopeTokens = validatedOAuthScopeTokens(details.data.requiredScopes);
241
+ const bodyMissingScopeTokens = validatedOAuthScopeTokens(details.data.missingScopes);
242
+ if (bodyRequiredScopeTokens && bodyMissingScopeTokens) {
243
+ const consistentRequiredScopeTokens = headerRequiredScopeTokens.filter((scope) => bodyRequiredScopeTokens.includes(scope));
244
+ const consistentMissingScopeTokens = consistentRequiredScopeTokens.filter((scope) => bodyMissingScopeTokens.includes(scope));
245
+ const requestedScopes = knownUAPKGCliScopes(credential.requestedScopes);
246
+ if (consistentMissingScopeTokens.some((scope) => !isUAPKGCliScope(scope))) {
247
+ return new OAuthScopeUnsupportedError(credential.registryAlias, requestedScopes, [], {
248
+ cause: error,
249
+ reason: 'cli-update-required',
250
+ status: error.status,
251
+ });
252
+ }
253
+ const requiredScopes = knownUAPKGCliScopes(consistentRequiredScopeTokens);
254
+ const missingScopes = knownUAPKGCliScopes(consistentMissingScopeTokens).filter((scope) => requestedScopes.includes(scope));
255
+ if (requiredScopes.length > 0 && missingScopes.length > 0) {
256
+ return new OAuthScopeInsufficientError(parsed.data.error.message, credential.registryAlias, requestedScopes, requiredScopes, missingScopes, error.status, { cause: error });
257
+ }
258
+ }
259
+ }
260
+ }
261
+ if (parsed.success) {
262
+ return new ControlPlaneError(parsed.data.error.code, parsed.data.error.message, error.status, parsed.data.error.details, { cause: error });
263
+ }
264
+ return new ControlPlaneError('CONTROL_PLANE_AUTHENTICATION_REQUIRED', 'The UAPKG control plane rejected the saved login.', error.status, undefined, { cause: error });
265
+ }
266
+ function validatedOAuthScopeTokens(values) {
267
+ if (values.some((scope) => !isOAuthScopeToken(scope)))
268
+ return undefined;
269
+ return [...new Set(values)];
270
+ }
271
+ async function tryReadJson(response) {
272
+ try {
273
+ const text = await response.text();
274
+ return text.trim().length > 0 ? JSON.parse(text) : undefined;
275
+ }
276
+ catch {
277
+ return undefined;
278
+ }
279
+ }
280
+ //# sourceMappingURL=ControlPlaneClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ControlPlaneClient.js","sourceRoot":"","sources":["../../src/control-plane/ControlPlaneClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAIL,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACnB,2BAA2B,EAC3B,0BAA0B,EAC1B,qBAAqB,EAKrB,uBAAuB,GAExB,MAAM,wBAAwB,CAAC;AAehC,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;IACpB,KAAK,EAAE,CAAC,CA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AAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,IAAI,iBAAiB,CAC1B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EACtB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EACzB,KAAK,CAAC,MAAM,EACZ,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EACzB,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,iBAAiB,CAC1B,uCAAuC,EACvC,mDAAmD,EACnD,KAAK,CAAC,MAAM,EACZ,SAAS,EACT,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;AACJ,CAAC;AAED,SAAS,yBAAyB,CAAC,MAAyB;IAC1D,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;QAAE,OAAO,SAAS,CAAC;IACxE,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;AAC9B,CAAC;AAED,KAAK,UAAU,WAAW,CAAC,QAAkB;IAC3C,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACnC,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAa,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { UAPKGBuildMode } from '@uapkg/common';
2
+ export interface UAPKGControlPlaneEndpoints {
3
+ readonly issuer: string;
4
+ readonly apiBaseUrl: string;
5
+ }
6
+ /**
7
+ * Only an explicitly stamped development build can select development trust
8
+ * roots. Source execution and any unrecognized runtime value fail closed to
9
+ * the production control plane.
10
+ */
11
+ export declare function controlPlaneEndpointsForBuildMode(mode: UAPKGBuildMode): UAPKGControlPlaneEndpoints;
12
+ export declare const UAPKG_CONTROL_PLANE_ENDPOINTS: UAPKGControlPlaneEndpoints;
13
+ //# sourceMappingURL=ControlPlaneEndpoints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ControlPlaneEndpoints.d.ts","sourceRoot":"","sources":["../../src/control-plane/ControlPlaneEndpoints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpD,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAYD;;;;GAIG;AACH,wBAAgB,iCAAiC,CAAC,IAAI,EAAE,cAAc,GAAG,0BAA0B,CAElG;AAED,eAAO,MAAM,6BAA6B,4BAA+D,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { UAPKG_BUILD_METADATA } from '../build/BuildMetadata.js';
2
+ const DEVELOPMENT_ENDPOINTS = Object.freeze({
3
+ issuer: 'https://account-dev.uapkg.dev/oauth',
4
+ apiBaseUrl: 'https://api-dev.uapkg.dev',
5
+ });
6
+ const PRODUCTION_ENDPOINTS = Object.freeze({
7
+ issuer: 'https://account.uapkg.dev/oauth',
8
+ apiBaseUrl: 'https://api.uapkg.dev',
9
+ });
10
+ /**
11
+ * Only an explicitly stamped development build can select development trust
12
+ * roots. Source execution and any unrecognized runtime value fail closed to
13
+ * the production control plane.
14
+ */
15
+ export function controlPlaneEndpointsForBuildMode(mode) {
16
+ return mode === 'development' ? DEVELOPMENT_ENDPOINTS : PRODUCTION_ENDPOINTS;
17
+ }
18
+ export const UAPKG_CONTROL_PLANE_ENDPOINTS = controlPlaneEndpointsForBuildMode(UAPKG_BUILD_METADATA.mode);
19
+ //# sourceMappingURL=ControlPlaneEndpoints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ControlPlaneEndpoints.js","sourceRoot":"","sources":["../../src/control-plane/ControlPlaneEndpoints.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAOjE,MAAM,qBAAqB,GAA+B,MAAM,CAAC,MAAM,CAAC;IACtE,MAAM,EAAE,qCAAqC;IAC7C,UAAU,EAAE,2BAA2B;CACxC,CAAC,CAAC;AAEH,MAAM,oBAAoB,GAA+B,MAAM,CAAC,MAAM,CAAC;IACrE,MAAM,EAAE,iCAAiC;IACzC,UAAU,EAAE,uBAAuB;CACpC,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,UAAU,iCAAiC,CAAC,IAAoB;IACpE,OAAO,IAAI,KAAK,aAAa,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,oBAAoB,CAAC;AAC/E,CAAC;AAED,MAAM,CAAC,MAAM,6BAA6B,GAAG,iCAAiC,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,168 @@
1
+ export declare const UAPKG_AUTHORIZATION_ISSUER: string;
2
+ export declare const UAPKG_CONTROL_PLANE_API: string;
3
+ export declare const UAPKG_CLI_CLIENT_ID = "uapkg-cli";
4
+ export declare const UAPKG_GITHUB_OIDC_AUDIENCE = "uapkg";
5
+ export declare const UAPKG_CLI_SCOPES: readonly ["identity.self.read", "publishing.request.create", "publishing.request.read.self", "registry_grant.revoke.self"];
6
+ export type UAPKGCliScope = (typeof UAPKG_CLI_SCOPES)[number];
7
+ export declare function knownUAPKGCliScopes(value: unknown): UAPKGCliScope[];
8
+ export declare function parseUAPKGCliScopeString(value: unknown): UAPKGCliScope[];
9
+ export declare function parseOAuthScopeTokens(value: unknown): string[];
10
+ export declare function isOAuthScopeToken(value: unknown): value is string;
11
+ export declare function isUAPKGCliScope(value: unknown): value is UAPKGCliScope;
12
+ export type ControlPlaneAuthMode = 'auto' | 'login' | 'gat' | 'oidc';
13
+ export interface RegistryTrust {
14
+ readonly alias: string;
15
+ readonly registryId: string;
16
+ readonly registryName: string;
17
+ readonly repositoryUrl: string;
18
+ readonly repositoryFingerprint: string;
19
+ readonly issuer: string;
20
+ readonly apiBaseUrl: string;
21
+ readonly resource: string;
22
+ readonly cacheShortId: string;
23
+ }
24
+ export interface AccountDisplayMetadata {
25
+ readonly id: string;
26
+ readonly username: string;
27
+ readonly displayName: string;
28
+ }
29
+ export interface AccountSelf {
30
+ readonly account: AccountDisplayMetadata;
31
+ readonly registry: {
32
+ readonly id: string;
33
+ };
34
+ readonly grant: {
35
+ readonly id: string;
36
+ readonly deviceName: string;
37
+ readonly idleExpiresAt: string;
38
+ readonly absoluteExpiresAt: string;
39
+ readonly scopes: readonly string[];
40
+ };
41
+ }
42
+ export interface CliLoginConfirmation extends AccountSelf {
43
+ readonly grant: AccountSelf['grant'] & {
44
+ readonly status: 'pending' | 'active';
45
+ readonly activationExpiresAt: string;
46
+ readonly replacesGrantId: string | null;
47
+ };
48
+ }
49
+ export interface ActivatedCliLoginGrant {
50
+ readonly id: string;
51
+ readonly status: 'active';
52
+ readonly replacesGrantId: string | null;
53
+ }
54
+ export interface RegistryGrantMetadata {
55
+ readonly issuer: string;
56
+ readonly registryId: string;
57
+ readonly registryName: string;
58
+ readonly grantId: string;
59
+ readonly clientId: string;
60
+ readonly keyReference: string;
61
+ readonly refreshTokenReference: string;
62
+ readonly publicKeyThumbprint: string;
63
+ readonly deviceName: string;
64
+ readonly repositoryFingerprint: string;
65
+ readonly account: AccountDisplayMetadata;
66
+ readonly createdAt: number;
67
+ readonly idleExpiresAt: number;
68
+ readonly expiresAt: number;
69
+ }
70
+ export interface AuthMetadataFile {
71
+ readonly schemaVersion: 1;
72
+ readonly grants: Readonly<Record<string, RegistryGrantMetadata>>;
73
+ }
74
+ export interface RegistryRequestSource {
75
+ readonly type: 'github_release';
76
+ readonly repository: string;
77
+ readonly releaseTag: string;
78
+ readonly assetName: string;
79
+ }
80
+ /** Artifact integrity observed by this client from the exact bytes it inspected. */
81
+ export interface ObservedArtifactIntegrity {
82
+ /** Exactly `sha256:` + 64 lowercase hex characters. */
83
+ readonly sha256: string;
84
+ readonly sizeBytes: number;
85
+ }
86
+ /** Normalized packaged-manifest claims submitted with a publish request. */
87
+ export interface SubmittedPackageClaims {
88
+ readonly name: string;
89
+ readonly version: string;
90
+ readonly private: boolean;
91
+ readonly dependencies: Readonly<Record<string, {
92
+ readonly version: string;
93
+ readonly registry?: string;
94
+ }>>;
95
+ readonly devDependencies: Readonly<Record<string, {
96
+ readonly version: string;
97
+ readonly registry?: string;
98
+ }>>;
99
+ readonly peerDependencies: Readonly<Record<string, {
100
+ readonly version: string;
101
+ readonly registry?: string;
102
+ }>>;
103
+ }
104
+ /** The six route-derived registry operations (PS-REQ-001). */
105
+ export type RegistryOperation = 'publish' | 'unpublish' | 'yank' | 'unyank' | 'deprecate' | 'undeprecate';
106
+ /**
107
+ * Body for `POST /v1/registry-requests/{operation}`. The operation is
108
+ * derived from the route; the body never carries a kind.
109
+ */
110
+ export interface RegistryRequestSubmission {
111
+ readonly registryId: string;
112
+ readonly ownerOrganizationName?: string;
113
+ readonly payload: {
114
+ readonly packageName: string;
115
+ readonly packageVersion: string;
116
+ readonly source?: RegistryRequestSource;
117
+ readonly observedIntegrity?: ObservedArtifactIntegrity;
118
+ readonly claims?: SubmittedPackageClaims;
119
+ readonly reason?: string;
120
+ };
121
+ }
122
+ export type RegistryRequestStatus = 'queued' | 'checking' | 'accepted' | 'ready' | 'ready_superseded' | 'rejected' | 'operationally_failed';
123
+ export interface RegistryRequestSummary {
124
+ readonly id: string;
125
+ readonly registryId: string;
126
+ readonly kind: string;
127
+ readonly status: RegistryRequestStatus;
128
+ readonly currentStep?: string;
129
+ readonly createdAt?: number;
130
+ readonly updatedAt?: number;
131
+ readonly payload?: {
132
+ readonly packageName?: string;
133
+ readonly packageVersion?: string;
134
+ };
135
+ }
136
+ export interface ControlPlaneApiErrorBody {
137
+ readonly ok: false;
138
+ readonly error: {
139
+ readonly code: string;
140
+ readonly message: string;
141
+ readonly details?: Readonly<Record<string, unknown>>;
142
+ };
143
+ }
144
+ export declare class ControlPlaneError extends Error {
145
+ readonly code: string;
146
+ readonly status?: number | undefined;
147
+ readonly details?: Readonly<Record<string, unknown>> | undefined;
148
+ constructor(code: string, message: string, status?: number | undefined, details?: Readonly<Record<string, unknown>> | undefined, options?: ErrorOptions);
149
+ }
150
+ export declare class OAuthScopeInsufficientError extends ControlPlaneError {
151
+ readonly registryAlias: string;
152
+ readonly requestedScopes: readonly UAPKGCliScope[];
153
+ readonly requiredScopes: readonly UAPKGCliScope[];
154
+ readonly missingScopes: readonly UAPKGCliScope[];
155
+ constructor(message: string, registryAlias: string, requestedScopes: readonly UAPKGCliScope[], requiredScopes: readonly UAPKGCliScope[], missingScopes: readonly UAPKGCliScope[], status?: number, options?: ErrorOptions);
156
+ }
157
+ export declare class OAuthScopeUnsupportedError extends ControlPlaneError {
158
+ readonly registryAlias: string;
159
+ readonly requestedScopes: readonly UAPKGCliScope[];
160
+ readonly unsupportedScopes: readonly UAPKGCliScope[];
161
+ readonly reason: 'issuer-does-not-support-requested-scope' | 'cli-update-required';
162
+ constructor(registryAlias: string, requestedScopes: readonly UAPKGCliScope[], unsupportedScopes: readonly UAPKGCliScope[], options?: ErrorOptions & {
163
+ readonly reason?: 'issuer-does-not-support-requested-scope' | 'cli-update-required';
164
+ readonly status?: number;
165
+ });
166
+ }
167
+ export declare function registryAudience(registryId: string): string;
168
+ //# sourceMappingURL=ControlPlaneTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ControlPlaneTypes.d.ts","sourceRoot":"","sources":["../../src/control-plane/ControlPlaneTypes.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,0BAA0B,QAAuC,CAAC;AAC/E,eAAO,MAAM,uBAAuB,QAA2C,CAAC;AAChF,eAAO,MAAM,mBAAmB,cAAc,CAAC;AAC/C,eAAO,MAAM,0BAA0B,UAA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,eAAe,EAAE,SAAS,aAAa,EAAE,EACzC,cAAc,EAAE,SAAS,aAAa,EAAE,EACxC,aAAa,EAAE,SAAS,aAAa,EAAE,EACvC,MAAM,SAAM,EACZ,OAAO,CAAC,EAAE,YAAY;CAmBzB;AAED,qBAAa,0BAA2B,SAAQ,iBAAiB;aAM7C,aAAa,EAAE,MAAM;IALvC,SAAgB,eAAe,EAAE,SAAS,aAAa,EAAE,CAAC;IAC1D,SAAgB,iBAAiB,EAAE,SAAS,aAAa,EAAE,CAAC;IAC5D,SAAgB,MAAM,EAAE,yCAAyC,GAAG,qBAAqB,CAAC;gBAGxE,aAAa,EAAE,MAAM,EACrC,eAAe,EAAE,SAAS,aAAa,EAAE,EACzC,iBAAiB,EAAE,SAAS,aAAa,EAAE,EAC3C,OAAO,CAAC,EAAE,YAAY,GAAG;QACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,yCAAyC,GAAG,qBAAqB,CAAC;QACpF,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;KAC1B;CAqBJ;AAOD,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAE3D"}
@@ -0,0 +1,93 @@
1
+ import { UAPKG_CONTROL_PLANE_ENDPOINTS } from './ControlPlaneEndpoints.js';
2
+ export const UAPKG_AUTHORIZATION_ISSUER = UAPKG_CONTROL_PLANE_ENDPOINTS.issuer;
3
+ export const UAPKG_CONTROL_PLANE_API = UAPKG_CONTROL_PLANE_ENDPOINTS.apiBaseUrl;
4
+ export const UAPKG_CLI_CLIENT_ID = 'uapkg-cli';
5
+ export const UAPKG_GITHUB_OIDC_AUDIENCE = 'uapkg';
6
+ export const UAPKG_CLI_SCOPES = [
7
+ 'identity.self.read',
8
+ 'publishing.request.create',
9
+ 'publishing.request.read.self',
10
+ 'registry_grant.revoke.self',
11
+ ];
12
+ const UAPKG_CLI_SCOPE_SET = new Set(UAPKG_CLI_SCOPES);
13
+ const OAUTH_SCOPE_TOKEN_PATTERN = /^[\x21\x23-\x5b\x5d-\x7e]+$/;
14
+ export function knownUAPKGCliScopes(value) {
15
+ if (!Array.isArray(value))
16
+ return [];
17
+ const candidates = new Set(value.filter((scope) => typeof scope === 'string'));
18
+ return UAPKG_CLI_SCOPES.filter((scope) => candidates.has(scope));
19
+ }
20
+ export function parseUAPKGCliScopeString(value) {
21
+ return knownUAPKGCliScopes(parseOAuthScopeTokens(value));
22
+ }
23
+ export function parseOAuthScopeTokens(value) {
24
+ if (typeof value !== 'string' || value.length === 0 || value.trim() !== value)
25
+ return [];
26
+ const scopes = value.split(' ');
27
+ if (scopes.some((scope) => !isOAuthScopeToken(scope)))
28
+ return [];
29
+ return [...new Set(scopes)];
30
+ }
31
+ export function isOAuthScopeToken(value) {
32
+ return typeof value === 'string' && OAUTH_SCOPE_TOKEN_PATTERN.test(value);
33
+ }
34
+ export function isUAPKGCliScope(value) {
35
+ return typeof value === 'string' && UAPKG_CLI_SCOPE_SET.has(value);
36
+ }
37
+ export class ControlPlaneError extends Error {
38
+ code;
39
+ status;
40
+ details;
41
+ constructor(code, message, status, details, options) {
42
+ super(message, options);
43
+ this.code = code;
44
+ this.status = status;
45
+ this.details = details;
46
+ this.name = 'ControlPlaneError';
47
+ }
48
+ }
49
+ export class OAuthScopeInsufficientError extends ControlPlaneError {
50
+ registryAlias;
51
+ requestedScopes;
52
+ requiredScopes;
53
+ missingScopes;
54
+ constructor(message, registryAlias, requestedScopes, requiredScopes, missingScopes, status = 403, options) {
55
+ const requested = knownUAPKGCliScopes(requestedScopes);
56
+ const required = knownUAPKGCliScopes(requiredScopes);
57
+ const missing = knownUAPKGCliScopes(missingScopes).filter((scope) => requested.includes(scope) && required.includes(scope));
58
+ super('OAUTH_SCOPE_INSUFFICIENT', message, status, { requestedScopes: requested, requiredScopes: required, missingScopes: missing }, options);
59
+ this.registryAlias = registryAlias;
60
+ this.name = 'OAuthScopeInsufficientError';
61
+ this.requestedScopes = requested;
62
+ this.requiredScopes = required;
63
+ this.missingScopes = missing;
64
+ }
65
+ }
66
+ export class OAuthScopeUnsupportedError extends ControlPlaneError {
67
+ registryAlias;
68
+ requestedScopes;
69
+ unsupportedScopes;
70
+ reason;
71
+ constructor(registryAlias, requestedScopes, unsupportedScopes, options) {
72
+ const requested = knownUAPKGCliScopes(requestedScopes);
73
+ const unsupported = knownUAPKGCliScopes(unsupportedScopes).filter((scope) => requested.includes(scope));
74
+ const reason = options?.reason ?? 'issuer-does-not-support-requested-scope';
75
+ const message = reason === 'cli-update-required'
76
+ ? `The authorization service for "${registryAlias}" requires an OAuth capability that this UAPKG CLI version does not recognize. Update UAPKG CLI and try again.`
77
+ : unsupportedIssuerScopeMessage(registryAlias, unsupported);
78
+ super('OAUTH_SCOPE_UNSUPPORTED', message, options?.status, { requestedScopes: requested, unsupportedScopes: unsupported, reason }, options);
79
+ this.registryAlias = registryAlias;
80
+ this.name = 'OAuthScopeUnsupportedError';
81
+ this.requestedScopes = requested;
82
+ this.unsupportedScopes = unsupported;
83
+ this.reason = reason;
84
+ }
85
+ }
86
+ function unsupportedIssuerScopeMessage(registryAlias, unsupportedScopes) {
87
+ const noun = unsupportedScopes.length === 1 ? 'scope' : 'scopes';
88
+ return `The authorization service for "${registryAlias}" does not support the OAuth ${noun} required by this UAPKG CLI: ${unsupportedScopes.join(', ')}. Update UAPKG CLI and try again; if it is already current, the authorization service must be updated.`;
89
+ }
90
+ export function registryAudience(registryId) {
91
+ return `${UAPKG_CONTROL_PLANE_API}/v1/registries/${encodeURIComponent(registryId)}`;
92
+ }
93
+ //# sourceMappingURL=ControlPlaneTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ControlPlaneTypes.js","sourceRoot":"","sources":["../../src/control-plane/ControlPlaneTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAE3E,MAAM,CAAC,MAAM,0BAA0B,GAAG,6BAA6B,CAAC,MAAM,CAAC;AAC/E,MAAM,CAAC,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AC;QACjC,IAAI,CAAC,iBAAiB,GAAG,WAAW,CAAC;QACrC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED,SAAS,6BAA6B,CAAC,aAAqB,EAAE,iBAA2C;IACvG,MAAM,IAAI,GAAG,iBAAiB,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC;IACjE,OAAO,kCAAkC,aAAa,gCAAgC,IAAI,gCAAgC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,wGAAwG,CAAC;AACjQ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,UAAkB;IACjD,OAAO,GAAG,uBAAuB,kBAAkB,kBAAkB,CAAC,UAAU,CAAC,EAAE,CAAC;AACtF,CAAC"}
@@ -0,0 +1,28 @@
1
+ interface KeyringEntry {
2
+ setPassword(password: string): void;
3
+ getPassword(): string | null;
4
+ deleteCredential(): boolean;
5
+ }
6
+ interface KeyringModule {
7
+ Entry: new (service: string, username: string) => KeyringEntry;
8
+ }
9
+ export type KeyringLoader = () => Promise<KeyringModule>;
10
+ /**
11
+ * Protected secret storage. The native module is imported only when a
12
+ * control-plane command needs it, so install/search/update remain portable.
13
+ */
14
+ export declare class CredentialStore {
15
+ private readonly loadKeyring;
16
+ private readonly service;
17
+ private module?;
18
+ constructor(loadKeyring?: KeyringLoader, service?: string);
19
+ assertAvailable(): Promise<void>;
20
+ get(reference: string): Promise<string | undefined>;
21
+ set(reference: string, value: string): Promise<void>;
22
+ delete(reference: string): Promise<void>;
23
+ createReference(kind: 'grant' | 'dpop-key', issuer: string, registryId: string, grantId: string): string;
24
+ private entry;
25
+ private ensureModule;
26
+ }
27
+ export {};
28
+ //# sourceMappingURL=CredentialStore.d.ts.map