wowok 2.1.13 → 2.1.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/cjs/bcs/bcs.js +160 -164
- package/dist/cjs/bcs/bcs.js.map +1 -1
- package/dist/cjs/bcs/effects.js +109 -112
- package/dist/cjs/bcs/effects.js.map +1 -1
- package/dist/cjs/bcs/index.js +49 -58
- package/dist/cjs/bcs/index.js.map +1 -1
- package/dist/cjs/bcs/pure.js +14 -17
- package/dist/cjs/bcs/pure.js.map +1 -1
- package/dist/cjs/bcs/type-tag-serializer.js +6 -11
- package/dist/cjs/bcs/type-tag-serializer.js.map +1 -1
- package/dist/cjs/bcs/types.js +1 -4
- package/dist/cjs/bcs/types.js.map +1 -1
- package/dist/cjs/client/index.js +4 -15
- package/dist/cjs/client/index.js.map +1 -1
- package/dist/cjs/client/network.js +3 -7
- package/dist/cjs/client/network.js.map +1 -1
- package/dist/cjs/cryptography/index.js +6 -27
- package/dist/cjs/cryptography/index.js.map +1 -1
- package/dist/cjs/cryptography/intent.js +4 -7
- package/dist/cjs/cryptography/intent.js.map +1 -1
- package/dist/cjs/cryptography/keypair.js +26 -33
- package/dist/cjs/cryptography/keypair.js.map +1 -1
- package/dist/cjs/cryptography/mnemonics.js +8 -14
- package/dist/cjs/cryptography/mnemonics.js.map +1 -1
- package/dist/cjs/cryptography/publickey.js +19 -25
- package/dist/cjs/cryptography/publickey.js.map +1 -1
- package/dist/cjs/cryptography/signature-scheme.js +3 -6
- package/dist/cjs/cryptography/signature-scheme.js.map +1 -1
- package/dist/cjs/cryptography/signature.js +14 -18
- package/dist/cjs/cryptography/signature.js.map +1 -1
- package/dist/cjs/experimental/cache.js +1 -5
- package/dist/cjs/experimental/cache.js.map +1 -1
- package/dist/cjs/experimental/client.js +3 -7
- package/dist/cjs/experimental/client.js.map +1 -1
- package/dist/cjs/experimental/core.js +11 -15
- package/dist/cjs/experimental/core.js.map +1 -1
- package/dist/cjs/experimental/errors.js +2 -7
- package/dist/cjs/experimental/errors.js.map +1 -1
- package/dist/cjs/experimental/index.js +5 -12
- package/dist/cjs/experimental/index.js.map +1 -1
- package/dist/cjs/experimental/persistent-storage.js +30 -36
- package/dist/cjs/experimental/persistent-storage.js.map +1 -1
- package/dist/cjs/experimental/persistent-storage.test.js +18 -20
- package/dist/cjs/experimental/persistent-storage.test.js.map +1 -1
- package/dist/cjs/experimental/transports/utils.js +6 -10
- package/dist/cjs/experimental/transports/utils.js.map +1 -1
- package/dist/cjs/experimental/types.js +1 -2
- package/dist/cjs/experimental/types.js.map +1 -1
- package/dist/cjs/faucet/faucet.js +6 -15
- package/dist/cjs/faucet/faucet.js.map +1 -1
- package/dist/cjs/faucet/index.js +1 -10
- package/dist/cjs/faucet/index.js.map +1 -1
- package/dist/cjs/grpc/client.js +20 -24
- package/dist/cjs/grpc/client.js.map +1 -1
- package/dist/cjs/grpc/core.js +65 -70
- package/dist/cjs/grpc/core.js.map +1 -1
- package/dist/cjs/grpc/index.js +2 -7
- package/dist/cjs/grpc/index.js.map +1 -1
- package/dist/cjs/grpc/proto/google/protobuf/any.js +10 -13
- package/dist/cjs/grpc/proto/google/protobuf/any.js.map +1 -1
- package/dist/cjs/grpc/proto/google/protobuf/duration.js +8 -11
- package/dist/cjs/grpc/proto/google/protobuf/duration.js.map +1 -1
- package/dist/cjs/grpc/proto/google/protobuf/empty.js +3 -6
- package/dist/cjs/grpc/proto/google/protobuf/empty.js.map +1 -1
- package/dist/cjs/grpc/proto/google/protobuf/field_mask.js +7 -10
- package/dist/cjs/grpc/proto/google/protobuf/field_mask.js.map +1 -1
- package/dist/cjs/grpc/proto/google/protobuf/struct.js +25 -28
- package/dist/cjs/grpc/proto/google/protobuf/struct.js.map +1 -1
- package/dist/cjs/grpc/proto/google/protobuf/timestamp.js +11 -14
- package/dist/cjs/grpc/proto/google/protobuf/timestamp.js.map +1 -1
- package/dist/cjs/grpc/proto/google/rpc/error_details.js +36 -39
- package/dist/cjs/grpc/proto/google/rpc/error_details.js.map +1 -1
- package/dist/cjs/grpc/proto/google/rpc/status.js +5 -8
- package/dist/cjs/grpc/proto/google/rpc/status.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/argument.js +5 -8
- package/dist/cjs/grpc/proto/sui/rpc/v2/argument.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/balance_change.js +3 -6
- package/dist/cjs/grpc/proto/sui/rpc/v2/balance_change.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/bcs.js +3 -6
- package/dist/cjs/grpc/proto/sui/rpc/v2/bcs.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint.js +13 -16
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint_contents.js +10 -13
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint_contents.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint_summary.js +20 -23
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint_summary.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/effects.js +29 -32
- package/dist/cjs/grpc/proto/sui/rpc/v2/effects.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/epoch.js +12 -15
- package/dist/cjs/grpc/proto/sui/rpc/v2/epoch.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/error_reason.js +2 -5
- package/dist/cjs/grpc/proto/sui/rpc/v2/error_reason.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/event.js +11 -14
- package/dist/cjs/grpc/proto/sui/rpc/v2/event.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/executed_transaction.js +17 -20
- package/dist/cjs/grpc/proto/sui/rpc/v2/executed_transaction.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/execution_status.js +45 -48
- package/dist/cjs/grpc/proto/sui/rpc/v2/execution_status.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/gas_cost_summary.js +3 -6
- package/dist/cjs/grpc/proto/sui/rpc/v2/gas_cost_summary.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/input.js +7 -10
- package/dist/cjs/grpc/proto/sui/rpc/v2/input.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/jwk.js +5 -8
- package/dist/cjs/grpc/proto/sui/rpc/v2/jwk.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/ledger_service.client.js +13 -17
- package/dist/cjs/grpc/proto/sui/rpc/v2/ledger_service.client.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/ledger_service.js +73 -76
- package/dist/cjs/grpc/proto/sui/rpc/v2/ledger_service.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/move_package.js +48 -51
- package/dist/cjs/grpc/proto/sui/rpc/v2/move_package.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/move_package_service.client.js +10 -14
- package/dist/cjs/grpc/proto/sui/rpc/v2/move_package_service.client.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/move_package_service.js +36 -39
- package/dist/cjs/grpc/proto/sui/rpc/v2/move_package_service.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/name_service.client.js +8 -12
- package/dist/cjs/grpc/proto/sui/rpc/v2/name_service.client.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/name_service.js +21 -24
- package/dist/cjs/grpc/proto/sui/rpc/v2/name_service.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/object.js +15 -18
- package/dist/cjs/grpc/proto/sui/rpc/v2/object.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/object_reference.js +3 -6
- package/dist/cjs/grpc/proto/sui/rpc/v2/object_reference.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/owner.js +5 -8
- package/dist/cjs/grpc/proto/sui/rpc/v2/owner.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/protocol_config.js +3 -6
- package/dist/cjs/grpc/proto/sui/rpc/v2/protocol_config.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature.js +67 -70
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_scheme.js +2 -5
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_scheme.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_verification_service.client.js +7 -11
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_verification_service.client.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_verification_service.js +15 -18
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_verification_service.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/state_service.client.js +11 -15
- package/dist/cjs/grpc/proto/sui/rpc/v2/state_service.client.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/state_service.js +67 -70
- package/dist/cjs/grpc/proto/sui/rpc/v2/state_service.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/subscription_service.client.js +7 -11
- package/dist/cjs/grpc/proto/sui/rpc/v2/subscription_service.client.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/subscription_service.js +13 -16
- package/dist/cjs/grpc/proto/sui/rpc/v2/subscription_service.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/system_state.js +38 -41
- package/dist/cjs/grpc/proto/sui/rpc/v2/system_state.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction.js +124 -127
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction_execution_service.client.js +8 -12
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction_execution_service.client.js.map +1 -1
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction_execution_service.js +41 -44
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction_execution_service.js.map +1 -1
- package/dist/cjs/index.js +22 -87
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/jsonRpc/client.js +29 -34
- package/dist/cjs/jsonRpc/client.js.map +1 -1
- package/dist/cjs/jsonRpc/core.js +29 -33
- package/dist/cjs/jsonRpc/core.js.map +1 -1
- package/dist/cjs/jsonRpc/errors.js +3 -9
- package/dist/cjs/jsonRpc/errors.js.map +1 -1
- package/dist/cjs/jsonRpc/http-transport.js +9 -13
- package/dist/cjs/jsonRpc/http-transport.js.map +1 -1
- package/dist/cjs/jsonRpc/index.js +3 -12
- package/dist/cjs/jsonRpc/index.js.map +1 -1
- package/dist/cjs/jsonRpc/json-rpc-resolver.js +19 -22
- package/dist/cjs/jsonRpc/json-rpc-resolver.js.map +1 -1
- package/dist/cjs/jsonRpc/rpc-websocket-client.js +5 -9
- package/dist/cjs/jsonRpc/rpc-websocket-client.js.map +1 -1
- package/dist/cjs/jsonRpc/types/chain.js +1 -2
- package/dist/cjs/jsonRpc/types/chain.js.map +1 -1
- package/dist/cjs/jsonRpc/types/changes.js +1 -2
- package/dist/cjs/jsonRpc/types/changes.js.map +1 -1
- package/dist/cjs/jsonRpc/types/coins.js +1 -2
- package/dist/cjs/jsonRpc/types/coins.js.map +1 -1
- package/dist/cjs/jsonRpc/types/common.js +1 -2
- package/dist/cjs/jsonRpc/types/common.js.map +1 -1
- package/dist/cjs/jsonRpc/types/generated.js +1 -2
- package/dist/cjs/jsonRpc/types/generated.js.map +1 -1
- package/dist/cjs/jsonRpc/types/index.js +1 -2
- package/dist/cjs/jsonRpc/types/index.js.map +1 -1
- package/dist/cjs/jsonRpc/types/params.js +1 -2
- package/dist/cjs/jsonRpc/types/params.js.map +1 -1
- package/dist/cjs/keypairs/ed25519/ed25519-hd-key.js +7 -11
- package/dist/cjs/keypairs/ed25519/ed25519-hd-key.js.map +1 -1
- package/dist/cjs/keypairs/ed25519/index.js +2 -8
- package/dist/cjs/keypairs/ed25519/index.js.map +1 -1
- package/dist/cjs/keypairs/ed25519/keypair.js +26 -30
- package/dist/cjs/keypairs/ed25519/keypair.js.map +1 -1
- package/dist/cjs/keypairs/ed25519/publickey.js +10 -14
- package/dist/cjs/keypairs/ed25519/publickey.js.map +1 -1
- package/dist/cjs/keypairs/index.js +4 -20
- package/dist/cjs/keypairs/index.js.map +1 -1
- package/dist/cjs/keypairs/passkey/index.js +2 -9
- package/dist/cjs/keypairs/passkey/index.js.map +1 -1
- package/dist/cjs/keypairs/passkey/keypair.js +29 -35
- package/dist/cjs/keypairs/passkey/keypair.js.map +1 -1
- package/dist/cjs/keypairs/passkey/publickey.js +35 -41
- package/dist/cjs/keypairs/passkey/publickey.js.map +1 -1
- package/dist/cjs/keypairs/passkey/types.js +1 -2
- package/dist/cjs/keypairs/passkey/types.js.map +1 -1
- package/dist/cjs/keypairs/secp256k1/index.js +2 -8
- package/dist/cjs/keypairs/secp256k1/index.js.map +1 -1
- package/dist/cjs/keypairs/secp256k1/keypair.js +25 -29
- package/dist/cjs/keypairs/secp256k1/keypair.js.map +1 -1
- package/dist/cjs/keypairs/secp256k1/publickey.js +11 -15
- package/dist/cjs/keypairs/secp256k1/publickey.js.map +1 -1
- package/dist/cjs/keypairs/secp256r1/index.js +2 -8
- package/dist/cjs/keypairs/secp256r1/index.js.map +1 -1
- package/dist/cjs/keypairs/secp256r1/keypair.js +25 -29
- package/dist/cjs/keypairs/secp256r1/keypair.js.map +1 -1
- package/dist/cjs/keypairs/secp256r1/publickey.js +12 -16
- package/dist/cjs/keypairs/secp256r1/publickey.js.map +1 -1
- package/dist/cjs/multisig/index.js +2 -8
- package/dist/cjs/multisig/index.js.map +1 -1
- package/dist/cjs/multisig/publickey.js +40 -45
- package/dist/cjs/multisig/publickey.js.map +1 -1
- package/dist/cjs/multisig/signer.js +5 -9
- package/dist/cjs/multisig/signer.js.map +1 -1
- package/dist/cjs/transactions/Arguments.js +5 -8
- package/dist/cjs/transactions/Arguments.js.map +1 -1
- package/dist/cjs/transactions/Commands.js +21 -24
- package/dist/cjs/transactions/Commands.js.map +1 -1
- package/dist/cjs/transactions/Inputs.js +7 -10
- package/dist/cjs/transactions/Inputs.js.map +1 -1
- package/dist/cjs/transactions/ObjectCache.js +7 -13
- package/dist/cjs/transactions/ObjectCache.js.map +1 -1
- package/dist/cjs/transactions/Transaction.js +54 -59
- package/dist/cjs/transactions/Transaction.js.map +1 -1
- package/dist/cjs/transactions/TransactionData.js +27 -31
- package/dist/cjs/transactions/TransactionData.js.map +1 -1
- package/dist/cjs/transactions/__tests__/Transaction.test.js +71 -73
- package/dist/cjs/transactions/__tests__/Transaction.test.js.map +1 -1
- package/dist/cjs/transactions/__tests__/bcs.test.js +26 -28
- package/dist/cjs/transactions/__tests__/bcs.test.js.map +1 -1
- package/dist/cjs/transactions/data/internal.js +122 -126
- package/dist/cjs/transactions/data/internal.js.map +1 -1
- package/dist/cjs/transactions/data/v1.js +114 -119
- package/dist/cjs/transactions/data/v1.js.map +1 -1
- package/dist/cjs/transactions/data/v2.js +63 -66
- package/dist/cjs/transactions/data/v2.js.map +1 -1
- package/dist/cjs/transactions/executor/caching.js +7 -11
- package/dist/cjs/transactions/executor/caching.js.map +1 -1
- package/dist/cjs/transactions/executor/parallel.js +20 -24
- package/dist/cjs/transactions/executor/parallel.js.map +1 -1
- package/dist/cjs/transactions/executor/queue.js +2 -7
- package/dist/cjs/transactions/executor/queue.js.map +1 -1
- package/dist/cjs/transactions/executor/serial.js +11 -16
- package/dist/cjs/transactions/executor/serial.js.map +1 -1
- package/dist/cjs/transactions/hash.js +3 -6
- package/dist/cjs/transactions/hash.js.map +1 -1
- package/dist/cjs/transactions/index.js +12 -31
- package/dist/cjs/transactions/index.js.map +1 -1
- package/dist/cjs/transactions/intents/CoinWithBalance.js +21 -25
- package/dist/cjs/transactions/intents/CoinWithBalance.js.map +1 -1
- package/dist/cjs/transactions/object.js +4 -7
- package/dist/cjs/transactions/object.js.map +1 -1
- package/dist/cjs/transactions/plugins/NamedPackagesPlugin.js +2 -7
- package/dist/cjs/transactions/plugins/NamedPackagesPlugin.js.map +1 -1
- package/dist/cjs/transactions/pure.js +19 -22
- package/dist/cjs/transactions/pure.js.map +1 -1
- package/dist/cjs/transactions/resolve.js +10 -15
- package/dist/cjs/transactions/resolve.js.map +1 -1
- package/dist/cjs/transactions/serializer.js +34 -40
- package/dist/cjs/transactions/serializer.js.map +1 -1
- package/dist/cjs/transactions/utils.js +15 -23
- package/dist/cjs/transactions/utils.js.map +1 -1
- package/dist/cjs/utils/constants.js +18 -21
- package/dist/cjs/utils/constants.js.map +1 -1
- package/dist/cjs/utils/derived-objects.js +5 -8
- package/dist/cjs/utils/derived-objects.js.map +1 -1
- package/dist/cjs/utils/dynamic-fields.js +9 -12
- package/dist/cjs/utils/dynamic-fields.js.map +1 -1
- package/dist/cjs/utils/format.js +2 -6
- package/dist/cjs/utils/format.js.map +1 -1
- package/dist/cjs/utils/index.js +10 -46
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/move-registry.js +5 -10
- package/dist/cjs/utils/move-registry.js.map +1 -1
- package/dist/cjs/utils/sui-types.js +15 -25
- package/dist/cjs/utils/sui-types.js.map +1 -1
- package/dist/cjs/utils/suins.js +2 -6
- package/dist/cjs/utils/suins.js.map +1 -1
- package/dist/cjs/verify/index.js +1 -9
- package/dist/cjs/verify/index.js.map +1 -1
- package/dist/cjs/verify/verify.js +21 -28
- package/dist/cjs/verify/verify.js.map +1 -1
- package/dist/cjs/version.js +2 -5
- package/dist/cjs/version.js.map +1 -1
- package/dist/cjs/w/call/allocation.js +88 -99
- package/dist/cjs/w/call/allocation.js.map +1 -1
- package/dist/cjs/w/call/arb.js +49 -58
- package/dist/cjs/w/call/arb.js.map +1 -1
- package/dist/cjs/w/call/arbitration.js +380 -406
- package/dist/cjs/w/call/arbitration.js.map +1 -1
- package/dist/cjs/w/call/base.js +63 -73
- package/dist/cjs/w/call/base.js.map +1 -1
- package/dist/cjs/w/call/contact.js +111 -123
- package/dist/cjs/w/call/contact.js.map +1 -1
- package/dist/cjs/w/call/demand.js +221 -238
- package/dist/cjs/w/call/demand.js.map +1 -1
- package/dist/cjs/w/call/entity.js +58 -75
- package/dist/cjs/w/call/entity.js.map +1 -1
- package/dist/cjs/w/call/guard-ins.js +1191 -1196
- package/dist/cjs/w/call/guard-ins.js.map +1 -1
- package/dist/cjs/w/call/guard.js +265 -286
- package/dist/cjs/w/call/guard.js.map +1 -1
- package/dist/cjs/w/call/index.js +22 -66
- package/dist/cjs/w/call/index.js.map +1 -1
- package/dist/cjs/w/call/machine.js +351 -378
- package/dist/cjs/w/call/machine.js.map +1 -1
- package/dist/cjs/w/call/order.js +102 -113
- package/dist/cjs/w/call/order.js.map +1 -1
- package/dist/cjs/w/call/passport.js +53 -65
- package/dist/cjs/w/call/passport.js.map +1 -1
- package/dist/cjs/w/call/payment.js +41 -50
- package/dist/cjs/w/call/payment.js.map +1 -1
- package/dist/cjs/w/call/permission.js +233 -263
- package/dist/cjs/w/call/permission.js.map +1 -1
- package/dist/cjs/w/call/personal.js +38 -42
- package/dist/cjs/w/call/personal.js.map +1 -1
- package/dist/cjs/w/call/progress.js +222 -240
- package/dist/cjs/w/call/progress.js.map +1 -1
- package/dist/cjs/w/call/proof.js +23 -30
- package/dist/cjs/w/call/proof.js.map +1 -1
- package/dist/cjs/w/call/repository.js +283 -302
- package/dist/cjs/w/call/repository.js.map +1 -1
- package/dist/cjs/w/call/resource.js +27 -37
- package/dist/cjs/w/call/resource.js.map +1 -1
- package/dist/cjs/w/call/reward.js +227 -241
- package/dist/cjs/w/call/reward.js.map +1 -1
- package/dist/cjs/w/call/service.js +653 -694
- package/dist/cjs/w/call/service.js.map +1 -1
- package/dist/cjs/w/call/treasury.js +270 -289
- package/dist/cjs/w/call/treasury.js.map +1 -1
- package/dist/cjs/w/call/util.js +201 -208
- package/dist/cjs/w/call/util.js.map +1 -1
- package/dist/cjs/w/common.js +117 -168
- package/dist/cjs/w/common.js.map +1 -1
- package/dist/cjs/w/exception.js +18 -30
- package/dist/cjs/w/exception.js.map +1 -1
- package/dist/cjs/w/index.js +8 -24
- package/dist/cjs/w/index.js.map +1 -1
- package/dist/cjs/w/local/account.js +73 -77
- package/dist/cjs/w/local/account.js.map +1 -1
- package/dist/cjs/w/local/cache.js +5 -9
- package/dist/cjs/w/local/cache.js.map +1 -1
- package/dist/cjs/w/local/config.js +10 -14
- package/dist/cjs/w/local/config.js.map +1 -1
- package/dist/cjs/w/local/index.js +65 -98
- package/dist/cjs/w/local/index.js.map +1 -1
- package/dist/cjs/w/local/local.js +59 -65
- package/dist/cjs/w/local/local.js.map +1 -1
- package/dist/cjs/w/local/storage.js +13 -56
- package/dist/cjs/w/local/storage.js.map +1 -1
- package/dist/cjs/w/local/token.js +20 -24
- package/dist/cjs/w/local/token.js.map +1 -1
- package/dist/cjs/w/local/util.js +3 -39
- package/dist/cjs/w/local/util.js.map +1 -1
- package/dist/cjs/w/local/wip.js +22 -70
- package/dist/cjs/w/local/wip.js.map +1 -1
- package/dist/cjs/w/messenger/crypto.js +34 -57
- package/dist/cjs/w/messenger/crypto.js.map +1 -1
- package/dist/cjs/w/messenger/index.js +4 -31
- package/dist/cjs/w/messenger/index.js.map +1 -1
- package/dist/cjs/w/messenger/messenger-api.js +125 -174
- package/dist/cjs/w/messenger/messenger-api.js.map +1 -1
- package/dist/cjs/w/messenger/messenger-manager.js +49 -53
- package/dist/cjs/w/messenger/messenger-manager.js.map +1 -1
- package/dist/cjs/w/messenger/messenger.js +100 -137
- package/dist/cjs/w/messenger/messenger.js.map +1 -1
- package/dist/cjs/w/messenger/server.js +40 -44
- package/dist/cjs/w/messenger/server.js.map +1 -1
- package/dist/cjs/w/messenger/session.js +52 -56
- package/dist/cjs/w/messenger/session.js.map +1 -1
- package/dist/cjs/w/messenger/storage.js +13 -57
- package/dist/cjs/w/messenger/storage.js.map +1 -1
- package/dist/cjs/w/messenger/types.js +23 -27
- package/dist/cjs/w/messenger/types.js.map +1 -1
- package/dist/cjs/w/messenger/utils.js +1 -4
- package/dist/cjs/w/messenger/utils.js.map +1 -1
- package/dist/cjs/w/query/bult-in.js +22 -27
- package/dist/cjs/w/query/bult-in.js.map +1 -1
- package/dist/cjs/w/query/event.js +13 -18
- package/dist/cjs/w/query/event.js.map +1 -1
- package/dist/cjs/w/query/index.js +5 -21
- package/dist/cjs/w/query/index.js.map +1 -1
- package/dist/cjs/w/query/object.js +229 -266
- package/dist/cjs/w/query/object.js.map +1 -1
- package/dist/cjs/w/query/received.js +17 -21
- package/dist/cjs/w/query/received.js.map +1 -1
- package/dist/cjs/w/query/util.js +13 -17
- package/dist/cjs/w/query/util.js.map +1 -1
- package/dist/cjs/w/util.js +211 -225
- package/dist/cjs/w/util.js.map +1 -1
- package/dist/esm/experimental/persistent-storage.test.js +1 -1
- package/dist/esm/experimental/persistent-storage.test.js.map +1 -1
- package/package.json +7 -4
- package/scripts/download-prebuilds.js +213 -195
- package/scripts/install-better-sqlite3.js +8 -8
|
@@ -1,70 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright (c) Wowok.
|
|
3
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
21
|
-
var ownKeys = function(o) {
|
|
22
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
23
|
-
var ar = [];
|
|
24
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
25
|
-
return ar;
|
|
26
|
-
};
|
|
27
|
-
return ownKeys(o);
|
|
28
|
-
};
|
|
29
|
-
return function (mod) {
|
|
30
|
-
if (mod && mod.__esModule) return mod;
|
|
31
|
-
var result = {};
|
|
32
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
33
|
-
__setModuleDefault(result, mod);
|
|
34
|
-
return result;
|
|
35
|
-
};
|
|
36
|
-
})();
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.getMessengerManager = getMessengerManager;
|
|
39
|
-
exports.watch_conversations = watch_conversations;
|
|
40
|
-
exports.send_message = send_message;
|
|
41
|
-
exports.send_file = send_file;
|
|
42
|
-
exports.watch_messages = watch_messages;
|
|
43
|
-
exports.extract_zip_messages = extract_zip_messages;
|
|
44
|
-
exports.generate_wts = generate_wts;
|
|
45
|
-
exports.verify_wts = verify_wts;
|
|
46
|
-
exports.sign_wts = sign_wts;
|
|
47
|
-
exports.wts2html = wts2html;
|
|
48
|
-
exports.proof_message = proof_message;
|
|
49
|
-
exports.blacklist = blacklist;
|
|
50
|
-
exports.friendslist = friendslist;
|
|
51
|
-
exports.guardlist = guardlist;
|
|
52
|
-
const messenger_manager_js_1 = require("./messenger-manager.js");
|
|
53
|
-
const account_js_1 = require("../local/account.js");
|
|
54
|
-
const exception_js_1 = require("../exception.js");
|
|
55
|
-
const sui_types_js_1 = require("../../utils/sui-types.js");
|
|
56
|
-
const local_js_1 = require("../local/local.js");
|
|
57
|
-
const storage_js_1 = require("./storage.js");
|
|
58
|
-
const types_js_1 = require("./types.js");
|
|
59
|
-
const crypto_1 = require("crypto");
|
|
60
|
-
const fs = __importStar(require("fs"));
|
|
61
|
-
const path = __importStar(require("path"));
|
|
62
|
-
const common_js_1 = require("../common.js");
|
|
63
|
-
const crypto_js_1 = require("./crypto.js");
|
|
64
|
-
const utils_js_1 = require("./utils.js");
|
|
65
|
-
const index_js_1 = require("../local/index.js");
|
|
66
|
-
const object_js_1 = require("../query/object.js");
|
|
67
|
-
const messenger_js_1 = require("./messenger.js");
|
|
3
|
+
import { MessengerManager } from "./messenger-manager.js";
|
|
4
|
+
import { Account } from "../local/account.js";
|
|
5
|
+
import { W_ERROR, WErrors } from "../exception.js";
|
|
6
|
+
import { isValidWowAddress } from "../../utils/sui-types.js";
|
|
7
|
+
import { LocalMark } from "../local/local.js";
|
|
8
|
+
import { MessageStorage } from "./storage.js";
|
|
9
|
+
import { MessengerError, MessengerErrorCode, CHAIN_PROOF_TYPE, } from "./types.js";
|
|
10
|
+
import { createHash } from "crypto";
|
|
11
|
+
import * as fs from "fs";
|
|
12
|
+
import * as path from "path";
|
|
13
|
+
import { isValidU64 } from "../common.js";
|
|
14
|
+
import { verifySingleMerkleRoot, hashPlaintext, verifyEd25519Signature, } from "./crypto.js";
|
|
15
|
+
import { canonicalizeJson } from "./utils.js";
|
|
16
|
+
import { GetAccountOrMark_Address, GetManyAccountOrMark_Address, } from "../local/index.js";
|
|
17
|
+
import { query_objects } from "../query/object.js";
|
|
18
|
+
import { Messenger } from "./messenger.js";
|
|
68
19
|
let managerInstance = null;
|
|
69
20
|
let isInitialized = false;
|
|
70
21
|
let backgroundTimer = null;
|
|
@@ -73,12 +24,12 @@ let backgroundTimer = null;
|
|
|
73
24
|
* 如果账号已注册(identity 已存在),则跳过
|
|
74
25
|
*/
|
|
75
26
|
async function autoRegisterMessengerAccounts() {
|
|
76
|
-
const accounts = await
|
|
27
|
+
const accounts = await Account.Instance().list_messenger_accounts();
|
|
77
28
|
for (const account of accounts) {
|
|
78
29
|
if (!account.address || !account.m) {
|
|
79
30
|
continue;
|
|
80
31
|
}
|
|
81
|
-
const messenger = new
|
|
32
|
+
const messenger = new Messenger(account.address);
|
|
82
33
|
await messenger.initialize();
|
|
83
34
|
}
|
|
84
35
|
}
|
|
@@ -86,9 +37,9 @@ async function autoRegisterMessengerAccounts() {
|
|
|
86
37
|
* 获取 MessengerManager 实例(单例)
|
|
87
38
|
* 首次调用时会自动启动后台服务
|
|
88
39
|
*/
|
|
89
|
-
function getMessengerManager() {
|
|
40
|
+
export function getMessengerManager() {
|
|
90
41
|
if (!managerInstance) {
|
|
91
|
-
managerInstance = new
|
|
42
|
+
managerInstance = new MessengerManager();
|
|
92
43
|
}
|
|
93
44
|
if (!isInitialized) {
|
|
94
45
|
isInitialized = true;
|
|
@@ -156,10 +107,10 @@ function registerCleanupHandler() {
|
|
|
156
107
|
}
|
|
157
108
|
registerCleanupHandler();
|
|
158
109
|
startBackgroundTimer();
|
|
159
|
-
async function watch_conversations(account) {
|
|
160
|
-
const address = await
|
|
110
|
+
export async function watch_conversations(account) {
|
|
111
|
+
const address = await Account.Instance().get_address(account);
|
|
161
112
|
if (!address) {
|
|
162
|
-
|
|
113
|
+
W_ERROR(WErrors.AccountNotFound, `watch_conversations.account ${account}`);
|
|
163
114
|
}
|
|
164
115
|
const manager = getMessengerManager();
|
|
165
116
|
return manager.get_conversations(address);
|
|
@@ -173,23 +124,23 @@ async function watch_conversations(account) {
|
|
|
173
124
|
* @param options 可选配置
|
|
174
125
|
* @returns SendMessageResult
|
|
175
126
|
*/
|
|
176
|
-
async function send_message(from, to, content, options) {
|
|
177
|
-
const fromAddress = await
|
|
127
|
+
export async function send_message(from, to, content, options) {
|
|
128
|
+
const fromAddress = await Account.Instance().get_address(from);
|
|
178
129
|
if (!fromAddress) {
|
|
179
|
-
|
|
130
|
+
W_ERROR(WErrors.AccountNotFound, `send_message.from ${from}`);
|
|
180
131
|
}
|
|
181
|
-
const t = await
|
|
132
|
+
const t = await GetAccountOrMark_Address(to);
|
|
182
133
|
if (!t) {
|
|
183
|
-
|
|
134
|
+
W_ERROR(WErrors.AccountNotFound, `send_message.to ${to} is not a valid account/address`);
|
|
184
135
|
}
|
|
185
136
|
if (options?.guardAddress != null && options?.passportAddress != null) {
|
|
186
137
|
[options.guardAddress, options.passportAddress] =
|
|
187
|
-
await
|
|
138
|
+
await LocalMark.Instance().get_many_address([
|
|
188
139
|
options.guardAddress,
|
|
189
140
|
options.passportAddress,
|
|
190
141
|
]);
|
|
191
142
|
if (!options.guardAddress || !options.passportAddress) {
|
|
192
|
-
|
|
143
|
+
W_ERROR(WErrors.AccountNotFound, `send_message.guardAddress or passportAddress not found`);
|
|
193
144
|
}
|
|
194
145
|
}
|
|
195
146
|
const manager = getMessengerManager();
|
|
@@ -207,23 +158,23 @@ async function send_message(from, to, content, options) {
|
|
|
207
158
|
* @param options 可选配置
|
|
208
159
|
* @returns SendMessageResult
|
|
209
160
|
*/
|
|
210
|
-
async function send_file(from, to, filePath, options) {
|
|
211
|
-
const fromAddress = await
|
|
161
|
+
export async function send_file(from, to, filePath, options) {
|
|
162
|
+
const fromAddress = await Account.Instance().get_address(from);
|
|
212
163
|
if (!fromAddress) {
|
|
213
|
-
|
|
164
|
+
W_ERROR(WErrors.AccountNotFound, `send_file.from ${from}`);
|
|
214
165
|
}
|
|
215
|
-
const t = await
|
|
166
|
+
const t = await GetAccountOrMark_Address(to);
|
|
216
167
|
if (!t) {
|
|
217
|
-
|
|
168
|
+
W_ERROR(WErrors.AccountNotFound, `send_file.to ${to} is not a valid account/address`);
|
|
218
169
|
}
|
|
219
170
|
if (options?.guardAddress != null && options?.passportAddress != null) {
|
|
220
171
|
[options.guardAddress, options.passportAddress] =
|
|
221
|
-
await
|
|
172
|
+
await LocalMark.Instance().get_many_address([
|
|
222
173
|
options.guardAddress,
|
|
223
174
|
options.passportAddress,
|
|
224
175
|
]);
|
|
225
176
|
if (!options.guardAddress || !options.passportAddress) {
|
|
226
|
-
|
|
177
|
+
W_ERROR(WErrors.AccountNotFound, `send_file.guardAddress or passportAddress not found`);
|
|
227
178
|
}
|
|
228
179
|
}
|
|
229
180
|
const manager = getMessengerManager();
|
|
@@ -235,15 +186,15 @@ async function send_file(from, to, filePath, options) {
|
|
|
235
186
|
* @param filter 过滤条件
|
|
236
187
|
* @returns Message 数组
|
|
237
188
|
*/
|
|
238
|
-
async function watch_messages(filter) {
|
|
189
|
+
export async function watch_messages(filter) {
|
|
239
190
|
if (filter?.account) {
|
|
240
|
-
filter.account = await
|
|
191
|
+
filter.account = await Account.Instance().get_address(filter.account);
|
|
241
192
|
}
|
|
242
193
|
if (filter?.customListFilter?.includeAddresses != null) {
|
|
243
|
-
filter.customListFilter.includeAddresses = (await
|
|
194
|
+
filter.customListFilter.includeAddresses = (await Account.Instance().get_many_address(filter.customListFilter.includeAddresses)).filter((v) => v != null);
|
|
244
195
|
}
|
|
245
196
|
if (filter?.customListFilter?.excludeAddresses != null) {
|
|
246
|
-
filter.customListFilter.excludeAddresses = (await
|
|
197
|
+
filter.customListFilter.excludeAddresses = (await Account.Instance().get_many_address(filter.customListFilter.excludeAddresses)).filter((v) => v != null);
|
|
247
198
|
}
|
|
248
199
|
const manager = getMessengerManager();
|
|
249
200
|
return manager.watch(filter);
|
|
@@ -257,20 +208,20 @@ async function watch_messages(filter) {
|
|
|
257
208
|
*/
|
|
258
209
|
async function extract_zip_message(message, outputDir) {
|
|
259
210
|
if (!message.zipMetadata) {
|
|
260
|
-
throw new
|
|
211
|
+
throw new MessengerError(MessengerErrorCode.INVALID_MESSAGE_TYPE, "Message is not a ZIP archive");
|
|
261
212
|
}
|
|
262
213
|
if (!message.plaintext) {
|
|
263
|
-
throw new
|
|
214
|
+
throw new MessengerError(MessengerErrorCode.MESSAGE_NOT_DECRYPTED, "Message plaintext not available");
|
|
264
215
|
}
|
|
265
216
|
// 1. 解码 base64 ZIP 数据
|
|
266
217
|
const zipBase64 = message.plaintext;
|
|
267
218
|
const zipData = Buffer.from(zipBase64, "base64");
|
|
268
219
|
// 2. 验证文件哈希
|
|
269
220
|
if (message.zipMetadata?.fileHash) {
|
|
270
|
-
const actualHash =
|
|
221
|
+
const actualHash = createHash("sha256").update(zipData).digest("hex");
|
|
271
222
|
const expectedHash = message.zipMetadata.fileHash.replace("0x", "");
|
|
272
223
|
if (actualHash !== expectedHash) {
|
|
273
|
-
throw new
|
|
224
|
+
throw new MessengerError(MessengerErrorCode.HASH_MISMATCH, `ZIP file hash mismatch: expected ${expectedHash}, got ${actualHash}`);
|
|
274
225
|
}
|
|
275
226
|
}
|
|
276
227
|
// 3. 解压 ZIP 文件
|
|
@@ -306,7 +257,7 @@ async function extract_zip_message(message, outputDir) {
|
|
|
306
257
|
const userAddress = message.direction === "sent"
|
|
307
258
|
? message.fromAddress
|
|
308
259
|
: message.toAddress;
|
|
309
|
-
const messageStorage = new
|
|
260
|
+
const messageStorage = new MessageStorage(userAddress);
|
|
310
261
|
messageStorage.saveMessage(message);
|
|
311
262
|
}
|
|
312
263
|
return savedPaths[0] || "";
|
|
@@ -319,11 +270,11 @@ async function extract_zip_message(message, outputDir) {
|
|
|
319
270
|
* @param userAddress 用户地址(当传入消息ID数组时需要)
|
|
320
271
|
* @returns 解压后的文件路径数组
|
|
321
272
|
*/
|
|
322
|
-
async function extract_zip_messages(account, messages, outputDir) {
|
|
273
|
+
export async function extract_zip_messages(account, messages, outputDir) {
|
|
323
274
|
const results = [];
|
|
324
|
-
const userAddress = await
|
|
275
|
+
const userAddress = await Account.Instance().get_address(account);
|
|
325
276
|
if (!userAddress) {
|
|
326
|
-
throw new
|
|
277
|
+
throw new MessengerError(MessengerErrorCode.INVALID_INPUT, "account is required when extracting by message IDs");
|
|
327
278
|
}
|
|
328
279
|
// 判断是 Message 数组还是 messageId 数组
|
|
329
280
|
const isMessageIds = messages.length > 0 && typeof messages[0] === "string";
|
|
@@ -332,7 +283,7 @@ async function extract_zip_messages(account, messages, outputDir) {
|
|
|
332
283
|
let message;
|
|
333
284
|
if (isMessageIds) {
|
|
334
285
|
const messageId = item;
|
|
335
|
-
const messageStorage = new
|
|
286
|
+
const messageStorage = new MessageStorage(userAddress);
|
|
336
287
|
const storedMessage = messageStorage.getMessageById(messageId);
|
|
337
288
|
if (!storedMessage) {
|
|
338
289
|
console.error(`Message not found: ${messageId}`);
|
|
@@ -360,15 +311,15 @@ async function extract_zip_messages(account, messages, outputDir) {
|
|
|
360
311
|
}
|
|
361
312
|
return results;
|
|
362
313
|
}
|
|
363
|
-
async function generate_wts(params) {
|
|
364
|
-
const myAddress = await
|
|
314
|
+
export async function generate_wts(params) {
|
|
315
|
+
const myAddress = await Account.Instance().get_address(params.myAccount);
|
|
365
316
|
if (!myAddress) {
|
|
366
|
-
|
|
317
|
+
W_ERROR(WErrors.AccountNotFound, `generate_wts.myAccount ${params.myAccount}`);
|
|
367
318
|
}
|
|
368
|
-
if (!
|
|
369
|
-
const t = await
|
|
319
|
+
if (!isValidWowAddress(params.peerAccount)) {
|
|
320
|
+
const t = await Account.Instance().get_address(params.peerAccount);
|
|
370
321
|
if (!t) {
|
|
371
|
-
|
|
322
|
+
W_ERROR(WErrors.AccountNotFound, `generate_wts.peerAccount ${params.peerAccount}`);
|
|
372
323
|
}
|
|
373
324
|
params.peerAccount = t;
|
|
374
325
|
}
|
|
@@ -410,7 +361,7 @@ function save_wts(wtsFile, filePath) {
|
|
|
410
361
|
* @param wtsFilePath WTS 文件路径(本地或网络文件)
|
|
411
362
|
* @returns 验证结果
|
|
412
363
|
*/
|
|
413
|
-
async function verify_wts(wtsFilePath) {
|
|
364
|
+
export async function verify_wts(wtsFilePath) {
|
|
414
365
|
try {
|
|
415
366
|
// 1. 加载 WTS 文件
|
|
416
367
|
const wtsFile = load_wts(wtsFilePath);
|
|
@@ -428,7 +379,7 @@ async function verify_wts(wtsFilePath) {
|
|
|
428
379
|
// 2. 验证每个消息的 Merkle Root 计算(不验证跨消息链连续性)
|
|
429
380
|
// 因为消息可能来自不同的 Merkle Tree(不同会话方向)
|
|
430
381
|
for (const msg of payload.messages) {
|
|
431
|
-
const result =
|
|
382
|
+
const result = verifySingleMerkleRoot(msg.prevRoot, msg.merkleRoot, msg.plaintextHash, msg.timestamp, msg.leafIndex);
|
|
432
383
|
if (!result.valid) {
|
|
433
384
|
return {
|
|
434
385
|
valid: false,
|
|
@@ -453,7 +404,7 @@ async function verify_wts(wtsFilePath) {
|
|
|
453
404
|
}
|
|
454
405
|
// 如果提供了明文,验证 plaintextHash
|
|
455
406
|
if (msg.plaintext) {
|
|
456
|
-
const computedHash =
|
|
407
|
+
const computedHash = hashPlaintext(msg.plaintext, msg.clientTimestamp, msg.guardAddress, msg.passportAddress, msg.lastReceivedLeafIndex);
|
|
457
408
|
if (computedHash.toLowerCase() !==
|
|
458
409
|
msg.plaintextHash.toLowerCase()) {
|
|
459
410
|
return {
|
|
@@ -485,7 +436,7 @@ async function verify_wts(wtsFilePath) {
|
|
|
485
436
|
};
|
|
486
437
|
}
|
|
487
438
|
const signData = `${msg.prevRoot}:${msg.merkleRoot}:${msg.timestamp}:${msg.serverPublicKey}`;
|
|
488
|
-
const signatureValid =
|
|
439
|
+
const signatureValid = verifyEd25519Signature(msg.serverPublicKey, signData, msg.serverSignature);
|
|
489
440
|
if (!signatureValid) {
|
|
490
441
|
return {
|
|
491
442
|
valid: false,
|
|
@@ -497,7 +448,7 @@ async function verify_wts(wtsFilePath) {
|
|
|
497
448
|
// 4. 验证 payload 哈希
|
|
498
449
|
const { sha256 } = await import("@noble/hashes/sha256");
|
|
499
450
|
const { bytesToHex } = await import("@noble/hashes/utils");
|
|
500
|
-
const canonicalPayload =
|
|
451
|
+
const canonicalPayload = canonicalizeJson(payload);
|
|
501
452
|
const computedHash = "sha256:" +
|
|
502
453
|
bytesToHex(sha256(new TextEncoder().encode(canonicalPayload)));
|
|
503
454
|
// DEBUG: 打印调试信息
|
|
@@ -681,21 +632,21 @@ async function verify_wts(wtsFilePath) {
|
|
|
681
632
|
* @param outputPath 输出文件路径(可选,默认覆盖原文件)
|
|
682
633
|
* @returns 签名后的 WTS 文件路径
|
|
683
634
|
*/
|
|
684
|
-
async function sign_wts(wtsFilePath, account, outputPath) {
|
|
635
|
+
export async function sign_wts(wtsFilePath, account, outputPath) {
|
|
685
636
|
// 1. 验证 WTS 文件格式(内部会加载文件)
|
|
686
637
|
const verifyResult = await verify_wts(wtsFilePath);
|
|
687
638
|
if (!verifyResult.valid) {
|
|
688
|
-
throw new
|
|
639
|
+
throw new MessengerError(MessengerErrorCode.INVALID_INPUT, `WTS file verification failed: ${verifyResult.error}`);
|
|
689
640
|
}
|
|
690
641
|
// 2. 加载 WTS 文件
|
|
691
642
|
const wtsFile = load_wts(wtsFilePath);
|
|
692
643
|
// 3. 获取签名者地址
|
|
693
|
-
const address = await
|
|
644
|
+
const address = await Account.Instance().get_address(account);
|
|
694
645
|
if (!address) {
|
|
695
|
-
|
|
646
|
+
W_ERROR(WErrors.AccountNotFound, `sign_wts.account ${account}`);
|
|
696
647
|
}
|
|
697
648
|
// 4. 使用 Account 签名(同时获取公钥)
|
|
698
|
-
const signResult = await
|
|
649
|
+
const signResult = await Account.Instance().signData(address, wtsFile.meta.hash);
|
|
699
650
|
// 6. 转换公钥格式为 base64 (32字节)
|
|
700
651
|
let publicKeyBase64;
|
|
701
652
|
const pk = signResult.publicKey;
|
|
@@ -709,7 +660,7 @@ async function sign_wts(wtsFilePath, account, outputPath) {
|
|
|
709
660
|
publicKeyBase64 = buffer.toString("base64");
|
|
710
661
|
}
|
|
711
662
|
else {
|
|
712
|
-
throw new
|
|
663
|
+
throw new MessengerError(MessengerErrorCode.INVALID_INPUT, `Invalid public key length: ${buffer.length}, expected 32 or 33 bytes`);
|
|
713
664
|
}
|
|
714
665
|
}
|
|
715
666
|
else {
|
|
@@ -768,7 +719,7 @@ async function sign_wts(wtsFilePath, account, outputPath) {
|
|
|
768
719
|
save_wts(signedWtsFile, savePath);
|
|
769
720
|
return savePath;
|
|
770
721
|
}
|
|
771
|
-
async function wts2html(wtsPath, options = {}) {
|
|
722
|
+
export async function wts2html(wtsPath, options = {}) {
|
|
772
723
|
const fs = await import("fs");
|
|
773
724
|
const path = await import("path");
|
|
774
725
|
// 检查是文件还是文件夹
|
|
@@ -778,7 +729,7 @@ async function wts2html(wtsPath, options = {}) {
|
|
|
778
729
|
const files = fs.readdirSync(wtsPath);
|
|
779
730
|
const wtsFiles = files.filter((f) => f.endsWith(".wts"));
|
|
780
731
|
if (wtsFiles.length === 0) {
|
|
781
|
-
throw new
|
|
732
|
+
throw new MessengerError(MessengerErrorCode.INVALID_INPUT, `No .wts files found in directory: ${wtsPath}`);
|
|
782
733
|
}
|
|
783
734
|
const results = [];
|
|
784
735
|
for (const file of wtsFiles) {
|
|
@@ -1045,33 +996,33 @@ async function convertWtsToHtml(wtsFilePath, options = {}) {
|
|
|
1045
996
|
* @param env 调用环境(包含网络、签名账号等)
|
|
1046
997
|
* @returns 证明对象地址
|
|
1047
998
|
*/
|
|
1048
|
-
async function proof_message(account, messageId, network) {
|
|
999
|
+
export async function proof_message(account, messageId, network) {
|
|
1049
1000
|
// 1. 解析账号地址
|
|
1050
|
-
const address = await
|
|
1001
|
+
const address = await Account.Instance().get_address(account);
|
|
1051
1002
|
if (!address) {
|
|
1052
|
-
|
|
1003
|
+
W_ERROR(WErrors.AccountNotFound, `proof_message.account ${account}`);
|
|
1053
1004
|
}
|
|
1054
1005
|
// 2. 获取消息
|
|
1055
|
-
const messageStorage = new
|
|
1006
|
+
const messageStorage = new MessageStorage(address);
|
|
1056
1007
|
const message = messageStorage.getMessageById(messageId);
|
|
1057
1008
|
if (!message) {
|
|
1058
|
-
throw new
|
|
1009
|
+
throw new MessengerError(MessengerErrorCode.INVALID_INPUT, `Message not found: ${messageId}`);
|
|
1059
1010
|
}
|
|
1060
1011
|
// 3. 验证消息属于该账号
|
|
1061
1012
|
if (message.fromAddress.toLowerCase() !== address.toLowerCase() &&
|
|
1062
1013
|
message.toAddress.toLowerCase() !== address.toLowerCase()) {
|
|
1063
|
-
throw new
|
|
1014
|
+
throw new MessengerError(MessengerErrorCode.INVALID_INPUT, `Message does not belong to account ${address}`);
|
|
1064
1015
|
}
|
|
1065
1016
|
// 4. 验证服务器签名存在
|
|
1066
1017
|
if (!message.serverSignature) {
|
|
1067
|
-
throw new
|
|
1018
|
+
throw new MessengerError(MessengerErrorCode.INVALID_PROOF, `Message does not have server signature`);
|
|
1068
1019
|
}
|
|
1069
1020
|
if (!message.serverPublicKey) {
|
|
1070
|
-
throw new
|
|
1021
|
+
throw new MessengerError(MessengerErrorCode.INVALID_PROOF, `Message does not have server public key`);
|
|
1071
1022
|
}
|
|
1072
1023
|
// 5. 使用 verifyMessage 验证消息完整性(包含服务器签名验证)
|
|
1073
1024
|
if (!message.plaintext) {
|
|
1074
|
-
throw new
|
|
1025
|
+
throw new MessengerError(MessengerErrorCode.INVALID_PROOF, `Message does not have plaintext`);
|
|
1075
1026
|
}
|
|
1076
1027
|
const { verifyMessage } = await import("./crypto.js");
|
|
1077
1028
|
// 构造验证参数
|
|
@@ -1089,7 +1040,7 @@ async function proof_message(account, messageId, network) {
|
|
|
1089
1040
|
if (message.newRoot && message.leafIndex !== undefined) {
|
|
1090
1041
|
// 检查服务器时间戳是否存在
|
|
1091
1042
|
if (!message.serverTimestamp) {
|
|
1092
|
-
throw new
|
|
1043
|
+
throw new MessengerError(MessengerErrorCode.INVALID_PROOF, `Message ${message.messageId} missing server timestamp for verification`);
|
|
1093
1044
|
}
|
|
1094
1045
|
verifyParams.merkleMetadata = {
|
|
1095
1046
|
newRoot: message.newRoot,
|
|
@@ -1102,11 +1053,11 @@ async function proof_message(account, messageId, network) {
|
|
|
1102
1053
|
}
|
|
1103
1054
|
const verifyResult = verifyMessage(verifyParams);
|
|
1104
1055
|
if (!verifyResult.valid) {
|
|
1105
|
-
throw new
|
|
1056
|
+
throw new MessengerError(MessengerErrorCode.INVALID_PROOF, `Message verification failed: ${verifyResult.error}`);
|
|
1106
1057
|
}
|
|
1107
1058
|
// 6. 从消息中获取服务器公钥
|
|
1108
1059
|
if (!message.serverPublicKey) {
|
|
1109
|
-
throw new
|
|
1060
|
+
throw new MessengerError(MessengerErrorCode.INVALID_PROOF, `Message does not have server public key`);
|
|
1110
1061
|
}
|
|
1111
1062
|
// 7. 创建链上证明
|
|
1112
1063
|
const { CallProof } = await import("../call/proof.js");
|
|
@@ -1114,7 +1065,7 @@ async function proof_message(account, messageId, network) {
|
|
|
1114
1065
|
proof: message.newRoot, // 证明root存在
|
|
1115
1066
|
server_pubkey: message.serverPublicKey,
|
|
1116
1067
|
server_signature: message.serverSignature,
|
|
1117
|
-
proof_type:
|
|
1068
|
+
proof_type: CHAIN_PROOF_TYPE, // 消息证明类型
|
|
1118
1069
|
description: `Message proof for ${messageId}`,
|
|
1119
1070
|
item_count: message.leafIndex ?? 1,
|
|
1120
1071
|
about_address: message.fromAddress.toLowerCase() === address.toLowerCase()
|
|
@@ -1133,7 +1084,7 @@ async function proof_message(account, messageId, network) {
|
|
|
1133
1084
|
// 查找 Proof 类型的对象
|
|
1134
1085
|
const proofResult = responseData.find((item) => item.type === "Proof");
|
|
1135
1086
|
if (!proofResult || !proofResult.object) {
|
|
1136
|
-
throw new
|
|
1087
|
+
throw new MessengerError(MessengerErrorCode.INVALID_PROOF, `Failed to get proof address from transaction result`);
|
|
1137
1088
|
}
|
|
1138
1089
|
message.proof = proofResult.object;
|
|
1139
1090
|
messageStorage.saveMessage(message);
|
|
@@ -1149,35 +1100,35 @@ const MAX_GUARDS_SIZE_ONCE = 10;
|
|
|
1149
1100
|
* @param request 操作请求
|
|
1150
1101
|
* @returns 操作结果
|
|
1151
1102
|
*/
|
|
1152
|
-
async function blacklist(request) {
|
|
1153
|
-
const acc = await
|
|
1103
|
+
export async function blacklist(request) {
|
|
1104
|
+
const acc = await Account.Instance().get_address(request.account);
|
|
1154
1105
|
if (!acc) {
|
|
1155
|
-
|
|
1106
|
+
W_ERROR(WErrors.AccountNotFound, `blacklist.account ${request.account}`);
|
|
1156
1107
|
}
|
|
1157
1108
|
const manager = getMessengerManager();
|
|
1158
1109
|
switch (request.op) {
|
|
1159
1110
|
case "add": {
|
|
1160
|
-
let addresses = await
|
|
1111
|
+
let addresses = await GetManyAccountOrMark_Address(request.users);
|
|
1161
1112
|
if (addresses.length === 0) {
|
|
1162
|
-
|
|
1113
|
+
W_ERROR(WErrors.InvalidParam, `blacklist.add.users ${request.users} have not valid addresses`);
|
|
1163
1114
|
}
|
|
1164
1115
|
// 去重
|
|
1165
1116
|
addresses = [...new Set(addresses.map((a) => a.toLowerCase()))];
|
|
1166
1117
|
if (addresses.length > MAX_BLACKLIST_SIZE_ONCE) {
|
|
1167
|
-
|
|
1118
|
+
W_ERROR(WErrors.InvalidParam, `blacklist.add.users ${request.users} have too many addresses, max ${MAX_BLACKLIST_SIZE_ONCE}`);
|
|
1168
1119
|
}
|
|
1169
1120
|
const result = await manager.addToBlacklist(acc, addresses);
|
|
1170
1121
|
return { op: "add", result };
|
|
1171
1122
|
}
|
|
1172
1123
|
case "remove": {
|
|
1173
|
-
let addresses = await
|
|
1124
|
+
let addresses = await GetManyAccountOrMark_Address(request.users);
|
|
1174
1125
|
if (addresses.length === 0) {
|
|
1175
|
-
|
|
1126
|
+
W_ERROR(WErrors.InvalidParam, `blacklist.remove.users ${request.users} have not valid addresses`);
|
|
1176
1127
|
}
|
|
1177
1128
|
// 去重
|
|
1178
1129
|
addresses = [...new Set(addresses.map((a) => a.toLowerCase()))];
|
|
1179
1130
|
if (addresses.length > MAX_BLACKLIST_SIZE_ONCE) {
|
|
1180
|
-
|
|
1131
|
+
W_ERROR(WErrors.InvalidParam, `blacklist.remove.users ${request.users} have too many addresses, max ${MAX_BLACKLIST_SIZE_ONCE}`);
|
|
1181
1132
|
}
|
|
1182
1133
|
const result = await manager.removeFromBlacklist(acc, addresses);
|
|
1183
1134
|
return { op: "remove", result };
|
|
@@ -1191,20 +1142,20 @@ async function blacklist(request) {
|
|
|
1191
1142
|
return { op: "get", result };
|
|
1192
1143
|
}
|
|
1193
1144
|
case "exist": {
|
|
1194
|
-
let addresses = await
|
|
1145
|
+
let addresses = await GetManyAccountOrMark_Address(request.users);
|
|
1195
1146
|
if (addresses.length === 0) {
|
|
1196
|
-
|
|
1147
|
+
W_ERROR(WErrors.InvalidParam, `blacklist.exist.users ${request.users} have not valid addresses`);
|
|
1197
1148
|
}
|
|
1198
1149
|
// 去重
|
|
1199
1150
|
addresses = [...new Set(addresses.map((a) => a.toLowerCase()))];
|
|
1200
1151
|
if (addresses.length > MAX_BLACKLIST_SIZE_ONCE) {
|
|
1201
|
-
|
|
1152
|
+
W_ERROR(WErrors.InvalidParam, `blacklist.exist.users ${request.users} have too many addresses, max ${MAX_BLACKLIST_SIZE_ONCE}`);
|
|
1202
1153
|
}
|
|
1203
1154
|
const result = await manager.existInBlacklist(acc, addresses);
|
|
1204
1155
|
return { op: "exist", result };
|
|
1205
1156
|
}
|
|
1206
1157
|
default:
|
|
1207
|
-
throw new
|
|
1158
|
+
throw new MessengerError(MessengerErrorCode.INVALID_INPUT, `blacklist.unknown op: ${request}`);
|
|
1208
1159
|
}
|
|
1209
1160
|
}
|
|
1210
1161
|
/**
|
|
@@ -1212,17 +1163,17 @@ async function blacklist(request) {
|
|
|
1212
1163
|
* @param request 操作请求
|
|
1213
1164
|
* @returns 操作结果
|
|
1214
1165
|
*/
|
|
1215
|
-
async function friendslist(request) {
|
|
1216
|
-
const acc = await
|
|
1166
|
+
export async function friendslist(request) {
|
|
1167
|
+
const acc = await Account.Instance().get_address(request.account);
|
|
1217
1168
|
if (!acc) {
|
|
1218
|
-
|
|
1169
|
+
W_ERROR(WErrors.AccountNotFound, `friendslist.account ${request.account}`);
|
|
1219
1170
|
}
|
|
1220
1171
|
const manager = getMessengerManager();
|
|
1221
1172
|
switch (request.op) {
|
|
1222
1173
|
case "add": {
|
|
1223
|
-
let addresses = await
|
|
1174
|
+
let addresses = await GetManyAccountOrMark_Address(request.users);
|
|
1224
1175
|
if (addresses.length === 0) {
|
|
1225
|
-
|
|
1176
|
+
W_ERROR(WErrors.InvalidParam, `friendslist.add.users ${request.users} have not valid addresses`);
|
|
1226
1177
|
}
|
|
1227
1178
|
// 去重
|
|
1228
1179
|
addresses = [...new Set(addresses.map((a) => a.toLowerCase()))];
|
|
@@ -1230,14 +1181,14 @@ async function friendslist(request) {
|
|
|
1230
1181
|
return { op: "add", result };
|
|
1231
1182
|
}
|
|
1232
1183
|
case "remove": {
|
|
1233
|
-
let addresses = await
|
|
1184
|
+
let addresses = await GetManyAccountOrMark_Address(request.users);
|
|
1234
1185
|
if (addresses.length === 0) {
|
|
1235
|
-
|
|
1186
|
+
W_ERROR(WErrors.InvalidParam, `friendslist.remove.users ${request.users} have not valid addresses`);
|
|
1236
1187
|
}
|
|
1237
1188
|
// 去重
|
|
1238
1189
|
addresses = [...new Set(addresses.map((a) => a.toLowerCase()))];
|
|
1239
1190
|
if (addresses.length > MAX_FRIENDS_SIZE_ONCE) {
|
|
1240
|
-
|
|
1191
|
+
W_ERROR(WErrors.InvalidParam, `friendslist.remove.users ${request.users} have too many addresses, max ${MAX_FRIENDS_SIZE_ONCE}`);
|
|
1241
1192
|
}
|
|
1242
1193
|
const result = await manager.removeFromFriendsList(acc, addresses);
|
|
1243
1194
|
return { op: "remove", result };
|
|
@@ -1251,20 +1202,20 @@ async function friendslist(request) {
|
|
|
1251
1202
|
return { op: "get", result };
|
|
1252
1203
|
}
|
|
1253
1204
|
case "exist": {
|
|
1254
|
-
let addresses = await
|
|
1205
|
+
let addresses = await GetManyAccountOrMark_Address(request.users);
|
|
1255
1206
|
if (addresses.length === 0) {
|
|
1256
|
-
|
|
1207
|
+
W_ERROR(WErrors.InvalidParam, `friendslist.exist.users ${request.users} have not valid addresses`);
|
|
1257
1208
|
}
|
|
1258
1209
|
// 去重
|
|
1259
1210
|
addresses = [...new Set(addresses.map((a) => a.toLowerCase()))];
|
|
1260
1211
|
if (addresses.length > MAX_FRIENDS_SIZE_ONCE) {
|
|
1261
|
-
|
|
1212
|
+
W_ERROR(WErrors.InvalidParam, `friendslist.exist.users ${request.users} have too many addresses, max ${MAX_FRIENDS_SIZE_ONCE}`);
|
|
1262
1213
|
}
|
|
1263
1214
|
const result = await manager.existInFriendsList(acc, addresses);
|
|
1264
1215
|
return { op: "exist", result };
|
|
1265
1216
|
}
|
|
1266
1217
|
default:
|
|
1267
|
-
throw new
|
|
1218
|
+
throw new MessengerError(MessengerErrorCode.INVALID_INPUT, `friendslist.unknown op: ${request}`);
|
|
1268
1219
|
}
|
|
1269
1220
|
}
|
|
1270
1221
|
/**
|
|
@@ -1272,10 +1223,10 @@ async function friendslist(request) {
|
|
|
1272
1223
|
* @param request 操作请求
|
|
1273
1224
|
* @returns 操作结果
|
|
1274
1225
|
*/
|
|
1275
|
-
async function guardlist(request) {
|
|
1276
|
-
const acc = await
|
|
1226
|
+
export async function guardlist(request) {
|
|
1227
|
+
const acc = await Account.Instance().get_address(request.account);
|
|
1277
1228
|
if (!acc) {
|
|
1278
|
-
|
|
1229
|
+
W_ERROR(WErrors.AccountNotFound, `guardlist.account ${request.account}`);
|
|
1279
1230
|
}
|
|
1280
1231
|
const manager = getMessengerManager();
|
|
1281
1232
|
switch (request.op) {
|
|
@@ -1287,21 +1238,21 @@ async function guardlist(request) {
|
|
|
1287
1238
|
}
|
|
1288
1239
|
const guards = Array.from(uniqueGuardsMap.values());
|
|
1289
1240
|
if (guards.length === 0) {
|
|
1290
|
-
|
|
1241
|
+
W_ERROR(WErrors.InvalidParam, `guardlist.add.guards ${request.guards} have not valid guards`);
|
|
1291
1242
|
}
|
|
1292
1243
|
// 去重
|
|
1293
1244
|
if (guards.length > MAX_GUARDS_SIZE_ONCE) {
|
|
1294
|
-
|
|
1245
|
+
W_ERROR(WErrors.InvalidParam, `guardlist.add.guards ${request.guards} have too many guards, max ${MAX_GUARDS_SIZE_ONCE}`);
|
|
1295
1246
|
}
|
|
1296
1247
|
// Validate TTL range
|
|
1297
1248
|
for (const g of guards) {
|
|
1298
|
-
if (!
|
|
1249
|
+
if (!isValidU64(g.passportValiditySeconds) ||
|
|
1299
1250
|
g.passportValiditySeconds < MIN_PASSPORT_VALIDITY ||
|
|
1300
1251
|
g.passportValiditySeconds > MAX_PASSPORT_VALIDITY) {
|
|
1301
|
-
|
|
1252
|
+
W_ERROR(WErrors.InvalidParam, `Guard ${g.guard}: passport validity ${g.passportValiditySeconds} must be between ${MIN_PASSPORT_VALIDITY} and ${MAX_PASSPORT_VALIDITY} seconds`);
|
|
1302
1253
|
}
|
|
1303
1254
|
}
|
|
1304
|
-
const addresses = await
|
|
1255
|
+
const addresses = await LocalMark.Instance().get_many_address(guards.map((g) => g.guard));
|
|
1305
1256
|
// Validate all addresses were found
|
|
1306
1257
|
if (addresses.length !== guards.length) {
|
|
1307
1258
|
const foundAddresses = new Set(addresses);
|
|
@@ -1312,20 +1263,20 @@ async function guardlist(request) {
|
|
|
1312
1263
|
missingGuards.push(g.guard);
|
|
1313
1264
|
}
|
|
1314
1265
|
}
|
|
1315
|
-
|
|
1266
|
+
W_ERROR(WErrors.InvalidParam, `Guard not found: ${missingGuards.join(", ")}`);
|
|
1316
1267
|
}
|
|
1317
1268
|
// 通过查询检查是不是guard地址
|
|
1318
|
-
const objs = await
|
|
1269
|
+
const objs = await query_objects({
|
|
1319
1270
|
objects: addresses,
|
|
1320
1271
|
no_cache: false,
|
|
1321
1272
|
network: manager.getConfig().network,
|
|
1322
1273
|
});
|
|
1323
1274
|
if (!objs || !objs.objects || objs.objects.length === 0) {
|
|
1324
|
-
|
|
1275
|
+
W_ERROR(WErrors.InvalidParam, `Guard not found: ${guards.map((g) => g.guard).join(", ")}`);
|
|
1325
1276
|
}
|
|
1326
1277
|
objs.objects.forEach((obj) => {
|
|
1327
1278
|
if (obj.type !== "Guard") {
|
|
1328
|
-
|
|
1279
|
+
W_ERROR(WErrors.InvalidParam, `Guard ${obj.object} is not a Guard`);
|
|
1329
1280
|
}
|
|
1330
1281
|
});
|
|
1331
1282
|
const guardListItems = guards.map((g, index) => ({
|
|
@@ -1340,13 +1291,13 @@ async function guardlist(request) {
|
|
|
1340
1291
|
...new Set(request.guards.map((g) => g.toLowerCase())),
|
|
1341
1292
|
];
|
|
1342
1293
|
if (guards.length === 0) {
|
|
1343
|
-
|
|
1294
|
+
W_ERROR(WErrors.InvalidParam, `guardlist.remove.guards ${request.guards} have not valid guards`);
|
|
1344
1295
|
}
|
|
1345
1296
|
// 去重
|
|
1346
1297
|
if (guards.length > MAX_GUARDS_SIZE_ONCE) {
|
|
1347
|
-
|
|
1298
|
+
W_ERROR(WErrors.InvalidParam, `guardlist.remove.guards ${request.guards} have too many guards, max ${MAX_GUARDS_SIZE_ONCE}`);
|
|
1348
1299
|
}
|
|
1349
|
-
const addresses = await
|
|
1300
|
+
const addresses = await LocalMark.Instance().get_many_address(guards);
|
|
1350
1301
|
if (addresses.length !== guards.length) {
|
|
1351
1302
|
const foundAddresses = new Set(addresses);
|
|
1352
1303
|
const missingGuards = [];
|
|
@@ -1355,7 +1306,7 @@ async function guardlist(request) {
|
|
|
1355
1306
|
missingGuards.push(g);
|
|
1356
1307
|
}
|
|
1357
1308
|
}
|
|
1358
|
-
|
|
1309
|
+
W_ERROR(WErrors.InvalidParam, `Guard not found: ${missingGuards.join(", ")}`);
|
|
1359
1310
|
}
|
|
1360
1311
|
const result = await manager.removeFromGuardList(acc, addresses);
|
|
1361
1312
|
return { op: "remove", result };
|
|
@@ -1365,7 +1316,7 @@ async function guardlist(request) {
|
|
|
1365
1316
|
return { op: "get", result };
|
|
1366
1317
|
}
|
|
1367
1318
|
default:
|
|
1368
|
-
throw new
|
|
1319
|
+
throw new MessengerError(MessengerErrorCode.INVALID_INPUT, `guardlist.unknown op: ${request}`);
|
|
1369
1320
|
}
|
|
1370
1321
|
}
|
|
1371
1322
|
//# sourceMappingURL=messenger-api.js.map
|