@agentgo-tw/app-sdk 0.0.0-stage → 2.6.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.
@@ -0,0 +1,61 @@
1
+ // src/errors.ts
2
+ var AcademyError = class extends Error {
3
+ code;
4
+ status;
5
+ details;
6
+ constructor(code, message, status = 0, details = {}) {
7
+ super(message);
8
+ this.name = "AcademyError";
9
+ this.code = code;
10
+ this.status = status;
11
+ this.details = details;
12
+ }
13
+ /** `LOGIN_REQUIRED` 的重新登入網址 */
14
+ get loginUrl() {
15
+ return str(this.details.login_url);
16
+ }
17
+ /** `SUBSCRIPTION_REQUIRED` 的訂閱網址 */
18
+ get subscribeUrl() {
19
+ return str(this.details.subscribe_url);
20
+ }
21
+ /** `INSUFFICIENT_POINTS` 的升級網址 */
22
+ get upgradeUrl() {
23
+ return str(this.details.upgrade_url);
24
+ }
25
+ /** 429 類錯誤建議等待的秒數 */
26
+ get retryAfterSeconds() {
27
+ const v = this.details.retry_after_seconds;
28
+ return typeof v === "number" ? v : void 0;
29
+ }
30
+ /** `AI_LIMIT_EXCEEDED`/`DATA_UNAVAILABLE` 的原因 */
31
+ get reason() {
32
+ return str(this.details.reason);
33
+ }
34
+ };
35
+ var str = (v) => typeof v === "string" ? v : void 0;
36
+ async function errorFromResponse(res) {
37
+ let body = {};
38
+ try {
39
+ body = await res.json();
40
+ } catch {
41
+ }
42
+ const { code, message, ...rest } = body;
43
+ const fallback = res.status === 401 ? "IDENTITY_EXPIRED" : res.status === 402 ? "INSUFFICIENT_POINTS" : res.status >= 500 ? "AI_UNAVAILABLE" : "INVALID_REQUEST";
44
+ return new AcademyError(
45
+ typeof code === "string" && code ? code : fallback,
46
+ typeof message === "string" && message ? message : `\u5E73\u53F0\u56DE\u61C9 HTTP ${res.status}`,
47
+ res.status,
48
+ rest
49
+ );
50
+ }
51
+
52
+ // src/version.ts
53
+ var SDK_VERSION = "2.6.0";
54
+ var CONTRACT_VERSION = 2;
55
+
56
+ export {
57
+ AcademyError,
58
+ errorFromResponse,
59
+ SDK_VERSION,
60
+ CONTRACT_VERSION
61
+ };
@@ -0,0 +1,283 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/client.ts
21
+ var client_exports = {};
22
+ __export(client_exports, {
23
+ AcademyClient: () => AcademyClient,
24
+ AcademyError: () => AcademyError,
25
+ SDK_VERSION: () => SDK_VERSION,
26
+ createAcademyClient: () => createAcademyClient
27
+ });
28
+ module.exports = __toCommonJS(client_exports);
29
+
30
+ // src/errors.ts
31
+ var AcademyError = class extends Error {
32
+ code;
33
+ status;
34
+ details;
35
+ constructor(code, message, status = 0, details = {}) {
36
+ super(message);
37
+ this.name = "AcademyError";
38
+ this.code = code;
39
+ this.status = status;
40
+ this.details = details;
41
+ }
42
+ /** `LOGIN_REQUIRED` 的重新登入網址 */
43
+ get loginUrl() {
44
+ return str(this.details.login_url);
45
+ }
46
+ /** `SUBSCRIPTION_REQUIRED` 的訂閱網址 */
47
+ get subscribeUrl() {
48
+ return str(this.details.subscribe_url);
49
+ }
50
+ /** `INSUFFICIENT_POINTS` 的升級網址 */
51
+ get upgradeUrl() {
52
+ return str(this.details.upgrade_url);
53
+ }
54
+ /** 429 類錯誤建議等待的秒數 */
55
+ get retryAfterSeconds() {
56
+ const v = this.details.retry_after_seconds;
57
+ return typeof v === "number" ? v : void 0;
58
+ }
59
+ /** `AI_LIMIT_EXCEEDED`/`DATA_UNAVAILABLE` 的原因 */
60
+ get reason() {
61
+ return str(this.details.reason);
62
+ }
63
+ };
64
+ var str = (v) => typeof v === "string" ? v : void 0;
65
+ async function errorFromResponse(res) {
66
+ let body = {};
67
+ try {
68
+ body = await res.json();
69
+ } catch {
70
+ }
71
+ const { code, message, ...rest } = body;
72
+ const fallback = res.status === 401 ? "IDENTITY_EXPIRED" : res.status === 402 ? "INSUFFICIENT_POINTS" : res.status >= 500 ? "AI_UNAVAILABLE" : "INVALID_REQUEST";
73
+ return new AcademyError(
74
+ typeof code === "string" && code ? code : fallback,
75
+ typeof message === "string" && message ? message : `\u5E73\u53F0\u56DE\u61C9 HTTP ${res.status}`,
76
+ res.status,
77
+ rest
78
+ );
79
+ }
80
+
81
+ // src/version.ts
82
+ var SDK_VERSION = "2.6.0";
83
+
84
+ // src/client.ts
85
+ var bytesToB64url = (bytes) => {
86
+ let bin = "";
87
+ for (const b of bytes) bin += String.fromCharCode(b);
88
+ return btoa(bin).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
89
+ };
90
+ var randomB64url = (n) => bytesToB64url(crypto.getRandomValues(new Uint8Array(n)));
91
+ async function s256(input) {
92
+ const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(input));
93
+ return bytesToB64url(new Uint8Array(digest));
94
+ }
95
+ var AcademyClient = class {
96
+ appOrigin;
97
+ client;
98
+ env;
99
+ redirectUri;
100
+ appSlug;
101
+ baseUrl;
102
+ storage;
103
+ fetchImpl;
104
+ skewMs;
105
+ keyPrefix;
106
+ /** 同時多個請求遇到過期時只更新一次 */
107
+ refreshing = null;
108
+ constructor(opts) {
109
+ const app = new URL(opts.appUrl);
110
+ this.appOrigin = app.origin;
111
+ this.client = opts.client;
112
+ this.redirectUri = opts.redirectUri;
113
+ this.appSlug = opts.appSlug ?? app.hostname.split(".")[0];
114
+ this.baseUrl = (opts.baseUrl ?? "https://agentgo.tw").replace(/\/+$/, "");
115
+ this.env = opts.env ?? (app.hostname.includes(".test.") ? "test" : "production");
116
+ this.storage = opts.storage;
117
+ this.fetchImpl = opts.fetch ?? ((input, init) => fetch(input, init));
118
+ this.skewMs = (opts.refreshSkewSeconds ?? 60) * 1e3;
119
+ this.keyPrefix = `academy:${this.client}:${app.host}`;
120
+ }
121
+ // ------------------------------------------------------------------ 授權
122
+ /**
123
+ * 產生 PKCE 與 `state`,回主站的授權網址。把這個網址交給瀏覽器開啟
124
+ * (擴充功能用 `chrome.identity.launchWebAuthFlow`),完成後把轉回來的網址交給 `handleRedirect()`。
125
+ */
126
+ async authorizeUrl() {
127
+ const pending = { state: randomB64url(16), verifier: randomB64url(32) };
128
+ await this.storage.set(`${this.keyPrefix}:pending`, JSON.stringify(pending));
129
+ const q = new URLSearchParams({
130
+ app: this.appSlug,
131
+ client: this.client,
132
+ redirect_uri: this.redirectUri,
133
+ code_challenge: await s256(pending.verifier),
134
+ code_challenge_method: "S256",
135
+ state: pending.state
136
+ });
137
+ if (this.env === "test") q.set("env", "test");
138
+ return `${this.baseUrl}/apps/authorize?${q.toString()}`;
139
+ }
140
+ /**
141
+ * 處理授權後轉回來的網址:核對 `state`、以授權碼換取憑證並存入 storage。
142
+ * 會員按了取消丟 `ACCESS_DENIED`;`state` 不符或授權碼失效丟 `TOKEN_INVALID`。
143
+ */
144
+ async handleRedirect(url) {
145
+ const u = new URL(url);
146
+ const params = u.searchParams;
147
+ const raw = await this.storage.get(`${this.keyPrefix}:pending`);
148
+ await this.storage.remove(`${this.keyPrefix}:pending`);
149
+ let pending = null;
150
+ try {
151
+ pending = raw ? JSON.parse(raw) : null;
152
+ } catch {
153
+ pending = null;
154
+ }
155
+ if (!pending || params.get("state") !== pending.state) throw new AcademyError("TOKEN_INVALID", "\u6388\u6B0A\u6D41\u7A0B\u5DF2\u5931\u6548\uFF0C\u8ACB\u91CD\u65B0\u6388\u6B0A\uFF08state \u4E0D\u7B26\uFF09", 0);
156
+ if (params.get("error")) {
157
+ const error = params.get("error");
158
+ throw new AcademyError(error === "access_denied" ? "ACCESS_DENIED" : "TOKEN_INVALID", error === "access_denied" ? "\u5DF2\u53D6\u6D88\u6388\u6B0A" : `\u6388\u6B0A\u5931\u6557\uFF1A${error}`, 0, { error });
159
+ }
160
+ const code = params.get("code");
161
+ if (!code) throw new AcademyError("TOKEN_INVALID", "\u8F49\u56DE\u4F86\u7684\u7DB2\u5740\u6C92\u6709\u6388\u6B0A\u78BC", 0);
162
+ await this.store(
163
+ await this.tokenRequest({ grant_type: "authorization_code", code, code_verifier: pending.verifier, client: this.client, redirect_uri: this.redirectUri })
164
+ );
165
+ }
166
+ // ------------------------------------------------------------------ 使用
167
+ /** 是否已有憑證(不保證仍有效;實際結果以呼叫 App 為準) */
168
+ async isSignedIn() {
169
+ return await this.load() !== null;
170
+ }
171
+ /** 目前可用的存取憑證;快過期時先更新。沒有憑證或更新失敗回 null */
172
+ async getAccessToken() {
173
+ const t = await this.load();
174
+ if (!t) return null;
175
+ if (t.expiresAt - Date.now() > this.skewMs) return t.accessToken;
176
+ return (await this.refresh())?.accessToken ?? null;
177
+ }
178
+ /**
179
+ * 呼叫 App:自動帶存取憑證;快過期時先更新,同時多個請求只更新一次。
180
+ * 只能打 App 自己的網域(避免憑證被送到別處)。沒有憑證、或憑證已被撤銷時丟 `TOKEN_INVALID`,由用戶端重新引導授權;
181
+ * 403 `SUBSCRIPTION_REQUIRED`、`APP_UNAVAILABLE` 等其他回應原樣交回。
182
+ */
183
+ async fetch(input, init = {}) {
184
+ const url = new URL(String(input), this.appOrigin);
185
+ if (url.origin !== this.appOrigin) throw new AcademyError("INVALID_REQUEST", `\u53EA\u80FD\u547C\u53EB App \u81EA\u5DF1\u7684\u7DB2\u5740\uFF08${this.appOrigin}\uFF09`, 0);
186
+ let token = await this.getAccessToken();
187
+ if (!token) throw new AcademyError("TOKEN_INVALID", "\u5C1A\u672A\u6388\u6B0A\u6216\u6388\u6B0A\u5DF2\u5931\u6548\uFF0C\u8ACB\u91CD\u65B0\u6388\u6B0A", 401, { authorize_required: true });
188
+ let res = await this.send(url, init, token);
189
+ if (res.status === 401 && await this.isTokenInvalid(res)) {
190
+ token = (await this.refresh())?.accessToken ?? null;
191
+ if (!token) throw new AcademyError("TOKEN_INVALID", "\u6388\u6B0A\u5DF2\u5931\u6548\uFF0C\u8ACB\u91CD\u65B0\u6388\u6B0A", 401, { authorize_required: true });
192
+ res = await this.send(url, init, token);
193
+ if (res.status === 401 && await this.isTokenInvalid(res)) {
194
+ await this.clear();
195
+ throw new AcademyError("TOKEN_INVALID", "\u6388\u6B0A\u5DF2\u5931\u6548\uFF0C\u8ACB\u91CD\u65B0\u6388\u6B0A", 401, { authorize_required: true });
196
+ }
197
+ }
198
+ return res;
199
+ }
200
+ /** 登出:向平台撤銷委任並清除本機的憑證 */
201
+ async signOut() {
202
+ const t = await this.load();
203
+ await this.clear();
204
+ if (!t) return;
205
+ await this.fetchImpl(`${this.appOrigin}/__academy/revoke`, {
206
+ method: "POST",
207
+ headers: { "content-type": "application/json", accept: "application/json", "x-academy-sdk": SDK_VERSION },
208
+ body: JSON.stringify({ refresh_token: t.refreshToken })
209
+ }).catch(() => void 0);
210
+ }
211
+ // ------------------------------------------------------------------ 內部
212
+ send(url, init, token) {
213
+ const headers = new Headers(init.headers);
214
+ headers.set("authorization", `Bearer ${token}`);
215
+ if (!headers.has("accept")) headers.set("accept", "application/json");
216
+ return this.fetchImpl(url.toString(), { ...init, headers });
217
+ }
218
+ async isTokenInvalid(res) {
219
+ try {
220
+ const body = await res.clone().json();
221
+ return body?.code === "TOKEN_INVALID";
222
+ } catch {
223
+ return false;
224
+ }
225
+ }
226
+ refresh() {
227
+ if (!this.refreshing) {
228
+ this.refreshing = (async () => {
229
+ const t = await this.load();
230
+ if (!t) return null;
231
+ try {
232
+ return await this.store(await this.tokenRequest({ grant_type: "refresh_token", refresh_token: t.refreshToken, client: this.client }));
233
+ } catch (e) {
234
+ if (e instanceof AcademyError && e.code === "TOKEN_INVALID") {
235
+ await this.clear();
236
+ return null;
237
+ }
238
+ throw e;
239
+ }
240
+ })().finally(() => {
241
+ this.refreshing = null;
242
+ });
243
+ }
244
+ return this.refreshing;
245
+ }
246
+ async tokenRequest(body) {
247
+ const res = await this.fetchImpl(`${this.appOrigin}/__academy/token`, {
248
+ method: "POST",
249
+ headers: { "content-type": "application/json", accept: "application/json", "x-academy-sdk": SDK_VERSION },
250
+ body: JSON.stringify(body)
251
+ });
252
+ if (!res.ok) throw await errorFromResponse(res);
253
+ return await res.json();
254
+ }
255
+ async store(r) {
256
+ const t = { accessToken: r.access_token, refreshToken: r.refresh_token, expiresAt: Date.now() + r.expires_in * 1e3 };
257
+ await this.storage.set(`${this.keyPrefix}:tokens`, JSON.stringify(t));
258
+ return t;
259
+ }
260
+ async load() {
261
+ const raw = await this.storage.get(`${this.keyPrefix}:tokens`);
262
+ if (!raw) return null;
263
+ try {
264
+ const t = JSON.parse(raw);
265
+ return typeof t.accessToken === "string" && typeof t.refreshToken === "string" && typeof t.expiresAt === "number" ? t : null;
266
+ } catch {
267
+ return null;
268
+ }
269
+ }
270
+ async clear() {
271
+ await this.storage.remove(`${this.keyPrefix}:tokens`);
272
+ }
273
+ };
274
+ function createAcademyClient(opts) {
275
+ return new AcademyClient(opts);
276
+ }
277
+ // Annotate the CommonJS export names for ESM import in node:
278
+ 0 && (module.exports = {
279
+ AcademyClient,
280
+ AcademyError,
281
+ SDK_VERSION,
282
+ createAcademyClient
283
+ });
@@ -0,0 +1,76 @@
1
+ import { m as AppIdentityEnv } from './version-ClrVQNzw.cjs';
2
+ export { d as AcademyError, e as AcademyErrorCode, S as SDK_VERSION } from './version-ClrVQNzw.cjs';
3
+
4
+ /** 保存憑證的地方。擴充功能可包 `chrome.storage.local`;同步或非同步皆可 */
5
+ interface AcademyClientStorage {
6
+ get(key: string): Promise<string | null | undefined> | string | null | undefined;
7
+ set(key: string, value: string): Promise<void> | void;
8
+ remove(key: string): Promise<void> | void;
9
+ }
10
+ interface AcademyClientOptions {
11
+ /** App 的網址,例如 `https://my-tool.app.agentgo.tw`;測試環境為 `https://my-tool.test.app.agentgo.tw` */
12
+ appUrl: string;
13
+ /** 上架資料宣告的用戶端代號 */
14
+ client: string;
15
+ /** 上架資料登記的轉址網址(完全相同) */
16
+ redirectUri: string;
17
+ storage: AcademyClientStorage;
18
+ /** 主站網址,預設 `https://agentgo.tw` */
19
+ baseUrl?: string;
20
+ /** 工具在平台上的 slug,預設取 `appUrl` 網域的第一段 */
21
+ appSlug?: string;
22
+ /** 預設依 `appUrl` 判斷:網域含 `.test.` 視為測試環境 */
23
+ env?: AppIdentityEnv;
24
+ /** 存取憑證到期前幾秒就先更新,預設 60 */
25
+ refreshSkewSeconds?: number;
26
+ /** 測試用:替換 fetch */
27
+ fetch?: typeof fetch;
28
+ }
29
+ declare class AcademyClient {
30
+ readonly appOrigin: string;
31
+ readonly client: string;
32
+ readonly env: AppIdentityEnv;
33
+ private readonly redirectUri;
34
+ private readonly appSlug;
35
+ private readonly baseUrl;
36
+ private readonly storage;
37
+ private readonly fetchImpl;
38
+ private readonly skewMs;
39
+ private readonly keyPrefix;
40
+ /** 同時多個請求遇到過期時只更新一次 */
41
+ private refreshing;
42
+ constructor(opts: AcademyClientOptions);
43
+ /**
44
+ * 產生 PKCE 與 `state`,回主站的授權網址。把這個網址交給瀏覽器開啟
45
+ * (擴充功能用 `chrome.identity.launchWebAuthFlow`),完成後把轉回來的網址交給 `handleRedirect()`。
46
+ */
47
+ authorizeUrl(): Promise<string>;
48
+ /**
49
+ * 處理授權後轉回來的網址:核對 `state`、以授權碼換取憑證並存入 storage。
50
+ * 會員按了取消丟 `ACCESS_DENIED`;`state` 不符或授權碼失效丟 `TOKEN_INVALID`。
51
+ */
52
+ handleRedirect(url: string): Promise<void>;
53
+ /** 是否已有憑證(不保證仍有效;實際結果以呼叫 App 為準) */
54
+ isSignedIn(): Promise<boolean>;
55
+ /** 目前可用的存取憑證;快過期時先更新。沒有憑證或更新失敗回 null */
56
+ getAccessToken(): Promise<string | null>;
57
+ /**
58
+ * 呼叫 App:自動帶存取憑證;快過期時先更新,同時多個請求只更新一次。
59
+ * 只能打 App 自己的網域(避免憑證被送到別處)。沒有憑證、或憑證已被撤銷時丟 `TOKEN_INVALID`,由用戶端重新引導授權;
60
+ * 403 `SUBSCRIPTION_REQUIRED`、`APP_UNAVAILABLE` 等其他回應原樣交回。
61
+ */
62
+ fetch(input: string | URL, init?: RequestInit): Promise<Response>;
63
+ /** 登出:向平台撤銷委任並清除本機的憑證 */
64
+ signOut(): Promise<void>;
65
+ private send;
66
+ private isTokenInvalid;
67
+ private refresh;
68
+ private tokenRequest;
69
+ private store;
70
+ private load;
71
+ private clear;
72
+ }
73
+ /** 建立會員用戶端(擴充功能、桌面與手機程式) */
74
+ declare function createAcademyClient(opts: AcademyClientOptions): AcademyClient;
75
+
76
+ export { AcademyClient, type AcademyClientOptions, type AcademyClientStorage, createAcademyClient };
@@ -0,0 +1,76 @@
1
+ import { m as AppIdentityEnv } from './version-ClrVQNzw.js';
2
+ export { d as AcademyError, e as AcademyErrorCode, S as SDK_VERSION } from './version-ClrVQNzw.js';
3
+
4
+ /** 保存憑證的地方。擴充功能可包 `chrome.storage.local`;同步或非同步皆可 */
5
+ interface AcademyClientStorage {
6
+ get(key: string): Promise<string | null | undefined> | string | null | undefined;
7
+ set(key: string, value: string): Promise<void> | void;
8
+ remove(key: string): Promise<void> | void;
9
+ }
10
+ interface AcademyClientOptions {
11
+ /** App 的網址,例如 `https://my-tool.app.agentgo.tw`;測試環境為 `https://my-tool.test.app.agentgo.tw` */
12
+ appUrl: string;
13
+ /** 上架資料宣告的用戶端代號 */
14
+ client: string;
15
+ /** 上架資料登記的轉址網址(完全相同) */
16
+ redirectUri: string;
17
+ storage: AcademyClientStorage;
18
+ /** 主站網址,預設 `https://agentgo.tw` */
19
+ baseUrl?: string;
20
+ /** 工具在平台上的 slug,預設取 `appUrl` 網域的第一段 */
21
+ appSlug?: string;
22
+ /** 預設依 `appUrl` 判斷:網域含 `.test.` 視為測試環境 */
23
+ env?: AppIdentityEnv;
24
+ /** 存取憑證到期前幾秒就先更新,預設 60 */
25
+ refreshSkewSeconds?: number;
26
+ /** 測試用:替換 fetch */
27
+ fetch?: typeof fetch;
28
+ }
29
+ declare class AcademyClient {
30
+ readonly appOrigin: string;
31
+ readonly client: string;
32
+ readonly env: AppIdentityEnv;
33
+ private readonly redirectUri;
34
+ private readonly appSlug;
35
+ private readonly baseUrl;
36
+ private readonly storage;
37
+ private readonly fetchImpl;
38
+ private readonly skewMs;
39
+ private readonly keyPrefix;
40
+ /** 同時多個請求遇到過期時只更新一次 */
41
+ private refreshing;
42
+ constructor(opts: AcademyClientOptions);
43
+ /**
44
+ * 產生 PKCE 與 `state`,回主站的授權網址。把這個網址交給瀏覽器開啟
45
+ * (擴充功能用 `chrome.identity.launchWebAuthFlow`),完成後把轉回來的網址交給 `handleRedirect()`。
46
+ */
47
+ authorizeUrl(): Promise<string>;
48
+ /**
49
+ * 處理授權後轉回來的網址:核對 `state`、以授權碼換取憑證並存入 storage。
50
+ * 會員按了取消丟 `ACCESS_DENIED`;`state` 不符或授權碼失效丟 `TOKEN_INVALID`。
51
+ */
52
+ handleRedirect(url: string): Promise<void>;
53
+ /** 是否已有憑證(不保證仍有效;實際結果以呼叫 App 為準) */
54
+ isSignedIn(): Promise<boolean>;
55
+ /** 目前可用的存取憑證;快過期時先更新。沒有憑證或更新失敗回 null */
56
+ getAccessToken(): Promise<string | null>;
57
+ /**
58
+ * 呼叫 App:自動帶存取憑證;快過期時先更新,同時多個請求只更新一次。
59
+ * 只能打 App 自己的網域(避免憑證被送到別處)。沒有憑證、或憑證已被撤銷時丟 `TOKEN_INVALID`,由用戶端重新引導授權;
60
+ * 403 `SUBSCRIPTION_REQUIRED`、`APP_UNAVAILABLE` 等其他回應原樣交回。
61
+ */
62
+ fetch(input: string | URL, init?: RequestInit): Promise<Response>;
63
+ /** 登出:向平台撤銷委任並清除本機的憑證 */
64
+ signOut(): Promise<void>;
65
+ private send;
66
+ private isTokenInvalid;
67
+ private refresh;
68
+ private tokenRequest;
69
+ private store;
70
+ private load;
71
+ private clear;
72
+ }
73
+ /** 建立會員用戶端(擴充功能、桌面與手機程式) */
74
+ declare function createAcademyClient(opts: AcademyClientOptions): AcademyClient;
75
+
76
+ export { AcademyClient, type AcademyClientOptions, type AcademyClientStorage, createAcademyClient };