@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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Transaction, VersionedTransaction } from '@solana/web3.js';
|
|
1
2
|
export type SetOptions = {
|
|
2
3
|
shouldSubmitTx?: boolean;
|
|
3
4
|
_overrides?: {
|
|
@@ -51,3 +52,5 @@ export declare function clearCache(path?: string, opts?: {
|
|
|
51
52
|
}): void;
|
|
52
53
|
export declare function getFiles(path: string): Promise<any>;
|
|
53
54
|
export declare function setFile(path: string, file: File | null): Promise<boolean>;
|
|
55
|
+
export declare function signMessage(message: string): Promise<string>;
|
|
56
|
+
export declare function signTransaction(transaction: Transaction | VersionedTransaction): Promise<Transaction | VersionedTransaction>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { init } from './client/config';
|
|
2
2
|
export { getConfig, ClientConfig } from './client/config';
|
|
3
|
-
export { get, set, setMany, setFile, getFiles, runQuery, runQueryMany, runExpression, runExpressionMany, SetOptions, RunExpressionOptions, RunExpressionResult } from './client/operations';
|
|
3
|
+
export { get, set, setMany, setFile, getFiles, runQuery, runQueryMany, runExpression, runExpressionMany, signMessage, signTransaction, SetOptions, RunExpressionOptions, RunExpressionResult } from './client/operations';
|
|
4
4
|
export { subscribe } from './client/subscription';
|
|
5
5
|
export * from './types';
|
|
6
6
|
export { getIdToken } from './utils/utils';
|
package/dist/index.js
CHANGED
|
@@ -2867,24 +2867,15 @@ async function genSolanaMessage(address, nonce) {
|
|
|
2867
2867
|
const statement = "Sign this message to authenticate with our application.";
|
|
2868
2868
|
const currentDate = new Date();
|
|
2869
2869
|
const issuedAt = currentDate.toISOString();
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
const expirationDate = new Date(currentDate.getTime() + 5 * 60 * 1000);
|
|
2873
|
-
const expirationTime = expirationDate.toISOString();
|
|
2874
|
-
return `${statement}\n\n` +
|
|
2875
|
-
`Wallet address:\n${address}\n\n` +
|
|
2876
|
-
`Domain: ${domain}\n` +
|
|
2877
|
-
`Origin: ${origin}\n` +
|
|
2878
|
-
`Nonce: ${nonce}\n` +
|
|
2879
|
-
`Issued At: ${issuedAt}\n` +
|
|
2880
|
-
`Expiration Time: ${expirationTime}`;
|
|
2881
|
-
}
|
|
2882
|
-
// Backward compatible: without nonce (for server-side usage)
|
|
2870
|
+
const expirationDate = new Date(currentDate.getTime() + 5 * 60 * 1000);
|
|
2871
|
+
const expirationTime = expirationDate.toISOString();
|
|
2883
2872
|
return `${statement}\n\n` +
|
|
2884
2873
|
`Wallet address:\n${address}\n\n` +
|
|
2885
2874
|
`Domain: ${domain}\n` +
|
|
2886
2875
|
`Origin: ${origin}\n` +
|
|
2887
|
-
`
|
|
2876
|
+
`Nonce: ${nonce}\n` +
|
|
2877
|
+
`Issued At: ${issuedAt}\n` +
|
|
2878
|
+
`Expiration Time: ${expirationTime}`;
|
|
2888
2879
|
}
|
|
2889
2880
|
// ─────────────────────────────────────────────────────────────
|
|
2890
2881
|
// Serialization Helpers
|
|
@@ -3052,6 +3043,7 @@ function loadKeypairFromEnv() {
|
|
|
3052
3043
|
async function createSession() {
|
|
3053
3044
|
const kp = loadKeypairFromEnv();
|
|
3054
3045
|
const address = kp.publicKey.toBase58();
|
|
3046
|
+
/* fetch nonce from auth API */
|
|
3055
3047
|
const nonce = await genAuthNonce();
|
|
3056
3048
|
const message = await genSolanaMessage(address, nonce);
|
|
3057
3049
|
/* sign the message */
|
|
@@ -3551,8 +3543,11 @@ async function setMany(many, options) {
|
|
|
3551
3543
|
async function handleOffchainTransaction(tx, authProvider, options) {
|
|
3552
3544
|
var _a, _b, _c, _d, _e;
|
|
3553
3545
|
const config = await getConfig();
|
|
3554
|
-
// 1. Sign the transaction message using
|
|
3555
|
-
|
|
3546
|
+
// 1. Sign the transaction message using mock signing for offchain transactions
|
|
3547
|
+
// Use signMessageMock if available (OffchainAuthProvider), otherwise fall back to signMessage
|
|
3548
|
+
const signature = authProvider.signMessageMock
|
|
3549
|
+
? await authProvider.signMessageMock(tx.message)
|
|
3550
|
+
: await authProvider.signMessage(tx.message);
|
|
3556
3551
|
// 2. Create signed transaction
|
|
3557
3552
|
const signedTx = {
|
|
3558
3553
|
transaction: tx,
|
|
@@ -3663,6 +3658,20 @@ async function setFile(path, file) {
|
|
|
3663
3658
|
// Optionally return the file's public URL or some confirmation
|
|
3664
3659
|
return true;
|
|
3665
3660
|
}
|
|
3661
|
+
async function signMessage(message) {
|
|
3662
|
+
const config = await getConfig();
|
|
3663
|
+
if (!config.authProvider) {
|
|
3664
|
+
throw new Error('Auth provider not initialized. Please call init() first.');
|
|
3665
|
+
}
|
|
3666
|
+
return config.authProvider.signMessage(message);
|
|
3667
|
+
}
|
|
3668
|
+
async function signTransaction(transaction) {
|
|
3669
|
+
const config = await getConfig();
|
|
3670
|
+
if (!config.authProvider) {
|
|
3671
|
+
throw new Error('Auth provider not initialized. Please call init() first.');
|
|
3672
|
+
}
|
|
3673
|
+
return config.authProvider.signTransaction(transaction);
|
|
3674
|
+
}
|
|
3666
3675
|
|
|
3667
3676
|
const activeConnections = {};
|
|
3668
3677
|
const responseCache = {};
|
|
@@ -3884,6 +3893,8 @@ exports.runQueryMany = runQueryMany;
|
|
|
3884
3893
|
exports.set = set;
|
|
3885
3894
|
exports.setFile = setFile;
|
|
3886
3895
|
exports.setMany = setMany;
|
|
3896
|
+
exports.signMessage = signMessage;
|
|
3887
3897
|
exports.signSessionCreateMessage = signSessionCreateMessage;
|
|
3898
|
+
exports.signTransaction = signTransaction;
|
|
3888
3899
|
exports.subscribe = subscribe;
|
|
3889
3900
|
//# sourceMappingURL=index.js.map
|