@explorins/pers-sdk-react-native 1.5.3 → 1.5.4
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.
|
@@ -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":"AA6EA,UAAU,wBAAwB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAKD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,oBAAoB;IAiK7B;;OAEG;2BAtE2C,MAAM,KAAG,QAAQ,wBAAwB,CAAC;IAyExF;;OAEG;gCA9HgD;QACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;KAC5B;IA6HC;;OAEG;;IAGH;;OAEG;;CAGN,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAE5E;;GAEG;AACH,YAAY,EAAE,wBAAwB,EAAE,CAAC"}
|
|
@@ -76,27 +76,34 @@ export const useTransactionSigner = () => {
|
|
|
76
76
|
const signerSDKRef = useRef(null);
|
|
77
77
|
// Auto-initialize signer when user is authenticated and real SDK is available
|
|
78
78
|
useEffect(() => {
|
|
79
|
-
if (isInitialized && isAuthenticated && user && !isSignerInitialized) {
|
|
79
|
+
if (isInitialized && isAuthenticated && user && !isSignerInitialized && sdk) {
|
|
80
80
|
console.log('[useTransactionSigner] Auto-initializing PERS transaction signer...');
|
|
81
|
+
// Get configuration from the PERS SDK
|
|
82
|
+
const sdkConfig = sdk.config || {};
|
|
83
|
+
const apiProjectKey = sdkConfig.apiProjectKey || 'demo-project-key';
|
|
84
|
+
const tenantId = sdkConfig.tenantId || 'vq-demo';
|
|
81
85
|
initializeSigner({
|
|
82
|
-
tenantId:
|
|
86
|
+
tenantId: tenantId,
|
|
87
|
+
projectKey: apiProjectKey,
|
|
83
88
|
ethersProviderUrl: DEFAULT_ETHERS_PROVIDER
|
|
84
89
|
}).catch((error) => {
|
|
85
90
|
console.error('[useTransactionSigner] Auto-initialization failed:', error);
|
|
86
91
|
});
|
|
87
92
|
}
|
|
88
|
-
}, [isInitialized, isAuthenticated, user, isSignerInitialized,
|
|
93
|
+
}, [isInitialized, isAuthenticated, user, isSignerInitialized, sdk]);
|
|
89
94
|
/**
|
|
90
95
|
* Initialize the blockchain signer with configuration
|
|
91
96
|
*
|
|
92
97
|
* @param config - Signer configuration options
|
|
93
98
|
* @param config.tenantId - Multi-tenant identifier for the signer
|
|
99
|
+
* @param config.projectKey - PERS project API key for authentication
|
|
94
100
|
* @param config.ethersProviderUrl - Custom blockchain provider URL
|
|
95
101
|
*
|
|
96
102
|
* @example
|
|
97
103
|
* ```typescript
|
|
98
104
|
* await initializeSigner({
|
|
99
105
|
* tenantId: 'my-tenant-id',
|
|
106
|
+
* projectKey: 'your-pers-api-key',
|
|
100
107
|
* ethersProviderUrl: 'https://sepolia.infura.io/v3/your-key'
|
|
101
108
|
* });
|
|
102
109
|
* ```
|
|
@@ -107,8 +114,10 @@ export const useTransactionSigner = () => {
|
|
|
107
114
|
}
|
|
108
115
|
try {
|
|
109
116
|
console.log('[useTransactionSigner] Initializing PERS transaction signer...');
|
|
117
|
+
// TODO: accept direct project key in signer sdk
|
|
110
118
|
const signerSDK = await createPersSignerSDK({
|
|
111
119
|
tenantId: config?.tenantId,
|
|
120
|
+
// projectKey: config?.projectKey,
|
|
112
121
|
ethersProviderUrl: config?.ethersProviderUrl || DEFAULT_ETHERS_PROVIDER
|
|
113
122
|
});
|
|
114
123
|
signerSDKRef.current = signerSDK;
|
|
@@ -166,9 +175,15 @@ export const useTransactionSigner = () => {
|
|
|
166
175
|
email: currentUser.email || jwtUserInfo.email,
|
|
167
176
|
id: currentUser.id || jwtUserInfo.userId
|
|
168
177
|
};
|
|
169
|
-
//
|
|
178
|
+
// Get PERS access token from the main SDK
|
|
179
|
+
const authProvider = sdk.authProvider || sdk._authProvider;
|
|
180
|
+
const persAccessToken = authProvider ? await authProvider.getToken() : '';
|
|
181
|
+
// Authenticate user with blockchain signer and pass PERS token
|
|
170
182
|
console.log('[useTransactionSigner] Authenticating user with signer:', signerUserInfo.identifier);
|
|
171
|
-
const signerUser = await signerSDKRef.current.authenticateUser(
|
|
183
|
+
const signerUser = await signerSDKRef.current.authenticateUser({
|
|
184
|
+
...signerUserInfo,
|
|
185
|
+
persAccessToken: persAccessToken
|
|
186
|
+
});
|
|
172
187
|
// Sign the PERS transaction using JWT
|
|
173
188
|
console.log('[useTransactionSigner] Signing PERS transaction with JWT containing transaction data');
|
|
174
189
|
const result = await signerSDKRef.current.signPersTransaction(signerUser, jwt);
|
package/dist/index.js
CHANGED
|
@@ -30318,27 +30318,34 @@ const useTransactionSigner = () => {
|
|
|
30318
30318
|
const signerSDKRef = react.useRef(null);
|
|
30319
30319
|
// Auto-initialize signer when user is authenticated and real SDK is available
|
|
30320
30320
|
react.useEffect(() => {
|
|
30321
|
-
if (isInitialized && isAuthenticated && user && !isSignerInitialized) {
|
|
30321
|
+
if (isInitialized && isAuthenticated && user && !isSignerInitialized && sdk) {
|
|
30322
30322
|
console.log('[useTransactionSigner] Auto-initializing PERS transaction signer...');
|
|
30323
|
+
// Get configuration from the PERS SDK
|
|
30324
|
+
const sdkConfig = sdk.config || {};
|
|
30325
|
+
const apiProjectKey = sdkConfig.apiProjectKey || 'demo-project-key';
|
|
30326
|
+
const tenantId = sdkConfig.tenantId || 'vq-demo';
|
|
30323
30327
|
initializeSigner({
|
|
30324
|
-
tenantId:
|
|
30328
|
+
tenantId: tenantId,
|
|
30329
|
+
projectKey: apiProjectKey,
|
|
30325
30330
|
ethersProviderUrl: DEFAULT_ETHERS_PROVIDER
|
|
30326
30331
|
}).catch((error) => {
|
|
30327
30332
|
console.error('[useTransactionSigner] Auto-initialization failed:', error);
|
|
30328
30333
|
});
|
|
30329
30334
|
}
|
|
30330
|
-
}, [isInitialized, isAuthenticated, user, isSignerInitialized,
|
|
30335
|
+
}, [isInitialized, isAuthenticated, user, isSignerInitialized, sdk]);
|
|
30331
30336
|
/**
|
|
30332
30337
|
* Initialize the blockchain signer with configuration
|
|
30333
30338
|
*
|
|
30334
30339
|
* @param config - Signer configuration options
|
|
30335
30340
|
* @param config.tenantId - Multi-tenant identifier for the signer
|
|
30341
|
+
* @param config.projectKey - PERS project API key for authentication
|
|
30336
30342
|
* @param config.ethersProviderUrl - Custom blockchain provider URL
|
|
30337
30343
|
*
|
|
30338
30344
|
* @example
|
|
30339
30345
|
* ```typescript
|
|
30340
30346
|
* await initializeSigner({
|
|
30341
30347
|
* tenantId: 'my-tenant-id',
|
|
30348
|
+
* projectKey: 'your-pers-api-key',
|
|
30342
30349
|
* ethersProviderUrl: 'https://sepolia.infura.io/v3/your-key'
|
|
30343
30350
|
* });
|
|
30344
30351
|
* ```
|
|
@@ -30349,8 +30356,10 @@ const useTransactionSigner = () => {
|
|
|
30349
30356
|
}
|
|
30350
30357
|
try {
|
|
30351
30358
|
console.log('[useTransactionSigner] Initializing PERS transaction signer...');
|
|
30359
|
+
// TODO: accept direct project key in signer sdk
|
|
30352
30360
|
const signerSDK = await createPersSignerSDK({
|
|
30353
30361
|
tenantId: config?.tenantId,
|
|
30362
|
+
// projectKey: config?.projectKey,
|
|
30354
30363
|
ethersProviderUrl: config?.ethersProviderUrl || DEFAULT_ETHERS_PROVIDER
|
|
30355
30364
|
});
|
|
30356
30365
|
signerSDKRef.current = signerSDK;
|
|
@@ -30408,9 +30417,15 @@ const useTransactionSigner = () => {
|
|
|
30408
30417
|
email: currentUser.email || jwtUserInfo.email,
|
|
30409
30418
|
id: currentUser.id || jwtUserInfo.userId
|
|
30410
30419
|
};
|
|
30411
|
-
//
|
|
30420
|
+
// Get PERS access token from the main SDK
|
|
30421
|
+
const authProvider = sdk.authProvider || sdk._authProvider;
|
|
30422
|
+
const persAccessToken = authProvider ? await authProvider.getToken() : '';
|
|
30423
|
+
// Authenticate user with blockchain signer and pass PERS token
|
|
30412
30424
|
console.log('[useTransactionSigner] Authenticating user with signer:', signerUserInfo.identifier);
|
|
30413
|
-
const signerUser = await signerSDKRef.current.authenticateUser(
|
|
30425
|
+
const signerUser = await signerSDKRef.current.authenticateUser({
|
|
30426
|
+
...signerUserInfo,
|
|
30427
|
+
persAccessToken: persAccessToken
|
|
30428
|
+
});
|
|
30414
30429
|
// Sign the PERS transaction using JWT
|
|
30415
30430
|
console.log('[useTransactionSigner] Signing PERS transaction with JWT containing transaction data');
|
|
30416
30431
|
const result = await signerSDKRef.current.signPersTransaction(signerUser, jwt);
|