@neuraiproject/neurai-rpc 0.4.3 → 0.4.5

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.mjs CHANGED
@@ -162,6 +162,26 @@ Examples:
162
162
  > neurai-cli checkaddresstag "address" "tag_name"
163
163
  > curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "checkaddresstag", "params": ["address" "tag_name"] }' -H 'content-type: text/plain;' http://127.0.0.1:8766/
164
164
  **/ checkaddresstag: 'checkaddresstag',
165
+ /** checkdepinvalidity "asset_name" "address"
166
+
167
+ Check if a DEPIN asset is valid/active for a specific address
168
+
169
+ Arguments:
170
+ 1. "asset_name" (string, required) The DEPIN asset name (must start with &)
171
+ 2. "address" (string, required) The address to check
172
+
173
+ Result:
174
+ {
175
+ "has_asset": true|false, (boolean) Whether the address holds the asset
176
+ "amount": n, (numeric) The amount (if has_asset is true)
177
+ "valid": 1|0, (numeric) 1 = active/valid, 0 = blocked/revoked (if has_asset is true)
178
+ "blocked": true|false (boolean) Whether the asset is blocked (if has_asset is true)
179
+ }
180
+
181
+ Examples:
182
+ > neurai-cli checkdepinvalidity "&FRANCE" "address"
183
+ > curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "checkdepinvalidity", "params": ["&FRANCE", "address"] }' -H 'content-type: text/plain;' http://127.0.0.1:8766/
184
+ **/ checkdepinvalidity: 'checkdepinvalidity',
165
185
  /** checkglobalrestriction restricted_name
166
186
 
167
187
  Checks to see if a restricted asset is globally frozen
@@ -615,6 +635,213 @@ Examples:
615
635
  > neurai-cli decodescript "hexstring"
616
636
  > curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "decodescript", "params": ["hexstring"] }' -H 'content-type: text/plain;' http://127.0.0.1:8766/
617
637
  **/ decodescript: 'decodescript',
