@pooflabs/core 0.0.18 → 0.0.20
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/client/operations.d.ts +3 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +27 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -17
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/utils/sol/sol-utils.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2847,24 +2847,15 @@ async function genSolanaMessage(address, nonce) {
|
|
|
2847
2847
|
const statement = "Sign this message to authenticate with our application.";
|
|
2848
2848
|
const currentDate = new Date();
|
|
2849
2849
|
const issuedAt = currentDate.toISOString();
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
const expirationDate = new Date(currentDate.getTime() + 5 * 60 * 1000);
|
|
2853
|
-
const expirationTime = expirationDate.toISOString();
|
|
2854
|
-
return `${statement}\n\n` +
|
|
2855
|
-
`Wallet address:\n${address}\n\n` +
|
|
2856
|
-
`Domain: ${domain}\n` +
|
|
2857
|
-
`Origin: ${origin}\n` +
|
|
2858
|
-
`Nonce: ${nonce}\n` +
|
|
2859
|
-
`Issued At: ${issuedAt}\n` +
|
|
2860
|
-
`Expiration Time: ${expirationTime}`;
|
|
2861
|
-
}
|
|
2862
|
-
// Backward compatible: without nonce (for server-side usage)
|
|
2850
|
+
const expirationDate = new Date(currentDate.getTime() + 5 * 60 * 1000);
|
|
2851
|
+
const expirationTime = expirationDate.toISOString();
|
|
2863
2852
|
return `${statement}\n\n` +
|
|
2864
2853
|
`Wallet address:\n${address}\n\n` +
|
|
2865
2854
|
`Domain: ${domain}\n` +
|
|
2866
2855
|
`Origin: ${origin}\n` +
|
|
2867
|
-
`
|
|
2856
|
+
`Nonce: ${nonce}\n` +
|
|
2857
|
+
`Issued At: ${issuedAt}\n` +
|
|
2858
|
+
`Expiration Time: ${expirationTime}`;
|
|
2868
2859
|
}
|
|
2869
2860
|
// ─────────────────────────────────────────────────────────────
|
|
2870
2861
|
// Serialization Helpers
|
|
@@ -3032,6 +3023,7 @@ function loadKeypairFromEnv() {
|
|
|
3032
3023
|
async function createSession() {
|
|
3033
3024
|
const kp = loadKeypairFromEnv();
|
|
3034
3025
|
const address = kp.publicKey.toBase58();
|
|
3026
|
+
/* fetch nonce from auth API */
|
|
3035
3027
|
const nonce = await genAuthNonce();
|
|
3036
3028
|
const message = await genSolanaMessage(address, nonce);
|
|
3037
3029
|
/* sign the message */
|
|
@@ -3531,8 +3523,11 @@ async function setMany(many, options) {
|
|
|
3531
3523
|
async function handleOffchainTransaction(tx, authProvider, options) {
|
|
3532
3524
|
var _a, _b, _c, _d, _e;
|
|
3533
3525
|
const config = await getConfig();
|
|
3534
|
-
// 1. Sign the transaction message using
|
|
3535
|
-
|
|
3526
|
+
// 1. Sign the transaction message using mock signing for offchain transactions
|
|
3527
|
+
// Use signMessageMock if available (OffchainAuthProvider), otherwise fall back to signMessage
|
|
3528
|
+
const signature = authProvider.signMessageMock
|
|
3529
|
+
? await authProvider.signMessageMock(tx.message)
|
|
3530
|
+
: await authProvider.signMessage(tx.message);
|
|
3536
3531
|
// 2. Create signed transaction
|
|
3537
3532
|
const signedTx = {
|
|
3538
3533
|
transaction: tx,
|
|
@@ -3643,6 +3638,20 @@ async function setFile(path, file) {
|
|
|
3643
3638
|
// Optionally return the file's public URL or some confirmation
|
|
3644
3639
|
return true;
|
|
3645
3640
|
}
|
|
3641
|
+
async function signMessage(message) {
|
|
3642
|
+
const config = await getConfig();
|
|
3643
|
+
if (!config.authProvider) {
|
|
3644
|
+
throw new Error('Auth provider not initialized. Please call init() first.');
|
|
3645
|
+
}
|
|
3646
|
+
return config.authProvider.signMessage(message);
|
|
3647
|
+
}
|
|
3648
|
+
async function signTransaction(transaction) {
|
|
3649
|
+
const config = await getConfig();
|
|
3650
|
+
if (!config.authProvider) {
|
|
3651
|
+
throw new Error('Auth provider not initialized. Please call init() first.');
|
|
3652
|
+
}
|
|
3653
|
+
return config.authProvider.signTransaction(transaction);
|
|
3654
|
+
}
|
|
3646
3655
|
|
|
3647
3656
|
const activeConnections = {};
|
|
3648
3657
|
const responseCache = {};
|
|
@@ -3843,5 +3852,5 @@ async function removeSubscription(connectionKey, subscription) {
|
|
|
3843
3852
|
delete activeConnections[connectionKey];
|
|
3844
3853
|
}
|
|
3845
3854
|
|
|
3846
|
-
export { ServerSessionManager, WebSessionManager, buildSetDocumentsTransaction, convertRemainingAccounts, createSessionWithPrivy, createSessionWithSignature, genAuthNonce, genSolanaMessage, get, getConfig, getFiles, getIdToken, init, refreshSession, runExpression, runExpressionMany, runQuery, runQueryMany, set, setFile, setMany, signSessionCreateMessage, subscribe };
|
|
3855
|
+
export { ServerSessionManager, WebSessionManager, buildSetDocumentsTransaction, convertRemainingAccounts, createSessionWithPrivy, createSessionWithSignature, genAuthNonce, genSolanaMessage, get, getConfig, getFiles, getIdToken, init, refreshSession, runExpression, runExpressionMany, runQuery, runQueryMany, set, setFile, setMany, signMessage, signSessionCreateMessage, signTransaction, subscribe };
|
|
3847
3856
|
//# sourceMappingURL=index.mjs.map
|