create-brainerce-store 1.0.0 → 1.0.1

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
@@ -31,10 +31,10 @@ var require_package = __commonJS({
31
31
  "package.json"(exports2, module2) {
32
32
  module2.exports = {
33
33
  name: "create-brainerce-store",
34
- version: "1.0.0",
34
+ version: "1.0.1",
35
35
  description: "Scaffold a production-ready e-commerce storefront connected to Brainerce",
36
36
  bin: {
37
- "create-brainerce-store": "./dist/index.js"
37
+ "create-brainerce-store": "dist/index.js"
38
38
  },
39
39
  files: [
40
40
  "dist",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-brainerce-store",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Scaffold a production-ready e-commerce storefront connected to Brainerce",
5
5
  "bin": {
6
6
  "create-brainerce-store": "dist/index.js"
@@ -2,8 +2,6 @@
2
2
 
3
3
  import { Suspense, useEffect, useState, useRef } from 'react';
4
4
  import { useRouter, useSearchParams } from 'next/navigation';
5
- import type { CustomerOAuthProvider } from 'brainerce';
6
- import { getClient } from '@/lib/brainerce';
7
5
  import { useAuth } from '@/providers/store-provider';
8
6
  import { LoadingSpinner } from '@/components/shared/loading-spinner';
9
7
 
@@ -14,36 +12,27 @@ function OAuthCallbackContent() {
14
12
  const [error, setError] = useState<string | null>(null);
15
13
  const processedRef = useRef(false);
16
14
 
17
- const code = searchParams.get('code');
18
- const state = searchParams.get('state');
19
- const provider = searchParams.get('provider') as CustomerOAuthProvider | null;
15
+ const oauthSuccess = searchParams.get('oauth_success');
16
+ const token = searchParams.get('token');
17
+ const oauthError = searchParams.get('oauth_error');
20
18
 
21
19
  useEffect(() => {
22
20
  // Prevent double-processing in React StrictMode
23
21
  if (processedRef.current) return;
24
22
  processedRef.current = true;
25
23
 
26
- async function handleCallback() {
27
- if (!code || !provider) {
28
- setError('Missing authentication parameters. Please try again.');
29
- return;
30
- }
31
-
32
- try {
33
- const client = getClient();
34
- const result = await client.handleOAuthCallback(provider, code, state || '');
35
-
36
- auth.login(result.token);
37
- router.push('/');
38
- } catch (err) {
39
- const message =
40
- err instanceof Error ? err.message : 'Authentication failed. Please try again.';
41
- setError(message);
42
- }
24
+ if (oauthError) {
25
+ setError(oauthError);
26
+ return;
43
27
  }
44
28
 
45
- handleCallback();
46
- }, [code, state, provider, auth, router]);
29
+ if (oauthSuccess === 'true' && token) {
30
+ auth.login(token);
31
+ router.push('/');
32
+ } else {
33
+ setError('Missing authentication parameters. Please try again.');
34
+ }
35
+ }, [oauthSuccess, token, oauthError, auth, router]);
47
36
 
48
37
  if (error) {
49
38
  return (
@@ -80,7 +80,7 @@ export function OAuthButtons({ className }: OAuthButtonsProps) {
80
80
  try {
81
81
  setRedirecting(provider);
82
82
  const client = getClient();
83
- const redirectUrl = window.location.origin + '/auth/callback?provider=' + provider;
83
+ const redirectUrl = window.location.origin + '/auth/callback';
84
84
  const result = await client.getOAuthAuthorizeUrl(provider, { redirectUrl });
85
85
  window.location.href = result.authorizationUrl;
86
86
  } catch (err) {