fix require is not defined in ES module scope

This commit is contained in:
Riccardo Balbo 2024-11-04 20:09:16 +01:00
parent 048c27fa7e
commit 571a230b3c
1 changed files with 4 additions and 1 deletions

View File

@ -5,12 +5,15 @@ import { join } from 'path'
import apiForProto from 'lightning/lnd_grpc/api_for_proto'
import { defaultSocket, grpcSslCipherSuites, packageTypes, protoFiles, protosDir, serviceTypes } from 'lightning/grpc/index'
import grpcCredentials from 'lightning/lnd_grpc/grpc_credentials'
import { createRequire } from 'module'
const { GRPC_SSL_CIPHER_SUITES } = process.env
const { keys } = Object
export function authenticatedLndGrpc ({ cert, macaroon, path, socket }, withProxy) {
const lightningModulePath = require.resolve('lightning')
const req = createRequire(import.meta.url)
const lightningModulePath = req.resolve('lightning')
const pathForProto = proto => join(lightningModulePath, protosDir, proto)
const { credentials } = grpcCredentials({ cert, macaroon })