@crosspost/types 0.1.8 → 0.1.10
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 +10 -5
- package/dist/index.d.cts +40 -18
- package/dist/index.d.ts +40 -18
- package/dist/index.js +10 -5
- package/package.json +1 -1
- package/src/auth.ts +6 -3
- package/src/errors.ts +4 -0
package/dist/index.cjs
CHANGED
@@ -141,6 +141,7 @@ var ApiErrorCode = /* @__PURE__ */ ((ApiErrorCode2) => {
|
|
141
141
|
ApiErrorCode2["POST_DELETION_FAILED"] = "POST_DELETION_FAILED";
|
142
142
|
ApiErrorCode2["POST_INTERACTION_FAILED"] = "POST_INTERACTION_FAILED";
|
143
143
|
ApiErrorCode2["NETWORK_ERROR"] = "NETWORK_ERROR";
|
144
|
+
ApiErrorCode2["INVALID_RESPONSE"] = "INVALID_RESPONSE";
|
144
145
|
return ApiErrorCode2;
|
145
146
|
})(ApiErrorCode || {});
|
146
147
|
var ApiErrorCodeSchema = import_zod2.z.enum(Object.values(ApiErrorCode));
|
@@ -163,7 +164,8 @@ var errorCodeToStatusCode = {
|
|
163
164
|
["THREAD_CREATION_FAILED" /* THREAD_CREATION_FAILED */]: 500,
|
164
165
|
["POST_DELETION_FAILED" /* POST_DELETION_FAILED */]: 500,
|
165
166
|
["POST_INTERACTION_FAILED" /* POST_INTERACTION_FAILED */]: 500,
|
166
|
-
["NETWORK_ERROR" /* NETWORK_ERROR */]: 503
|
167
|
+
["NETWORK_ERROR" /* NETWORK_ERROR */]: 503,
|
168
|
+
["INVALID_RESPONSE" /* INVALID_RESPONSE */]: 500
|
167
169
|
};
|
168
170
|
var ErrorDetailSchema = import_zod2.z.object({
|
169
171
|
message: import_zod2.z.string().describe("Human-readable error message"),
|
@@ -222,7 +224,10 @@ var AuthInitRequestSchema = import_zod4.z.object({
|
|
222
224
|
successUrl: import_zod4.z.string().url().optional().describe(
|
223
225
|
"URL to redirect to on successful authentication"
|
224
226
|
),
|
225
|
-
errorUrl: import_zod4.z.string().url().optional().describe("URL to redirect to on authentication error")
|
227
|
+
errorUrl: import_zod4.z.string().url().optional().describe("URL to redirect to on authentication error"),
|
228
|
+
redirect: import_zod4.z.boolean().optional().default(false).describe(
|
229
|
+
"Whether to redirect to successUrl/errorUrl (true) or return data directly (false)"
|
230
|
+
)
|
226
231
|
}).describe("Auth initialization request");
|
227
232
|
var AuthUrlResponseSchema = import_zod4.z.object({
|
228
233
|
url: import_zod4.z.string().describe("Authentication URL to redirect the user to"),
|
@@ -270,9 +275,9 @@ var ConnectedAccountSchema = import_zod4.z.object({
|
|
270
275
|
profileUrl: import_zod4.z.string().optional().describe("URL to the user profile"),
|
271
276
|
connectedAt: import_zod4.z.string().optional().describe("When the account was connected")
|
272
277
|
}).describe("Connected account");
|
273
|
-
var ConnectedAccountsResponseSchema = import_zod4.z.
|
274
|
-
|
275
|
-
);
|
278
|
+
var ConnectedAccountsResponseSchema = import_zod4.z.object({
|
279
|
+
accounts: import_zod4.z.array(ConnectedAccountSchema)
|
280
|
+
}).describe("Response containing an array of connected accounts");
|
276
281
|
var NearAuthorizationRequestSchema = import_zod4.z.object({
|
277
282
|
// No additional parameters needed, as the NEAR account ID is extracted from the signature
|
278
283
|
}).describe("NEAR authorization request");
|
package/dist/index.d.cts
CHANGED
@@ -45,7 +45,8 @@ declare enum ApiErrorCode {
|
|
45
45
|
THREAD_CREATION_FAILED = "THREAD_CREATION_FAILED",
|
46
46
|
POST_DELETION_FAILED = "POST_DELETION_FAILED",
|
47
47
|
POST_INTERACTION_FAILED = "POST_INTERACTION_FAILED",
|
48
|
-
NETWORK_ERROR = "NETWORK_ERROR"
|
48
|
+
NETWORK_ERROR = "NETWORK_ERROR",
|
49
|
+
INVALID_RESPONSE = "INVALID_RESPONSE"
|
49
50
|
}
|
50
51
|
declare const ApiErrorCodeSchema: z.ZodEnum<[string, ...string[]]>;
|
51
52
|
/**
|
@@ -298,12 +299,15 @@ declare const PlatformParamSchema: z.ZodObject<{
|
|
298
299
|
declare const AuthInitRequestSchema: z.ZodObject<{
|
299
300
|
successUrl: z.ZodOptional<z.ZodString>;
|
300
301
|
errorUrl: z.ZodOptional<z.ZodString>;
|
302
|
+
redirect: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
301
303
|
}, "strip", z.ZodTypeAny, {
|
304
|
+
redirect: boolean;
|
302
305
|
successUrl?: string | undefined;
|
303
306
|
errorUrl?: string | undefined;
|
304
307
|
}, {
|
305
308
|
successUrl?: string | undefined;
|
306
309
|
errorUrl?: string | undefined;
|
310
|
+
redirect?: boolean | undefined;
|
307
311
|
}>;
|
308
312
|
declare const AuthUrlResponseSchema: z.ZodObject<{
|
309
313
|
url: z.ZodString;
|
@@ -433,25 +437,43 @@ declare const ConnectedAccountSchema: z.ZodObject<{
|
|
433
437
|
profileUrl?: string | undefined;
|
434
438
|
connectedAt?: string | undefined;
|
435
439
|
}>;
|
436
|
-
declare const ConnectedAccountsResponseSchema: z.
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
440
|
+
declare const ConnectedAccountsResponseSchema: z.ZodObject<{
|
441
|
+
accounts: z.ZodArray<z.ZodObject<{
|
442
|
+
platform: z.ZodNativeEnum<typeof Platform>;
|
443
|
+
userId: z.ZodString;
|
444
|
+
username: z.ZodOptional<z.ZodString>;
|
445
|
+
profileUrl: z.ZodOptional<z.ZodString>;
|
446
|
+
connectedAt: z.ZodOptional<z.ZodString>;
|
447
|
+
}, "strip", z.ZodTypeAny, {
|
448
|
+
platform: Platform;
|
449
|
+
userId: string;
|
450
|
+
username?: string | undefined;
|
451
|
+
profileUrl?: string | undefined;
|
452
|
+
connectedAt?: string | undefined;
|
453
|
+
}, {
|
454
|
+
platform: Platform;
|
455
|
+
userId: string;
|
456
|
+
username?: string | undefined;
|
457
|
+
profileUrl?: string | undefined;
|
458
|
+
connectedAt?: string | undefined;
|
459
|
+
}>, "many">;
|
442
460
|
}, "strip", z.ZodTypeAny, {
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
461
|
+
accounts: {
|
462
|
+
platform: Platform;
|
463
|
+
userId: string;
|
464
|
+
username?: string | undefined;
|
465
|
+
profileUrl?: string | undefined;
|
466
|
+
connectedAt?: string | undefined;
|
467
|
+
}[];
|
448
468
|
}, {
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
469
|
+
accounts: {
|
470
|
+
platform: Platform;
|
471
|
+
userId: string;
|
472
|
+
username?: string | undefined;
|
473
|
+
profileUrl?: string | undefined;
|
474
|
+
connectedAt?: string | undefined;
|
475
|
+
}[];
|
476
|
+
}>;
|
455
477
|
declare const NearAuthorizationRequestSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
456
478
|
declare const NearAuthorizationResponseSchema: z.ZodObject<{
|
457
479
|
nearAccount: z.ZodString;
|
package/dist/index.d.ts
CHANGED
@@ -45,7 +45,8 @@ declare enum ApiErrorCode {
|
|
45
45
|
THREAD_CREATION_FAILED = "THREAD_CREATION_FAILED",
|
46
46
|
POST_DELETION_FAILED = "POST_DELETION_FAILED",
|
47
47
|
POST_INTERACTION_FAILED = "POST_INTERACTION_FAILED",
|
48
|
-
NETWORK_ERROR = "NETWORK_ERROR"
|
48
|
+
NETWORK_ERROR = "NETWORK_ERROR",
|
49
|
+
INVALID_RESPONSE = "INVALID_RESPONSE"
|
49
50
|
}
|
50
51
|
declare const ApiErrorCodeSchema: z.ZodEnum<[string, ...string[]]>;
|
51
52
|
/**
|
@@ -298,12 +299,15 @@ declare const PlatformParamSchema: z.ZodObject<{
|
|
298
299
|
declare const AuthInitRequestSchema: z.ZodObject<{
|
299
300
|
successUrl: z.ZodOptional<z.ZodString>;
|
300
301
|
errorUrl: z.ZodOptional<z.ZodString>;
|
302
|
+
redirect: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
301
303
|
}, "strip", z.ZodTypeAny, {
|
304
|
+
redirect: boolean;
|
302
305
|
successUrl?: string | undefined;
|
303
306
|
errorUrl?: string | undefined;
|
304
307
|
}, {
|
305
308
|
successUrl?: string | undefined;
|
306
309
|
errorUrl?: string | undefined;
|
310
|
+
redirect?: boolean | undefined;
|
307
311
|
}>;
|
308
312
|
declare const AuthUrlResponseSchema: z.ZodObject<{
|
309
313
|
url: z.ZodString;
|
@@ -433,25 +437,43 @@ declare const ConnectedAccountSchema: z.ZodObject<{
|
|
433
437
|
profileUrl?: string | undefined;
|
434
438
|
connectedAt?: string | undefined;
|
435
439
|
}>;
|
436
|
-
declare const ConnectedAccountsResponseSchema: z.
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
440
|
+
declare const ConnectedAccountsResponseSchema: z.ZodObject<{
|
441
|
+
accounts: z.ZodArray<z.ZodObject<{
|
442
|
+
platform: z.ZodNativeEnum<typeof Platform>;
|
443
|
+
userId: z.ZodString;
|
444
|
+
username: z.ZodOptional<z.ZodString>;
|
445
|
+
profileUrl: z.ZodOptional<z.ZodString>;
|
446
|
+
connectedAt: z.ZodOptional<z.ZodString>;
|
447
|
+
}, "strip", z.ZodTypeAny, {
|
448
|
+
platform: Platform;
|
449
|
+
userId: string;
|
450
|
+
username?: string | undefined;
|
451
|
+
profileUrl?: string | undefined;
|
452
|
+
connectedAt?: string | undefined;
|
453
|
+
}, {
|
454
|
+
platform: Platform;
|
455
|
+
userId: string;
|
456
|
+
username?: string | undefined;
|
457
|
+
profileUrl?: string | undefined;
|
458
|
+
connectedAt?: string | undefined;
|
459
|
+
}>, "many">;
|
442
460
|
}, "strip", z.ZodTypeAny, {
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
461
|
+
accounts: {
|
462
|
+
platform: Platform;
|
463
|
+
userId: string;
|
464
|
+
username?: string | undefined;
|
465
|
+
profileUrl?: string | undefined;
|
466
|
+
connectedAt?: string | undefined;
|
467
|
+
}[];
|
448
468
|
}, {
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
469
|
+
accounts: {
|
470
|
+
platform: Platform;
|
471
|
+
userId: string;
|
472
|
+
username?: string | undefined;
|
473
|
+
profileUrl?: string | undefined;
|
474
|
+
connectedAt?: string | undefined;
|
475
|
+
}[];
|
476
|
+
}>;
|
455
477
|
declare const NearAuthorizationRequestSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
456
478
|
declare const NearAuthorizationResponseSchema: z.ZodObject<{
|
457
479
|
nearAccount: z.ZodString;
|
package/dist/index.js
CHANGED
@@ -41,6 +41,7 @@ var ApiErrorCode = /* @__PURE__ */ ((ApiErrorCode2) => {
|
|
41
41
|
ApiErrorCode2["POST_DELETION_FAILED"] = "POST_DELETION_FAILED";
|
42
42
|
ApiErrorCode2["POST_INTERACTION_FAILED"] = "POST_INTERACTION_FAILED";
|
43
43
|
ApiErrorCode2["NETWORK_ERROR"] = "NETWORK_ERROR";
|
44
|
+
ApiErrorCode2["INVALID_RESPONSE"] = "INVALID_RESPONSE";
|
44
45
|
return ApiErrorCode2;
|
45
46
|
})(ApiErrorCode || {});
|
46
47
|
var ApiErrorCodeSchema = z2.enum(Object.values(ApiErrorCode));
|
@@ -63,7 +64,8 @@ var errorCodeToStatusCode = {
|
|
63
64
|
["THREAD_CREATION_FAILED" /* THREAD_CREATION_FAILED */]: 500,
|
64
65
|
["POST_DELETION_FAILED" /* POST_DELETION_FAILED */]: 500,
|
65
66
|
["POST_INTERACTION_FAILED" /* POST_INTERACTION_FAILED */]: 500,
|
66
|
-
["NETWORK_ERROR" /* NETWORK_ERROR */]: 503
|
67
|
+
["NETWORK_ERROR" /* NETWORK_ERROR */]: 503,
|
68
|
+
["INVALID_RESPONSE" /* INVALID_RESPONSE */]: 500
|
67
69
|
};
|
68
70
|
var ErrorDetailSchema = z2.object({
|
69
71
|
message: z2.string().describe("Human-readable error message"),
|
@@ -122,7 +124,10 @@ var AuthInitRequestSchema = z4.object({
|
|
122
124
|
successUrl: z4.string().url().optional().describe(
|
123
125
|
"URL to redirect to on successful authentication"
|
124
126
|
),
|
125
|
-
errorUrl: z4.string().url().optional().describe("URL to redirect to on authentication error")
|
127
|
+
errorUrl: z4.string().url().optional().describe("URL to redirect to on authentication error"),
|
128
|
+
redirect: z4.boolean().optional().default(false).describe(
|
129
|
+
"Whether to redirect to successUrl/errorUrl (true) or return data directly (false)"
|
130
|
+
)
|
126
131
|
}).describe("Auth initialization request");
|
127
132
|
var AuthUrlResponseSchema = z4.object({
|
128
133
|
url: z4.string().describe("Authentication URL to redirect the user to"),
|
@@ -170,9 +175,9 @@ var ConnectedAccountSchema = z4.object({
|
|
170
175
|
profileUrl: z4.string().optional().describe("URL to the user profile"),
|
171
176
|
connectedAt: z4.string().optional().describe("When the account was connected")
|
172
177
|
}).describe("Connected account");
|
173
|
-
var ConnectedAccountsResponseSchema = z4.
|
174
|
-
|
175
|
-
);
|
178
|
+
var ConnectedAccountsResponseSchema = z4.object({
|
179
|
+
accounts: z4.array(ConnectedAccountSchema)
|
180
|
+
}).describe("Response containing an array of connected accounts");
|
176
181
|
var NearAuthorizationRequestSchema = z4.object({
|
177
182
|
// No additional parameters needed, as the NEAR account ID is extracted from the signature
|
178
183
|
}).describe("NEAR authorization request");
|
package/package.json
CHANGED
package/src/auth.ts
CHANGED
@@ -10,6 +10,9 @@ export const AuthInitRequestSchema = z.object({
|
|
10
10
|
'URL to redirect to on successful authentication',
|
11
11
|
),
|
12
12
|
errorUrl: z.string().url().optional().describe('URL to redirect to on authentication error'),
|
13
|
+
redirect: z.boolean().optional().default(false).describe(
|
14
|
+
'Whether to redirect to successUrl/errorUrl (true) or return data directly (false)',
|
15
|
+
),
|
13
16
|
}).describe('Auth initialization request');
|
14
17
|
|
15
18
|
export const AuthUrlResponseSchema = z.object({
|
@@ -67,9 +70,9 @@ export const ConnectedAccountSchema = z.object({
|
|
67
70
|
connectedAt: z.string().optional().describe('When the account was connected'),
|
68
71
|
}).describe('Connected account');
|
69
72
|
|
70
|
-
export const ConnectedAccountsResponseSchema = z.
|
71
|
-
|
72
|
-
);
|
73
|
+
export const ConnectedAccountsResponseSchema = z.object({
|
74
|
+
accounts: z.array(ConnectedAccountSchema),
|
75
|
+
}).describe('Response containing an array of connected accounts');
|
73
76
|
|
74
77
|
export const NearAuthorizationRequestSchema = z.object({
|
75
78
|
// No additional parameters needed, as the NEAR account ID is extracted from the signature
|
package/src/errors.ts
CHANGED
@@ -42,6 +42,9 @@ export enum ApiErrorCode {
|
|
42
42
|
|
43
43
|
// Network errors
|
44
44
|
NETWORK_ERROR = 'NETWORK_ERROR',
|
45
|
+
|
46
|
+
// Response format errors
|
47
|
+
INVALID_RESPONSE = 'INVALID_RESPONSE',
|
45
48
|
}
|
46
49
|
|
47
50
|
export const ApiErrorCodeSchema = z.enum(Object.values(ApiErrorCode) as [string, ...string[]]);
|
@@ -70,6 +73,7 @@ export const errorCodeToStatusCode: Record<ApiErrorCode, StatusCode> = {
|
|
70
73
|
[ApiErrorCode.POST_DELETION_FAILED]: 500,
|
71
74
|
[ApiErrorCode.POST_INTERACTION_FAILED]: 500,
|
72
75
|
[ApiErrorCode.NETWORK_ERROR]: 503,
|
76
|
+
[ApiErrorCode.INVALID_RESPONSE]: 500,
|
73
77
|
};
|
74
78
|
|
75
79
|
/**
|