@buildonspark/spark-sdk 0.1.41 → 0.1.43
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/CHANGELOG.md +15 -0
- package/android/src/main/jniLibs/arm64-v8a/libuniffi_spark_frost.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libuniffi_spark_frost.so +0 -0
- package/android/src/main/jniLibs/x86/libuniffi_spark_frost.so +0 -0
- package/android/src/main/jniLibs/x86_64/libuniffi_spark_frost.so +0 -0
- package/dist/LightningSendFeeEstimateInput-BgOhEAI-.d.cts +10 -0
- package/dist/LightningSendFeeEstimateInput-BgOhEAI-.d.ts +10 -0
- package/dist/{RequestLightningSendInput-mXUWn_cp.d.ts → RequestLightningSendInput-D7fZdT4A.d.ts} +35 -16
- package/dist/{RequestLightningSendInput-DXcLoiCe.d.cts → RequestLightningSendInput-Na1mHdWg.d.cts} +35 -16
- package/dist/address/index.cjs +38 -7
- package/dist/address/index.d.cts +2 -2
- package/dist/address/index.d.ts +2 -2
- package/dist/address/index.js +3 -3
- package/dist/{chunk-ATEHMLKP.js → chunk-6AFUC5M2.js} +1 -1
- package/dist/{chunk-ZXDE2XMU.js → chunk-BUTZWYBW.js} +9 -6
- package/dist/{chunk-7EFSUADA.js → chunk-DOA6QXYQ.js} +1 -0
- package/dist/{chunk-J5W5Q2ZP.js → chunk-DQYKQJRZ.js} +291 -7
- package/dist/{chunk-TWF35O6M.js → chunk-GSI4OLXZ.js} +32 -1
- package/dist/{chunk-2ZXXLPG2.js → chunk-GYQR4B4P.js} +5 -4
- package/dist/{chunk-ROKY5KS4.js → chunk-HRQRRDSS.js} +53 -15
- package/dist/{chunk-YEZDPUFY.js → chunk-IRW5TWMH.js} +8 -8
- package/dist/{chunk-7VMYMQLF.js → chunk-NSJF5F5O.js} +1 -1
- package/dist/{chunk-TM4TOEOX.js → chunk-O4RYNJNB.js} +3 -3
- package/dist/{chunk-MGPRLH6Q.js → chunk-QNNSEJ4P.js} +1 -1
- package/dist/{chunk-UKT6OFLO.js → chunk-TIUBYNN5.js} +13 -7
- package/dist/{chunk-6YVPOQ2A.js → chunk-TOSP3INR.js} +235 -143
- package/dist/chunk-VFJQNBFX.js +21 -0
- package/dist/{chunk-KKSU7OZO.js → chunk-WWOTVNPP.js} +195 -67
- package/dist/{chunk-HK6LPV6Z.js → chunk-Z5HIAYFT.js} +1 -1
- package/dist/graphql/objects/index.cjs +229 -135
- package/dist/graphql/objects/index.d.cts +54 -9
- package/dist/graphql/objects/index.d.ts +54 -9
- package/dist/graphql/objects/index.js +3 -3
- package/dist/{index-OSDtPMmC.d.ts → index-7RYRH5wc.d.ts} +10 -8
- package/dist/{index-CFh4uWzi.d.cts → index-BJOc8Ur-.d.cts} +10 -8
- package/dist/index.cjs +790 -315
- package/dist/index.d.cts +8 -7
- package/dist/index.d.ts +8 -7
- package/dist/index.js +26 -26
- package/dist/index.node.cjs +790 -315
- package/dist/index.node.d.cts +9 -8
- package/dist/index.node.d.ts +9 -8
- package/dist/index.node.js +26 -26
- package/dist/native/index.cjs +812 -332
- package/dist/native/index.d.cts +53 -18
- package/dist/native/index.d.ts +53 -18
- package/dist/native/index.js +659 -181
- package/dist/{network-BiwBmoOg.d.cts → network-D5lKssVl.d.cts} +1 -1
- package/dist/{network-BF2GYPye.d.ts → network-xkBSpaTn.d.ts} +1 -1
- package/dist/proto/lrc20.d.cts +1 -1
- package/dist/proto/lrc20.d.ts +1 -1
- package/dist/proto/spark.d.cts +1 -1
- package/dist/proto/spark.d.ts +1 -1
- package/dist/proto/spark_token.d.cts +1 -1
- package/dist/proto/spark_token.d.ts +1 -1
- package/dist/{sdk-types-CfhdFnsA.d.cts → sdk-types-B-q9py_P.d.cts} +1 -1
- package/dist/{sdk-types-MnQrHolg.d.ts → sdk-types-BPoPgzda.d.ts} +1 -1
- package/dist/services/config.cjs +118 -69
- package/dist/services/config.d.cts +6 -4
- package/dist/services/config.d.ts +6 -4
- package/dist/services/config.js +9 -9
- package/dist/services/connection.cjs +95 -15
- package/dist/services/connection.d.cts +6 -4
- package/dist/services/connection.d.ts +6 -4
- package/dist/services/connection.js +3 -3
- package/dist/services/index.cjs +487 -117
- package/dist/services/index.d.cts +5 -4
- package/dist/services/index.d.ts +5 -4
- package/dist/services/index.js +19 -19
- package/dist/services/lrc-connection.cjs +50 -7
- package/dist/services/lrc-connection.d.cts +5 -4
- package/dist/services/lrc-connection.d.ts +5 -4
- package/dist/services/lrc-connection.js +3 -3
- package/dist/services/token-transactions.cjs +351 -36
- package/dist/services/token-transactions.d.cts +5 -4
- package/dist/services/token-transactions.d.ts +5 -4
- package/dist/services/token-transactions.js +6 -6
- package/dist/services/wallet-config.cjs +1 -0
- package/dist/services/wallet-config.d.cts +6 -4
- package/dist/services/wallet-config.d.ts +6 -4
- package/dist/services/wallet-config.js +1 -1
- package/dist/signer/signer.cjs +117 -64
- package/dist/signer/signer.d.cts +4 -3
- package/dist/signer/signer.d.ts +4 -3
- package/dist/signer/signer.js +15 -7
- package/dist/{signer-CylxIujU.d.ts → signer-IO3oMRNj.d.cts} +2 -1
- package/dist/{signer-BhLS7SYR.d.cts → signer-wqesWifN.d.ts} +2 -1
- package/dist/{spark-DjR1b3TC.d.cts → spark-CDm4gqS6.d.cts} +1 -1
- package/dist/{spark-DjR1b3TC.d.ts → spark-CDm4gqS6.d.ts} +1 -1
- package/dist/types/index.cjs +282 -188
- package/dist/types/index.d.cts +7 -6
- package/dist/types/index.d.ts +7 -6
- package/dist/types/index.js +3 -3
- package/dist/utils/index.cjs +90 -58
- package/dist/utils/index.d.cts +6 -5
- package/dist/utils/index.d.ts +6 -5
- package/dist/utils/index.js +16 -16
- package/ios/spark_frostFFI.xcframework/ios-arm64/SparkFrost +0 -0
- package/ios/spark_frostFFI.xcframework/ios-arm64/spark_frostFFI.framework/spark_frostFFI +0 -0
- package/ios/spark_frostFFI.xcframework/ios-arm64_x86_64-simulator/SparkFrost +0 -0
- package/ios/spark_frostFFI.xcframework/ios-arm64_x86_64-simulator/spark_frostFFI.framework/spark_frostFFI +0 -0
- package/ios/spark_frostFFI.xcframework/macos-arm64_x86_64/spark_frostFFI.framework/spark_frostFFI +0 -0
- package/package.json +4 -4
- package/src/constants.ts +21 -0
- package/src/errors/base.ts +43 -1
- package/src/graphql/client.ts +4 -0
- package/src/graphql/mutations/RequestLightningSend.ts +2 -0
- package/src/graphql/objects/ClaimStaticDepositInput.ts +1 -1
- package/src/graphql/objects/ClaimStaticDepositStatus.ts +4 -2
- package/src/graphql/objects/Connection.ts +7 -7
- package/src/graphql/objects/CoopExitFeeEstimate.ts +1 -1
- package/src/graphql/objects/CoopExitFeeQuote.ts +202 -0
- package/src/graphql/objects/CoopExitFeeQuoteInput.ts +41 -0
- package/src/graphql/objects/CoopExitFeeQuoteOutput.ts +45 -0
- package/src/graphql/objects/CoopExitRequest.ts +21 -0
- package/src/graphql/objects/CurrencyUnit.ts +26 -28
- package/src/graphql/objects/Entity.ts +84 -0
- package/src/graphql/objects/Invoice.ts +2 -2
- package/src/graphql/objects/Leaf.ts +1 -1
- package/src/graphql/objects/LeavesSwapFeeEstimateOutput.ts +1 -1
- package/src/graphql/objects/LeavesSwapRequest.ts +6 -0
- package/src/graphql/objects/LightningReceiveRequest.ts +11 -0
- package/src/graphql/objects/LightningSendFeeEstimateInput.ts +8 -0
- package/src/graphql/objects/LightningSendFeeEstimateOutput.ts +1 -1
- package/src/graphql/objects/LightningSendRequest.ts +3 -0
- package/src/graphql/objects/RequestCoopExitInput.ts +8 -0
- package/src/graphql/objects/RequestLeavesSwapInput.ts +5 -1
- package/src/graphql/objects/RequestLightningReceiveInput.ts +9 -2
- package/src/graphql/objects/RequestLightningSendInput.ts +8 -0
- package/src/graphql/objects/SparkCoopExitRequestStatus.ts +2 -0
- package/src/graphql/objects/SparkUserRequestType.ts +2 -0
- package/src/graphql/objects/SparkWalletUser.ts +20 -0
- package/src/graphql/objects/UserRequest.ts +32 -0
- package/src/graphql/objects/VerifyChallengeInput.ts +1 -1
- package/src/graphql/objects/index.ts +12 -3
- package/src/graphql/queries/LightningSendFeeEstimate.ts +2 -0
- package/src/logger.ts +3 -0
- package/src/native/index.ts +1 -0
- package/src/services/config.ts +4 -0
- package/src/services/connection.ts +68 -29
- package/src/services/coop-exit.ts +1 -1
- package/src/services/lightning.ts +25 -1
- package/src/services/lrc-connection.ts +3 -3
- package/src/services/token-transactions.ts +6 -2
- package/src/services/wallet-config.ts +2 -0
- package/src/signer/signer.ts +4 -1
- package/src/spark-wallet/spark-wallet.ts +51 -15
- package/src/spark-wallet/types.ts +1 -0
- package/src/tests/errors.test.ts +58 -0
- package/src/tests/integration/lightning.test.ts +184 -0
- package/src/tests/integration/ssp/static_deposit.test.ts +1 -2
- package/src/tests/tokens.test.ts +52 -3
- package/src/utils/token-hashing.ts +335 -1
- package/dist/LightningSendFeeEstimateInput-CJvPnCSB.d.cts +0 -5
- package/dist/LightningSendFeeEstimateInput-CJvPnCSB.d.ts +0 -5
- package/dist/chunk-HKAKEKCE.js +0 -8
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { HasLrc20WalletApiConfig, LRC20WalletApiConfig } from '@buildonspark/lrc20-sdk';
|
|
2
|
-
import { H as HasSspClientOptions, B as SspClientOptions } from '../RequestLightningSendInput-
|
|
2
|
+
import { H as HasSspClientOptions, B as SspClientOptions } from '../RequestLightningSendInput-D7fZdT4A.js';
|
|
3
3
|
import { B as BitcoinNetwork } from '../BitcoinNetwork-TnABML0T.js';
|
|
4
|
-
import { S as SparkSigner } from '../signer-
|
|
5
|
-
import { N as Network, a as NetworkType } from '../network-
|
|
4
|
+
import { S as SparkSigner } from '../signer-wqesWifN.js';
|
|
5
|
+
import { N as Network, a as NetworkType } from '../network-xkBSpaTn.js';
|
|
6
6
|
import { ConfigOptions, SigningOperator } from './wallet-config.js';
|
|
7
7
|
import '@lightsparkdev/core';
|
|
8
8
|
import '@scure/bip32';
|
|
9
|
-
import '../spark-
|
|
9
|
+
import '../spark-CDm4gqS6.js';
|
|
10
10
|
import '@bufbuild/protobuf/wire';
|
|
11
11
|
import 'nice-grpc-common';
|
|
12
12
|
import '@scure/btc-signer';
|
|
13
13
|
import 'bitcoinjs-lib';
|
|
14
|
+
import '@buildonspark/lrc20-sdk/lrc/types';
|
|
14
15
|
|
|
15
16
|
declare class WalletConfigService implements HasLrc20WalletApiConfig, HasSspClientOptions {
|
|
16
17
|
private readonly config;
|
|
@@ -32,6 +33,7 @@ declare class WalletConfigService implements HasLrc20WalletApiConfig, HasSspClie
|
|
|
32
33
|
getNetworkProto(): number;
|
|
33
34
|
getTokenSignatures(): "ECDSA" | "SCHNORR";
|
|
34
35
|
getTokenTransactionVersion(): "V0" | "V1";
|
|
36
|
+
getTokenValidityDurationSeconds(): number;
|
|
35
37
|
getElectrsUrl(): string;
|
|
36
38
|
getSspIdentityPublicKey(): string;
|
|
37
39
|
}
|
package/dist/services/config.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WalletConfigService
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-7EFSUADA.js";
|
|
7
|
-
import "../chunk-7VMYMQLF.js";
|
|
3
|
+
} from "../chunk-BUTZWYBW.js";
|
|
4
|
+
import "../chunk-Z5HIAYFT.js";
|
|
5
|
+
import "../chunk-DOA6QXYQ.js";
|
|
8
6
|
import "../chunk-HMLOC6TE.js";
|
|
9
|
-
import "../chunk-HKAKEKCE.js";
|
|
10
|
-
import "../chunk-MGPRLH6Q.js";
|
|
11
|
-
import "../chunk-VTUGIIWI.js";
|
|
12
|
-
import "../chunk-TWF35O6M.js";
|
|
13
7
|
import "../chunk-M6A4KFIG.js";
|
|
8
|
+
import "../chunk-TIUBYNN5.js";
|
|
9
|
+
import "../chunk-VFJQNBFX.js";
|
|
10
|
+
import "../chunk-NSJF5F5O.js";
|
|
11
|
+
import "../chunk-QNNSEJ4P.js";
|
|
12
|
+
import "../chunk-VTUGIIWI.js";
|
|
13
|
+
import "../chunk-GSI4OLXZ.js";
|
|
14
14
|
import "../chunk-MVRQ5US7.js";
|
|
15
15
|
export {
|
|
16
16
|
WalletConfigService
|
|
@@ -231,21 +231,34 @@ __export(connection_exports, {
|
|
|
231
231
|
});
|
|
232
232
|
module.exports = __toCommonJS(connection_exports);
|
|
233
233
|
init_buffer();
|
|
234
|
-
var
|
|
234
|
+
var import_core2 = require("@lightsparkdev/core");
|
|
235
235
|
var import_sha2 = require("@noble/hashes/sha2");
|
|
236
236
|
var import_nice_grpc_client_middleware_retry = require("nice-grpc-client-middleware-retry");
|
|
237
237
|
var import_nice_grpc_common2 = require("nice-grpc-common");
|
|
238
238
|
|
|
239
239
|
// src/constants.ts
|
|
240
240
|
init_buffer();
|
|
241
|
+
var import_core = require("@lightsparkdev/core");
|
|
241
242
|
var isReactNative = typeof navigator !== "undefined" && navigator.product === "ReactNative";
|
|
242
243
|
var isBun = globalThis.Bun !== void 0;
|
|
244
|
+
var packageVersion = true ? "0.1.43" : "unknown";
|
|
245
|
+
var baseEnvStr = "unknown";
|
|
246
|
+
if (import_core.isNode) {
|
|
247
|
+
baseEnvStr = `node/${process.version}`;
|
|
248
|
+
} else if (isReactNative) {
|
|
249
|
+
baseEnvStr = "react-native";
|
|
250
|
+
} else {
|
|
251
|
+
const userAgent = typeof navigator !== "undefined" && navigator.userAgent || "unknown-user-agent";
|
|
252
|
+
baseEnvStr = `browser/${userAgent}`;
|
|
253
|
+
}
|
|
254
|
+
var clientEnv = `js-spark-sdk/${packageVersion} ${baseEnvStr}`;
|
|
243
255
|
|
|
244
256
|
// src/errors/types.ts
|
|
245
257
|
init_buffer();
|
|
246
258
|
|
|
247
259
|
// src/errors/base.ts
|
|
248
260
|
init_buffer();
|
|
261
|
+
var import_utils = require("@noble/hashes/utils");
|
|
249
262
|
var SparkSDKError = class extends Error {
|
|
250
263
|
context;
|
|
251
264
|
originalError;
|
|
@@ -277,12 +290,42 @@ var SparkSDKError = class extends Error {
|
|
|
277
290
|
}
|
|
278
291
|
};
|
|
279
292
|
function getMessage(message, context = {}, originalError) {
|
|
280
|
-
const contextStr = Object.entries(context).map(([key, value]) => `${key}: ${
|
|
293
|
+
const contextStr = Object.entries(context).map(([key, value]) => `${key}: ${safeStringify(value)}`).join(", ");
|
|
281
294
|
const originalErrorStr = originalError ? `
|
|
282
295
|
Original Error: ${originalError.message}` : "";
|
|
283
296
|
return `SparkSDKError: ${message}${contextStr ? `
|
|
284
297
|
Context: ${contextStr}` : ""}${originalErrorStr}`;
|
|
285
298
|
}
|
|
299
|
+
function safeStringify(value) {
|
|
300
|
+
const replacer = (_, v) => {
|
|
301
|
+
if (typeof v === "bigint") {
|
|
302
|
+
return v.toString();
|
|
303
|
+
}
|
|
304
|
+
if (v instanceof Uint8Array) {
|
|
305
|
+
return formatUint8Array(v);
|
|
306
|
+
}
|
|
307
|
+
return v;
|
|
308
|
+
};
|
|
309
|
+
if (typeof value === "bigint") {
|
|
310
|
+
return `"${value.toString()}"`;
|
|
311
|
+
}
|
|
312
|
+
if (value instanceof Uint8Array) {
|
|
313
|
+
return `"${formatUint8Array(value)}"`;
|
|
314
|
+
}
|
|
315
|
+
try {
|
|
316
|
+
const result = JSON.stringify(value, replacer);
|
|
317
|
+
return result === void 0 ? String(value) : result;
|
|
318
|
+
} catch {
|
|
319
|
+
try {
|
|
320
|
+
return String(value);
|
|
321
|
+
} catch {
|
|
322
|
+
return "[Unserializable]";
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
function formatUint8Array(arr) {
|
|
327
|
+
return `Uint8Array(0x${(0, import_utils.bytesToHex)(arr)})`;
|
|
328
|
+
}
|
|
286
329
|
|
|
287
330
|
// src/errors/types.ts
|
|
288
331
|
var NetworkError = class extends SparkSDKError {
|
|
@@ -15046,7 +15089,7 @@ var ConnectionManager = class {
|
|
|
15046
15089
|
async createMockClient(address) {
|
|
15047
15090
|
const channel = await this.createChannelWithTLS(address);
|
|
15048
15091
|
const isNodeChannel = "close" in channel;
|
|
15049
|
-
if (
|
|
15092
|
+
if (import_core2.isNode && isNodeChannel && !isBun) {
|
|
15050
15093
|
const grpcModule = await import("nice-grpc");
|
|
15051
15094
|
const { createClient } = "default" in grpcModule ? grpcModule.default : grpcModule;
|
|
15052
15095
|
const client = createClient(MockServiceDefinition, channel);
|
|
@@ -15063,7 +15106,7 @@ var ConnectionManager = class {
|
|
|
15063
15106
|
}
|
|
15064
15107
|
async createChannelWithTLS(address, certPath) {
|
|
15065
15108
|
try {
|
|
15066
|
-
if (
|
|
15109
|
+
if (import_core2.isNode && !isBun) {
|
|
15067
15110
|
const grpcModule = await import("nice-grpc");
|
|
15068
15111
|
const { ChannelCredentials, createChannel } = "default" in grpcModule ? grpcModule.default : grpcModule;
|
|
15069
15112
|
if (certPath) {
|
|
@@ -15204,14 +15247,38 @@ var ConnectionManager = class {
|
|
|
15204
15247
|
}
|
|
15205
15248
|
async createSparkAuthnGrpcConnection(address, certPath) {
|
|
15206
15249
|
const channel = await this.createChannelWithTLS(address, certPath);
|
|
15250
|
+
const authnMiddleware = this.createAuthnMiddleware();
|
|
15207
15251
|
return this.createGrpcClient(
|
|
15208
15252
|
SparkAuthnServiceDefinition,
|
|
15209
15253
|
channel,
|
|
15210
|
-
false
|
|
15254
|
+
false,
|
|
15255
|
+
authnMiddleware
|
|
15211
15256
|
);
|
|
15212
15257
|
}
|
|
15258
|
+
createAuthnMiddleware() {
|
|
15259
|
+
if (import_core2.isNode) {
|
|
15260
|
+
return async function* (call, options) {
|
|
15261
|
+
const metadata = (0, import_nice_grpc_common2.Metadata)(options.metadata).set(
|
|
15262
|
+
"X-Client-Env",
|
|
15263
|
+
clientEnv
|
|
15264
|
+
);
|
|
15265
|
+
return yield* call.next(call.request, {
|
|
15266
|
+
...options,
|
|
15267
|
+
metadata
|
|
15268
|
+
});
|
|
15269
|
+
}.bind(this);
|
|
15270
|
+
} else {
|
|
15271
|
+
return async function* (call, options) {
|
|
15272
|
+
const metadata = (0, import_nice_grpc_common2.Metadata)(options.metadata).set("X-Requested-With", "XMLHttpRequest").set("X-Grpc-Web", "1").set("X-Client-Env", clientEnv).set("Content-Type", "application/grpc-web+proto");
|
|
15273
|
+
return yield* call.next(call.request, {
|
|
15274
|
+
...options,
|
|
15275
|
+
metadata
|
|
15276
|
+
});
|
|
15277
|
+
}.bind(this);
|
|
15278
|
+
}
|
|
15279
|
+
}
|
|
15213
15280
|
createMiddleware(address, authToken) {
|
|
15214
|
-
if (
|
|
15281
|
+
if (import_core2.isNode) {
|
|
15215
15282
|
return this.createNodeMiddleware(address, authToken);
|
|
15216
15283
|
} else {
|
|
15217
15284
|
return this.createBrowserMiddleware(address, authToken);
|
|
@@ -15219,21 +15286,29 @@ var ConnectionManager = class {
|
|
|
15219
15286
|
}
|
|
15220
15287
|
createNodeMiddleware(address, initialAuthToken) {
|
|
15221
15288
|
return async function* (call, options) {
|
|
15289
|
+
const metadata = (0, import_nice_grpc_common2.Metadata)(options.metadata).set(
|
|
15290
|
+
"X-Client-Env",
|
|
15291
|
+
clientEnv
|
|
15292
|
+
);
|
|
15222
15293
|
try {
|
|
15223
15294
|
return yield* call.next(call.request, {
|
|
15224
15295
|
...options,
|
|
15225
|
-
metadata:
|
|
15296
|
+
metadata: metadata.set(
|
|
15226
15297
|
"Authorization",
|
|
15227
15298
|
`Bearer ${this.clients.get(address)?.authToken || initialAuthToken}`
|
|
15228
|
-
)
|
|
15299
|
+
)
|
|
15229
15300
|
});
|
|
15230
15301
|
} catch (error) {
|
|
15231
15302
|
if (error.message?.includes("token has expired")) {
|
|
15232
15303
|
const newAuthToken = await this.authenticate(address);
|
|
15233
|
-
this.clients.get(address)
|
|
15304
|
+
const clientData = this.clients.get(address);
|
|
15305
|
+
if (!clientData) {
|
|
15306
|
+
throw new Error(`No client found for address: ${address}`);
|
|
15307
|
+
}
|
|
15308
|
+
clientData.authToken = newAuthToken;
|
|
15234
15309
|
return yield* call.next(call.request, {
|
|
15235
15310
|
...options,
|
|
15236
|
-
metadata:
|
|
15311
|
+
metadata: metadata.set("Authorization", `Bearer ${newAuthToken}`)
|
|
15237
15312
|
});
|
|
15238
15313
|
}
|
|
15239
15314
|
throw error;
|
|
@@ -15242,21 +15317,26 @@ var ConnectionManager = class {
|
|
|
15242
15317
|
}
|
|
15243
15318
|
createBrowserMiddleware(address, initialAuthToken) {
|
|
15244
15319
|
return async function* (call, options) {
|
|
15320
|
+
const metadata = (0, import_nice_grpc_common2.Metadata)(options.metadata).set("X-Requested-With", "XMLHttpRequest").set("X-Grpc-Web", "1").set("X-Client-Env", clientEnv).set("Content-Type", "application/grpc-web+proto");
|
|
15245
15321
|
try {
|
|
15246
15322
|
return yield* call.next(call.request, {
|
|
15247
15323
|
...options,
|
|
15248
|
-
metadata:
|
|
15324
|
+
metadata: metadata.set(
|
|
15249
15325
|
"Authorization",
|
|
15250
15326
|
`Bearer ${this.clients.get(address)?.authToken || initialAuthToken}`
|
|
15251
|
-
)
|
|
15327
|
+
)
|
|
15252
15328
|
});
|
|
15253
15329
|
} catch (error) {
|
|
15254
15330
|
if (error.message?.includes("token has expired")) {
|
|
15255
15331
|
const newAuthToken = await this.authenticate(address);
|
|
15256
|
-
this.clients.get(address)
|
|
15332
|
+
const clientData = this.clients.get(address);
|
|
15333
|
+
if (!clientData) {
|
|
15334
|
+
throw new Error(`No client found for address: ${address}`);
|
|
15335
|
+
}
|
|
15336
|
+
clientData.authToken = newAuthToken;
|
|
15257
15337
|
return yield* call.next(call.request, {
|
|
15258
15338
|
...options,
|
|
15259
|
-
metadata:
|
|
15339
|
+
metadata: metadata.set("Authorization", `Bearer ${newAuthToken}`)
|
|
15260
15340
|
});
|
|
15261
15341
|
}
|
|
15262
15342
|
throw error;
|
|
@@ -15271,7 +15351,7 @@ var ConnectionManager = class {
|
|
|
15271
15351
|
};
|
|
15272
15352
|
let options = {};
|
|
15273
15353
|
const isNodeChannel = "close" in channel;
|
|
15274
|
-
if (
|
|
15354
|
+
if (import_core2.isNode && isNodeChannel && !isBun) {
|
|
15275
15355
|
const grpcModule = await import("nice-grpc");
|
|
15276
15356
|
const { openTelemetryClientMiddleware } = await import("nice-grpc-opentelemetry");
|
|
15277
15357
|
const { createClientFactory } = "default" in grpcModule ? grpcModule.default : grpcModule;
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { Channel } from 'nice-grpc';
|
|
2
2
|
import { Channel as Channel$1 } from 'nice-grpc-web';
|
|
3
|
-
import { E as Empty, g as SparkServiceClient } from '../spark-
|
|
3
|
+
import { E as Empty, g as SparkServiceClient } from '../spark-CDm4gqS6.cjs';
|
|
4
4
|
import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
|
|
5
5
|
import { CallOptions } from 'nice-grpc-common';
|
|
6
6
|
import { WalletConfigService } from './config.cjs';
|
|
7
7
|
import { SparkTokenServiceClient } from '../proto/spark_token.cjs';
|
|
8
8
|
import '@buildonspark/lrc20-sdk';
|
|
9
|
-
import '../RequestLightningSendInput-
|
|
9
|
+
import '../RequestLightningSendInput-Na1mHdWg.cjs';
|
|
10
10
|
import '@lightsparkdev/core';
|
|
11
11
|
import '../BitcoinNetwork-TnABML0T.cjs';
|
|
12
|
-
import '../signer-
|
|
12
|
+
import '../signer-IO3oMRNj.cjs';
|
|
13
13
|
import '@scure/bip32';
|
|
14
14
|
import '@scure/btc-signer';
|
|
15
15
|
import 'bitcoinjs-lib';
|
|
16
|
-
import '
|
|
16
|
+
import '@buildonspark/lrc20-sdk/lrc/types';
|
|
17
|
+
import '../network-D5lKssVl.cjs';
|
|
17
18
|
import './wallet-config.cjs';
|
|
18
19
|
|
|
19
20
|
declare enum InterruptTransferRequest_InterruptTransferAction {
|
|
@@ -83,6 +84,7 @@ declare class ConnectionManager {
|
|
|
83
84
|
getStreamChannel(address: string): Promise<Channel | Channel$1 | undefined>;
|
|
84
85
|
private authenticate;
|
|
85
86
|
private createSparkAuthnGrpcConnection;
|
|
87
|
+
private createAuthnMiddleware;
|
|
86
88
|
private createMiddleware;
|
|
87
89
|
private createNodeMiddleware;
|
|
88
90
|
private createBrowserMiddleware;
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { Channel } from 'nice-grpc';
|
|
2
2
|
import { Channel as Channel$1 } from 'nice-grpc-web';
|
|
3
|
-
import { E as Empty, g as SparkServiceClient } from '../spark-
|
|
3
|
+
import { E as Empty, g as SparkServiceClient } from '../spark-CDm4gqS6.js';
|
|
4
4
|
import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
|
|
5
5
|
import { CallOptions } from 'nice-grpc-common';
|
|
6
6
|
import { WalletConfigService } from './config.js';
|
|
7
7
|
import { SparkTokenServiceClient } from '../proto/spark_token.js';
|
|
8
8
|
import '@buildonspark/lrc20-sdk';
|
|
9
|
-
import '../RequestLightningSendInput-
|
|
9
|
+
import '../RequestLightningSendInput-D7fZdT4A.js';
|
|
10
10
|
import '@lightsparkdev/core';
|
|
11
11
|
import '../BitcoinNetwork-TnABML0T.js';
|
|
12
|
-
import '../signer-
|
|
12
|
+
import '../signer-wqesWifN.js';
|
|
13
13
|
import '@scure/bip32';
|
|
14
14
|
import '@scure/btc-signer';
|
|
15
15
|
import 'bitcoinjs-lib';
|
|
16
|
-
import '
|
|
16
|
+
import '@buildonspark/lrc20-sdk/lrc/types';
|
|
17
|
+
import '../network-xkBSpaTn.js';
|
|
17
18
|
import './wallet-config.js';
|
|
18
19
|
|
|
19
20
|
declare enum InterruptTransferRequest_InterruptTransferAction {
|
|
@@ -83,6 +84,7 @@ declare class ConnectionManager {
|
|
|
83
84
|
getStreamChannel(address: string): Promise<Channel | Channel$1 | undefined>;
|
|
84
85
|
private authenticate;
|
|
85
86
|
private createSparkAuthnGrpcConnection;
|
|
87
|
+
private createAuthnMiddleware;
|
|
86
88
|
private createMiddleware;
|
|
87
89
|
private createNodeMiddleware;
|
|
88
90
|
private createBrowserMiddleware;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ConnectionManager
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-HRQRRDSS.js";
|
|
4
4
|
import "../chunk-VA7MV4MZ.js";
|
|
5
|
-
import "../chunk-HKAKEKCE.js";
|
|
6
|
-
import "../chunk-TWF35O6M.js";
|
|
7
5
|
import "../chunk-M6A4KFIG.js";
|
|
6
|
+
import "../chunk-VFJQNBFX.js";
|
|
7
|
+
import "../chunk-GSI4OLXZ.js";
|
|
8
8
|
import "../chunk-MVRQ5US7.js";
|
|
9
9
|
export {
|
|
10
10
|
ConnectionManager
|