@solvapay/react-supabase 1.0.0-preview.18 → 1.0.0-preview.19

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.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 SolvaPay Inc.
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
@@ -17,20 +17,16 @@ yarn add @solvapay/react-supabase @supabase/supabase-js
17
17
  Use the Supabase adapter with `SolvaPayProvider`:
18
18
 
19
19
  ```tsx
20
- import { SolvaPayProvider } from '@solvapay/react';
21
- import { createSupabaseAuthAdapter } from '@solvapay/react-supabase';
20
+ import { SolvaPayProvider } from '@solvapay/react'
21
+ import { createSupabaseAuthAdapter } from '@solvapay/react-supabase'
22
22
 
23
23
  const adapter = createSupabaseAuthAdapter({
24
24
  supabaseUrl: process.env.NEXT_PUBLIC_SUPABASE_URL!,
25
25
  supabaseAnonKey: process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
26
- });
26
+ })
27
27
 
28
28
  export default function RootLayout({ children }) {
29
- return (
30
- <SolvaPayProvider config={{ auth: { adapter } }}>
31
- {children}
32
- </SolvaPayProvider>
33
- );
29
+ return <SolvaPayProvider config={{ auth: { adapter } }}>{children}</SolvaPayProvider>
34
30
  }
35
31
  ```
36
32
 
