@ricsam/r5d-api 0.0.51 → 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 CHANGED
@@ -26,10 +26,12 @@ console.log(projects);
26
26
  ## Auth
27
27
 
28
28
  `R5dctlClient` supports:
29
- - interactive token (`r5dctl_tok_*`)
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.loginStart()`
41
- - `auth.loginPoll(requestId, { pollCode })`
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`
@@ -119,22 +119,37 @@ class R5dctlClient {
119
119
  return payload;
120
120
  }
121
121
  auth = {
122
- loginStart: (input) => this.request({
122
+ deviceStart: (input) => this.request({
123
123
  method: "POST",
124
- path: "/api/r5dctl/auth/login/start",
124
+ path: "/api/auth/device/start",
125
125
  auth: "none",
126
- body: {
127
- baseUrl: input?.baseUrl
128
- }
126
+ body: input
129
127
  }),
130
- loginPoll: (requestId, input) => this.request({
131
- method: "GET",
132
- path: `/api/r5dctl/auth/login/poll/${encodeURIComponent(requestId)}`,
128
+ devicePoll: (requestId, input) => this.request({
129
+ method: "POST",
130
+ path: `/api/auth/device/poll/${encodeURIComponent(requestId)}`,
133
131
  auth: "none",
134
- query: {
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",
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@ricsam/r5d-api",
3
- "version": "0.0.51",
3
+ "version": "0.0.53",
4
4
  "type": "commonjs"
5
5
  }
@@ -95,22 +95,37 @@ class R5dctlClient {
95
95
  return payload;
96
96
  }
97
97
  auth = {
98
- loginStart: (input) => this.request({
98
+ deviceStart: (input) => this.request({
99
99
  method: "POST",
100
- path: "/api/r5dctl/auth/login/start",
100
+ path: "/api/auth/device/start",
101
101
  auth: "none",
102
- body: {
103
- baseUrl: input?.baseUrl
104
- }
102
+ body: input
105
103
  }),
106
- loginPoll: (requestId, input) => this.request({
107
- method: "GET",
108
- path: `/api/r5dctl/auth/login/poll/${encodeURIComponent(requestId)}`,
104
+ devicePoll: (requestId, input) => this.request({
105
+ method: "POST",
106
+ path: `/api/auth/device/poll/${encodeURIComponent(requestId)}`,
109
107
  auth: "none",
110
- query: {
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",
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@ricsam/r5d-api",
3
- "version": "0.0.51",
3
+ "version": "0.0.53",
4
4
  "type": "module"
5
5
  }
@@ -142,14 +142,16 @@ export type R5dctlAbortMergeResult = {
142
142
  status: "aborted";
143
143
  message: string;
144
144
  };
145
- export type R5dctlLoginStartResponse = {
145
+ export type DeviceAuthorizationStartResponse = {
146
146
  requestId: string;
147
- pollCode: string;
148
- loginUrl: string;
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 R5dctlLoginPollResponse = {
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" | "r5dctl";
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;
@@ -370,12 +389,34 @@ export declare class R5dctlClient {
370
389
  private resolveBearerToken;
371
390
  private request;
372
391
  readonly auth: {
373
- loginStart: (input?: {
374
- baseUrl?: string;
375
- }) => Promise<R5dctlLoginStartResponse>;
376
- loginPoll: (requestId: string, input: {
377
- pollCode: string;
378
- }) => Promise<R5dctlLoginPollResponse>;
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
+ };
379
420
  logout: () => Promise<{
380
421
  success: boolean;
381
422
  revokedCredential: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ricsam/r5d-api",
3
- "version": "0.0.51",
3
+ "version": "0.0.53",
4
4
  "type": "module",
5
5
  "main": "./dist/cjs/index.cjs",
6
6
  "module": "./dist/mjs/index.mjs",