@edcalderon/auth 1.1.3 → 1.2.0
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/CHANGELOG.md +8 -0
- package/README.md +44 -5
- package/dist/providers/HybridNativeClient.js +14 -0
- package/dist/providers/HybridWebClient.js +14 -0
- package/dist/providers/SupabaseClient.js +16 -1
- package/dist/types.d.ts +8 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.2.0] - 2026-03-02
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- 🔗 Added agnostic Web3 support to the core `SignInOptions` (`options.provider === 'web3'`).
|
|
8
|
+
- 🔗 Upgraded `SupabaseClient` and `HybridClient` adapters to natively call Supabase's `signInWithWeb3` standard.
|
|
9
|
+
- 📝 Documented Wagmi and `@solana/wallet-adapter` implementation examples in README.
|
|
10
|
+
|
|
3
11
|
## [1.1.3] - 2026-03-02
|
|
4
12
|
|
|
5
13
|
### Docs
|
package/README.md
CHANGED
|
@@ -10,11 +10,13 @@ Swap between Supabase, Firebase, Hybrid, or any custom provider without changing
|
|
|
10
10
|
|
|
11
11
|
---
|
|
12
12
|
|
|
13
|
-
## 📋 Latest Changes (v1.
|
|
13
|
+
## 📋 Latest Changes (v1.2.0)
|
|
14
14
|
|
|
15
|
-
###
|
|
15
|
+
### Added
|
|
16
16
|
|
|
17
|
-
-
|
|
17
|
+
- 🔗 Added agnostic Web3 support to the core `SignInOptions` (`options.provider === 'web3'`).
|
|
18
|
+
- 🔗 Upgraded `SupabaseClient` and `HybridClient` adapters to natively call Supabase's `signInWithWeb3` standard.
|
|
19
|
+
- 📝 Documented Wagmi and `@solana/wallet-adapter` implementation examples in README.
|
|
18
20
|
|
|
19
21
|
For full version history, see [CHANGELOG.md](./CHANGELOG.md) and [GitHub releases](https://github.com/edcalderon/my-second-brain/releases)
|
|
20
22
|
|
|
@@ -114,7 +116,36 @@ export default function Dashboard() {
|
|
|
114
116
|
}
|
|
115
117
|
```
|
|
116
118
|
|
|
117
|
-
### 2.
|
|
119
|
+
### 2. Web3 Crypto Wallets (Wagmi / Solana)
|
|
120
|
+
|
|
121
|
+
Because the orchestration is provider-blind, you can easily pair it with libraries like `wagmi` or `@solana/wallet-adapter-react`.
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
"use client";
|
|
125
|
+
import { useAuth } from "@edcalderon/auth";
|
|
126
|
+
import { useWallet } from "@solana/wallet-adapter-react";
|
|
127
|
+
|
|
128
|
+
export function SolanaLogin() {
|
|
129
|
+
const { signIn } = useAuth();
|
|
130
|
+
const wallet = useWallet();
|
|
131
|
+
|
|
132
|
+
const handleWeb3SignIn = () => {
|
|
133
|
+
if (!wallet.connected) return;
|
|
134
|
+
|
|
135
|
+
signIn({
|
|
136
|
+
provider: "web3",
|
|
137
|
+
web3: {
|
|
138
|
+
chain: "solana",
|
|
139
|
+
wallet: wallet.wallet?.adapter // Pass the raw wallet adapter
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return <button onClick={handleWeb3SignIn}>Sign In with Solana</button>;
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### 3. Provider Top-Level App Injectors
|
|
118
149
|
|
|
119
150
|
Wire the environment appropriate class up at your app root.
|
|
120
151
|
|
|
@@ -208,10 +239,18 @@ The core strength of `@edcalderon/auth` is that **any authentication service** c
|
|
|
208
239
|
type AuthRuntime = "web" | "native" | "server";
|
|
209
240
|
type OAuthFlow = "popup" | "redirect" | "native";
|
|
210
241
|
|
|
242
|
+
export interface Web3SignInOptions {
|
|
243
|
+
chain: "ethereum" | "solana" | "bitcoin";
|
|
244
|
+
wallet?: any;
|
|
245
|
+
message?: string;
|
|
246
|
+
signature?: string;
|
|
247
|
+
}
|
|
248
|
+
|
|
211
249
|
export interface SignInOptions {
|
|
212
|
-
provider?: "google" | "apple" | "github" | string;
|
|
250
|
+
provider?: "google" | "apple" | "github" | "web3" | string;
|
|
213
251
|
flow?: OAuthFlow;
|
|
214
252
|
redirectUri?: string;
|
|
253
|
+
web3?: Web3SignInOptions;
|
|
215
254
|
}
|
|
216
255
|
|
|
217
256
|
export interface AuthClient {
|
|
@@ -48,6 +48,20 @@ export class HybridNativeClient {
|
|
|
48
48
|
}
|
|
49
49
|
async signIn(options) {
|
|
50
50
|
const provider = options.provider || "google";
|
|
51
|
+
if (provider === "web3") {
|
|
52
|
+
if (!options.web3)
|
|
53
|
+
throw new Error("CONFIG_ERROR: options.web3 is required when provider is 'web3'");
|
|
54
|
+
const { error } = await this.supabase.auth.signInWithWeb3({
|
|
55
|
+
// @ts-ignore - Supabase TS types might be strict (e.g. 0x${string}), bypass for agnostic adapter
|
|
56
|
+
chain: options.web3.chain,
|
|
57
|
+
message: options.web3.message,
|
|
58
|
+
signature: options.web3.signature,
|
|
59
|
+
wallet: options.web3.wallet,
|
|
60
|
+
});
|
|
61
|
+
if (error)
|
|
62
|
+
throw new Error(`PROVIDER_ERROR: ${error.message}`);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
51
65
|
// Pure Supabase route
|
|
52
66
|
if (!this.firebaseAuth || !this.methods || !this.oauthHandlers[provider]) {
|
|
53
67
|
console.warn(`Native OAuth via Hybrid fallback for '${provider}' targeting Supabase purely`);
|
|
@@ -48,6 +48,20 @@ export class HybridWebClient {
|
|
|
48
48
|
}
|
|
49
49
|
async signIn(options) {
|
|
50
50
|
const provider = options.provider || "google";
|
|
51
|
+
if (provider === "web3") {
|
|
52
|
+
if (!options.web3)
|
|
53
|
+
throw new Error("CONFIG_ERROR: options.web3 is required when provider is 'web3'");
|
|
54
|
+
const { error } = await this.supabase.auth.signInWithWeb3({
|
|
55
|
+
// @ts-ignore - Supabase TS types might be strict (e.g. 0x${string}), bypass for agnostic adapter
|
|
56
|
+
chain: options.web3.chain,
|
|
57
|
+
message: options.web3.message,
|
|
58
|
+
signature: options.web3.signature,
|
|
59
|
+
wallet: options.web3.wallet,
|
|
60
|
+
});
|
|
61
|
+
if (error)
|
|
62
|
+
throw new Error(`PROVIDER_ERROR: ${error.message}`);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
51
65
|
if (!this.firebaseAuth || !this.methods || !this.googleProvider) {
|
|
52
66
|
console.warn("Firebase not configured on Hybrid fallback, using Supabase pure auth");
|
|
53
67
|
const { error } = await this.supabase.auth.signInWithOAuth({
|
|
@@ -50,7 +50,22 @@ export class SupabaseClient {
|
|
|
50
50
|
}
|
|
51
51
|
async signIn(options) {
|
|
52
52
|
if (!options.provider) {
|
|
53
|
-
throw new Error("CONFIG_ERROR: options.provider is required for Supabase OAuth");
|
|
53
|
+
throw new Error("CONFIG_ERROR: options.provider is required for Supabase OAuth or Web3");
|
|
54
|
+
}
|
|
55
|
+
if (options.provider === "web3") {
|
|
56
|
+
if (!options.web3) {
|
|
57
|
+
throw new Error("CONFIG_ERROR: options.web3 is required when provider is 'web3'");
|
|
58
|
+
}
|
|
59
|
+
const { error } = await this.supabase.auth.signInWithWeb3({
|
|
60
|
+
// @ts-ignore - Supabase TS types might be strict (e.g. 0x${string}), bypass for agnostic adapter
|
|
61
|
+
chain: options.web3.chain,
|
|
62
|
+
message: options.web3.message,
|
|
63
|
+
signature: options.web3.signature,
|
|
64
|
+
wallet: options.web3.wallet,
|
|
65
|
+
});
|
|
66
|
+
if (error)
|
|
67
|
+
throw new Error(`PROVIDER_ERROR: ${error.message}`);
|
|
68
|
+
return;
|
|
54
69
|
}
|
|
55
70
|
let redirectTo = options.redirectUri;
|
|
56
71
|
// Apply web assumption ONLY if strictly web
|
package/dist/types.d.ts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
export type AuthRuntime = "web" | "native" | "server";
|
|
2
2
|
export type OAuthFlow = "popup" | "redirect" | "native";
|
|
3
|
+
export interface Web3SignInOptions {
|
|
4
|
+
chain: "ethereum" | "solana" | "bitcoin";
|
|
5
|
+
wallet?: any;
|
|
6
|
+
message?: string;
|
|
7
|
+
signature?: string;
|
|
8
|
+
}
|
|
3
9
|
export interface SignInOptions {
|
|
4
|
-
provider?: "google" | "apple" | "github" | string;
|
|
10
|
+
provider?: "google" | "apple" | "github" | "web3" | string;
|
|
5
11
|
flow?: OAuthFlow;
|
|
6
12
|
redirectUri?: string;
|
|
13
|
+
web3?: Web3SignInOptions;
|
|
7
14
|
}
|
|
8
15
|
export type AuthErrorCode = "CONFIG_ERROR" | "UNSUPPORTED_FLOW" | "NETWORK_ERROR" | "PROVIDER_ERROR" | "SESSION_ERROR";
|
|
9
16
|
export interface User {
|