@crosspost/sdk 0.1.3 → 0.1.5

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
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,21 +15,11 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // src/index.ts
31
21
  var index_exports = {};
32
22
  __export(index_exports, {
33
- AUTH_COOKIE_NAME: () => AUTH_COOKIE_NAME,
34
- AUTH_COOKIE_OPTIONS: () => AUTH_COOKIE_OPTIONS,
35
23
  AccountActivityEntrySchema: () => AccountActivityEntrySchema,
36
24
  AccountActivityParamsSchema: () => AccountActivityParamsSchema,
37
25
  AccountActivityQuerySchema: () => AccountActivityQuerySchema,
@@ -55,8 +43,6 @@ __export(index_exports, {
55
43
  AuthStatusResponseSchema: () => AuthStatusResponseSchema,
56
44
  AuthUrlResponseSchema: () => AuthUrlResponseSchema,
57
45
  BaseError: () => BaseError,
58
- CSRF_COOKIE_NAME: () => CSRF_COOKIE_NAME,
59
- CSRF_HEADER_NAME: () => CSRF_HEADER_NAME,
60
46
  ConnectedAccountSchema: () => ConnectedAccountSchema,
61
47
  ConnectedAccountsResponseSchema: () => ConnectedAccountsResponseSchema,
62
48
  CreatePostRequestSchema: () => CreatePostRequestSchema,
@@ -112,7 +98,9 @@ __export(index_exports, {
112
98
  ReplyToPostResponseSchema: () => ReplyToPostResponseSchema,
113
99
  RepostRequestSchema: () => RepostRequestSchema,
114
100
  RepostResponseSchema: () => RepostResponseSchema,
101
+ SUPPORTED_PLATFORMS: () => SUPPORTED_PLATFORMS,
115
102
  SuccessDetailSchema: () => SuccessDetailSchema,
103
+ SupportedPlatformSchema: () => SupportedPlatformSchema,
116
104
  SystemApi: () => SystemApi,
117
105
  TargetSchema: () => TargetSchema,
118
106
  TimePeriod: () => TimePeriod,
@@ -121,7 +109,6 @@ __export(index_exports, {
121
109
  UsageRateLimitSchema: () => UsageRateLimitSchema,
122
110
  UserProfileSchema: () => UserProfileSchema,
123
111
  apiWrapper: () => apiWrapper,
124
- clearAuthCookie: () => clearAuthCookie,
125
112
  createApiResponse: () => createApiResponse,
126
113
  createEnhancedApiResponse: () => createEnhancedApiResponse,
127
114
  createEnhancedErrorResponse: () => createEnhancedErrorResponse,
@@ -131,8 +118,6 @@ __export(index_exports, {
131
118
  createNetworkError: () => createNetworkError,
132
119
  createSuccessDetail: () => createSuccessDetail,
133
120
  enrichErrorWithContext: () => enrichErrorWithContext,
134
- getAuthFromCookie: () => getAuthFromCookie,
135
- getCsrfToken: () => getCsrfToken,
136
121
  getErrorDetails: () => getErrorDetails,
137
122
  getErrorMessage: () => getErrorMessage,
138
123
  handleErrorResponse: () => handleErrorResponse,
@@ -142,11 +127,11 @@ __export(index_exports, {
142
127
  isMediaError: () => isMediaError,
143
128
  isNetworkError: () => isNetworkError,
144
129
  isPlatformError: () => isPlatformError,
130
+ isPlatformSupported: () => isPlatformSupported,
145
131
  isPostError: () => isPostError,
146
132
  isRateLimitError: () => isRateLimitError,
147
133
  isRecoverableError: () => isRecoverableError,
148
- isValidationError: () => isValidationError,
149
- storeAuthInCookie: () => storeAuthInCookie
134
+ isValidationError: () => isValidationError
150
135
  });
151
136
  module.exports = __toCommonJS(index_exports);
152
137
 
@@ -4211,19 +4196,22 @@ var z = /* @__PURE__ */ Object.freeze({
4211
4196
  });
4212
4197
 
4213
4198
  // ../types/dist/index.js
4214
- var PlatformSchema = z.enum([
4215
- "unknown",
4216
- "twitter"
4217
- // Add more platforms as they're implemented
4218
- // 'linkedin',
4219
- // 'facebook',
4220
- // 'instagram',
4221
- ]).describe("Social media platform");
4222
- var Platform = /* @__PURE__ */ ((Platform22) => {
4223
- Platform22["UNKNOWN"] = "unknown";
4224
- Platform22["TWITTER"] = "twitter";
4225
- return Platform22;
4199
+ var Platform = /* @__PURE__ */ ((Platform2) => {
4200
+ Platform2["UNKNOWN"] = "unknown";
4201
+ Platform2["TWITTER"] = "twitter";
4202
+ return Platform2;
4226
4203
  })(Platform || {});
4204
+ var PlatformSchema = z.nativeEnum(Platform).describe("Social media platform");
4205
+ var SUPPORTED_PLATFORMS = [
4206
+ "twitter"
4207
+ /* TWITTER */
4208
+ // Add more platforms here as they're implemented
4209
+ ];
4210
+ var SupportedPlatformSchema = SUPPORTED_PLATFORMS.length > 0 ? z.enum(SUPPORTED_PLATFORMS) : z.never();
4211
+ SupportedPlatformSchema.describe("Currently supported social media platforms");
4212
+ function isPlatformSupported(platform) {
4213
+ return SUPPORTED_PLATFORMS.includes(platform);
4214
+ }
4227
4215
  var ApiResponseSchema = z.object({
4228
4216
  data: z.any().describe("Response data"),
4229
4217
  meta: z.object({
@@ -4832,15 +4820,15 @@ var EndpointRateLimitResponseSchema = z.object({
4832
4820
  signerId: z.string().describe("NEAR account ID")
4833
4821
  }).describe("Endpoint rate limit response");
4834
4822
  var TimePeriod = /* @__PURE__ */ ((TimePeriod2) => {
4835
- TimePeriod2["ALL_TIME"] = "all";
4836
- TimePeriod2["YEARLY"] = "yearly";
4837
- TimePeriod2["MONTHLY"] = "monthly";
4838
- TimePeriod2["WEEKLY"] = "weekly";
4839
- TimePeriod2["DAILY"] = "daily";
4823
+ TimePeriod2["ALL"] = "all";
4824
+ TimePeriod2["YEARLY"] = "year";
4825
+ TimePeriod2["MONTHLY"] = "month";
4826
+ TimePeriod2["WEEKLY"] = "week";
4827
+ TimePeriod2["DAILY"] = "day";
4840
4828
  return TimePeriod2;
4841
4829
  })(TimePeriod || {});
4842
4830
  var ActivityLeaderboardQuerySchema = z.object({
4843
- timeframe: z.enum(["day", "week", "month", "all"]).optional().describe(
4831
+ timeframe: z.nativeEnum(TimePeriod).optional().describe(
4844
4832
  "Timeframe for the leaderboard"
4845
4833
  ),
4846
4834
  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)"),
@@ -4859,7 +4847,7 @@ var AccountActivityEntrySchema = z.object({
4859
4847
  }).describe("Account activity entry");
4860
4848
  var ActivityLeaderboardResponseSchema = EnhancedResponseSchema(
4861
4849
  z.object({
4862
- timeframe: z.enum(["day", "week", "month", "all"]).describe("Timeframe for the leaderboard"),
4850
+ timeframe: z.nativeEnum(TimePeriod).describe("Timeframe for the leaderboard"),
4863
4851
  entries: z.array(AccountActivityEntrySchema).describe("Leaderboard entries"),
4864
4852
  total: z.number().describe("Total number of entries in the leaderboard"),
4865
4853
  limit: z.number().describe("Maximum number of results returned"),
@@ -4871,7 +4859,7 @@ var AccountActivityParamsSchema = z.object({
4871
4859
  signerId: z.string().describe("NEAR account ID")
4872
4860
  }).describe("Account activity params");
4873
4861
  var AccountActivityQuerySchema = z.object({
4874
- timeframe: z.enum(["day", "week", "month", "all"]).optional().describe(
4862
+ timeframe: z.nativeEnum(TimePeriod).optional().describe(
4875
4863
  "Timeframe for the activity"
4876
4864
  )
4877
4865
  }).describe("Account activity query");
@@ -4888,7 +4876,7 @@ var PlatformActivitySchema = z.object({
4888
4876
  var AccountActivityResponseSchema = EnhancedResponseSchema(
4889
4877
  z.object({
4890
4878
  signerId: z.string().describe("NEAR account ID"),
4891
- timeframe: z.enum(["day", "week", "month", "all"]).describe("Timeframe for the activity"),
4879
+ timeframe: z.nativeEnum(TimePeriod).describe("Timeframe for the activity"),
4892
4880
  totalPosts: z.number().describe("Total number of posts across all platforms"),
4893
4881
  totalLikes: z.number().describe("Total number of likes across all platforms"),
4894
4882
  totalReposts: z.number().describe("Total number of reposts across all platforms"),
@@ -4962,59 +4950,6 @@ var ProfileRefreshResponseSchema = EnhancedResponseSchema(
4962
4950
  var import_near_sign_verify = require("near-sign-verify");
4963
4951
 
4964
4952
  // src/utils/error.ts
4965
- function handleErrorResponse(data, status) {
4966
- const errorData = data?.error || {};
4967
- const message = errorData?.message || data?.message || "An API error occurred";
4968
- const codeString = errorData?.code || data?.code || ApiErrorCode.UNKNOWN_ERROR;
4969
- const code = Object.values(ApiErrorCode).includes(codeString) ? codeString : ApiErrorCode.UNKNOWN_ERROR;
4970
- const details = errorData?.details || data?.details || {};
4971
- const recoverable = errorData?.recoverable ?? data?.recoverable ?? false;
4972
- const platform = errorData?.platform || data?.platform;
4973
- const enhancedDetails = { ...details };
4974
- if (typeof enhancedDetails === "object" && !enhancedDetails.originalResponse) {
4975
- enhancedDetails.originalResponse = data;
4976
- }
4977
- if (platform && Object.values(Platform).includes(platform)) {
4978
- return new PlatformError(
4979
- message,
4980
- platform,
4981
- code,
4982
- // Use the parsed code
4983
- status,
4984
- // Cast status
4985
- enhancedDetails,
4986
- recoverable
4987
- );
4988
- } else {
4989
- return new ApiError(
4990
- message,
4991
- code,
4992
- // Use the parsed code
4993
- status,
4994
- // Cast status
4995
- enhancedDetails,
4996
- recoverable
4997
- );
4998
- }
4999
- }
5000
- function createNetworkError(error, url, timeout) {
5001
- if (error instanceof DOMException && error.name === "AbortError") {
5002
- return new ApiError(
5003
- `Request timed out after ${timeout}ms`,
5004
- ApiErrorCode.NETWORK_ERROR,
5005
- 408,
5006
- { url }
5007
- );
5008
- }
5009
- return new ApiError(
5010
- error instanceof Error ? error.message : "An unexpected error occurred during the request",
5011
- ApiErrorCode.INTERNAL_ERROR,
5012
- 500,
5013
- { originalError: String(error), url }
5014
- );
5015
- }
5016
-
5017
- // src/utils/error-utils.ts
5018
4953
  var ERROR_CATEGORIES = {
5019
4954
  AUTH: [
5020
4955
  ApiErrorCode.UNAUTHORIZED,
@@ -5142,9 +5077,6 @@ function enrichErrorWithContext(error, context) {
5142
5077
  false
5143
5078
  );
5144
5079
  }
5145
- function handleErrorResponse2(data, status) {
5146
- return handleErrorResponse(data, status);
5147
- }
5148
5080
  async function apiWrapper(apiCall, context) {
5149
5081
  try {
5150
5082
  return await apiCall();
@@ -5153,7 +5085,7 @@ async function apiWrapper(apiCall, context) {
5153
5085
  try {
5154
5086
  const errorData = await error.json();
5155
5087
  throw enrichErrorWithContext(
5156
- handleErrorResponse2(errorData, error.status),
5088
+ handleErrorResponse(errorData, error.status),
5157
5089
  context || {}
5158
5090
  );
5159
5091
  } catch (jsonError) {
@@ -5180,63 +5112,56 @@ async function apiWrapper(apiCall, context) {
5180
5112
  );
5181
5113
  }
5182
5114
  }
5183
-
5184
- // src/utils/cookie.ts
5185
- var import_js_cookie = __toESM(require("js-cookie"), 1);
5186
- var AUTH_COOKIE_NAME = "__crosspost_auth";
5187
- var CSRF_COOKIE_NAME = "XSRF-TOKEN";
5188
- var CSRF_HEADER_NAME = "X-CSRF-Token";
5189
- var isDeno = () => {
5190
- return typeof globalThis.Deno !== "undefined";
5191
- };
5192
- var isBrowser = () => {
5193
- return !isDeno() && typeof globalThis.window !== "undefined";
5194
- };
5195
- var AUTH_COOKIE_OPTIONS = {
5196
- secure: true,
5197
- sameSite: "lax",
5198
- // Restrict to same-site and top-level navigation
5199
- path: "/",
5200
- expires: 30
5201
- // 30 days
5202
- };
5203
- function getAuthFromCookie() {
5204
- try {
5205
- if (!isBrowser()) {
5206
- return void 0;
5207
- }
5208
- const cookieValue = import_js_cookie.default.get(AUTH_COOKIE_NAME);
5209
- if (!cookieValue) {
5210
- return void 0;
5211
- }
5212
- return JSON.parse(cookieValue);
5213
- } catch (error) {
5214
- console.error("Failed to parse auth cookie:", error);
5215
- return void 0;
5216
- }
5217
- }
5218
- function storeAuthInCookie(authData) {
5219
- try {
5220
- if (!isBrowser()) {
5221
- return;
5222
- }
5223
- const cookieValue = JSON.stringify(authData);
5224
- import_js_cookie.default.set(AUTH_COOKIE_NAME, cookieValue, AUTH_COOKIE_OPTIONS);
5225
- } catch (error) {
5226
- console.error("Failed to store auth cookie:", error);
5115
+ function handleErrorResponse(data, status) {
5116
+ const errorData = data?.error || {};
5117
+ const message = errorData?.message || data?.message || "An API error occurred";
5118
+ const codeString = errorData?.code || data?.code || ApiErrorCode.UNKNOWN_ERROR;
5119
+ const code = Object.values(ApiErrorCode).includes(codeString) ? codeString : ApiErrorCode.UNKNOWN_ERROR;
5120
+ const details = errorData?.details || data?.details || {};
5121
+ const recoverable = errorData?.recoverable ?? data?.recoverable ?? false;
5122
+ const platform = errorData?.platform || data?.platform;
5123
+ const enhancedDetails = { ...details };
5124
+ if (typeof enhancedDetails === "object" && !enhancedDetails.originalResponse) {
5125
+ enhancedDetails.originalResponse = data;
5227
5126
  }
5228
- }
5229
- function clearAuthCookie() {
5230
- if (!isBrowser()) {
5231
- return;
5127
+ if (platform && Object.values(Platform).includes(platform)) {
5128
+ return new PlatformError(
5129
+ message,
5130
+ platform,
5131
+ code,
5132
+ // Use the parsed code
5133
+ status,
5134
+ // Cast status
5135
+ enhancedDetails,
5136
+ recoverable
5137
+ );
5138
+ } else {
5139
+ return new ApiError(
5140
+ message,
5141
+ code,
5142
+ // Use the parsed code
5143
+ status,
5144
+ // Cast status
5145
+ enhancedDetails,
5146
+ recoverable
5147
+ );
5232
5148
  }
5233
- import_js_cookie.default.remove(AUTH_COOKIE_NAME, { path: AUTH_COOKIE_OPTIONS.path });
5234
5149
  }
5235
- function getCsrfToken() {
5236
- if (!isBrowser()) {
5237
- return void 0;
5150
+ function createNetworkError(error, url, timeout) {
5151
+ if (error instanceof DOMException && error.name === "AbortError") {
5152
+ return new ApiError(
5153
+ `Request timed out after ${timeout}ms`,
5154
+ ApiErrorCode.NETWORK_ERROR,
5155
+ 408,
5156
+ { url }
5157
+ );
5238
5158
  }
5239
- return import_js_cookie.default.get(CSRF_COOKIE_NAME);
5159
+ return new ApiError(
5160
+ error instanceof Error ? error.message : "An unexpected error occurred during the request",
5161
+ ApiErrorCode.INTERNAL_ERROR,
5162
+ 500,
5163
+ { originalError: String(error), url }
5164
+ );
5240
5165
  }
5241
5166
 
5242
5167
  // src/core/request.ts
@@ -5274,12 +5199,6 @@ async function makeRequest(method, path, options, data, query) {
5274
5199
  "Accept": "application/json",
5275
5200
  "Authorization": `Bearer ${(0, import_near_sign_verify.createAuthToken)(options.nearAuthData)}`
5276
5201
  };
5277
- if (method !== "GET") {
5278
- const csrfToken = getCsrfToken();
5279
- if (csrfToken) {
5280
- headers[CSRF_HEADER_NAME] = csrfToken;
5281
- }
5282
- }
5283
5202
  const requestOptions = {
5284
5203
  method,
5285
5204
  headers,
@@ -5679,7 +5598,7 @@ var CrosspostClient = class {
5679
5598
  const baseUrl = config.baseUrl || DEFAULT_CONFIG.baseUrl;
5680
5599
  const timeout = config.timeout || DEFAULT_CONFIG.timeout;
5681
5600
  const retries = config.retries ?? DEFAULT_CONFIG.retries;
5682
- const nearAuthData = config.nearAuthData || getAuthFromCookie();
5601
+ const nearAuthData = config.nearAuthData;
5683
5602
  this.options = {
5684
5603
  baseUrl,
5685
5604
  timeout,
@@ -5692,12 +5611,11 @@ var CrosspostClient = class {
5692
5611
  this.system = new SystemApi(this.options);
5693
5612
  }
5694
5613
  /**
5695
- * Sets the authentication data (signature) for the client and stores it in a cookie
5696
- * @param signature The NEAR authentication data
5614
+ * Sets the authentication data (signature) for the client
5615
+ * @param nearAuthData The NEAR authentication data
5697
5616
  */
5698
5617
  setAuthentication(nearAuthData) {
5699
5618
  this.options.nearAuthData = nearAuthData;
5700
- storeAuthInCookie(nearAuthData);
5701
5619
  }
5702
5620
  /**
5703
5621
  * Checks if authentication data (signature) exists on client
@@ -5709,8 +5627,6 @@ var CrosspostClient = class {
5709
5627
  };
5710
5628
  // Annotate the CommonJS export names for ESM import in node:
5711
5629
  0 && (module.exports = {
5712
- AUTH_COOKIE_NAME,
5713
- AUTH_COOKIE_OPTIONS,
5714
5630
  AccountActivityEntrySchema,
5715
5631
  AccountActivityParamsSchema,
5716
5632
  AccountActivityQuerySchema,
@@ -5734,8 +5650,6 @@ var CrosspostClient = class {
5734
5650
  AuthStatusResponseSchema,
5735
5651
  AuthUrlResponseSchema,
5736
5652
  BaseError,
5737
- CSRF_COOKIE_NAME,
5738
- CSRF_HEADER_NAME,
5739
5653
  ConnectedAccountSchema,
5740
5654
  ConnectedAccountsResponseSchema,
5741
5655
  CreatePostRequestSchema,
@@ -5791,7 +5705,9 @@ var CrosspostClient = class {
5791
5705
  ReplyToPostResponseSchema,
5792
5706
  RepostRequestSchema,
5793
5707
  RepostResponseSchema,
5708
+ SUPPORTED_PLATFORMS,
5794
5709
  SuccessDetailSchema,
5710
+ SupportedPlatformSchema,
5795
5711
  SystemApi,
5796
5712
  TargetSchema,
5797
5713
  TimePeriod,
@@ -5800,7 +5716,6 @@ var CrosspostClient = class {
5800
5716
  UsageRateLimitSchema,
5801
5717
  UserProfileSchema,
5802
5718
  apiWrapper,
5803
- clearAuthCookie,
5804
5719
  createApiResponse,
5805
5720
  createEnhancedApiResponse,
5806
5721
  createEnhancedErrorResponse,
@@ -5810,8 +5725,6 @@ var CrosspostClient = class {
5810
5725
  createNetworkError,
5811
5726
  createSuccessDetail,
5812
5727
  enrichErrorWithContext,
5813
- getAuthFromCookie,
5814
- getCsrfToken,
5815
5728
  getErrorDetails,
5816
5729
  getErrorMessage,
5817
5730
  handleErrorResponse,
@@ -5821,9 +5734,9 @@ var CrosspostClient = class {
5821
5734
  isMediaError,
5822
5735
  isNetworkError,
5823
5736
  isPlatformError,
5737
+ isPlatformSupported,
5824
5738
  isPostError,
5825
5739
  isRateLimitError,
5826
5740
  isRecoverableError,
5827
- isValidationError,
5828
- storeAuthInCookie
5741
+ isValidationError
5829
5742
  });
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, EnhancedApiResponse, AuthStatusResponse, AuthRevokeResponse, ConnectedAccountsResponse, CreatePostRequest, CreatePostResponse, RepostRequest, RepostResponse, QuotePostRequest, QuotePostResponse, ReplyToPostRequest, ReplyToPostResponse, LikePostRequest, LikePostResponse, UnlikePostRequest, UnlikePostResponse, DeletePostRequest, DeletePostResponse, RateLimitResponse, EndpointRateLimitResponse, ApiError, PlatformError, ApiErrorCode } from '@crosspost/types';
2
+ import { ActivityLeaderboardQuery, ActivityLeaderboardResponse, AccountActivityQuery, AccountActivityResponse, AccountPostsQuery, AccountPostsResponse, NearAuthorizationResponse, Platform, EnhancedApiResponse, AuthStatusResponse, AuthRevokeResponse, ConnectedAccountsResponse, CreatePostRequest, CreatePostResponse, RepostRequest, RepostResponse, QuotePostRequest, QuotePostResponse, ReplyToPostRequest, ReplyToPostResponse, LikePostRequest, LikePostResponse, UnlikePostRequest, UnlikePostResponse, DeletePostRequest, DeletePostResponse, RateLimitResponse, EndpointRateLimitResponse, ApiError, ApiErrorCode, PlatformError } from '@crosspost/types';
3
3
  export * from '@crosspost/types';
4
4
 
5
5
  /**
@@ -244,8 +244,8 @@ declare class CrosspostClient {
244
244
  */
245
245
  constructor(config?: CrosspostClientConfig);
246
246
  /**
247
- * Sets the authentication data (signature) for the client and stores it in a cookie
248
- * @param signature The NEAR authentication data
247
+ * Sets the authentication data (signature) for the client
248
+ * @param nearAuthData The NEAR authentication data
249
249
  */
250
250
  setAuthentication(nearAuthData: NearAuthData): void;
251
251
  /**
@@ -256,25 +256,7 @@ declare class CrosspostClient {
256
256
  }
257
257
 
258
258
  /**
259
- * Handles error responses from the API and converts them to appropriate error objects.
260
- *
261
- * @param data The error response data
262
- * @param status The HTTP status code
263
- * @returns An ApiError or PlatformError instance
264
- */
265
- declare function handleErrorResponse(data: any, status: number): ApiError | PlatformError;
266
- /**
267
- * Creates a network error with appropriate details
268
- *
269
- * @param error The original error
270
- * @param url The request URL
271
- * @param timeout The request timeout
272
- * @returns An ApiError instance
273
- */
274
- declare function createNetworkError(error: unknown, url: string, timeout: number): ApiError;
275
-
276
- /**
277
- * Error categories grouped by type for better organization and usage
259
+ * Error categories grouped by type
278
260
  */
279
261
  declare const ERROR_CATEGORIES: {
280
262
  AUTH: ApiErrorCode[];
@@ -389,29 +371,22 @@ declare function enrichErrorWithContext(error: unknown, context: Record<string,
389
371
  * @throws An enriched error if the API call fails
390
372
  */
391
373
  declare function apiWrapper<T>(apiCall: () => Promise<T>, context?: Record<string, any>): Promise<T>;
392
-
393
- declare const AUTH_COOKIE_NAME = "__crosspost_auth";
394
- declare const CSRF_COOKIE_NAME = "XSRF-TOKEN";
395
- declare const CSRF_HEADER_NAME = "X-CSRF-Token";
396
- declare const AUTH_COOKIE_OPTIONS: Cookies.CookieAttributes;
397
- /**
398
- * Gets authentication data from the cookie
399
- * @returns The NearAuthData object or undefined if not found
400
- */
401
- declare function getAuthFromCookie(): NearAuthData | undefined;
402
- /**
403
- * Stores authentication data in a secure cookie
404
- * @param authData The NearAuthData object to store
405
- */
406
- declare function storeAuthInCookie(authData: NearAuthData): void;
407
374
  /**
408
- * Clears the authentication cookie
375
+ * Handles error responses from the API and converts them to appropriate error objects.
376
+ *
377
+ * @param data The error response data
378
+ * @param status The HTTP status code
379
+ * @returns An ApiError or PlatformError instance
409
380
  */
410
- declare function clearAuthCookie(): void;
381
+ declare function handleErrorResponse(data: any, status: number): ApiError | PlatformError;
411
382
  /**
412
- * Gets the CSRF token from the cookie
413
- * @returns The CSRF token or undefined if not found
383
+ * Creates a network error with appropriate details
384
+ *
385
+ * @param error The original error
386
+ * @param url The request URL
387
+ * @param timeout The request timeout
388
+ * @returns An ApiError instance
414
389
  */
415
- declare function getCsrfToken(): string | undefined;
390
+ declare function createNetworkError(error: unknown, url: string, timeout: number): ApiError;
416
391
 
417
- export { AUTH_COOKIE_NAME, AUTH_COOKIE_OPTIONS, ActivityApi, AuthApi, CSRF_COOKIE_NAME, CSRF_HEADER_NAME, CrosspostClient, type CrosspostClientConfig, ERROR_CATEGORIES, PostApi, SystemApi, apiWrapper, clearAuthCookie, createNetworkError, enrichErrorWithContext, getAuthFromCookie, getCsrfToken, getErrorDetails, getErrorMessage, handleErrorResponse, isAuthError, isContentError, isErrorOfCategory, isMediaError, isNetworkError, isPlatformError, isPostError, isRateLimitError, isRecoverableError, isValidationError, storeAuthInCookie };
392
+ export { ActivityApi, AuthApi, CrosspostClient, type CrosspostClientConfig, ERROR_CATEGORIES, PostApi, SystemApi, apiWrapper, createNetworkError, enrichErrorWithContext, getErrorDetails, getErrorMessage, handleErrorResponse, isAuthError, isContentError, isErrorOfCategory, isMediaError, isNetworkError, isPlatformError, isPostError, isRateLimitError, isRecoverableError, isValidationError };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { NearAuthData } from 'near-sign-verify';
2
- import { ActivityLeaderboardQuery, ActivityLeaderboardResponse, AccountActivityQuery, AccountActivityResponse, AccountPostsQuery, AccountPostsResponse, NearAuthorizationResponse, Platform, EnhancedApiResponse, AuthStatusResponse, AuthRevokeResponse, ConnectedAccountsResponse, CreatePostRequest, CreatePostResponse, RepostRequest, RepostResponse, QuotePostRequest, QuotePostResponse, ReplyToPostRequest, ReplyToPostResponse, LikePostRequest, LikePostResponse, UnlikePostRequest, UnlikePostResponse, DeletePostRequest, DeletePostResponse, RateLimitResponse, EndpointRateLimitResponse, ApiError, PlatformError, ApiErrorCode } from '@crosspost/types';
2
+ import { ActivityLeaderboardQuery, ActivityLeaderboardResponse, AccountActivityQuery, AccountActivityResponse, AccountPostsQuery, AccountPostsResponse, NearAuthorizationResponse, Platform, EnhancedApiResponse, AuthStatusResponse, AuthRevokeResponse, ConnectedAccountsResponse, CreatePostRequest, CreatePostResponse, RepostRequest, RepostResponse, QuotePostRequest, QuotePostResponse, ReplyToPostRequest, ReplyToPostResponse, LikePostRequest, LikePostResponse, UnlikePostRequest, UnlikePostResponse, DeletePostRequest, DeletePostResponse, RateLimitResponse, EndpointRateLimitResponse, ApiError, ApiErrorCode, PlatformError } from '@crosspost/types';
3
3
  export * from '@crosspost/types';
4
4
 
5
5
  /**
@@ -244,8 +244,8 @@ declare class CrosspostClient {
244
244
  */
245
245
  constructor(config?: CrosspostClientConfig);
246
246
  /**
247
- * Sets the authentication data (signature) for the client and stores it in a cookie
248
- * @param signature The NEAR authentication data
247
+ * Sets the authentication data (signature) for the client
248
+ * @param nearAuthData The NEAR authentication data
249
249
  */
250
250
  setAuthentication(nearAuthData: NearAuthData): void;
251
251
  /**
@@ -256,25 +256,7 @@ declare class CrosspostClient {
256
256
  }
257
257
 
258
258
  /**
259
- * Handles error responses from the API and converts them to appropriate error objects.
260
- *
261
- * @param data The error response data
262
- * @param status The HTTP status code
263
- * @returns An ApiError or PlatformError instance
264
- */
265
- declare function handleErrorResponse(data: any, status: number): ApiError | PlatformError;
266
- /**
267
- * Creates a network error with appropriate details
268
- *
269
- * @param error The original error
270
- * @param url The request URL
271
- * @param timeout The request timeout
272
- * @returns An ApiError instance
273
- */
274
- declare function createNetworkError(error: unknown, url: string, timeout: number): ApiError;
275
-
276
- /**
277
- * Error categories grouped by type for better organization and usage
259
+ * Error categories grouped by type
278
260
  */
279
261
  declare const ERROR_CATEGORIES: {
280
262
  AUTH: ApiErrorCode[];
@@ -389,29 +371,22 @@ declare function enrichErrorWithContext(error: unknown, context: Record<string,
389
371
  * @throws An enriched error if the API call fails
390
372
  */
391
373
  declare function apiWrapper<T>(apiCall: () => Promise<T>, context?: Record<string, any>): Promise<T>;
392
-
393
- declare const AUTH_COOKIE_NAME = "__crosspost_auth";
394
- declare const CSRF_COOKIE_NAME = "XSRF-TOKEN";
395
- declare const CSRF_HEADER_NAME = "X-CSRF-Token";
396
- declare const AUTH_COOKIE_OPTIONS: Cookies.CookieAttributes;
397
- /**
398
- * Gets authentication data from the cookie
399
- * @returns The NearAuthData object or undefined if not found
400
- */
401
- declare function getAuthFromCookie(): NearAuthData | undefined;
402
- /**
403
- * Stores authentication data in a secure cookie
404
- * @param authData The NearAuthData object to store
405
- */
406
- declare function storeAuthInCookie(authData: NearAuthData): void;
407
374
  /**
408
- * Clears the authentication cookie
375
+ * Handles error responses from the API and converts them to appropriate error objects.
376
+ *
377
+ * @param data The error response data
378
+ * @param status The HTTP status code
379
+ * @returns An ApiError or PlatformError instance
409
380
  */
410
- declare function clearAuthCookie(): void;
381
+ declare function handleErrorResponse(data: any, status: number): ApiError | PlatformError;
411
382
  /**
412
- * Gets the CSRF token from the cookie
413
- * @returns The CSRF token or undefined if not found
383
+ * Creates a network error with appropriate details
384
+ *
385
+ * @param error The original error
386
+ * @param url The request URL
387
+ * @param timeout The request timeout
388
+ * @returns An ApiError instance
414
389
  */
415
- declare function getCsrfToken(): string | undefined;
390
+ declare function createNetworkError(error: unknown, url: string, timeout: number): ApiError;
416
391
 
417
- export { AUTH_COOKIE_NAME, AUTH_COOKIE_OPTIONS, ActivityApi, AuthApi, CSRF_COOKIE_NAME, CSRF_HEADER_NAME, CrosspostClient, type CrosspostClientConfig, ERROR_CATEGORIES, PostApi, SystemApi, apiWrapper, clearAuthCookie, createNetworkError, enrichErrorWithContext, getAuthFromCookie, getCsrfToken, getErrorDetails, getErrorMessage, handleErrorResponse, isAuthError, isContentError, isErrorOfCategory, isMediaError, isNetworkError, isPlatformError, isPostError, isRateLimitError, isRecoverableError, isValidationError, storeAuthInCookie };
392
+ export { ActivityApi, AuthApi, CrosspostClient, type CrosspostClientConfig, ERROR_CATEGORIES, PostApi, SystemApi, apiWrapper, createNetworkError, enrichErrorWithContext, getErrorDetails, getErrorMessage, handleErrorResponse, isAuthError, isContentError, isErrorOfCategory, isMediaError, isNetworkError, isPlatformError, isPostError, isRateLimitError, isRecoverableError, isValidationError };