@crosspost/sdk 0.1.11 → 0.1.13
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 +7 -9
- package/dist/index.js +7 -9
- package/package.json +1 -1
- package/src/api/auth.ts +10 -13
- package/src/utils/popup.ts +0 -7
package/dist/index.cjs
CHANGED
@@ -544,15 +544,13 @@ var AuthApi = class {
|
|
544
544
|
* @throws Error if popups are blocked or if running in a non-browser environment.
|
545
545
|
*/
|
546
546
|
async loginToPlatform(platform, options) {
|
547
|
-
const
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
}
|
555
|
-
const result = await openAuthPopup(loginUrl.toString());
|
547
|
+
const { url } = await makeRequest(
|
548
|
+
"POST",
|
549
|
+
`/auth/${platform}/login`,
|
550
|
+
this.options,
|
551
|
+
options || { redirect: false }
|
552
|
+
);
|
553
|
+
const result = await openAuthPopup(url);
|
556
554
|
if (!result.success || !result.userId) {
|
557
555
|
throw new Error(result.error || "Authentication failed");
|
558
556
|
}
|
package/dist/index.js
CHANGED
@@ -498,15 +498,13 @@ var AuthApi = class {
|
|
498
498
|
* @throws Error if popups are blocked or if running in a non-browser environment.
|
499
499
|
*/
|
500
500
|
async loginToPlatform(platform, options) {
|
501
|
-
const
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
}
|
509
|
-
const result = await openAuthPopup(loginUrl.toString());
|
501
|
+
const { url } = await makeRequest(
|
502
|
+
"POST",
|
503
|
+
`/auth/${platform}/login`,
|
504
|
+
this.options,
|
505
|
+
options || { redirect: false }
|
506
|
+
);
|
507
|
+
const result = await openAuthPopup(url);
|
510
508
|
if (!result.success || !result.userId) {
|
511
509
|
throw new Error(result.error || "Authentication failed");
|
512
510
|
}
|
package/package.json
CHANGED
package/src/api/auth.ts
CHANGED
@@ -5,6 +5,7 @@ import type {
|
|
5
5
|
AuthStatusParams,
|
6
6
|
AuthStatusResponse,
|
7
7
|
AuthTokenRequest,
|
8
|
+
AuthUrlResponse,
|
8
9
|
ConnectedAccount,
|
9
10
|
ConnectedAccountsResponse,
|
10
11
|
NearAuthorizationRequest,
|
@@ -65,20 +66,16 @@ export class AuthApi {
|
|
65
66
|
platform: Platform,
|
66
67
|
options?: AuthInitRequest,
|
67
68
|
): Promise<AuthCallbackResponse> {
|
68
|
-
//
|
69
|
-
const
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
}
|
76
|
-
if (options?.errorUrl) {
|
77
|
-
loginUrl.searchParams.set('errorUrl', options.errorUrl);
|
78
|
-
}
|
69
|
+
// Make POST request to get auth URL
|
70
|
+
const { url } = await makeRequest<AuthUrlResponse, AuthInitRequest>(
|
71
|
+
'POST',
|
72
|
+
`/auth/${platform}/login`,
|
73
|
+
this.options,
|
74
|
+
options || { redirect: false },
|
75
|
+
);
|
79
76
|
|
80
|
-
// Open the popup
|
81
|
-
const result = await openAuthPopup(
|
77
|
+
// Open the popup with the auth URL
|
78
|
+
const result = await openAuthPopup(url);
|
82
79
|
|
83
80
|
if (!result.success || !result.userId) {
|
84
81
|
throw new Error(result.error || 'Authentication failed');
|
package/src/utils/popup.ts
CHANGED
@@ -1,13 +1,6 @@
|
|
1
1
|
// @ts-nocheck
|
2
|
-
|
3
2
|
import type { PlatformName } from '@crosspost/types';
|
4
|
-
|
5
3
|
declare global {
|
6
|
-
interface Window {
|
7
|
-
innerWidth: number;
|
8
|
-
innerHeight: number;
|
9
|
-
open(url: string, target: string, features: string): Window | null;
|
10
|
-
}
|
11
4
|
interface WindowEventMap {
|
12
5
|
message: MessageEvent<AuthCallbackMessage>;
|
13
6
|
}
|