@ateam-ai-mobile/core 0.1.9 → 0.1.10
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/dist/index.d.mts +14 -5
- package/dist/index.d.ts +14 -5
- package/dist/index.js +23 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/authSession.ts +1 -20
- package/src/config.ts +14 -4
- package/src/index.ts +1 -0
- package/src/jwt.ts +29 -0
package/dist/index.d.mts
CHANGED
|
@@ -85,10 +85,9 @@ interface AdasConfig {
|
|
|
85
85
|
* the user belongs to). */
|
|
86
86
|
consumerAuthUrl?: UrlSource;
|
|
87
87
|
tokenProvider: TokenProvider;
|
|
88
|
-
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* tenant switch). */
|
|
88
|
+
/** The host's tenant PICK — used only while signed out (e.g. the login
|
|
89
|
+
* screen's chosen workspace). A signed-in session's tenant is always the
|
|
90
|
+
* token's `tenant` claim, the one the backend acts on (getTenant()). */
|
|
92
91
|
tenant?: string | (() => string);
|
|
93
92
|
/** Current end user as known to the host. actorId is used as the chat
|
|
94
93
|
* reply context; without it, replies route to 'unknown'. */
|
|
@@ -126,6 +125,12 @@ declare function getCoreApiUrl(): string;
|
|
|
126
125
|
declare function getCoreWsUrl(): string;
|
|
127
126
|
declare function getVoiceApiUrl(): string;
|
|
128
127
|
declare function getConsumerAuthApiUrl(): string;
|
|
128
|
+
/** The tenant the app is scoped to. Signed in: the live token's `tenant` claim,
|
|
129
|
+
* the same tenant every API call acts on, so a plugin URL, the voice session
|
|
130
|
+
* and the header can never name a different workspace than the backend does
|
|
131
|
+
* (2026-09-29: a stored pick still said 'ada' while the token said
|
|
132
|
+
* ateam-mcp-test, and a plugin page 401'd). Signed out: the host's pick, or ''
|
|
133
|
+
* when there is none — never a default tenant. */
|
|
129
134
|
declare function getTenant(): string;
|
|
130
135
|
declare function getUser(): AdasUser | null;
|
|
131
136
|
declare function getToken(): string | null;
|
|
@@ -283,6 +288,10 @@ interface AuthSession {
|
|
|
283
288
|
}
|
|
284
289
|
declare function createAuthSession(deps: AuthSessionDeps): AuthSession;
|
|
285
290
|
|
|
291
|
+
/** The tenant a signed-in session is scoped to: the token's `tenant` claim, the
|
|
292
|
+
* same value the backend reads. Null for no token or a token without one. */
|
|
293
|
+
declare function tenantFromToken(token: string | null | undefined): string | null;
|
|
294
|
+
|
|
286
295
|
/**
|
|
287
296
|
* SDK-owned push registration lifecycle (R7).
|
|
288
297
|
*
|
|
@@ -1145,4 +1154,4 @@ interface AcsKvStorage {
|
|
|
1145
1154
|
}
|
|
1146
1155
|
declare function setAcsCacheStorage(kv: AcsKvStorage | null): void;
|
|
1147
1156
|
|
|
1148
|
-
export { type AcsArtifact, type AcsDeleteReason, type AcsEvent, type AcsKvStorage, type AcsPatchReason, type AcsReachabilityReporter, type AcsSurface, type AdasConfig, type AdasGateFlags, type AdasPhase, type AdasSession, type AdasUser, type AttachmentCache, type AttachmentPreview, type AuthSession, type AuthSessionDeps, type AuthSessionState, type BufferedCommand, type ConsumerCapabilityConfig, type ConsumerProviderConfig, type ConsumerSignInResult, type DeleteResult, type HandoffExchangeResult, type HomeAction, type HomeActionLeaf, type HomeActionReason, type InvitePreview, type JobProgress, type Message, type MessageAttachment, type OtpStartResult, type OutgoingAttachment, type PatchResult, PluginCommandEmitter, type PushBackend, type PushRegistration, type RefreshOutcome, type Session, type SessionEnv, type SessionPersistence, type SessionStatus, type SessionUser, TABLE_BLOCK_CLOSE, TABLE_BLOCK_OPEN, type TenantMembership, type TokenProvider, type ToolCall, type UIAction, type WorkspaceCapabilities, type WorkspaceSnapshot, type WorkspaceState, ada, apiFetch, apiFetchRaw, blocksToText, borderRadius, capabilityEnabled, closeChatStream, colors, connectAcsWs, connectorCall, createAuthSession, createPushRegistration, deleteArtifact, disconnectAcsWs, exchangeHandoff, fetchConsumerConfig, fontSize, getConfig, getConsumerAuthApiUrl, getCoreApiUrl, getCoreWsUrl, getSession, getTenant, getToken, getUser, getVoiceApiUrl, initAdas, isAdasInitialized, isDevHost, joinWithApple, joinWithGoogle, linkChannelStart, linkChannelVerify, listHomeActions, listMadeForYou, listMyTenants, listSurface, mcpFetch, mcpToolCall, notifyAcsWsForeground, notifyAppForeground, onAppForeground, openJoinWithApple, openJoinWithGoogle, parseDeepLinkParam, parseHandoffCode, parseInviteCode, patchArtifact, patchHomeAction, pluginCommandEmitter, postCommandResult, previewInvite, recordEvent, refreshToken, resolveAdasPhase, setAcsCacheStorage, setAcsReachabilityReporter, setClientDeclarationProvider, setHomeActionOrder, setOrder, signInWithApple, signInWithGoogle, spacing, switchTenant, unwrapMcpResult, useCapability, useChatStore, useHomeActionsStore, useWidgetsStore, useWorkspaceStore, userFromJwt };
|
|
1157
|
+
export { type AcsArtifact, type AcsDeleteReason, type AcsEvent, type AcsKvStorage, type AcsPatchReason, type AcsReachabilityReporter, type AcsSurface, type AdasConfig, type AdasGateFlags, type AdasPhase, type AdasSession, type AdasUser, type AttachmentCache, type AttachmentPreview, type AuthSession, type AuthSessionDeps, type AuthSessionState, type BufferedCommand, type ConsumerCapabilityConfig, type ConsumerProviderConfig, type ConsumerSignInResult, type DeleteResult, type HandoffExchangeResult, type HomeAction, type HomeActionLeaf, type HomeActionReason, type InvitePreview, type JobProgress, type Message, type MessageAttachment, type OtpStartResult, type OutgoingAttachment, type PatchResult, PluginCommandEmitter, type PushBackend, type PushRegistration, type RefreshOutcome, type Session, type SessionEnv, type SessionPersistence, type SessionStatus, type SessionUser, TABLE_BLOCK_CLOSE, TABLE_BLOCK_OPEN, type TenantMembership, type TokenProvider, type ToolCall, type UIAction, type WorkspaceCapabilities, type WorkspaceSnapshot, type WorkspaceState, ada, apiFetch, apiFetchRaw, blocksToText, borderRadius, capabilityEnabled, closeChatStream, colors, connectAcsWs, connectorCall, createAuthSession, createPushRegistration, deleteArtifact, disconnectAcsWs, exchangeHandoff, fetchConsumerConfig, fontSize, getConfig, getConsumerAuthApiUrl, getCoreApiUrl, getCoreWsUrl, getSession, getTenant, getToken, getUser, getVoiceApiUrl, initAdas, isAdasInitialized, isDevHost, joinWithApple, joinWithGoogle, linkChannelStart, linkChannelVerify, listHomeActions, listMadeForYou, listMyTenants, listSurface, mcpFetch, mcpToolCall, notifyAcsWsForeground, notifyAppForeground, onAppForeground, openJoinWithApple, openJoinWithGoogle, parseDeepLinkParam, parseHandoffCode, parseInviteCode, patchArtifact, patchHomeAction, pluginCommandEmitter, postCommandResult, previewInvite, recordEvent, refreshToken, resolveAdasPhase, setAcsCacheStorage, setAcsReachabilityReporter, setClientDeclarationProvider, setHomeActionOrder, setOrder, signInWithApple, signInWithGoogle, spacing, switchTenant, tenantFromToken, unwrapMcpResult, useCapability, useChatStore, useHomeActionsStore, useWidgetsStore, useWorkspaceStore, userFromJwt };
|
package/dist/index.d.ts
CHANGED
|
@@ -85,10 +85,9 @@ interface AdasConfig {
|
|
|
85
85
|
* the user belongs to). */
|
|
86
86
|
consumerAuthUrl?: UrlSource;
|
|
87
87
|
tokenProvider: TokenProvider;
|
|
88
|
-
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* tenant switch). */
|
|
88
|
+
/** The host's tenant PICK — used only while signed out (e.g. the login
|
|
89
|
+
* screen's chosen workspace). A signed-in session's tenant is always the
|
|
90
|
+
* token's `tenant` claim, the one the backend acts on (getTenant()). */
|
|
92
91
|
tenant?: string | (() => string);
|
|
93
92
|
/** Current end user as known to the host. actorId is used as the chat
|
|
94
93
|
* reply context; without it, replies route to 'unknown'. */
|
|
@@ -126,6 +125,12 @@ declare function getCoreApiUrl(): string;
|
|
|
126
125
|
declare function getCoreWsUrl(): string;
|
|
127
126
|
declare function getVoiceApiUrl(): string;
|
|
128
127
|
declare function getConsumerAuthApiUrl(): string;
|
|
128
|
+
/** The tenant the app is scoped to. Signed in: the live token's `tenant` claim,
|
|
129
|
+
* the same tenant every API call acts on, so a plugin URL, the voice session
|
|
130
|
+
* and the header can never name a different workspace than the backend does
|
|
131
|
+
* (2026-09-29: a stored pick still said 'ada' while the token said
|
|
132
|
+
* ateam-mcp-test, and a plugin page 401'd). Signed out: the host's pick, or ''
|
|
133
|
+
* when there is none — never a default tenant. */
|
|
129
134
|
declare function getTenant(): string;
|
|
130
135
|
declare function getUser(): AdasUser | null;
|
|
131
136
|
declare function getToken(): string | null;
|
|
@@ -283,6 +288,10 @@ interface AuthSession {
|
|
|
283
288
|
}
|
|
284
289
|
declare function createAuthSession(deps: AuthSessionDeps): AuthSession;
|
|
285
290
|
|
|
291
|
+
/** The tenant a signed-in session is scoped to: the token's `tenant` claim, the
|
|
292
|
+
* same value the backend reads. Null for no token or a token without one. */
|
|
293
|
+
declare function tenantFromToken(token: string | null | undefined): string | null;
|
|
294
|
+
|
|
286
295
|
/**
|
|
287
296
|
* SDK-owned push registration lifecycle (R7).
|
|
288
297
|
*
|
|
@@ -1145,4 +1154,4 @@ interface AcsKvStorage {
|
|
|
1145
1154
|
}
|
|
1146
1155
|
declare function setAcsCacheStorage(kv: AcsKvStorage | null): void;
|
|
1147
1156
|
|
|
1148
|
-
export { type AcsArtifact, type AcsDeleteReason, type AcsEvent, type AcsKvStorage, type AcsPatchReason, type AcsReachabilityReporter, type AcsSurface, type AdasConfig, type AdasGateFlags, type AdasPhase, type AdasSession, type AdasUser, type AttachmentCache, type AttachmentPreview, type AuthSession, type AuthSessionDeps, type AuthSessionState, type BufferedCommand, type ConsumerCapabilityConfig, type ConsumerProviderConfig, type ConsumerSignInResult, type DeleteResult, type HandoffExchangeResult, type HomeAction, type HomeActionLeaf, type HomeActionReason, type InvitePreview, type JobProgress, type Message, type MessageAttachment, type OtpStartResult, type OutgoingAttachment, type PatchResult, PluginCommandEmitter, type PushBackend, type PushRegistration, type RefreshOutcome, type Session, type SessionEnv, type SessionPersistence, type SessionStatus, type SessionUser, TABLE_BLOCK_CLOSE, TABLE_BLOCK_OPEN, type TenantMembership, type TokenProvider, type ToolCall, type UIAction, type WorkspaceCapabilities, type WorkspaceSnapshot, type WorkspaceState, ada, apiFetch, apiFetchRaw, blocksToText, borderRadius, capabilityEnabled, closeChatStream, colors, connectAcsWs, connectorCall, createAuthSession, createPushRegistration, deleteArtifact, disconnectAcsWs, exchangeHandoff, fetchConsumerConfig, fontSize, getConfig, getConsumerAuthApiUrl, getCoreApiUrl, getCoreWsUrl, getSession, getTenant, getToken, getUser, getVoiceApiUrl, initAdas, isAdasInitialized, isDevHost, joinWithApple, joinWithGoogle, linkChannelStart, linkChannelVerify, listHomeActions, listMadeForYou, listMyTenants, listSurface, mcpFetch, mcpToolCall, notifyAcsWsForeground, notifyAppForeground, onAppForeground, openJoinWithApple, openJoinWithGoogle, parseDeepLinkParam, parseHandoffCode, parseInviteCode, patchArtifact, patchHomeAction, pluginCommandEmitter, postCommandResult, previewInvite, recordEvent, refreshToken, resolveAdasPhase, setAcsCacheStorage, setAcsReachabilityReporter, setClientDeclarationProvider, setHomeActionOrder, setOrder, signInWithApple, signInWithGoogle, spacing, switchTenant, unwrapMcpResult, useCapability, useChatStore, useHomeActionsStore, useWidgetsStore, useWorkspaceStore, userFromJwt };
|
|
1157
|
+
export { type AcsArtifact, type AcsDeleteReason, type AcsEvent, type AcsKvStorage, type AcsPatchReason, type AcsReachabilityReporter, type AcsSurface, type AdasConfig, type AdasGateFlags, type AdasPhase, type AdasSession, type AdasUser, type AttachmentCache, type AttachmentPreview, type AuthSession, type AuthSessionDeps, type AuthSessionState, type BufferedCommand, type ConsumerCapabilityConfig, type ConsumerProviderConfig, type ConsumerSignInResult, type DeleteResult, type HandoffExchangeResult, type HomeAction, type HomeActionLeaf, type HomeActionReason, type InvitePreview, type JobProgress, type Message, type MessageAttachment, type OtpStartResult, type OutgoingAttachment, type PatchResult, PluginCommandEmitter, type PushBackend, type PushRegistration, type RefreshOutcome, type Session, type SessionEnv, type SessionPersistence, type SessionStatus, type SessionUser, TABLE_BLOCK_CLOSE, TABLE_BLOCK_OPEN, type TenantMembership, type TokenProvider, type ToolCall, type UIAction, type WorkspaceCapabilities, type WorkspaceSnapshot, type WorkspaceState, ada, apiFetch, apiFetchRaw, blocksToText, borderRadius, capabilityEnabled, closeChatStream, colors, connectAcsWs, connectorCall, createAuthSession, createPushRegistration, deleteArtifact, disconnectAcsWs, exchangeHandoff, fetchConsumerConfig, fontSize, getConfig, getConsumerAuthApiUrl, getCoreApiUrl, getCoreWsUrl, getSession, getTenant, getToken, getUser, getVoiceApiUrl, initAdas, isAdasInitialized, isDevHost, joinWithApple, joinWithGoogle, linkChannelStart, linkChannelVerify, listHomeActions, listMadeForYou, listMyTenants, listSurface, mcpFetch, mcpToolCall, notifyAcsWsForeground, notifyAppForeground, onAppForeground, openJoinWithApple, openJoinWithGoogle, parseDeepLinkParam, parseHandoffCode, parseInviteCode, patchArtifact, patchHomeAction, pluginCommandEmitter, postCommandResult, previewInvite, recordEvent, refreshToken, resolveAdasPhase, setAcsCacheStorage, setAcsReachabilityReporter, setClientDeclarationProvider, setHomeActionOrder, setOrder, signInWithApple, signInWithGoogle, spacing, switchTenant, tenantFromToken, unwrapMcpResult, useCapability, useChatStore, useHomeActionsStore, useWidgetsStore, useWorkspaceStore, userFromJwt };
|
package/dist/index.js
CHANGED
|
@@ -87,6 +87,7 @@ __export(index_exports, {
|
|
|
87
87
|
signInWithGoogle: () => signInWithGoogle,
|
|
88
88
|
spacing: () => spacing,
|
|
89
89
|
switchTenant: () => switchTenant,
|
|
90
|
+
tenantFromToken: () => tenantFromToken,
|
|
90
91
|
unwrapMcpResult: () => unwrapMcpResult,
|
|
91
92
|
useCapability: () => useCapability,
|
|
92
93
|
useChatStore: () => useChatStore,
|
|
@@ -97,6 +98,25 @@ __export(index_exports, {
|
|
|
97
98
|
});
|
|
98
99
|
module.exports = __toCommonJS(index_exports);
|
|
99
100
|
|
|
101
|
+
// src/jwt.ts
|
|
102
|
+
function decodeJwtPayload(token) {
|
|
103
|
+
try {
|
|
104
|
+
const segs = token.split(".");
|
|
105
|
+
if (segs.length !== 3) return null;
|
|
106
|
+
const b64 = segs[1].replace(/-/g, "+").replace(/_/g, "/");
|
|
107
|
+
const padded = b64 + "=".repeat((4 - b64.length % 4) % 4);
|
|
108
|
+
const json = typeof atob === "function" ? atob(padded) : Buffer.from(padded, "base64").toString("utf8");
|
|
109
|
+
return JSON.parse(json);
|
|
110
|
+
} catch {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function tenantFromToken(token) {
|
|
115
|
+
if (!token) return null;
|
|
116
|
+
const t = decodeJwtPayload(token)?.tenant;
|
|
117
|
+
return typeof t === "string" && t ? t : null;
|
|
118
|
+
}
|
|
119
|
+
|
|
100
120
|
// src/config.ts
|
|
101
121
|
var _config = null;
|
|
102
122
|
function initAdas(config) {
|
|
@@ -131,6 +151,8 @@ function getConsumerAuthApiUrl() {
|
|
|
131
151
|
return resolveUrl(url);
|
|
132
152
|
}
|
|
133
153
|
function getTenant() {
|
|
154
|
+
const token = getConfig().tokenProvider.getToken();
|
|
155
|
+
if (token) return tenantFromToken(token) || "";
|
|
134
156
|
const t = getConfig().tenant;
|
|
135
157
|
return (typeof t === "function" ? t() : t) || "";
|
|
136
158
|
}
|
|
@@ -306,18 +328,6 @@ function getSession() {
|
|
|
306
328
|
}
|
|
307
329
|
|
|
308
330
|
// src/authSession.ts
|
|
309
|
-
function decodeJwtPayload(token) {
|
|
310
|
-
try {
|
|
311
|
-
const segs = token.split(".");
|
|
312
|
-
if (segs.length !== 3) return null;
|
|
313
|
-
const b64 = segs[1].replace(/-/g, "+").replace(/_/g, "/");
|
|
314
|
-
const padded = b64 + "=".repeat((4 - b64.length % 4) % 4);
|
|
315
|
-
const json = typeof atob === "function" ? atob(padded) : Buffer.from(padded, "base64").toString("utf8");
|
|
316
|
-
return JSON.parse(json);
|
|
317
|
-
} catch {
|
|
318
|
-
return null;
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
331
|
function userFromJwt(token) {
|
|
322
332
|
const claims = decodeJwtPayload(token);
|
|
323
333
|
if (!claims?.sub) return null;
|
|
@@ -2242,6 +2252,7 @@ var borderRadius = {
|
|
|
2242
2252
|
signInWithGoogle,
|
|
2243
2253
|
spacing,
|
|
2244
2254
|
switchTenant,
|
|
2255
|
+
tenantFromToken,
|
|
2245
2256
|
unwrapMcpResult,
|
|
2246
2257
|
useCapability,
|
|
2247
2258
|
useChatStore,
|