@curless/agentbank-sdk 0.1.2 → 0.2.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 +7 -1
- package/dist/buyer-wallet.d.ts +37 -0
- package/dist/buyer-wallet.d.ts.map +1 -0
- package/dist/buyer-wallet.js +132 -0
- package/dist/buyer-wallet.js.map +1 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -56,6 +56,12 @@ if (auth.status === 'authorized') {
|
|
|
56
56
|
## Notes
|
|
57
57
|
|
|
58
58
|
- **Amounts** are minor-unit integers (USD = cents).
|
|
59
|
-
- **Errors** throw `AgentbankError` with `.status` + `.code
|
|
59
|
+
- **Errors** throw `AgentbankError` with `.status` + `.code` — including
|
|
60
|
+
transport failures: `status === 0` with code `timeout` / `aborted` /
|
|
61
|
+
`network_error` means no HTTP response happened. One catch type.
|
|
62
|
+
- **Timeouts**: every request has a 30s deadline by default. Tune per client
|
|
63
|
+
(`new Agentbank({ ..., timeoutMs })`) or per request
|
|
64
|
+
(`RequestOptions.timeoutMs`; `0` disables). `RequestOptions.signal` accepts
|
|
65
|
+
an `AbortSignal` for caller-side cancellation.
|
|
60
66
|
- ESM-only; Node ≥ 18 (uses global `fetch`).
|
|
61
67
|
- Pass `fetch` in the constructor to inject a custom implementation (tests, proxies).
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export type BuyerUser = {
|
|
2
|
+
id: string;
|
|
3
|
+
email: string;
|
|
4
|
+
name: string | null;
|
|
5
|
+
mode: string;
|
|
6
|
+
};
|
|
7
|
+
export type DeviceLogin = {
|
|
8
|
+
userCode: string;
|
|
9
|
+
verificationUri: string;
|
|
10
|
+
verificationUriComplete: string;
|
|
11
|
+
expiresIn: number;
|
|
12
|
+
interval: number;
|
|
13
|
+
};
|
|
14
|
+
export type BuyerSession = {
|
|
15
|
+
login: (email: string, password: string) => Promise<BuyerUser>;
|
|
16
|
+
/**
|
|
17
|
+
* Begin a browser sign-in for a client that has no browser.
|
|
18
|
+
*
|
|
19
|
+
* Returns where to send the person and a `wait()` that resolves when they
|
|
20
|
+
* finish there. The device code itself never leaves this object — it is the
|
|
21
|
+
* bearer credential that collects the resulting session, so handing it to a
|
|
22
|
+
* caller who only needs a URL would be handing out the login.
|
|
23
|
+
*/
|
|
24
|
+
startDeviceLogin: () => Promise<DeviceLogin & {
|
|
25
|
+
wait: () => Promise<BuyerUser>;
|
|
26
|
+
}>;
|
|
27
|
+
fetch: <T>(path: string, init?: RequestInit) => Promise<T>;
|
|
28
|
+
current: () => BuyerUser | null;
|
|
29
|
+
/** Revoke the session server-side, then forget it. Safe to call signed out. */
|
|
30
|
+
logout: () => Promise<void>;
|
|
31
|
+
};
|
|
32
|
+
export declare const NOT_LOGGED_IN = "buyer_not_logged_in";
|
|
33
|
+
export declare const SESSION_EXPIRED = "buyer_session_expired";
|
|
34
|
+
export declare const createBuyerSession: (opts: {
|
|
35
|
+
baseUrl: string;
|
|
36
|
+
}) => BuyerSession;
|
|
37
|
+
//# sourceMappingURL=buyer-wallet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buyer-wallet.d.ts","sourceRoot":"","sources":["../src/buyer-wallet.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,SAAS,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzF,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,uBAAuB,EAAE,MAAM,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,SAAS,CAAC,CAAC;IAC/D;;;;;;;OAOG;IACH,gBAAgB,EAAE,MAAM,OAAO,CAAC,WAAW,GAAG;QAAE,IAAI,EAAE,MAAM,OAAO,CAAC,SAAS,CAAC,CAAA;KAAE,CAAC,CAAC;IAClF,KAAK,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3D,OAAO,EAAE,MAAM,SAAS,GAAG,IAAI,CAAC;IAChC,+EAA+E;IAC/E,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7B,CAAC;AAKF,eAAO,MAAM,aAAa,wBAAwB,CAAC;AACnD,eAAO,MAAM,eAAe,0BAA0B,CAAC;AAEvD,eAAO,MAAM,kBAAkB,GAAI,MAAM;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,KAAG,YAsK9D,CAAC"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { AgentbankError, toError } from '@curless/agentbank-core';
|
|
2
|
+
// Distinct codes so the model can tell the two states apart and say the right
|
|
3
|
+
// thing to the person. Collapsing them is how "your session expired" gets
|
|
4
|
+
// rendered as "you have no orders".
|
|
5
|
+
export const NOT_LOGGED_IN = 'buyer_not_logged_in';
|
|
6
|
+
export const SESSION_EXPIRED = 'buyer_session_expired';
|
|
7
|
+
export const createBuyerSession = (opts) => {
|
|
8
|
+
let token = null;
|
|
9
|
+
let user = null;
|
|
10
|
+
// Wall-clock expiry from the server's expiresIn, so an obviously-dead token
|
|
11
|
+
// is reported as expired without a round-trip that would 401 anyway.
|
|
12
|
+
let expiresAt = 0;
|
|
13
|
+
const call = async (path, init = {}, bearer,
|
|
14
|
+
// Statuses that carry a meaningful body rather than an error. Device
|
|
15
|
+
// polling uses it: 202 means "not yet", which is an answer.
|
|
16
|
+
alsoOk) => {
|
|
17
|
+
let res;
|
|
18
|
+
try {
|
|
19
|
+
res = await fetch(`${opts.baseUrl}${path}`, {
|
|
20
|
+
...init,
|
|
21
|
+
headers: {
|
|
22
|
+
'content-type': 'application/json',
|
|
23
|
+
...(bearer ? { authorization: `Bearer ${bearer}` } : {}),
|
|
24
|
+
...(init.headers ?? {}),
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
throw new AgentbankError(0, 'network_error', `agentbank API unreachable at ${opts.baseUrl}: ${err.message}`);
|
|
30
|
+
}
|
|
31
|
+
if (!res.ok && !alsoOk?.(res.status)) {
|
|
32
|
+
const text = await res.text().catch(() => '');
|
|
33
|
+
let json;
|
|
34
|
+
try {
|
|
35
|
+
json = text ? JSON.parse(text) : undefined;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
json = undefined;
|
|
39
|
+
}
|
|
40
|
+
throw toError(res.status, json);
|
|
41
|
+
}
|
|
42
|
+
return (await res.json());
|
|
43
|
+
};
|
|
44
|
+
const adopt = (body) => {
|
|
45
|
+
token = body.token;
|
|
46
|
+
user = body.user;
|
|
47
|
+
expiresAt = Date.now() + body.expiresIn * 1000;
|
|
48
|
+
return body.user;
|
|
49
|
+
};
|
|
50
|
+
return {
|
|
51
|
+
startDeviceLogin: async () => {
|
|
52
|
+
const started = await call('/v1/buyer/device', {
|
|
53
|
+
method: 'POST',
|
|
54
|
+
body: '{}',
|
|
55
|
+
});
|
|
56
|
+
const deadline = Date.now() + started.expiresIn * 1000;
|
|
57
|
+
const wait = async () => {
|
|
58
|
+
// Server-driven interval, and it can raise it: a `slow_down` that the
|
|
59
|
+
// client ignores is a client that keeps being told to slow down.
|
|
60
|
+
let waitMs = started.interval * 1000;
|
|
61
|
+
while (Date.now() < deadline) {
|
|
62
|
+
await new Promise((r) => setTimeout(r, waitMs));
|
|
63
|
+
const res = await call('/v1/buyer/device/token', { method: 'POST', body: JSON.stringify({ deviceCode: started.deviceCode }) }, undefined,
|
|
64
|
+
// 202 is "not finished", not a failure — the generic error path
|
|
65
|
+
// would abandon a login the person is still completing.
|
|
66
|
+
(status) => status === 202).catch((err) => {
|
|
67
|
+
throw err;
|
|
68
|
+
});
|
|
69
|
+
if (res.status === 'approved' && res.token && res.user) {
|
|
70
|
+
return adopt({ token: res.token, expiresIn: res.expiresIn ?? 3600, user: res.user });
|
|
71
|
+
}
|
|
72
|
+
if (res.status === 'slow_down')
|
|
73
|
+
waitMs = Math.min(waitMs * 2, 10_000);
|
|
74
|
+
}
|
|
75
|
+
throw new AgentbankError(408, 'buyer_login_timeout', 'the sign-in was not completed in time — start it again');
|
|
76
|
+
};
|
|
77
|
+
const { deviceCode: _secret, ...publicPart } = started;
|
|
78
|
+
return { ...publicPart, wait };
|
|
79
|
+
},
|
|
80
|
+
login: async (email, password) => {
|
|
81
|
+
const body = await call('/v1/buyer/session', { method: 'POST', body: JSON.stringify({ email, password }) });
|
|
82
|
+
return adopt(body);
|
|
83
|
+
},
|
|
84
|
+
fetch: async (path, init = {}) => {
|
|
85
|
+
if (!token) {
|
|
86
|
+
throw new AgentbankError(401, NOT_LOGGED_IN, 'no wallet session on this server yet — call wallet_login with the buyer’s email first');
|
|
87
|
+
}
|
|
88
|
+
if (Date.now() >= expiresAt) {
|
|
89
|
+
// Say it plainly and drop the dead token. A stale bearer that keeps
|
|
90
|
+
// getting sent turns every wallet read into an opaque 401, and an
|
|
91
|
+
// expired session rendered as an empty balance is a lie about money.
|
|
92
|
+
token = null;
|
|
93
|
+
const who = user?.email;
|
|
94
|
+
user = null;
|
|
95
|
+
throw new AgentbankError(401, SESSION_EXPIRED, `the wallet session${who ? ` for ${who}` : ''} has expired — call wallet_login again. This is NOT a zero balance and NOT an empty order list.`);
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
return await call(path, init, token);
|
|
99
|
+
}
|
|
100
|
+
catch (err) {
|
|
101
|
+
// The server rejected a token we believed in — revoked, or signed by a
|
|
102
|
+
// deployment that has since rotated its secret. Same rule: report the
|
|
103
|
+
// session, not the resource.
|
|
104
|
+
//
|
|
105
|
+
// ⚠️ 401 ONLY. A 403 means the server knows exactly who this is and is
|
|
106
|
+
// refusing the ACTION — "over the limit you set", "live mode", "this
|
|
107
|
+
// wallet is suspended". Treating those as an expired session signs the
|
|
108
|
+
// person out for hitting their own spend cap, and then they cannot even
|
|
109
|
+
// raise it, because raising it needs the session they just lost.
|
|
110
|
+
if (err instanceof AgentbankError && err.status === 401) {
|
|
111
|
+
token = null;
|
|
112
|
+
user = null;
|
|
113
|
+
throw new AgentbankError(err.status, SESSION_EXPIRED, `the wallet session is no longer valid — call wallet_login again. This is NOT a zero balance and NOT an empty order list. (${err.message})`);
|
|
114
|
+
}
|
|
115
|
+
throw err;
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
current: () => user,
|
|
119
|
+
logout: async () => {
|
|
120
|
+
// Tell the server FIRST, while the credential still works. Forgetting it
|
|
121
|
+
// locally and then trying to revoke would leave a live token nobody can
|
|
122
|
+
// reach — a sign-out in appearance only.
|
|
123
|
+
if (token) {
|
|
124
|
+
await call('/v1/buyer/session/revoke', { method: 'POST', body: '{}' }, token).catch(() => undefined);
|
|
125
|
+
}
|
|
126
|
+
token = null;
|
|
127
|
+
user = null;
|
|
128
|
+
expiresAt = 0;
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
//# sourceMappingURL=buyer-wallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buyer-wallet.js","sourceRoot":"","sources":["../src/buyer-wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAsClE,8EAA8E;AAC9E,0EAA0E;AAC1E,oCAAoC;AACpC,MAAM,CAAC,MAAM,aAAa,GAAG,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AE,KAAK,IAAI,EAAE;YACjB,yEAAyE;YACzE,wEAAwE;YACxE,yCAAyC;YACzC,IAAI,KAAK,EAAE,CAAC;gBACV,MAAM,IAAI,CAAC,0BAA0B,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC,KAAK,CACjF,GAAG,EAAE,CAAC,SAAS,CAChB,CAAC;YACJ,CAAC;YACD,KAAK,GAAG,IAAI,CAAC;YACb,IAAI,GAAG,IAAI,CAAC;YACZ,SAAS,GAAG,CAAC,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
export { Agentbank } from './client.js';
|
|
2
2
|
export type { AgentbankOptions, FetchLike, RequestOptions } from './client.js';
|
|
3
|
-
export { AgentbankError } from '@curless/agentbank-core';
|
|
3
|
+
export { AgentbankError, toError } from '@curless/agentbank-core';
|
|
4
|
+
/**
|
|
5
|
+
* The buyer's wallet session — the face an integrator actually uses.
|
|
6
|
+
*
|
|
7
|
+
* It lives HERE, not in @curless/agentbank-core: core is the shared kernel
|
|
8
|
+
* (crypto, errors, HTTP) that every package builds on, and nobody outside this
|
|
9
|
+
* repo should be importing it directly. This is the official buyer SDK, so this
|
|
10
|
+
* is where a buyer-side capability belongs.
|
|
11
|
+
*/
|
|
12
|
+
export { NOT_LOGGED_IN, SESSION_EXPIRED, type BuyerSession, type BuyerUser, type DeviceLogin, createBuyerSession, } from './buyer-wallet.js';
|
|
4
13
|
export type { CreateAgentInput, UpdateAgentInput, AgentCredentialScope, } from './resources/agents.js';
|
|
5
14
|
export type { CreateCustomerInput, UpdateCustomerInput } from './resources/customers.js';
|
|
6
15
|
export type { CatalogItem, Merchant } from './resources/merchants.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElE;;;;;;;GAOG;AACH,OAAO,EACL,aAAa,EACb,eAAe,EACf,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACzF,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACtE,YAAY,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,YAAY,EACV,KAAK,EACL,eAAe,EACf,sBAAsB,EACtB,WAAW,EACX,kBAAkB,EAClB,QAAQ,EACR,cAAc,EACd,eAAe,EACf,QAAQ,EACR,SAAS,EACT,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,wBAAwB,EACxB,WAAW,EACX,aAAa,GACd,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
export { Agentbank } from './client.js';
|
|
2
|
-
export { AgentbankError } from '@curless/agentbank-core';
|
|
2
|
+
export { AgentbankError, toError } from '@curless/agentbank-core';
|
|
3
|
+
/**
|
|
4
|
+
* The buyer's wallet session — the face an integrator actually uses.
|
|
5
|
+
*
|
|
6
|
+
* It lives HERE, not in @curless/agentbank-core: core is the shared kernel
|
|
7
|
+
* (crypto, errors, HTTP) that every package builds on, and nobody outside this
|
|
8
|
+
* repo should be importing it directly. This is the official buyer SDK, so this
|
|
9
|
+
* is where a buyer-side capability belongs.
|
|
10
|
+
*/
|
|
11
|
+
export { NOT_LOGGED_IN, SESSION_EXPIRED, createBuyerSession, } from './buyer-wallet.js';
|
|
3
12
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElE;;;;;;;GAOG;AACH,OAAO,EACL,aAAa,EACb,eAAe,EAIf,kBAAkB,GACnB,MAAM,mBAAmB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@curless/agentbank-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Official buyer/agent SDK for agentbank — OAuth, agent + customer management, Wallets, and the Pay spend-control plane.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"README.md"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@curless/agentbank-core": "^0.
|
|
20
|
+
"@curless/agentbank-core": "^0.7.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/node": "^22.10.1",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"repository": {
|
|
40
40
|
"type": "git",
|
|
41
41
|
"url": "git+https://gitlab.com/robin-ruan/agentbank.git",
|
|
42
|
-
"directory": "packages/sdk"
|
|
42
|
+
"directory": "packages/sdks/sdk"
|
|
43
43
|
},
|
|
44
44
|
"author": "robin",
|
|
45
45
|
"scripts": {
|