@quantabit/oauth-sdk 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 QuantaBit Team
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 ADDED
@@ -0,0 +1,143 @@
1
+ # @quantabit/oauth-sdk
2
+
3
+ > QuantaBit OAuth SDK - Third-party login integration, social account binding, and WalletConnect
4
+
5
+ ## ✨ Features
6
+
7
+ - 🔐 **Social Login** - Google, GitHub, Discord, Twitter, WeChat
8
+ - 🔗 **Account Linking** - Bind/unbind social accounts to your DID identity
9
+ - 🎨 **Ready-to-Use UI** - Pre-built OAuth buttons, modals, and callback pages
10
+ - 🔄 **OAuth Flow** - Complete authorization code flow with PKCE support
11
+ - 🌍 **Multi-Language** - Built-in Chinese/English translations
12
+
13
+ ## 📦 Installation
14
+
15
+ ```bash
16
+ npm install @quantabit/oauth-sdk
17
+ # or
18
+ yarn add @quantabit/oauth-sdk
19
+ ```
20
+
21
+ ## 🚀 Quick Start
22
+
23
+ ### 1. Using Components
24
+
25
+ ```jsx
26
+ import {
27
+ OAuthButtonGroup,
28
+ OAuthLoginModal,
29
+ OAuthCallbackPage,
30
+ LinkedAccountsList,
31
+ } from '@quantabit/oauth-sdk';
32
+
33
+ // OAuth button group (Google, GitHub, Discord, etc.)
34
+ <OAuthButtonGroup
35
+ providers={['google', 'github', 'discord', 'twitter']}
36
+ onSuccess={(result) => console.log('Logged in:', result)}
37
+ />
38
+
39
+ // OAuth login modal
40
+ <OAuthLoginModal
41
+ isOpen={showLogin}
42
+ onClose={() => setShowLogin(false)}
43
+ onSuccess={(result) => handleLogin(result)}
44
+ />
45
+
46
+ // OAuth callback page (place at /oauth/callback route)
47
+ <OAuthCallbackPage
48
+ onSuccess={(result) => navigate('/dashboard')}
49
+ onError={(error) => console.error(error)}
50
+ />
51
+
52
+ // Linked accounts management
53
+ <LinkedAccountsList
54
+ onUnlink={(account) => handleUnlink(account)}
55
+ onLink={(provider) => handleLink(provider)}
56
+ />
57
+ ```
58
+
59
+ ### 2. Using Hooks
60
+
61
+ ```jsx
62
+ import {
63
+ useOAuthLogin,
64
+ useOAuthCallback,
65
+ useLinkedAccounts,
66
+ useOAuthState,
67
+ useOAuthProviders,
68
+ } from "@quantabit/oauth-sdk";
69
+
70
+ function MyComponent() {
71
+ const { login, loading } = useOAuthLogin();
72
+ const { handleCallback } = useOAuthCallback();
73
+ const { accounts, linkAccount, unlinkAccount } = useLinkedAccounts();
74
+ const { isAuthenticated, user } = useOAuthState();
75
+ const { providers, getAuthUrl } = useOAuthProviders();
76
+
77
+ return <button onClick={() => login("google")}>Sign in with Google</button>;
78
+ }
79
+ ```
80
+
81
+ ### 3. API Client
82
+
83
+ ```javascript
84
+ import { oauthApi } from "@quantabit/oauth-sdk";
85
+
86
+ // Get authorization URL
87
+ const url = await oauthApi.getAuthUrl("google", {
88
+ redirectUri: window.location.origin + "/oauth/callback",
89
+ });
90
+
91
+ // Handle callback
92
+ const result = await oauthApi.handleCallback(callbackParams);
93
+
94
+ // Check auth status
95
+ const status = await oauthApi.checkAuth();
96
+
97
+ // Get linked accounts
98
+ const accounts = await oauthApi.getLinkedAccounts();
99
+ ```
100
+
101
+ ## 📚 Components
102
+
103
+ | Component | Description |
104
+ | -------------------- | ------------------------------------------------ |
105
+ | `OAuthButton` | Single OAuth provider button |
106
+ | `OAuthButtonGroup` | Multiple OAuth buttons in a row |
107
+ | `OAuthIconGroup` | Compact icon-only OAuth buttons |
108
+ | `OAuthCallbackPage` | Callback handling page with loading/error states |
109
+ | `LinkedAccountsList` | Linked social accounts management |
110
+ | `OAuthLoginModal` | Modal with all OAuth providers |
111
+
112
+ ## 📖 Type Definitions
113
+
114
+ ```javascript
115
+ import { OAuthProvider, OAuthScope } from "@quantabit/oauth-sdk";
116
+
117
+ // Supported providers
118
+ OAuthProvider.GOOGLE;
119
+ OAuthProvider.GITHUB;
120
+ OAuthProvider.DISCORD;
121
+ OAuthProvider.TWITTER;
122
+ OAuthProvider.WECHAT;
123
+
124
+ // OAuth scopes
125
+ OAuthScope.PROFILE; // Basic profile
126
+ OAuthScope.EMAIL; // Email access
127
+ OAuthScope.OPENID; // OpenID Connect
128
+ ```
129
+
130
+ ## 📄 License
131
+
132
+ MIT License
133
+
134
+
135
+
136
+ ---
137
+
138
+ ## 🌐 Brand & Links
139
+ - Official Mainnet: [QuantaBit Chain](https://qbitchain.io/)
140
+ - Developer Platform: [Developer Platform](https://developer.quantabit.io/)
141
+ - Open Platform: [Open Platform](https://open.quantabit.io/)
142
+ - Payment Platform: [Pay Platform](https://pay.qbitwallet.io/)
143
+ - Feedback: [Feedback](https://xwin.live/qbit)