@ricsam/r5d-api 0.0.50 → 0.0.53
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/README.md +9 -3
- package/dist/cjs/index.cjs +28 -12
- package/dist/cjs/package.json +1 -1
- package/dist/mjs/index.mjs +28 -12
- package/dist/mjs/package.json +1 -1
- package/dist/types/index.d.ts +57 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,10 +26,12 @@ console.log(projects);
|
|
|
26
26
|
## Auth
|
|
27
27
|
|
|
28
28
|
`R5dctlClient` supports:
|
|
29
|
-
|
|
29
|
+
|
|
30
|
+
- authorized device token (`r5d_device_*`)
|
|
30
31
|
- API key (`r5dctl_key_*`)
|
|
31
32
|
|
|
32
33
|
Set either `token` or `apiKey` in client options, or later via:
|
|
34
|
+
|
|
33
35
|
- `client.setToken(...)`
|
|
34
36
|
- `client.setApiKey(...)`
|
|
35
37
|
|
|
@@ -37,8 +39,11 @@ Trusted server-side callers that authenticate through custom headers, such as a
|
|
|
37
39
|
|
|
38
40
|
## Main API Surface
|
|
39
41
|
|
|
40
|
-
- `auth.
|
|
41
|
-
- `auth.
|
|
42
|
+
- `auth.deviceStart({ deviceName, workerLabel? })`
|
|
43
|
+
- `auth.devicePoll(requestId, { deviceCode })`
|
|
44
|
+
- `auth.deviceVerify({ userCode })`
|
|
45
|
+
- `auth.deviceApprove({ userCode })` / `auth.deviceDeny({ userCode })`
|
|
46
|
+
- `auth.devices.list()` / `auth.devices.revoke(id)`
|
|
42
47
|
- `auth.status()`
|
|
43
48
|
- `auth.logout()`
|
|
44
49
|
- `auth.apiKeys.create/list/revoke`
|
|
@@ -67,6 +72,7 @@ Trusted server-side callers that authenticate through custom headers, such as a
|
|
|
67
72
|
## Errors
|
|
68
73
|
|
|
69
74
|
Non-2xx responses throw `R5dctlApiError` with:
|
|
75
|
+
|
|
70
76
|
- `status`
|
|
71
77
|
- `path`
|
|
72
78
|
- `body`
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -119,22 +119,37 @@ class R5dctlClient {
|
|
|
119
119
|
return payload;
|
|
120
120
|
}
|
|
121
121
|
auth = {
|
|
122
|
-
|
|
122
|
+
deviceStart: (input) => this.request({
|
|
123
123
|
method: "POST",
|
|
124
|
-
path: "/api/
|
|
124
|
+
path: "/api/auth/device/start",
|
|
125
125
|
auth: "none",
|
|
126
|
-
body:
|
|
127
|
-
baseUrl: input?.baseUrl
|
|
128
|
-
}
|
|
126
|
+
body: input
|
|
129
127
|
}),
|
|
130
|
-
|
|
131
|
-
method: "
|
|
132
|
-
path: `/api/
|
|
128
|
+
devicePoll: (requestId, input) => this.request({
|
|
129
|
+
method: "POST",
|
|
130
|
+
path: `/api/auth/device/poll/${encodeURIComponent(requestId)}`,
|
|
133
131
|
auth: "none",
|
|
134
|
-
|
|
135
|
-
pollCode: input.pollCode
|
|
136
|
-
}
|
|
132
|
+
body: input
|
|
137
133
|
}),
|
|
134
|
+
deviceVerify: (input) => this.request({
|
|
135
|
+
method: "POST",
|
|
136
|
+
path: "/api/auth/device/verify",
|
|
137
|
+
body: input
|
|
138
|
+
}),
|
|
139
|
+
deviceApprove: (input) => this.request({
|
|
140
|
+
method: "POST",
|
|
141
|
+
path: "/api/auth/device/approve",
|
|
142
|
+
body: input
|
|
143
|
+
}),
|
|
144
|
+
deviceDeny: (input) => this.request({
|
|
145
|
+
method: "POST",
|
|
146
|
+
path: "/api/auth/device/deny",
|
|
147
|
+
body: input
|
|
148
|
+
}),
|
|
149
|
+
devices: {
|
|
150
|
+
list: () => this.request({ method: "GET", path: "/api/auth/devices" }),
|
|
151
|
+
revoke: (id) => this.request({ method: "DELETE", path: `/api/auth/devices/${encodeURIComponent(id)}` })
|
|
152
|
+
},
|
|
138
153
|
logout: () => this.request({
|
|
139
154
|
method: "POST",
|
|
140
155
|
path: "/api/r5dctl/auth/logout",
|
|
@@ -218,7 +233,8 @@ class R5dctlClient {
|
|
|
218
233
|
path: "/api/user/managed-vcluster/resource-history",
|
|
219
234
|
query: {
|
|
220
235
|
workloadUid: input.workloadUid,
|
|
221
|
-
containerName: input.containerName
|
|
236
|
+
containerName: input.containerName,
|
|
237
|
+
window: input.window
|
|
222
238
|
}
|
|
223
239
|
})
|
|
224
240
|
};
|
package/dist/cjs/package.json
CHANGED
package/dist/mjs/index.mjs
CHANGED
|
@@ -95,22 +95,37 @@ class R5dctlClient {
|
|
|
95
95
|
return payload;
|
|
96
96
|
}
|
|
97
97
|
auth = {
|
|
98
|
-
|
|
98
|
+
deviceStart: (input) => this.request({
|
|
99
99
|
method: "POST",
|
|
100
|
-
path: "/api/
|
|
100
|
+
path: "/api/auth/device/start",
|
|
101
101
|
auth: "none",
|
|
102
|
-
body:
|
|
103
|
-
baseUrl: input?.baseUrl
|
|
104
|
-
}
|
|
102
|
+
body: input
|
|
105
103
|
}),
|
|
106
|
-
|
|
107
|
-
method: "
|
|
108
|
-
path: `/api/
|
|
104
|
+
devicePoll: (requestId, input) => this.request({
|
|
105
|
+
method: "POST",
|
|
106
|
+
path: `/api/auth/device/poll/${encodeURIComponent(requestId)}`,
|
|
109
107
|
auth: "none",
|
|
110
|
-
|
|
111
|
-
pollCode: input.pollCode
|
|
112
|
-
}
|
|
108
|
+
body: input
|
|
113
109
|
}),
|
|
110
|
+
deviceVerify: (input) => this.request({
|
|
111
|
+
method: "POST",
|
|
112
|
+
path: "/api/auth/device/verify",
|
|
113
|
+
body: input
|
|
114
|
+
}),
|
|
115
|
+
deviceApprove: (input) => this.request({
|
|
116
|
+
method: "POST",
|
|
117
|
+
path: "/api/auth/device/approve",
|
|
118
|
+
body: input
|
|
119
|
+
}),
|
|
120
|
+
deviceDeny: (input) => this.request({
|
|
121
|
+
method: "POST",
|
|
122
|
+
path: "/api/auth/device/deny",
|
|
123
|
+
body: input
|
|
124
|
+
}),
|
|
125
|
+
devices: {
|
|
126
|
+
list: () => this.request({ method: "GET", path: "/api/auth/devices" }),
|
|
127
|
+
revoke: (id) => this.request({ method: "DELETE", path: `/api/auth/devices/${encodeURIComponent(id)}` })
|
|
128
|
+
},
|
|
114
129
|
logout: () => this.request({
|
|
115
130
|
method: "POST",
|
|
116
131
|
path: "/api/r5dctl/auth/logout",
|
|
@@ -194,7 +209,8 @@ class R5dctlClient {
|
|
|
194
209
|
path: "/api/user/managed-vcluster/resource-history",
|
|
195
210
|
query: {
|
|
196
211
|
workloadUid: input.workloadUid,
|
|
197
|
-
containerName: input.containerName
|
|
212
|
+
containerName: input.containerName,
|
|
213
|
+
window: input.window
|
|
198
214
|
}
|
|
199
215
|
})
|
|
200
216
|
};
|
package/dist/mjs/package.json
CHANGED
package/dist/types/index.d.ts
CHANGED
|
@@ -142,14 +142,16 @@ export type R5dctlAbortMergeResult = {
|
|
|
142
142
|
status: "aborted";
|
|
143
143
|
message: string;
|
|
144
144
|
};
|
|
145
|
-
export type
|
|
145
|
+
export type DeviceAuthorizationStartResponse = {
|
|
146
146
|
requestId: string;
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
deviceCode: string;
|
|
148
|
+
userCode: string;
|
|
149
|
+
verificationUri: string;
|
|
150
|
+
verificationUriComplete: string;
|
|
149
151
|
expiresAt: string;
|
|
150
152
|
intervalMs: number;
|
|
151
153
|
};
|
|
152
|
-
export type
|
|
154
|
+
export type DeviceAuthorizationPollResponse = {
|
|
153
155
|
status: "pending";
|
|
154
156
|
expiresAt: string;
|
|
155
157
|
intervalMs: number;
|
|
@@ -158,11 +160,28 @@ export type R5dctlLoginPollResponse = {
|
|
|
158
160
|
token: string;
|
|
159
161
|
credentialId: string;
|
|
160
162
|
} | {
|
|
161
|
-
status: "expired" | "consumed";
|
|
163
|
+
status: "denied" | "expired" | "consumed";
|
|
164
|
+
};
|
|
165
|
+
export type DeviceAuthorizationRequestDetails = {
|
|
166
|
+
requestId: string;
|
|
167
|
+
userCode: string;
|
|
168
|
+
deviceName: string;
|
|
169
|
+
workerLabel: string | null;
|
|
170
|
+
expiresAt: string;
|
|
171
|
+
};
|
|
172
|
+
export type AuthorizedDevice = {
|
|
173
|
+
id: string;
|
|
174
|
+
deviceName: string;
|
|
175
|
+
workerLabel: string | null;
|
|
176
|
+
createdAt: string;
|
|
177
|
+
lastUsedAt: string | null;
|
|
162
178
|
};
|
|
163
179
|
export type R5dctlAuthStatusResponse = {
|
|
164
180
|
authenticated: true;
|
|
165
|
-
source: "session" | "
|
|
181
|
+
source: "session" | "device" | "api_key" | "user_worker";
|
|
182
|
+
credentialId: string | null;
|
|
183
|
+
credentialType: "device" | "api_key" | "user_worker" | null;
|
|
184
|
+
workerLabel: string | null;
|
|
166
185
|
user: {
|
|
167
186
|
id: string;
|
|
168
187
|
email: string;
|
|
@@ -291,6 +310,7 @@ export type R5dctlK8sContainer = {
|
|
|
291
310
|
pods: Array<R5dctlK8sUsage & {
|
|
292
311
|
podUid: string;
|
|
293
312
|
podName: string;
|
|
313
|
+
phase: string | null;
|
|
294
314
|
}>;
|
|
295
315
|
};
|
|
296
316
|
export type R5dctlK8sWorkload = {
|
|
@@ -298,6 +318,8 @@ export type R5dctlK8sWorkload = {
|
|
|
298
318
|
kind: "Deployment" | "StatefulSet" | "DaemonSet" | "CronJob" | "ReplicaSet" | "Job" | "Pod";
|
|
299
319
|
namespace: string;
|
|
300
320
|
name: string;
|
|
321
|
+
replicas: number;
|
|
322
|
+
readyReplicas: number;
|
|
301
323
|
containers: R5dctlK8sContainer[];
|
|
302
324
|
};
|
|
303
325
|
export type R5dctlK8sResources = {
|
|
@@ -367,12 +389,34 @@ export declare class R5dctlClient {
|
|
|
367
389
|
private resolveBearerToken;
|
|
368
390
|
private request;
|
|
369
391
|
readonly auth: {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
392
|
+
deviceStart: (input: {
|
|
393
|
+
deviceName: string;
|
|
394
|
+
workerLabel?: string;
|
|
395
|
+
}) => Promise<DeviceAuthorizationStartResponse>;
|
|
396
|
+
devicePoll: (requestId: string, input: {
|
|
397
|
+
deviceCode: string;
|
|
398
|
+
}) => Promise<DeviceAuthorizationPollResponse>;
|
|
399
|
+
deviceVerify: (input: {
|
|
400
|
+
userCode: string;
|
|
401
|
+
}) => Promise<DeviceAuthorizationRequestDetails>;
|
|
402
|
+
deviceApprove: (input: {
|
|
403
|
+
userCode: string;
|
|
404
|
+
}) => Promise<{
|
|
405
|
+
approved: true;
|
|
406
|
+
}>;
|
|
407
|
+
deviceDeny: (input: {
|
|
408
|
+
userCode: string;
|
|
409
|
+
}) => Promise<{
|
|
410
|
+
denied: true;
|
|
411
|
+
}>;
|
|
412
|
+
devices: {
|
|
413
|
+
list: () => Promise<{
|
|
414
|
+
devices: AuthorizedDevice[];
|
|
415
|
+
}>;
|
|
416
|
+
revoke: (id: string) => Promise<{
|
|
417
|
+
success: true;
|
|
418
|
+
}>;
|
|
419
|
+
};
|
|
376
420
|
logout: () => Promise<{
|
|
377
421
|
success: boolean;
|
|
378
422
|
revokedCredential: boolean;
|
|
@@ -414,6 +458,7 @@ export declare class R5dctlClient {
|
|
|
414
458
|
resourceHistory: (input: {
|
|
415
459
|
workloadUid: string;
|
|
416
460
|
containerName: string;
|
|
461
|
+
window?: "24h" | "7d";
|
|
417
462
|
}) => Promise<R5dctlK8sResourceHistory>;
|
|
418
463
|
};
|
|
419
464
|
readonly projects: {
|