@bounded-sh/core 0.0.14 → 0.0.15
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.js +12 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3800,24 +3800,19 @@ async function buildSetDocumentsTransaction(connection, idl, anchorProvider, pay
|
|
|
3800
3800
|
/* ------------------------------------------------------------------ */
|
|
3801
3801
|
/* ENV helpers */
|
|
3802
3802
|
/* ------------------------------------------------------------------ */
|
|
3803
|
-
// Canonical `BOUNDED_PRIVATE_KEY` (matches the CLI)
|
|
3804
|
-
//
|
|
3805
|
-
|
|
3806
|
-
const
|
|
3803
|
+
// Canonical `BOUNDED_PRIVATE_KEY` (matches the CLI). Only consulted when no
|
|
3804
|
+
// explicit keypair was provided (createWalletClient passes one).
|
|
3805
|
+
const ENV_KEYPAIR = "BOUNDED_PRIVATE_KEY";
|
|
3806
|
+
const LEGACY_ENV_KEYPAIR = "BOUNDED_SOLANA_KEYPAIR";
|
|
3807
3807
|
function loadKeypairFromEnv() {
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
const v = process.env[name];
|
|
3812
|
-
if (v) {
|
|
3813
|
-
secret = v;
|
|
3814
|
-
found = name;
|
|
3815
|
-
break;
|
|
3816
|
-
}
|
|
3808
|
+
if (process.env[LEGACY_ENV_KEYPAIR]) {
|
|
3809
|
+
throw new Error(`${LEGACY_ENV_KEYPAIR} is no longer supported. Set ${ENV_KEYPAIR} instead, ` +
|
|
3810
|
+
`or pass an explicit keypair via createWalletClient({ keypair }).`);
|
|
3817
3811
|
}
|
|
3812
|
+
const secret = process.env[ENV_KEYPAIR];
|
|
3818
3813
|
if (!secret) {
|
|
3819
3814
|
throw new Error(`No server keypair for this top-level call. The top-level get/set/subscribe/etc. use an ` +
|
|
3820
|
-
`AMBIENT session — set ${
|
|
3815
|
+
`AMBIENT session — set ${ENV_KEYPAIR} to a base-58 secret key (or JSON array) to provide one. ` +
|
|
3821
3816
|
`If you already created a wallet with createWalletClient({ keypair }), call ITS methods instead ` +
|
|
3822
3817
|
`(client.subscribe / client.set / client.get): that client is self-contained and deliberately does ` +
|
|
3823
3818
|
`not set the ambient session, so the top-level functions can't see it.`);
|
|
@@ -3829,7 +3824,7 @@ function loadKeypairFromEnv() {
|
|
|
3829
3824
|
return web3_js.Keypair.fromSecretKey(secretKey);
|
|
3830
3825
|
}
|
|
3831
3826
|
catch (err) {
|
|
3832
|
-
throw new Error(`Unable to parse ${
|
|
3827
|
+
throw new Error(`Unable to parse ${ENV_KEYPAIR}. Ensure it is valid base-58 or JSON.`);
|
|
3833
3828
|
}
|
|
3834
3829
|
}
|
|
3835
3830
|
/* ------------------------------------------------------------------ */
|
|
@@ -3896,7 +3891,7 @@ class ServerSessionManager {
|
|
|
3896
3891
|
this.session = session;
|
|
3897
3892
|
}
|
|
3898
3893
|
/* ---------------------------------------------- *
|
|
3899
|
-
* CLEAR (e.g. after logout
|
|
3894
|
+
* CLEAR (e.g. after explicit logout)
|
|
3900
3895
|
* ---------------------------------------------- */
|
|
3901
3896
|
clearSession() {
|
|
3902
3897
|
this.session = null;
|
|
@@ -3920,11 +3915,6 @@ class ServerSessionManager {
|
|
|
3920
3915
|
/* The default singleton instance (reads keypair from env) */
|
|
3921
3916
|
ServerSessionManager.instance = new ServerSessionManager();
|
|
3922
3917
|
|
|
3923
|
-
var serverSessionManager = /*#__PURE__*/Object.freeze({
|
|
3924
|
-
__proto__: null,
|
|
3925
|
-
ServerSessionManager: ServerSessionManager
|
|
3926
|
-
});
|
|
3927
|
-
|
|
3928
3918
|
/**
|
|
3929
3919
|
* Safe base64 helpers for bounded-core.
|
|
3930
3920
|
*
|
|
@@ -4149,13 +4139,6 @@ async function refreshAuthSessionOnce(appId, isServer) {
|
|
|
4149
4139
|
async function makeApiRequest(method, urlPath, data, _overrides) {
|
|
4150
4140
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
4151
4141
|
const config = await getConfig();
|
|
4152
|
-
let hasRetriedAfterServerSessionReset = false;
|
|
4153
|
-
const clearServerSession = async () => {
|
|
4154
|
-
if (!config.isServer)
|
|
4155
|
-
return;
|
|
4156
|
-
const { ServerSessionManager } = await Promise.resolve().then(function () { return serverSessionManager; });
|
|
4157
|
-
ServerSessionManager.instance.clearSession();
|
|
4158
|
-
};
|
|
4159
4142
|
async function executeRequest() {
|
|
4160
4143
|
var _a;
|
|
4161
4144
|
// When _getAuthHeaders is provided (wallet client), use it as the sole auth source.
|
|
@@ -4205,13 +4188,7 @@ async function makeApiRequest(method, urlPath, data, _overrides) {
|
|
|
4205
4188
|
}
|
|
4206
4189
|
return await executeRequest();
|
|
4207
4190
|
}
|
|
4208
|
-
catch (
|
|
4209
|
-
// Server-side fallback: clear global session and retry once
|
|
4210
|
-
if (config.isServer && !hasRetriedAfterServerSessionReset) {
|
|
4211
|
-
hasRetriedAfterServerSessionReset = true;
|
|
4212
|
-
await clearServerSession();
|
|
4213
|
-
return await executeRequest();
|
|
4214
|
-
}
|
|
4191
|
+
catch (_j) {
|
|
4215
4192
|
throw error;
|
|
4216
4193
|
}
|
|
4217
4194
|
}
|