638
+ /** depinclearmsg ( "all" | hours )
639
+
640
+ Remove messages from DePIN messaging pool
641
+
642
+ Arguments:
643
+ 1. mode (string or numeric, optional) Cleanup mode:
644
+ - omitted: Remove only expired messages (default)
645
+ - "all": Remove ALL messages from pool
646
+ - <hours>: Remove messages older than specified hours (numeric)
647
+
648
+ Result:
649
+ {
650
+ "removed": n, (numeric) Number of messages removed
651
+ "remaining": n (numeric) Number of messages remaining
652
+ }
653
+
654
+ Examples:
655
+ > neurai-cli depinclearmsg
656
+ > neurai-cli depinclearmsg "all"
657
+ > neurai-cli depinclearmsg 7
658
+ > curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "depinclearmsg", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:8766/
659
+ **/ depinclearmsg: 'depinclearmsg',
660
+ /** depingetmsg "token" ("ip[:port]"|"fromaddress") ("fromaddress")
661
+
662
+ Retrieve and decrypt DePIN messages for your addresses
663
+
664
+ Arguments:
665
+ 1. "token" (string, required) Token name
666
+ 2. "ip[:port]" OR "fromaddress" (string, optional)
667
+ - IP address with optional port (e.g., "192.168.1.31" or "192.168.1.31:19002")
668
+ - OR Neurai address for local query with specific address
669
+ - Omit for local query with all addresses
670
+ 3. "fromaddress" (string, optional) Specific address to decrypt with (only if arg 2 is an IP)
671
+
672
+ Result:
673
+ [
674
+ {
675
+ "recipient": "address", (string) Recipient address (your address)
676
+ "sender": "address", (string) Sender address
677
+ "message": "text", (string) Decrypted message
678
+ "timestamp": n, (numeric) Unix timestamp
679
+ "date": "YYYY-MM-DD HH:MM:SS", (string) Formatted date
680
+ "expires": "YYYY-MM-DD HH:MM:SS" (string) Expiration date
681
+ },
682
+ ...
683
+ ]
684
+
685
+ Examples:
686
+ > neurai-cli depingetmsg "MYTOKEN"
687
+ > neurai-cli depingetmsg "MYTOKEN" "NXyouraddress..."
688
+ > neurai-cli depingetmsg "MYTOKEN" "192.168.1.78"
689
+ > neurai-cli depingetmsg "MYTOKEN" "192.168.1.78:19002" "NXyouraddress..."
690
+ > curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "depingetmsg", "params": ["MYTOKEN"] }' -H 'content-type: text/plain;' http://127.0.0.1:8766/
691
+ **/ depingetmsg: 'depingetmsg',
692
+ /** depingetmsginfo
693
+
694
+ Returns information about the DePIN messaging system
695
+
696
+ Result:
697
+ {
698
+ "enabled": true|false, (boolean) Whether DePIN messaging is enabled
699
+ "token": "name", (string) Active token name
700
+ "port": n, (numeric) Listening port
701
+ "maxrecipients": n, (numeric) Maximum recipients per message
702
+ "maxmessagesize": n, (numeric) Maximum message size in bytes
703
+ "messageexpiryhours": n, (numeric) Message expiry time in hours
704
+ "maxpoolsizemb": n, (numeric) Maximum pool size in MB
705
+ "messages": n, (numeric) Number of messages in mempool
706
+ "memoryusage": n, (numeric) Memory usage in bytes
707
+ "memoryusagemb": n, (numeric) Memory usage in MB
708
+ "oldestmessage": "time", (string) Timestamp of oldest message
709
+ "newestmessage": "time" (string) Timestamp of newest message
710
+ }
711
+
712
+ Examples:
713
+ > neurai-cli depingetmsginfo
714
+ > curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "depingetmsginfo", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:8766/
715
+ **/ depingetmsginfo: 'depingetmsginfo',
716
+ /** depingetpoolcontent ( verbose sender_address recipient_address start_time end_time limit offset )
717
+
718
+ Inspect the contents of the DePIN message pool.
719
+
720
+ Arguments:
721
+ 1. verbose (boolean, "all", or "raw", optional, default=false) Show detailed message structure. Use "all" for all messages, "raw" to show encrypted hex data
722
+ 2. sender_address (string, optional) Filter by sender address
723
+ 3. recipient_address (string, optional) Filter by recipient address
724
+ 4. start_time (numeric, optional) Filter messages after timestamp
725
+ 5. end_time (numeric, optional) Filter messages before timestamp
726
+ 6. limit (numeric, optional, default=100) Maximum messages to return
727
+ 7. offset (numeric, optional, default=0) Skip first N messages
728
+
729
+ Result (verbose=false):
730
+ [
731
+ {
732
+ "hash": "hex",
733
+ "sender": "address",
734
+ "timestamp": n,
735
+ "date": "YYYY-MM-DD HH:MM:SS",
736
+ "expires": "YYYY-MM-DD HH:MM:SS",
737
+ "encryption_type": "ECIES_shared",
738
+ "size": n
739
+ },
740
+ ...
741
+ ]
742
+
743
+ Examples:
744
+ > neurai-cli depingetpoolcontent
745
+ > neurai-cli depingetpoolcontent true
746
+ > neurai-cli depingetpoolcontent "all"
747
+ > curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "depingetpoolcontent", "params": [true] }' -H 'content-type: text/plain;' http://127.0.0.1:8766/
748
+ **/ depingetpoolcontent: 'depingetpoolcontent',
749
+ /** depinmcpstatus
750
+
751
+ Get status information about the DePIN MCP (AI) worker
752
+
753
+ Result:
754
+ {
755
+ "enabled": true|false, (boolean) Whether MCP worker is enabled
756
+ "running": true|false, (boolean) Whether MCP worker is running
757
+ "mcp_url": "url", (string) MCP server URL
758
+ "model_name": "name", (string) Name of the loaded AI model
759
+ "command_key": "key", (string) Command prefix (e.g. /ai)
760
+ "depin_token": "token", (string) DePIN token being monitored
761
+ "poll_interval": n, (numeric) Polling interval in seconds
762
+ "commands_processed": n, (numeric) Total commands processed
763
+ "total_errors": n, (numeric) Total errors encountered
764
+ "last_poll_time": n (numeric) Unix timestamp of last poll
765
+ }
766
+
767
+ Examples:
768
+ > neurai-cli depinmcpstatus
769
+ > curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "depinmcpstatus", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:8766/
770
+ **/ depinmcpstatus: 'depinmcpstatus',
771
+ /** depinpoolstats
772
+
773
+ Get statistical analysis of the DePIN message pool.
774
+
775
+ Result:
776
+ {
777
+ "enabled": true|false,
778
+ "token": "string",
779
+ "total_messages": n,
780
+ "total_size_bytes": n,
781
+ "memory_usage_bytes": n,
782
+ "oldest_message": "YYYY-MM-DD HH:MM:SS",
783
+ "newest_message": "YYYY-MM-DD HH:MM:SS",
784
+ "messages_by_age": {
785
+ "last_hour": n,
786
+ "last_day": n,
787
+ "last_week": n
788
+ },
789
+ "unique_senders": n,
790
+ "avg_message_size": n,
791
+ "expiring_in_24h": n
792
+ }
793
+
794
+ Examples:
795
+ > neurai-cli depinpoolstats
796
+ > curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "depinpoolstats", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:8766/
797
+ **/ depinpoolstats: 'depinpoolstats',
798
+ /** depinsendmsg "token" "ip[:port]" "message" "fromaddress" (port)
799
+
800
+ Send an encrypted message through a remote DePIN gateway (challenge/response)
801
+
802
+ Arguments:
803
+ 1. "token" (string, required) Token name
804
+ 2. "ip[:port]" (string, required) Target node address (optional :port to contact remote gateway)
805
+ 3. "message" (string, required) Message to send (max 1KB)
806
+ 4. "fromaddress" (string, required) Wallet address used for signing/encryption
807
+ 5. port (numeric, optional) Destination message port (defaults to 19002). Only used when specified after fromaddress
808
+
809
+ Result:
810
+ {
811
+ "result": "success", (string) Status
812
+ "hash": "hash", (string) Message hash
813
+ "recipients": n, (numeric) Number of recipients
814
+ "timestamp": n (numeric) Message timestamp
815
+ }
816
+
817
+ Examples:
818
+ > neurai-cli depinsendmsg "MYTOKEN" "192.168.1.100" "Hello team!" "NXsender..."
819
+ > neurai-cli depinsendmsg "MYTOKEN" "192.168.1.100:19005" "Hello team!" "NXsender..." 19005
820
+ > curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "depinsendmsg", "params": ["MYTOKEN", "192.168.1.100", "Hello team!", "NXsender..."] }' -H 'content-type: text/plain;' http://127.0.0.1:8766/
821
+ **/ depinsendmsg: 'depinsendmsg',
822
+ /** depinsubmitmsg "hexmessage"
823
+
824
+ Submit a pre-encrypted and signed DePIN message to the pool
825
+
826
+ This is the secure protocol where the client prepares the complete message
827
+ (encryption + signature) and the server only validates and stores it.
828
+
829
+ Arguments:
830
+ 1. "hexmessage" (string, required) Hex-encoded serialized CDepinMessage
831
+
832
+ Result:
833
+ {
834
+ "result": "success", (string) Status
835
+ "hash": "hash", (string) Message hash
836
+ "timestamp": n (numeric) Unix timestamp
837
+ }
838
+
839
+ Note: This endpoint is typically called by remote nodes after challenge/response authentication.
840
+
841
+ Examples:
842
+ > neurai-cli depinsubmitmsg "0a3f2e..."
843
+ > curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "depinsubmitmsg", "params": ["0a3f2e..."] }' -H 'content-type: text/plain;' http://127.0.0.1:8766/
844
+ **/ depinsubmitmsg: 'depinsubmitmsg',
618
845
  /** disconnectnode "[address]" [nodeid]
619
846
 
620
847
  Immediately disconnects from the specified peer node.
@@ -804,6 +1031,26 @@ Examples:
804
1031
  > neurai-cli freezeaddress "$RESTRICTED_ASSET" "address" "change_address"
805
1032
  > curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "freezeaddress", "params": ["$RESTRICTED_ASSET" "address" "change_address"] }' -H 'content-type: text/plain;' http://127.0.0.1:8766/
806
1033
  **/ freezeaddress: 'freezeaddress',
