@crosspost/sdk 0.1.7 → 0.1.9

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.cjs CHANGED
@@ -36,6 +36,7 @@ __export(index_exports, {
36
36
  AuthCallbackResponseSchema: () => AuthCallbackResponseSchema,
37
37
  AuthInitRequestSchema: () => AuthInitRequestSchema,
38
38
  AuthRevokeResponseSchema: () => AuthRevokeResponseSchema,
39
+ AuthStatusParamsSchema: () => AuthStatusParamsSchema,
39
40
  AuthStatusResponseSchema: () => AuthStatusResponseSchema,
40
41
  AuthTokenRequestSchema: () => AuthTokenRequestSchema,
41
42
  AuthUrlResponseSchema: () => AuthUrlResponseSchema,
@@ -49,6 +50,7 @@ __export(index_exports, {
49
50
  DeleteResultSchema: () => DeleteResultSchema,
50
51
  EndpointRateLimitResponseSchema: () => EndpointRateLimitResponseSchema,
51
52
  ErrorDetailSchema: () => ErrorDetailSchema,
53
+ HealthStatusSchema: () => HealthStatusSchema,
52
54
  LikePostRequestSchema: () => LikePostRequestSchema,
53
55
  LikePostResponseSchema: () => LikePostResponseSchema,
54
56
  LikeResultSchema: () => LikeResultSchema,
@@ -58,6 +60,7 @@ __export(index_exports, {
58
60
  NearAuthorizationRequestSchema: () => NearAuthorizationRequestSchema,
59
61
  NearAuthorizationResponseSchema: () => NearAuthorizationResponseSchema,
60
62
  NearAuthorizationStatusResponseSchema: () => NearAuthorizationStatusResponseSchema,
63
+ NearUnauthorizationResponseSchema: () => NearUnauthorizationResponseSchema,
61
64
  Platform: () => Platform,
62
65
  PlatformActivitySchema: () => PlatformActivitySchema,
63
66
  PlatformParamSchema: () => PlatformParamSchema,
@@ -4212,6 +4215,7 @@ var ApiErrorCode = /* @__PURE__ */ ((ApiErrorCode2) => {
4212
4215
  ApiErrorCode2["POST_DELETION_FAILED"] = "POST_DELETION_FAILED";
4213
4216
  ApiErrorCode2["POST_INTERACTION_FAILED"] = "POST_INTERACTION_FAILED";
4214
4217
  ApiErrorCode2["NETWORK_ERROR"] = "NETWORK_ERROR";
4218
+ ApiErrorCode2["INVALID_RESPONSE"] = "INVALID_RESPONSE";
4215
4219
  return ApiErrorCode2;
4216
4220
  })(ApiErrorCode || {});
4217
4221
  var ApiErrorCodeSchema = z.enum(Object.values(ApiErrorCode));
@@ -4291,7 +4295,11 @@ var errorCodeToStatusCode = {
4291
4295
  [
4292
4296
  "NETWORK_ERROR"
4293
4297
  /* NETWORK_ERROR */
4294
- ]: 503
4298
+ ]: 503,
4299
+ [
4300
+ "INVALID_RESPONSE"
4301
+ /* INVALID_RESPONSE */
4302
+ ]: 500
4295
4303
  };
4296
4304
  var ErrorDetailSchema = z.object({
4297
4305
  message: z.string().describe("Human-readable error message"),
@@ -4324,6 +4332,11 @@ var SuccessDetailSchema = z.object({
4324
4332
  additionalData: z.any().optional(),
4325
4333
  status: z.literal("success")
4326
4334
  }).catchall(z.any());
4335
+ var HealthStatusSchema = z.object({
4336
+ status: z.string().describe("Health status of the API"),
4337
+ version: z.string().optional().describe("API version"),
4338
+ timestamp: z.string().datetime().describe("Current server time")
4339
+ }).describe("Health status response");
4327
4340
  var MultiStatusDataSchema = z.object({
4328
4341
  summary: z.object({
4329
4342
  total: z.number().int().nonnegative(),
@@ -4356,6 +4369,14 @@ var AuthCallbackResponseSchema = z.object({
4356
4369
  userId: z.string().describe("User ID"),
4357
4370
  redirectUrl: z.string().optional().describe("URL to redirect the user to after authentication")
4358
4371
  }).describe("Auth callback response");
4372
+ var AuthStatusParamsSchema = z.object({
4373
+ platform: z.string().describe("Social media platform"),
4374
+ userId: z.string().describe("User ID on the platform")
4375
+ }).describe("Token status parameters");
4376
+ var NearUnauthorizationResponseSchema = z.object({
4377
+ success: z.boolean().describe("Whether the unauthorized operation was successful"),
4378
+ nearAccount: z.string().describe("NEAR account ID that was unauthorized")
4379
+ }).describe("NEAR unauthorized response");
4359
4380
  var AuthStatusResponseSchema = z.object({
4360
4381
  platform: PlatformSchema,
4361
4382
  userId: z.string().describe("User ID"),
@@ -4952,7 +4973,7 @@ function createNetworkError(error, url, timeout) {
4952
4973
  // src/core/request.ts
4953
4974
  async function makeRequest(method, path, options, data, query) {
4954
4975
  let url = `${options.baseUrl}${path.startsWith("/") ? path : `/${path}`}`;
4955
- if (query && Object.keys(query).length > 0) {
4976
+ if (query && typeof query === "object" && Object.keys(query).length > 0) {
4956
4977
  const queryParams = new URLSearchParams();
4957
4978
  for (const [key, value] of Object.entries(query)) {
4958
4979
  if (value !== void 0 && value !== null) {
@@ -4967,84 +4988,96 @@ async function makeRequest(method, path, options, data, query) {
4967
4988
  const context = {
4968
4989
  method,
4969
4990
  path,
4970
- url,
4971
- retries: options.retries
4991
+ url
4972
4992
  };
4973
- return apiWrapper(async () => {
4974
- let lastError = null;
4975
- for (let attempt = 0; attempt <= options.retries; attempt++) {
4976
- const controller = new AbortController();
4977
- const timeoutId = setTimeout(() => controller.abort(), options.timeout);
4993
+ const controller = new AbortController();
4994
+ const timeoutId = setTimeout(() => controller.abort(), options.timeout);
4995
+ try {
4996
+ const headers = {
4997
+ "Content-Type": "application/json",
4998
+ "Accept": "application/json"
4999
+ };
5000
+ if (method === "GET") {
5001
+ const nearAccount = options.nearAccount || options.nearAuthData?.account_id;
5002
+ if (!nearAccount) {
5003
+ throw new CrosspostError(
5004
+ "No NEAR account provided for GET request",
5005
+ ApiErrorCode.UNAUTHORIZED,
5006
+ 401
5007
+ );
5008
+ }
5009
+ headers["X-Near-Account"] = nearAccount;
5010
+ } else {
5011
+ if (!options.nearAuthData) {
5012
+ throw new CrosspostError(
5013
+ "NEAR authentication data required for non-GET request",
5014
+ ApiErrorCode.UNAUTHORIZED,
5015
+ 401
5016
+ );
5017
+ }
5018
+ headers["Authorization"] = `Bearer ${(0, import_near_sign_verify.createAuthToken)(options.nearAuthData)}`;
5019
+ }
5020
+ const requestOptions = {
5021
+ method,
5022
+ headers,
5023
+ body: method !== "GET" && data ? JSON.stringify(data) : void 0,
5024
+ signal: controller.signal
5025
+ };
5026
+ const response = await fetch(url, requestOptions);
5027
+ clearTimeout(timeoutId);
5028
+ let responseData;
5029
+ try {
5030
+ responseData = await response.json();
5031
+ } catch (jsonError) {
5032
+ let responseText;
4978
5033
  try {
4979
- const headers = {
4980
- "Content-Type": "application/json",
4981
- "Accept": "application/json",
4982
- "Authorization": `Bearer ${(0, import_near_sign_verify.createAuthToken)(options.nearAuthData)}`
4983
- };
4984
- const requestOptions = {
4985
- method,
4986
- headers,
4987
- body: method !== "GET" && data ? JSON.stringify(data) : void 0,
4988
- signal: controller.signal
4989
- };
4990
- const response = await fetch(url, requestOptions);
4991
- clearTimeout(timeoutId);
4992
- let responseData;
4993
- try {
4994
- responseData = await response.json();
4995
- } catch (jsonError) {
4996
- if (!response.ok) {
4997
- throw new CrosspostError(
4998
- `API request failed with status ${response.status} and non-JSON response`,
4999
- ApiErrorCode.NETWORK_ERROR,
5000
- response.status,
5001
- { originalStatusText: response.statusText }
5002
- );
5003
- }
5004
- throw new CrosspostError(
5005
- `Failed to parse JSON response: ${jsonError instanceof Error ? jsonError.message : String(jsonError)}`,
5006
- ApiErrorCode.INTERNAL_ERROR,
5007
- response.status
5008
- );
5009
- }
5010
- if (!response.ok) {
5011
- lastError = handleErrorResponse(responseData, response.status);
5012
- const shouldRetry = lastError instanceof CrosspostError && lastError.code === ApiErrorCode.RATE_LIMITED;
5013
- if (shouldRetry && attempt < options.retries) {
5014
- await new Promise((resolve) => setTimeout(resolve, 1e3 * Math.pow(2, attempt)));
5015
- continue;
5016
- }
5017
- throw lastError;
5018
- }
5019
- if (responseData && typeof responseData === "object" && "success" in responseData) {
5020
- if (responseData.success) {
5021
- return responseData.data;
5022
- } else {
5023
- lastError = handleErrorResponse(responseData, response.status);
5024
- const shouldRetry = lastError instanceof CrosspostError && lastError.code === ApiErrorCode.RATE_LIMITED;
5025
- if (shouldRetry && attempt < options.retries) {
5026
- await new Promise((resolve) => setTimeout(resolve, 1e3 * Math.pow(2, attempt)));
5027
- continue;
5028
- }
5029
- throw lastError;
5030
- }
5031
- }
5032
- } catch (error) {
5033
- clearTimeout(timeoutId);
5034
- lastError = error instanceof Error ? error : new Error(String(error));
5035
- const isNetworkError2 = error instanceof TypeError || error instanceof DOMException && error.name === "AbortError";
5036
- if (isNetworkError2 && attempt < options.retries) {
5037
- await new Promise((resolve) => setTimeout(resolve, 1e3 * Math.pow(2, attempt)));
5038
- continue;
5039
- }
5040
- if (!(error instanceof CrosspostError)) {
5041
- throw createNetworkError(error, url, options.timeout);
5042
- }
5043
- throw error;
5034
+ responseText = await response.text();
5035
+ } catch (_) {
5044
5036
  }
5037
+ throw new CrosspostError(
5038
+ `API request failed with status ${response.status} and non-JSON response`,
5039
+ ApiErrorCode.INVALID_RESPONSE,
5040
+ response.status,
5041
+ {
5042
+ originalStatusText: response.statusText,
5043
+ originalError: jsonError instanceof Error ? jsonError.message : String(jsonError),
5044
+ responseText
5045
+ }
5046
+ );
5047
+ }
5048
+ if (!response.ok) {
5049
+ throw handleErrorResponse(responseData, response.status);
5050
+ }
5051
+ if (!responseData || typeof responseData !== "object" || !("success" in responseData)) {
5052
+ throw new CrosspostError(
5053
+ "Invalid success response format from API",
5054
+ ApiErrorCode.INVALID_RESPONSE,
5055
+ response.status,
5056
+ { responseData }
5057
+ );
5058
+ }
5059
+ if (responseData.success) {
5060
+ return responseData.data;
5061
+ }
5062
+ throw handleErrorResponse(responseData, response.status);
5063
+ } catch (error) {
5064
+ clearTimeout(timeoutId);
5065
+ if (error instanceof CrosspostError) {
5066
+ throw enrichErrorWithContext(error, context);
5067
+ }
5068
+ if (error instanceof TypeError || error instanceof DOMException && error.name === "AbortError") {
5069
+ throw enrichErrorWithContext(createNetworkError(error, url, options.timeout), context);
5045
5070
  }
5046
- throw lastError || new CrosspostError("Request failed after multiple retries", ApiErrorCode.INTERNAL_ERROR, 500);
5047
- }, context);
5071
+ throw enrichErrorWithContext(
5072
+ new CrosspostError(
5073
+ error instanceof Error ? error.message : String(error),
5074
+ ApiErrorCode.INTERNAL_ERROR,
5075
+ 500,
5076
+ { originalError: String(error) }
5077
+ ),
5078
+ context
5079
+ );
5080
+ }
5048
5081
  }
5049
5082
 
5050
5083
  // src/api/activity.ts
@@ -5152,25 +5185,28 @@ var AuthApi = class {
5152
5185
  /**
5153
5186
  * Refreshes the authentication token for the specified platform.
5154
5187
  * @param platform The target platform.
5155
- * @returns A promise resolving with the refresh response.
5188
+ * @returns A promise resolving with the refresh response containing updated auth details.
5156
5189
  */
5157
- async refreshToken(platform) {
5190
+ async refreshToken(platform, userId) {
5158
5191
  return makeRequest(
5159
5192
  "POST",
5160
5193
  `/auth/${platform}/refresh`,
5161
- this.options
5194
+ this.options,
5195
+ { userId }
5162
5196
  );
5163
5197
  }
5164
5198
  /**
5165
5199
  * Refreshes the user's profile information from the specified platform.
5166
5200
  * @param platform The target platform.
5167
- * @returns A promise resolving with the profile refresh response.
5201
+ * @param userId The user ID on the platform
5202
+ * @returns A promise resolving with the updated account profile information.
5168
5203
  */
5169
- async refreshProfile(platform) {
5204
+ async refreshProfile(platform, userId) {
5170
5205
  return makeRequest(
5171
5206
  "POST",
5172
5207
  `/auth/${platform}/refresh-profile`,
5173
- this.options
5208
+ this.options,
5209
+ { userId }
5174
5210
  );
5175
5211
  }
5176
5212
  /**
@@ -5178,11 +5214,25 @@ var AuthApi = class {
5178
5214
  * @param platform The target platform.
5179
5215
  * @returns A promise resolving with the authentication status response.
5180
5216
  */
5181
- async getAuthStatus(platform) {
5217
+ async getAuthStatus(platform, userId) {
5182
5218
  return makeRequest(
5183
5219
  "GET",
5184
- `/auth/${platform}/status`,
5185
- this.options
5220
+ `/auth/${platform}/status/${userId}`,
5221
+ this.options,
5222
+ void 0,
5223
+ { platform, userId }
5224
+ );
5225
+ }
5226
+ /**
5227
+ * Unauthorizes a NEAR account from using the service
5228
+ * @returns A promise resolving with the unauthorized response
5229
+ */
5230
+ async unauthorizeNear() {
5231
+ return makeRequest(
5232
+ "DELETE",
5233
+ "/auth/unauthorize/near",
5234
+ this.options,
5235
+ {}
5186
5236
  );
5187
5237
  }
5188
5238
  /**
@@ -5190,11 +5240,12 @@ var AuthApi = class {
5190
5240
  * @param platform The target platform.
5191
5241
  * @returns A promise resolving with the revocation response.
5192
5242
  */
5193
- async revokeAuth(platform) {
5243
+ async revokeAuth(platform, userId) {
5194
5244
  return makeRequest(
5195
5245
  "DELETE",
5196
5246
  `/auth/${platform}/revoke`,
5197
- this.options
5247
+ this.options,
5248
+ { userId }
5198
5249
  );
5199
5250
  }
5200
5251
  /**
@@ -5341,7 +5392,9 @@ var SystemApi = class {
5341
5392
  return makeRequest(
5342
5393
  "GET",
5343
5394
  `/api/rate-limit/${endpoint}`,
5344
- this.options
5395
+ this.options,
5396
+ void 0,
5397
+ { endpoint }
5345
5398
  );
5346
5399
  }
5347
5400
  /**
@@ -5360,8 +5413,7 @@ var SystemApi = class {
5360
5413
  // src/core/config.ts
5361
5414
  var DEFAULT_CONFIG = {
5362
5415
  baseUrl: "https://open-crosspost-proxy.deno.dev/",
5363
- timeout: 3e4,
5364
- retries: 2
5416
+ timeout: 3e4
5365
5417
  };
5366
5418
 
5367
5419
  // src/core/client.ts
@@ -5373,12 +5425,10 @@ var CrosspostClient = class {
5373
5425
  constructor(config = {}) {
5374
5426
  const baseUrl = config.baseUrl || DEFAULT_CONFIG.baseUrl;
5375
5427
  const timeout = config.timeout || DEFAULT_CONFIG.timeout;
5376
- const retries = config.retries ?? DEFAULT_CONFIG.retries;
5377
5428
  const nearAuthData = config.nearAuthData;
5378
5429
  this.options = {
5379
5430
  baseUrl,
5380
5431
  timeout,
5381
- retries,
5382
5432
  nearAuthData
5383
5433
  };
5384
5434
  this.auth = new AuthApi(this.options);
@@ -5388,18 +5438,52 @@ var CrosspostClient = class {
5388
5438
  }
5389
5439
  /**
5390
5440
  * Sets the authentication data (signature) for the client
5441
+ * Required for non-GET requests
5391
5442
  * @param nearAuthData The NEAR authentication data
5392
5443
  */
5393
5444
  setAuthentication(nearAuthData) {
5394
5445
  this.options.nearAuthData = nearAuthData;
5446
+ if (!this.options.nearAccount) {
5447
+ this.options.nearAccount = nearAuthData.account_id;
5448
+ }
5449
+ }
5450
+ /**
5451
+ * Sets the NEAR account ID for simplified GET request authentication
5452
+ * If not set, will use account_id from nearAuthData
5453
+ * @param nearAccount The NEAR account ID
5454
+ */
5455
+ setNearAccount(nearAccount) {
5456
+ this.options.nearAccount = nearAccount;
5457
+ }
5458
+ /**
5459
+ * Gets the current NEAR account ID being used for authentication
5460
+ * @returns The NEAR account ID from nearAccount or nearAuthData
5461
+ */
5462
+ getNearAccount() {
5463
+ return this.options.nearAccount || this.options.nearAuthData?.account_id;
5395
5464
  }
5396
5465
  /**
5397
5466
  * Checks if authentication data (signature) exists on client
5398
- * @param signature The NEAR authentication data
5467
+ * @returns true if nearAuthData is set (required for non-GET requests)
5399
5468
  */
5400
5469
  isAuthenticated() {
5401
5470
  return !!this.options.nearAuthData;
5402
5471
  }
5472
+ /**
5473
+ * Checks if a NEAR account is set for GET request authentication
5474
+ * @returns true if either nearAccount or nearAuthData.account_id is set
5475
+ */
5476
+ hasNearAccount() {
5477
+ return !!(this.options.nearAccount || this.options.nearAuthData?.account_id);
5478
+ }
5479
+ /**
5480
+ * Clears all authentication data from the client
5481
+ * This will prevent all requests from working until new authentication is set
5482
+ */
5483
+ clear() {
5484
+ this.options.nearAuthData = void 0;
5485
+ this.options.nearAccount = void 0;
5486
+ }
5403
5487
  };
5404
5488
  // Annotate the CommonJS export names for ESM import in node:
5405
5489
  0 && (module.exports = {
@@ -5419,6 +5503,7 @@ var CrosspostClient = class {
5419
5503
  AuthCallbackResponseSchema,
5420
5504
  AuthInitRequestSchema,
5421
5505
  AuthRevokeResponseSchema,
5506
+ AuthStatusParamsSchema,
5422
5507
  AuthStatusResponseSchema,
5423
5508
  AuthTokenRequestSchema,
5424
5509
  AuthUrlResponseSchema,
@@ -5432,6 +5517,7 @@ var CrosspostClient = class {
5432
5517
  DeleteResultSchema,
5433
5518
  EndpointRateLimitResponseSchema,
5434
5519
  ErrorDetailSchema,
5520
+ HealthStatusSchema,
5435
5521
  LikePostRequestSchema,
5436
5522
  LikePostResponseSchema,
5437
5523
  LikeResultSchema,
@@ -5441,6 +5527,7 @@ var CrosspostClient = class {
5441
5527
  NearAuthorizationRequestSchema,
5442
5528
  NearAuthorizationResponseSchema,
5443
5529
  NearAuthorizationStatusResponseSchema,
5530
+ NearUnauthorizationResponseSchema,
5444
5531
  Platform,
5445
5532
  PlatformActivitySchema,
5446
5533
  PlatformParamSchema,
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { NearAuthData } from 'near-sign-verify';
2
- import { ActivityLeaderboardQuery, ActivityLeaderboardResponse, AccountActivityQuery, AccountActivityResponse, AccountPostsQuery, AccountPostsResponse, NearAuthorizationResponse, Platform, ApiResponse, AuthStatusResponse, AuthRevokeResponse, ConnectedAccountsResponse, CreatePostRequest, CreatePostResponse, RepostRequest, RepostResponse, QuotePostRequest, QuotePostResponse, ReplyToPostRequest, ReplyToPostResponse, LikePostRequest, LikePostResponse, UnlikePostRequest, UnlikePostResponse, DeletePostRequest, DeletePostResponse, RateLimitResponse, EndpointRateLimitResponse, ApiErrorCode, StatusCode, ErrorDetails } from '@crosspost/types';
2
+ import { ActivityLeaderboardQuery, ActivityLeaderboardResponse, AccountActivityQuery, AccountActivityResponse, AccountPostsQuery, AccountPostsResponse, NearAuthorizationResponse, Platform, AuthInitRequest, AuthUrlResponse, AuthCallbackResponse, ConnectedAccount, AuthStatusResponse, NearUnauthorizationResponse, AuthRevokeResponse, ConnectedAccountsResponse, CreatePostRequest, CreatePostResponse, RepostRequest, RepostResponse, QuotePostRequest, QuotePostResponse, ReplyToPostRequest, ReplyToPostResponse, LikePostRequest, LikePostResponse, UnlikePostRequest, UnlikePostResponse, DeletePostRequest, DeletePostResponse, RateLimitResponse, EndpointRateLimitResponse, HealthStatus, ApiErrorCode, StatusCode, ErrorDetails } from '@crosspost/types';
3
3
  export * from '@crosspost/types';
4
4
 
5
5
  /**
@@ -12,17 +12,18 @@ interface RequestOptions {
12
12
  baseUrl: string;
13
13
  /**
14
14
  * NEAR authentication data for generating auth tokens
15
- * Can be undefined if not authorize yet
15
+ * Required for non-GET requests, optional for GET requests
16
16
  */
17
17
  nearAuthData?: NearAuthData;
18
18
  /**
19
- * Request timeout in milliseconds
19
+ * NEAR account ID for simplified GET request authentication
20
+ * If not provided, will use account_id from nearAuthData
20
21
  */
21
- timeout: number;
22
+ nearAccount?: string;
22
23
  /**
23
- * Number of retries for failed requests
24
+ * Request timeout in milliseconds
24
25
  */
25
- retries: number;
26
+ timeout: number;
26
27
  }
27
28
 
28
29
  /**
@@ -84,34 +85,37 @@ declare class AuthApi {
84
85
  * @param options Optional success and error redirect URLs.
85
86
  * @returns A promise resolving with the response from the service (might indicate success/failure or redirect info).
86
87
  */
87
- loginToPlatform(platform: Platform, options?: {
88
- successUrl?: string;
89
- errorUrl?: string;
90
- }): Promise<ApiResponse<any>>;
88
+ loginToPlatform(platform: Platform, options?: AuthInitRequest): Promise<AuthUrlResponse>;
91
89
  /**
92
90
  * Refreshes the authentication token for the specified platform.
93
91
  * @param platform The target platform.
94
- * @returns A promise resolving with the refresh response.
92
+ * @returns A promise resolving with the refresh response containing updated auth details.
95
93
  */
96
- refreshToken(platform: Platform): Promise<ApiResponse<any>>;
94
+ refreshToken(platform: Platform, userId: string): Promise<AuthCallbackResponse>;
97
95
  /**
98
96
  * Refreshes the user's profile information from the specified platform.
99
97
  * @param platform The target platform.
100
- * @returns A promise resolving with the profile refresh response.
98
+ * @param userId The user ID on the platform
99
+ * @returns A promise resolving with the updated account profile information.
101
100
  */
102
- refreshProfile(platform: Platform): Promise<ApiResponse<any>>;
101
+ refreshProfile(platform: Platform, userId: string): Promise<ConnectedAccount>;
103
102
  /**
104
103
  * Gets the authentication status for the specified platform.
105
104
  * @param platform The target platform.
106
105
  * @returns A promise resolving with the authentication status response.
107
106
  */
108
- getAuthStatus(platform: Platform): Promise<AuthStatusResponse>;
107
+ getAuthStatus(platform: Platform, userId: string): Promise<AuthStatusResponse>;
108
+ /**
109
+ * Unauthorizes a NEAR account from using the service
110
+ * @returns A promise resolving with the unauthorized response
111
+ */
112
+ unauthorizeNear(): Promise<NearUnauthorizationResponse>;
109
113
  /**
110
114
  * Revokes the authentication token for the specified platform.
111
115
  * @param platform The target platform.
112
116
  * @returns A promise resolving with the revocation response.
113
117
  */
114
- revokeAuth(platform: Platform): Promise<AuthRevokeResponse>;
118
+ revokeAuth(platform: Platform, userId: string): Promise<AuthRevokeResponse>;
115
119
  /**
116
120
  * Lists all accounts connected to the NEAR account.
117
121
  * @returns A promise resolving with the list of connected accounts.
@@ -199,9 +203,7 @@ declare class SystemApi {
199
203
  * Gets the health status of the API
200
204
  * @returns A promise resolving with the health status
201
205
  */
202
- getHealthStatus(): Promise<ApiResponse<{
203
- status: string;
204
- }>>;
206
+ getHealthStatus(): Promise<HealthStatus>;
205
207
  }
206
208
 
207
209
  /**
@@ -222,11 +224,6 @@ interface CrosspostClientConfig {
222
224
  * @default 30000
223
225
  */
224
226
  timeout?: number;
225
- /**
226
- * Number of retries for failed requests (specifically for network errors or 5xx status codes)
227
- * @default 2
228
- */
229
- retries?: number;
230
227
  }
231
228
 
232
229
  /**
@@ -245,14 +242,36 @@ declare class CrosspostClient {
245
242
  constructor(config?: CrosspostClientConfig);
246
243
  /**
247
244
  * Sets the authentication data (signature) for the client
245
+ * Required for non-GET requests
248
246
  * @param nearAuthData The NEAR authentication data
249
247
  */
250
248
  setAuthentication(nearAuthData: NearAuthData): void;
249
+ /**
250
+ * Sets the NEAR account ID for simplified GET request authentication
251
+ * If not set, will use account_id from nearAuthData
252
+ * @param nearAccount The NEAR account ID
253
+ */
254
+ setNearAccount(nearAccount: string): void;
255
+ /**
256
+ * Gets the current NEAR account ID being used for authentication
257
+ * @returns The NEAR account ID from nearAccount or nearAuthData
258
+ */
259
+ getNearAccount(): string | undefined;
251
260
  /**
252
261
  * Checks if authentication data (signature) exists on client
253
- * @param signature The NEAR authentication data
262
+ * @returns true if nearAuthData is set (required for non-GET requests)
254
263
  */
255
264
  isAuthenticated(): boolean;
265
+ /**
266
+ * Checks if a NEAR account is set for GET request authentication
267
+ * @returns true if either nearAccount or nearAuthData.account_id is set
268
+ */
269
+ hasNearAccount(): boolean;
270
+ /**
271
+ * Clears all authentication data from the client
272
+ * This will prevent all requests from working until new authentication is set
273
+ */
274
+ clear(): void;
256
275
  }
257
276
 
258
277
  /**