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,41 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright (c) Wowok.
|
|
3
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
-
if (k2 === undefined) k2 = k;
|
|
6
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
-
}
|
|
10
|
-
Object.defineProperty(o, k2, desc);
|
|
11
|
-
}) : (function(o, m, k, k2) {
|
|
12
|
-
if (k2 === undefined) k2 = k;
|
|
13
|
-
o[k2] = m[k];
|
|
14
|
-
}));
|
|
15
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
-
}) : function(o, v) {
|
|
18
|
-
o["default"] = v;
|
|
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.Messenger = void 0;
|
|
39
3
|
/**
|
|
40
4
|
* Messenger 核心模块
|
|
41
5
|
*
|
|
@@ -50,27 +14,27 @@ exports.Messenger = void 0;
|
|
|
50
14
|
* - 加密信任:Signal Protocol 双棘轮
|
|
51
15
|
* - 时序信任:Merkle Tree + 服务器签名 + 链上证明
|
|
52
16
|
*/
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
17
|
+
import { createHash } from "crypto";
|
|
18
|
+
import * as fs from "fs";
|
|
19
|
+
import * as path from "path";
|
|
20
|
+
import { CallProof } from "../call/proof.js";
|
|
21
|
+
import { MessengerSession } from "./session.js";
|
|
22
|
+
import { MessengerServerClient } from "./server.js";
|
|
23
|
+
import { MessageStorage, SessionStateStorage } from "./storage.js";
|
|
24
|
+
import { hashPlaintext, verifyMessage, bytesToBase64 } from "./crypto.js";
|
|
25
|
+
import { canonicalizeJson } from "./utils.js";
|
|
26
|
+
import { DEFAULT_MESSENGER_CONFIG, MessengerError, MessengerErrorCode, MessageDirection, MessageStatus, WTS_FILE_BYTES_LIMIT, NORMAL_MESSAGE_BYTES_LIMIT, CHAIN_PROOF_TYPE, } from "./types.js";
|
|
27
|
+
import { isValidWowAddress } from "../../utils/sui-types.js";
|
|
28
|
+
import { Account } from "../local/account.js";
|
|
29
|
+
import { EventSource as EventSourcePolyfill } from "eventsource";
|
|
66
30
|
// Polyfill EventSource for Node.js environment
|
|
67
31
|
if (typeof window === "undefined" &&
|
|
68
32
|
typeof globalThis.EventSource === "undefined") {
|
|
69
33
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
70
|
-
globalThis.EventSource =
|
|
34
|
+
globalThis.EventSource = EventSourcePolyfill;
|
|
71
35
|
console.log("[EventSource] Successfully polyfilled EventSource");
|
|
72
36
|
}
|
|
73
|
-
class Messenger {
|
|
37
|
+
export class Messenger {
|
|
74
38
|
session;
|
|
75
39
|
serverClient;
|
|
76
40
|
config;
|
|
@@ -82,11 +46,11 @@ class Messenger {
|
|
|
82
46
|
sessionStateStorage;
|
|
83
47
|
constructor(userAddress, config) {
|
|
84
48
|
this.userAddress = userAddress;
|
|
85
|
-
this.config = { ...
|
|
86
|
-
this.session = new
|
|
87
|
-
this.serverClient = new
|
|
88
|
-
this.messageStorage = new
|
|
89
|
-
this.sessionStateStorage = new
|
|
49
|
+
this.config = { ...DEFAULT_MESSENGER_CONFIG, ...config };
|
|
50
|
+
this.session = new MessengerSession(userAddress, this.config);
|
|
51
|
+
this.serverClient = new MessengerServerClient(this.config);
|
|
52
|
+
this.messageStorage = new MessageStorage(userAddress);
|
|
53
|
+
this.sessionStateStorage = new SessionStateStorage(userAddress);
|
|
90
54
|
}
|
|
91
55
|
/**
|
|
92
56
|
* 获取用户地址
|
|
@@ -94,7 +58,7 @@ class Messenger {
|
|
|
94
58
|
*/
|
|
95
59
|
getUserAddress() {
|
|
96
60
|
if (!this.userAddress) {
|
|
97
|
-
throw new
|
|
61
|
+
throw new MessengerError(MessengerErrorCode.IDENTITY_NOT_FOUND, "User address not set");
|
|
98
62
|
}
|
|
99
63
|
return this.userAddress;
|
|
100
64
|
}
|
|
@@ -104,9 +68,9 @@ class Messenger {
|
|
|
104
68
|
*/
|
|
105
69
|
async getPublicKey() {
|
|
106
70
|
if (!this.userAddress) {
|
|
107
|
-
throw new
|
|
71
|
+
throw new MessengerError(MessengerErrorCode.IDENTITY_NOT_FOUND, "User address not set");
|
|
108
72
|
}
|
|
109
|
-
const account = await
|
|
73
|
+
const account = await Account.Instance().get(this.userAddress, false);
|
|
110
74
|
return account?.pubkey || "";
|
|
111
75
|
}
|
|
112
76
|
/**
|
|
@@ -118,8 +82,8 @@ class Messenger {
|
|
|
118
82
|
isValidGuardMessage(guardAddress, passportAddress) {
|
|
119
83
|
return Boolean(guardAddress &&
|
|
120
84
|
passportAddress &&
|
|
121
|
-
|
|
122
|
-
|
|
85
|
+
isValidWowAddress(guardAddress) &&
|
|
86
|
+
isValidWowAddress(passportAddress));
|
|
123
87
|
}
|
|
124
88
|
/**
|
|
125
89
|
* 生成签名参数
|
|
@@ -127,11 +91,11 @@ class Messenger {
|
|
|
127
91
|
*/
|
|
128
92
|
async generateSignatureParams(operation) {
|
|
129
93
|
if (!this.userAddress) {
|
|
130
|
-
throw new
|
|
94
|
+
throw new MessengerError(MessengerErrorCode.IDENTITY_NOT_FOUND, "User address not set");
|
|
131
95
|
}
|
|
132
|
-
const account = await
|
|
96
|
+
const account = await Account.Instance().get(this.userAddress, false);
|
|
133
97
|
if (!account?.secret) {
|
|
134
|
-
throw new
|
|
98
|
+
throw new MessengerError(MessengerErrorCode.IDENTITY_NOT_FOUND, `Account not found or no secret key for ${this.userAddress}`);
|
|
135
99
|
}
|
|
136
100
|
const { Ed25519Keypair } = await import("../../keypairs/ed25519/index.js");
|
|
137
101
|
const keypair = Ed25519Keypair.fromSecretKey(account.secret);
|
|
@@ -166,7 +130,7 @@ class Messenger {
|
|
|
166
130
|
*/
|
|
167
131
|
async initialize() {
|
|
168
132
|
if (!this.userAddress) {
|
|
169
|
-
throw new
|
|
133
|
+
throw new MessengerError(MessengerErrorCode.IDENTITY_NOT_FOUND, "User address not set");
|
|
170
134
|
}
|
|
171
135
|
// 确保身份并注册设备
|
|
172
136
|
await this.session.ensureIdentity(this.userAddress);
|
|
@@ -222,15 +186,15 @@ class Messenger {
|
|
|
222
186
|
*/
|
|
223
187
|
async sendMessage(recipientAddress, plaintext, options) {
|
|
224
188
|
if (!this.userAddress) {
|
|
225
|
-
throw new
|
|
189
|
+
throw new MessengerError(MessengerErrorCode.IDENTITY_NOT_FOUND, "User address not set");
|
|
226
190
|
}
|
|
227
191
|
const createdAt = Date.now();
|
|
228
192
|
const timestamp = Date.now();
|
|
229
193
|
const nonce = this.generateNonce();
|
|
230
194
|
// 检查普通消息大小限制(10KB)
|
|
231
195
|
const plaintextBytes = new TextEncoder().encode(plaintext).length;
|
|
232
|
-
if (plaintextBytes >
|
|
233
|
-
throw new
|
|
196
|
+
if (plaintextBytes > NORMAL_MESSAGE_BYTES_LIMIT) {
|
|
197
|
+
throw new MessengerError(MessengerErrorCode.INVALID_INPUT, `Message size (${plaintextBytes} bytes) exceeds maximum allowed size (${NORMAL_MESSAGE_BYTES_LIMIT} bytes). Consider using sendZipFile for large content.`);
|
|
234
198
|
}
|
|
235
199
|
// 【新增】获取最后收到的消息序号(用于消息确认)
|
|
236
200
|
const lastReceivedLeafIndex = this.messageStorage.getLastReceivedLeafIndex(this.userAddress, recipientAddress);
|
|
@@ -239,12 +203,12 @@ class Messenger {
|
|
|
239
203
|
const ciphertext = Buffer.from(new Uint8Array(encrypted.body)).toString("base64");
|
|
240
204
|
// 2. 计算明文哈希(用于 Merkle Tree 证明)
|
|
241
205
|
// 【更新】包含 lastReceivedLeafIndex 在哈希计算中
|
|
242
|
-
const plaintextHash =
|
|
206
|
+
const plaintextHash = hashPlaintext(plaintext, createdAt, options?.guardAddress, options?.passportAddress, lastReceivedLeafIndex);
|
|
243
207
|
// 3. 签名消息
|
|
244
208
|
// 注意: guard_address 和 passport_address 始终包含在签名中(可能为空字符串),防止参数篡改
|
|
245
|
-
const account = await
|
|
209
|
+
const account = await Account.Instance().get(this.userAddress, false);
|
|
246
210
|
if (!account) {
|
|
247
|
-
throw new
|
|
211
|
+
throw new MessengerError(MessengerErrorCode.IDENTITY_NOT_FOUND, "User account not found");
|
|
248
212
|
}
|
|
249
213
|
const publicKey = account.pubkey;
|
|
250
214
|
const guardAddr = options?.guardAddress || "";
|
|
@@ -254,9 +218,9 @@ class Messenger {
|
|
|
254
218
|
const lastReceivedStr = lastReceivedLeafIndex >= 0 ? lastReceivedLeafIndex.toString() : "";
|
|
255
219
|
const forceStr = options?.force ? "true" : "false";
|
|
256
220
|
const signMessage = `send_message:${this.userAddress}:${recipientAddress}:${guardAddr}:${passportAddr}:${plaintextHash}:${lastReceivedStr}:${publicKey}:${timestamp}:${nonce}:${forceStr}`;
|
|
257
|
-
const signResult = await
|
|
221
|
+
const signResult = await Account.Instance().signData(this.userAddress, signMessage);
|
|
258
222
|
const signatureBuffer = Buffer.from(signResult.signature.slice(2), "hex");
|
|
259
|
-
const signatureBase64 =
|
|
223
|
+
const signatureBase64 = bytesToBase64(new Uint8Array(signatureBuffer));
|
|
260
224
|
// 使用统一的 sendMessage API
|
|
261
225
|
const response = await this.serverClient.sendMessage({
|
|
262
226
|
sender: signResult.publicKey,
|
|
@@ -287,10 +251,10 @@ class Messenger {
|
|
|
287
251
|
guardAddress: options?.guardAddress,
|
|
288
252
|
passportAddress: options?.passportAddress,
|
|
289
253
|
lastReceivedLeafIndex, // 【新增】保存消息确认字段
|
|
290
|
-
direction:
|
|
254
|
+
direction: MessageDirection.SENT,
|
|
291
255
|
status: response.status === "confirmed"
|
|
292
|
-
?
|
|
293
|
-
:
|
|
256
|
+
? MessageStatus.CONFIRMED
|
|
257
|
+
: MessageStatus.PENDING,
|
|
294
258
|
msgType: encrypted.type,
|
|
295
259
|
createdAt,
|
|
296
260
|
};
|
|
@@ -317,9 +281,9 @@ class Messenger {
|
|
|
317
281
|
// 检查本地是否已有该消息
|
|
318
282
|
const existingMsg = this.messageStorage.getMessage(msgId);
|
|
319
283
|
if (existingMsg &&
|
|
320
|
-
existingMsg.status ===
|
|
284
|
+
existingMsg.status === MessageStatus.PENDING) {
|
|
321
285
|
// 更新消息的 Merkle 数据
|
|
322
|
-
this.messageStorage.updateMessageStatus(msgId,
|
|
286
|
+
this.messageStorage.updateMessageStatus(msgId, MessageStatus.CONFIRMED, {
|
|
323
287
|
leafIndex: merkleData.leafIndex,
|
|
324
288
|
newRoot: merkleData.newRoot,
|
|
325
289
|
serverSignature: merkleData.serverSignature,
|
|
@@ -350,20 +314,20 @@ class Messenger {
|
|
|
350
314
|
*/
|
|
351
315
|
async pullMessages(limit) {
|
|
352
316
|
if (!this.userAddress) {
|
|
353
|
-
throw new
|
|
317
|
+
throw new MessengerError(MessengerErrorCode.IDENTITY_NOT_FOUND, "User address not set");
|
|
354
318
|
}
|
|
355
319
|
// 1. 生成签名参数
|
|
356
320
|
// 签名格式: fetch_messages:{address}:{limit}:{timestamp}:{nonce}
|
|
357
321
|
const timestamp = Date.now(); //@ 使用ms时间戳
|
|
358
322
|
const nonce = this.generateNonce();
|
|
359
323
|
const message = `fetch_messages:${this.userAddress}:${limit || 100}:${timestamp}:${nonce}`;
|
|
360
|
-
const account = await
|
|
324
|
+
const account = await Account.Instance().get(this.userAddress, false);
|
|
361
325
|
const publicKey = account?.pubkey || "";
|
|
362
|
-
const signResult = await
|
|
326
|
+
const signResult = await Account.Instance().signData(this.userAddress, message);
|
|
363
327
|
const signature = Buffer.from(signResult.signature.slice(2), "hex");
|
|
364
328
|
const signatureParams = {
|
|
365
329
|
signatureScheme: "ED25519",
|
|
366
|
-
signature:
|
|
330
|
+
signature: bytesToBase64(signature),
|
|
367
331
|
timestamp,
|
|
368
332
|
nonce,
|
|
369
333
|
};
|
|
@@ -428,7 +392,7 @@ class Messenger {
|
|
|
428
392
|
throw new Error(`Message ${serverMsg.id} missing newRoot in merkleMetadata`);
|
|
429
393
|
}
|
|
430
394
|
}
|
|
431
|
-
const verificationResult =
|
|
395
|
+
const verificationResult = verifyMessage({
|
|
432
396
|
messageId: serverMsg.id,
|
|
433
397
|
plaintext,
|
|
434
398
|
plaintextHash: serverMsg.plaintextHash,
|
|
@@ -463,8 +427,8 @@ class Messenger {
|
|
|
463
427
|
guardAddress: serverMsg.guardAddress,
|
|
464
428
|
passportAddress: serverMsg.passportAddress,
|
|
465
429
|
lastReceivedLeafIndex: serverMsg.lastReceivedLeafIndex, // 【新增】保存消息确认字段
|
|
466
|
-
direction:
|
|
467
|
-
status:
|
|
430
|
+
direction: MessageDirection.RECEIVED,
|
|
431
|
+
status: MessageStatus.CONFIRMED,
|
|
468
432
|
msgType: serverMsg.msgType,
|
|
469
433
|
leafIndex: serverMsg.merkleMetadata?.leafIndex,
|
|
470
434
|
prevRoot: serverMsg.merkleMetadata?.prevRoot,
|
|
@@ -513,12 +477,12 @@ class Messenger {
|
|
|
513
477
|
const ackTimestamp = Date.now(); //@ 使用ms时间戳
|
|
514
478
|
const ackNonce = this.generateNonce();
|
|
515
479
|
// 签名消息格式: ack_messages:{user}:{message_ids}:{public_key}:{timestamp}:{nonce}
|
|
516
|
-
const account = await
|
|
480
|
+
const account = await Account.Instance().get(this.userAddress, false);
|
|
517
481
|
if (account?.pubkey) {
|
|
518
482
|
const ackMessage = `ack_messages:${this.userAddress}:${acknowledgedIds.join(",")}:${account.pubkey}:${ackTimestamp}:${ackNonce}`;
|
|
519
|
-
const signResult = await
|
|
483
|
+
const signResult = await Account.Instance().signData(this.userAddress, ackMessage);
|
|
520
484
|
const signatureBuffer = Buffer.from(signResult.signature.slice(2), "hex");
|
|
521
|
-
const signatureBase64 =
|
|
485
|
+
const signatureBase64 = bytesToBase64(new Uint8Array(signatureBuffer));
|
|
522
486
|
await this.serverClient.acknowledgeMessages(acknowledgedIds, signResult.publicKey, {
|
|
523
487
|
publicKey: signResult.publicKey,
|
|
524
488
|
signatureScheme: "ED25519",
|
|
@@ -541,7 +505,7 @@ class Messenger {
|
|
|
541
505
|
if (!this.userAddress)
|
|
542
506
|
return -1;
|
|
543
507
|
const messages = this.messageStorage.getMessagesBySession(this.userAddress, peerAddress);
|
|
544
|
-
const sentMessages = messages.filter((m) => m.direction ===
|
|
508
|
+
const sentMessages = messages.filter((m) => m.direction === MessageDirection.SENT &&
|
|
545
509
|
m.leafIndex !== undefined);
|
|
546
510
|
if (sentMessages.length === 0)
|
|
547
511
|
return -1;
|
|
@@ -576,12 +540,12 @@ class Messenger {
|
|
|
576
540
|
*/
|
|
577
541
|
async submitChainProof(env, peerAddress, description) {
|
|
578
542
|
if (!this.userAddress) {
|
|
579
|
-
throw new
|
|
543
|
+
throw new MessengerError(MessengerErrorCode.IDENTITY_NOT_FOUND, "User address not set");
|
|
580
544
|
}
|
|
581
545
|
// 获取当前会话状态
|
|
582
546
|
const sessionState = this.sessionStateStorage.getSessionState(this.userAddress, peerAddress);
|
|
583
547
|
if (!sessionState || !sessionState.currentRoot) {
|
|
584
|
-
throw new
|
|
548
|
+
throw new MessengerError(MessengerErrorCode.SESSION_NOT_ESTABLISHED, "No session state found");
|
|
585
549
|
}
|
|
586
550
|
// 从会话消息中获取服务器公钥和签名
|
|
587
551
|
const messages = this.messageStorage.getMessagesBySession(this.userAddress, peerAddress);
|
|
@@ -589,7 +553,7 @@ class Messenger {
|
|
|
589
553
|
if (!lastMessage ||
|
|
590
554
|
!lastMessage.serverPublicKey ||
|
|
591
555
|
!lastMessage.serverSignature) {
|
|
592
|
-
throw new
|
|
556
|
+
throw new MessengerError(MessengerErrorCode.INVALID_PROOF, "No temporal proof (missing server public key or signature), cannot submit Proof to WoWok blockchain");
|
|
593
557
|
}
|
|
594
558
|
const serverPubKey = lastMessage.serverPublicKey;
|
|
595
559
|
const serverSignature = lastMessage.serverSignature;
|
|
@@ -601,11 +565,11 @@ class Messenger {
|
|
|
601
565
|
timestamp: Date.now(),
|
|
602
566
|
};
|
|
603
567
|
// 使用 CallProof 提交到链上
|
|
604
|
-
const callProof = new
|
|
568
|
+
const callProof = new CallProof({
|
|
605
569
|
proof: JSON.stringify(proofData),
|
|
606
570
|
server_pubkey: serverPubKey,
|
|
607
571
|
server_signature: serverSignature,
|
|
608
|
-
proof_type:
|
|
572
|
+
proof_type: CHAIN_PROOF_TYPE, // 1 = Messenger Session Proof
|
|
609
573
|
description: description ||
|
|
610
574
|
`Messenger session proof for ${this.userAddress} <-> ${peerAddress}`,
|
|
611
575
|
item_count: sessionState.messageCount,
|
|
@@ -630,7 +594,7 @@ class Messenger {
|
|
|
630
594
|
*/
|
|
631
595
|
async connectEventSource(onMessage, signatureParams) {
|
|
632
596
|
if (!this.userAddress) {
|
|
633
|
-
throw new
|
|
597
|
+
throw new MessengerError(MessengerErrorCode.IDENTITY_NOT_FOUND, "User address not set");
|
|
634
598
|
}
|
|
635
599
|
// 关闭已有连接
|
|
636
600
|
this.disconnectEventSource();
|
|
@@ -639,16 +603,16 @@ class Messenger {
|
|
|
639
603
|
}
|
|
640
604
|
// 如果没有提供签名参数,自动生成
|
|
641
605
|
// 签名格式: event_stream:{address}:{timestamp}:{nonce}
|
|
642
|
-
const account = await
|
|
606
|
+
const account = await Account.Instance().get(this.userAddress, false);
|
|
643
607
|
const publicKey = account?.pubkey || "";
|
|
644
608
|
let params = signatureParams;
|
|
645
609
|
if (!params) {
|
|
646
610
|
const timestamp = Date.now(); //@ 使用ms时间戳
|
|
647
611
|
const nonce = this.generateNonce();
|
|
648
612
|
const message = `event_stream:${this.userAddress}:${timestamp}:${nonce}`;
|
|
649
|
-
const signResult = await
|
|
613
|
+
const signResult = await Account.Instance().signData(this.userAddress, message);
|
|
650
614
|
const signatureBuffer = Buffer.from(signResult.signature.slice(2), "hex");
|
|
651
|
-
const signatureBase64 =
|
|
615
|
+
const signatureBase64 = bytesToBase64(new Uint8Array(signatureBuffer));
|
|
652
616
|
params = {
|
|
653
617
|
signatureScheme: "ED25519",
|
|
654
618
|
signature: signatureBase64,
|
|
@@ -802,7 +766,7 @@ class Messenger {
|
|
|
802
766
|
);*/
|
|
803
767
|
// 直接使用 updateMessageStatus 更新消息的 Merkle 数据
|
|
804
768
|
// 因为 message_id 已经包含 nonce,不需要再更新消息 ID
|
|
805
|
-
this.messageStorage.updateMessageStatus(message_id,
|
|
769
|
+
this.messageStorage.updateMessageStatus(message_id, MessageStatus.CONFIRMED, {
|
|
806
770
|
leafIndex: merkle_data.leafIndex,
|
|
807
771
|
newRoot: merkle_data.newRoot,
|
|
808
772
|
serverSignature: merkle_data.serverSignature,
|
|
@@ -844,7 +808,7 @@ class Messenger {
|
|
|
844
808
|
// 首先尝试通过 message_id 查找消息
|
|
845
809
|
const existingMsg = this.messageStorage.getMessage(message_id);
|
|
846
810
|
if (existingMsg) {
|
|
847
|
-
existingMsg.status =
|
|
811
|
+
existingMsg.status = MessageStatus.REJECTED;
|
|
848
812
|
this.messageStorage.saveMessage(existingMsg);
|
|
849
813
|
/*console.log(
|
|
850
814
|
`Guard message ${message_id} marked as rejected`,
|
|
@@ -918,7 +882,7 @@ class Messenger {
|
|
|
918
882
|
*/
|
|
919
883
|
async sendZipFile(recipientAddress, source, options) {
|
|
920
884
|
if (!this.userAddress) {
|
|
921
|
-
throw new
|
|
885
|
+
throw new MessengerError(MessengerErrorCode.IDENTITY_NOT_FOUND, "User address not set");
|
|
922
886
|
}
|
|
923
887
|
// 1. 加载文件内容
|
|
924
888
|
const fileData = await this.loadFileData(source);
|
|
@@ -930,11 +894,11 @@ class Messenger {
|
|
|
930
894
|
zip.file(fileName, fileData);
|
|
931
895
|
const zipBlob = await zip.generateAsync({ type: "uint8array" });
|
|
932
896
|
// 3. 本地文件大小限制检查(默认 5MB)
|
|
933
|
-
if (zipBlob.length >
|
|
934
|
-
throw new
|
|
897
|
+
if (zipBlob.length > WTS_FILE_BYTES_LIMIT) {
|
|
898
|
+
throw new MessengerError(MessengerErrorCode.INVALID_INPUT, `ZIP file size (${zipBlob.length} bytes) exceeds local maximum allowed size (${WTS_FILE_BYTES_LIMIT} bytes)`);
|
|
935
899
|
}
|
|
936
900
|
// 4. 计算 ZIP 文件哈希(用于 zipMetadata)
|
|
937
|
-
const zipFileHash = "0x" +
|
|
901
|
+
const zipFileHash = "0x" + createHash("sha256").update(zipBlob).digest("hex");
|
|
938
902
|
// 4. 将 ZIP 数据转为 base64
|
|
939
903
|
const zipBase64 = Buffer.from(zipBlob).toString("base64");
|
|
940
904
|
// 5. 构造 ZIP 元数据
|
|
@@ -954,13 +918,13 @@ class Messenger {
|
|
|
954
918
|
// 【更新】包含 lastReceivedLeafIndex 在哈希计算中
|
|
955
919
|
const guardAddr = options?.guardAddress || "";
|
|
956
920
|
const passportAddr = options?.passportAddress || "";
|
|
957
|
-
const plaintextHash =
|
|
921
|
+
const plaintextHash = hashPlaintext(zipBase64, createdAt, guardAddr, passportAddr, lastReceivedLeafIndex);
|
|
958
922
|
// 8. 发送到服务器(带 ZIP 元数据)
|
|
959
923
|
const timestamp = Date.now();
|
|
960
924
|
const nonce = this.generateNonce();
|
|
961
|
-
const account = await
|
|
925
|
+
const account = await Account.Instance().get(this.userAddress, false);
|
|
962
926
|
if (!account) {
|
|
963
|
-
throw new
|
|
927
|
+
throw new MessengerError(MessengerErrorCode.IDENTITY_NOT_FOUND, "User account not found");
|
|
964
928
|
}
|
|
965
929
|
const publicKey = account.pubkey;
|
|
966
930
|
// 统一发送模式(合并 send 和 send_force)
|
|
@@ -968,9 +932,9 @@ class Messenger {
|
|
|
968
932
|
const lastReceivedStr = lastReceivedLeafIndex >= 0 ? lastReceivedLeafIndex.toString() : "";
|
|
969
933
|
const forceStr = options?.force ? "true" : "false";
|
|
970
934
|
const signMessage = `send_message:${this.userAddress}:${recipientAddress}:${guardAddr}:${passportAddr}:${plaintextHash}:${lastReceivedStr}:${publicKey}:${timestamp}:${nonce}:${forceStr}`;
|
|
971
|
-
const signResult = await
|
|
935
|
+
const signResult = await Account.Instance().signData(this.userAddress, signMessage);
|
|
972
936
|
const signatureBuffer = Buffer.from(signResult.signature.slice(2), "hex");
|
|
973
|
-
const signatureBase64 =
|
|
937
|
+
const signatureBase64 = bytesToBase64(new Uint8Array(signatureBuffer));
|
|
974
938
|
// 使用统一的 sendMessage API
|
|
975
939
|
const response = await this.serverClient.sendMessage({
|
|
976
940
|
sender: signResult.publicKey,
|
|
@@ -1003,10 +967,10 @@ class Messenger {
|
|
|
1003
967
|
guardAddress: options?.guardAddress,
|
|
1004
968
|
passportAddress: options?.passportAddress,
|
|
1005
969
|
lastReceivedLeafIndex, // 【新增】保存消息确认字段
|
|
1006
|
-
direction:
|
|
970
|
+
direction: MessageDirection.SENT,
|
|
1007
971
|
status: response.status === "confirmed"
|
|
1008
|
-
?
|
|
1009
|
-
:
|
|
972
|
+
? MessageStatus.CONFIRMED
|
|
973
|
+
: MessageStatus.PENDING,
|
|
1010
974
|
msgType: encrypted.type, // 使用底层 Signal Protocol 消息类型(1 或 3)
|
|
1011
975
|
zipMetadata,
|
|
1012
976
|
createdAt,
|
|
@@ -1034,9 +998,9 @@ class Messenger {
|
|
|
1034
998
|
// 检查本地是否已有该消息
|
|
1035
999
|
const existingMsg = this.messageStorage.getMessage(msgId);
|
|
1036
1000
|
if (existingMsg &&
|
|
1037
|
-
existingMsg.status ===
|
|
1001
|
+
existingMsg.status === MessageStatus.PENDING) {
|
|
1038
1002
|
// 更新消息的 Merkle 数据
|
|
1039
|
-
this.messageStorage.updateMessageStatus(msgId,
|
|
1003
|
+
this.messageStorage.updateMessageStatus(msgId, MessageStatus.CONFIRMED, {
|
|
1040
1004
|
leafIndex: merkleData.leafIndex,
|
|
1041
1005
|
newRoot: merkleData.newRoot,
|
|
1042
1006
|
serverSignature: merkleData.serverSignature,
|
|
@@ -1065,7 +1029,7 @@ class Messenger {
|
|
|
1065
1029
|
// 从网络加载
|
|
1066
1030
|
const response = await fetch(source);
|
|
1067
1031
|
if (!response.ok) {
|
|
1068
|
-
throw new
|
|
1032
|
+
throw new MessengerError(MessengerErrorCode.NETWORK_ERROR, `Failed to fetch file from ${source}: ${response.statusText}`);
|
|
1069
1033
|
}
|
|
1070
1034
|
const arrayBuffer = await response.arrayBuffer();
|
|
1071
1035
|
return new Uint8Array(arrayBuffer);
|
|
@@ -1073,7 +1037,7 @@ class Messenger {
|
|
|
1073
1037
|
// 从本地文件加载
|
|
1074
1038
|
const resolvedPath = path.resolve(source);
|
|
1075
1039
|
if (!fs.existsSync(resolvedPath)) {
|
|
1076
|
-
throw new
|
|
1040
|
+
throw new MessengerError(MessengerErrorCode.FILE_NOT_FOUND, `File not found: ${resolvedPath}`);
|
|
1077
1041
|
}
|
|
1078
1042
|
const buffer = fs.readFileSync(resolvedPath);
|
|
1079
1043
|
return new Uint8Array(buffer);
|
|
@@ -1097,19 +1061,19 @@ class Messenger {
|
|
|
1097
1061
|
*/
|
|
1098
1062
|
async _createSignedRequest(data) {
|
|
1099
1063
|
if (!this.userAddress) {
|
|
1100
|
-
throw new
|
|
1064
|
+
throw new MessengerError(MessengerErrorCode.IDENTITY_NOT_FOUND, "User address not set");
|
|
1101
1065
|
}
|
|
1102
1066
|
const timestamp = Date.now();
|
|
1103
1067
|
const nonce = this.generateNonce();
|
|
1104
|
-
const dataJson =
|
|
1068
|
+
const dataJson = canonicalizeJson(data);
|
|
1105
1069
|
const signMessage = `${timestamp}:${nonce}:${dataJson}`;
|
|
1106
|
-
const signResult = await
|
|
1070
|
+
const signResult = await Account.Instance().signData(this.userAddress, signMessage);
|
|
1107
1071
|
const signatureBuffer = Buffer.from(signResult.signature.slice(2), "hex");
|
|
1108
|
-
const signatureBase64 =
|
|
1072
|
+
const signatureBase64 = bytesToBase64(new Uint8Array(signatureBuffer));
|
|
1109
1073
|
// 获取公钥(带标志位)用于服务器验证
|
|
1110
|
-
const account = await
|
|
1074
|
+
const account = await Account.Instance().get(this.userAddress, false);
|
|
1111
1075
|
if (!account || !account.pubkey) {
|
|
1112
|
-
throw new
|
|
1076
|
+
throw new MessengerError(MessengerErrorCode.IDENTITY_NOT_FOUND, "Account public key not found");
|
|
1113
1077
|
}
|
|
1114
1078
|
return {
|
|
1115
1079
|
userAddress: this.userAddress,
|
|
@@ -1128,7 +1092,7 @@ class Messenger {
|
|
|
1128
1092
|
const valid = [];
|
|
1129
1093
|
const invalid = [];
|
|
1130
1094
|
for (const addr of addresses) {
|
|
1131
|
-
if (
|
|
1095
|
+
if (isValidWowAddress(addr)) {
|
|
1132
1096
|
valid.push(addr);
|
|
1133
1097
|
}
|
|
1134
1098
|
else {
|
|
@@ -1142,7 +1106,7 @@ class Messenger {
|
|
|
1142
1106
|
*/
|
|
1143
1107
|
async addToBlacklist(addresses) {
|
|
1144
1108
|
if (!this.userAddress) {
|
|
1145
|
-
throw new
|
|
1109
|
+
throw new MessengerError(MessengerErrorCode.IDENTITY_NOT_FOUND, "User address not set");
|
|
1146
1110
|
}
|
|
1147
1111
|
const { valid, invalid } = this._validateAddresses(addresses);
|
|
1148
1112
|
if (invalid.length > 0) {
|
|
@@ -1165,7 +1129,7 @@ class Messenger {
|
|
|
1165
1129
|
*/
|
|
1166
1130
|
async removeFromBlacklist(addresses) {
|
|
1167
1131
|
if (!this.userAddress) {
|
|
1168
|
-
throw new
|
|
1132
|
+
throw new MessengerError(MessengerErrorCode.IDENTITY_NOT_FOUND, "User address not set");
|
|
1169
1133
|
}
|
|
1170
1134
|
const { valid, invalid } = this._validateAddresses(addresses);
|
|
1171
1135
|
if (invalid.length > 0) {
|
|
@@ -1188,7 +1152,7 @@ class Messenger {
|
|
|
1188
1152
|
*/
|
|
1189
1153
|
async clearBlacklist() {
|
|
1190
1154
|
if (!this.userAddress) {
|
|
1191
|
-
throw new
|
|
1155
|
+
throw new MessengerError(MessengerErrorCode.IDENTITY_NOT_FOUND, "User address not set");
|
|
1192
1156
|
}
|
|
1193
1157
|
const data = {};
|
|
1194
1158
|
const signedRequest = await this._createSignedRequest(data);
|
|
@@ -1199,7 +1163,7 @@ class Messenger {
|
|
|
1199
1163
|
*/
|
|
1200
1164
|
async getBlacklist() {
|
|
1201
1165
|
if (!this.userAddress) {
|
|
1202
|
-
throw new
|
|
1166
|
+
throw new MessengerError(MessengerErrorCode.IDENTITY_NOT_FOUND, "User address not set");
|
|
1203
1167
|
}
|
|
1204
1168
|
const signedRequest = await this._createSignedRequest({});
|
|
1205
1169
|
return this.serverClient.getBlacklist(this.userAddress, signedRequest);
|
|
@@ -1209,7 +1173,7 @@ class Messenger {
|
|
|
1209
1173
|
*/
|
|
1210
1174
|
async existInBlacklist(addresses) {
|
|
1211
1175
|
if (!this.userAddress) {
|
|
1212
|
-
throw new
|
|
1176
|
+
throw new MessengerError(MessengerErrorCode.IDENTITY_NOT_FOUND, "User address not set");
|
|
1213
1177
|
}
|
|
1214
1178
|
const { valid, invalid } = this._validateAddresses(addresses);
|
|
1215
1179
|
if (invalid.length > 0) {
|
|
@@ -1232,7 +1196,7 @@ class Messenger {
|
|
|
1232
1196
|
*/
|
|
1233
1197
|
async addToFriendsList(addresses) {
|
|
1234
1198
|
if (!this.userAddress) {
|
|
1235
|
-
throw new
|
|
1199
|
+
throw new MessengerError(MessengerErrorCode.IDENTITY_NOT_FOUND, "User address not set");
|
|
1236
1200
|
}
|
|
1237
1201
|
const { valid, invalid } = this._validateAddresses(addresses);
|
|
1238
1202
|
if (invalid.length > 0) {
|
|
@@ -1255,7 +1219,7 @@ class Messenger {
|
|
|
1255
1219
|
*/
|
|
1256
1220
|
async removeFromFriendsList(addresses) {
|
|
1257
1221
|
if (!this.userAddress) {
|
|
1258
|
-
throw new
|
|
1222
|
+
throw new MessengerError(MessengerErrorCode.IDENTITY_NOT_FOUND, "User address not set");
|
|
1259
1223
|
}
|
|
1260
1224
|
const { valid, invalid } = this._validateAddresses(addresses);
|
|
1261
1225
|
if (invalid.length > 0) {
|
|
@@ -1278,7 +1242,7 @@ class Messenger {
|
|
|
1278
1242
|
*/
|
|
1279
1243
|
async clearFriendsList() {
|
|
1280
1244
|
if (!this.userAddress) {
|
|
1281
|
-
throw new
|
|
1245
|
+
throw new MessengerError(MessengerErrorCode.IDENTITY_NOT_FOUND, "User address not set");
|
|
1282
1246
|
}
|
|
1283
1247
|
const data = {};
|
|
1284
1248
|
const signedRequest = await this._createSignedRequest(data);
|
|
@@ -1289,7 +1253,7 @@ class Messenger {
|
|
|
1289
1253
|
*/
|
|
1290
1254
|
async getFriendsList() {
|
|
1291
1255
|
if (!this.userAddress) {
|
|
1292
|
-
throw new
|
|
1256
|
+
throw new MessengerError(MessengerErrorCode.IDENTITY_NOT_FOUND, "User address not set");
|
|
1293
1257
|
}
|
|
1294
1258
|
const signedRequest = await this._createSignedRequest({});
|
|
1295
1259
|
return this.serverClient.getFriendsList(this.userAddress, signedRequest);
|
|
@@ -1299,7 +1263,7 @@ class Messenger {
|
|
|
1299
1263
|
*/
|
|
1300
1264
|
async existInFriendsList(addresses) {
|
|
1301
1265
|
if (!this.userAddress) {
|
|
1302
|
-
throw new
|
|
1266
|
+
throw new MessengerError(MessengerErrorCode.IDENTITY_NOT_FOUND, "User address not set");
|
|
1303
1267
|
}
|
|
1304
1268
|
const { valid, invalid } = this._validateAddresses(addresses);
|
|
1305
1269
|
if (invalid.length > 0) {
|
|
@@ -1322,7 +1286,7 @@ class Messenger {
|
|
|
1322
1286
|
*/
|
|
1323
1287
|
async addToGuardList(guards) {
|
|
1324
1288
|
if (!this.userAddress) {
|
|
1325
|
-
throw new
|
|
1289
|
+
throw new MessengerError(MessengerErrorCode.IDENTITY_NOT_FOUND, "User address not set");
|
|
1326
1290
|
}
|
|
1327
1291
|
const data = { guards };
|
|
1328
1292
|
const signedRequest = await this._createSignedRequest(data);
|
|
@@ -1333,7 +1297,7 @@ class Messenger {
|
|
|
1333
1297
|
*/
|
|
1334
1298
|
async removeFromGuardList(addresses) {
|
|
1335
1299
|
if (!this.userAddress) {
|
|
1336
|
-
throw new
|
|
1300
|
+
throw new MessengerError(MessengerErrorCode.IDENTITY_NOT_FOUND, "User address not set");
|
|
1337
1301
|
}
|
|
1338
1302
|
const { valid, invalid } = this._validateAddresses(addresses);
|
|
1339
1303
|
if (invalid.length > 0) {
|
|
@@ -1356,11 +1320,10 @@ class Messenger {
|
|
|
1356
1320
|
*/
|
|
1357
1321
|
async getGuardList() {
|
|
1358
1322
|
if (!this.userAddress) {
|
|
1359
|
-
throw new
|
|
1323
|
+
throw new MessengerError(MessengerErrorCode.IDENTITY_NOT_FOUND, "User address not set");
|
|
1360
1324
|
}
|
|
1361
1325
|
const signedRequest = await this._createSignedRequest({});
|
|
1362
1326
|
return this.serverClient.getGuardList(this.userAddress, signedRequest);
|
|
1363
1327
|
}
|
|
1364
1328
|
}
|
|
1365
|
-
exports.Messenger = Messenger;
|
|
1366
1329
|
//# sourceMappingURL=messenger.js.map
|