@crosspost/sdk 0.1.3 → 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Open Crosspost
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -13,34 +13,22 @@ bun install @crosspost/sdk
13
13
  ```typescript
14
14
  import { ApiError, CrosspostClient, isAuthError, PlatformError } from '@crosspost/sdk';
15
15
 
16
- // Initialize the client with direct authentication
16
+ // Initialize the client (authentication can be provided later)
17
17
  const client = new CrosspostClient({
18
18
  baseUrl: 'https://your-crosspost-api.com', // Optional: Defaults to official API
19
- nearAuthData: {
20
- accountId: 'your-account.near',
21
- publicKey: 'ed25519:...',
22
- signature: '...',
23
- message: '...',
24
- },
25
- });
26
-
27
- // Or initialize with cookie-based authentication (will auto-load from cookie if available)
28
- const cookieClient = new CrosspostClient({
29
- baseUrl: 'https://your-crosspost-api.com',
30
- // No nearAuthData provided - will check for cookie
31
19
  });
32
20
 
33
- // Set authentication explicitly (also stores in secure cookie)
34
- await cookieClient.setAuthentication({
21
+ // Set authentication with fresh signature for the request
22
+ client.setAuthentication({
35
23
  accountId: 'your-account.near',
36
24
  publicKey: 'ed25519:...',
37
25
  signature: '...',
38
26
  message: '...',
39
27
  });
40
28
 
41
- // Check if client is authenticated
42
- if (cookieClient.isAuthenticated()) {
43
- console.log('Client is authenticated');
29
+ // Check if client has authentication data set
30
+ if (client.isAuthenticated()) {
31
+ console.log('Client has authentication data');
44
32
  }
45
33
 
46
34
  // NEAR Account Authorization
@@ -110,6 +98,7 @@ async function revokePlatformAuth(platform) {
110
98
  async function createPost() {
111
99
  try {
112
100
  const response = await client.post.createPost({
101
+ targets: [{ platform: 'twitter', userId: 'your-twitter-id' }],
113
102
  content: {
114
103
  text: 'Hello from Crosspost SDK!',
115
104
  },
@@ -178,13 +167,21 @@ constructor(config?: {
178
167
 
179
168
  ### Post API (client.post)
180
169
 
181
- - `createPost(request): Promise<CreatePostResponse>` - Creates a new post
182
- - `repost(request): Promise<RepostResponse>` - Reposts an existing post
183
- - `quotePost(request): Promise<QuotePostResponse>` - Quotes an existing post
184
- - `replyToPost(request): Promise<ReplyToPostResponse>` - Replies to a post
185
- - `likePost(request): Promise<LikePostResponse>` - Likes a post
186
- - `unlikePost(request): Promise<UnlikePostResponse>` - Unlikes a post
187
- - `deletePost(request): Promise<DeletePostResponse>` - Deletes a post
170
+ Each post operation accepts a request object that includes:
171
+
172
+ - `targets`: Array of `{ platform: string, userId: string }` specifying where to perform the action
173
+ - Additional parameters specific to each operation
174
+
175
+ Available methods:
176
+
177
+ - `createPost(request: CreatePostRequest): Promise<CreatePostResponse>` - Creates posts on specified
178
+ platforms
179
+ - `repost(request: RepostRequest): Promise<RepostResponse>` - Reposts an existing post
180
+ - `quotePost(request: QuotePostRequest): Promise<QuotePostResponse>` - Quotes an existing post
181
+ - `replyToPost(request: ReplyToPostRequest): Promise<ReplyToPostResponse>` - Replies to a post
182
+ - `likePost(request: LikePostRequest): Promise<LikePostResponse>` - Likes a post
183
+ - `unlikePost(request: UnlikePostRequest): Promise<UnlikePostResponse>` - Unlikes a post
184
+ - `deletePost(request: DeletePostRequest): Promise<DeletePostResponse>` - Deletes posts
188
185
 
189
186
  ### Activity API (client.activity)
190
187
 
@@ -249,51 +246,81 @@ const result = await apiWrapper(
249
246
  ### Creating a Post
250
247
 
251
248
  ```typescript
252
- // Create a simple text post
249
+ // Create a text post on Twitter
253
250
  const textPostResponse = await client.post.createPost({
254
- content: {
251
+ targets: [{
252
+ platform: 'twitter',
253
+ userId: 'your-twitter-id',
254
+ }],
255
+ content: [{
255
256
  text: 'Hello from Crosspost SDK!',
256
- },
257
+ }],
257
258
  });
258
259
 
