Skip to content

Commit

Permalink
feat: Update agent device token api. (TabbyML#244)
Browse files Browse the repository at this point in the history
* feat: Update agent device token api.

* fix: typedef for DeviceTokenRequest.
  • Loading branch information
icycodes authored Jun 16, 2023
1 parent 7cb9f2f commit 6f7a6af
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 20 deletions.
2 changes: 1 addition & 1 deletion clients/tabby-agent/dist/cli.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion clients/tabby-agent/dist/cli.js.map

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions clients/tabby-agent/dist/index.global.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion clients/tabby-agent/dist/index.global.js.map

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions clients/tabby-agent/dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion clients/tabby-agent/dist/index.js.map

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions clients/tabby-agent/dist/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13183,10 +13183,11 @@ var ApiService = class {
* @returns DeviceTokenResponse Success
* @throws ApiError
*/
deviceToken() {
deviceToken(body) {
return this.httpRequest.request({
method: "POST",
url: "/device-token"
url: "/device-token",
body
});
}
/**
Expand Down Expand Up @@ -13341,7 +13342,7 @@ var _Auth = class extends EventEmitter {
async requestToken() {
try {
await this.reset();
const deviceToken = await this.authApi.api.deviceToken();
const deviceToken = await this.authApi.api.deviceToken({ auth_url: this.endpoint });
this.logger.debug({ deviceToken }, "Request device token response");
const authUrl = new URL(_Auth.authPageUrl);
authUrl.searchParams.append("code", deviceToken.data.code);
Expand Down
2 changes: 1 addition & 1 deletion clients/tabby-agent/dist/index.mjs.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions clients/tabby-agent/src/Auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class Auth extends EventEmitter {
this.endpoint = options.endpoint;
this.dataStore = options.dataStore || dataStore;

// From tabby endpoint: http[s]://{namespace}.app.tabbyml.com/tabby[/]
// From tabby endpoint: http[s]://{namespace}.app.tabbyml.com/tabby[/]
// To auth endpoint: http[s]://{namespace}.app.tabbyml.com/api
const authApiBase = this.endpoint.replace(/\/tabby\/?$/, "/api");
this.authApi = new CloudApi({ BASE: authApiBase });
Expand Down Expand Up @@ -92,7 +92,7 @@ export class Auth extends EventEmitter {
async requestToken(): Promise<string> {
try {
await this.reset();
const deviceToken = await this.authApi.api.deviceToken();
const deviceToken = await this.authApi.api.deviceToken({ auth_url: this.endpoint });
this.logger.debug({ deviceToken }, "Request device token response");
const authUrl = new URL(Auth.authPageUrl);
authUrl.searchParams.append("code", deviceToken.data.code);
Expand Down
3 changes: 3 additions & 0 deletions clients/tabby-agent/src/cloud/models/DeviceTokenRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export type DeviceTokenResponse = {
auth_url: string;
};
4 changes: 3 additions & 1 deletion clients/tabby-agent/src/cloud/services/ApiService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { CancelablePromise } from "../../generated/core/CancelablePromise";
import type { BaseHttpRequest } from "../../generated/core/BaseHttpRequest";

import { DeviceTokenRequest } from "../models/DeviceTokenRequest";
import { DeviceTokenResponse } from "../models/DeviceTokenResponse";
import { DeviceTokenAcceptResponse } from "../models/DeviceTokenAcceptResponse";

Expand All @@ -11,10 +12,11 @@ export class ApiService {
* @returns DeviceTokenResponse Success
* @throws ApiError
*/
public deviceToken(): CancelablePromise<DeviceTokenResponse> {
public deviceToken(body: DeviceTokenRequest): CancelablePromise<DeviceTokenResponse> {
return this.httpRequest.request({
method: "POST",
url: "/device-token",
body,
});
}

Expand Down

0 comments on commit 6f7a6af

Please sign in to comment.