@amigo-ai/platform-sdk 0.9.3 → 0.11.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/dist/core/device-code.js +411 -0
- package/dist/core/device-code.js.map +1 -0
- package/dist/index.cjs +387 -0
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +387 -0
- package/dist/index.mjs.map +4 -4
- package/dist/types/core/device-code.d.ts +134 -0
- package/dist/types/core/device-code.d.ts.map +1 -0
- package/dist/types/generated/api.d.ts +71 -3
- package/dist/types/generated/api.d.ts.map +1 -1
- package/dist/types/index.d.cts +2 -0
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/resources/functions.d.ts.map +1 -1
- package/dist/types/resources/metrics.d.ts.map +1 -1
- package/dist/types/resources/settings.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RFC 8628 Device Authorization Grant for desktop and CLI apps.
|
|
3
|
+
*
|
|
4
|
+
* Authenticates users via the identity service's device code flow:
|
|
5
|
+
* the app displays a code, the user approves in their browser,
|
|
6
|
+
* and the app receives a workspace-scoped JWT.
|
|
7
|
+
*/
|
|
8
|
+
import { AmigoError, AuthenticationError } from './errors.js';
|
|
9
|
+
export interface DeviceCodeIssuance {
|
|
10
|
+
device_code: string;
|
|
11
|
+
user_code: string;
|
|
12
|
+
verification_uri: string;
|
|
13
|
+
verification_uri_complete: string;
|
|
14
|
+
expires_in: number;
|
|
15
|
+
interval: number;
|
|
16
|
+
}
|
|
17
|
+
export interface IdentityTokenResponse {
|
|
18
|
+
access_token: string;
|
|
19
|
+
token_type: 'Bearer' | 'DPoP';
|
|
20
|
+
expires_in: number;
|
|
21
|
+
scope: string;
|
|
22
|
+
session_id?: string;
|
|
23
|
+
refresh_token?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface WorkspaceChoice {
|
|
26
|
+
workspace_id: string;
|
|
27
|
+
role?: string;
|
|
28
|
+
name?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface MultiWorkspaceResponse {
|
|
31
|
+
error: 'workspace_selection_required';
|
|
32
|
+
workspaces: WorkspaceChoice[];
|
|
33
|
+
access_token?: string;
|
|
34
|
+
token_type?: string;
|
|
35
|
+
expires_in?: number;
|
|
36
|
+
scope?: string;
|
|
37
|
+
refresh_token?: string;
|
|
38
|
+
}
|
|
39
|
+
export type DeviceCodeStatus = 'authorization_pending' | 'polling' | 'approved' | 'expired' | 'denied' | 'slow_down';
|
|
40
|
+
export interface DeviceCodeLoginOptions {
|
|
41
|
+
/** Identity service base URL. Default: https://identity.platform.amigo.ai */
|
|
42
|
+
identityBaseUrl?: string;
|
|
43
|
+
/** Client description for audit logs */
|
|
44
|
+
clientDescription?: string;
|
|
45
|
+
/** OAuth scope to request */
|
|
46
|
+
scope?: string;
|
|
47
|
+
/** Called when device code is issued — display instructions to user */
|
|
48
|
+
onCode: (issuance: DeviceCodeIssuance) => void | Promise<void>;
|
|
49
|
+
/** Called with polling status updates */
|
|
50
|
+
onStatus?: (status: DeviceCodeStatus) => void;
|
|
51
|
+
/** Called when user must select a workspace — return the chosen workspace_id */
|
|
52
|
+
onWorkspaceRequired: (workspaces: WorkspaceChoice[]) => Promise<string>;
|
|
53
|
+
/** AbortSignal to cancel the login flow */
|
|
54
|
+
signal?: AbortSignal;
|
|
55
|
+
/** Custom fetch implementation */
|
|
56
|
+
fetch?: typeof globalThis.fetch;
|
|
57
|
+
}
|
|
58
|
+
export interface AuthResult {
|
|
59
|
+
accessToken: string;
|
|
60
|
+
refreshToken: string;
|
|
61
|
+
workspaceId: string;
|
|
62
|
+
expiresAt: number;
|
|
63
|
+
scope?: string;
|
|
64
|
+
}
|
|
65
|
+
export interface StoredCredentials {
|
|
66
|
+
access_token: string;
|
|
67
|
+
refresh_token: string;
|
|
68
|
+
workspace_id: string;
|
|
69
|
+
expires_at: number;
|
|
70
|
+
scope?: string;
|
|
71
|
+
identity_base_url?: string;
|
|
72
|
+
}
|
|
73
|
+
export interface TokenStorage {
|
|
74
|
+
load(): Promise<StoredCredentials | null>;
|
|
75
|
+
save(credentials: StoredCredentials): Promise<void>;
|
|
76
|
+
clear(): Promise<void>;
|
|
77
|
+
}
|
|
78
|
+
export declare class DeviceCodeExpiredError extends AmigoError {
|
|
79
|
+
constructor(message?: string);
|
|
80
|
+
}
|
|
81
|
+
export declare class DeviceCodeDeniedError extends AmigoError {
|
|
82
|
+
constructor(message?: string);
|
|
83
|
+
}
|
|
84
|
+
export declare class RefreshTokenExpiredError extends AuthenticationError {
|
|
85
|
+
constructor(message?: string);
|
|
86
|
+
}
|
|
87
|
+
export declare class LoginCancelledError extends AmigoError {
|
|
88
|
+
constructor();
|
|
89
|
+
}
|
|
90
|
+
export declare function decodeJwtPayload(jwt: string): Record<string, unknown> | null;
|
|
91
|
+
export declare function loginWithDeviceCode(options: DeviceCodeLoginOptions): Promise<AuthResult>;
|
|
92
|
+
export interface TokenManagerConfig {
|
|
93
|
+
storage?: TokenStorage;
|
|
94
|
+
identityBaseUrl?: string;
|
|
95
|
+
fetch?: typeof globalThis.fetch;
|
|
96
|
+
}
|
|
97
|
+
export declare class TokenManager {
|
|
98
|
+
private readonly _storage;
|
|
99
|
+
private readonly _baseUrl;
|
|
100
|
+
private readonly _fetch;
|
|
101
|
+
private _cached;
|
|
102
|
+
private _refreshPromise;
|
|
103
|
+
constructor(config?: TokenManagerConfig);
|
|
104
|
+
store(result: AuthResult): Promise<void>;
|
|
105
|
+
getAccessToken(): Promise<{
|
|
106
|
+
token: string;
|
|
107
|
+
workspaceId: string;
|
|
108
|
+
} | null>;
|
|
109
|
+
hasCredentials(): Promise<boolean>;
|
|
110
|
+
clear(): Promise<void>;
|
|
111
|
+
private _loadCached;
|
|
112
|
+
private _refresh;
|
|
113
|
+
private _doRefresh;
|
|
114
|
+
}
|
|
115
|
+
export declare class FileTokenStorage implements TokenStorage {
|
|
116
|
+
private readonly _explicitPath;
|
|
117
|
+
private _resolvedPath;
|
|
118
|
+
constructor(filePath?: string);
|
|
119
|
+
private _filePath;
|
|
120
|
+
load(): Promise<StoredCredentials | null>;
|
|
121
|
+
save(credentials: StoredCredentials): Promise<void>;
|
|
122
|
+
clear(): Promise<void>;
|
|
123
|
+
}
|
|
124
|
+
export declare class MemoryTokenStorage implements TokenStorage {
|
|
125
|
+
private _credentials;
|
|
126
|
+
load(): Promise<StoredCredentials | null>;
|
|
127
|
+
save(credentials: StoredCredentials): Promise<void>;
|
|
128
|
+
clear(): Promise<void>;
|
|
129
|
+
}
|
|
130
|
+
export declare function formatDeviceCodeInstructions(issuance: DeviceCodeIssuance): string;
|
|
131
|
+
export declare function formatDeviceCodeLink(issuance: DeviceCodeIssuance): string;
|
|
132
|
+
export declare function openBrowser(url: string): Promise<boolean>;
|
|
133
|
+
export declare function formatWorkspaceList(workspaces: WorkspaceChoice[]): string;
|
|
134
|
+
//# sourceMappingURL=device-code.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device-code.d.ts","sourceRoot":"","sources":["../../../src/core/device-code.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAgC,MAAM,aAAa,CAAA;AAI3F,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,gBAAgB,EAAE,MAAM,CAAA;IACxB,yBAAyB,EAAE,MAAM,CAAA;IACjC,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,qBAAqB;IACpC,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,QAAQ,GAAG,MAAM,CAAA;IAC7B,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,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sB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAmB/D;AAED,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,eAAe,EAAE,GAAG,MAAM,CAUzE"}
|
|
@@ -1502,6 +1502,30 @@ export interface paths {
|
|
|
1502
1502
|
patch?: never;
|
|
1503
1503
|
trace?: never;
|
|
1504
1504
|
};
|
|
1505
|
+
"/v1/{workspace_id}/brief": {
|
|
1506
|
+
parameters: {
|
|
1507
|
+
query?: never;
|
|
1508
|
+
header?: never;
|
|
1509
|
+
path?: never;
|
|
1510
|
+
cookie?: never;
|
|
1511
|
+
};
|
|
1512
|
+
/**
|
|
1513
|
+
* Get Latest Workspace Brief
|
|
1514
|
+
* @description Return the latest workspace-level Self-Image brief (null shape if none).
|
|
1515
|
+
*/
|
|
1516
|
+
get: operations["get_latest_workspace_brief_v1__workspace_id__brief_get"];
|
|
1517
|
+
put?: never;
|
|
1518
|
+
/**
|
|
1519
|
+
* Generate Workspace Brief
|
|
1520
|
+
* @description Generate a workspace-level Self-Image brief (Opus 4.7).
|
|
1521
|
+
*/
|
|
1522
|
+
post: operations["generate_workspace_brief_v1__workspace_id__brief_post"];
|
|
1523
|
+
delete?: never;
|
|
1524
|
+
options?: never;
|
|
1525
|
+
head?: never;
|
|
1526
|
+
patch?: never;
|
|
1527
|
+
trace?: never;
|
|
1528
|
+
};
|
|
1505
1529
|
"/v1/{workspace_id}/calls": {
|
|
1506
1530
|
parameters: {
|
|
1507
1531
|
query?: never;
|
|
@@ -2476,7 +2500,7 @@ export interface paths {
|
|
|
2476
2500
|
put?: never;
|
|
2477
2501
|
/**
|
|
2478
2502
|
* Generate Brief
|
|
2479
|
-
* @description Generate a Self-Image brief for the target entity (
|
|
2503
|
+
* @description Generate a Self-Image brief for the target entity (patient, cohort, territory, emirate, or district).
|
|
2480
2504
|
*/
|
|
2481
2505
|
post: operations["generate_brief_v1__workspace_id__entities__entity_id__brief_post"];
|
|
2482
2506
|
delete?: never;
|
|
@@ -9324,9 +9348,9 @@ export interface components {
|
|
|
9324
9348
|
target_entity_id: string;
|
|
9325
9349
|
/**
|
|
9326
9350
|
* Target Entity Type
|
|
9327
|
-
* @
|
|
9351
|
+
* @enum {string}
|
|
9328
9352
|
*/
|
|
9329
|
-
target_entity_type: "patient";
|
|
9353
|
+
target_entity_type: "patient" | "cohort" | "workspace" | "territory" | "emirate" | "district";
|
|
9330
9354
|
/**
|
|
9331
9355
|
* Truncated
|
|
9332
9356
|
* @default false
|
|
@@ -28427,6 +28451,50 @@ export interface operations {
|
|
|
28427
28451
|
};
|
|
28428
28452
|
};
|
|
28429
28453
|
};
|
|
28454
|
+
get_latest_workspace_brief_v1__workspace_id__brief_get: {
|
|
28455
|
+
parameters: {
|
|
28456
|
+
query?: never;
|
|
28457
|
+
header?: never;
|
|
28458
|
+
path: {
|
|
28459
|
+
workspace_id: string;
|
|
28460
|
+
};
|
|
28461
|
+
cookie?: never;
|
|
28462
|
+
};
|
|
28463
|
+
requestBody?: never;
|
|
28464
|
+
responses: {
|
|
28465
|
+
/** @description Successful Response */
|
|
28466
|
+
200: {
|
|
28467
|
+
headers: {
|
|
28468
|
+
[name: string]: unknown;
|
|
28469
|
+
};
|
|
28470
|
+
content: {
|
|
28471
|
+
"application/json": components["schemas"]["BriefResponse"];
|
|
28472
|
+
};
|
|
28473
|
+
};
|
|
28474
|
+
};
|
|
28475
|
+
};
|
|
28476
|
+
generate_workspace_brief_v1__workspace_id__brief_post: {
|
|
28477
|
+
parameters: {
|
|
28478
|
+
query?: never;
|
|
28479
|
+
header?: never;
|
|
28480
|
+
path: {
|
|
28481
|
+
workspace_id: string;
|
|
28482
|
+
};
|
|
28483
|
+
cookie?: never;
|
|
28484
|
+
};
|
|
28485
|
+
requestBody?: never;
|
|
28486
|
+
responses: {
|
|
28487
|
+
/** @description Successful Response */
|
|
28488
|
+
200: {
|
|
28489
|
+
headers: {
|
|
28490
|
+
[name: string]: unknown;
|
|
28491
|
+
};
|
|
28492
|
+
content: {
|
|
28493
|
+
"application/json": components["schemas"]["BriefResponse"];
|
|
28494
|
+
};
|
|
28495
|
+
};
|
|
28496
|
+
};
|
|
28497
|
+
};
|
|
28430
28498
|
"list-calls": {
|
|
28431
28499
|
parameters: {
|
|
28432
28500
|
query?: {
|