@apteva/web-sdk 0.7.0 → 0.9.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/CHANGELOG.md +28 -0
- package/README.md +103 -0
- package/dist/auth-session.d.ts +83 -0
- package/dist/auth-session.d.ts.map +1 -0
- package/dist/auth-session.js +300 -0
- package/dist/auth-session.js.map +1 -0
- package/dist/client.d.ts +12 -3
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +133 -32
- package/dist/client.js.map +1 -1
- package/dist/extensions.d.ts +3 -0
- package/dist/extensions.d.ts.map +1 -1
- package/dist/extensions.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
## 0.9.0
|
|
2
|
+
|
|
3
|
+
- Add `credential: "auth" | "platform"` to app handles, extensions and frontend
|
|
4
|
+
loaders. HTTP, MCP and SSE use the selected credential within one managed session.
|
|
5
|
+
- Refresh Auth and platform credentials independently with shared renewal across
|
|
6
|
+
handles. Auth routes remain usable when platform minting is unavailable.
|
|
7
|
+
- Prevent stale mints and old-session 401s from overwriting a newer session.
|
|
8
|
+
Both stream types reconnect at their credential expiry and close on logout or
|
|
9
|
+
detected session revocation. No credential fallback or HTTP replay after a 401.
|
|
10
|
+
- Restrict managed forwarding to the configured server, project and scoped app
|
|
11
|
+
routes; reject escaped paths, URL credentials, header overrides and redirects.
|
|
12
|
+
- Managed `getAccessToken()` now returns `undefined`; use app handles instead.
|
|
13
|
+
Host-owned opaque-token transport retains its existing behavior.
|
|
14
|
+
- Add mixed-session regression tests and an opt-in integration harness using real
|
|
15
|
+
Auth, API and Telephony handlers. Platform mint/Conversations gateway are fixtures.
|
|
16
|
+
- Requires Auth v0.12.0 or newer. No additional Auth or server release required.
|
|
17
|
+
|
|
18
|
+
## 0.8.0
|
|
19
|
+
|
|
20
|
+
- Add unified Auth app login/signup, user lookup, session metadata, automatic
|
|
21
|
+
platform-token renewal and logout through `AptevaClient({ auth })`.
|
|
22
|
+
- Coordinate Auth refresh rotation and platform renewal, preserve rotated Auth
|
|
23
|
+
credentials during mint outages, and ignore late results after session changes.
|
|
24
|
+
- Keep app-user credentials isolated from API keys/cookies; reconnect managed
|
|
25
|
+
streams at expiry and close them on logout. Existing SDK auth mode is unchanged.
|
|
26
|
+
- Requires Auth v0.12.0 with explicit role bindings and platform policy lifetimes
|
|
27
|
+
of at most 60 seconds. Sessions are memory-only; reloads require login.
|
|
28
|
+
|
|
1
29
|
# Changelog
|
|
2
30
|
|
|
3
31
|
## 0.7.0 — 2026-09-07
|
package/README.md
CHANGED
|
@@ -556,3 +556,106 @@ bun run serve
|
|
|
556
556
|
## License
|
|
557
557
|
|
|
558
558
|
MIT
|
|
559
|
+
|
|
560
|
+
## One client for Auth app sessions (v0.9.0)
|
|
561
|
+
|
|
562
|
+
With Auth app v0.12.0 or newer, configure `auth` and use the same client for
|
|
563
|
+
login, app requests, agents and logout:
|
|
564
|
+
|
|
565
|
+
```ts
|
|
566
|
+
const apteva = new AptevaClient({
|
|
567
|
+
baseURL: "https://agents.example.com",
|
|
568
|
+
projectId: "YOUR_PROJECT",
|
|
569
|
+
auth: {
|
|
570
|
+
clientId: "YOUR_PUBLIC_AUTH_CLIENT",
|
|
571
|
+
// installId: 209, // when explicit install routing is needed
|
|
572
|
+
// organizationSlug: "default",// for a multi-organization Auth client
|
|
573
|
+
// profile: "commercial", // requested role policy; checked by Auth
|
|
574
|
+
onSessionChange: session => renderUser(session?.user),
|
|
575
|
+
},
|
|
576
|
+
});
|
|
577
|
+
|
|
578
|
+
const user = await apteva.auth.login({ email, password });
|
|
579
|
+
const crm = apteva.app("api", { credential: "auth" });
|
|
580
|
+
const conversations = apteva.app("conversations", { credential: "platform" });
|
|
581
|
+
await crm.get("/YOUR_CRM_ROUTE");
|
|
582
|
+
await conversations.get("/chats");
|
|
583
|
+
|
|
584
|
+
const telephony = await apteva.apps.load("telephony", {
|
|
585
|
+
credential: "auth",
|
|
586
|
+
installId: YOUR_TELEPHONY_INSTALL_ID,
|
|
587
|
+
clientOptions: { authProvider: "YOUR_CONFIGURED_PROVIDER" },
|
|
588
|
+
});
|
|
589
|
+
// The loaded client keeps this Auth handle for /user/ calls and subscriptions.
|
|
590
|
+
await apteva.auth.logout();
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
`auth.register({ email, password, displayName? })` also supports signup. When
|
|
594
|
+
email verification is required, it returns `verification_required: true` and
|
|
595
|
+
does not establish a session. `auth.me()` reads the current Auth user;
|
|
596
|
+
`auth.getSession()` returns a local copy of user, authorization and expiry
|
|
597
|
+
metadata without credentials. `auth.status()` reports local session presence.
|
|
598
|
+
`auth.refresh()` explicitly requests a fresh platform credential when needed.
|
|
599
|
+
|
|
600
|
+
Auth owns identity and authorization. Configure its trusted role bindings and
|
|
601
|
+
matching platform policies with `token_ttl_seconds: 60` before enabling platform
|
|
602
|
+
app access. Login can succeed without platform permissions; platform calls fail
|
|
603
|
+
closed until an authorized policy can mint a token. Auth-credential routes remain
|
|
604
|
+
available according to their own current user permissions. A requested profile never grants a
|
|
605
|
+
role. The SDK does not infer permissions or mint credentials itself.
|
|
606
|
+
|
|
607
|
+
The SDK privately maintains the normal Auth session plus its short-lived
|
|
608
|
+
platform token. Choose `credential: "auth"` for API Auth-policy routes and
|
|
609
|
+
Telephony `/user/` routes; choose `"platform"` for Conversations. Omitted choices
|
|
610
|
+
default to `"platform"`. The choice applies to every HTTP method, MCP tool and
|
|
611
|
+
subscription on that handle, and to `client.use` and `client.apps.load`. Loaded
|
|
612
|
+
frontend assets and the resulting app client share the selected handle.
|
|
613
|
+
|
|
614
|
+
Before a request, the SDK renews the selected credential when it is within ten
|
|
615
|
+
seconds of expiry. Auth tokens use the normal Auth refresh flow; platform tokens
|
|
616
|
+
use `/delegated-token`. Auth requests do not require a working mint policy. Concurrent operations share renewal and refresh-token rotation; no custom
|
|
617
|
+
refresh callback or application token endpoint is required. Both the returned
|
|
618
|
+
absolute expiry and remaining lifetime limit credential use. Fetch streams
|
|
619
|
+
reconnect at token expiry and close on local logout. SDK stream reconnection is
|
|
620
|
+
not server-side revocation: already-admitted work or a modified client may outlive
|
|
621
|
+
token expiry unless the receiving app enforces its own lifetime.
|
|
622
|
+
|
|
623
|
+
Sessions are kept **in memory**, not written to localStorage, sessionStorage or
|
|
624
|
+
cookies. Reuse one client per application session. Reloads/new tabs require
|
|
625
|
+
login and do not implicitly share a rotating refresh credential. Do not copy
|
|
626
|
+
refresh tokens between clients/tabs. This release deliberately does not provide
|
|
627
|
+
persistent/shared browser sessions.
|
|
628
|
+
|
|
629
|
+
`auth` mode cannot be combined with `apiKey`, `accessToken` or
|
|
630
|
+
`refreshAccessToken`; `setApiKey` and `setAccessToken` are unavailable in this
|
|
631
|
+
mode. `getAccessToken()` now returns `undefined` in managed mode: use scoped
|
|
632
|
+
handles instead of extracting either credential. Host-owned opaque tokens retain
|
|
633
|
+
the existing getter behavior. Auth handles cannot change the configured project
|
|
634
|
+
or escape their app routes; credentials are never forwarded through redirects
|
|
635
|
+
or accepted from URL parameters or header overrides.
|
|
636
|
+
|
|
637
|
+
User requests omit cookies and never fall back to a kiosk or administrator
|
|
638
|
+
credential. Platform administrator operations such as `auth.listKeys()` are
|
|
639
|
+
rejected in app Auth mode. Without `auth` configuration, existing platform
|
|
640
|
+
login and opaque-token APIs retain their original behavior.
|
|
641
|
+
|
|
642
|
+
A temporary mint failure preserves the normal Auth session and blocks only
|
|
643
|
+
platform-credential requests. Credential types never switch after an error. A rejected Auth refresh clears the session. Local logout clears
|
|
644
|
+
credentials and streams immediately; a failed network logout still throws so the
|
|
645
|
+
host can report that server-side revocation could not be confirmed. A late
|
|
646
|
+
renewal cannot restore a logged-out session. HTTP writes are never automatically
|
|
647
|
+
replayed after a 401; successful renewal prepares subsequent calls. Unlike legacy
|
|
648
|
+
transport mode, a successfully recovered 401 does not trigger the
|
|
649
|
+
`onUnauthorized` callback in managed Auth mode, although the original call still
|
|
650
|
+
rejects. Reconcile a write's outcome before retrying it.
|
|
651
|
+
|
|
652
|
+
|
|
653
|
+
### Mixed-app integration check
|
|
654
|
+
|
|
655
|
+
Run `APTEVA_APPS_DIR=/path/to/apps bun run test:mixed-apps` with a compatible Go
|
|
656
|
+
compiler (`GO_BINARY` can select it). This uses real Auth handlers, API's
|
|
657
|
+
`auth_jwt` validator and Telephony's `/user/` handler, temporary databases and
|
|
658
|
+
local fixture servers. The platform mint API and protected Conversations gateway
|
|
659
|
+
are simulated. It verifies routing, role downgrade, and server-side session
|
|
660
|
+
revocation without accessing live accounts or carriers. Set `SDK_TEST_MODULE` to
|
|
661
|
+
an unpacked package's `dist/index.js` to check the release artifact.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { AppCredential } from "./extensions.js";
|
|
2
|
+
import type { User } from "./types.js";
|
|
3
|
+
export interface AuthLoginInput {
|
|
4
|
+
email: string;
|
|
5
|
+
password: string;
|
|
6
|
+
}
|
|
7
|
+
export interface AuthSignupInput extends AuthLoginInput {
|
|
8
|
+
displayName?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface AuthUser extends User {
|
|
11
|
+
id: number;
|
|
12
|
+
display_name?: string;
|
|
13
|
+
status?: string;
|
|
14
|
+
organization_id?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface AuthAuthorization {
|
|
17
|
+
roles: string[];
|
|
18
|
+
permissions: string[];
|
|
19
|
+
authorization_version: number;
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
}
|
|
22
|
+
export interface AuthSessionInfo {
|
|
23
|
+
user: AuthUser;
|
|
24
|
+
authorization?: AuthAuthorization;
|
|
25
|
+
expiresAt: string;
|
|
26
|
+
platformExpiresAt?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface AppAuthOptions {
|
|
29
|
+
/** Public Auth app OAuth client identifier; never a private client secret. */
|
|
30
|
+
clientId: string;
|
|
31
|
+
installId?: number;
|
|
32
|
+
organizationSlug?: string;
|
|
33
|
+
/** Requested Auth policy profile. Auth independently checks current roles. */
|
|
34
|
+
profile?: string;
|
|
35
|
+
/** Receives user/session metadata, never credentials. Sessions are memory-only. */
|
|
36
|
+
onSessionChange?: (session: AuthSessionInfo | undefined) => void;
|
|
37
|
+
}
|
|
38
|
+
export interface SessionCredential {
|
|
39
|
+
token: string;
|
|
40
|
+
epoch: number;
|
|
41
|
+
revision: number;
|
|
42
|
+
deadline: number;
|
|
43
|
+
}
|
|
44
|
+
/** Internal issuer-specific session lifecycle. AptevaClient is the public API. */
|
|
45
|
+
export declare class AuthSession {
|
|
46
|
+
private readonly baseURL;
|
|
47
|
+
private readonly projectId;
|
|
48
|
+
private readonly options;
|
|
49
|
+
private readonly fetchImpl;
|
|
50
|
+
private readonly changed;
|
|
51
|
+
private state?;
|
|
52
|
+
private epoch;
|
|
53
|
+
private authRevision;
|
|
54
|
+
private platformRevision;
|
|
55
|
+
private pending?;
|
|
56
|
+
private pendingAuth?;
|
|
57
|
+
private controllers;
|
|
58
|
+
private listeners;
|
|
59
|
+
constructor(baseURL: string, projectId: string, options: AppAuthOptions, fetchImpl: typeof fetch, changed: (token: string | undefined) => void);
|
|
60
|
+
info(): AuthSessionInfo | undefined;
|
|
61
|
+
onClear(listener: () => void): () => void;
|
|
62
|
+
private notify;
|
|
63
|
+
clear(): void;
|
|
64
|
+
private assertEpoch;
|
|
65
|
+
private call;
|
|
66
|
+
private input;
|
|
67
|
+
private platform;
|
|
68
|
+
private accept;
|
|
69
|
+
login(input: AuthLoginInput): Promise<AuthUser>;
|
|
70
|
+
register(input: AuthSignupInput): Promise<{
|
|
71
|
+
user: AuthUser;
|
|
72
|
+
verification_required?: boolean;
|
|
73
|
+
}>;
|
|
74
|
+
logout(): Promise<void>;
|
|
75
|
+
private refreshAuth;
|
|
76
|
+
private performAuthRefresh;
|
|
77
|
+
private renew;
|
|
78
|
+
token(force?: boolean): Promise<string>;
|
|
79
|
+
me(): Promise<AuthUser>;
|
|
80
|
+
credential(kind: AppCredential): Promise<SessionCredential>;
|
|
81
|
+
recover(kind: AppCredential, used: SessionCredential): Promise<boolean>;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=auth-session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-session.d.ts","sourceRoot":"","sources":["../src/auth-session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,WAAW,cAAc;IAAG,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE;AACnE,MAAM,WAAW,eAAgB,SAAQ,cAAc;IAAG,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE;AAChF,MAAM,WAAW,QAAS,SAAQ,IAAI;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AACD,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AACD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,QAAQ,CAAC;IACf,aAAa,CAAC,EAAE,iBAAiB,CAAC;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AACD,MAAM,WAAW,cAAc;IAC7B,8EAA8E;IAC9E,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;I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C,QAAQ;IAShB,OAAO,CAAC,MAAM;IAeR,KAAK,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC;IAK/C,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,QAAQ,CAAC;QAAC,qBAAqB,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IAO9F,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;YAKf,WAAW;YAMX,kBAAkB;YAWlB,KAAK;IA+Bb,KAAK,CAAC,KAAK,UAAQ,GAAG,OAAO,CAAC,MAAM,CAAC;IAgBrC,EAAE,IAAI,OAAO,CAAC,QAAQ,CAAC;IAmBvB,UAAU,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAkB3D,OAAO,CAAC,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;CAS9E"}
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { AptevaError } from "./errors.js";
|
|
2
|
+
const margin = 10_000;
|
|
3
|
+
/** Internal issuer-specific session lifecycle. AptevaClient is the public API. */
|
|
4
|
+
export class AuthSession {
|
|
5
|
+
baseURL;
|
|
6
|
+
projectId;
|
|
7
|
+
options;
|
|
8
|
+
fetchImpl;
|
|
9
|
+
changed;
|
|
10
|
+
state;
|
|
11
|
+
epoch = 0;
|
|
12
|
+
authRevision = 0;
|
|
13
|
+
platformRevision = 0;
|
|
14
|
+
pending;
|
|
15
|
+
pendingAuth;
|
|
16
|
+
controllers = new Set();
|
|
17
|
+
listeners = new Set();
|
|
18
|
+
constructor(baseURL, projectId, options, fetchImpl, changed) {
|
|
19
|
+
this.baseURL = baseURL;
|
|
20
|
+
this.projectId = projectId;
|
|
21
|
+
this.options = options;
|
|
22
|
+
this.fetchImpl = fetchImpl;
|
|
23
|
+
this.changed = changed;
|
|
24
|
+
if (!projectId || !options.clientId?.trim())
|
|
25
|
+
throw new Error("Auth requires projectId and auth.clientId");
|
|
26
|
+
if (options.installId !== undefined && (!Number.isSafeInteger(options.installId) || options.installId < 1))
|
|
27
|
+
throw new Error("Invalid Auth installId");
|
|
28
|
+
}
|
|
29
|
+
info() {
|
|
30
|
+
const s = this.state;
|
|
31
|
+
return s ? structuredClone({ user: s.response.user, authorization: s.response.authorization,
|
|
32
|
+
expiresAt: new Date(s.expiresAt).toISOString(),
|
|
33
|
+
platformExpiresAt: s.platformExpiresAt ? new Date(s.platformExpiresAt).toISOString() : undefined }) : undefined;
|
|
34
|
+
}
|
|
35
|
+
onClear(listener) { this.listeners.add(listener); return () => this.listeners.delete(listener); }
|
|
36
|
+
notify() {
|
|
37
|
+
try {
|
|
38
|
+
this.options.onSessionChange?.(this.info());
|
|
39
|
+
}
|
|
40
|
+
catch { /* Observers cannot roll back credential rotation. */ }
|
|
41
|
+
}
|
|
42
|
+
clear() {
|
|
43
|
+
this.epoch++;
|
|
44
|
+
this.state = undefined;
|
|
45
|
+
this.pending = undefined;
|
|
46
|
+
this.pendingAuth = undefined;
|
|
47
|
+
for (const controller of this.controllers)
|
|
48
|
+
controller.abort();
|
|
49
|
+
this.controllers.clear();
|
|
50
|
+
this.changed(undefined);
|
|
51
|
+
for (const listener of this.listeners)
|
|
52
|
+
listener();
|
|
53
|
+
this.notify();
|
|
54
|
+
}
|
|
55
|
+
assertEpoch(epoch) {
|
|
56
|
+
if (this.epoch !== epoch)
|
|
57
|
+
throw new AptevaError(401, "Auth session changed");
|
|
58
|
+
}
|
|
59
|
+
async call(path, body, token, method = "POST") {
|
|
60
|
+
const url = new URL(this.baseURL + "/api/apps/auth" + path, globalThis.location?.origin || "http://localhost");
|
|
61
|
+
url.searchParams.set("project_id", this.projectId);
|
|
62
|
+
if (this.options.installId)
|
|
63
|
+
url.searchParams.set("install_id", String(this.options.installId));
|
|
64
|
+
if (this.options.profile)
|
|
65
|
+
url.searchParams.set("delegated_profile", this.options.profile);
|
|
66
|
+
const controller = new AbortController();
|
|
67
|
+
if (path !== "/logout")
|
|
68
|
+
this.controllers.add(controller);
|
|
69
|
+
const timer = setTimeout(() => controller.abort(), 15_000);
|
|
70
|
+
try {
|
|
71
|
+
const response = await this.fetchImpl(url.toString(), { method, credentials: "omit", cache: "no-store", redirect: "error",
|
|
72
|
+
headers: { "Content-Type": "application/json", ...(token ? { Authorization: `Bearer ${token}` } : {}) },
|
|
73
|
+
body: body === undefined ? undefined : JSON.stringify(body), signal: controller.signal });
|
|
74
|
+
if (!response.ok)
|
|
75
|
+
throw new AptevaError(response.status, path + " failed");
|
|
76
|
+
return response.status === 204 ? undefined : await response.json();
|
|
77
|
+
}
|
|
78
|
+
finally {
|
|
79
|
+
clearTimeout(timer);
|
|
80
|
+
this.controllers.delete(controller);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
input(body) {
|
|
84
|
+
return { ...body, client_id: this.options.clientId, organization_slug: this.options.organizationSlug };
|
|
85
|
+
}
|
|
86
|
+
platform(response) {
|
|
87
|
+
if (!response.apteva_access_token && response.apteva_expires_at === undefined && response.apteva_expires_in === undefined)
|
|
88
|
+
return { expiresAt: 0 };
|
|
89
|
+
const expiresAt = Date.parse(response.apteva_expires_at || "");
|
|
90
|
+
const seconds = response.apteva_expires_in;
|
|
91
|
+
// expires_in is measured conservatively from receipt; it also tolerates a
|
|
92
|
+
// client clock offset without ever extending a token beyond 60 seconds.
|
|
93
|
+
if (typeof response.apteva_access_token !== "string" || !response.apteva_access_token || !Number.isFinite(expiresAt) || expiresAt > Date.now() + 61_000 || typeof seconds !== "number" || !Number.isFinite(seconds) || seconds <= 0 || seconds > 60)
|
|
94
|
+
throw new AptevaError(502, "Invalid Auth platform credential expiry");
|
|
95
|
+
return { token: response.apteva_access_token, expiresAt: Math.min(expiresAt, Date.now() + seconds * 1000) };
|
|
96
|
+
}
|
|
97
|
+
accept(response, epoch, receivedAt) {
|
|
98
|
+
this.assertEpoch(epoch);
|
|
99
|
+
if (!response.user || !Number.isSafeInteger(response.user.id) || typeof response.access_token !== "string" || !response.access_token || typeof response.refresh_token !== "string" || !response.refresh_token || !Number.isFinite(response.expires_in) || response.expires_in <= 0 || response.expires_in > 86400)
|
|
100
|
+
throw new AptevaError(502, "Invalid Auth session response");
|
|
101
|
+
// Save a rotated refresh token before processing the optional platform
|
|
102
|
+
// credential, so a platform outage can never strand the Auth session.
|
|
103
|
+
this.authRevision++;
|
|
104
|
+
this.platformRevision++;
|
|
105
|
+
this.state = { response: { ...response, apteva_access_token: undefined, apteva_expires_at: undefined, apteva_expires_in: undefined }, expiresAt: receivedAt + response.expires_in * 1000, platformExpiresAt: 0 };
|
|
106
|
+
this.changed(undefined);
|
|
107
|
+
try {
|
|
108
|
+
const platform = this.platform(response);
|
|
109
|
+
this.state.response.apteva_access_token = platform.token;
|
|
110
|
+
this.state.platformExpiresAt = platform.expiresAt;
|
|
111
|
+
this.changed(platform.token);
|
|
112
|
+
}
|
|
113
|
+
finally {
|
|
114
|
+
this.notify();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
async login(input) {
|
|
118
|
+
this.clear();
|
|
119
|
+
const epoch = this.epoch;
|
|
120
|
+
const response = await this.call("/login", this.input(input));
|
|
121
|
+
this.accept(response, epoch, Date.now());
|
|
122
|
+
return response.user;
|
|
123
|
+
}
|
|
124
|
+
async register(input) {
|
|
125
|
+
this.clear();
|
|
126
|
+
const epoch = this.epoch;
|
|
127
|
+
const response = await this.call("/signup", this.input({ email: input.email, password: input.password, display_name: input.displayName }));
|
|
128
|
+
this.assertEpoch(epoch);
|
|
129
|
+
if (!response.verification_required)
|
|
130
|
+
this.accept(response, epoch, Date.now());
|
|
131
|
+
return { user: response.user, verification_required: response.verification_required };
|
|
132
|
+
}
|
|
133
|
+
async logout() {
|
|
134
|
+
const refresh = this.state?.response.refresh_token;
|
|
135
|
+
this.clear();
|
|
136
|
+
if (refresh)
|
|
137
|
+
await this.call("/logout", this.input({ refresh_token: refresh }));
|
|
138
|
+
}
|
|
139
|
+
async refreshAuth(epoch) {
|
|
140
|
+
if (this.pendingAuth)
|
|
141
|
+
return this.pendingAuth;
|
|
142
|
+
const pending = this.performAuthRefresh(epoch);
|
|
143
|
+
this.pendingAuth = pending;
|
|
144
|
+
try {
|
|
145
|
+
await pending;
|
|
146
|
+
}
|
|
147
|
+
finally {
|
|
148
|
+
if (this.pendingAuth === pending)
|
|
149
|
+
this.pendingAuth = undefined;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
async performAuthRefresh(epoch) {
|
|
153
|
+
const refresh = this.state?.response.refresh_token;
|
|
154
|
+
if (!refresh)
|
|
155
|
+
throw new AptevaError(401, "Login required");
|
|
156
|
+
try {
|
|
157
|
+
const response = await this.call("/refresh", this.input({ refresh_token: refresh }));
|
|
158
|
+
this.accept(response, epoch, Date.now());
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
if (this.epoch === epoch && error instanceof AptevaError && error.status === 401)
|
|
162
|
+
this.clear();
|
|
163
|
+
throw error;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
async renew(epoch, force) {
|
|
167
|
+
this.assertEpoch(epoch);
|
|
168
|
+
if (!this.state)
|
|
169
|
+
throw new AptevaError(401, "Login required");
|
|
170
|
+
if (this.state.expiresAt <= Date.now() + margin)
|
|
171
|
+
await this.refreshAuth(epoch);
|
|
172
|
+
this.assertEpoch(epoch);
|
|
173
|
+
if (!force && this.state.response.apteva_access_token && this.state.platformExpiresAt > Date.now() + margin)
|
|
174
|
+
return this.state.response.apteva_access_token;
|
|
175
|
+
let revision = this.authRevision;
|
|
176
|
+
let result;
|
|
177
|
+
try {
|
|
178
|
+
result = await this.call("/delegated-token", {}, this.state.response.access_token);
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
this.assertEpoch(epoch);
|
|
182
|
+
if (!(error instanceof AptevaError) || error.status !== 401)
|
|
183
|
+
throw error;
|
|
184
|
+
// Stale Auth roles or an expired Auth access token require normal refresh.
|
|
185
|
+
if (revision === this.authRevision)
|
|
186
|
+
await this.refreshAuth(epoch);
|
|
187
|
+
this.assertEpoch(epoch);
|
|
188
|
+
revision = this.authRevision;
|
|
189
|
+
if (this.state.response.apteva_access_token && this.state.platformExpiresAt > Date.now() + margin)
|
|
190
|
+
return this.state.response.apteva_access_token;
|
|
191
|
+
result = await this.call("/delegated-token", {}, this.state.response.access_token);
|
|
192
|
+
}
|
|
193
|
+
if (this.pendingAuth)
|
|
194
|
+
await this.pendingAuth;
|
|
195
|
+
this.assertEpoch(epoch);
|
|
196
|
+
// A mint started under older Auth permissions must never win over refresh.
|
|
197
|
+
if (revision !== this.authRevision)
|
|
198
|
+
return this.renew(epoch, false);
|
|
199
|
+
const platform = this.platform(result);
|
|
200
|
+
if (!platform.token || platform.expiresAt <= Date.now())
|
|
201
|
+
throw new AptevaError(502, "Missing or expired platform credential");
|
|
202
|
+
this.platformRevision++;
|
|
203
|
+
this.state.response.apteva_access_token = platform.token;
|
|
204
|
+
this.state.platformExpiresAt = platform.expiresAt;
|
|
205
|
+
this.changed(platform.token);
|
|
206
|
+
this.notify();
|
|
207
|
+
return platform.token;
|
|
208
|
+
}
|
|
209
|
+
async token(force = false) {
|
|
210
|
+
const epoch = this.epoch;
|
|
211
|
+
if (this.pendingAuth)
|
|
212
|
+
await this.pendingAuth;
|
|
213
|
+
this.assertEpoch(epoch);
|
|
214
|
+
if (this.pending)
|
|
215
|
+
return this.pending;
|
|
216
|
+
if (!force && this.state?.response.apteva_access_token && this.state.platformExpiresAt > Date.now() + margin)
|
|
217
|
+
return this.state.response.apteva_access_token;
|
|
218
|
+
const revision = this.authRevision;
|
|
219
|
+
const pending = this.renew(epoch, force).catch(error => {
|
|
220
|
+
if (this.epoch === epoch && this.authRevision === revision && this.state) {
|
|
221
|
+
this.state.response.apteva_access_token = undefined;
|
|
222
|
+
this.state.platformExpiresAt = 0;
|
|
223
|
+
this.changed(undefined);
|
|
224
|
+
this.notify();
|
|
225
|
+
}
|
|
226
|
+
throw error;
|
|
227
|
+
});
|
|
228
|
+
this.pending = pending;
|
|
229
|
+
try {
|
|
230
|
+
return await pending;
|
|
231
|
+
}
|
|
232
|
+
finally {
|
|
233
|
+
if (this.pending === pending)
|
|
234
|
+
this.pending = undefined;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
async me() {
|
|
238
|
+
if (!this.state)
|
|
239
|
+
throw new AptevaError(401, "Login required");
|
|
240
|
+
const epoch = this.epoch;
|
|
241
|
+
if (this.state.expiresAt <= Date.now() + margin)
|
|
242
|
+
await this.refreshAuth(epoch);
|
|
243
|
+
this.assertEpoch(epoch);
|
|
244
|
+
let response;
|
|
245
|
+
try {
|
|
246
|
+
response = await this.call("/me", undefined, this.state.response.access_token, "GET");
|
|
247
|
+
}
|
|
248
|
+
catch (error) {
|
|
249
|
+
this.assertEpoch(epoch);
|
|
250
|
+
if (!(error instanceof AptevaError) || error.status !== 401)
|
|
251
|
+
throw error;
|
|
252
|
+
await this.refreshAuth(epoch);
|
|
253
|
+
this.assertEpoch(epoch);
|
|
254
|
+
response = await this.call("/me", undefined, this.state.response.access_token, "GET");
|
|
255
|
+
}
|
|
256
|
+
this.assertEpoch(epoch);
|
|
257
|
+
this.state.response.user = response.user;
|
|
258
|
+
this.state.response.authorization = response.authorization;
|
|
259
|
+
this.notify();
|
|
260
|
+
return response.user;
|
|
261
|
+
}
|
|
262
|
+
async credential(kind) {
|
|
263
|
+
const epoch = this.epoch;
|
|
264
|
+
for (;;) {
|
|
265
|
+
if (!this.state)
|
|
266
|
+
throw new AptevaError(401, "Login required");
|
|
267
|
+
if (this.pendingAuth)
|
|
268
|
+
await this.pendingAuth;
|
|
269
|
+
this.assertEpoch(epoch);
|
|
270
|
+
if (kind === "platform")
|
|
271
|
+
await this.token();
|
|
272
|
+
else if (this.state.expiresAt <= Date.now() + margin)
|
|
273
|
+
await this.refreshAuth(epoch);
|
|
274
|
+
this.assertEpoch(epoch);
|
|
275
|
+
// A refresh can start while token() yields. Take one consistent snapshot
|
|
276
|
+
// only after rotation, including when the refreshed session has no mint.
|
|
277
|
+
if (this.pendingAuth)
|
|
278
|
+
continue;
|
|
279
|
+
const token = kind === "auth" ? this.state.response.access_token : this.state.response.apteva_access_token;
|
|
280
|
+
if (!token)
|
|
281
|
+
continue;
|
|
282
|
+
return { token, epoch, revision: kind === "auth" ? this.authRevision : this.platformRevision,
|
|
283
|
+
deadline: kind === "auth" ? this.state.expiresAt : this.state.platformExpiresAt };
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
async recover(kind, used) {
|
|
287
|
+
this.assertEpoch(used.epoch);
|
|
288
|
+
if (!this.state)
|
|
289
|
+
return false;
|
|
290
|
+
if (kind === "auth") {
|
|
291
|
+
if (used.revision === this.authRevision)
|
|
292
|
+
await this.refreshAuth(used.epoch);
|
|
293
|
+
}
|
|
294
|
+
else if (used.revision === this.platformRevision)
|
|
295
|
+
await this.token(true);
|
|
296
|
+
this.assertEpoch(used.epoch);
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
//# sourceMappingURL=auth-session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-session.js","sourceRoot":"","sources":["../src/auth-session.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AA8C1C,MAAM,MAAM,GAAG,MAAM,CAAC;AAEtB,kFAAkF;AAClF,MAAM,OAAO,WAAW;IAUH;IACA;IACA;IACA;IACA;IAbX,KAAK,CAAS;IACd,KAAK,GAAG,CAAC,CAAC;IACV,YAAY,GAAG,CAAC,CAAC;IACjB,gBAAgB,GAAG,CAAC,CAAC;IACrB,OAAO,CAAmB;IAC1B,WAAW,CAAiB;IAC5B,WAAW,GAAG,IAAI,GAAG,EAAmB,CAAC;IACzC,SAAS,GAAG,IAAI,GAAG,EAAc,CAAC;IAC1C,YACmB,OAAe,EACf,SAAiB,EACjB,OAAuB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AC,IAAmB,EAAE,IAAuB;QACxD,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7B,IAAI,CAAC,IAAI,CAAC,KAAK;YAAE,OAAO,KAAK,CAAC;QAC9B,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;YACpB,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,YAAY;gBAAE,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC9E,CAAC;aAAM,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,gBAAgB;YAAE,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC3E,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import type { AuthLoginInput, AuthSignupInput } from "./auth-session.js";
|
|
1
2
|
import { type LoadAppOptions, type LoadedAppFrontend } from "./frontend.js";
|
|
2
|
-
import type { AppExtension, AppScope } from "./extensions.js";
|
|
3
|
+
import type { AppExtension, AppScope, AppCredential } from "./extensions.js";
|
|
3
4
|
import type { InstalledApp } from "./apps.js";
|
|
4
5
|
import type { Agent, AgentConfig, AgentCoreEvent, AgentCreateInput, AgentCreateResult, AgentDeleteResult, AgentPauseResult, AgentRestartResult, AgentStatus, AgentSystemMCPResult, AgentUpdateInput, AptevaClientOptions, AuthStatus, ChannelInfo, Chat, CreateChatOptions, CreateOrResumeChatOptions, ChatCreateResult, CreateDelegatedUserInput, DelegatedUserToken, ChatHistoryMessage, ChatMessage, ChatMessagesQuery, ChatSendInput, ChatSendOptions, ChatStreamOptions, MCPCallResponse, Project, StreamHandle, SubscribeOptions, SSEEventMetadata, TelemetryEvent, TelemetryPeriod, TelemetryQuery, TelemetryStats, Thread, TimelineBucket, UpdateChatOptions, User } from "./types.js";
|
|
5
6
|
export declare class AptevaClient {
|
|
6
7
|
private readonly baseURL;
|
|
7
8
|
private apiKey?;
|
|
9
|
+
private readonly appAuth?;
|
|
8
10
|
private accessToken?;
|
|
9
11
|
private readonly projectId?;
|
|
10
12
|
private readonly fetchImpl;
|
|
@@ -18,17 +20,21 @@ export declare class AptevaClient {
|
|
|
18
20
|
setApiKey(key: string | undefined): void;
|
|
19
21
|
getApiKey(): string | undefined;
|
|
20
22
|
setAccessToken(token: string | undefined): void;
|
|
23
|
+
/** Host-owned opaque token only; managed Auth credentials remain internal. */
|
|
21
24
|
getAccessToken(): string | undefined;
|
|
22
25
|
/** Refresh once for concurrent callers. Undefined leaves credentials unchanged. */
|
|
23
26
|
refreshAccessToken(): Promise<boolean>;
|
|
24
27
|
private renewAfterUnauthorized;
|
|
25
28
|
readonly auth: {
|
|
26
|
-
register: (email: string, password
|
|
29
|
+
register: (email: string | AuthSignupInput, password?: string, name?: string) => Promise<{
|
|
27
30
|
user: User;
|
|
31
|
+
verification_required?: boolean;
|
|
28
32
|
}>;
|
|
29
|
-
login: (email: string, password
|
|
33
|
+
login: (email: string | AuthLoginInput, password?: string) => Promise<User>;
|
|
30
34
|
logout: () => Promise<void>;
|
|
31
35
|
me: () => Promise<User>;
|
|
36
|
+
getSession: () => import("./auth-session.js").AuthSessionInfo | undefined;
|
|
37
|
+
refresh: () => Promise<import("./auth-session.js").AuthSessionInfo | undefined>;
|
|
32
38
|
status: () => Promise<AuthStatus>;
|
|
33
39
|
changePassword: (current: string, next: string) => Promise<void>;
|
|
34
40
|
listKeys: () => Promise<{
|
|
@@ -112,9 +118,11 @@ export declare class AptevaClient {
|
|
|
112
118
|
del<R>(path: string, init?: RequestInit): Promise<R>;
|
|
113
119
|
sseURL(path: string, params?: Record<string, string | number | undefined>): string;
|
|
114
120
|
subscribe<E>(path: string, params: Record<string, string | number | undefined> | undefined, onEvent: (event: E, metadata: SSEEventMetadata) => void, opts?: SubscribeOptions): StreamHandle;
|
|
121
|
+
private subscribeScoped;
|
|
115
122
|
private subscribeWithFetch;
|
|
116
123
|
private bindAbortSignal;
|
|
117
124
|
private appPath;
|
|
125
|
+
private validateManagedPath;
|
|
118
126
|
private bearerToken;
|
|
119
127
|
private isAccessTokenCredential;
|
|
120
128
|
private request;
|
|
@@ -124,6 +132,7 @@ export interface AppHandle<TDefault = unknown> {
|
|
|
124
132
|
readonly name: string;
|
|
125
133
|
readonly projectId?: string;
|
|
126
134
|
readonly installId?: number;
|
|
135
|
+
readonly credential?: AppCredential;
|
|
127
136
|
get<R = TDefault>(path: string, init?: RequestInit): Promise<R>;
|
|
128
137
|
post<R = TDefault>(path: string, body?: unknown, init?: RequestInit): Promise<R>;
|
|
129
138
|
put<R = TDefault>(path: string, body?: unknown, init?: RequestInit): Promise<R>;
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAqB,MAAM,mBAAmB,CAAC;AAC5F,OAAO,EAAmB,KAAK,cAAc,EAAE,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE7F,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EACV,KAAK,EACL,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,EACX,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,UAAU,EACV,WAAW,EACX,IAAI,EACJ,iBAAiB,EACjB,yBAAyB,EACzB,gBAAgB,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