@pubflow/react 0.4.10 → 0.4.12
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.cjs +8 -110
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -6
- package/dist/index.esm.js +9 -111
- package/dist/index.esm.js.map +1 -1
- package/dist/types/context/PubflowProvider.d.ts +1 -6
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _pubflow_core from '@pubflow/core';
|
|
2
|
-
import { EntityData, BridgeApiService, EntityConfig, FilterOperator, FilterDefinition, PubflowInstanceConfig, ApiClient, AuthService,
|
|
2
|
+
import { EntityData, BridgeApiService, EntityConfig, FilterOperator, FilterDefinition, PubflowInstanceConfig, ApiClient, AuthService, User, TwoFactorMethod, TwoFactorVerifyResult, TwoFactorStartResult, QueryParams, SearchParams, TwoFactorSetupResult, TwoFactorToggleResult, StorageAdapter } from '@pubflow/core';
|
|
3
3
|
export * from '@pubflow/core';
|
|
4
4
|
export { AddOrganizationMemberRequest, Address, AddressType, BridgePaymentClient, BridgePaymentConfig, CancelSubscriptionRequest, ConvertGuestToUserRequest, ConvertGuestToUserResponse, CreateAddressRequest, CreateCustomerRequest, CreateOrganizationRequest, CreatePaymentIntentRequest, CreateSubscriptionRequest, Customer, ListResponse, Organization, OrganizationMember, OrganizationRole, PaginationParams, Payment, PaymentIntent, PaymentMethod, PaymentMethodType, PaymentRequestOptions, Subscription, SubscriptionStatus, UpdateAddressRequest, UpdateCustomerRequest, UpdateOrganizationMemberRoleRequest, UpdateOrganizationRequest, UpdatePaymentMethodRequest } from '@pubflow/core';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
@@ -1294,12 +1294,9 @@ interface PubflowInstance {
|
|
|
1294
1294
|
config: PubflowInstanceConfig;
|
|
1295
1295
|
apiClient: ApiClient;
|
|
1296
1296
|
authService: AuthService;
|
|
1297
|
-
twoFactorService: TwoFactorService;
|
|
1298
1297
|
user: User | null | undefined;
|
|
1299
1298
|
isAuthenticated: boolean;
|
|
1300
1299
|
isLoading: boolean;
|
|
1301
|
-
twoFactorPending: boolean;
|
|
1302
|
-
twoFactorMethods: TwoFactorMethod[];
|
|
1303
1300
|
login: (credentials: {
|
|
1304
1301
|
email?: string;
|
|
1305
1302
|
userName?: string;
|
|
@@ -1311,8 +1308,6 @@ interface PubflowInstance {
|
|
|
1311
1308
|
expiresAt?: string;
|
|
1312
1309
|
user?: User;
|
|
1313
1310
|
}>;
|
|
1314
|
-
verifyTwoFactor: (methodId: string, code: string) => Promise<TwoFactorVerifyResult>;
|
|
1315
|
-
startTwoFactor: (methodId: string, method: string) => Promise<TwoFactorStartResult>;
|
|
1316
1311
|
}
|
|
1317
1312
|
/**
|
|
1318
1313
|
* Create Pubflow context
|
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createStorageKey, initConfig, ApiClient, AuthService,
|
|
1
|
+
import { createStorageKey, initConfig, ApiClient, AuthService, BridgeApiService, validateWithSchema, FilterOperator } from '@pubflow/core';
|
|
2
2
|
export * from '@pubflow/core';
|
|
3
3
|
export { BridgePaymentClient } from '@pubflow/core';
|
|
4
4
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
@@ -254,7 +254,6 @@ function PubflowProvider({ children, config, instances, defaultInstance = 'defau
|
|
|
254
254
|
});
|
|
255
255
|
const apiClient = new ApiClient(fullConfig, storage);
|
|
256
256
|
const authService = new AuthService(apiClient, storage, fullConfig);
|
|
257
|
-
const twoFactorService = new TwoFactorService(apiClient, fullConfig);
|
|
258
257
|
// Get current user (non-blocking)
|
|
259
258
|
let user = null;
|
|
260
259
|
let isAuthenticated = false;
|
|
@@ -262,35 +261,12 @@ function PubflowProvider({ children, config, instances, defaultInstance = 'defau
|
|
|
262
261
|
config: fullConfig,
|
|
263
262
|
apiClient,
|
|
264
263
|
authService,
|
|
265
|
-
twoFactorService,
|
|
266
264
|
user,
|
|
267
265
|
isAuthenticated,
|
|
268
266
|
isLoading: true,
|
|
269
|
-
twoFactorPending: false,
|
|
270
|
-
twoFactorMethods: [],
|
|
271
267
|
login: async (credentials) => {
|
|
272
268
|
const result = await authService.login(credentials);
|
|
273
|
-
if (
|
|
274
|
-
return result;
|
|
275
|
-
if (result.success && result.requires2fa) {
|
|
276
|
-
// 2FA required — keep session pending, expose methods
|
|
277
|
-
setContextValue(prev => {
|
|
278
|
-
var _a;
|
|
279
|
-
return ({
|
|
280
|
-
...prev,
|
|
281
|
-
instances: {
|
|
282
|
-
...prev.instances,
|
|
283
|
-
[instanceConfig.id]: {
|
|
284
|
-
...prev.instances[instanceConfig.id],
|
|
285
|
-
isLoading: false,
|
|
286
|
-
twoFactorPending: true,
|
|
287
|
-
twoFactorMethods: (_a = result.availableMethods) !== null && _a !== void 0 ? _a : [],
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
else if (result.success && result.user) {
|
|
269
|
+
if (result.success && result.user && isMounted) {
|
|
294
270
|
setContextValue(prev => ({
|
|
295
271
|
...prev,
|
|
296
272
|
instances: {
|
|
@@ -299,9 +275,7 @@ function PubflowProvider({ children, config, instances, defaultInstance = 'defau
|
|
|
299
275
|
...prev.instances[instanceConfig.id],
|
|
300
276
|
user: result.user,
|
|
301
277
|
isAuthenticated: true,
|
|
302
|
-
isLoading: false
|
|
303
|
-
twoFactorPending: false,
|
|
304
|
-
twoFactorMethods: [],
|
|
278
|
+
isLoading: false
|
|
305
279
|
}
|
|
306
280
|
}
|
|
307
281
|
}));
|
|
@@ -319,9 +293,7 @@ function PubflowProvider({ children, config, instances, defaultInstance = 'defau
|
|
|
319
293
|
...prev.instances[instanceConfig.id],
|
|
320
294
|
user: null,
|
|
321
295
|
isAuthenticated: false,
|
|
322
|
-
isLoading: false
|
|
323
|
-
twoFactorPending: false,
|
|
324
|
-
twoFactorMethods: [],
|
|
296
|
+
isLoading: false
|
|
325
297
|
}
|
|
326
298
|
}
|
|
327
299
|
}));
|
|
@@ -344,31 +316,7 @@ function PubflowProvider({ children, config, instances, defaultInstance = 'defau
|
|
|
344
316
|
}));
|
|
345
317
|
}
|
|
346
318
|
return result;
|
|
347
|
-
}
|
|
348
|
-
verifyTwoFactor: async (methodId, code) => {
|
|
349
|
-
const result = await twoFactorService.verify(methodId, code, 'login');
|
|
350
|
-
if (result.verified && isMounted) {
|
|
351
|
-
// Fetch the now-active user from the server
|
|
352
|
-
const userData = await authService.getCurrentUser();
|
|
353
|
-
setContextValue(prev => ({
|
|
354
|
-
...prev,
|
|
355
|
-
instances: {
|
|
356
|
-
...prev.instances,
|
|
357
|
-
[instanceConfig.id]: {
|
|
358
|
-
...prev.instances[instanceConfig.id],
|
|
359
|
-
user: userData,
|
|
360
|
-
isAuthenticated: true,
|
|
361
|
-
twoFactorPending: false,
|
|
362
|
-
twoFactorMethods: [],
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
}));
|
|
366
|
-
}
|
|
367
|
-
return result;
|
|
368
|
-
},
|
|
369
|
-
startTwoFactor: async (methodId, method) => {
|
|
370
|
-
return twoFactorService.start(methodId, method, 'login');
|
|
371
|
-
},
|
|
319
|
+
}
|
|
372
320
|
};
|
|
373
321
|
// Load user asynchronously
|
|
374
322
|
authService.getCurrentUser().then(currentUser => {
|
|
@@ -417,39 +365,16 @@ function PubflowProvider({ children, config, instances, defaultInstance = 'defau
|
|
|
417
365
|
});
|
|
418
366
|
const apiClient = new ApiClient(fullConfig, storage);
|
|
419
367
|
const authService = new AuthService(apiClient, storage, fullConfig);
|
|
420
|
-
const twoFactorService = new TwoFactorService(apiClient, fullConfig);
|
|
421
368
|
instancesMap[defaultInstance] = {
|
|
422
369
|
config: fullConfig,
|
|
423
370
|
apiClient,
|
|
424
371
|
authService,
|
|
425
|
-
twoFactorService,
|
|
426
372
|
user: null,
|
|
427
373
|
isAuthenticated: false,
|
|
428
374
|
isLoading: true,
|
|
429
|
-
twoFactorPending: false,
|
|
430
|
-
twoFactorMethods: [],
|
|
431
375
|
login: async (credentials) => {
|
|
432
376
|
const result = await authService.login(credentials);
|
|
433
|
-
if (
|
|
434
|
-
return result;
|
|
435
|
-
if (result.success && result.requires2fa) {
|
|
436
|
-
setContextValue(prev => {
|
|
437
|
-
var _a;
|
|
438
|
-
return ({
|
|
439
|
-
...prev,
|
|
440
|
-
instances: {
|
|
441
|
-
...prev.instances,
|
|
442
|
-
[defaultInstance]: {
|
|
443
|
-
...prev.instances[defaultInstance],
|
|
444
|
-
isLoading: false,
|
|
445
|
-
twoFactorPending: true,
|
|
446
|
-
twoFactorMethods: (_a = result.availableMethods) !== null && _a !== void 0 ? _a : [],
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
});
|
|
450
|
-
});
|
|
451
|
-
}
|
|
452
|
-
else if (result.success && result.user) {
|
|
377
|
+
if (result.success && result.user && isMounted) {
|
|
453
378
|
setContextValue(prev => ({
|
|
454
379
|
...prev,
|
|
455
380
|
instances: {
|
|
@@ -458,9 +383,7 @@ function PubflowProvider({ children, config, instances, defaultInstance = 'defau
|
|
|
458
383
|
...prev.instances[defaultInstance],
|
|
459
384
|
user: result.user,
|
|
460
385
|
isAuthenticated: true,
|
|
461
|
-
isLoading: false
|
|
462
|
-
twoFactorPending: false,
|
|
463
|
-
twoFactorMethods: [],
|
|
386
|
+
isLoading: false
|
|
464
387
|
}
|
|
465
388
|
}
|
|
466
389
|
}));
|
|
@@ -478,9 +401,7 @@ function PubflowProvider({ children, config, instances, defaultInstance = 'defau
|
|
|
478
401
|
...prev.instances[defaultInstance],
|
|
479
402
|
user: null,
|
|
480
403
|
isAuthenticated: false,
|
|
481
|
-
isLoading: false
|
|
482
|
-
twoFactorPending: false,
|
|
483
|
-
twoFactorMethods: [],
|
|
404
|
+
isLoading: false
|
|
484
405
|
}
|
|
485
406
|
}
|
|
486
407
|
}));
|
|
@@ -503,30 +424,7 @@ function PubflowProvider({ children, config, instances, defaultInstance = 'defau
|
|
|
503
424
|
}));
|
|
504
425
|
}
|
|
505
426
|
return result;
|
|
506
|
-
}
|
|
507
|
-
verifyTwoFactor: async (methodId, code) => {
|
|
508
|
-
const result = await twoFactorService.verify(methodId, code, 'login');
|
|
509
|
-
if (result.verified && isMounted) {
|
|
510
|
-
const userData = await authService.getCurrentUser();
|
|
511
|
-
setContextValue(prev => ({
|
|
512
|
-
...prev,
|
|
513
|
-
instances: {
|
|
514
|
-
...prev.instances,
|
|
515
|
-
[defaultInstance]: {
|
|
516
|
-
...prev.instances[defaultInstance],
|
|
517
|
-
user: userData,
|
|
518
|
-
isAuthenticated: true,
|
|
519
|
-
twoFactorPending: false,
|
|
520
|
-
twoFactorMethods: [],
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
}));
|
|
524
|
-
}
|
|
525
|
-
return result;
|
|
526
|
-
},
|
|
527
|
-
startTwoFactor: async (methodId, method) => {
|
|
528
|
-
return twoFactorService.start(methodId, method, 'login');
|
|
529
|
-
},
|
|
427
|
+
}
|
|
530
428
|
};
|
|
531
429
|
// Load user asynchronously
|
|
532
430
|
authService.getCurrentUser().then(currentUser => {
|