@explorins/pers-sdk-react-native 2.2.0-alpha.3 → 2.2.0-alpha.5
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/hooks/index.js +1 -1
- package/dist/hooks/useRedemptions.d.ts +1 -1
- package/dist/hooks/useTransactionSigner.d.ts +5 -4
- package/dist/hooks/useTransactionSigner.d.ts.map +1 -1
- package/dist/hooks/useTransactionSigner.js +18 -8
- package/dist/hooks/useTransactions.d.ts +1 -1
- package/dist/index.js +68 -52
- package/dist/index.js.map +1 -1
- package/dist/storage/async-storage-token-storage.d.ts +13 -1
- package/dist/storage/async-storage-token-storage.d.ts.map +1 -1
- package/dist/storage/async-storage-token-storage.js +40 -30
- package/package.json +2 -2
- package/src/hooks/useTransactionSigner.ts +28 -12
- package/src/storage/async-storage-token-storage.ts +49 -33
package/dist/hooks/index.js
CHANGED
|
@@ -3,7 +3,7 @@ export { useAuth } from './useAuth';
|
|
|
3
3
|
export { useTokens } from './useTokens';
|
|
4
4
|
export { useTokenBalances } from './useTokenBalances';
|
|
5
5
|
export { useTransactions } from './useTransactions';
|
|
6
|
-
export { useTransactionSigner
|
|
6
|
+
export { useTransactionSigner } from './useTransactionSigner';
|
|
7
7
|
export { useBusiness } from './useBusiness';
|
|
8
8
|
export { useCampaigns } from './useCampaigns';
|
|
9
9
|
export { useRedemptions } from './useRedemptions';
|
|
@@ -44,7 +44,7 @@ export declare const useRedemptions: () => {
|
|
|
44
44
|
updateRedemption: (redemptionId: string, redemptionData: RedemptionCreateRequestDTO) => Promise<RedemptionDTO>;
|
|
45
45
|
toggleRedemptionStatus: (redemptionId: string) => Promise<RedemptionDTO>;
|
|
46
46
|
isAvailable: boolean;
|
|
47
|
-
signingStatus: import("@explorins/pers-signer").SigningStatus | null;
|
|
47
|
+
signingStatus: import("@explorins/pers-signer/types").SigningStatus | null;
|
|
48
48
|
signingStatusMessage: string | null;
|
|
49
49
|
};
|
|
50
50
|
export type RedemptionHook = ReturnType<typeof useRedemptions>;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { StatusUpdateData } from '@explorins/pers-signer/types';
|
|
2
|
+
import type { SigningStatus as SigningStatusType } from '@explorins/pers-signer/types';
|
|
2
3
|
type SubmissionResult = import('@explorins/pers-signer/react-native').SubmissionResult;
|
|
3
4
|
type AuthenticatedUser = import('@explorins/pers-signer/react-native').AuthenticatedUser;
|
|
4
5
|
type TransactionSigningResult = import('@explorins/pers-signer/react-native').TransactionSigningResult;
|
|
5
|
-
export { SigningStatus };
|
|
6
|
+
export type { SigningStatusType as SigningStatus };
|
|
6
7
|
export type { StatusUpdateData };
|
|
7
8
|
/**
|
|
8
9
|
* Simple status callback function type for React Native consumers
|
|
9
10
|
* (Simplified from the signer SDK's object-based StatusCallback interface)
|
|
10
11
|
*/
|
|
11
|
-
export type OnStatusUpdateFn = (status:
|
|
12
|
+
export type OnStatusUpdateFn = (status: SigningStatusType, message: string, data?: StatusUpdateData) => void;
|
|
12
13
|
/**
|
|
13
14
|
* Return interface for the useTransactionSigner hook
|
|
14
15
|
*
|
|
@@ -28,7 +29,7 @@ export interface TransactionSignerHook {
|
|
|
28
29
|
signPersTransaction: (jwt: string, onStatusUpdate?: OnStatusUpdateFn) => Promise<TransactionSigningResult>;
|
|
29
30
|
isSignerInitialized: boolean;
|
|
30
31
|
isSignerAvailable: boolean;
|
|
31
|
-
currentStatus:
|
|
32
|
+
currentStatus: SigningStatusType | null;
|
|
32
33
|
statusMessage: string | null;
|
|
33
34
|
}
|
|
34
35
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTransactionSigner.d.ts","sourceRoot":"","sources":["../../src/hooks/useTransactionSigner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useTransactionSigner.d.ts","sourceRoot":"","sources":["../../src/hooks/useTransactionSigner.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAoC,gBAAg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TvC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,CAAC"}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { useCallback, useState, useRef, useEffect } from 'react';
|
|
2
|
-
// import
|
|
3
|
-
import { SigningStatus } from '@explorins/pers-signer';
|
|
4
|
-
//
|
|
5
|
-
export { SigningStatus };
|
|
6
|
-
// Lazy-loaded signer SDK factory - initialized on first use to avoid native module timing issues
|
|
2
|
+
// Runtime const import - also from /types (no native deps)
|
|
3
|
+
import { SigningStatus as SigningStatusConst } from '@explorins/pers-signer/types';
|
|
4
|
+
// Lazy-loaded signer SDK - initialized on first use to avoid native module timing issues
|
|
7
5
|
let _createPersSignerSDK = null;
|
|
8
6
|
let _signerInitAttempted = false;
|
|
7
|
+
/**
|
|
8
|
+
* Get the SigningStatus const object
|
|
9
|
+
* Now directly imported from /types (no native deps, always available)
|
|
10
|
+
*/
|
|
11
|
+
function getSigningStatus() {
|
|
12
|
+
return SigningStatusConst;
|
|
13
|
+
}
|
|
9
14
|
/**
|
|
10
15
|
* Lazily load the PERS Signer SDK.
|
|
11
16
|
*
|
|
@@ -22,7 +27,8 @@ function getSignerSDKFactory() {
|
|
|
22
27
|
_signerInitAttempted = true;
|
|
23
28
|
// Check for customer pre-initialized global (for native module timing issues)
|
|
24
29
|
if (typeof global !== 'undefined' && global.__PersSigner?.createPersSignerSDK) {
|
|
25
|
-
|
|
30
|
+
const globalModule = global.__PersSigner;
|
|
31
|
+
_createPersSignerSDK = globalModule.createPersSignerSDK;
|
|
26
32
|
return _createPersSignerSDK;
|
|
27
33
|
}
|
|
28
34
|
// Standard lazy load
|
|
@@ -360,7 +366,9 @@ export const useTransactionSigner = () => {
|
|
|
360
366
|
}
|
|
361
367
|
catch (error) {
|
|
362
368
|
console.error('[useTransactionSigner] JWT transaction signing failed:', error);
|
|
363
|
-
|
|
369
|
+
const SigningStatusEnum = getSigningStatus();
|
|
370
|
+
if (SigningStatusEnum)
|
|
371
|
+
setCurrentStatus(SigningStatusEnum.ERROR);
|
|
364
372
|
setStatusMessage(error instanceof Error ? error.message : 'Transaction failed');
|
|
365
373
|
throw error; // Re-throw to maintain error handling upstream
|
|
366
374
|
}
|
|
@@ -417,7 +425,9 @@ export const useTransactionSigner = () => {
|
|
|
417
425
|
}
|
|
418
426
|
catch (error) {
|
|
419
427
|
console.error('[useTransactionSigner] Sign-only transaction failed:', error);
|
|
420
|
-
|
|
428
|
+
const SigningStatusEnum = getSigningStatus();
|
|
429
|
+
if (SigningStatusEnum)
|
|
430
|
+
setCurrentStatus(SigningStatusEnum.ERROR);
|
|
421
431
|
setStatusMessage(error instanceof Error ? error.message : 'Signing failed');
|
|
422
432
|
throw error;
|
|
423
433
|
}
|
|
@@ -47,7 +47,7 @@ export declare const useTransactions: () => {
|
|
|
47
47
|
}) => Promise<PaginatedResponseDTO<TransactionDTO>>;
|
|
48
48
|
exportTransactionsCSV: () => Promise<Blob>;
|
|
49
49
|
isAvailable: boolean;
|
|
50
|
-
signingStatus: import("@explorins/pers-signer").SigningStatus | null;
|
|
50
|
+
signingStatus: import("@explorins/pers-signer/types").SigningStatus | null;
|
|
51
51
|
signingStatusMessage: string | null;
|
|
52
52
|
};
|
|
53
53
|
export type TransactionHook = ReturnType<typeof useTransactions>;
|
package/dist/index.js
CHANGED
|
@@ -19451,52 +19451,62 @@ function warnIfProblematicEnvironment(feature) {
|
|
|
19451
19451
|
/**
|
|
19452
19452
|
* AsyncStorage Token Storage for React Native Mobile Platforms
|
|
19453
19453
|
*
|
|
19454
|
-
* Bundler-agnostic AsyncStorage implementation for mobile platforms
|
|
19454
|
+
* Bundler-agnostic AsyncStorage implementation for mobile platforms.
|
|
19455
|
+
*
|
|
19456
|
+
* IMPORTANT: Due to bundler conflicts between Rollup (SDK) and Metro (app),
|
|
19457
|
+
* the consuming app MUST set global.AsyncStorageModule before using this SDK:
|
|
19458
|
+
*
|
|
19459
|
+
* ```javascript
|
|
19460
|
+
* // In your app's index.js, BEFORE importing the SDK:
|
|
19461
|
+
* import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
19462
|
+
* global.AsyncStorageModule = AsyncStorage;
|
|
19463
|
+
* ```
|
|
19455
19464
|
*/
|
|
19456
19465
|
/**
|
|
19457
|
-
*
|
|
19466
|
+
* Get AsyncStorage from the global that the app must set.
|
|
19458
19467
|
*
|
|
19459
|
-
*
|
|
19460
|
-
*
|
|
19461
|
-
* hoisting and namespace collisions.
|
|
19462
|
-
*
|
|
19463
|
-
* By using require() at runtime, we ensure we get the actual AsyncStorage
|
|
19464
|
-
* from the app's node_modules, not a bundled/mangled version.
|
|
19468
|
+
* This bypasses all bundler resolution issues by having the app
|
|
19469
|
+
* explicitly provide the AsyncStorage module via a global variable.
|
|
19465
19470
|
*/
|
|
19466
19471
|
function getAsyncStorage() {
|
|
19467
|
-
//
|
|
19468
|
-
|
|
19472
|
+
// Check if the app has set the global
|
|
19473
|
+
if (global.AsyncStorageModule) {
|
|
19474
|
+
const module = global.AsyncStorageModule;
|
|
19475
|
+
// Validate it has the expected methods
|
|
19476
|
+
if (typeof module?.getItem === 'function') {
|
|
19477
|
+
console.log('[AsyncStorage] Using global.AsyncStorageModule (direct)');
|
|
19478
|
+
return module;
|
|
19479
|
+
}
|
|
19480
|
+
else if (typeof module?.default?.getItem === 'function') {
|
|
19481
|
+
console.log('[AsyncStorage] Using global.AsyncStorageModule.default');
|
|
19482
|
+
return module.default;
|
|
19483
|
+
}
|
|
19484
|
+
}
|
|
19485
|
+
// Fallback: try require (may not work due to bundler conflicts)
|
|
19469
19486
|
try {
|
|
19470
|
-
//
|
|
19487
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
19471
19488
|
const module = require('@react-native-async-storage/async-storage');
|
|
19472
|
-
|
|
19473
|
-
|
|
19474
|
-
const hasDefaultGetItem = typeof module?.default?.getItem === 'function';
|
|
19475
|
-
console.log('[AsyncStorage] Module resolution:', {
|
|
19476
|
-
hasGetItem,
|
|
19477
|
-
hasDefaultGetItem,
|
|
19478
|
-
moduleType: typeof module,
|
|
19479
|
-
keys: module ? Object.keys(module).slice(0, 10) : []
|
|
19480
|
-
});
|
|
19481
|
-
if (hasDefaultGetItem) {
|
|
19489
|
+
if (typeof module?.default?.getItem === 'function') {
|
|
19490
|
+
console.log('[AsyncStorage] Fallback: using require().default');
|
|
19482
19491
|
return module.default;
|
|
19483
19492
|
}
|
|
19484
|
-
else if (
|
|
19493
|
+
else if (typeof module?.getItem === 'function') {
|
|
19494
|
+
console.log('[AsyncStorage] Fallback: using require() direct');
|
|
19485
19495
|
return module;
|
|
19486
19496
|
}
|
|
19487
|
-
else {
|
|
19488
|
-
throw new Error('AsyncStorage module found but missing getItem method');
|
|
19489
|
-
}
|
|
19490
19497
|
}
|
|
19491
|
-
catch (
|
|
19492
|
-
|
|
19493
|
-
throw new Error('Failed to load @react-native-async-storage/async-storage. ' +
|
|
19494
|
-
'Make sure it is installed and properly linked.');
|
|
19498
|
+
catch (e) {
|
|
19499
|
+
// Ignore require errors
|
|
19495
19500
|
}
|
|
19501
|
+
// If we get here, provide a helpful error
|
|
19502
|
+
throw new Error('AsyncStorage not available. Please add this to your app\'s index.js BEFORE importing the SDK:\n\n' +
|
|
19503
|
+
' import AsyncStorage from \'@react-native-async-storage/async-storage\';\n' +
|
|
19504
|
+
' global.AsyncStorageModule = AsyncStorage;\n\n' +
|
|
19505
|
+
'This is required due to bundler conflicts between Rollup and Metro.');
|
|
19496
19506
|
}
|
|
19497
19507
|
/**
|
|
19498
19508
|
* Bundler-agnostic AsyncStorage wrapper
|
|
19499
|
-
*
|
|
19509
|
+
* Uses global injection to avoid bundler conflicts
|
|
19500
19510
|
*/
|
|
19501
19511
|
class BundlerAgnosticAsyncStorage {
|
|
19502
19512
|
constructor() {
|
|
@@ -42398,9 +42408,19 @@ function useTokenBalances(options) {
|
|
|
42398
42408
|
}
|
|
42399
42409
|
|
|
42400
42410
|
/**
|
|
42401
|
-
*
|
|
42411
|
+
* Signing status types for type-safe status updates
|
|
42412
|
+
* Using const pattern instead of enum for better bundling compatibility
|
|
42402
42413
|
*/
|
|
42403
|
-
|
|
42414
|
+
const SigningStatus = {
|
|
42415
|
+
INITIALIZING: 'initializing',
|
|
42416
|
+
AUTHENTICATING: 'authenticating',
|
|
42417
|
+
PREPARING: 'preparing',
|
|
42418
|
+
SIGNING: 'signing',
|
|
42419
|
+
SUBMITTING: 'submitting',
|
|
42420
|
+
COMPLETED: 'completed',
|
|
42421
|
+
ERROR: 'error',
|
|
42422
|
+
EXPIRED: 'expired'
|
|
42423
|
+
};
|
|
42404
42424
|
|
|
42405
42425
|
/**
|
|
42406
42426
|
* Error codes for transaction signing operations
|
|
@@ -42421,24 +42441,16 @@ var TransactionSigningErrorCode;
|
|
|
42421
42441
|
TransactionSigningErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
|
|
42422
42442
|
})(TransactionSigningErrorCode || (TransactionSigningErrorCode = {}));
|
|
42423
42443
|
|
|
42424
|
-
|
|
42425
|
-
* Signing status types for type-safe status updates
|
|
42426
|
-
* Using const pattern instead of enum for better bundling compatibility
|
|
42427
|
-
*/
|
|
42428
|
-
const SigningStatus = {
|
|
42429
|
-
INITIALIZING: 'initializing',
|
|
42430
|
-
AUTHENTICATING: 'authenticating',
|
|
42431
|
-
PREPARING: 'preparing',
|
|
42432
|
-
SIGNING: 'signing',
|
|
42433
|
-
SUBMITTING: 'submitting',
|
|
42434
|
-
COMPLETED: 'completed',
|
|
42435
|
-
ERROR: 'error',
|
|
42436
|
-
EXPIRED: 'expired'
|
|
42437
|
-
};
|
|
42438
|
-
|
|
42439
|
-
// Lazy-loaded signer SDK factory - initialized on first use to avoid native module timing issues
|
|
42444
|
+
// Lazy-loaded signer SDK - initialized on first use to avoid native module timing issues
|
|
42440
42445
|
let _createPersSignerSDK = null;
|
|
42441
42446
|
let _signerInitAttempted = false;
|
|
42447
|
+
/**
|
|
42448
|
+
* Get the SigningStatus const object
|
|
42449
|
+
* Now directly imported from /types (no native deps, always available)
|
|
42450
|
+
*/
|
|
42451
|
+
function getSigningStatus() {
|
|
42452
|
+
return SigningStatus;
|
|
42453
|
+
}
|
|
42442
42454
|
/**
|
|
42443
42455
|
* Lazily load the PERS Signer SDK.
|
|
42444
42456
|
*
|
|
@@ -42455,7 +42467,8 @@ function getSignerSDKFactory() {
|
|
|
42455
42467
|
_signerInitAttempted = true;
|
|
42456
42468
|
// Check for customer pre-initialized global (for native module timing issues)
|
|
42457
42469
|
if (typeof global !== 'undefined' && global.__PersSigner?.createPersSignerSDK) {
|
|
42458
|
-
|
|
42470
|
+
const globalModule = global.__PersSigner;
|
|
42471
|
+
_createPersSignerSDK = globalModule.createPersSignerSDK;
|
|
42459
42472
|
return _createPersSignerSDK;
|
|
42460
42473
|
}
|
|
42461
42474
|
// Standard lazy load
|
|
@@ -42793,7 +42806,9 @@ const useTransactionSigner = () => {
|
|
|
42793
42806
|
}
|
|
42794
42807
|
catch (error) {
|
|
42795
42808
|
console.error('[useTransactionSigner] JWT transaction signing failed:', error);
|
|
42796
|
-
|
|
42809
|
+
const SigningStatusEnum = getSigningStatus();
|
|
42810
|
+
if (SigningStatusEnum)
|
|
42811
|
+
setCurrentStatus(SigningStatusEnum.ERROR);
|
|
42797
42812
|
setStatusMessage(error instanceof Error ? error.message : 'Transaction failed');
|
|
42798
42813
|
throw error; // Re-throw to maintain error handling upstream
|
|
42799
42814
|
}
|
|
@@ -42850,7 +42865,9 @@ const useTransactionSigner = () => {
|
|
|
42850
42865
|
}
|
|
42851
42866
|
catch (error) {
|
|
42852
42867
|
console.error('[useTransactionSigner] Sign-only transaction failed:', error);
|
|
42853
|
-
|
|
42868
|
+
const SigningStatusEnum = getSigningStatus();
|
|
42869
|
+
if (SigningStatusEnum)
|
|
42870
|
+
setCurrentStatus(SigningStatusEnum.ERROR);
|
|
42854
42871
|
setStatusMessage(error instanceof Error ? error.message : 'Signing failed');
|
|
42855
42872
|
throw error;
|
|
42856
42873
|
}
|
|
@@ -45826,7 +45843,6 @@ exports.SDK_VERSION = SDK_VERSION;
|
|
|
45826
45843
|
exports.SOURCE_LOGIC_TYPES = SOURCE_LOGIC_TYPES;
|
|
45827
45844
|
exports.SOURCE_LOGIC_TYPE_VALUES = SOURCE_LOGIC_TYPE_VALUES;
|
|
45828
45845
|
exports.SdkErrorCodes = SdkErrorCodes;
|
|
45829
|
-
exports.SigningStatus = SigningStatus;
|
|
45830
45846
|
exports.StaticJwtAuthProvider = StaticJwtAuthProvider;
|
|
45831
45847
|
exports.TOKEN_VALIDITY_TYPE_VALUES = TOKEN_VALIDITY_TYPE_VALUES;
|
|
45832
45848
|
exports.TRANSACTION_FORMATS = TRANSACTION_FORMATS;
|