@crosspost/sdk 0.1.2 → 0.1.4

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.js CHANGED
@@ -4059,19 +4059,22 @@ var z = /* @__PURE__ */ Object.freeze({
4059
4059
  });
4060
4060
 
4061
4061
  // ../types/dist/index.js
4062
- var PlatformSchema = z.enum([
4063
- "unknown",
4064
- "twitter"
4065
- // Add more platforms as they're implemented
4066
- // 'linkedin',
4067
- // 'facebook',
4068
- // 'instagram',
4069
- ]).describe("Social media platform");
4070
4062
  var Platform = /* @__PURE__ */ ((Platform2) => {
4071
4063
  Platform2["UNKNOWN"] = "unknown";
4072
4064
  Platform2["TWITTER"] = "twitter";
4073
4065
  return Platform2;
4074
4066
  })(Platform || {});
4067
+ var PlatformSchema = z.nativeEnum(Platform).describe("Social media platform");
4068
+ var SUPPORTED_PLATFORMS = [
4069
+ "twitter"
4070
+ /* TWITTER */
4071
+ // Add more platforms here as they're implemented
4072
+ ];
4073
+ var SupportedPlatformSchema = SUPPORTED_PLATFORMS.length > 0 ? z.enum(SUPPORTED_PLATFORMS) : z.never();
4074
+ SupportedPlatformSchema.describe("Currently supported social media platforms");
4075
+ function isPlatformSupported(platform) {
4076
+ return SUPPORTED_PLATFORMS.includes(platform);
4077
+ }
4075
4078
  var ApiResponseSchema = z.object({
4076
4079
  data: z.any().describe("Response data"),
4077
4080
  meta: z.object({
@@ -4679,13 +4682,21 @@ var EndpointRateLimitResponseSchema = z.object({
4679
4682
  endpoint: z.string().describe("API endpoint or action"),
4680
4683
  signerId: z.string().describe("NEAR account ID")
4681
4684
  }).describe("Endpoint rate limit response");
4682
- var LeaderboardQuerySchema = z.object({
4685
+ var TimePeriod = /* @__PURE__ */ ((TimePeriod2) => {
4686
+ TimePeriod2["ALL_TIME"] = "all";
4687
+ TimePeriod2["YEARLY"] = "yearly";
4688
+ TimePeriod2["MONTHLY"] = "monthly";
4689
+ TimePeriod2["WEEKLY"] = "weekly";
4690
+ TimePeriod2["DAILY"] = "daily";
4691
+ return TimePeriod2;
4692
+ })(TimePeriod || {});
4693
+ var ActivityLeaderboardQuerySchema = z.object({
4683
4694
  timeframe: z.enum(["day", "week", "month", "all"]).optional().describe(
4684
4695
  "Timeframe for the leaderboard"
4685
4696
  ),
4686
4697
  limit: z.string().optional().transform((val) => val ? parseInt(val, 10) : void 0).pipe(z.number().min(1).max(100).optional()).describe("Maximum number of results to return (1-100)"),
4687
4698
  offset: z.string().optional().transform((val) => val ? parseInt(val, 10) : void 0).pipe(z.number().min(0).optional()).describe("Offset for pagination")
4688
- }).describe("Leaderboard query");
4699
+ }).describe("Activity leaderboard query");
4689
4700
  var AccountActivityEntrySchema = z.object({
4690
4701
  signerId: z.string().describe("NEAR account ID"),
4691
4702
  totalPosts: z.number().describe("Total number of posts"),
@@ -4697,7 +4708,7 @@ var AccountActivityEntrySchema = z.object({
4697
4708
  rank: z.number().describe("Rank on the leaderboard"),
4698
4709
  lastActive: z.string().datetime().describe("Timestamp of last activity")
4699
4710
  }).describe("Account activity entry");
4700
- var LeaderboardResponseSchema = EnhancedResponseSchema(
4711
+ var ActivityLeaderboardResponseSchema = EnhancedResponseSchema(
4701
4712
  z.object({
4702
4713
  timeframe: z.enum(["day", "week", "month", "all"]).describe("Timeframe for the leaderboard"),
4703
4714
  entries: z.array(AccountActivityEntrySchema).describe("Leaderboard entries"),
@@ -4706,7 +4717,7 @@ var LeaderboardResponseSchema = EnhancedResponseSchema(
4706
4717
  offset: z.number().describe("Offset for pagination"),
4707
4718
  generatedAt: z.string().datetime().describe("Timestamp when the leaderboard was generated")
4708
4719
  })
4709
- ).describe("Leaderboard response");
4720
+ ).describe("Activity leaderboard response");
4710
4721
  var AccountActivityParamsSchema = z.object({
4711
4722
  signerId: z.string().describe("NEAR account ID")
4712
4723
  }).describe("Account activity params");
@@ -4802,6 +4813,168 @@ var ProfileRefreshResponseSchema = EnhancedResponseSchema(
4802
4813
  import { createAuthToken } from "near-sign-verify";
4803
4814
 
4804
4815
  // src/utils/error.ts
4816
+ var ERROR_CATEGORIES = {
4817
+ AUTH: [
4818
+ ApiErrorCode.UNAUTHORIZED,
4819
+ ApiErrorCode.FORBIDDEN
4820
+ ],
4821
+ VALIDATION: [
4822
+ ApiErrorCode.VALIDATION_ERROR,
4823
+ ApiErrorCode.INVALID_REQUEST
4824
+ ],
4825
+ NETWORK: [
4826
+ ApiErrorCode.NETWORK_ERROR
4827
+ ],
4828
+ PLATFORM: [
4829
+ ApiErrorCode.PLATFORM_ERROR,
4830
+ ApiErrorCode.PLATFORM_UNAVAILABLE
4831
+ ],
4832
+ CONTENT: [
4833
+ ApiErrorCode.CONTENT_POLICY_VIOLATION,
4834
+ ApiErrorCode.DUPLICATE_CONTENT
4835
+ ],
4836
+ RATE_LIMIT: [
4837
+ ApiErrorCode.RATE_LIMITED
4838
+ ],
4839
+ POST: [
4840
+ ApiErrorCode.POST_CREATION_FAILED,
4841
+ ApiErrorCode.THREAD_CREATION_FAILED,
4842
+ ApiErrorCode.POST_DELETION_FAILED,
4843
+ ApiErrorCode.POST_INTERACTION_FAILED
4844
+ ],
4845
+ MEDIA: [
4846
+ ApiErrorCode.MEDIA_UPLOAD_FAILED
4847
+ ]
4848
+ };
4849
+ function isErrorOfCategory(error, category) {
4850
+ if (error instanceof ApiError) {
4851
+ return category.includes(error.code);
4852
+ }
4853
+ if (error instanceof PlatformError) {
4854
+ return category.includes(error.code);
4855
+ }
4856
+ if (error && typeof error === "object" && "code" in error) {
4857
+ return category.includes(error.code);
4858
+ }
4859
+ return false;
4860
+ }
4861
+ function isAuthError(error) {
4862
+ return isErrorOfCategory(error, ERROR_CATEGORIES.AUTH);
4863
+ }
4864
+ function isValidationError(error) {
4865
+ return isErrorOfCategory(error, ERROR_CATEGORIES.VALIDATION);
4866
+ }
4867
+ function isNetworkError(error) {
4868
+ return isErrorOfCategory(error, ERROR_CATEGORIES.NETWORK);
4869
+ }
4870
+ function isPlatformError(error) {
4871
+ return isErrorOfCategory(error, ERROR_CATEGORIES.PLATFORM) || error instanceof PlatformError;
4872
+ }
4873
+ function isContentError(error) {
4874
+ return isErrorOfCategory(error, ERROR_CATEGORIES.CONTENT);
4875
+ }
4876
+ function isRateLimitError(error) {
4877
+ return isErrorOfCategory(error, ERROR_CATEGORIES.RATE_LIMIT);
4878
+ }
4879
+ function isPostError(error) {
4880
+ return isErrorOfCategory(error, ERROR_CATEGORIES.POST);
4881
+ }
4882
+ function isMediaError(error) {
4883
+ return isErrorOfCategory(error, ERROR_CATEGORIES.MEDIA);
4884
+ }
4885
+ function isRecoverableError(error) {
4886
+ if (error instanceof ApiError || error instanceof PlatformError) {
4887
+ return error.recoverable;
4888
+ }
4889
+ return false;
4890
+ }
4891
+ function getErrorMessage(error, defaultMessage = "An error occurred") {
4892
+ if (error instanceof Error) {
4893
+ return error.message || defaultMessage;
4894
+ }
4895
+ if (typeof error === "string") {
4896
+ return error;
4897
+ }
4898
+ if (error && typeof error === "object" && "message" in error) {
4899
+ return error.message || defaultMessage;
4900
+ }
4901
+ return defaultMessage;
4902
+ }
4903
+ function getErrorDetails(error) {
4904
+ if (error instanceof ApiError || error instanceof PlatformError) {
4905
+ return error.details;
4906
+ }
4907
+ if (error && typeof error === "object" && "details" in error) {
4908
+ return error.details;
4909
+ }
4910
+ return void 0;
4911
+ }
4912
+ function enrichErrorWithContext(error, context) {
4913
+ if (error instanceof ApiError) {
4914
+ return new ApiError(
4915
+ error.message,
4916
+ error.code,
4917
+ error.status,
4918
+ { ...error.details || {}, ...context },
4919
+ error.recoverable
4920
+ );
4921
+ }
4922
+ if (error instanceof PlatformError) {
4923
+ return new PlatformError(
4924
+ error.message,
4925
+ error.platform,
4926
+ error.code,
4927
+ error.recoverable,
4928
+ error.originalError,
4929
+ error.status,
4930
+ error.userId,
4931
+ { ...error.details || {}, ...context }
4932
+ );
4933
+ }
4934
+ const errorMessage = error instanceof Error ? error.message : String(error);
4935
+ return new ApiError(
4936
+ errorMessage || "An error occurred",
4937
+ ApiErrorCode.INTERNAL_ERROR,
4938
+ 500,
4939
+ { originalError: error, ...context },
4940
+ false
4941
+ );
4942
+ }
4943
+ async function apiWrapper(apiCall, context) {
4944
+ try {
4945
+ return await apiCall();
4946
+ } catch (error) {
4947
+ if (error instanceof Response) {
4948
+ try {
4949
+ const errorData = await error.json();
4950
+ throw enrichErrorWithContext(
4951
+ handleErrorResponse(errorData, error.status),
4952
+ context || {}
4953
+ );
4954
+ } catch (jsonError) {
4955
+ if (jsonError instanceof Error && jsonError.name === "SyntaxError") {
4956
+ throw enrichErrorWithContext(
4957
+ new ApiError(
4958
+ `API request failed with status ${error.status} and non-JSON response`,
4959
+ ApiErrorCode.NETWORK_ERROR,
4960
+ error.status,
4961
+ { originalResponse: error.statusText }
4962
+ ),
4963
+ context || {}
4964
+ );
4965
+ }
4966
+ throw jsonError;
4967
+ }
4968
+ }
4969
+ if (error instanceof ApiError || error instanceof PlatformError) {
4970
+ throw enrichErrorWithContext(error, context || {});
4971
+ }
4972
+ throw enrichErrorWithContext(
4973
+ error instanceof Error ? error : new Error(String(error)),
4974
+ context || {}
4975
+ );
4976
+ }
4977
+ }
4805
4978
  function handleErrorResponse(data, status) {
4806
4979
  const errorData = data?.error || {};
4807
4980
  const message = errorData?.message || data?.message || "An API error occurred";
@@ -4854,145 +5027,160 @@ function createNetworkError(error, url, timeout) {
4854
5027
  );
4855
5028
  }
4856
5029
 
4857
- // src/utils/cookie.ts
4858
- import Cookies from "js-cookie";
4859
- var AUTH_COOKIE_NAME = "__crosspost_auth";
4860
- var CSRF_COOKIE_NAME = "XSRF-TOKEN";
4861
- var CSRF_HEADER_NAME = "X-CSRF-Token";
4862
- var AUTH_COOKIE_OPTIONS = {
4863
- secure: true,
4864
- sameSite: "lax",
4865
- // how could we make this none?
4866
- path: "/",
4867
- expires: 30
4868
- // 30 days
4869
- };
4870
- function getAuthFromCookie() {
4871
- try {
4872
- if (typeof document === "undefined") {
4873
- return void 0;
4874
- }
4875
- const cookieValue = Cookies.get(AUTH_COOKIE_NAME);
4876
- if (!cookieValue) {
4877
- return void 0;
5030
+ // src/core/request.ts
5031
+ async function makeRequest(method, path, options, data, query) {
5032
+ let url = `${options.baseUrl}${path.startsWith("/") ? path : `/${path}`}`;
5033
+ if (query && Object.keys(query).length > 0) {
5034
+ const queryParams = new URLSearchParams();
5035
+ for (const [key, value] of Object.entries(query)) {
5036
+ if (value !== void 0 && value !== null) {
5037
+ queryParams.append(key, String(value));
5038
+ }
4878
5039
  }
4879
- return JSON.parse(cookieValue);
4880
- } catch (error) {
4881
- console.error("Failed to parse auth cookie:", error);
4882
- return void 0;
4883
- }
4884
- }
4885
- function storeAuthInCookie(authData) {
4886
- try {
4887
- if (typeof document === "undefined") {
4888
- return;
5040
+ const queryString = queryParams.toString();
5041
+ if (queryString) {
5042
+ url += `?${queryString}`;
4889
5043
  }
4890
- const cookieValue = JSON.stringify(authData);
4891
- Cookies.set(AUTH_COOKIE_NAME, cookieValue, AUTH_COOKIE_OPTIONS);
4892
- } catch (error) {
4893
- console.error("Failed to store auth cookie:", error);
4894
- }
4895
- }
4896
- function clearAuthCookie() {
4897
- if (typeof document === "undefined") {
4898
- return;
4899
5044
  }
4900
- Cookies.remove(AUTH_COOKIE_NAME, { path: AUTH_COOKIE_OPTIONS.path });
4901
- }
4902
- function getCsrfToken() {
4903
- if (typeof document === "undefined") {
4904
- return void 0;
4905
- }
4906
- return Cookies.get(CSRF_COOKIE_NAME);
4907
- }
4908
-
4909
- // src/core/request.ts
4910
- async function makeRequest(method, path, options, data) {
4911
- const url = `${options.baseUrl}${path.startsWith("/") ? path : `/${path}`}`;
4912
- let lastError = null;
4913
- if (!options.signature) {
5045
+ if (!options.nearAuthData) {
4914
5046
  throw ApiError.unauthorized("Authentication required. Please provide NEAR signature.");
4915
5047
  }
4916
- for (let attempt = 0; attempt <= options.retries; attempt++) {
4917
- const controller = new AbortController();
4918
- const timeoutId = setTimeout(() => controller.abort(), options.timeout);
4919
- try {
4920
- const headers = {
4921
- "Content-Type": "application/json",
4922
- "Accept": "application/json",
4923
- "Authorization": `Bearer ${createAuthToken(options.signature)}`
4924
- };
4925
- if (method !== "GET") {
4926
- const csrfToken = getCsrfToken();
4927
- if (csrfToken) {
4928
- headers[CSRF_HEADER_NAME] = csrfToken;
4929
- }
4930
- }
4931
- const requestOptions = {
4932
- method,
4933
- headers,
4934
- body: method !== "GET" && data ? JSON.stringify(data) : void 0,
4935
- signal: controller.signal
4936
- };
4937
- const response = await fetch(url, requestOptions);
4938
- clearTimeout(timeoutId);
4939
- let responseData;
5048
+ const context = {
5049
+ method,
5050
+ path,
5051
+ url,
5052
+ retries: options.retries
5053
+ };
5054
+ return apiWrapper(async () => {
5055
+ let lastError = null;
5056
+ for (let attempt = 0; attempt <= options.retries; attempt++) {
5057
+ const controller = new AbortController();
5058
+ const timeoutId = setTimeout(() => controller.abort(), options.timeout);
4940
5059
  try {
4941
- responseData = await response.json();
4942
- } catch (jsonError) {
4943
- if (!response.ok) {
5060
+ const headers = {
5061
+ "Content-Type": "application/json",
5062
+ "Accept": "application/json",
5063
+ "Authorization": `Bearer ${createAuthToken(options.nearAuthData)}`
5064
+ };
5065
+ const requestOptions = {
5066
+ method,
5067
+ headers,
5068
+ body: method !== "GET" && data ? JSON.stringify(data) : void 0,
5069
+ signal: controller.signal
5070
+ };
5071
+ const response = await fetch(url, requestOptions);
5072
+ clearTimeout(timeoutId);
5073
+ let responseData;
5074
+ try {
5075
+ responseData = await response.json();
5076
+ } catch (jsonError) {
5077
+ if (!response.ok) {
5078
+ throw new ApiError(
5079
+ `API request failed with status ${response.status} and non-JSON response`,
5080
+ ApiErrorCode.NETWORK_ERROR,
5081
+ response.status,
5082
+ { originalStatusText: response.statusText }
5083
+ );
5084
+ }
5085
+ if (response.status === 204) return {};
4944
5086
  throw new ApiError(
4945
- `API request failed with status ${response.status} and non-JSON response`,
4946
- ApiErrorCode.NETWORK_ERROR,
4947
- // Or a more specific code
4948
- response.status,
4949
- { originalStatusText: response.statusText }
5087
+ `Failed to parse JSON response: ${jsonError instanceof Error ? jsonError.message : String(jsonError)}`,
5088
+ ApiErrorCode.INTERNAL_ERROR,
5089
+ response.status
4950
5090
  );
4951
5091
  }
4952
- if (response.status === 204) return {};
4953
- throw new ApiError(
4954
- `Failed to parse JSON response: ${jsonError instanceof Error ? jsonError.message : String(jsonError)}`,
4955
- ApiErrorCode.INTERNAL_ERROR,
4956
- // Or NETWORK_ERROR?
4957
- response.status
4958
- );
4959
- }
4960
- if (!response.ok) {
4961
- lastError = handleErrorResponse(responseData, response.status);
4962
- const shouldRetry = response.status >= 500 || lastError instanceof ApiError && lastError.recoverable;
4963
- if (shouldRetry && attempt < options.retries) {
4964
- await new Promise((resolve) => setTimeout(resolve, 1e3 * Math.pow(2, attempt)));
4965
- continue;
5092
+ if (!response.ok) {
5093
+ lastError = handleErrorResponse(responseData, response.status);
5094
+ const shouldRetry = response.status >= 500 || lastError instanceof ApiError && lastError.recoverable;
5095
+ if (shouldRetry && attempt < options.retries) {
5096
+ await new Promise((resolve) => setTimeout(resolve, 1e3 * Math.pow(2, attempt)));
5097
+ continue;
5098
+ }
5099
+ throw lastError;
4966
5100
  }
4967
- throw lastError;
4968
- }
4969
- if (responseData && typeof responseData === "object" && "success" in responseData && !responseData.success && responseData.error) {
4970
- lastError = handleErrorResponse(responseData, response.status);
4971
- const shouldRetry = lastError instanceof ApiError && lastError.recoverable;
4972
- if (shouldRetry && attempt < options.retries) {
5101
+ if (responseData && typeof responseData === "object" && "success" in responseData && !responseData.success && responseData.error) {
5102
+ lastError = handleErrorResponse(responseData, response.status);
5103
+ const shouldRetry = lastError instanceof ApiError && lastError.recoverable;
5104
+ if (shouldRetry && attempt < options.retries) {
5105
+ await new Promise((resolve) => setTimeout(resolve, 1e3 * Math.pow(2, attempt)));
5106
+ continue;
5107
+ }
5108
+ throw lastError;
5109
+ }
5110
+ return responseData;
5111
+ } catch (error) {
5112
+ clearTimeout(timeoutId);
5113
+ lastError = error instanceof Error ? error : new Error(String(error));
5114
+ const isNetworkError2 = error instanceof TypeError || error instanceof DOMException && error.name === "AbortError";
5115
+ if (isNetworkError2 && attempt < options.retries) {
4973
5116
  await new Promise((resolve) => setTimeout(resolve, 1e3 * Math.pow(2, attempt)));
4974
5117
  continue;
4975
5118
  }
4976
- throw lastError;
4977
- }
4978
- return responseData;
4979
- } catch (error) {
4980
- clearTimeout(timeoutId);
4981
- lastError = error;
4982
- const isNetworkError = error instanceof TypeError || error instanceof DOMException && error.name === "AbortError";
4983
- if (isNetworkError && attempt < options.retries) {
4984
- await new Promise((resolve) => setTimeout(resolve, 1e3 * Math.pow(2, attempt)));
4985
- continue;
4986
- }
4987
- if (!(error instanceof ApiError)) {
4988
- throw createNetworkError(error, url, options.timeout);
5119
+ if (!(error instanceof ApiError)) {
5120
+ throw createNetworkError(error, url, options.timeout);
5121
+ }
5122
+ throw error;
4989
5123
  }
4990
- throw error;
4991
5124
  }
4992
- }
4993
- throw lastError || new ApiError("Request failed after multiple retries", ApiErrorCode.INTERNAL_ERROR, 500);
5125
+ throw lastError || new ApiError("Request failed after multiple retries", ApiErrorCode.INTERNAL_ERROR, 500);
5126
+ }, context);
4994
5127
  }
4995
5128
 
5129
+ // src/api/activity.ts
5130
+ var ActivityApi = class {
5131
+ /**
5132
+ * Creates an instance of ActivityApi
5133
+ * @param options Request options
5134
+ */
5135
+ constructor(options) {
5136
+ this.options = options;
5137
+ }
5138
+ /**
5139
+ * Gets the global activity leaderboard
5140
+ * @param query Optional query parameters
5141
+ * @returns A promise resolving with the leaderboard response
5142
+ */
5143
+ async getLeaderboard(query) {
5144
+ return makeRequest(
5145
+ "GET",
5146
+ "/api/activity",
5147
+ this.options,
5148
+ void 0,
5149
+ query
5150
+ );
5151
+ }
5152
+ /**
5153
+ * Gets activity for a specific account
5154
+ * @param signerId The NEAR account ID
5155
+ * @param query Optional query parameters
5156
+ * @returns A promise resolving with the account activity response
5157
+ */
5158
+ async getAccountActivity(signerId, query) {
5159
+ return makeRequest(
5160
+ "GET",
5161
+ `/api/activity/${signerId}`,
5162
+ this.options,
5163
+ void 0,
5164
+ query
5165
+ );
5166
+ }
5167
+ /**
5168
+ * Gets posts for a specific account
5169
+ * @param signerId The NEAR account ID
5170
+ * @param query Optional query parameters
5171
+ * @returns A promise resolving with the account posts response
5172
+ */
5173
+ async getAccountPosts(signerId, query) {
5174
+ return makeRequest(
5175
+ "GET",
5176
+ `/api/activity/${signerId}/posts`,
5177
+ this.options,
5178
+ void 0,
5179
+ query
5180
+ );
5181
+ }
5182
+ };
5183
+
4996
5184
  // src/api/auth.ts
4997
5185
  var AuthApi = class {
4998
5186
  /**
@@ -5211,6 +5399,51 @@ var PostApi = class {
5211
5399
  }
5212
5400
  };
5213
5401
 
5402
+ // src/api/system.ts
5403
+ var SystemApi = class {
5404
+ /**
5405
+ * Creates an instance of SystemApi
5406
+ * @param options Request options
5407
+ */
5408
+ constructor(options) {
5409
+ this.options = options;
5410
+ }
5411
+ /**
5412
+ * Gets the current rate limit status
5413
+ * @returns A promise resolving with the rate limit response
5414
+ */
5415
+ async getRateLimits() {
5416
+ return makeRequest(
5417
+ "GET",
5418
+ "/api/rate-limit",
5419
+ this.options
5420
+ );
5421
+ }
5422
+ /**
5423
+ * Gets the rate limit status for a specific endpoint
5424
+ * @param endpoint The endpoint to get rate limit for
5425
+ * @returns A promise resolving with the endpoint rate limit response
5426
+ */
5427
+ async getEndpointRateLimit(endpoint) {
5428
+ return makeRequest(
5429
+ "GET",
5430
+ `/api/rate-limit/${endpoint}`,
5431
+ this.options
5432
+ );
5433
+ }
5434
+ /**
5435
+ * Gets the health status of the API
5436
+ * @returns A promise resolving with the health status
5437
+ */
5438
+ async getHealthStatus() {
5439
+ return makeRequest(
5440
+ "GET",
5441
+ "/health",
5442
+ this.options
5443
+ );
5444
+ }
5445
+ };
5446
+
5214
5447
  // src/core/config.ts
5215
5448
  var DEFAULT_CONFIG = {
5216
5449
  baseUrl: "https://open-crosspost-proxy.deno.dev/",
@@ -5228,28 +5461,34 @@ var CrosspostClient = class {
5228
5461
  const baseUrl = config.baseUrl || DEFAULT_CONFIG.baseUrl;
5229
5462
  const timeout = config.timeout || DEFAULT_CONFIG.timeout;
5230
5463
  const retries = config.retries ?? DEFAULT_CONFIG.retries;
5231
- const signature = config.signature || getAuthFromCookie();
5464
+ const nearAuthData = config.nearAuthData;
5232
5465
  this.options = {
5233
5466
  baseUrl,
5234
5467
  timeout,
5235
5468
  retries,
5236
- signature
5469
+ nearAuthData
5237
5470
  };
5238
5471
  this.auth = new AuthApi(this.options);
5239
5472
  this.post = new PostApi(this.options);
5473
+ this.activity = new ActivityApi(this.options);
5474
+ this.system = new SystemApi(this.options);
5475
+ }
5476
+ /**
5477
+ * Sets the authentication data (signature) for the client
5478
+ * @param nearAuthData The NEAR authentication data
5479
+ */
5480
+ setAuthentication(nearAuthData) {
5481
+ this.options.nearAuthData = nearAuthData;
5240
5482
  }
5241
5483
  /**
5242
- * Sets the authentication data (signature) for the client and stores it in a cookie
5484
+ * Checks if authentication data (signature) exists on client
5243
5485
  * @param signature The NEAR authentication data
5244
5486
  */
5245
- async setAuthentication(signature) {
5246
- this.options.signature = signature;
5247
- storeAuthInCookie(signature);
5487
+ isAuthenticated() {
5488
+ return !!this.options.nearAuthData;
5248
5489
  }
5249
5490
  };
5250
5491
  export {
5251
- AUTH_COOKIE_NAME,
5252
- AUTH_COOKIE_OPTIONS,
5253
5492
  AccountActivityEntrySchema,
5254
5493
  AccountActivityParamsSchema,
5255
5494
  AccountActivityQuerySchema,
@@ -5258,6 +5497,9 @@ export {
5258
5497
  AccountPostsParamsSchema,
5259
5498
  AccountPostsQuerySchema,
5260
5499
  AccountPostsResponseSchema,
5500
+ ActivityApi,
5501
+ ActivityLeaderboardQuerySchema,
5502
+ ActivityLeaderboardResponseSchema,
5261
5503
  AllRateLimitsResponseSchema,
5262
5504
  ApiError,
5263
5505
  ApiErrorCode,
@@ -5270,8 +5512,6 @@ export {
5270
5512
  AuthStatusResponseSchema,
5271
5513
  AuthUrlResponseSchema,
5272
5514
  BaseError,
5273
- CSRF_COOKIE_NAME,
5274
- CSRF_HEADER_NAME,
5275
5515
  ConnectedAccountSchema,
5276
5516
  ConnectedAccountsResponseSchema,
5277
5517
  CreatePostRequestSchema,
@@ -5283,14 +5523,13 @@ export {
5283
5523
  DeletePostRequestSchema,
5284
5524
  DeletePostResponseSchema,
5285
5525
  DeleteResultSchema,
5526
+ ERROR_CATEGORIES,
5286
5527
  EndpointRateLimitResponseSchema,
5287
5528
  EnhancedErrorResponseSchema,
5288
5529
  EnhancedResponseMetaSchema,
5289
5530
  EnhancedResponseSchema,
5290
5531
  ErrorDetailSchema,
5291
5532
  ErrorResponseSchema,
5292
- LeaderboardQuerySchema,
5293
- LeaderboardResponseSchema,
5294
5533
  LikePostRequestSchema,
5295
5534
  LikePostResponseSchema,
5296
5535
  LikeResultSchema,
@@ -5328,13 +5567,17 @@ export {
5328
5567
  ReplyToPostResponseSchema,
5329
5568
  RepostRequestSchema,
5330
5569
  RepostResponseSchema,
5570
+ SUPPORTED_PLATFORMS,
5331
5571
  SuccessDetailSchema,
5572
+ SupportedPlatformSchema,
5573
+ SystemApi,
5332
5574
  TargetSchema,
5575
+ TimePeriod,
5333
5576
  UnlikePostRequestSchema,
5334
5577
  UnlikePostResponseSchema,
5335
5578
  UsageRateLimitSchema,
5336
5579
  UserProfileSchema,
5337
- clearAuthCookie,
5580
+ apiWrapper,
5338
5581
  createApiResponse,
5339
5582
  createEnhancedApiResponse,
5340
5583
  createEnhancedErrorResponse,
@@ -5343,8 +5586,19 @@ export {
5343
5586
  createMultiStatusResponse,
5344
5587
  createNetworkError,
5345
5588
  createSuccessDetail,
5346
- getAuthFromCookie,
5347
- getCsrfToken,
5589
+ enrichErrorWithContext,
5590
+ getErrorDetails,
5591
+ getErrorMessage,
5348
5592
  handleErrorResponse,
5349
- storeAuthInCookie
5593
+ isAuthError,
5594
+ isContentError,
5595
+ isErrorOfCategory,
5596
+ isMediaError,
5597
+ isNetworkError,
5598
+ isPlatformError,
5599
+ isPlatformSupported,
5600
+ isPostError,
5601
+ isRateLimitError,
5602
+ isRecoverableError,
5603
+ isValidationError
5350
5604
  };