@arke-institute/sdk 2.1.0 → 2.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.
@@ -11,7 +11,12 @@ interface ArkeClientConfig {
11
11
  */
12
12
  baseUrl?: string;
13
13
  /**
14
- * Authentication token (JWT or API key)
14
+ * Authentication token - accepts either:
15
+ * - JWT token from Supabase auth (sent as Bearer)
16
+ * - Agent API key with 'ak_' prefix (sent as ApiKey)
17
+ * - User API key with 'uk_' prefix (sent as ApiKey)
18
+ *
19
+ * The correct Authorization header format is auto-detected from the token prefix.
15
20
  */
16
21
  authToken?: string;
17
22
  /**
@@ -39,13 +44,28 @@ declare const DEFAULT_CONFIG: Required<Pick<ArkeClientConfig, 'baseUrl' | 'netwo
39
44
  */
40
45
 
41
46
  type ArkeApiClient = Client<paths>;
47
+ /**
48
+ * Check if a token is an API key (starts with 'ak_' or 'uk_')
49
+ */
50
+ declare function isApiKey(token: string): boolean;
51
+ /**
52
+ * Get the appropriate Authorization header value for a token
53
+ * - API keys (ak_*, uk_*) use: ApiKey {token}
54
+ * - JWT tokens use: Bearer {token}
55
+ */
56
+ declare function getAuthorizationHeader(token: string): string;
42
57
  /**
43
58
  * Type-safe client for the Arke API
44
59
  *
45
60
  * @example
46
61
  * ```typescript
62
+ * // With JWT token
47
63
  * const arke = new ArkeClient({ authToken: 'your-jwt-token' });
48
64
  *
65
+ * // With API key (agent or user)
66
+ * const arke = new ArkeClient({ authToken: 'ak_your-agent-api-key' });
67
+ * const arke = new ArkeClient({ authToken: 'uk_your-user-api-key' });
68
+ *
49
69
  * // Create an entity
50
70
  * const { data, error } = await arke.api.POST('/entities', {
51
71
  * body: {
@@ -175,22 +195,26 @@ interface UploadTarget {
175
195
  */
176
196
  interface UploadProgress$1 {
177
197
  /** Current phase of the upload */
178
- phase: 'scanning' | 'computing-cids' | 'creating-folders' | 'creating-files' | 'uploading-content' | 'linking' | 'complete' | 'error';
179
- /** Total number of files to upload */
180
- totalFiles: number;
181
- /** Number of files completed */
182
- completedFiles: number;
183
- /** Total number of folders to create */
184
- totalFolders: number;
185
- /** Number of folders completed */
186
- completedFolders: number;
187
- /** Current file being processed */
188
- currentFile?: string;
189
- /** Current folder being processed */
190
- currentFolder?: string;
198
+ phase: 'computing-cids' | 'creating' | 'backlinking' | 'uploading' | 'complete' | 'error';
199
+ /** Current phase index (0=computing-cids, 1=creating, 2=backlinking, 3=uploading) */
200
+ phaseIndex: number;
201
+ /** Total number of phases (4, excluding complete/error) */
202
+ phaseCount: number;
203
+ /** Progress within current phase (0-100) */
204
+ phasePercent: number;
205
+ /** Total number of entities (files + folders) */
206
+ totalEntities: number;
207
+ /** Number of entities completed */
208
+ completedEntities: number;
209
+ /** Total number of parents to backlink */
210
+ totalParents: number;
211
+ /** Number of parents backlinked */
212
+ completedParents: number;
213
+ /** Current item being processed */
214
+ currentItem?: string;
191
215
  /** Error message if phase is 'error' */
192
216
  error?: string;
193
- /** Bytes uploaded so far (for content upload phase) */
217
+ /** Bytes uploaded so far */
194
218
  bytesUploaded?: number;
195
219
  /** Total bytes to upload */
196
220
  totalBytes?: number;
@@ -456,4 +480,4 @@ declare class CryptoOperations {
456
480
  static computeCID(_content: Uint8Array): Promise<string>;
457
481
  }
458
482
 
459
- export { ArkeClient as A, BatchOperations as B, CryptoOperations as C, DEFAULT_CONFIG as D, FolderOperations as F, type KeyPair as K, type SignedPayload as S, type UploadProgress$1 as U, type ArkeApiClient as a, type ArkeClientConfig as b, createArkeClient as c, type UploadDirectoryOptions as d, type UploadDirectoryResult as e, type BatchCreateOptions as f, type BatchResult as g, type UploadTree as h, type UploadOptions as i, type UploadResult as j, type UploadFile as k, type UploadFolder as l, type UploadTarget as m, type CreatedEntity as n };
483
+ export { ArkeClient as A, BatchOperations as B, CryptoOperations as C, DEFAULT_CONFIG as D, FolderOperations as F, type KeyPair as K, type SignedPayload as S, type UploadProgress$1 as U, type ArkeApiClient as a, type ArkeClientConfig as b, createArkeClient as c, type UploadDirectoryOptions as d, type UploadDirectoryResult as e, type BatchCreateOptions as f, getAuthorizationHeader as g, type BatchResult as h, isApiKey as i, type UploadTree as j, type UploadOptions as k, type UploadResult as l, type UploadFile as m, type UploadFolder as n, type UploadTarget as o, type CreatedEntity as p };
@@ -11,7 +11,12 @@ interface ArkeClientConfig {
11
11
  */
12
12
  baseUrl?: string;
13
13
  /**
14
- * Authentication token (JWT or API key)
14
+ * Authentication token - accepts either:
15
+ * - JWT token from Supabase auth (sent as Bearer)
16
+ * - Agent API key with 'ak_' prefix (sent as ApiKey)
17
+ * - User API key with 'uk_' prefix (sent as ApiKey)
18
+ *
19
+ * The correct Authorization header format is auto-detected from the token prefix.
15
20
  */
16
21
  authToken?: string;
17
22
  /**
@@ -39,13 +44,28 @@ declare const DEFAULT_CONFIG: Required<Pick<ArkeClientConfig, 'baseUrl' | 'netwo
39
44
  */
40
45
 
41
46
  type ArkeApiClient = Client<paths>;
47
+ /**
48
+ * Check if a token is an API key (starts with 'ak_' or 'uk_')
49
+ */
50
+ declare function isApiKey(token: string): boolean;
51
+ /**
52
+ * Get the appropriate Authorization header value for a token
53
+ * - API keys (ak_*, uk_*) use: ApiKey {token}
54
+ * - JWT tokens use: Bearer {token}
55
+ */
56
+ declare function getAuthorizationHeader(token: string): string;
42
57
  /**
43
58
  * Type-safe client for the Arke API
44
59
  *
45
60
  * @example
46
61
  * ```typescript
62
+ * // With JWT token
47
63
  * const arke = new ArkeClient({ authToken: 'your-jwt-token' });
48
64
  *
65
+ * // With API key (agent or user)
66
+ * const arke = new ArkeClient({ authToken: 'ak_your-agent-api-key' });
67
+ * const arke = new ArkeClient({ authToken: 'uk_your-user-api-key' });
68
+ *
49
69
  * // Create an entity
50
70
  * const { data, error } = await arke.api.POST('/entities', {
51
71
  * body: {
@@ -175,22 +195,26 @@ interface UploadTarget {
175
195
  */
176
196
  interface UploadProgress$1 {
177
197
  /** Current phase of the upload */
178
- phase: 'scanning' | 'computing-cids' | 'creating-folders' | 'creating-files' | 'uploading-content' | 'linking' | 'complete' | 'error';
179
- /** Total number of files to upload */
180
- totalFiles: number;
181
- /** Number of files completed */
182
- completedFiles: number;
183
- /** Total number of folders to create */
184
- totalFolders: number;
185
- /** Number of folders completed */
186
- completedFolders: number;
187
- /** Current file being processed */
188
- currentFile?: string;
189
- /** Current folder being processed */
190
- currentFolder?: string;
198
+ phase: 'computing-cids' | 'creating' | 'backlinking' | 'uploading' | 'complete' | 'error';
199
+ /** Current phase index (0=computing-cids, 1=creating, 2=backlinking, 3=uploading) */
200
+ phaseIndex: number;
201
+ /** Total number of phases (4, excluding complete/error) */
202
+ phaseCount: number;
203
+ /** Progress within current phase (0-100) */
204
+ phasePercent: number;
205
+ /** Total number of entities (files + folders) */
206
+ totalEntities: number;
207
+ /** Number of entities completed */
208
+ completedEntities: number;
209
+ /** Total number of parents to backlink */
210
+ totalParents: number;
211
+ /** Number of parents backlinked */
212
+ completedParents: number;
213
+ /** Current item being processed */
214
+ currentItem?: string;
191
215
  /** Error message if phase is 'error' */
192
216
  error?: string;
193
- /** Bytes uploaded so far (for content upload phase) */
217
+ /** Bytes uploaded so far */
194
218
  bytesUploaded?: number;
195
219
  /** Total bytes to upload */
196
220
  totalBytes?: number;
@@ -456,4 +480,4 @@ declare class CryptoOperations {
456
480
  static computeCID(_content: Uint8Array): Promise<string>;
457
481
  }
458
482
 
459
- export { ArkeClient as A, BatchOperations as B, CryptoOperations as C, DEFAULT_CONFIG as D, FolderOperations as F, type KeyPair as K, type SignedPayload as S, type UploadProgress$1 as U, type ArkeApiClient as a, type ArkeClientConfig as b, createArkeClient as c, type UploadDirectoryOptions as d, type UploadDirectoryResult as e, type BatchCreateOptions as f, type BatchResult as g, type UploadTree as h, type UploadOptions as i, type UploadResult as j, type UploadFile as k, type UploadFolder as l, type UploadTarget as m, type CreatedEntity as n };
483
+ export { ArkeClient as A, BatchOperations as B, CryptoOperations as C, DEFAULT_CONFIG as D, FolderOperations as F, type KeyPair as K, type SignedPayload as S, type UploadProgress$1 as U, type ArkeApiClient as a, type ArkeClientConfig as b, createArkeClient as c, type UploadDirectoryOptions as d, type UploadDirectoryResult as e, type BatchCreateOptions as f, getAuthorizationHeader as g, type BatchResult as h, isApiKey as i, type UploadTree as j, type UploadOptions as k, type UploadResult as l, type UploadFile as m, type UploadFolder as n, type UploadTarget as o, type CreatedEntity as p };