1034
+ /** freezedepin "asset_name" "address" ("change_address")
1035
+
1036
+ Freeze a DEPIN asset for a specific address (owner only)
1037
+
1038
+ The address will still hold the asset but it will be marked as invalid
1039
+
1040
+ Requires the owner token (&ASSET!) in the wallet
1041
+
1042
+ Arguments:
1043
+ 1. "asset_name" (string, required) The DEPIN asset name (must start with &)
1044
+ 2. "address" (string, required) The address to freeze
1045
+ 3. "change_address" (string, optional) The change address for the owner token
1046
+
1047
+ Result:
1048
+ "txid" (string) The transaction id
1049
+
1050
+ Examples:
1051
+ > neurai-cli freezedepin "&FRANCE" "address"
1052
+ > curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "freezedepin", "params": ["&FRANCE", "address"] }' -H 'content-type: text/plain;' http://127.0.0.1:8766/
1053
+ **/ freezedepin: 'freezedepin',
807
1054
  /** freezerestrictedasset asset_name (change_address) (asset_data)
808
1055
 
809
1056
  Freeze all trading for a specific restricted asset
@@ -2902,6 +3149,29 @@ Examples:
2902
3149
  > neurai-cli listbanned
2903
3150
  > curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "listbanned", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:8766/
2904
3151
  **/ listbanned: 'listbanned',
