binoauth 0.0.11 → 0.0.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/README.md +359 -165
- package/dist/core/src/admin/client.d.ts +203 -0
- package/dist/core/src/admin/client.d.ts.map +1 -0
- package/dist/core/src/admin/client.js +391 -0
- package/dist/core/src/admin/client.js.map +1 -0
- package/dist/core/src/admin/index.d.ts +6 -0
- package/dist/core/src/admin/index.d.ts.map +1 -0
- package/dist/core/src/admin/index.js +5 -0
- package/dist/core/src/admin/index.js.map +1 -0
- package/dist/core/src/admin/types.d.ts +412 -0
- package/dist/core/src/admin/types.d.ts.map +1 -0
- package/dist/core/src/admin/types.js +5 -0
- package/dist/core/src/admin/types.js.map +1 -0
- package/dist/core/src/auth/client.d.ts +330 -0
- package/dist/core/src/auth/client.d.ts.map +1 -0
- package/dist/core/src/auth/client.js +408 -0
- package/dist/core/src/auth/client.js.map +1 -0
- package/dist/core/src/auth/error.d.ts +113 -0
- package/dist/core/src/auth/error.d.ts.map +1 -0
- package/dist/core/src/auth/error.js +257 -0
- package/dist/core/src/auth/error.js.map +1 -0
- package/dist/core/src/auth/flows/base-flow.d.ts +98 -0
- package/dist/core/src/auth/flows/base-flow.d.ts.map +1 -0
- package/dist/core/src/auth/flows/base-flow.js +182 -0
- package/dist/core/src/auth/flows/base-flow.js.map +1 -0
- package/dist/core/src/auth/flows/magic-link.d.ts +175 -0
- package/dist/core/src/auth/flows/magic-link.d.ts.map +1 -0
- package/dist/core/src/auth/flows/magic-link.js +228 -0
- package/dist/core/src/auth/flows/magic-link.js.map +1 -0
- package/dist/core/src/auth/flows/mfa.d.ts +81 -0
- package/dist/core/src/auth/flows/mfa.d.ts.map +1 -0
- package/dist/core/src/auth/flows/mfa.js +103 -0
- package/dist/core/src/auth/flows/mfa.js.map +1 -0
- package/dist/core/src/auth/flows/otp.d.ts +172 -0
- package/dist/core/src/auth/flows/otp.d.ts.map +1 -0
- package/dist/core/src/auth/flows/otp.js +222 -0
- package/dist/core/src/auth/flows/otp.js.map +1 -0
- package/dist/core/src/auth/flows/password.d.ts +242 -0
- package/dist/core/src/auth/flows/password.d.ts.map +1 -0
- package/dist/core/src/auth/flows/password.js +344 -0
- package/dist/core/src/auth/flows/password.js.map +1 -0
- package/dist/core/src/auth/flows/social.d.ts +209 -0
- package/dist/core/src/auth/flows/social.d.ts.map +1 -0
- package/dist/core/src/auth/flows/social.js +284 -0
- package/dist/core/src/auth/flows/social.js.map +1 -0
- package/dist/core/src/auth/index.d.ts +19 -0
- package/dist/core/src/auth/index.d.ts.map +1 -0
- package/dist/core/src/auth/index.js +32 -0
- package/dist/core/src/auth/index.js.map +1 -0
- package/dist/core/src/auth/types.d.ts +151 -0
- package/dist/core/src/auth/types.d.ts.map +1 -0
- package/dist/core/src/auth/types.js +7 -0
- package/dist/core/src/auth/types.js.map +1 -0
- package/dist/core/src/index.d.ts +53 -49
- package/dist/core/src/index.d.ts.map +1 -1
- package/dist/core/src/index.js +61 -343
- package/dist/core/src/index.js.map +1 -1
- package/dist/core/src/oauth/client.d.ts +322 -0
- package/dist/core/src/oauth/client.d.ts.map +1 -0
- package/dist/core/src/oauth/client.js +491 -0
- package/dist/core/src/oauth/client.js.map +1 -0
- package/dist/core/src/oauth/error.d.ts +18 -0
- package/dist/core/src/oauth/error.d.ts.map +1 -0
- package/dist/core/src/oauth/error.js +24 -0
- package/dist/core/src/oauth/error.js.map +1 -0
- package/dist/core/src/oauth/flows/authorization-code.d.ts +122 -0
- package/dist/core/src/oauth/flows/authorization-code.d.ts.map +1 -0
- package/dist/core/src/oauth/flows/authorization-code.js +278 -0
- package/dist/core/src/oauth/flows/authorization-code.js.map +1 -0
- package/dist/core/src/oauth/flows/base-flow.d.ts +17 -0
- package/dist/core/src/oauth/flows/base-flow.d.ts.map +1 -0
- package/dist/core/src/oauth/flows/base-flow.js +107 -0
- package/dist/core/src/oauth/flows/base-flow.js.map +1 -0
- package/dist/core/src/oauth/flows/client-credentials.d.ts +72 -0
- package/dist/core/src/oauth/flows/client-credentials.d.ts.map +1 -0
- package/dist/core/src/oauth/flows/client-credentials.js +100 -0
- package/dist/core/src/oauth/flows/client-credentials.js.map +1 -0
- package/dist/core/src/oauth/flows/device-code.d.ts +108 -0
- package/dist/core/src/oauth/flows/device-code.d.ts.map +1 -0
- package/dist/core/src/oauth/flows/device-code.js +193 -0
- package/dist/core/src/oauth/flows/device-code.js.map +1 -0
- package/dist/core/src/oauth/flows/refresh-token.d.ts +59 -0
- package/dist/core/src/oauth/flows/refresh-token.d.ts.map +1 -0
- package/dist/core/src/oauth/flows/refresh-token.js +105 -0
- package/dist/core/src/oauth/flows/refresh-token.js.map +1 -0
- package/dist/core/src/oauth/index.d.ts +12 -0
- package/dist/core/src/oauth/index.d.ts.map +1 -0
- package/dist/core/src/oauth/index.js +11 -0
- package/dist/core/src/oauth/index.js.map +1 -0
- package/dist/core/src/oauth/storage/encryption.d.ts +12 -0
- package/dist/core/src/oauth/storage/encryption.d.ts.map +1 -0
- package/dist/core/src/oauth/storage/encryption.js +76 -0
- package/dist/core/src/oauth/storage/encryption.js.map +1 -0
- package/dist/core/src/oauth/storage/index.d.ts +201 -0
- package/dist/core/src/oauth/storage/index.d.ts.map +1 -0
- package/dist/core/src/oauth/storage/index.js +322 -0
- package/dist/core/src/oauth/storage/index.js.map +1 -0
- package/dist/core/src/oauth/storage/strategies.d.ts +34 -0
- package/dist/core/src/oauth/storage/strategies.d.ts.map +1 -0
- package/dist/core/src/oauth/storage/strategies.js +100 -0
- package/dist/core/src/oauth/storage/strategies.js.map +1 -0
- package/dist/core/src/oauth/types.d.ts +261 -0
- package/dist/core/src/oauth/types.d.ts.map +1 -0
- package/dist/core/src/oauth/types.js +39 -0
- package/dist/core/src/oauth/types.js.map +1 -0
- package/dist/core/src/oauth/utils.d.ts +56 -0
- package/dist/core/src/oauth/utils.d.ts.map +1 -0
- package/dist/core/src/oauth/utils.js +140 -0
- package/dist/core/src/oauth/utils.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
@@ -0,0 +1,284 @@
|
|
1
|
+
/**
|
2
|
+
* Social authentication flow
|
3
|
+
*
|
4
|
+
* Handles OAuth authentication with social providers using actual tenant-sdk ExternalAuthApi.
|
5
|
+
*/
|
6
|
+
import { AuthError, AuthErrorCode } from "../error";
|
7
|
+
import { BaseAuthFlow } from "./base-flow";
|
8
|
+
/**
|
9
|
+
* Social authentication flow
|
10
|
+
*
|
11
|
+
* Provides OAuth authentication with social providers using actual tenant-sdk APIs.
|
12
|
+
* Uses ExternalAuthApi.getActiveProvidersApiV1AuthExternalActiveProvidersGet and
|
13
|
+
* ExternalAuthApi.socialCallbackApiV1AuthExternalCallbackProviderGet.
|
14
|
+
*
|
15
|
+
* @example
|
16
|
+
* ```typescript
|
17
|
+
* const socialFlow = new SocialFlow(config);
|
18
|
+
*
|
19
|
+
* // Get available providers and their auth URLs
|
20
|
+
* const providers = await socialFlow.getActiveProviders('https://myapp.com/dashboard');
|
21
|
+
* const googleProvider = providers.find(p => p.provider === 'google');
|
22
|
+
*
|
23
|
+
* // Redirect user to Google
|
24
|
+
* if (googleProvider) {
|
25
|
+
* window.location.href = googleProvider.authUrl;
|
26
|
+
* }
|
27
|
+
*
|
28
|
+
* // Handle callback after user returns from Google
|
29
|
+
* const urlParams = new URLSearchParams(window.location.search);
|
30
|
+
* const code = urlParams.get('code');
|
31
|
+
* const state = urlParams.get('state');
|
32
|
+
*
|
33
|
+
* if (code && state) {
|
34
|
+
* const result = await socialFlow.handleCallback('google', code, state);
|
35
|
+
* if (result.success) {
|
36
|
+
* console.log('Social login successful:', result.user);
|
37
|
+
* }
|
38
|
+
* }
|
39
|
+
* ```
|
40
|
+
*/
|
41
|
+
export class SocialFlow extends BaseAuthFlow {
|
42
|
+
constructor(config) {
|
43
|
+
super(config);
|
44
|
+
}
|
45
|
+
/**
|
46
|
+
* Gets active social providers and their authorization URLs using tenant-sdk ExternalAuthApi.getActiveProvidersApiV1AuthExternalActiveProvidersGet
|
47
|
+
*
|
48
|
+
* @param returnTo - Final destination URL after successful authentication
|
49
|
+
* @param redirectUri - Optional redirect path (relative to tenant domain)
|
50
|
+
* @returns Promise resolving to array of active providers with auth URLs
|
51
|
+
*
|
52
|
+
* @example
|
53
|
+
* ```typescript
|
54
|
+
* // Get all active providers with auth URLs
|
55
|
+
* const providers = await socialFlow.getActiveProviders('https://myapp.com/dashboard');
|
56
|
+
*
|
57
|
+
* providers.forEach(provider => {
|
58
|
+
* console.log(`${provider.name}: ${provider.authUrl}`);
|
59
|
+
* // Create login button that redirects to provider.authUrl
|
60
|
+
* });
|
61
|
+
*
|
62
|
+
* // Find specific provider
|
63
|
+
* const googleProvider = providers.find(p => p.provider === 'google');
|
64
|
+
* if (googleProvider) {
|
65
|
+
* window.location.href = googleProvider.authUrl;
|
66
|
+
* }
|
67
|
+
* ```
|
68
|
+
*
|
69
|
+
* @throws {AuthError} When fetching active providers fails
|
70
|
+
*/
|
71
|
+
async getActiveProviders(returnTo, redirectUri) {
|
72
|
+
if (!returnTo) {
|
73
|
+
throw new AuthError(AuthErrorCode.MISSING_REQUIRED_FIELD, 'returnTo URL is required');
|
74
|
+
}
|
75
|
+
return this.safeApiCall(async () => {
|
76
|
+
// Use the actual tenant-sdk ExternalAuthApi.getActiveProvidersApiV1AuthExternalActiveProvidersGet method
|
77
|
+
const response = await this.externalAuthApi.getActiveProvidersApiV1AuthExternalActiveProvidersGet({
|
78
|
+
returnTo,
|
79
|
+
redirectUri,
|
80
|
+
});
|
81
|
+
return response || [];
|
82
|
+
}, AuthErrorCode.SERVER_ERROR);
|
83
|
+
}
|
84
|
+
/**
|
85
|
+
* Gets authorization URL for a specific provider
|
86
|
+
*
|
87
|
+
* @param provider - Social provider name
|
88
|
+
* @param returnTo - Final destination URL after successful authentication
|
89
|
+
* @param redirectUri - Optional redirect path
|
90
|
+
* @returns Promise resolving to authorization URL
|
91
|
+
*
|
92
|
+
* @example
|
93
|
+
* ```typescript
|
94
|
+
* const googleUrl = await socialFlow.getAuthUrl('google', 'https://myapp.com/dashboard');
|
95
|
+
* window.location.href = googleUrl;
|
96
|
+
* ```
|
97
|
+
*/
|
98
|
+
async getAuthUrl(provider, returnTo, redirectUri) {
|
99
|
+
const providers = await this.getActiveProviders(returnTo, redirectUri);
|
100
|
+
const targetProvider = providers.find(p => p.provider === provider);
|
101
|
+
if (!targetProvider) {
|
102
|
+
throw new AuthError(AuthErrorCode.INVALID_CONFIG, `Provider ${provider} is not active or not supported`);
|
103
|
+
}
|
104
|
+
return targetProvider.authUrl;
|
105
|
+
}
|
106
|
+
/**
|
107
|
+
* Handles the OAuth callback from a social provider using tenant-sdk ExternalAuthApi.socialCallbackApiV1AuthExternalCallbackProviderGet
|
108
|
+
*
|
109
|
+
* @param provider - Social provider that initiated the callback
|
110
|
+
* @param code - Authorization code from provider
|
111
|
+
* @param state - State parameter for CSRF protection
|
112
|
+
* @param link - Optional flag to link account instead of login
|
113
|
+
* @returns Promise resolving to authentication result
|
114
|
+
*
|
115
|
+
* @example
|
116
|
+
* ```typescript
|
117
|
+
* // Extract parameters from callback URL
|
118
|
+
* const urlParams = new URLSearchParams(window.location.search);
|
119
|
+
* const code = urlParams.get('code');
|
120
|
+
* const state = urlParams.get('state');
|
121
|
+
*
|
122
|
+
* if (code && state) {
|
123
|
+
* try {
|
124
|
+
* const result = await socialFlow.handleCallback('google', code, state);
|
125
|
+
* if (result.success) {
|
126
|
+
* console.log('Welcome,', result.user.name);
|
127
|
+
* localStorage.setItem('accessToken', result.accessToken);
|
128
|
+
*
|
129
|
+
* // Redirect to dashboard
|
130
|
+
* window.location.href = '/dashboard';
|
131
|
+
* }
|
132
|
+
* } catch (error) {
|
133
|
+
* if (error.code === AuthErrorCode.INVALID_GRANT) {
|
134
|
+
* console.log('Social login was cancelled or failed');
|
135
|
+
* }
|
136
|
+
* }
|
137
|
+
* }
|
138
|
+
* ```
|
139
|
+
*
|
140
|
+
* @throws {AuthError} When callback handling fails
|
141
|
+
*/
|
142
|
+
async handleCallback(provider, code, state, link) {
|
143
|
+
if (!this.isSupportedProvider(provider)) {
|
144
|
+
throw new AuthError(AuthErrorCode.INVALID_CONFIG, `Unsupported social provider: ${provider}`);
|
145
|
+
}
|
146
|
+
if (!code) {
|
147
|
+
throw new AuthError(AuthErrorCode.MISSING_REQUIRED_FIELD, 'Authorization code is required');
|
148
|
+
}
|
149
|
+
if (!state) {
|
150
|
+
throw new AuthError(AuthErrorCode.MISSING_REQUIRED_FIELD, 'State parameter is required for CSRF protection');
|
151
|
+
}
|
152
|
+
return this.safeApiCall(async () => {
|
153
|
+
// Use the actual tenant-sdk ExternalAuthApi.socialCallbackApiV1AuthExternalCallbackProviderGet method
|
154
|
+
const response = await this.externalAuthApi.socialCallbackApiV1AuthExternalCallbackProviderGet({
|
155
|
+
provider: provider, // Cast to ProviderType from tenant-sdk
|
156
|
+
code,
|
157
|
+
state,
|
158
|
+
link,
|
159
|
+
});
|
160
|
+
return this.processAuthResponse(response);
|
161
|
+
}, AuthErrorCode.INVALID_GRANT);
|
162
|
+
}
|
163
|
+
/**
|
164
|
+
* Gets URL for linking a social account to an existing user account
|
165
|
+
*
|
166
|
+
* This uses the same flow as regular authentication but with the link flag set to true in the callback.
|
167
|
+
* The user must be authenticated (provide access token via Authorization header) to link accounts.
|
168
|
+
*
|
169
|
+
* @param provider - Social provider to link
|
170
|
+
* @param returnTo - Return URL after linking is complete
|
171
|
+
* @param redirectUri - Optional redirect path
|
172
|
+
* @returns Promise resolving to link URL
|
173
|
+
*
|
174
|
+
* @example
|
175
|
+
* ```typescript
|
176
|
+
* // Get URL to link Google account (user must be authenticated)
|
177
|
+
* const linkUrl = await socialFlow.getLinkUrl('google', 'https://myapp.com/settings');
|
178
|
+
*
|
179
|
+
* // Redirect user to complete linking
|
180
|
+
* window.location.href = linkUrl;
|
181
|
+
*
|
182
|
+
* // Handle callback with link=true flag
|
183
|
+
* const result = await socialFlow.handleCallback('google', code, state, true);
|
184
|
+
* ```
|
185
|
+
*
|
186
|
+
* @throws {AuthError} When getting link URL fails
|
187
|
+
*/
|
188
|
+
async getLinkUrl(provider, returnTo, redirectUri) {
|
189
|
+
// Get the auth URL for linking (same as regular auth, but will be used with link=true in callback)
|
190
|
+
return this.getAuthUrl(provider, returnTo, redirectUri);
|
191
|
+
}
|
192
|
+
/**
|
193
|
+
* Note: Account unlinking and linked account retrieval functionality is not available
|
194
|
+
* in the current tenant-sdk. The ExternalAuthApi only provides authentication and
|
195
|
+
* account linking capabilities.
|
196
|
+
*
|
197
|
+
* These features must be handled through other means (admin SDK or backend API).
|
198
|
+
*/
|
199
|
+
/**
|
200
|
+
* Gets all supported social providers using tenant-sdk ExternalAuthApi.getProvidersApiV1AuthExternalProvidersGet
|
201
|
+
*
|
202
|
+
* This returns all supported providers regardless of whether they are configured for the current tenant.
|
203
|
+
* Use getActiveProviders() to get only the providers that are actually configured and enabled.
|
204
|
+
*
|
205
|
+
* @returns Promise resolving to array of all supported providers
|
206
|
+
*
|
207
|
+
* @example
|
208
|
+
* ```typescript
|
209
|
+
* const allProviders = await socialFlow.getAllProviders();
|
210
|
+
* console.log('All supported providers:', allProviders);
|
211
|
+
*
|
212
|
+
* // Get only active/configured providers
|
213
|
+
* const activeProviders = await socialFlow.getActiveProviders('https://myapp.com/dashboard');
|
214
|
+
* console.log('Active providers:', activeProviders.map(p => p.provider));
|
215
|
+
* ```
|
216
|
+
*/
|
217
|
+
async getAllProviders() {
|
218
|
+
return this.safeApiCall(async () => {
|
219
|
+
// Use the actual tenant-sdk ExternalAuthApi.getProvidersApiV1AuthExternalProvidersGet method
|
220
|
+
return await this.externalAuthApi.getProvidersApiV1AuthExternalProvidersGet();
|
221
|
+
}, AuthErrorCode.SERVER_ERROR);
|
222
|
+
}
|
223
|
+
/**
|
224
|
+
* Checks if a social provider is supported based on tenant-sdk ProviderType
|
225
|
+
*
|
226
|
+
* @param provider - Provider to check
|
227
|
+
* @returns True if provider is supported, false otherwise
|
228
|
+
*
|
229
|
+
* @example
|
230
|
+
* ```typescript
|
231
|
+
* if (socialFlow.isSupportedProvider('google')) {
|
232
|
+
* // Show Google login button
|
233
|
+
* }
|
234
|
+
* ```
|
235
|
+
*/
|
236
|
+
isSupportedProvider(provider) {
|
237
|
+
// Based on actual tenant-sdk ProviderType enum
|
238
|
+
const supportedProviders = [
|
239
|
+
'google', 'github', 'microsoft', 'facebook', 'apple'
|
240
|
+
];
|
241
|
+
return supportedProviders.includes(provider);
|
242
|
+
}
|
243
|
+
/**
|
244
|
+
* Gets provider-specific information (display name, icon, etc.)
|
245
|
+
*
|
246
|
+
* Based on the actual tenant-sdk supported providers: google, github, microsoft, facebook, apple
|
247
|
+
*
|
248
|
+
* @param provider - Social provider
|
249
|
+
* @returns Provider information
|
250
|
+
*
|
251
|
+
* @example
|
252
|
+
* ```typescript
|
253
|
+
* const info = socialFlow.getProviderInfo('google');
|
254
|
+
* console.log(info.displayName); // "Google"
|
255
|
+
* console.log(info.primaryColor); // "#4285f4"
|
256
|
+
* ```
|
257
|
+
*/
|
258
|
+
getProviderInfo(provider) {
|
259
|
+
const providerInfo = {
|
260
|
+
google: {
|
261
|
+
displayName: 'Google',
|
262
|
+
primaryColor: '#4285f4',
|
263
|
+
},
|
264
|
+
github: {
|
265
|
+
displayName: 'GitHub',
|
266
|
+
primaryColor: '#333333',
|
267
|
+
},
|
268
|
+
microsoft: {
|
269
|
+
displayName: 'Microsoft',
|
270
|
+
primaryColor: '#0078d4',
|
271
|
+
},
|
272
|
+
facebook: {
|
273
|
+
displayName: 'Facebook',
|
274
|
+
primaryColor: '#1877f2',
|
275
|
+
},
|
276
|
+
apple: {
|
277
|
+
displayName: 'Apple',
|
278
|
+
primaryColor: '#000000',
|
279
|
+
},
|
280
|
+
};
|
281
|
+
return providerInfo[provider] || { displayName: provider };
|
282
|
+
}
|
283
|
+
}
|
284
|
+
//# sourceMappingURL=social.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":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OAiBG;IACH,KAAK,CAAC,eAAe;QACnB,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,IAAI,EAAE;YACjC,6FAA6F;YAC7F,OAAO,MAAM,IAAI,CAAC,eAAe,CAAC,yCAAyC,EAAE,CAAC;QAChF,CAAC,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;IACjC,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,mBAAmB,CAAC,QAAgB;QAClC,+CAA+C;QAC/C,MAAM,kBAAkB,GAAqB;YAC3C,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO;SACrD,CAAC;QACF,OAAO,kBAAkB,CAAC,QAAQ,CAAC,QAA0B,CAAC,CAAC;IACjE,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,eAAe,CAAC,QAAwB;QAKtC,MAAM,YAAY,GAAG;YACnB,MAAM,EAAE;gBACN,WAAW,EAAE,QAAQ;gBACrB,YAAY,EAAE,SAAS;aACxB;YACD,MAAM,EAAE;gBACN,WAAW,EAAE,QAAQ;gBACrB,YAAY,EAAE,SAAS;aACxB;YACD,SAAS,EAAE;gBACT,WAAW,EAAE,WAAW;gBACxB,YAAY,EAAE,SAAS;aACxB;YACD,QAAQ,EAAE;gBACR,WAAW,EAAE,UAAU;gBACvB,YAAY,EAAE,SAAS;aACxB;YACD,KAAK,EAAE;gBACL,WAAW,EAAE,OAAO;gBACpB,YAAY,EAAE,SAAS;aACxB;SACF,CAAC;QAEF,OAAO,YAAY,CAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;IAC7D,CAAC;CACF"}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
/**
|
2
|
+
* BinoAuth authentication module exports
|
3
|
+
*/
|
4
|
+
export { BinoAuthClient } from "./client";
|
5
|
+
export { PasswordFlow } from "./flows/password";
|
6
|
+
export { MagicLinkFlow } from "./flows/magic-link";
|
7
|
+
export { OTPFlow } from "./flows/otp";
|
8
|
+
export { MFAFlow } from "./flows/mfa";
|
9
|
+
export { SocialFlow } from "./flows/social";
|
10
|
+
export { BaseAuthFlow } from "./flows/base-flow";
|
11
|
+
export type { BinoAuthConfig, AuthResult, User, MFAChallenge, MFAMethod, PasswordResetRequest, PasswordResetData, OTPRequest, SocialProvider, SocialAuthRequest, LoginRequest, SignupRequest, MagicLinkRequest, PhoneOTPRequest, PhoneOTPVerificationRequest, MFARequest, EmailVerificationRequest, ResendEmailVerificationRequest, VerifyMagicLinkTokenRequest, VerifyMagicLinkCodeRequest, LoginResponse, TokenResponse, UserInfoResponse, RequestMagicLinkResponse, SignupResponse, ProviderType, ProviderResponse } from "./types";
|
12
|
+
export { AuthError, AuthErrorCode, getErrorMessage } from "./error";
|
13
|
+
import type { BinoAuthConfig } from "./types";
|
14
|
+
export declare function createPasswordAuth(config: BinoAuthConfig): import(".").PasswordFlow;
|
15
|
+
export declare function createMagicLinkAuth(config: BinoAuthConfig): import(".").MagicLinkFlow;
|
16
|
+
export declare function createOTPAuth(config: BinoAuthConfig): import(".").OTPFlow;
|
17
|
+
export declare function createSocialAuth(config: BinoAuthConfig): import(".").SocialFlow;
|
18
|
+
export declare function createOAuthAuth(config: BinoAuthConfig): import("..").BinoAuthOAuth;
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG1C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,YAAY,EACV,cAAc,EACd,UAAU,EACV,IAAI,EACJ,YAAY,EACZ,SAAS,EACT,oBAAoB,EACpB,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,iBAAiB,EAEjB,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,2BAA2B,EAC3B,UAAU,EACV,wBAAwB,EACxB,8BAA8B,EAC9B,2BAA2B,EAC3B,0BAA0B,EAC1B,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,wBAAwB,EACxB,cAAc,EACd,YAAY,EACZ,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAIpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc,4BAExD;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,cAAc,6BAEzD;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,cAAc,uBAEnD;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,cAAc,0BAEtD;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,cAAc,8BAErD"}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
/**
|
2
|
+
* BinoAuth authentication module exports
|
3
|
+
*/
|
4
|
+
// Main client
|
5
|
+
export { BinoAuthClient } from "./client";
|
6
|
+
// Individual flows
|
7
|
+
export { PasswordFlow } from "./flows/password";
|
8
|
+
export { MagicLinkFlow } from "./flows/magic-link";
|
9
|
+
export { OTPFlow } from "./flows/otp";
|
10
|
+
export { MFAFlow } from "./flows/mfa";
|
11
|
+
export { SocialFlow } from "./flows/social";
|
12
|
+
export { BaseAuthFlow } from "./flows/base-flow";
|
13
|
+
// Error handling
|
14
|
+
export { AuthError, AuthErrorCode, getErrorMessage } from "./error";
|
15
|
+
// Convenience factory functions
|
16
|
+
import { BinoAuthClient } from "./client";
|
17
|
+
export function createPasswordAuth(config) {
|
18
|
+
return new BinoAuthClient(config).password;
|
19
|
+
}
|
20
|
+
export function createMagicLinkAuth(config) {
|
21
|
+
return new BinoAuthClient(config).magicLink;
|
22
|
+
}
|
23
|
+
export function createOTPAuth(config) {
|
24
|
+
return new BinoAuthClient(config).otp;
|
25
|
+
}
|
26
|
+
export function createSocialAuth(config) {
|
27
|
+
return new BinoAuthClient(config).social;
|
28
|
+
}
|
29
|
+
export function createOAuthAuth(config) {
|
30
|
+
return new BinoAuthClient(config).oauth;
|
31
|
+
}
|
32
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc;AACd,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,mBAAmB;AACnB,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAkCjD,iBAAiB;AACjB,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAEpE,gCAAgC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG1C,MAAM,UAAU,kBAAkB,CAAC,MAAsB;IACvD,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,MAAsB;IACxD,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,MAAsB;IAClD,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAsB;IACrD,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,MAAsB;IACpD,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC;AAC1C,CAAC"}
|
@@ -0,0 +1,151 @@
|
|
1
|
+
/**
|
2
|
+
* Core authentication types and interfaces
|
3
|
+
*
|
4
|
+
* Re-exports tenant-sdk types and adds BinoAuth-specific configuration types.
|
5
|
+
*/
|
6
|
+
import type { LoginResponse, UserInfoResponse, ProviderType } from "@binoauth/tenant-sdk";
|
7
|
+
export type { LoginRequest, SignupRequest, MagicLinkRequest, PhoneOTPRequest, PhoneOTPVerificationRequest, MFARequest, EmailVerificationRequest, ResendEmailVerificationRequest, VerifyMagicLinkTokenRequest, VerifyMagicLinkCodeRequest, LoginResponse, TokenResponse, UserInfoResponse, RequestMagicLinkResponse, SignupResponse, ProviderType, ProviderResponse, } from "@binoauth/tenant-sdk";
|
8
|
+
export type AuthResult = LoginResponse;
|
9
|
+
export type User = UserInfoResponse;
|
10
|
+
export type SocialProvider = ProviderType;
|
11
|
+
/**
|
12
|
+
* Main BinoAuth configuration
|
13
|
+
*
|
14
|
+
* Supports both OAuth flows and direct authentication methods.
|
15
|
+
*
|
16
|
+
* @example
|
17
|
+
* ```typescript
|
18
|
+
* const config: BinoAuthConfig = {
|
19
|
+
* issuer: 'https://auth.binoauth.com',
|
20
|
+
* clientId: 'your_client_id',
|
21
|
+
* apiKey: 'your_api_key',
|
22
|
+
* tenant: 'your_tenant_id',
|
23
|
+
* redirectUri: 'https://yourapp.com/callback'
|
24
|
+
* };
|
25
|
+
* ```
|
26
|
+
*/
|
27
|
+
export interface BinoAuthConfig {
|
28
|
+
/** BinoAuth server URL (e.g., 'https://auth.binoauth.com') */
|
29
|
+
issuer?: string;
|
30
|
+
/** Your application's client ID */
|
31
|
+
clientId: string;
|
32
|
+
/** Callback URL after authentication */
|
33
|
+
redirectUri?: string;
|
34
|
+
/** OAuth scopes (defaults to 'openid profile email') */
|
35
|
+
scope?: string;
|
36
|
+
/** Client secret (only for confidential clients) */
|
37
|
+
clientSecret?: string;
|
38
|
+
/** API key for direct API access */
|
39
|
+
apiKey?: string;
|
40
|
+
/** Tenant identifier */
|
41
|
+
tenant?: string;
|
42
|
+
/** Base URL override (defaults to issuer) */
|
43
|
+
baseUrl?: string;
|
44
|
+
/** Enable multi-factor authentication */
|
45
|
+
enableMFA?: boolean;
|
46
|
+
/** Magic link time-to-live in seconds (default: 3600) */
|
47
|
+
magicLinkTTL?: number;
|
48
|
+
/** OTP time-to-live in seconds (default: 300) */
|
49
|
+
otpTTL?: number;
|
50
|
+
}
|
51
|
+
/**
|
52
|
+
* Extended MFA challenge interface (tenant-sdk doesn't provide this)
|
53
|
+
*
|
54
|
+
* @example
|
55
|
+
* ```typescript
|
56
|
+
* const mfaChallenge: MFAChallenge = {
|
57
|
+
* sessionId: 'session123',
|
58
|
+
* methods: ['totp', 'sms'],
|
59
|
+
* primaryMethod: 'totp'
|
60
|
+
* };
|
61
|
+
* ```
|
62
|
+
*/
|
63
|
+
export interface MFAChallenge {
|
64
|
+
/** Session identifier for MFA flow */
|
65
|
+
sessionId: string;
|
66
|
+
/** Available MFA methods */
|
67
|
+
methods: MFAMethod[];
|
68
|
+
/** Primary/recommended method */
|
69
|
+
primaryMethod?: MFAMethod;
|
70
|
+
/** Challenge expiration time */
|
71
|
+
expiresAt?: number;
|
72
|
+
}
|
73
|
+
/**
|
74
|
+
* Available MFA methods
|
75
|
+
*/
|
76
|
+
export type MFAMethod = 'sms' | 'email' | 'totp' | 'backup_codes';
|
77
|
+
/**
|
78
|
+
* Password reset request (uses magic link flow)
|
79
|
+
*
|
80
|
+
* @example
|
81
|
+
* ```typescript
|
82
|
+
* const resetRequest: PasswordResetRequest = {
|
83
|
+
* email: 'user@example.com',
|
84
|
+
* returnTo: 'https://myapp.com/reset-complete'
|
85
|
+
* };
|
86
|
+
* ```
|
87
|
+
*/
|
88
|
+
export interface PasswordResetRequest {
|
89
|
+
/** User's email address */
|
90
|
+
email: string;
|
91
|
+
/** URL to redirect after reset */
|
92
|
+
returnTo?: string;
|
93
|
+
}
|
94
|
+
/**
|
95
|
+
* Password reset completion
|
96
|
+
*
|
97
|
+
* @example
|
98
|
+
* ```typescript
|
99
|
+
* const resetData: PasswordResetData = {
|
100
|
+
* token: 'reset_token_from_email',
|
101
|
+
* newPassword: 'newsecurepassword',
|
102
|
+
* confirmPassword: 'newsecurepassword'
|
103
|
+
* };
|
104
|
+
* ```
|
105
|
+
*/
|
106
|
+
export interface PasswordResetData {
|
107
|
+
/** Reset token from magic link */
|
108
|
+
token: string;
|
109
|
+
/** New password */
|
110
|
+
newPassword: string;
|
111
|
+
/** Confirm new password */
|
112
|
+
confirmPassword: string;
|
113
|
+
}
|
114
|
+
/**
|
115
|
+
* Extended OTP request that supports method selection
|
116
|
+
*
|
117
|
+
* @example
|
118
|
+
* ```typescript
|
119
|
+
* const otpRequest: OTPRequest = {
|
120
|
+
* phone: '+1234567890',
|
121
|
+
* method: 'sms',
|
122
|
+
* allowedCountries: ['US', 'CA']
|
123
|
+
* };
|
124
|
+
* ```
|
125
|
+
*/
|
126
|
+
export interface OTPRequest {
|
127
|
+
/** User's phone number (for SMS OTP) */
|
128
|
+
phone?: string;
|
129
|
+
/** OTP delivery method (only 'sms' supported in tenant-sdk) */
|
130
|
+
method: 'sms';
|
131
|
+
/** Allowed countries for phone number validation */
|
132
|
+
allowedCountries?: string[];
|
133
|
+
}
|
134
|
+
/**
|
135
|
+
* Social authentication request
|
136
|
+
*
|
137
|
+
* @example
|
138
|
+
* ```typescript
|
139
|
+
* const socialAuth: SocialAuthRequest = {
|
140
|
+
* returnTo: 'https://myapp.com/dashboard',
|
141
|
+
* redirectUri: '/auth/callback'
|
142
|
+
* };
|
143
|
+
* ```
|
144
|
+
*/
|
145
|
+
export interface SocialAuthRequest {
|
146
|
+
/** URL to redirect after authentication */
|
147
|
+
returnTo?: string;
|
148
|
+
/** Redirect URI path (relative to tenant domain) */
|
149
|
+
redirectUri?: string;
|
150
|
+
}
|
151
|
+
//# sourceMappingURL=types.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/auth/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAGV,aAAa,EAEb,gBAAgB,EAOhB,YAAY,EAMb,MAAM,sBAAsB,CAAC;AAG9B,YAAY,EAEV,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,2BAA2B,EAC3B,UAAU,EACV,wBAAwB,EACxB,8BAA8B,EAC9B,2BAA2B,EAC3B,0BAA0B,EAG1B,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,wBAAwB,EACxB,cAAc,EAGd,YAAY,EACZ,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAG9B,MAAM,MAAM,UAAU,GAAG,aAAa,CAAC;AACvC,MAAM,MAAM,IAAI,GAAG,gBAAgB,CAAC;AACpC,MAAM,MAAM,cAAc,GAAG,YAAY,CAAC;AAE1C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,cAAc;IAE7B,8DAA8D;IAC9D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,wCAAwC;IACxC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wDAAwD;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oDAAoD;IACpD,YAAY,CAAC,EAAE,MAAM,CAAC;IAGtB,oCAAo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AChC,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oDAAoD;IACpD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/auth/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
package/dist/core/src/index.d.ts
CHANGED
@@ -1,53 +1,57 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
/**
|
2
|
+
* BinoAuth Core SDK - Main Exports
|
3
|
+
*
|
4
|
+
* Comprehensive authentication and user management solution with multiple
|
5
|
+
* authentication flows, user management, and admin operations.
|
6
|
+
*/
|
7
|
+
export { BinoAuthClient as default } from "./auth/client";
|
8
|
+
export * from "./oauth";
|
9
|
+
export { BinoAuthClient, PasswordFlow, MagicLinkFlow, OTPFlow, MFAFlow, SocialFlow, BaseAuthFlow, createPasswordAuth, createMagicLinkAuth, createOTPAuth, createSocialAuth, createOAuthAuth } from "./auth";
|
10
|
+
export type { BinoAuthConfig as AuthConfig, AuthResult as AuthResponse, User as AuthUser, MFAChallenge, MFAMethod, PasswordResetRequest, PasswordResetData, OTPRequest, SocialProvider, SocialAuthRequest, LoginRequest, SignupRequest, MagicLinkRequest, PhoneOTPRequest, PhoneOTPVerificationRequest, MFARequest, EmailVerificationRequest, ResendEmailVerificationRequest, VerifyMagicLinkTokenRequest, VerifyMagicLinkCodeRequest, LoginResponse, TokenResponse, UserInfoResponse, RequestMagicLinkResponse, SignupResponse, ProviderType, ProviderResponse } from "./auth";
|
11
|
+
export { AuthError, AuthErrorCode, getErrorMessage } from "./auth";
|
12
|
+
export * from "./admin";
|
13
|
+
import { TokenStorage } from "./oauth/storage";
|
14
|
+
import type { StorageConfig } from "./oauth";
|
15
|
+
/**
|
16
|
+
* In-memory token storage (for server-side or testing)
|
17
|
+
*
|
18
|
+
* @example
|
19
|
+
* ```typescript
|
20
|
+
* const storage = new InMemoryTokenStorage({
|
21
|
+
* clientId: 'your_client_id',
|
22
|
+
* encryptionKey: 'your-encryption-key'
|
23
|
+
* });
|
24
|
+
* ```
|
25
|
+
*/
|
26
|
+
export declare class InMemoryTokenStorage extends TokenStorage {
|
27
|
+
constructor(config: Omit<StorageConfig, 'storage'>);
|
5
28
|
}
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
29
|
+
/**
|
30
|
+
* localStorage-based token storage (for browsers)
|
31
|
+
*
|
32
|
+
* @example
|
33
|
+
* ```typescript
|
34
|
+
* const storage = new LocalStorageTokenStorage({
|
35
|
+
* clientId: 'your_client_id',
|
36
|
+
* encryptionKey: 'your-encryption-key'
|
37
|
+
* });
|
38
|
+
* ```
|
39
|
+
*/
|
40
|
+
export declare class LocalStorageTokenStorage extends TokenStorage {
|
41
|
+
constructor(config: Omit<StorageConfig, 'storage'>);
|
11
42
|
}
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
43
|
+
/**
|
44
|
+
* sessionStorage-based token storage (for browsers)
|
45
|
+
*
|
46
|
+
* @example
|
47
|
+
* ```typescript
|
48
|
+
* const storage = new SessionStorageTokenStorage({
|
49
|
+
* clientId: 'your_client_id',
|
50
|
+
* encryptionKey: 'your-encryption-key'
|
51
|
+
* });
|
52
|
+
* ```
|
53
|
+
*/
|
54
|
+
export declare class SessionStorageTokenStorage extends TokenStorage {
|
55
|
+
constructor(config: Omit<StorageConfig, 'storage'>);
|
17
56
|
}
|
18
|
-
export declare class BinoAuth {
|
19
|
-
private config;
|
20
|
-
private tenantConfig;
|
21
|
-
private adminConfig;
|
22
|
-
private authApi;
|
23
|
-
private oauthApi;
|
24
|
-
private userProfileApi;
|
25
|
-
private adminApi;
|
26
|
-
constructor(config: BinoAuthConfig);
|
27
|
-
sendEmailOTP(email: string, returnTo: string): Promise<BinoAuthResponse>;
|
28
|
-
sendPhoneOTP(phone: string): Promise<BinoAuthResponse>;
|
29
|
-
sendMagicLink(email: string, returnTo: string): Promise<BinoAuthResponse>;
|
30
|
-
login(type: "password" | "otp", credentials: LoginCredentials): Promise<BinoAuthResponse>;
|
31
|
-
sendResetPasswordEmailOTP(email: string, returnTo: string): Promise<BinoAuthResponse>;
|
32
|
-
sendResetPasswordPhoneOTP(phone: string): Promise<BinoAuthResponse>;
|
33
|
-
resetPassword(params: {
|
34
|
-
otp: string;
|
35
|
-
newPassword: string;
|
36
|
-
repeatNewPassword: string;
|
37
|
-
}): Promise<BinoAuthResponse>;
|
38
|
-
refreshToken(refreshToken: string): Promise<BinoAuthResponse>;
|
39
|
-
logout(): Promise<BinoAuthResponse>;
|
40
|
-
getProfile(): Promise<BinoAuthResponse>;
|
41
|
-
requestDeviceCode(): Promise<BinoAuthResponse>;
|
42
|
-
pollDeviceToken(deviceCode: string): Promise<BinoAuthResponse>;
|
43
|
-
createUser(userData: any): Promise<BinoAuthResponse>;
|
44
|
-
getUser(userId: string): Promise<BinoAuthResponse>;
|
45
|
-
getUsers(params?: {
|
46
|
-
page?: number;
|
47
|
-
limit?: number;
|
48
|
-
}): Promise<BinoAuthResponse>;
|
49
|
-
updateUser(userId: string, userData: any): Promise<BinoAuthResponse>;
|
50
|
-
deleteUser(userId: string): Promise<BinoAuthResponse>;
|
51
|
-
}
|
52
|
-
export default BinoAuth;
|
53
57
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,cAAc,IAAI,OAAO,EAAE,MAAM,eAAe,CAAC;AAG1D,cAAc,SAAS,CAAC;AAGxB,OAAO,EACL,cAAc,EACd,YAAY,EACZ,aAAa,EACb,OAAO,EACP,OAAO,EACP,UAAU,EACV,YAAY,EACZ,kBAAkB,EAClB,mBAA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