259
- // Create a post with media
260
+ // Create a post with media on multiple platforms
260
261
  const mediaPostResponse = await client.post.createPost({
261
- content: {
262
+ targets: [
263
+ { platform: 'twitter', userId: 'your-twitter-id' },
264
+ { platform: 'facebook', userId: 'your-facebook-id' },
265
+ ],
266
+ content: [{
262
267
  text: 'Check out this image!',
263
- media: [
264
- {
265
- type: 'image',
266
- url: 'https://example.com/image.jpg',
267
- },
268
- ],
269
- },
268
+ media: [{
269
+ data: imageBlob,
270
+ mimeType: 'image/jpeg',
271
+ altText: 'A beautiful sunset',
272
+ }],
273
+ }],
270
274
  });
271
275
  ```
272
276
 
273
277
  ### Post Interactions
274
278
 
275
279
  ```typescript
276
- // Like a post
280
+ // Like a post on Twitter
277
281
  await client.post.likePost({
282
+ targets: [{
283
+ platform: 'twitter',
284
+ userId: 'your-twitter-id',
285
+ }],
286
+ platform: 'twitter',
278
287
  postId: '1234567890',
279
288
  });
280
289
 
281
- // Repost
290
+ // Repost on multiple platforms
282
291
  await client.post.repost({
292
+ targets: [
293
+ { platform: 'twitter', userId: 'your-twitter-id' },
294
+ { platform: 'facebook', userId: 'your-facebook-id' },
295
+ ],
296
+ platform: 'twitter',
283
297
  postId: '1234567890',
284
298
  });
285
299
 
286
300
  // Reply to a post
287
301
  await client.post.replyToPost({
302
+ targets: [{
303
+ platform: 'twitter',
304
+ userId: 'your-twitter-id',
305
+ }],
306
+ platform: 'twitter',
288
307
  postId: '1234567890',
289
- content: {
308
+ content: [{
290
309
  text: 'This is a reply!',
291
- },
310
+ }],
292
311
  });
293
312
 
294
- // Delete a post
313
+ // Delete posts
295
314
  await client.post.deletePost({
296
- postId: '1234567890',
315
+ targets: [{
316
+ platform: 'twitter',
317
+ userId: 'your-twitter-id',
318
+ }],
319
+ posts: [{
320
+ platform: 'twitter',
321
+ userId: 'your-twitter-id',
322
+ postId: '1234567890',
323
+ }],
297
324
  });
298
325
  ```
299
326
 
@@ -330,56 +357,21 @@ const postRateLimit = await client.system.getEndpointRateLimit('post');
330
357
 
331
358
  ## Authentication and Security
332
359
 
333
- ### Authentication Strategies
334
-
335
- The SDK supports two authentication strategies:
336
-
337
- 1. **Direct Authentication**: Provide `nearAuthData` directly in the constructor.
338
- ```typescript
339
- const client = new CrosspostClient({
340
- nearAuthData: {
341
- accountId: 'your-account.near',
342
- publicKey: 'ed25519:...',
343
- signature: '...',
344
- message: '...',
345
- },
346
- });
347
- ```
348
-
349
- 2. **Cookie-Based Authentication**: Automatically read/write authentication data from a secure
350
- cookie.
351
- ```typescript
352
- // Initialize without auth data (will check for cookie)
353
- const client = new CrosspostClient();
354
-
355
- // Set authentication (also stores in cookie)
356
- client.setAuthentication(nearAuthData);
357
- ```
360
+ ### Authentication Strategy
358
361
 
359
- ### Cookie Security
362
+ The SDK uses direct authentication with per-request signatures:
360
363
 
361
- When using cookie-based authentication, the SDK stores authentication data in a secure cookie with
362
- the following settings:
363
-
364
- - **Name**: `__crosspost_auth`
365
- - **Secure**: `true` (only sent over HTTPS)
366
- - **SameSite**: `Lax` (sent with same-site requests and top-level navigations)
367
- - **Path**: `/` (available across the entire domain)
368
- - **Expires**: 30 days
369
-
370
- ### CSRF Protection
371
-
372
- The SDK implements CSRF protection for state-changing requests (non-GET) using the Double Submit
373
- Cookie pattern:
374
-
375
- 1. The backend API sets a CSRF token in a non-HttpOnly cookie (`XSRF-TOKEN`)
376
- 2. The SDK reads this token and includes it in the `X-CSRF-Token` header for all state-changing
377
- requests
378
- 3. The backend validates that the token in the header matches the token in the cookie
379
-
380
- This protection is automatically enabled when using cookie-based authentication and requires no
381
- additional configuration from the client side.
382
-
383
- ## License
364
+ ```typescript
365
+ // Initialize the client
366
+ const client = new CrosspostClient({
367
+ baseUrl: 'https://your-crosspost-api.com',
368
+ });
384
369
 
385
- MIT
370
+ // Before making authenticated requests, set fresh signature
371
+ client.setAuthentication({
372
+ accountId: 'your-account.near',
373
+ publicKey: 'ed25519:...',
374
+ signature: '...',
375
+ message: '...',
376
+ });
377
+ ```
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({
@@ -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
  });