3152
+ /** listdepinholders "asset_name"
3153
+
3154
+ Returns all addresses holding a DEPIN asset with validity status
3155
+
3156
+ DEPIN assets are soulbound (non-transferable except by owner) and can be frozen/revoked
3157
+
3158
+ Arguments:
3159
+ 1. "asset_name" (string, required) The DEPIN asset name (must start with &)
3160
+
3161
+ Result:
3162
+ [
3163
+ {
3164
+ "address": "address", (string) The address
3165
+ "amount": n, (numeric) The amount (always 1 for DEPIN)
3166
+ "valid": 1|0 (numeric) 1 = active/valid, 0 = blocked/revoked
3167
+ },
3168
+ ...
3169
+ ]
3170
+
3171
+ Examples:
3172
+ > neurai-cli listdepinholders "&FRANCE"
3173
+ > curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "listdepinholders", "params": ["&FRANCE"] }' -H 'content-type: text/plain;' http://127.0.0.1:8766/
3174
+ **/ listdepinholders: 'listdepinholders',
2905
3175
  /** listglobalrestrictions
2906
3176
 
2907
3177
  List all global restricted assets
@@ -3537,6 +3807,24 @@ Examples:
3537
3807
  > neurai-cli savemempool
3538
3808
  > curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "savemempool", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:8766/
3539
3809
  **/ savemempool: 'savemempool',
3810
+ /** selfrevokedepin "asset_name"
3811
+
3812
+ Self-revoke a DEPIN asset held in this wallet
3813
+
3814
+ The asset will be marked as invalid but will remain in the address
3815
+
3816
+ This action can only be undone by the asset owner
3817
+
3818
+ Arguments:
3819
+ 1. "asset_name" (string, required) The DEPIN asset name (must start with &)
3820
+
3821
+ Result:
3822
+ "txid" (string) The transaction id
3823
+
3824
+ Examples:
3825
+ > neurai-cli selfrevokedepin "&FRANCE"
3826
+ > curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "selfrevokedepin", "params": ["&FRANCE"] }' -H 'content-type: text/plain;' http://127.0.0.1:8766/
3827
+ **/ selfrevokedepin: 'selfrevokedepin',
3540
3828
  /** sendfrom "fromaccount" "toaddress" amount ( minconf "comment" "comment_to" )
3541
3829
 
3542
3830
  DEPRECATED (use sendtoaddress). Sent an amount from an account to a neurai address.
@@ -4062,6 +4350,26 @@ Examples:
4062
4350
  > neurai-cli unfreezeaddress "$RESTRICTED_ASSET" "address" "change_address"
4063
4351
  > curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "unfreezeaddress", "params": ["$RESTRICTED_ASSET" "address" "change_address"] }' -H 'content-type: text/plain;' http://127.0.0.1:8766/
4064
4352
  **/ unfreezeaddress: 'unfreezeaddress',