@@ -41,6 +37,7 @@ export default function RootLayout({ children }) {
41
37
  Creates a Supabase auth adapter instance.
42
38
 
43
39
  **Parameters:**
40
+
44
41
  - `config.supabaseUrl` (string, required) - Your Supabase project URL
45
42
  - `config.supabaseAnonKey` (string, required) - Your Supabase anonymous/public key
46
43
 
@@ -49,6 +46,7 @@ Creates a Supabase auth adapter instance.
49
46
  ## How It Works
50
47
 
51
48
  The adapter:
49
+
52
50
  1. Creates a Supabase client using your credentials
53
51
  2. Gets the current session using `supabase.auth.getSession()`
54
52
  3. Extracts the access token and user ID from the session
@@ -59,26 +57,24 @@ The adapter handles errors gracefully and never throws - it returns `null` when
59
57
  ## Example: Full Setup
60
58
 
61
59
  ```tsx
62
- 'use client';
60
+ 'use client'
63
61
 
64
- import { SolvaPayProvider } from '@solvapay/react';
65
- import { createSupabaseAuthAdapter } from '@solvapay/react-supabase';
62
+ import { SolvaPayProvider } from '@solvapay/react'
63
+ import { createSupabaseAuthAdapter } from '@solvapay/react-supabase'
66
64
 
67
65
  export default function RootLayout({ children }) {
68
66
  const adapter = createSupabaseAuthAdapter({
69
67
  supabaseUrl: process.env.NEXT_PUBLIC_SUPABASE_URL!,
70
68
  supabaseAnonKey: process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
71
- });
69
+ })
72
70
 
73
71
  return (
74
72
  <html>
75
73
  <body>
76
- <SolvaPayProvider config={{ auth: { adapter } }}>
77
- {children}
78
- </SolvaPayProvider>
74
+ <SolvaPayProvider config={{ auth: { adapter } }}>{children}</SolvaPayProvider>
79
75
  </body>
80
76
  </html>
81
- );
77
+ )
82
78
  }
83
79
  ```
84
80
 
@@ -100,4 +96,3 @@ const myAuthAdapter: AuthAdapter = {
100
96
 
101
97
  <SolvaPayProvider config={{ auth: { adapter: myAuthAdapter } }}>
102
98
  ```
103
-
package/dist/index.cjs CHANGED
@@ -37,9 +37,7 @@ module.exports = __toCommonJS(index_exports);
37
37
  // src/supabase-adapter.ts
38
38
  function createSupabaseAuthAdapter(config) {
39
39
  if (!config.supabaseUrl || !config.supabaseAnonKey) {
40
- throw new Error(
41
- "SupabaseAuthAdapter requires both supabaseUrl and supabaseAnonKey"
42
- );
40
+ throw new Error("SupabaseAuthAdapter requires both supabaseUrl and supabaseAnonKey");
43
41
  }
44
42
  let supabaseClient = null;
45
43
  let clientPromise = null;
@@ -53,9 +51,10 @@ function createSupabaseAuthAdapter(config) {
53
51
  clientPromise = (async () => {
54
52
  try {
55
53
  const { createClient } = await import("@supabase/supabase-js");
56
- supabaseClient = createClient(config.supabaseUrl, config.supabaseAnonKey);
57
- return supabaseClient;
58
- } catch (error) {
54
+ const client = createClient(config.supabaseUrl, config.supabaseAnonKey);
55
+ supabaseClient = client;
56
+ return client;
57
+ } catch {
59
58
  clientPromise = null;
60
59
  throw new Error(
61
60
  "Failed to load @supabase/supabase-js. Make sure it is installed: npm install @supabase/supabase-js"
@@ -69,7 +68,9 @@ function createSupabaseAuthAdapter(config) {
69
68
  if (typeof window === "undefined") return null;
70
69
  try {
71
70
  const supabase = await getSupabaseClient();
72
- const { data: { session } } = await supabase.auth.getSession();
71
+ const {
72
+ data: { session }
73
+ } = await supabase.auth.getSession();
73
74
  return session?.access_token || null;
74
75
  } catch (error) {
75
76
  console.warn("[SupabaseAuthAdapter] Failed to get token:", error);
@@ -80,7 +81,9 @@ function createSupabaseAuthAdapter(config) {
80
81
  if (typeof window === "undefined") return null;
81
82
  try {
82
83
  const supabase = await getSupabaseClient();
83
- const { data: { session } } = await supabase.auth.getSession();
84
+ const {
85
+ data: { session }
86
+ } = await supabase.auth.getSession();
84
87
  return session?.user?.id || null;
85
88
  } catch (error) {
86
89
  console.warn("[SupabaseAuthAdapter] Failed to get user ID:", error);
package/dist/index.d.cts CHANGED
@@ -17,31 +17,6 @@ interface SupabaseAuthAdapterConfig {
17
17
  */
18
18
  supabaseAnonKey: string;
19
19
  }
20
- /**
21
- * Create a Supabase auth adapter for SolvaPayProvider
22
- *
23
- * This adapter uses Supabase's client-side auth to get tokens and user IDs.
24
- * It dynamically imports @supabase/supabase-js to avoid adding it as a dependency
25
- * if Supabase isn't being used.
26
- *
27
- * @param config - Supabase configuration
28
- * @returns AuthAdapter instance
29
- *
30
- * @example
31
- * ```tsx
32
- * import { createSupabaseAuthAdapter } from '@solvapay/react-supabase';
33
- * import { SolvaPayProvider } from '@solvapay/react';
34
- *
35
- * const adapter = createSupabaseAuthAdapter({
36
- * supabaseUrl: process.env.NEXT_PUBLIC_SUPABASE_URL!,
37
- * supabaseAnonKey: process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
38
- * });
39
- *
40
- * <SolvaPayProvider config={{ auth: { adapter } }}>
41
- * {children}
42
- * </SolvaPayProvider>
43
- * ```
44
- */
45
20
  declare function createSupabaseAuthAdapter(config: SupabaseAuthAdapterConfig): AuthAdapter;
46
21
 
47
22
  export { type SupabaseAuthAdapterConfig, createSupabaseAuthAdapter };
package/dist/index.d.ts CHANGED
@@ -17,31 +17,6 @@ interface SupabaseAuthAdapterConfig {
17
17
  */
18
18
  supabaseAnonKey: string;
19
19
  }
20
- /**
21
- * Create a Supabase auth adapter for SolvaPayProvider
22
- *
23
- * This adapter uses Supabase's client-side auth to get tokens and user IDs.
24
- * It dynamically imports @supabase/supabase-js to avoid adding it as a dependency
25
- * if Supabase isn't being used.
26
- *
27
- * @param config - Supabase configuration
28
- * @returns AuthAdapter instance
29
- *
30
- * @example
31
- * ```tsx
32
- * import { createSupabaseAuthAdapter } from '@solvapay/react-supabase';
33
- * import { SolvaPayProvider } from '@solvapay/react';
34
- *
35
- * const adapter = createSupabaseAuthAdapter({
36
- * supabaseUrl: process.env.NEXT_PUBLIC_SUPABASE_URL!,
37
- * supabaseAnonKey: process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
38
- * });
39
- *
40
- * <SolvaPayProvider config={{ auth: { adapter } }}>
41
- * {children}
42
- * </SolvaPayProvider>
43
- * ```
44
- */
45
20
  declare function createSupabaseAuthAdapter(config: SupabaseAuthAdapterConfig): AuthAdapter;
46
21
 
47
22
  export { type SupabaseAuthAdapterConfig, createSupabaseAuthAdapter };
package/dist/index.js CHANGED
@@ -1,9 +1,7 @@
1
1
  // src/supabase-adapter.ts
2
2
  function createSupabaseAuthAdapter(config) {
3
3
  if (!config.supabaseUrl || !config.supabaseAnonKey) {
4
- throw new Error(
5
- "SupabaseAuthAdapter requires both supabaseUrl and supabaseAnonKey"
6
- );
4
+ throw new Error("SupabaseAuthAdapter requires both supabaseUrl and supabaseAnonKey");
7
5
  }
8
6
  let supabaseClient = null;
9
7
  let clientPromise = null;
@@ -17,9 +15,10 @@ function createSupabaseAuthAdapter(config) {
17
15
  clientPromise = (async () => {
18
16
  try {
19
17
  const { createClient } = await import("@supabase/supabase-js");
20
- supabaseClient = createClient(config.supabaseUrl, config.supabaseAnonKey);
21
- return supabaseClient;
22
- } catch (error) {
18
+ const client = createClient(config.supabaseUrl, config.supabaseAnonKey);
19
+ supabaseClient = client;
20
+ return client;
21
+ } catch {
23
22
  clientPromise = null;
24
23
  throw new Error(
25
24
  "Failed to load @supabase/supabase-js. Make sure it is installed: npm install @supabase/supabase-js"
@@ -33,7 +32,9 @@ function createSupabaseAuthAdapter(config) {
33
32
  if (typeof window === "undefined") return null;
34
33
  try {
35
34
  const supabase = await getSupabaseClient();
36
- const { data: { session } } = await supabase.auth.getSession();
35
+ const {
36
+ data: { session }
37
+ } = await supabase.auth.getSession();
37
38
  return session?.access_token || null;
38
39
  } catch (error) {
39
40
  console.warn("[SupabaseAuthAdapter] Failed to get token:", error);
@@ -44,7 +45,9 @@ function createSupabaseAuthAdapter(config) {
44
45
  if (typeof window === "undefined") return null;
45
46
  try {
46
47
  const supabase = await getSupabaseClient();
47
- const { data: { session } } = await supabase.auth.getSession();
48
+ const {
49
+ data: { session }
50
+ } = await supabase.auth.getSession();
48
51
  return session?.user?.id || null;
49
52
  } catch (error) {
50
53
  console.warn("[SupabaseAuthAdapter] Failed to get user ID:", error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solvapay/react-supabase",
3
- "version": "1.0.0-preview.18",
3
+ "version": "1.0.0-preview.19",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -22,16 +22,18 @@
22
22
  "@supabase/supabase-js": "^2.0.0"
23
23
  },
24
24
  "devDependencies": {
25
- "@types/react": "^18.2.74",
25
+ "@types/react": ">=18.2.0",
26
26
  "typescript": "^5.5.4",
27
27
  "tsup": "^8.0.0",
28
28
  "vitest": "^2.0.5",
29
- "@solvapay/react": "1.0.0-preview.18"
29
+ "@solvapay/react": "1.0.0-preview.19"
30
30
  },
31
31
  "scripts": {
32
32
  "build": "tsup src/index.ts --format esm,cjs --dts --tsconfig tsconfig.build.json",
33
33
  "test": "vitest run || exit 0",
34
34
  "test:unit": "vitest run || exit 0",
35
- "test:watch": "vitest"
35
+ "test:watch": "vitest",
36
+ "lint": "eslint src --config ../../eslint.config.react.mjs",
37
+ "lint:fix": "eslint src --config ../../eslint.config.react.mjs --fix"
36
38
  }
37
39
  }