@aexhq/sdk 0.69.0 → 0.70.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.
- package/README.md +21 -0
- package/dist/generated.d.ts +33 -0
- package/dist/index.d.ts +13 -4
- package/dist/index.js +9 -4
- package/package.json +26 -7
package/README.md
CHANGED
|
@@ -21,3 +21,24 @@ on the initial deployment. Supply your model key per session.
|
|
|
21
21
|
`account.get()` and `account.usage()` accept a workload API key. `keys` management requires
|
|
22
22
|
an authenticated account session and is normally performed in the dashboard. API keys do
|
|
23
23
|
not grant authority to create more credentials. New key secrets are returned once.
|
|
24
|
+
|
|
25
|
+
## Account management
|
|
26
|
+
|
|
27
|
+
Use an account session obtained through browser login for account management. Workload
|
|
28
|
+
API keys remain scoped to runtime operations and read-only account/usage access.
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
const account = new Aex({ accountToken: process.env.AEX_ACCOUNT_TOKEN! });
|
|
32
|
+
await account.keys.list();
|
|
33
|
+
const issued = await account.keys.create({ name: "My app" });
|
|
34
|
+
await account.keys.update(issued.key.id, { name: "Renamed app" });
|
|
35
|
+
await account.keys.delete(issued.key.id);
|
|
36
|
+
await account.account.get(); // includes billing status and limits
|
|
37
|
+
await account.account.usage();
|
|
38
|
+
await account.account.logout();
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
`account.account.authorizeLogin({code_challenge, redirect_uri})` and
|
|
42
|
+
`Aex.exchangeLogin({code, code_verifier, redirect_uri})` expose the shared HTTP login
|
|
43
|
+
contract for clients. The `@aexhq/cli` package handles opening the browser, PKCE,
|
|
44
|
+
loopback callback and local credential storage.
|
package/dist/generated.d.ts
CHANGED
|
@@ -78,3 +78,36 @@ export interface IssuedKey {
|
|
|
78
78
|
export interface KeyInput {
|
|
79
79
|
name: string;
|
|
80
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* This interface was referenced by `AexContracts`'s JSON-Schema
|
|
83
|
+
* via the `definition` "LoginGrantInput".
|
|
84
|
+
*/
|
|
85
|
+
export interface LoginGrantInput {
|
|
86
|
+
code_challenge: string;
|
|
87
|
+
redirect_uri: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* This interface was referenced by `AexContracts`'s JSON-Schema
|
|
91
|
+
* via the `definition` "LoginGrant".
|
|
92
|
+
*/
|
|
93
|
+
export interface LoginGrant {
|
|
94
|
+
code: string;
|
|
95
|
+
expires: number;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* This interface was referenced by `AexContracts`'s JSON-Schema
|
|
99
|
+
* via the `definition` "LoginExchange".
|
|
100
|
+
*/
|
|
101
|
+
export interface LoginExchange {
|
|
102
|
+
code: string;
|
|
103
|
+
code_verifier: string;
|
|
104
|
+
redirect_uri: string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* This interface was referenced by `AexContracts`'s JSON-Schema
|
|
108
|
+
* via the `definition` "AccountSession".
|
|
109
|
+
*/
|
|
110
|
+
export interface AccountSession {
|
|
111
|
+
expires: number;
|
|
112
|
+
token: string;
|
|
113
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
export * from "@aexhq/brain";
|
|
2
2
|
export type * from "./generated.js";
|
|
3
3
|
import { Brain, type BrainOptions } from "@aexhq/brain";
|
|
4
|
-
import type { Account, Usage, ApiKey, IssuedKey, KeyInput } from "./generated.js";
|
|
5
|
-
export type
|
|
6
|
-
apiKey: string;
|
|
4
|
+
import type { Account, Usage, ApiKey, IssuedKey, KeyInput, LoginGrantInput, LoginGrant, LoginExchange, AccountSession } from "./generated.js";
|
|
5
|
+
export type AexConnection = Omit<BrainOptions, "token" | "baseUrl"> & {
|
|
7
6
|
baseUrl?: string;
|
|
8
7
|
};
|
|
8
|
+
export type AexOptions = AexConnection & ({
|
|
9
|
+
apiKey: string;
|
|
10
|
+
accountToken?: never;
|
|
11
|
+
} | {
|
|
12
|
+
accountToken: string;
|
|
13
|
+
apiKey?: never;
|
|
14
|
+
});
|
|
9
15
|
export declare class Aex extends Brain {
|
|
10
|
-
constructor({ apiKey, ...options }: AexOptions);
|
|
16
|
+
constructor({ apiKey, accountToken, ...options }: AexOptions);
|
|
17
|
+
static exchangeLogin(input: LoginExchange, options?: AexConnection): Promise<AccountSession>;
|
|
11
18
|
readonly account: {
|
|
12
19
|
get: () => Promise<Account>;
|
|
13
20
|
usage: () => Promise<Usage>;
|
|
21
|
+
logout: () => Promise<void>;
|
|
22
|
+
authorizeLogin: (input: LoginGrantInput) => Promise<LoginGrant>;
|
|
14
23
|
};
|
|
15
24
|
/** Key management requires an account session; workload API keys cannot create credentials. */
|
|
16
25
|
readonly keys: {
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
export * from "@aexhq/brain";
|
|
2
2
|
import { Brain } from "@aexhq/brain";
|
|
3
3
|
export class Aex extends Brain {
|
|
4
|
-
constructor({ apiKey, ...options }) {
|
|
5
|
-
if (!apiKey)
|
|
6
|
-
throw new TypeError("apiKey is required");
|
|
7
|
-
super({ baseUrl: "https://api.aex.dev", ...options, token: apiKey });
|
|
4
|
+
constructor({ apiKey, accountToken, ...options }) {
|
|
5
|
+
if (!(apiKey || accountToken) || (apiKey && accountToken))
|
|
6
|
+
throw new TypeError("one apiKey or accountToken is required");
|
|
7
|
+
super({ baseUrl: "https://api.aex.dev", ...options, token: apiKey ?? accountToken });
|
|
8
|
+
}
|
|
9
|
+
static exchangeLogin(input, options = {}) {
|
|
10
|
+
return new Brain({ baseUrl: "https://api.aex.dev", ...options }).request("POST", "/v1/auth/exchange", input);
|
|
8
11
|
}
|
|
9
12
|
account = {
|
|
10
13
|
get: () => this.request("GET", "/v1/account"),
|
|
11
14
|
usage: () => this.request("GET", "/v1/usage"),
|
|
15
|
+
logout: () => this.request("DELETE", "/v1/account/session"),
|
|
16
|
+
authorizeLogin: (input) => this.request("POST", "/v1/auth/grants", input),
|
|
12
17
|
};
|
|
13
18
|
/** Key management requires an account session; workload API keys cannot create credentials. */
|
|
14
19
|
keys = {
|
package/package.json
CHANGED
|
@@ -1,16 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aexhq/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.70.0",
|
|
4
4
|
"description": "Aex accounts and hosted sessions using the Brain SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"sideEffects": false,
|
|
8
|
-
"engines": {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=22"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/aexhq/aex.git",
|
|
14
|
+
"directory": "packages/sdk"
|
|
15
|
+
},
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"README.md"
|
|
25
|
+
],
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public",
|
|
28
|
+
"tag": "next"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@aexhq/brain": "0.19.0"
|
|
32
|
+
},
|
|
14
33
|
"scripts": {
|
|
15
34
|
"gen": "node ../../tools/sdk-contracts.mjs",
|
|
16
35
|
"build": "tsc -p tsconfig.json",
|