4353
+ /** unfreezedepin "asset_name" "address" ("change_address")
4354
+
4355
+ Unfreeze a DEPIN asset for a specific address (owner only)
4356
+
4357
+ The asset will be marked as valid again
4358
+
4359
+ Requires the owner token (&ASSET!) in the wallet
4360
+
4361
+ Arguments:
4362
+ 1. "asset_name" (string, required) The DEPIN asset name (must start with &)
4363
+ 2. "address" (string, required) The address to unfreeze
4364
+ 3. "change_address" (string, optional) The change address for the owner token
4365
+
4366
+ Result:
4367
+ "txid" (string) The transaction id
4368
+
4369
+ Examples:
4370
+ > neurai-cli unfreezedepin "&FRANCE" "address"
4371
+ > curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "unfreezedepin", "params": ["&FRANCE", "address"] }' -H 'content-type: text/plain;' http://127.0.0.1:8766/
4372
+ **/ unfreezedepin: 'unfreezedepin',
4065
4373
  /** unfreezerestrictedasset asset_name (change_address) (asset_data)
4066
4374
 
4067
4375
  Unfreeze all trading for a specific restricted asset
@@ -4258,6 +4566,154 @@ Examples:
4258
4566
  };
4259
4567
 
4260
4568
 
4569
+ /**
4570
+ * DePIN RPC Client for Neurai
4571
+ *
4572
+ * This module provides support for communicating with Neurai DePIN messaging
4573
+ * on port 19002 using the challenge/response authentication protocol.
4574
+ */ /**
4575
+ * Request a challenge from DePIN server
4576
+ * Uses the simple protocol: AUTH|token|address|mode
4577
+ */ async function $70bab8e696d427b0$var$requestChallenge(url, authOptions) {
4578
+ const mode = authOptions.mode || 'RECEIVE';
4579
+ const authCommand = `AUTH|${authOptions.token}|${authOptions.address}|${mode}`;
4580
+ try {
4581
+ const response = await fetch(url, {
4582
+ method: 'POST',
4583
+ headers: {
4584
+ 'Content-Type': 'text/plain'
4585
+ },
4586
+ body: authCommand
4587
+ });
4588
+ if (!response.ok) throw new Error(`Failed to request challenge: ${response.statusText}`);
4589
+ const responseText = await response.text();
4590
+ // Parse response: CHALLENGE|<challenge>|<timeout>
4591
+ if (!responseText.startsWith('CHALLENGE|')) throw new Error(`Invalid challenge response: ${responseText}`);
4592
+ const parts = responseText.split('|');
4593
+ if (parts.length < 3) throw new Error(`Malformed challenge response: ${responseText}`);
4594
+ const challenge = parts[1];
4595
+ const timeout = parseInt(parts[2], 10);
4596
+ if (!challenge || isNaN(timeout)) throw new Error(`Invalid challenge data: ${responseText}`);
4597
+ // Construct the message that needs to be signed
4598
+ const messageToSign = `DEPIN-${mode}|${authOptions.token}|${authOptions.address}|${challenge}`;
4599
+ return {
4600
+ challenge: challenge,
4601
+ timeout: timeout,
4602
+ messageToSign: messageToSign
4603
+ };
4604
+ } catch (error) {
4605
+ throw new Error(`Failed to request DePIN challenge: ${error.message}`);
4606
+ }
4607
+ }
4608
+ /**
4609
+ * Make authenticated JSON-RPC request to DePIN server
4610
+ */ async function $70bab8e696d427b0$var$postDePinData(url, data, challenge, signature) {
4611
+ const response = await fetch(url, {
4612
+ method: 'POST',
4613
+ mode: 'cors',
4614
+ headers: {
4615
+ 'Content-Type': 'application/json'
4616
+ },
4617
+ body: JSON.stringify(data)
4618
+ });
4619
+ return response;
4620
+ }
4621
+ /**
4622
+ * Get or refresh challenge if needed
4623
+ */ async function $70bab8e696d427b0$var$ensureValidChallenge(context, requiredMode) {
4624
+ const now = Date.now();
4625
+ // Check if we have a valid cached challenge
4626
+ if (context.currentChallenge && context.currentChallenge.mode === requiredMode && context.currentChallenge.expiresAt > now) return context.currentChallenge.challenge;
4627
+ // Request new challenge
4628
+ const authOptions = {
4629
+ ...context.authOptions,
4630
+ mode: requiredMode
4631
+ };
4632
+ const challengeData = await $70bab8e696d427b0$var$requestChallenge(context.url, authOptions);
4633
+ // Cache challenge (expires 5 seconds before actual timeout for safety)
4634
+ context.currentChallenge = {
4635
+ challenge: challengeData.challenge,
4636
+ expiresAt: now + (challengeData.timeout - 5) * 1000,
4637
+ mode: requiredMode
4638
+ };
4639
+ return challengeData.challenge;
4640
+ }
4641
+ function $70bab8e696d427b0$export$e3c4528d9eee3c6(url, authOptions) {
4642
+ if (!url) throw new Error('URL is required for DePIN RPC');
4643
+ if (!authOptions.token) throw new Error('Token is required for DePIN authentication');
4644
+ if (!authOptions.address) throw new Error('Address is required for DePIN authentication');
4645
+ if (!authOptions.signMessage || typeof authOptions.signMessage !== 'function') throw new Error('signMessage function is required for DePIN authentication');
4646
+ const context = {
4647
+ url: url,
4648
+ authOptions: authOptions
4649
+ };
4650
+ return async function depinRpc(method, params) {
4651
+ return new Promise(async (resolve, reject)=>{
4652
+ try {
4653
+ // Determine operation mode from method
4654
+ const requiredMode = method === 'depinsendmsg' || method === 'depinsubmitmsg' ? 'SEND' : 'RECEIVE';
4655
+ // Get valid challenge
4656
+ const challenge = await $70bab8e696d427b0$var$ensureValidChallenge(context, requiredMode);
4657
+ // Build message to sign
4658
+ const messageToSign = `DEPIN-${requiredMode}|${authOptions.token}|${authOptions.address}|${challenge}`;
4659
+ // Sign the message
4660
+ const signature = await authOptions.signMessage(messageToSign);
4661
+ if (!signature) throw new Error('Signature function returned empty result');
4662
+ // Add challenge and signature to params
4663
+ const enhancedParams = [
4664
+ ...params,
4665
+ challenge,
4666
+ signature
4667
+ ];
4668
+ // Build JSON-RPC request
4669
+ const requestData = {
4670
+ jsonrpc: '2.0',
4671
+ id: Math.random(),
4672
+ method: method,
4673
+ params: enhancedParams
4674
+ };
4675
+ // Make request
4676
+ const response = await $70bab8e696d427b0$var$postDePinData(url, requestData, challenge, signature);
4677
+ if (response.ok) {
4678
+ const responseData = await response.json();
4679
+ if (responseData.error) {
4680
+ // Check if it's an expired challenge error
4681
+ if (responseData.error.message && responseData.error.message.includes('expired')) {
4682
+ // Clear cached challenge and retry once
4683
+ context.currentChallenge = undefined;
4684
+ // Retry the request with a new challenge
4685
+ return depinRpc(method, params).then(resolve).catch(reject);
4686
+ }
4687
+ reject({
4688
+ error: responseData.error,
4689
+ description: responseData.error.message || 'Unknown error'
4690
+ });
4691
+ } else resolve(responseData.result);
4692
+ } else {
4693
+ const errorData = await response.json().catch(()=>({}));
4694
+ reject({
4695
+ statusText: response.statusText,
4696
+ status: response.status,
4697
+ error: errorData.error,
4698
+ description: errorData.error?.message || 'Request failed'
4699
+ });
4700
+ }
4701
+ } catch (error) {
4702
+ reject({
4703
+ originalError: error,
4704
+ type: 'DePinRequestError',
4705
+ error: error.message || 'Failed to communicate with DePIN server',
4706
+ description: 'Check that the DePIN server URL is correct and that the server is running'
4707
+ });
4708
+ }
4709
+ });
4710
+ };
4711
+ }
4712
+ async function $70bab8e696d427b0$export$9d7d174baf084291(url, authOptions) {
4713
+ return $70bab8e696d427b0$var$requestChallenge(url, authOptions);
4714
+ }
4715
+
4716
+
4261
4717
  function $c3f6c693698dc7cd$var$throwSyntaxError() {
4262
4718
  throw new Error("Syntax error, call getRPC with (username, password, URL)");
4263
4719
  }
@@ -4515,5 +4971,5 @@ export const methods = {
4515
4971
  }*/
4516
4972
 
4517
4973
 
4518
- export {$c3f6c693698dc7cd$export$eb94c228b080d168 as getRPC, $ebb7c8e52e3397d2$export$e13b82b2b0368a6a as methods};
4974
+ export {$c3f6c693698dc7cd$export$eb94c228b080d168 as getRPC, $ebb7c8e52e3397d2$export$e13b82b2b0368a6a as methods, $70bab8e696d427b0$export$e3c4528d9eee3c6 as getDePinRPC, $70bab8e696d427b0$export$9d7d174baf084291 as requestDePinChallenge};
4519
4975
  //# sourceMappingURL=index.mjs.map