wowok 1.8.3 → 2.1.10
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/NOTICE +46 -0
- package/README.md +4 -33
- package/dist/cjs/bcs/bcs.d.ts +1973 -0
- package/dist/cjs/bcs/bcs.js +327 -0
- package/dist/cjs/bcs/effects.d.ts +579 -0
- package/dist/cjs/bcs/effects.js +231 -0
- package/dist/cjs/bcs/index.d.ts +2589 -0
- package/dist/cjs/bcs/index.js +79 -0
- package/dist/cjs/bcs/pure.d.ts +22 -0
- package/dist/cjs/bcs/pure.js +62 -0
- package/dist/cjs/bcs/type-tag-serializer.d.ts +7 -0
- package/dist/cjs/bcs/type-tag-serializer.js +124 -0
- package/dist/cjs/bcs/types.d.ts +114 -0
- package/dist/cjs/bcs/types.js +26 -0
- package/dist/cjs/client/index.d.ts +5 -0
- package/dist/cjs/client/index.js +34 -0
- package/dist/cjs/client/network.d.ts +5 -0
- package/dist/cjs/client/network.js +43 -0
- package/dist/cjs/cryptography/index.d.ts +7 -0
- package/dist/cjs/cryptography/index.js +46 -0
- package/dist/cjs/cryptography/intent.d.ts +6 -0
- package/dist/cjs/cryptography/intent.js +34 -0
- package/dist/cjs/cryptography/keypair.d.ts +73 -0
- package/dist/cjs/cryptography/keypair.js +125 -0
- package/dist/cjs/cryptography/mnemonics.d.ts +27 -0
- package/dist/cjs/cryptography/mnemonics.js +50 -0
- package/dist/cjs/cryptography/publickey.d.ts +67 -0
- package/dist/cjs/cryptography/publickey.js +142 -0
- package/dist/cjs/cryptography/signature-scheme.d.ts +24 -0
- package/dist/cjs/cryptography/signature-scheme.js +47 -0
- package/dist/cjs/cryptography/signature.d.ts +62 -0
- package/dist/cjs/cryptography/signature.js +71 -0
- package/dist/cjs/experimental/cache.d.ts +12 -0
- package/dist/cjs/experimental/client.d.ts +12 -0
- package/dist/cjs/experimental/core.d.ts +33 -0
- package/dist/cjs/experimental/errors.d.ts +8 -0
- package/dist/cjs/experimental/index.d.ts +7 -0
- package/dist/cjs/experimental/persistent-storage.d.ts +134 -0
- package/dist/cjs/experimental/persistent-storage.test.d.ts +5 -0
- package/dist/cjs/experimental/transports/utils.d.ts +3 -0
- package/dist/cjs/experimental/types.d.ts +367 -0
- package/dist/cjs/faucet/faucet.d.ts +66 -0
- package/dist/cjs/faucet/faucet.js +138 -0
- package/dist/cjs/faucet/index.d.ts +1 -0
- package/dist/cjs/faucet/index.js +29 -0
- package/dist/cjs/graphql/client.js +98 -0
- package/dist/cjs/graphql/core.js +506 -0
- package/dist/cjs/graphql/generated/2024.1/tada-env.js +13141 -0
- package/dist/cjs/graphql/generated/2024.1/tsconfig.tada.js +11 -0
- package/dist/cjs/graphql/generated/2024.4/tada-env.js +13287 -0
- package/dist/cjs/graphql/generated/2024.4/tsconfig.tada.js +11 -0
- package/dist/cjs/graphql/generated/latest/tada-env.js +12925 -0
- package/dist/cjs/graphql/generated/latest/tsconfig.tada.js +11 -0
- package/dist/cjs/graphql/generated/queries.js +807 -0
- package/dist/cjs/graphql/index.js +25 -0
- package/dist/cjs/graphql/schemas/2024.1/index.js +28 -0
- package/dist/cjs/graphql/schemas/2024.4/index.js +28 -0
- package/dist/cjs/graphql/schemas/latest/index.js +28 -0
- package/dist/cjs/graphql/types.js +16 -0
- package/dist/cjs/grpc/client.d.ts +32 -0
- package/dist/cjs/grpc/client.js +64 -0
- package/dist/cjs/grpc/core.d.ts +28 -0
- package/dist/cjs/grpc/core.js +645 -0
- package/dist/cjs/grpc/index.d.ts +4 -0
- package/dist/cjs/grpc/index.js +26 -0
- package/dist/cjs/grpc/proto/google/protobuf/any.d.ts +173 -0
- package/dist/cjs/grpc/proto/google/protobuf/any.js +138 -0
- package/dist/cjs/grpc/proto/google/protobuf/duration.d.ts +104 -0
- package/dist/cjs/grpc/proto/google/protobuf/duration.js +94 -0
- package/dist/cjs/grpc/proto/google/protobuf/empty.d.ts +25 -0
- package/dist/cjs/grpc/proto/google/protobuf/empty.js +30 -0
- package/dist/cjs/grpc/proto/google/protobuf/field_mask.d.ts +231 -0
- package/dist/cjs/grpc/proto/google/protobuf/field_mask.js +77 -0
- package/dist/cjs/grpc/proto/google/protobuf/struct.d.ts +169 -0
- package/dist/cjs/grpc/proto/google/protobuf/struct.js +224 -0
- package/dist/cjs/grpc/proto/google/protobuf/timestamp.d.ts +145 -0
- package/dist/cjs/grpc/proto/google/protobuf/timestamp.js +134 -0
- package/dist/cjs/grpc/proto/google/rpc/error_details.d.ts +525 -0
- package/dist/cjs/grpc/proto/google/rpc/error_details.js +317 -0
- package/dist/cjs/grpc/proto/google/rpc/status.d.ts +46 -0
- package/dist/cjs/grpc/proto/google/rpc/status.js +52 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/argument.d.ts +66 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/argument.js +70 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/balance_change.d.ts +34 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/balance_change.js +52 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/bcs.d.ts +30 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/bcs.js +45 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint.d.ts +68 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint.js +77 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint_contents.d.ts +74 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint_contents.js +84 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint_summary.d.ts +195 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint_summary.js +170 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/effects.d.ts +338 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/effects.js +300 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/epoch.d.ts +62 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/epoch.js +87 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/error_reason.d.ts +17 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/error_reason.js +29 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/event.d.ts +88 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/event.js +86 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/executed_transaction.d.ts +80 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/executed_transaction.js +87 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/execution_status.d.ts +843 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/execution_status.js +519 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/gas_cost_summary.d.ts +41 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/gas_cost_summary.js +63 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/input.d.ts +98 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/input.js +85 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/jwk.d.ts +70 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/jwk.js +81 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/ledger_service.client.d.ts +95 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/ledger_service.client.js +122 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/ledger_service.d.ts +420 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/ledger_service.js +368 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/move_package.d.ts +579 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/move_package.js +485 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/move_package_service.client.d.ts +61 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/move_package_service.client.js +81 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/move_package_service.d.ts +229 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/move_package_service.js +241 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/name_service.client.d.ts +41 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/name_service.client.js +55 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/name_service.d.ts +144 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/name_service.js +141 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/object.d.ts +127 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/object.js +114 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/object_reference.d.ts +34 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/object_reference.js +53 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/owner.d.ts +61 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/owner.js +63 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/protocol_config.d.ts +30 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/protocol_config.js +61 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature.d.ts +630 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature.js +541 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_scheme.d.ts +40 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_scheme.js +33 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.ts +35 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_verification_service.client.js +50 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_verification_service.d.ts +79 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/signature_verification_service.js +90 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/state_service.client.d.ts +71 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/state_service.client.js +88 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/state_service.d.ts +690 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/state_service.js +546 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/subscription_service.client.d.ts +55 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/subscription_service.client.js +54 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/subscription_service.d.ts +57 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/subscription_service.js +65 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/system_state.d.ts +684 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/system_state.js +740 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction.d.ts +1321 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction.js +1005 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.ts +41 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction_execution_service.client.js +49 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction_execution_service.d.ts +184 -0
- package/dist/cjs/grpc/proto/sui/rpc/v2/transaction_execution_service.js +177 -0
- package/dist/cjs/index.d.ts +25 -0
- package/dist/cjs/index.js +93 -0
- package/dist/cjs/jsonRpc/client.d.ts +261 -0
- package/dist/cjs/jsonRpc/client.js +747 -0
- package/dist/cjs/jsonRpc/core.d.ts +87 -0
- package/dist/cjs/jsonRpc/core.js +638 -0
- package/dist/cjs/jsonRpc/errors.d.ts +12 -0
- package/dist/cjs/jsonRpc/errors.js +65 -0
- package/dist/cjs/jsonRpc/http-transport.d.ts +42 -0
- package/dist/cjs/jsonRpc/http-transport.js +121 -0
- package/dist/cjs/jsonRpc/index.d.ts +4 -0
- package/dist/cjs/jsonRpc/index.js +31 -0
- package/dist/cjs/jsonRpc/json-rpc-resolver.d.ts +4 -0
- package/dist/cjs/jsonRpc/json-rpc-resolver.js +321 -0
- package/dist/cjs/jsonRpc/rpc-websocket-client.d.ts +43 -0
- package/dist/cjs/jsonRpc/rpc-websocket-client.js +220 -0
- package/dist/cjs/jsonRpc/types/chain.d.ts +99 -0
- package/dist/cjs/jsonRpc/types/chain.js +16 -0
- package/dist/cjs/jsonRpc/types/changes.d.ts +19 -0
- package/dist/cjs/jsonRpc/types/changes.js +16 -0
- package/dist/cjs/jsonRpc/types/coins.d.ts +6 -0
- package/dist/cjs/jsonRpc/types/coins.js +16 -0
- package/dist/cjs/jsonRpc/types/common.d.ts +2 -0
- package/dist/cjs/jsonRpc/types/common.js +16 -0
- package/dist/cjs/jsonRpc/types/generated.d.ts +1492 -0
- package/dist/cjs/jsonRpc/types/generated.js +16 -0
- package/dist/cjs/jsonRpc/types/index.d.ts +6 -0
- package/dist/cjs/jsonRpc/types/index.js +16 -0
- package/dist/cjs/jsonRpc/types/params.d.ts +656 -0
- package/dist/cjs/jsonRpc/types/params.js +16 -0
- package/dist/cjs/keypairs/ed25519/ed25519-hd-key.d.ts +8 -0
- package/dist/cjs/keypairs/ed25519/ed25519-hd-key.js +82 -0
- package/dist/cjs/keypairs/ed25519/index.d.ts +2 -0
- package/dist/cjs/keypairs/ed25519/index.js +27 -0
- package/dist/cjs/keypairs/ed25519/keypair.d.ts +74 -0
- package/dist/cjs/keypairs/ed25519/keypair.js +169 -0
- package/dist/cjs/keypairs/ed25519/publickey.d.ts +30 -0
- package/dist/cjs/keypairs/ed25519/publickey.js +90 -0
- package/dist/cjs/keypairs/index.d.ts +4 -0
- package/dist/cjs/keypairs/index.js +21 -0
- package/dist/cjs/keypairs/passkey/index.d.ts +3 -0
- package/dist/cjs/keypairs/passkey/index.js +28 -0
- package/dist/cjs/keypairs/passkey/keypair.d.ts +113 -0
- package/dist/cjs/keypairs/passkey/keypair.js +268 -0
- package/dist/cjs/keypairs/passkey/publickey.d.ts +72 -0
- package/dist/cjs/keypairs/passkey/publickey.js +175 -0
- package/dist/cjs/keypairs/passkey/types.d.ts +12 -0
- package/dist/cjs/keypairs/passkey/types.js +16 -0
- package/dist/cjs/keypairs/secp256k1/index.d.ts +2 -0
- package/dist/cjs/keypairs/secp256k1/index.js +27 -0
- package/dist/cjs/keypairs/secp256k1/keypair.d.ts +73 -0
- package/dist/cjs/keypairs/secp256k1/keypair.js +159 -0
- package/dist/cjs/keypairs/secp256k1/publickey.d.ts +30 -0
- package/dist/cjs/keypairs/secp256k1/publickey.js +95 -0
- package/dist/cjs/keypairs/secp256r1/index.d.ts +2 -0
- package/dist/cjs/keypairs/secp256r1/index.js +27 -0
- package/dist/cjs/keypairs/secp256r1/keypair.d.ts +73 -0
- package/dist/cjs/keypairs/secp256r1/keypair.js +155 -0
- package/dist/cjs/keypairs/secp256r1/publickey.d.ts +30 -0
- package/dist/cjs/keypairs/secp256r1/publickey.js +96 -0
- package/dist/cjs/multisig/index.d.ts +2 -0
- package/dist/cjs/multisig/index.js +27 -0
- package/dist/cjs/multisig/publickey.d.ts +79 -0
- package/dist/cjs/multisig/publickey.js +296 -0
- package/dist/cjs/multisig/signer.d.ts +20 -0
- package/dist/cjs/multisig/signer.js +114 -0
- package/dist/cjs/package.json +5 -0
- package/dist/cjs/transactions/Arguments.d.ts +57 -0
- package/dist/cjs/transactions/Arguments.js +36 -0
- package/dist/cjs/transactions/Commands.d.ts +57 -0
- package/dist/cjs/transactions/Commands.js +143 -0
- package/dist/cjs/transactions/Inputs.d.ts +22 -0
- package/dist/cjs/transactions/Inputs.js +87 -0
- package/dist/cjs/transactions/ObjectCache.d.ts +83 -0
- package/dist/cjs/transactions/ObjectCache.js +251 -0
- package/dist/cjs/transactions/Transaction.d.ts +710 -0
- package/dist/cjs/transactions/Transaction.js +742 -0
- package/dist/cjs/transactions/TransactionData.d.ts +73 -0
- package/dist/cjs/transactions/TransactionData.js +472 -0
- package/dist/cjs/transactions/__tests__/Transaction.test.d.ts +1 -0
- package/dist/cjs/transactions/__tests__/bcs.test.d.ts +1 -0
- package/dist/cjs/transactions/data/internal.d.ts +1010 -0
- package/dist/cjs/transactions/data/internal.js +230 -0
- package/dist/cjs/transactions/data/v1.d.ts +312 -0
- package/dist/cjs/transactions/data/v1.js +538 -0
- package/dist/cjs/transactions/data/v2.d.ts +153 -0
- package/dist/cjs/transactions/data/v2.js +124 -0
- package/dist/cjs/transactions/executor/caching.d.ts +31 -0
- package/dist/cjs/transactions/executor/caching.js +118 -0
- package/dist/cjs/transactions/executor/parallel.d.ts +37 -0
- package/dist/cjs/transactions/executor/parallel.js +395 -0
- package/dist/cjs/transactions/executor/queue.d.ts +11 -0
- package/dist/cjs/transactions/executor/queue.js +87 -0
- package/dist/cjs/transactions/executor/serial.d.ts +31 -0
- package/dist/cjs/transactions/executor/serial.js +136 -0
- package/dist/cjs/transactions/hash.d.ts +7 -0
- package/dist/cjs/transactions/hash.js +31 -0
- package/dist/cjs/transactions/index.d.ts +21 -0
- package/dist/cjs/transactions/index.js +50 -0
- package/dist/cjs/transactions/intents/CoinWithBalance.d.ts +9 -0
- package/dist/cjs/transactions/intents/CoinWithBalance.js +206 -0
- package/dist/cjs/transactions/object.d.ts +24 -0
- package/dist/cjs/transactions/object.js +116 -0
- package/dist/cjs/transactions/plugins/NamedPackagesPlugin.d.ts +31 -0
- package/dist/cjs/transactions/plugins/NamedPackagesPlugin.js +37 -0
- package/dist/cjs/transactions/pure.d.ts +20 -0
- package/dist/cjs/transactions/pure.js +64 -0
- package/dist/cjs/transactions/resolve.d.ts +13 -0
- package/dist/cjs/transactions/resolve.js +103 -0
- package/dist/cjs/transactions/serializer.d.ts +7 -0
- package/dist/cjs/transactions/serializer.js +189 -0
- package/dist/cjs/transactions/utils.d.ts +10 -0
- package/dist/cjs/transactions/utils.js +143 -0
- package/dist/cjs/utils/constants.d.ts +17 -0
- package/dist/cjs/utils/constants.js +57 -0
- package/dist/cjs/utils/derived-objects.d.ts +5 -0
- package/dist/cjs/utils/derived-objects.js +33 -0
- package/dist/cjs/utils/dynamic-fields.d.ts +2 -0
- package/dist/cjs/utils/dynamic-fields.js +40 -0
- package/dist/cjs/utils/format.d.ts +2 -0
- package/dist/cjs/utils/format.js +35 -0
- package/dist/cjs/utils/index.d.ts +8 -0
- package/dist/cjs/utils/index.js +65 -0
- package/dist/cjs/utils/move-registry.d.ts +6 -0
- package/dist/cjs/utils/move-registry.js +44 -0
- package/dist/cjs/utils/sui-types.d.ts +26 -0
- package/dist/cjs/utils/sui-types.js +90 -0
- package/dist/cjs/utils/suins.d.ts +2 -0
- package/dist/cjs/utils/suins.js +56 -0
- package/dist/cjs/verify/index.d.ts +1 -0
- package/dist/cjs/verify/index.js +28 -0
- package/dist/cjs/verify/verify.d.ts +16 -0
- package/dist/cjs/verify/verify.js +125 -0
- package/dist/cjs/version.d.ts +2 -0
- package/dist/cjs/version.js +26 -0
- package/dist/cjs/w/call/allocation.d.ts +35 -0
- package/dist/cjs/w/call/allocation.js +439 -0
- package/dist/cjs/w/call/arb.d.ts +17 -0
- package/dist/cjs/w/call/arb.js +149 -0
- package/dist/cjs/w/call/arbitration.d.ts +106 -0
- package/dist/cjs/w/call/arbitration.js +1623 -0
- package/dist/cjs/w/call/base.d.ts +42 -0
- package/dist/cjs/w/call/base.js +363 -0
- package/dist/cjs/w/call/contact.d.ts +45 -0
- package/dist/cjs/w/call/contact.js +479 -0
- package/dist/cjs/w/call/demand.d.ts +79 -0
- package/dist/cjs/w/call/demand.js +872 -0
- package/dist/cjs/w/call/entity.d.ts +33 -0
- package/dist/cjs/w/call/entity.js +230 -0
- package/dist/cjs/w/call/guard-ins.d.ts +32 -0
- package/dist/cjs/w/call/guard-ins.js +4396 -0
- package/dist/cjs/w/call/guard.d.ts +264 -0
- package/dist/cjs/w/call/guard.js +1203 -0
- package/dist/cjs/w/call/index.d.ts +37 -0
- package/dist/cjs/w/call/index.js +72 -0
- package/dist/cjs/w/call/machine.d.ts +124 -0
- package/dist/cjs/w/call/machine.js +1486 -0
- package/dist/cjs/w/call/order.d.ts +73 -0
- package/dist/cjs/w/call/order.js +485 -0
- package/dist/cjs/w/call/passport.d.ts +24 -0
- package/dist/cjs/w/call/passport.js +281 -0
- package/dist/cjs/w/call/payment.d.ts +27 -0
- package/dist/cjs/w/call/payment.js +241 -0
- package/dist/cjs/w/call/permission.d.ts +222 -0
- package/dist/cjs/w/call/permission.js +1368 -0
- package/dist/cjs/w/call/personal.d.ts +51 -0
- package/dist/cjs/w/call/personal.js +184 -0
- package/dist/cjs/w/call/progress.d.ts +94 -0
- package/dist/cjs/w/call/progress.js +833 -0
- package/dist/cjs/w/call/proof.d.ts +27 -0
- package/dist/cjs/w/call/proof.js +124 -0
- package/dist/cjs/w/call/repository.d.ts +97 -0
- package/dist/cjs/w/call/repository.js +1324 -0
- package/dist/cjs/w/call/resource.d.ts +27 -0
- package/dist/cjs/w/call/resource.js +149 -0
- package/dist/cjs/w/call/reward.d.ts +52 -0
- package/dist/cjs/w/call/reward.js +879 -0
- package/dist/cjs/w/call/service.d.ts +184 -0
- package/dist/cjs/w/call/service.js +2468 -0
- package/dist/cjs/w/call/treasury.d.ts +77 -0
- package/dist/cjs/w/call/treasury.js +1192 -0
- package/dist/cjs/w/call/util.d.ts +12 -0
- package/dist/cjs/w/call/util.js +661 -0
- package/dist/cjs/w/common.d.ts +359 -0
- package/dist/cjs/w/common.js +625 -0
- package/dist/cjs/w/exception.d.ts +82 -0
- package/dist/cjs/w/exception.js +604 -0
- package/dist/cjs/w/index.d.ts +8 -0
- package/dist/cjs/w/index.js +25 -0
- package/dist/cjs/w/local/.eslintrc.js +15 -0
- package/dist/cjs/w/local/account.d.ts +134 -0
- package/dist/cjs/w/local/account.js +770 -0
- package/dist/cjs/w/local/cache.d.ts +35 -0
- package/dist/cjs/w/local/cache.js +181 -0
- package/dist/cjs/w/local/config.d.ts +15 -0
- package/dist/cjs/w/local/config.js +83 -0
- package/dist/cjs/w/local/index.d.ts +193 -0
- package/dist/cjs/w/local/index.js +322 -0
- package/dist/cjs/w/local/local.d.ts +93 -0
- package/dist/cjs/w/local/local.js +673 -0
- package/dist/cjs/w/local/storage.d.ts +61 -0
- package/dist/cjs/w/local/storage.js +219 -0
- package/dist/cjs/w/local/token.d.ts +22 -0
- package/dist/cjs/w/local/token.js +182 -0
- package/dist/cjs/w/local/util.d.ts +5 -0
- package/dist/cjs/w/local/util.js +57 -0
- package/dist/cjs/w/local/wip.d.ts +218 -0
- package/dist/cjs/w/local/wip.js +911 -0
- package/dist/cjs/w/messenger/.eslintrc.js +15 -0
- package/dist/cjs/w/messenger/crypto.d.ts +269 -0
- package/dist/cjs/w/messenger/crypto.js +448 -0
- package/dist/cjs/w/messenger/index.d.ts +23 -0
- package/dist/cjs/w/messenger/index.js +37 -0
- package/dist/cjs/w/messenger/messenger-api.d.ts +225 -0
- package/dist/cjs/w/messenger/messenger-api.js +1247 -0
- package/dist/cjs/w/messenger/messenger-manager.d.ts +80 -0
- package/dist/cjs/w/messenger/messenger-manager.js +1143 -0
- package/dist/cjs/w/messenger/messenger.d.ts +231 -0
- package/dist/cjs/w/messenger/messenger.js +1512 -0
- package/dist/cjs/w/messenger/server.d.ts +134 -0
- package/dist/cjs/w/messenger/server.js +535 -0
- package/dist/cjs/w/messenger/session.d.ts +78 -0
- package/dist/cjs/w/messenger/session.js +418 -0
- package/dist/cjs/w/messenger/storage.d.ts +192 -0
- package/dist/cjs/w/messenger/storage.js +964 -0
- package/dist/cjs/w/messenger/types.d.ts +705 -0
- package/dist/cjs/w/messenger/types.js +107 -0
- package/dist/cjs/w/messenger/utils.d.ts +15 -0
- package/dist/cjs/w/messenger/utils.js +37 -0
- package/dist/cjs/w/query/bult-in.d.ts +73 -0
- package/dist/cjs/w/query/bult-in.js +121 -0
- package/dist/cjs/w/query/event.d.ts +82 -0
- package/dist/cjs/w/query/event.js +157 -0
- package/dist/cjs/w/query/index.d.ts +5 -0
- package/dist/cjs/w/query/index.js +22 -0
- package/dist/cjs/w/query/object.d.ts +658 -0
- package/dist/cjs/w/query/object.js +1671 -0
- package/dist/cjs/w/query/received.d.ts +34 -0
- package/dist/cjs/w/query/received.js +93 -0
- package/dist/cjs/w/query/util.d.ts +5 -0
- package/dist/cjs/w/query/util.js +82 -0
- package/dist/cjs/w/util.d.ts +19 -0
- package/dist/cjs/w/util.js +715 -0
- package/dist/cjs/zklogin/address.js +93 -0
- package/dist/cjs/zklogin/bcs.js +41 -0
- package/dist/cjs/zklogin/index.js +45 -0
- package/dist/cjs/zklogin/jwt-decode.js +88 -0
- package/dist/cjs/zklogin/jwt-utils.js +128 -0
- package/dist/cjs/zklogin/nonce.js +60 -0
- package/dist/cjs/zklogin/poseidon.js +64 -0
- package/dist/cjs/zklogin/publickey.js +281 -0
- package/dist/cjs/zklogin/signature.js +57 -0
- package/dist/cjs/zklogin/utils.js +98 -0
- package/dist/esm/bcs/bcs.d.ts +1973 -0
- package/dist/esm/bcs/bcs.js +319 -0
- package/dist/esm/bcs/effects.d.ts +579 -0
- package/dist/esm/bcs/effects.js +211 -0
- package/dist/esm/bcs/index.d.ts +2589 -0
- package/dist/esm/bcs/index.js +98 -0
- package/dist/esm/bcs/pure.d.ts +22 -0
- package/dist/esm/bcs/pure.js +42 -0
- package/dist/esm/bcs/type-tag-serializer.d.ts +7 -0
- package/dist/esm/bcs/type-tag-serializer.js +104 -0
- package/dist/esm/bcs/types.d.ts +114 -0
- package/dist/esm/bcs/types.js +6 -0
- package/dist/esm/client/index.d.ts +5 -0
- package/dist/esm/client/index.js +23 -0
- package/dist/esm/client/network.d.ts +5 -0
- package/dist/esm/client/network.js +23 -0
- package/dist/esm/cryptography/index.d.ts +7 -0
- package/dist/esm/cryptography/index.js +46 -0
- package/dist/esm/cryptography/intent.d.ts +6 -0
- package/dist/esm/cryptography/intent.js +14 -0
- package/dist/esm/cryptography/keypair.d.ts +73 -0
- package/dist/esm/cryptography/keypair.js +108 -0
- package/dist/esm/cryptography/mnemonics.d.ts +27 -0
- package/dist/esm/cryptography/mnemonics.js +30 -0
- package/dist/esm/cryptography/publickey.d.ts +67 -0
- package/dist/esm/cryptography/publickey.js +125 -0
- package/dist/esm/cryptography/signature-scheme.d.ts +24 -0
- package/dist/esm/cryptography/signature-scheme.js +27 -0
- package/dist/esm/cryptography/signature.d.ts +62 -0
- package/dist/esm/cryptography/signature.js +54 -0
- package/dist/esm/experimental/cache.d.ts +12 -0
- package/dist/esm/experimental/client.d.ts +12 -0
- package/dist/esm/experimental/core.d.ts +33 -0
- package/dist/esm/experimental/errors.d.ts +8 -0
- package/dist/esm/experimental/index.d.ts +7 -0
- package/dist/esm/experimental/persistent-storage.d.ts +134 -0
- package/dist/esm/experimental/persistent-storage.test.d.ts +5 -0
- package/dist/esm/experimental/transports/utils.d.ts +3 -0
- package/dist/esm/experimental/types.d.ts +367 -0
- package/dist/esm/faucet/faucet.d.ts +66 -0
- package/dist/esm/faucet/faucet.js +118 -0
- package/dist/esm/faucet/index.d.ts +1 -0
- package/dist/esm/faucet/index.js +16 -0
- package/dist/esm/graphql/client.js +79 -0
- package/dist/esm/graphql/core.js +505 -0
- package/dist/esm/graphql/generated/2024.1/tada-env.js +13121 -0
- package/dist/esm/graphql/generated/2024.1/tsconfig.tada.js +16 -0
- package/dist/esm/graphql/generated/2024.4/tada-env.js +13267 -0
- package/dist/esm/graphql/generated/2024.4/tsconfig.tada.js +16 -0
- package/dist/esm/graphql/generated/latest/tada-env.js +12905 -0
- package/dist/esm/graphql/generated/latest/tsconfig.tada.js +16 -0
- package/dist/esm/graphql/generated/queries.js +788 -0
- package/dist/esm/graphql/index.js +8 -0
- package/dist/esm/graphql/schemas/2024.1/index.js +8 -0
- package/dist/esm/graphql/schemas/2024.4/index.js +8 -0
- package/dist/esm/graphql/schemas/latest/index.js +8 -0
- package/dist/esm/graphql/types.js +0 -0
- package/dist/esm/grpc/client.d.ts +32 -0
- package/dist/esm/grpc/client.js +45 -0
- package/dist/esm/grpc/core.d.ts +28 -0
- package/dist/esm/grpc/core.js +634 -0
- package/dist/esm/grpc/index.d.ts +4 -0
- package/dist/esm/grpc/index.js +6 -0
- package/dist/esm/grpc/proto/google/protobuf/any.d.ts +173 -0
- package/dist/esm/grpc/proto/google/protobuf/any.js +118 -0
- package/dist/esm/grpc/proto/google/protobuf/duration.d.ts +104 -0
- package/dist/esm/grpc/proto/google/protobuf/duration.js +74 -0
- package/dist/esm/grpc/proto/google/protobuf/empty.d.ts +25 -0
- package/dist/esm/grpc/proto/google/protobuf/empty.js +10 -0
- package/dist/esm/grpc/proto/google/protobuf/field_mask.d.ts +231 -0
- package/dist/esm/grpc/proto/google/protobuf/field_mask.js +57 -0
- package/dist/esm/grpc/proto/google/protobuf/struct.d.ts +169 -0
- package/dist/esm/grpc/proto/google/protobuf/struct.js +204 -0
- package/dist/esm/grpc/proto/google/protobuf/timestamp.d.ts +145 -0
- package/dist/esm/grpc/proto/google/protobuf/timestamp.js +114 -0
- package/dist/esm/grpc/proto/google/rpc/error_details.d.ts +525 -0
- package/dist/esm/grpc/proto/google/rpc/error_details.js +297 -0
- package/dist/esm/grpc/proto/google/rpc/status.d.ts +46 -0
- package/dist/esm/grpc/proto/google/rpc/status.js +32 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/argument.d.ts +66 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/argument.js +50 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/balance_change.d.ts +34 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/balance_change.js +32 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/bcs.d.ts +30 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/bcs.js +25 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint.d.ts +68 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint.js +57 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint_contents.d.ts +74 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint_contents.js +64 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint_summary.d.ts +195 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint_summary.js +150 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/effects.d.ts +338 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/effects.js +280 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/epoch.d.ts +62 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/epoch.js +67 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/error_reason.d.ts +17 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/error_reason.js +9 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/event.d.ts +88 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/event.js +66 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/executed_transaction.d.ts +80 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/executed_transaction.js +67 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/execution_status.d.ts +843 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/execution_status.js +499 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/gas_cost_summary.d.ts +41 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/gas_cost_summary.js +43 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/input.d.ts +98 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/input.js +65 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/jwk.d.ts +70 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/jwk.js +61 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/ledger_service.client.d.ts +95 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/ledger_service.client.js +103 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/ledger_service.d.ts +420 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/ledger_service.js +348 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/move_package.d.ts +579 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/move_package.js +465 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/move_package_service.client.d.ts +61 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/move_package_service.client.js +62 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/move_package_service.d.ts +229 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/move_package_service.js +221 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/name_service.client.d.ts +41 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/name_service.client.js +36 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/name_service.d.ts +144 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/name_service.js +121 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/object.d.ts +127 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/object.js +94 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/object_reference.d.ts +34 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/object_reference.js +33 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/owner.d.ts +61 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/owner.js +43 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/protocol_config.d.ts +30 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/protocol_config.js +41 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/signature.d.ts +630 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/signature.js +521 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/signature_scheme.d.ts +40 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/signature_scheme.js +13 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.ts +35 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/signature_verification_service.client.js +31 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/signature_verification_service.d.ts +79 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/signature_verification_service.js +70 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/state_service.client.d.ts +71 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/state_service.client.js +69 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/state_service.d.ts +690 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/state_service.js +526 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/subscription_service.client.d.ts +55 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/subscription_service.client.js +35 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/subscription_service.d.ts +57 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/subscription_service.js +45 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/system_state.d.ts +684 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/system_state.js +720 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/transaction.d.ts +1321 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/transaction.js +985 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.ts +41 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/transaction_execution_service.client.js +30 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/transaction_execution_service.d.ts +184 -0
- package/dist/esm/grpc/proto/sui/rpc/v2/transaction_execution_service.js +157 -0
- package/dist/esm/index.d.ts +25 -0
- package/dist/esm/index.js +119 -0
- package/dist/esm/jsonRpc/client.d.ts +261 -0
- package/dist/esm/jsonRpc/client.js +734 -0
- package/dist/esm/jsonRpc/core.d.ts +87 -0
- package/dist/esm/jsonRpc/core.js +621 -0
- package/dist/esm/jsonRpc/errors.d.ts +12 -0
- package/dist/esm/jsonRpc/errors.js +46 -0
- package/dist/esm/jsonRpc/http-transport.d.ts +42 -0
- package/dist/esm/jsonRpc/http-transport.js +101 -0
- package/dist/esm/jsonRpc/index.d.ts +4 -0
- package/dist/esm/jsonRpc/index.js +20 -0
- package/dist/esm/jsonRpc/json-rpc-resolver.d.ts +4 -0
- package/dist/esm/jsonRpc/json-rpc-resolver.js +309 -0
- package/dist/esm/jsonRpc/rpc-websocket-client.d.ts +43 -0
- package/dist/esm/jsonRpc/rpc-websocket-client.js +201 -0
- package/dist/esm/jsonRpc/types/chain.d.ts +99 -0
- package/dist/esm/jsonRpc/types/chain.js +0 -0
- package/dist/esm/jsonRpc/types/changes.d.ts +19 -0
- package/dist/esm/jsonRpc/types/changes.js +0 -0
- package/dist/esm/jsonRpc/types/coins.d.ts +6 -0
- package/dist/esm/jsonRpc/types/coins.js +0 -0
- package/dist/esm/jsonRpc/types/common.d.ts +2 -0
- package/dist/esm/jsonRpc/types/common.js +0 -0
- package/dist/esm/jsonRpc/types/generated.d.ts +1492 -0
- package/dist/esm/jsonRpc/types/generated.js +0 -0
- package/dist/esm/jsonRpc/types/index.d.ts +6 -0
- package/dist/esm/jsonRpc/types/index.js +0 -0
- package/dist/esm/jsonRpc/types/params.d.ts +656 -0
- package/dist/esm/jsonRpc/types/params.js +0 -0
- package/dist/esm/keypairs/ed25519/ed25519-hd-key.d.ts +8 -0
- package/dist/esm/keypairs/ed25519/ed25519-hd-key.js +62 -0
- package/dist/esm/keypairs/ed25519/index.d.ts +2 -0
- package/dist/esm/keypairs/ed25519/index.js +10 -0
- package/dist/esm/keypairs/ed25519/keypair.d.ts +74 -0
- package/dist/esm/keypairs/ed25519/keypair.js +158 -0
- package/dist/esm/keypairs/ed25519/publickey.d.ts +30 -0
- package/dist/esm/keypairs/ed25519/publickey.js +75 -0
- package/dist/esm/keypairs/index.d.ts +4 -0
- package/dist/esm/keypairs/index.js +4 -0
- package/dist/esm/keypairs/passkey/index.d.ts +3 -0
- package/dist/esm/keypairs/passkey/index.js +12 -0
- package/dist/esm/keypairs/passkey/keypair.d.ts +113 -0
- package/dist/esm/keypairs/passkey/keypair.js +258 -0
- package/dist/esm/keypairs/passkey/publickey.d.ts +72 -0
- package/dist/esm/keypairs/passkey/publickey.js +156 -0
- package/dist/esm/keypairs/passkey/types.d.ts +12 -0
- package/dist/esm/keypairs/passkey/types.js +0 -0
- package/dist/esm/keypairs/secp256k1/index.d.ts +2 -0
- package/dist/esm/keypairs/secp256k1/index.js +10 -0
- package/dist/esm/keypairs/secp256k1/keypair.d.ts +73 -0
- package/dist/esm/keypairs/secp256k1/keypair.js +147 -0
- package/dist/esm/keypairs/secp256k1/publickey.d.ts +30 -0
- package/dist/esm/keypairs/secp256k1/publickey.js +80 -0
- package/dist/esm/keypairs/secp256r1/index.d.ts +2 -0
- package/dist/esm/keypairs/secp256r1/index.js +10 -0
- package/dist/esm/keypairs/secp256r1/keypair.d.ts +73 -0
- package/dist/esm/keypairs/secp256r1/keypair.js +143 -0
- package/dist/esm/keypairs/secp256r1/publickey.d.ts +30 -0
- package/dist/esm/keypairs/secp256r1/publickey.js +77 -0
- package/dist/esm/multisig/index.d.ts +2 -0
- package/dist/esm/multisig/index.js +10 -0
- package/dist/esm/multisig/publickey.d.ts +79 -0
- package/dist/esm/multisig/publickey.js +280 -0
- package/dist/esm/multisig/signer.d.ts +20 -0
- package/dist/esm/multisig/signer.js +94 -0
- package/dist/esm/package.json +5 -0
- package/dist/esm/transactions/Arguments.d.ts +57 -0
- package/dist/esm/transactions/Arguments.js +16 -0
- package/dist/esm/transactions/Commands.d.ts +57 -0
- package/dist/esm/transactions/Commands.js +123 -0
- package/dist/esm/transactions/Inputs.d.ts +22 -0
- package/dist/esm/transactions/Inputs.js +67 -0
- package/dist/esm/transactions/ObjectCache.d.ts +83 -0
- package/dist/esm/transactions/ObjectCache.js +231 -0
- package/dist/esm/transactions/Transaction.d.ts +710 -0
- package/dist/esm/transactions/Transaction.js +731 -0
- package/dist/esm/transactions/TransactionData.d.ts +73 -0
- package/dist/esm/transactions/TransactionData.js +453 -0
- package/dist/esm/transactions/__tests__/Transaction.test.d.ts +1 -0
- package/dist/esm/transactions/__tests__/bcs.test.d.ts +1 -0
- package/dist/esm/transactions/data/internal.d.ts +1010 -0
- package/dist/esm/transactions/data/internal.js +232 -0
- package/dist/esm/transactions/data/v1.d.ts +312 -0
- package/dist/esm/transactions/data/v1.js +542 -0
- package/dist/esm/transactions/data/v2.d.ts +153 -0
- package/dist/esm/transactions/data/v2.js +126 -0
- package/dist/esm/transactions/executor/caching.d.ts +31 -0
- package/dist/esm/transactions/executor/caching.js +99 -0
- package/dist/esm/transactions/executor/parallel.d.ts +37 -0
- package/dist/esm/transactions/executor/parallel.js +375 -0
- package/dist/esm/transactions/executor/queue.d.ts +11 -0
- package/dist/esm/transactions/executor/queue.js +68 -0
- package/dist/esm/transactions/executor/serial.d.ts +31 -0
- package/dist/esm/transactions/executor/serial.js +116 -0
- package/dist/esm/transactions/hash.d.ts +7 -0
- package/dist/esm/transactions/hash.js +11 -0
- package/dist/esm/transactions/index.d.ts +21 -0
- package/dist/esm/transactions/index.js +41 -0
- package/dist/esm/transactions/intents/CoinWithBalance.d.ts +9 -0
- package/dist/esm/transactions/intents/CoinWithBalance.js +186 -0
- package/dist/esm/transactions/object.d.ts +24 -0
- package/dist/esm/transactions/object.js +96 -0
- package/dist/esm/transactions/plugins/NamedPackagesPlugin.d.ts +31 -0
- package/dist/esm/transactions/plugins/NamedPackagesPlugin.js +17 -0
- package/dist/esm/transactions/pure.d.ts +20 -0
- package/dist/esm/transactions/pure.js +44 -0
- package/dist/esm/transactions/resolve.d.ts +13 -0
- package/dist/esm/transactions/resolve.js +83 -0
- package/dist/esm/transactions/serializer.d.ts +7 -0
- package/dist/esm/transactions/serializer.js +169 -0
- package/dist/esm/transactions/utils.d.ts +10 -0
- package/dist/esm/transactions/utils.js +123 -0
- package/dist/esm/utils/constants.d.ts +17 -0
- package/dist/esm/utils/constants.js +37 -0
- package/dist/esm/utils/derived-objects.d.ts +5 -0
- package/dist/esm/utils/derived-objects.js +13 -0
- package/dist/esm/utils/dynamic-fields.d.ts +2 -0
- package/dist/esm/utils/dynamic-fields.js +20 -0
- package/dist/esm/utils/format.d.ts +2 -0
- package/dist/esm/utils/format.js +15 -0
- package/dist/esm/utils/index.d.ts +8 -0
- package/dist/esm/utils/index.js +76 -0
- package/dist/esm/utils/move-registry.d.ts +6 -0
- package/dist/esm/utils/move-registry.js +24 -0
- package/dist/esm/utils/sui-types.d.ts +26 -0
- package/dist/esm/utils/sui-types.js +70 -0
- package/dist/esm/utils/suins.d.ts +2 -0
- package/dist/esm/utils/suins.js +36 -0
- package/dist/esm/verify/index.d.ts +1 -0
- package/dist/esm/verify/index.js +14 -0
- package/dist/esm/verify/verify.d.ts +16 -0
- package/dist/esm/verify/verify.js +108 -0
- package/dist/esm/version.d.ts +2 -0
- package/dist/esm/version.js +6 -0
- package/dist/esm/w/call/allocation.d.ts +35 -0
- package/dist/esm/w/call/allocation.js +433 -0
- package/dist/esm/w/call/arb.d.ts +17 -0
- package/dist/esm/w/call/arb.js +138 -0
- package/dist/esm/w/call/arbitration.d.ts +106 -0
- package/dist/esm/w/call/arbitration.js +1620 -0
- package/dist/esm/w/call/base.d.ts +42 -0
- package/dist/esm/w/call/base.js +350 -0
- package/dist/esm/w/call/contact.d.ts +45 -0
- package/dist/esm/w/call/contact.js +474 -0
- package/dist/esm/w/call/demand.d.ts +79 -0
- package/dist/esm/w/call/demand.js +869 -0
- package/dist/esm/w/call/entity.d.ts +33 -0
- package/dist/esm/w/call/entity.js +220 -0
- package/dist/esm/w/call/guard-ins.d.ts +32 -0
- package/dist/esm/w/call/guard-ins.js +4376 -0
- package/dist/esm/w/call/guard.d.ts +264 -0
- package/dist/esm/w/call/guard.js +1195 -0
- package/dist/esm/w/call/index.d.ts +37 -0
- package/dist/esm/w/call/index.js +59 -0
- package/dist/esm/w/call/machine.d.ts +124 -0
- package/dist/esm/w/call/machine.js +1492 -0
- package/dist/esm/w/call/order.d.ts +73 -0
- package/dist/esm/w/call/order.js +481 -0
- package/dist/esm/w/call/passport.d.ts +24 -0
- package/dist/esm/w/call/passport.js +266 -0
- package/dist/esm/w/call/payment.d.ts +27 -0
- package/dist/esm/w/call/payment.js +233 -0
- package/dist/esm/w/call/permission.d.ts +222 -0
- package/dist/esm/w/call/permission.js +1375 -0
- package/dist/esm/w/call/personal.d.ts +51 -0
- package/dist/esm/w/call/personal.js +177 -0
- package/dist/esm/w/call/progress.d.ts +94 -0
- package/dist/esm/w/call/progress.js +827 -0
- package/dist/esm/w/call/proof.d.ts +27 -0
- package/dist/esm/w/call/proof.js +110 -0
- package/dist/esm/w/call/repository.d.ts +97 -0
- package/dist/esm/w/call/repository.js +1325 -0
- package/dist/esm/w/call/resource.d.ts +27 -0
- package/dist/esm/w/call/resource.js +135 -0
- package/dist/esm/w/call/reward.d.ts +52 -0
- package/dist/esm/w/call/reward.js +874 -0
- package/dist/esm/w/call/service.d.ts +184 -0
- package/dist/esm/w/call/service.js +2472 -0
- package/dist/esm/w/call/treasury.d.ts +77 -0
- package/dist/esm/w/call/treasury.js +1186 -0
- package/dist/esm/w/call/util.d.ts +12 -0
- package/dist/esm/w/call/util.js +646 -0
- package/dist/esm/w/common.d.ts +359 -0
- package/dist/esm/w/common.js +605 -0
- package/dist/esm/w/exception.d.ts +82 -0
- package/dist/esm/w/exception.js +585 -0
- package/dist/esm/w/index.d.ts +8 -0
- package/dist/esm/w/index.js +8 -0
- package/dist/esm/w/local/.eslintrc.js +23 -0
- package/dist/esm/w/local/account.d.ts +134 -0
- package/dist/esm/w/local/account.js +746 -0
- package/dist/esm/w/local/cache.d.ts +35 -0
- package/dist/esm/w/local/cache.js +162 -0
- package/dist/esm/w/local/config.d.ts +15 -0
- package/dist/esm/w/local/config.js +64 -0
- package/dist/esm/w/local/index.d.ts +193 -0
- package/dist/esm/w/local/index.js +301 -0
- package/dist/esm/w/local/local.d.ts +93 -0
- package/dist/esm/w/local/local.js +654 -0
- package/dist/esm/w/local/storage.d.ts +61 -0
- package/dist/esm/w/local/storage.js +190 -0
- package/dist/esm/w/local/token.d.ts +22 -0
- package/dist/esm/w/local/token.js +163 -0
- package/dist/esm/w/local/util.d.ts +5 -0
- package/dist/esm/w/local/util.js +27 -0
- package/dist/esm/w/local/wip.d.ts +218 -0
- package/dist/esm/w/local/wip.js +882 -0
- package/dist/esm/w/messenger/.eslintrc.js +23 -0
- package/dist/esm/w/messenger/crypto.d.ts +269 -0
- package/dist/esm/w/messenger/crypto.js +428 -0
- package/dist/esm/w/messenger/index.d.ts +23 -0
- package/dist/esm/w/messenger/index.js +25 -0
- package/dist/esm/w/messenger/messenger-api.d.ts +225 -0
- package/dist/esm/w/messenger/messenger-api.js +1228 -0
- package/dist/esm/w/messenger/messenger-manager.d.ts +80 -0
- package/dist/esm/w/messenger/messenger-manager.js +1118 -0
- package/dist/esm/w/messenger/messenger.d.ts +231 -0
- package/dist/esm/w/messenger/messenger.js +1492 -0
- package/dist/esm/w/messenger/server.d.ts +134 -0
- package/dist/esm/w/messenger/server.js +520 -0
- package/dist/esm/w/messenger/session.d.ts +78 -0
- package/dist/esm/w/messenger/session.js +415 -0
- package/dist/esm/w/messenger/storage.d.ts +192 -0
- package/dist/esm/w/messenger/storage.js +935 -0
- package/dist/esm/w/messenger/types.d.ts +705 -0
- package/dist/esm/w/messenger/types.js +88 -0
- package/dist/esm/w/messenger/utils.d.ts +15 -0
- package/dist/esm/w/messenger/utils.js +17 -0
- package/dist/esm/w/query/bult-in.d.ts +73 -0
- package/dist/esm/w/query/bult-in.js +112 -0
- package/dist/esm/w/query/event.d.ts +82 -0
- package/dist/esm/w/query/event.js +137 -0
- package/dist/esm/w/query/index.d.ts +5 -0
- package/dist/esm/w/query/index.js +5 -0
- package/dist/esm/w/query/object.d.ts +658 -0
- package/dist/esm/w/query/object.js +1648 -0
- package/dist/esm/w/query/received.d.ts +34 -0
- package/dist/esm/w/query/received.js +73 -0
- package/dist/esm/w/query/util.d.ts +5 -0
- package/dist/esm/w/query/util.js +62 -0
- package/dist/esm/w/util.d.ts +19 -0
- package/dist/esm/w/util.js +710 -0
- package/dist/esm/zklogin/address.js +78 -0
- package/dist/esm/zklogin/bcs.js +21 -0
- package/dist/esm/zklogin/index.js +38 -0
- package/dist/esm/zklogin/jwt-decode.js +68 -0
- package/dist/esm/zklogin/jwt-utils.js +108 -0
- package/dist/esm/zklogin/nonce.js +40 -0
- package/dist/esm/zklogin/poseidon.js +61 -0
- package/dist/esm/zklogin/publickey.js +265 -0
- package/dist/esm/zklogin/signature.js +37 -0
- package/dist/esm/zklogin/utils.js +78 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +297 -61
- package/dist/arbitration.d.ts +0 -65
- package/dist/arbitration.d.ts.map +0 -1
- package/dist/arbitration.js +0 -517
- package/dist/arbitration.js.map +0 -1
- package/dist/demand.d.ts +0 -27
- package/dist/demand.d.ts.map +0 -1
- package/dist/demand.js +0 -266
- package/dist/demand.js.map +0 -1
- package/dist/entity.d.ts +0 -46
- package/dist/entity.d.ts.map +0 -1
- package/dist/entity.js +0 -146
- package/dist/entity.js.map +0 -1
- package/dist/exception.d.ts +0 -37
- package/dist/exception.d.ts.map +0 -1
- package/dist/exception.js +0 -41
- package/dist/exception.js.map +0 -1
- package/dist/guard.d.ts +0 -110
- package/dist/guard.d.ts.map +0 -1
- package/dist/guard.js +0 -936
- package/dist/guard.js.map +0 -1
- package/dist/index.d.ts +0 -40
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -28
- package/dist/index.js.map +0 -1
- package/dist/machine.d.ts +0 -68
- package/dist/machine.d.ts.map +0 -1
- package/dist/machine.js +0 -520
- package/dist/machine.js.map +0 -1
- package/dist/passport.d.ts +0 -129
- package/dist/passport.d.ts.map +0 -1
- package/dist/passport.js +0 -1233
- package/dist/passport.js.map +0 -1
- package/dist/payment.d.ts +0 -28
- package/dist/payment.d.ts.map +0 -1
- package/dist/payment.js +0 -60
- package/dist/payment.js.map +0 -1
- package/dist/permission.d.ts +0 -155
- package/dist/permission.d.ts.map +0 -1
- package/dist/permission.js +0 -462
- package/dist/permission.js.map +0 -1
- package/dist/progress.d.ts +0 -66
- package/dist/progress.d.ts.map +0 -1
- package/dist/progress.js +0 -311
- package/dist/progress.js.map +0 -1
- package/dist/protocol.d.ts +0 -247
- package/dist/protocol.d.ts.map +0 -1
- package/dist/protocol.js +0 -726
- package/dist/protocol.js.map +0 -1
- package/dist/repository.d.ts +0 -95
- package/dist/repository.d.ts.map +0 -1
- package/dist/repository.js +0 -793
- package/dist/repository.js.map +0 -1
- package/dist/resource.d.ts +0 -36
- package/dist/resource.d.ts.map +0 -1
- package/dist/resource.js +0 -129
- package/dist/resource.js.map +0 -1
- package/dist/service.d.ts +0 -144
- package/dist/service.d.ts.map +0 -1
- package/dist/service.js +0 -1303
- package/dist/service.js.map +0 -1
- package/dist/treasury.d.ts +0 -55
- package/dist/treasury.d.ts.map +0 -1
- package/dist/treasury.js +0 -393
- package/dist/treasury.js.map +0 -1
- package/dist/utils.d.ts +0 -94
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -582
- package/dist/utils.js.map +0 -1
- package/dist/wowok.d.ts +0 -15
- package/dist/wowok.d.ts.map +0 -1
- package/dist/wowok.js +0 -66
- package/dist/wowok.js.map +0 -1
|
@@ -0,0 +1,1247 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var messenger_api_exports = {};
|
|
30
|
+
__export(messenger_api_exports, {
|
|
31
|
+
blacklist: () => blacklist,
|
|
32
|
+
extract_zip_messages: () => extract_zip_messages,
|
|
33
|
+
friendslist: () => friendslist,
|
|
34
|
+
generate_wts: () => generate_wts,
|
|
35
|
+
getMessengerManager: () => getMessengerManager,
|
|
36
|
+
guardlist: () => guardlist,
|
|
37
|
+
proof_message: () => proof_message,
|
|
38
|
+
send_file: () => send_file,
|
|
39
|
+
send_message: () => send_message,
|
|
40
|
+
sign_wts: () => sign_wts,
|
|
41
|
+
verify_wts: () => verify_wts,
|
|
42
|
+
watch_conversations: () => watch_conversations,
|
|
43
|
+
watch_messages: () => watch_messages,
|
|
44
|
+
wts2html: () => wts2html
|
|
45
|
+
});
|
|
46
|
+
module.exports = __toCommonJS(messenger_api_exports);
|
|
47
|
+
var import_messenger_manager = require("./messenger-manager.js");
|
|
48
|
+
var import_account = require("../local/account.js");
|
|
49
|
+
var import_exception = require("../exception.js");
|
|
50
|
+
var import_sui_types = require("../../utils/sui-types.js");
|
|
51
|
+
var import_local = require("../local/local.js");
|
|
52
|
+
var import_storage = require("./storage.js");
|
|
53
|
+
var import_types = require("./types.js");
|
|
54
|
+
var import_crypto = require("crypto");
|
|
55
|
+
var fs = __toESM(require("fs"));
|
|
56
|
+
var path = __toESM(require("path"));
|
|
57
|
+
var import_common = require("../common.js");
|
|
58
|
+
var import_crypto2 = require("./crypto.js");
|
|
59
|
+
var import_utils = require("./utils.js");
|
|
60
|
+
var import_local2 = require("../local/index.js");
|
|
61
|
+
var import_object = require("../query/object.js");
|
|
62
|
+
var import_messenger = require("./messenger.js");
|
|
63
|
+
let managerInstance = null;
|
|
64
|
+
let isInitialized = false;
|
|
65
|
+
let backgroundTimer = null;
|
|
66
|
+
async function autoRegisterMessengerAccounts() {
|
|
67
|
+
const accounts = await import_account.Account.Instance().list_messenger_accounts();
|
|
68
|
+
for (const account of accounts) {
|
|
69
|
+
if (!account.address || !account.m) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const messenger = new import_messenger.Messenger(account.address);
|
|
73
|
+
await messenger.initialize();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function getMessengerManager() {
|
|
77
|
+
if (!managerInstance) {
|
|
78
|
+
managerInstance = new import_messenger_manager.MessengerManager();
|
|
79
|
+
}
|
|
80
|
+
if (!isInitialized) {
|
|
81
|
+
isInitialized = true;
|
|
82
|
+
autoRegisterMessengerAccounts().catch((err) => {
|
|
83
|
+
console.error("Failed to auto-register messenger accounts:", err);
|
|
84
|
+
});
|
|
85
|
+
managerInstance.start().catch((err) => {
|
|
86
|
+
console.error("Failed to auto-start messenger manager:", err);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return managerInstance;
|
|
90
|
+
}
|
|
91
|
+
async function backgroundCheck() {
|
|
92
|
+
try {
|
|
93
|
+
const manager = getMessengerManager();
|
|
94
|
+
await manager.start();
|
|
95
|
+
} catch (err) {
|
|
96
|
+
console.error("Background check failed:", err);
|
|
97
|
+
}
|
|
98
|
+
await autoRegisterMessengerAccounts();
|
|
99
|
+
}
|
|
100
|
+
function startBackgroundTimer() {
|
|
101
|
+
if (backgroundTimer) {
|
|
102
|
+
clearInterval(backgroundTimer);
|
|
103
|
+
}
|
|
104
|
+
backgroundTimer = setInterval(() => {
|
|
105
|
+
backgroundCheck().catch(() => {
|
|
106
|
+
});
|
|
107
|
+
}, 60 * 1e3);
|
|
108
|
+
backgroundCheck().catch(() => {
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function registerCleanupHandler() {
|
|
112
|
+
const cleanup = () => {
|
|
113
|
+
if (backgroundTimer) {
|
|
114
|
+
clearInterval(backgroundTimer);
|
|
115
|
+
backgroundTimer = null;
|
|
116
|
+
}
|
|
117
|
+
if (managerInstance) {
|
|
118
|
+
managerInstance.stop();
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
process.on("exit", cleanup);
|
|
122
|
+
process.on("SIGINT", () => {
|
|
123
|
+
cleanup();
|
|
124
|
+
process.exit();
|
|
125
|
+
});
|
|
126
|
+
process.on("SIGTERM", () => {
|
|
127
|
+
cleanup();
|
|
128
|
+
process.exit();
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
registerCleanupHandler();
|
|
132
|
+
startBackgroundTimer();
|
|
133
|
+
async function watch_conversations(account) {
|
|
134
|
+
const address = await import_account.Account.Instance().get_address(account);
|
|
135
|
+
if (!address) {
|
|
136
|
+
(0, import_exception.W_ERROR)(
|
|
137
|
+
import_exception.WErrors.AccountNotFound,
|
|
138
|
+
`watch_conversations.account ${account}`
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
const manager = getMessengerManager();
|
|
142
|
+
return manager.get_conversations(address);
|
|
143
|
+
}
|
|
144
|
+
async function send_message(from, to, content, options) {
|
|
145
|
+
const fromAddress = await import_account.Account.Instance().get_address(from);
|
|
146
|
+
if (!fromAddress) {
|
|
147
|
+
(0, import_exception.W_ERROR)(import_exception.WErrors.AccountNotFound, `send_message.from ${from}`);
|
|
148
|
+
}
|
|
149
|
+
const t = await (0, import_local2.GetAccountOrMark_Address)(to);
|
|
150
|
+
if (!t) {
|
|
151
|
+
(0, import_exception.W_ERROR)(
|
|
152
|
+
import_exception.WErrors.AccountNotFound,
|
|
153
|
+
`send_message.to ${to} is not a valid account/address`
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
if (options?.guardAddress != null && options?.passportAddress != null) {
|
|
157
|
+
[options.guardAddress, options.passportAddress] = await import_local.LocalMark.Instance().get_many_address([
|
|
158
|
+
options.guardAddress,
|
|
159
|
+
options.passportAddress
|
|
160
|
+
]);
|
|
161
|
+
if (!options.guardAddress || !options.passportAddress) {
|
|
162
|
+
(0, import_exception.W_ERROR)(
|
|
163
|
+
import_exception.WErrors.AccountNotFound,
|
|
164
|
+
`send_message.guardAddress or passportAddress not found`
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
const manager = getMessengerManager();
|
|
169
|
+
return manager.send(fromAddress, t, content, options);
|
|
170
|
+
}
|
|
171
|
+
async function send_file(from, to, filePath, options) {
|
|
172
|
+
const fromAddress = await import_account.Account.Instance().get_address(from);
|
|
173
|
+
if (!fromAddress) {
|
|
174
|
+
(0, import_exception.W_ERROR)(import_exception.WErrors.AccountNotFound, `send_file.from ${from}`);
|
|
175
|
+
}
|
|
176
|
+
const t = await (0, import_local2.GetAccountOrMark_Address)(to);
|
|
177
|
+
if (!t) {
|
|
178
|
+
(0, import_exception.W_ERROR)(
|
|
179
|
+
import_exception.WErrors.AccountNotFound,
|
|
180
|
+
`send_file.to ${to} is not a valid account/address`
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
if (options?.guardAddress != null && options?.passportAddress != null) {
|
|
184
|
+
[options.guardAddress, options.passportAddress] = await import_local.LocalMark.Instance().get_many_address([
|
|
185
|
+
options.guardAddress,
|
|
186
|
+
options.passportAddress
|
|
187
|
+
]);
|
|
188
|
+
if (!options.guardAddress || !options.passportAddress) {
|
|
189
|
+
(0, import_exception.W_ERROR)(
|
|
190
|
+
import_exception.WErrors.AccountNotFound,
|
|
191
|
+
`send_file.guardAddress or passportAddress not found`
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
const manager = getMessengerManager();
|
|
196
|
+
return manager.send_file(fromAddress, t, filePath, options);
|
|
197
|
+
}
|
|
198
|
+
async function watch_messages(filter) {
|
|
199
|
+
if (filter?.account) {
|
|
200
|
+
filter.account = await import_account.Account.Instance().get_address(filter.account);
|
|
201
|
+
}
|
|
202
|
+
if (filter?.customListFilter?.includeAddresses != null) {
|
|
203
|
+
filter.customListFilter.includeAddresses = (await import_account.Account.Instance().get_many_address(
|
|
204
|
+
filter.customListFilter.includeAddresses
|
|
205
|
+
)).filter((v) => v != null);
|
|
206
|
+
}
|
|
207
|
+
if (filter?.customListFilter?.excludeAddresses != null) {
|
|
208
|
+
filter.customListFilter.excludeAddresses = (await import_account.Account.Instance().get_many_address(
|
|
209
|
+
filter.customListFilter.excludeAddresses
|
|
210
|
+
)).filter((v) => v != null);
|
|
211
|
+
}
|
|
212
|
+
const manager = getMessengerManager();
|
|
213
|
+
return manager.watch(filter);
|
|
214
|
+
}
|
|
215
|
+
async function extract_zip_message(message, outputDir) {
|
|
216
|
+
if (!message.zipMetadata) {
|
|
217
|
+
throw new import_types.MessengerError(
|
|
218
|
+
import_types.MessengerErrorCode.INVALID_MESSAGE_TYPE,
|
|
219
|
+
"Message is not a ZIP archive"
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
if (!message.plaintext) {
|
|
223
|
+
throw new import_types.MessengerError(
|
|
224
|
+
import_types.MessengerErrorCode.MESSAGE_NOT_DECRYPTED,
|
|
225
|
+
"Message plaintext not available"
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
const zipBase64 = message.plaintext;
|
|
229
|
+
const zipData = Buffer.from(zipBase64, "base64");
|
|
230
|
+
if (message.zipMetadata?.fileHash) {
|
|
231
|
+
const actualHash = (0, import_crypto.createHash)("sha256").update(zipData).digest("hex");
|
|
232
|
+
const expectedHash = message.zipMetadata.fileHash.replace("0x", "");
|
|
233
|
+
if (actualHash !== expectedHash) {
|
|
234
|
+
throw new import_types.MessengerError(
|
|
235
|
+
import_types.MessengerErrorCode.HASH_MISMATCH,
|
|
236
|
+
`ZIP file hash mismatch: expected ${expectedHash}, got ${actualHash}`
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
const JSZip = (await import("jszip")).default;
|
|
241
|
+
const zip = await JSZip.loadAsync(zipData);
|
|
242
|
+
if (!fs.existsSync(outputDir)) {
|
|
243
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
244
|
+
}
|
|
245
|
+
const savedPaths = [];
|
|
246
|
+
for (const [fileName, file] of Object.entries(zip.files)) {
|
|
247
|
+
const zipFile = file;
|
|
248
|
+
if (!zipFile.dir) {
|
|
249
|
+
const content = await zipFile.async("nodebuffer");
|
|
250
|
+
const outputPath = path.join(outputDir, fileName);
|
|
251
|
+
fs.writeFileSync(outputPath, content);
|
|
252
|
+
savedPaths.push(outputPath);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
if (savedPaths.length > 0 && message.zipMetadata) {
|
|
256
|
+
const updatedMetadata = {
|
|
257
|
+
fileName: message.zipMetadata.fileName,
|
|
258
|
+
fileSize: message.zipMetadata.fileSize,
|
|
259
|
+
fileHash: message.zipMetadata.fileHash,
|
|
260
|
+
contentType: message.zipMetadata.contentType,
|
|
261
|
+
localCachePath: savedPaths[0],
|
|
262
|
+
downloadedAt: Date.now()
|
|
263
|
+
};
|
|
264
|
+
message.zipMetadata = updatedMetadata;
|
|
265
|
+
const userAddress = message.direction === "sent" ? message.fromAddress : message.toAddress;
|
|
266
|
+
const messageStorage = new import_storage.MessageStorage(userAddress);
|
|
267
|
+
messageStorage.saveMessage(message);
|
|
268
|
+
}
|
|
269
|
+
return savedPaths[0] || "";
|
|
270
|
+
}
|
|
271
|
+
async function extract_zip_messages(account, messages, outputDir) {
|
|
272
|
+
const results = [];
|
|
273
|
+
const userAddress = await import_account.Account.Instance().get_address(account);
|
|
274
|
+
if (!userAddress) {
|
|
275
|
+
throw new import_types.MessengerError(
|
|
276
|
+
import_types.MessengerErrorCode.INVALID_INPUT,
|
|
277
|
+
"account is required when extracting by message IDs"
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
const isMessageIds = messages.length > 0 && typeof messages[0] === "string";
|
|
281
|
+
for (const item of messages) {
|
|
282
|
+
try {
|
|
283
|
+
let message;
|
|
284
|
+
if (isMessageIds) {
|
|
285
|
+
const messageId = item;
|
|
286
|
+
const messageStorage = new import_storage.MessageStorage(userAddress);
|
|
287
|
+
const storedMessage = messageStorage.getMessageById(messageId);
|
|
288
|
+
if (!storedMessage) {
|
|
289
|
+
console.error(`Message not found: ${messageId}`);
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
message = storedMessage;
|
|
293
|
+
} else {
|
|
294
|
+
message = item;
|
|
295
|
+
}
|
|
296
|
+
if (!message.zipMetadata) {
|
|
297
|
+
console.error(
|
|
298
|
+
`Message ${message.messageId} is not a ZIP archive`
|
|
299
|
+
);
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
const filePath = await extract_zip_message(message, outputDir);
|
|
303
|
+
results.push(filePath);
|
|
304
|
+
} catch (e) {
|
|
305
|
+
const id = isMessageIds ? item : item.messageId;
|
|
306
|
+
console.error(`Failed to extract message ${id}:`, e);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return results;
|
|
310
|
+
}
|
|
311
|
+
async function generate_wts(params) {
|
|
312
|
+
const myAddress = await import_account.Account.Instance().get_address(params.myAccount);
|
|
313
|
+
if (!myAddress) {
|
|
314
|
+
(0, import_exception.W_ERROR)(
|
|
315
|
+
import_exception.WErrors.AccountNotFound,
|
|
316
|
+
`generate_wts.myAccount ${params.myAccount}`
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
if (!(0, import_sui_types.isValidWowAddress)(params.peerAccount)) {
|
|
320
|
+
const t = await import_account.Account.Instance().get_address(params.peerAccount);
|
|
321
|
+
if (!t) {
|
|
322
|
+
(0, import_exception.W_ERROR)(
|
|
323
|
+
import_exception.WErrors.AccountNotFound,
|
|
324
|
+
`generate_wts.peerAccount ${params.peerAccount}`
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
params.peerAccount = t;
|
|
328
|
+
}
|
|
329
|
+
return getMessengerManager().generate_wts(params);
|
|
330
|
+
}
|
|
331
|
+
function load_wts(filePath) {
|
|
332
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
333
|
+
return JSON.parse(content);
|
|
334
|
+
}
|
|
335
|
+
function save_wts(wtsFile, filePath) {
|
|
336
|
+
const dir = path.dirname(filePath);
|
|
337
|
+
if (!fs.existsSync(dir)) {
|
|
338
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
339
|
+
}
|
|
340
|
+
fs.writeFileSync(filePath, JSON.stringify(wtsFile, null, 2), "utf-8");
|
|
341
|
+
}
|
|
342
|
+
async function verify_wts(wtsFilePath) {
|
|
343
|
+
try {
|
|
344
|
+
const wtsFile = load_wts(wtsFilePath);
|
|
345
|
+
if (!wtsFile.wts || !wtsFile.payload || !wtsFile.meta) {
|
|
346
|
+
return { valid: false, error: "Invalid WTS file structure" };
|
|
347
|
+
}
|
|
348
|
+
if (wtsFile.meta.type !== "wts") {
|
|
349
|
+
return {
|
|
350
|
+
valid: false,
|
|
351
|
+
error: `Invalid meta.type: ${wtsFile.meta.type}`
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
const { payload, meta } = wtsFile;
|
|
355
|
+
for (const msg of payload.messages) {
|
|
356
|
+
const result = (0, import_crypto2.verifySingleMerkleRoot)(
|
|
357
|
+
msg.prevRoot,
|
|
358
|
+
msg.merkleRoot,
|
|
359
|
+
msg.plaintextHash,
|
|
360
|
+
msg.timestamp,
|
|
361
|
+
msg.leafIndex
|
|
362
|
+
);
|
|
363
|
+
if (!result.valid) {
|
|
364
|
+
return {
|
|
365
|
+
valid: false,
|
|
366
|
+
error: `${result.error} at leafIndex ${msg.leafIndex}`
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
for (let i = 0; i < payload.messages.length; i++) {
|
|
371
|
+
const msg = payload.messages[i];
|
|
372
|
+
const isNonTextMsg = !!msg.zipMetadata;
|
|
373
|
+
if (!isNonTextMsg) {
|
|
374
|
+
if (!msg.plaintextHash.startsWith("0x") || msg.plaintextHash.length !== 66) {
|
|
375
|
+
return {
|
|
376
|
+
valid: false,
|
|
377
|
+
error: `Message ${i}: Invalid plaintextHash format`
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
if (msg.plaintext) {
|
|
381
|
+
const computedHash2 = (0, import_crypto2.hashPlaintext)(
|
|
382
|
+
msg.plaintext,
|
|
383
|
+
msg.clientTimestamp,
|
|
384
|
+
msg.guardAddress,
|
|
385
|
+
msg.passportAddress,
|
|
386
|
+
msg.lastReceivedLeafIndex
|
|
387
|
+
);
|
|
388
|
+
if (computedHash2.toLowerCase() !== msg.plaintextHash.toLowerCase()) {
|
|
389
|
+
return {
|
|
390
|
+
valid: false,
|
|
391
|
+
error: `Message ${i}: Plaintext hash mismatch`
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
if (msg.serverSignature && msg.serverPublicKey) {
|
|
397
|
+
if (!msg.timestamp) {
|
|
398
|
+
return {
|
|
399
|
+
valid: false,
|
|
400
|
+
error: `Message ${i}: Missing timestamp for signature verification`
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
if (!msg.merkleRoot) {
|
|
404
|
+
return {
|
|
405
|
+
valid: false,
|
|
406
|
+
error: `Message ${i}: Missing merkleRoot for signature verification`
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
if (!msg.prevRoot) {
|
|
410
|
+
return {
|
|
411
|
+
valid: false,
|
|
412
|
+
error: `Message ${i}: Missing prevRoot for signature verification`
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
const signData = `${msg.prevRoot}:${msg.merkleRoot}:${msg.timestamp}:${msg.serverPublicKey}`;
|
|
416
|
+
const signatureValid2 = (0, import_crypto2.verifyEd25519Signature)(
|
|
417
|
+
msg.serverPublicKey,
|
|
418
|
+
signData,
|
|
419
|
+
msg.serverSignature
|
|
420
|
+
);
|
|
421
|
+
if (!signatureValid2) {
|
|
422
|
+
return {
|
|
423
|
+
valid: false,
|
|
424
|
+
error: `Message ${i}: Server signature verification failed`
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
const { sha256 } = await import("@noble/hashes/sha256");
|
|
430
|
+
const { bytesToHex } = await import("@noble/hashes/utils");
|
|
431
|
+
const canonicalPayload = (0, import_utils.canonicalizeJson)(payload);
|
|
432
|
+
const computedHash = "sha256:" + bytesToHex(sha256(new TextEncoder().encode(canonicalPayload)));
|
|
433
|
+
if (computedHash !== meta.hash) {
|
|
434
|
+
return {
|
|
435
|
+
valid: false,
|
|
436
|
+
error: "Hash mismatch - content has been tampered",
|
|
437
|
+
hashValid: false,
|
|
438
|
+
hasSignature: !!meta.signature
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
const signatures = [];
|
|
442
|
+
let signatureValid;
|
|
443
|
+
if (meta.signature) {
|
|
444
|
+
const { Ed25519PublicKey } = await import("../../keypairs/ed25519/publickey.js");
|
|
445
|
+
const sigArray = Array.isArray(meta.signature) ? meta.signature : [meta.signature];
|
|
446
|
+
let allValid = true;
|
|
447
|
+
for (const sig of sigArray) {
|
|
448
|
+
let pkToUse;
|
|
449
|
+
const pk = sig.publicKey;
|
|
450
|
+
if (pk.startsWith("0x")) {
|
|
451
|
+
const buffer = Buffer.from(pk.slice(2), "hex");
|
|
452
|
+
if (buffer.length === 33) {
|
|
453
|
+
pkToUse = buffer.slice(1).toString("base64");
|
|
454
|
+
} else if (buffer.length === 32) {
|
|
455
|
+
pkToUse = buffer.toString("base64");
|
|
456
|
+
} else {
|
|
457
|
+
let address;
|
|
458
|
+
try {
|
|
459
|
+
const pubKey = new Ed25519PublicKey(pk.slice(2));
|
|
460
|
+
address = pubKey.toWAddress();
|
|
461
|
+
} catch {
|
|
462
|
+
}
|
|
463
|
+
signatures.push({
|
|
464
|
+
publicKey: pk,
|
|
465
|
+
address,
|
|
466
|
+
valid: false
|
|
467
|
+
});
|
|
468
|
+
allValid = false;
|
|
469
|
+
continue;
|
|
470
|
+
}
|
|
471
|
+
} else {
|
|
472
|
+
try {
|
|
473
|
+
const buffer = Buffer.from(pk, "base64");
|
|
474
|
+
if (buffer.length === 33) {
|
|
475
|
+
pkToUse = buffer.slice(1).toString("base64");
|
|
476
|
+
} else if (buffer.length === 32) {
|
|
477
|
+
pkToUse = buffer.toString("base64");
|
|
478
|
+
} else {
|
|
479
|
+
let address;
|
|
480
|
+
try {
|
|
481
|
+
const pubKey = new Ed25519PublicKey(pk);
|
|
482
|
+
address = pubKey.toWAddress();
|
|
483
|
+
} catch {
|
|
484
|
+
}
|
|
485
|
+
signatures.push({
|
|
486
|
+
publicKey: pk,
|
|
487
|
+
address,
|
|
488
|
+
valid: false
|
|
489
|
+
});
|
|
490
|
+
allValid = false;
|
|
491
|
+
continue;
|
|
492
|
+
}
|
|
493
|
+
} catch {
|
|
494
|
+
pkToUse = pk;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
try {
|
|
498
|
+
const pubKey = new Ed25519PublicKey(pkToUse);
|
|
499
|
+
const signatureBytes = Uint8Array.from(
|
|
500
|
+
Buffer.from(sig.value, "base64")
|
|
501
|
+
);
|
|
502
|
+
const signValid = await pubKey.verify(
|
|
503
|
+
new TextEncoder().encode(meta.hash),
|
|
504
|
+
signatureBytes
|
|
505
|
+
);
|
|
506
|
+
let address;
|
|
507
|
+
try {
|
|
508
|
+
address = pubKey.toWAddress();
|
|
509
|
+
} catch {
|
|
510
|
+
}
|
|
511
|
+
signatures.push({
|
|
512
|
+
publicKey: pk,
|
|
513
|
+
address,
|
|
514
|
+
valid: signValid
|
|
515
|
+
});
|
|
516
|
+
if (!signValid) {
|
|
517
|
+
allValid = false;
|
|
518
|
+
}
|
|
519
|
+
} catch {
|
|
520
|
+
let address;
|
|
521
|
+
try {
|
|
522
|
+
const pubKey = new Ed25519PublicKey(pkToUse);
|
|
523
|
+
address = pubKey.toWAddress();
|
|
524
|
+
} catch {
|
|
525
|
+
}
|
|
526
|
+
signatures.push({ publicKey: pk, address, valid: false });
|
|
527
|
+
allValid = false;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
signatureValid = allValid;
|
|
531
|
+
if (!signatureValid) {
|
|
532
|
+
const failedAddresses = signatures.filter((s) => !s.valid && s.address).map((s) => s.address);
|
|
533
|
+
return {
|
|
534
|
+
valid: false,
|
|
535
|
+
error: `Signatures from the following addresses are invalid: ${failedAddresses.join(", ")}`,
|
|
536
|
+
hashValid: true,
|
|
537
|
+
hasSignature: true,
|
|
538
|
+
signatureValid: false,
|
|
539
|
+
signatures
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
return {
|
|
544
|
+
valid: true,
|
|
545
|
+
hashValid: true,
|
|
546
|
+
hasSignature: !!meta.signature,
|
|
547
|
+
signatureValid,
|
|
548
|
+
signatures: signatures.length > 0 ? signatures : void 0
|
|
549
|
+
};
|
|
550
|
+
} catch (error) {
|
|
551
|
+
return {
|
|
552
|
+
valid: false,
|
|
553
|
+
error: `Verification error: ${error}`,
|
|
554
|
+
hashValid: false,
|
|
555
|
+
hasSignature: false
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
async function sign_wts(wtsFilePath, account, outputPath) {
|
|
560
|
+
const verifyResult = await verify_wts(wtsFilePath);
|
|
561
|
+
if (!verifyResult.valid) {
|
|
562
|
+
throw new import_types.MessengerError(
|
|
563
|
+
import_types.MessengerErrorCode.INVALID_INPUT,
|
|
564
|
+
`WTS file verification failed: ${verifyResult.error}`
|
|
565
|
+
);
|
|
566
|
+
}
|
|
567
|
+
const wtsFile = load_wts(wtsFilePath);
|
|
568
|
+
const address = await import_account.Account.Instance().get_address(account);
|
|
569
|
+
if (!address) {
|
|
570
|
+
(0, import_exception.W_ERROR)(import_exception.WErrors.AccountNotFound, `sign_wts.account ${account}`);
|
|
571
|
+
}
|
|
572
|
+
const signResult = await import_account.Account.Instance().signData(
|
|
573
|
+
address,
|
|
574
|
+
wtsFile.meta.hash
|
|
575
|
+
);
|
|
576
|
+
let publicKeyBase64;
|
|
577
|
+
const pk = signResult.publicKey;
|
|
578
|
+
if (pk.startsWith("0x")) {
|
|
579
|
+
const buffer = Buffer.from(pk.slice(2), "hex");
|
|
580
|
+
if (buffer.length === 33) {
|
|
581
|
+
publicKeyBase64 = buffer.slice(1).toString("base64");
|
|
582
|
+
} else if (buffer.length === 32) {
|
|
583
|
+
publicKeyBase64 = buffer.toString("base64");
|
|
584
|
+
} else {
|
|
585
|
+
throw new import_types.MessengerError(
|
|
586
|
+
import_types.MessengerErrorCode.INVALID_INPUT,
|
|
587
|
+
`Invalid public key length: ${buffer.length}, expected 32 or 33 bytes`
|
|
588
|
+
);
|
|
589
|
+
}
|
|
590
|
+
} else {
|
|
591
|
+
publicKeyBase64 = pk;
|
|
592
|
+
}
|
|
593
|
+
const newSignature = {
|
|
594
|
+
value: Buffer.from(signResult.signature.slice(2), "hex").toString(
|
|
595
|
+
"base64"
|
|
596
|
+
),
|
|
597
|
+
publicKey: publicKeyBase64,
|
|
598
|
+
algorithm: "Ed25519",
|
|
599
|
+
address: signResult.address
|
|
600
|
+
};
|
|
601
|
+
let signatures;
|
|
602
|
+
if (wtsFile.meta.signature) {
|
|
603
|
+
const existingSigs = Array.isArray(wtsFile.meta.signature) ? [...wtsFile.meta.signature] : [wtsFile.meta.signature];
|
|
604
|
+
const existingIndex = existingSigs.findIndex(
|
|
605
|
+
(sig) => sig.publicKey === publicKeyBase64
|
|
606
|
+
);
|
|
607
|
+
if (existingIndex >= 0) {
|
|
608
|
+
existingSigs[existingIndex] = newSignature;
|
|
609
|
+
signatures = existingSigs;
|
|
610
|
+
} else {
|
|
611
|
+
signatures = [...existingSigs, newSignature];
|
|
612
|
+
}
|
|
613
|
+
} else {
|
|
614
|
+
signatures = [newSignature];
|
|
615
|
+
}
|
|
616
|
+
const signedWtsFile = {
|
|
617
|
+
...wtsFile,
|
|
618
|
+
meta: {
|
|
619
|
+
...wtsFile.meta,
|
|
620
|
+
signature: signatures
|
|
621
|
+
}
|
|
622
|
+
};
|
|
623
|
+
let savePath;
|
|
624
|
+
if (outputPath) {
|
|
625
|
+
savePath = outputPath;
|
|
626
|
+
} else {
|
|
627
|
+
const dir = path.dirname(wtsFilePath);
|
|
628
|
+
const ext = path.extname(wtsFilePath);
|
|
629
|
+
const baseName = path.basename(wtsFilePath, ext);
|
|
630
|
+
savePath = path.join(dir, `signed_${baseName}${ext}`);
|
|
631
|
+
}
|
|
632
|
+
save_wts(signedWtsFile, savePath);
|
|
633
|
+
return savePath;
|
|
634
|
+
}
|
|
635
|
+
async function wts2html(wtsPath, options = {}) {
|
|
636
|
+
const fs2 = await import("fs");
|
|
637
|
+
const path2 = await import("path");
|
|
638
|
+
const stats = fs2.statSync(wtsPath);
|
|
639
|
+
if (stats.isDirectory()) {
|
|
640
|
+
const files = fs2.readdirSync(wtsPath);
|
|
641
|
+
const wtsFiles = files.filter((f) => f.endsWith(".wts"));
|
|
642
|
+
if (wtsFiles.length === 0) {
|
|
643
|
+
throw new import_types.MessengerError(
|
|
644
|
+
import_types.MessengerErrorCode.INVALID_INPUT,
|
|
645
|
+
`No .wts files found in directory: ${wtsPath}`
|
|
646
|
+
);
|
|
647
|
+
}
|
|
648
|
+
const results = [];
|
|
649
|
+
for (const file of wtsFiles) {
|
|
650
|
+
const filePath = path2.join(wtsPath, file);
|
|
651
|
+
const html = await convertWtsToHtml(filePath, options);
|
|
652
|
+
const outputFileName = file.replace(".wts", ".html");
|
|
653
|
+
const outputFilePath = options.outputPath ? path2.join(options.outputPath, outputFileName) : path2.join(wtsPath, outputFileName);
|
|
654
|
+
const outputDir = path2.dirname(outputFilePath);
|
|
655
|
+
if (!fs2.existsSync(outputDir)) {
|
|
656
|
+
fs2.mkdirSync(outputDir, { recursive: true });
|
|
657
|
+
}
|
|
658
|
+
fs2.writeFileSync(outputFilePath, html, "utf-8");
|
|
659
|
+
results.push(outputFilePath);
|
|
660
|
+
}
|
|
661
|
+
return results;
|
|
662
|
+
}
|
|
663
|
+
return convertWtsToHtml(wtsPath, options);
|
|
664
|
+
}
|
|
665
|
+
async function convertWtsToHtml(wtsFilePath, options = {}) {
|
|
666
|
+
const fs2 = await import("fs");
|
|
667
|
+
const path2 = await import("path");
|
|
668
|
+
const { title = "WTS Document", theme = "light" } = options;
|
|
669
|
+
const verifyResult = await verify_wts(wtsFilePath);
|
|
670
|
+
const wtsFile = load_wts(wtsFilePath);
|
|
671
|
+
const { payload, meta } = wtsFile;
|
|
672
|
+
const bgColor = theme === "dark" ? "#1a1a1a" : "#ffffff";
|
|
673
|
+
const textColor = theme === "dark" ? "#e0e0e0" : "#333333";
|
|
674
|
+
const borderColor = theme === "dark" ? "#444444" : "#e0e0e0";
|
|
675
|
+
const escapeHtml = (text) => {
|
|
676
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
677
|
+
};
|
|
678
|
+
const isNonTextMessage = (msg) => {
|
|
679
|
+
return !!msg.zipMetadata;
|
|
680
|
+
};
|
|
681
|
+
const getFileTypeLabel = (msg) => {
|
|
682
|
+
if (msg.zipMetadata?.contentType) {
|
|
683
|
+
return msg.zipMetadata.contentType.toUpperCase();
|
|
684
|
+
}
|
|
685
|
+
const fileName = msg.zipMetadata?.fileName || "";
|
|
686
|
+
if (fileName.endsWith(".wts")) return "WTS";
|
|
687
|
+
if (fileName.endsWith(".wip")) return "WIP";
|
|
688
|
+
if (fileName.endsWith(".zip")) return "ZIP";
|
|
689
|
+
if (fileName.endsWith(".json")) return "JSON";
|
|
690
|
+
if (fileName.endsWith(".txt")) return "TXT";
|
|
691
|
+
if (msg.zipMetadata) return "ZIP";
|
|
692
|
+
return "FILE";
|
|
693
|
+
};
|
|
694
|
+
const generateSaveButton = (msg, index) => {
|
|
695
|
+
const fileType = getFileTypeLabel(msg);
|
|
696
|
+
const fileName = msg.zipMetadata?.fileName || `message_${index}.${fileType.toLowerCase()}`;
|
|
697
|
+
const fileData = msg.plaintext || "";
|
|
698
|
+
return `
|
|
699
|
+
<div style="margin: 12px 0; padding: 16px; background: ${theme === "dark" ? "#2a3f2a" : "#e8f5e9"}; border: 1px solid ${theme === "dark" ? "#4caf50" : "#81c784"}; border-radius: 8px; text-align: center;">
|
|
700
|
+
<div style="font-size: 14px; color: ${theme === "dark" ? "#81c784" : "#2e7d32"}; margin-bottom: 8px;">
|
|
701
|
+
\u{1F4CE} ${fileType} File
|
|
702
|
+
${msg.zipMetadata ? `<span style="font-size: 12px; color: #666;">(${formatFileSize(msg.zipMetadata.fileSize)})</span>` : ""}
|
|
703
|
+
</div>
|
|
704
|
+
<button
|
|
705
|
+
onclick="saveFile${index}()"
|
|
706
|
+
style="padding: 10px 24px; background: #4caf50; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 14px;"
|
|
707
|
+
onmouseover="this.style.background='#45a049'"
|
|
708
|
+
onmouseout="this.style.background='#4caf50'"
|
|
709
|
+
>
|
|
710
|
+
\u{1F4BE} Save ${escapeHtml(fileName)}
|
|
711
|
+
</button>
|
|
712
|
+
</div>
|
|
713
|
+
<script>
|
|
714
|
+
function saveFile${index}() {
|
|
715
|
+
try {
|
|
716
|
+
// Base64 \u89E3\u7801
|
|
717
|
+
const base64Data = "${escapeHtml(fileData)}";
|
|
718
|
+
const byteCharacters = atob(base64Data);
|
|
719
|
+
const byteNumbers = new Array(byteCharacters.length);
|
|
720
|
+
for (let i = 0; i < byteCharacters.length; i++) {
|
|
721
|
+
byteNumbers[i] = byteCharacters.charCodeAt(i);
|
|
722
|
+
}
|
|
723
|
+
const byteArray = new Uint8Array(byteNumbers);
|
|
724
|
+
|
|
725
|
+
// \u6839\u636E\u6587\u4EF6\u7C7B\u578B\u8BBE\u7F6E MIME \u7C7B\u578B
|
|
726
|
+
let mimeType = "application/octet-stream";
|
|
727
|
+
const fileName = "${escapeHtml(fileName)}";
|
|
728
|
+
if (fileName.endsWith('.json')) mimeType = "application/json";
|
|
729
|
+
else if (fileName.endsWith('.zip')) mimeType = "application/zip";
|
|
730
|
+
else if (fileName.endsWith('.txt')) mimeType = "text/plain";
|
|
731
|
+
|
|
732
|
+
const blob = new Blob([byteArray], { type: mimeType });
|
|
733
|
+
const url = URL.createObjectURL(blob);
|
|
734
|
+
const a = document.createElement("a");
|
|
735
|
+
a.href = url;
|
|
736
|
+
a.download = fileName;
|
|
737
|
+
document.body.appendChild(a);
|
|
738
|
+
a.click();
|
|
739
|
+
document.body.removeChild(a);
|
|
740
|
+
URL.revokeObjectURL(url);
|
|
741
|
+
} catch (e) {
|
|
742
|
+
alert('\u4FDD\u5B58\u6587\u4EF6\u5931\u8D25: ' + e.message);
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
<\/script>
|
|
746
|
+
`;
|
|
747
|
+
};
|
|
748
|
+
const formatFileSize = (bytes) => {
|
|
749
|
+
if (bytes < 1024) return bytes + " B";
|
|
750
|
+
if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + " KB";
|
|
751
|
+
return (bytes / (1024 * 1024)).toFixed(1) + " MB";
|
|
752
|
+
};
|
|
753
|
+
const messagesHtml = payload.messages.map((msg, index) => {
|
|
754
|
+
const isNonText = isNonTextMessage(msg);
|
|
755
|
+
return `
|
|
756
|
+
<div style="margin: 16px 0; padding: 16px; border: 1px solid ${borderColor}; border-radius: 8px; background: ${theme === "dark" ? "#2a2a2a" : "#f9f9f9"};">
|
|
757
|
+
<div style="display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 12px; color: #666;">
|
|
758
|
+
<span>From: ${escapeHtml(msg.from.slice(0, 20))}... To: ${escapeHtml(msg.to.slice(0, 20))}...</span>
|
|
759
|
+
<span>${new Date(msg.timestamp).toLocaleString()}</span>
|
|
760
|
+
</div>
|
|
761
|
+
${isNonText ? generateSaveButton(msg, index) : msg.plaintext ? `<div style="margin: 12px 0; padding: 12px; background: ${theme === "dark" ? "#333333" : "#ffffff"}; border: 1px solid ${borderColor}; border-radius: 4px; font-size: 14px; line-height: 1.6; max-height: calc(1.6em * 6); overflow-y: auto; white-space: pre-wrap; word-break: break-word;">${escapeHtml(msg.plaintext)}</div>` : ""}
|
|
762
|
+
<div style="margin: 8px 0; font-size: 11px; color: #666;">
|
|
763
|
+
<div>Plaintext Hash: ${escapeHtml(msg.plaintextHash)}</div>
|
|
764
|
+
${msg.arkConfirmed ? `<div>ARK Confirmed: ${escapeHtml(msg.arkConfirmed.recipient)} at ${new Date(msg.arkConfirmed.timestamp).toLocaleString()}</div>` : ""}
|
|
765
|
+
${msg.guardAddress ? `<div>Guard: ${escapeHtml(msg.guardAddress)}</div>` : ""}
|
|
766
|
+
${msg.passportAddress ? `<div>Passport: ${escapeHtml(msg.passportAddress)}</div>` : ""}
|
|
767
|
+
</div>
|
|
768
|
+
<div style="font-size: 11px; color: #888; margin-top: 8px; padding-top: 8px; border-top: 1px solid ${borderColor};">
|
|
769
|
+
<div>Leaf Index: ${msg.leafIndex}</div>
|
|
770
|
+
<div style="word-break: break-all;">Merkle Root: ${escapeHtml(msg.merkleRoot)}</div>
|
|
771
|
+
<div style="word-break: break-all;">Server Sig: ${escapeHtml(msg.serverSignature.slice(0, 50))}...</div>
|
|
772
|
+
</div>
|
|
773
|
+
</div>
|
|
774
|
+
`;
|
|
775
|
+
}).join("");
|
|
776
|
+
const signatureHtml = "";
|
|
777
|
+
const html = `<!DOCTYPE html>
|
|
778
|
+
<html lang="en">
|
|
779
|
+
<head>
|
|
780
|
+
<meta charset="UTF-8">
|
|
781
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
782
|
+
<title>${escapeHtml(title)}</title>
|
|
783
|
+
<style>
|
|
784
|
+
body {
|
|
785
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
786
|
+
max-width: 800px;
|
|
787
|
+
margin: 0 auto;
|
|
788
|
+
padding: 20px;
|
|
789
|
+
background: ${bgColor};
|
|
790
|
+
color: ${textColor};
|
|
791
|
+
}
|
|
792
|
+
.header {
|
|
793
|
+
border-bottom: 2px solid ${borderColor};
|
|
794
|
+
padding-bottom: 16px;
|
|
795
|
+
margin-bottom: 24px;
|
|
796
|
+
}
|
|
797
|
+
.meta {
|
|
798
|
+
font-size: 12px;
|
|
799
|
+
color: #666;
|
|
800
|
+
margin-top: 8px;
|
|
801
|
+
}
|
|
802
|
+
.note {
|
|
803
|
+
font-size: 11px;
|
|
804
|
+
color: #999;
|
|
805
|
+
margin-top: 12px;
|
|
806
|
+
padding: 8px;
|
|
807
|
+
background: ${theme === "dark" ? "#2a2a2a" : "#f5f5f5"};
|
|
808
|
+
border-radius: 4px;
|
|
809
|
+
font-style: italic;
|
|
810
|
+
}
|
|
811
|
+
</style>
|
|
812
|
+
</head>
|
|
813
|
+
<body>
|
|
814
|
+
<div class="header">
|
|
815
|
+
<h1>Witness Timestamped Sequence</h1>
|
|
816
|
+
<div class="note">
|
|
817
|
+
Important Note: This page is for message browsing and verification reference only. Please verify whether the message sequence has been tampered with through the API using the WTS file.
|
|
818
|
+
</div>
|
|
819
|
+
<div style="font-size: 14px; color: #666; margin-top: 4px;">
|
|
820
|
+
${new Date(meta.startTime).toLocaleDateString()} - ${new Date(meta.endTime).toLocaleDateString()}
|
|
821
|
+
${verifyResult.valid ? `<span style="color: #4caf50; margin-left: 8px;">\u2713 The accuracy, sequentiality, and integrity of the messages are verified without tampering</span>` : `<span style="color: #ff9800; margin-left: 8px;">\u26A0 ${verifyResult.error || "Hash mismatch - content has been tampered"}</span>`}
|
|
822
|
+
</div>
|
|
823
|
+
<div class="meta">
|
|
824
|
+
<div>Session: ${escapeHtml(payload.session.id)}</div>
|
|
825
|
+
<div>Participants: ${payload.session.participants.map((p) => escapeHtml(p.slice(0, 20)) + "...").join(", ")}</div>
|
|
826
|
+
<div>Messages: ${meta.messageCount} | Time: ${new Date(meta.startTime).toLocaleString()} - ${new Date(meta.endTime).toLocaleString()}</div>
|
|
827
|
+
<div style="word-break: break-all;">Merkle Root: ${escapeHtml(meta.merkleRoot)}</div>
|
|
828
|
+
${verifyResult.signatures && verifyResult.signatures.length > 0 ? `
|
|
829
|
+
<div style="margin-top: 8px; padding: 8px; background: ${theme === "dark" ? "#2a3f2a" : "#e8f5e9"}; border-radius: 4px;">
|
|
830
|
+
<div style="font-size: 11px; color: ${theme === "dark" ? "#81c784" : "#2e7d32"}; margin-bottom: 4px;">\u2713 Signature Verification (${verifyResult.signatures.length} signature${verifyResult.signatures.length > 1 ? "s" : ""})</div>
|
|
831
|
+
${verifyResult.signatures.map(
|
|
832
|
+
(s, idx) => `
|
|
833
|
+
<div style="font-size: 10px; color: ${textColor}; margin-left: 8px;">
|
|
834
|
+
${idx + 1}. ${s.address ? escapeHtml(s.address.slice(0, 20)) + "..." : "Unknown"}: ${s.valid ? '<span style="color: #4caf50;">\u2713 Valid</span>' : '<span style="color: #f44336;">\u2717 Invalid</span>'}
|
|
835
|
+
</div>
|
|
836
|
+
`
|
|
837
|
+
).join("")}
|
|
838
|
+
</div>
|
|
839
|
+
` : ""}
|
|
840
|
+
</div>
|
|
841
|
+
</div>
|
|
842
|
+
<div class="messages">
|
|
843
|
+
${messagesHtml}
|
|
844
|
+
</div>
|
|
845
|
+
${signatureHtml}
|
|
846
|
+
</body>
|
|
847
|
+
</html>`;
|
|
848
|
+
if (options.outputPath) {
|
|
849
|
+
const dir = path2.dirname(options.outputPath);
|
|
850
|
+
if (!fs2.existsSync(dir)) {
|
|
851
|
+
fs2.mkdirSync(dir, { recursive: true });
|
|
852
|
+
}
|
|
853
|
+
fs2.writeFileSync(options.outputPath, html, "utf-8");
|
|
854
|
+
return options.outputPath;
|
|
855
|
+
}
|
|
856
|
+
return html;
|
|
857
|
+
}
|
|
858
|
+
async function proof_message(account, messageId, network) {
|
|
859
|
+
const address = await import_account.Account.Instance().get_address(account);
|
|
860
|
+
if (!address) {
|
|
861
|
+
(0, import_exception.W_ERROR)(import_exception.WErrors.AccountNotFound, `proof_message.account ${account}`);
|
|
862
|
+
}
|
|
863
|
+
const messageStorage = new import_storage.MessageStorage(address);
|
|
864
|
+
const message = messageStorage.getMessageById(messageId);
|
|
865
|
+
if (!message) {
|
|
866
|
+
throw new import_types.MessengerError(
|
|
867
|
+
import_types.MessengerErrorCode.INVALID_INPUT,
|
|
868
|
+
`Message not found: ${messageId}`
|
|
869
|
+
);
|
|
870
|
+
}
|
|
871
|
+
if (message.fromAddress.toLowerCase() !== address.toLowerCase() && message.toAddress.toLowerCase() !== address.toLowerCase()) {
|
|
872
|
+
throw new import_types.MessengerError(
|
|
873
|
+
import_types.MessengerErrorCode.INVALID_INPUT,
|
|
874
|
+
`Message does not belong to account ${address}`
|
|
875
|
+
);
|
|
876
|
+
}
|
|
877
|
+
if (!message.serverSignature) {
|
|
878
|
+
throw new import_types.MessengerError(
|
|
879
|
+
import_types.MessengerErrorCode.INVALID_PROOF,
|
|
880
|
+
`Message does not have server signature`
|
|
881
|
+
);
|
|
882
|
+
}
|
|
883
|
+
if (!message.serverPublicKey) {
|
|
884
|
+
throw new import_types.MessengerError(
|
|
885
|
+
import_types.MessengerErrorCode.INVALID_PROOF,
|
|
886
|
+
`Message does not have server public key`
|
|
887
|
+
);
|
|
888
|
+
}
|
|
889
|
+
if (!message.plaintext) {
|
|
890
|
+
throw new import_types.MessengerError(
|
|
891
|
+
import_types.MessengerErrorCode.INVALID_PROOF,
|
|
892
|
+
`Message does not have plaintext`
|
|
893
|
+
);
|
|
894
|
+
}
|
|
895
|
+
const { verifyMessage } = await import("./crypto.js");
|
|
896
|
+
const verifyParams = {
|
|
897
|
+
messageId: message.messageId,
|
|
898
|
+
plaintext: message.plaintext,
|
|
899
|
+
plaintextHash: message.plaintextHash,
|
|
900
|
+
createdAt: message.createdAt,
|
|
901
|
+
guardAddress: message.guardAddress,
|
|
902
|
+
passportAddress: message.passportAddress,
|
|
903
|
+
serverSignature: message.serverSignature,
|
|
904
|
+
serverPublicKey: message.serverPublicKey
|
|
905
|
+
};
|
|
906
|
+
if (message.newRoot && message.leafIndex !== void 0) {
|
|
907
|
+
if (!message.serverTimestamp) {
|
|
908
|
+
throw new import_types.MessengerError(
|
|
909
|
+
import_types.MessengerErrorCode.INVALID_PROOF,
|
|
910
|
+
`Message ${message.messageId} missing server timestamp for verification`
|
|
911
|
+
);
|
|
912
|
+
}
|
|
913
|
+
verifyParams.merkleMetadata = {
|
|
914
|
+
newRoot: message.newRoot,
|
|
915
|
+
prevRoot: message.prevRoot,
|
|
916
|
+
leafIndex: message.leafIndex,
|
|
917
|
+
serverTimestamp: message.serverTimestamp
|
|
918
|
+
// 必须使用服务器时间戳
|
|
919
|
+
// 注意:proofSiblings 和 proofIndices 从服务器拉取时不提供
|
|
920
|
+
// verifyMessage 会跳过 Merkle Proof 验证,只验证 Root 计算
|
|
921
|
+
};
|
|
922
|
+
}
|
|
923
|
+
const verifyResult = verifyMessage(verifyParams);
|
|
924
|
+
if (!verifyResult.valid) {
|
|
925
|
+
throw new import_types.MessengerError(
|
|
926
|
+
import_types.MessengerErrorCode.INVALID_PROOF,
|
|
927
|
+
`Message verification failed: ${verifyResult.error}`
|
|
928
|
+
);
|
|
929
|
+
}
|
|
930
|
+
if (!message.serverPublicKey) {
|
|
931
|
+
throw new import_types.MessengerError(
|
|
932
|
+
import_types.MessengerErrorCode.INVALID_PROOF,
|
|
933
|
+
`Message does not have server public key`
|
|
934
|
+
);
|
|
935
|
+
}
|
|
936
|
+
const { CallProof } = await import("../call/proof.js");
|
|
937
|
+
const callProof = new CallProof({
|
|
938
|
+
proof: message.newRoot,
|
|
939
|
+
// 证明root存在
|
|
940
|
+
server_pubkey: message.serverPublicKey,
|
|
941
|
+
server_signature: message.serverSignature,
|
|
942
|
+
proof_type: import_types.CHAIN_PROOF_TYPE,
|
|
943
|
+
// 消息证明类型
|
|
944
|
+
description: `Message proof for ${messageId}`,
|
|
945
|
+
item_count: message.leafIndex ?? 1,
|
|
946
|
+
about_address: message.fromAddress.toLowerCase() === address.toLowerCase() ? message.toAddress : message.fromAddress
|
|
947
|
+
});
|
|
948
|
+
const env = {
|
|
949
|
+
network,
|
|
950
|
+
account: address
|
|
951
|
+
};
|
|
952
|
+
const result = await callProof.call(env);
|
|
953
|
+
const { ResponseData: extractResponseData } = await import("../call/base.js");
|
|
954
|
+
const responseData = extractResponseData(result);
|
|
955
|
+
const proofResult = responseData.find((item) => item.type === "Proof");
|
|
956
|
+
if (!proofResult || !proofResult.object) {
|
|
957
|
+
throw new import_types.MessengerError(
|
|
958
|
+
import_types.MessengerErrorCode.INVALID_PROOF,
|
|
959
|
+
`Failed to get proof address from transaction result`
|
|
960
|
+
);
|
|
961
|
+
}
|
|
962
|
+
message.proof = proofResult.object;
|
|
963
|
+
messageStorage.saveMessage(message);
|
|
964
|
+
return { proofAddress: proofResult.object };
|
|
965
|
+
}
|
|
966
|
+
const MIN_PASSPORT_VALIDITY = 10;
|
|
967
|
+
const MAX_PASSPORT_VALIDITY = 10 * 365 * 24 * 60 * 60;
|
|
968
|
+
const MAX_BLACKLIST_SIZE_ONCE = 100;
|
|
969
|
+
const MAX_FRIENDS_SIZE_ONCE = 100;
|
|
970
|
+
const MAX_GUARDS_SIZE_ONCE = 10;
|
|
971
|
+
async function blacklist(request) {
|
|
972
|
+
const acc = await import_account.Account.Instance().get_address(request.account);
|
|
973
|
+
if (!acc) {
|
|
974
|
+
(0, import_exception.W_ERROR)(
|
|
975
|
+
import_exception.WErrors.AccountNotFound,
|
|
976
|
+
`blacklist.account ${request.account}`
|
|
977
|
+
);
|
|
978
|
+
}
|
|
979
|
+
const manager = getMessengerManager();
|
|
980
|
+
switch (request.op) {
|
|
981
|
+
case "add": {
|
|
982
|
+
let addresses = await (0, import_local2.GetManyAccountOrMark_Address)(request.users);
|
|
983
|
+
if (addresses.length === 0) {
|
|
984
|
+
(0, import_exception.W_ERROR)(
|
|
985
|
+
import_exception.WErrors.InvalidParam,
|
|
986
|
+
`blacklist.add.users ${request.users} have not valid addresses`
|
|
987
|
+
);
|
|
988
|
+
}
|
|
989
|
+
addresses = [...new Set(addresses.map((a) => a.toLowerCase()))];
|
|
990
|
+
if (addresses.length > MAX_BLACKLIST_SIZE_ONCE) {
|
|
991
|
+
(0, import_exception.W_ERROR)(
|
|
992
|
+
import_exception.WErrors.InvalidParam,
|
|
993
|
+
`blacklist.add.users ${request.users} have too many addresses, max ${MAX_BLACKLIST_SIZE_ONCE}`
|
|
994
|
+
);
|
|
995
|
+
}
|
|
996
|
+
const result = await manager.addToBlacklist(acc, addresses);
|
|
997
|
+
return { op: "add", result };
|
|
998
|
+
}
|
|
999
|
+
case "remove": {
|
|
1000
|
+
let addresses = await (0, import_local2.GetManyAccountOrMark_Address)(request.users);
|
|
1001
|
+
if (addresses.length === 0) {
|
|
1002
|
+
(0, import_exception.W_ERROR)(
|
|
1003
|
+
import_exception.WErrors.InvalidParam,
|
|
1004
|
+
`blacklist.remove.users ${request.users} have not valid addresses`
|
|
1005
|
+
);
|
|
1006
|
+
}
|
|
1007
|
+
addresses = [...new Set(addresses.map((a) => a.toLowerCase()))];
|
|
1008
|
+
if (addresses.length > MAX_BLACKLIST_SIZE_ONCE) {
|
|
1009
|
+
(0, import_exception.W_ERROR)(
|
|
1010
|
+
import_exception.WErrors.InvalidParam,
|
|
1011
|
+
`blacklist.remove.users ${request.users} have too many addresses, max ${MAX_BLACKLIST_SIZE_ONCE}`
|
|
1012
|
+
);
|
|
1013
|
+
}
|
|
1014
|
+
const result = await manager.removeFromBlacklist(acc, addresses);
|
|
1015
|
+
return { op: "remove", result };
|
|
1016
|
+
}
|
|
1017
|
+
case "clear": {
|
|
1018
|
+
const result = await manager.clearBlacklist(acc);
|
|
1019
|
+
return { op: "clear", result };
|
|
1020
|
+
}
|
|
1021
|
+
case "get": {
|
|
1022
|
+
const result = await manager.getBlacklist(acc);
|
|
1023
|
+
return { op: "get", result };
|
|
1024
|
+
}
|
|
1025
|
+
case "exist": {
|
|
1026
|
+
let addresses = await (0, import_local2.GetManyAccountOrMark_Address)(request.users);
|
|
1027
|
+
if (addresses.length === 0) {
|
|
1028
|
+
(0, import_exception.W_ERROR)(
|
|
1029
|
+
import_exception.WErrors.InvalidParam,
|
|
1030
|
+
`blacklist.exist.users ${request.users} have not valid addresses`
|
|
1031
|
+
);
|
|
1032
|
+
}
|
|
1033
|
+
addresses = [...new Set(addresses.map((a) => a.toLowerCase()))];
|
|
1034
|
+
if (addresses.length > MAX_BLACKLIST_SIZE_ONCE) {
|
|
1035
|
+
(0, import_exception.W_ERROR)(
|
|
1036
|
+
import_exception.WErrors.InvalidParam,
|
|
1037
|
+
`blacklist.exist.users ${request.users} have too many addresses, max ${MAX_BLACKLIST_SIZE_ONCE}`
|
|
1038
|
+
);
|
|
1039
|
+
}
|
|
1040
|
+
const result = await manager.existInBlacklist(acc, addresses);
|
|
1041
|
+
return { op: "exist", result };
|
|
1042
|
+
}
|
|
1043
|
+
default:
|
|
1044
|
+
throw new import_types.MessengerError(
|
|
1045
|
+
import_types.MessengerErrorCode.INVALID_INPUT,
|
|
1046
|
+
`blacklist.unknown op: ${request}`
|
|
1047
|
+
);
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
async function friendslist(request) {
|
|
1051
|
+
const acc = await import_account.Account.Instance().get_address(request.account);
|
|
1052
|
+
if (!acc) {
|
|
1053
|
+
(0, import_exception.W_ERROR)(
|
|
1054
|
+
import_exception.WErrors.AccountNotFound,
|
|
1055
|
+
`friendslist.account ${request.account}`
|
|
1056
|
+
);
|
|
1057
|
+
}
|
|
1058
|
+
const manager = getMessengerManager();
|
|
1059
|
+
switch (request.op) {
|
|
1060
|
+
case "add": {
|
|
1061
|
+
let addresses = await (0, import_local2.GetManyAccountOrMark_Address)(request.users);
|
|
1062
|
+
if (addresses.length === 0) {
|
|
1063
|
+
(0, import_exception.W_ERROR)(
|
|
1064
|
+
import_exception.WErrors.InvalidParam,
|
|
1065
|
+
`friendslist.add.users ${request.users} have not valid addresses`
|
|
1066
|
+
);
|
|
1067
|
+
}
|
|
1068
|
+
addresses = [...new Set(addresses.map((a) => a.toLowerCase()))];
|
|
1069
|
+
const result = await manager.addToFriendsList(acc, addresses);
|
|
1070
|
+
return { op: "add", result };
|
|
1071
|
+
}
|
|
1072
|
+
case "remove": {
|
|
1073
|
+
let addresses = await (0, import_local2.GetManyAccountOrMark_Address)(request.users);
|
|
1074
|
+
if (addresses.length === 0) {
|
|
1075
|
+
(0, import_exception.W_ERROR)(
|
|
1076
|
+
import_exception.WErrors.InvalidParam,
|
|
1077
|
+
`friendslist.remove.users ${request.users} have not valid addresses`
|
|
1078
|
+
);
|
|
1079
|
+
}
|
|
1080
|
+
addresses = [...new Set(addresses.map((a) => a.toLowerCase()))];
|
|
1081
|
+
if (addresses.length > MAX_FRIENDS_SIZE_ONCE) {
|
|
1082
|
+
(0, import_exception.W_ERROR)(
|
|
1083
|
+
import_exception.WErrors.InvalidParam,
|
|
1084
|
+
`friendslist.remove.users ${request.users} have too many addresses, max ${MAX_FRIENDS_SIZE_ONCE}`
|
|
1085
|
+
);
|
|
1086
|
+
}
|
|
1087
|
+
const result = await manager.removeFromFriendsList(acc, addresses);
|
|
1088
|
+
return { op: "remove", result };
|
|
1089
|
+
}
|
|
1090
|
+
case "clear": {
|
|
1091
|
+
const result = await manager.clearFriendsList(acc);
|
|
1092
|
+
return { op: "clear", result };
|
|
1093
|
+
}
|
|
1094
|
+
case "get": {
|
|
1095
|
+
const result = await manager.getFriendsList(acc);
|
|
1096
|
+
return { op: "get", result };
|
|
1097
|
+
}
|
|
1098
|
+
case "exist": {
|
|
1099
|
+
let addresses = await (0, import_local2.GetManyAccountOrMark_Address)(request.users);
|
|
1100
|
+
if (addresses.length === 0) {
|
|
1101
|
+
(0, import_exception.W_ERROR)(
|
|
1102
|
+
import_exception.WErrors.InvalidParam,
|
|
1103
|
+
`friendslist.exist.users ${request.users} have not valid addresses`
|
|
1104
|
+
);
|
|
1105
|
+
}
|
|
1106
|
+
addresses = [...new Set(addresses.map((a) => a.toLowerCase()))];
|
|
1107
|
+
if (addresses.length > MAX_FRIENDS_SIZE_ONCE) {
|
|
1108
|
+
(0, import_exception.W_ERROR)(
|
|
1109
|
+
import_exception.WErrors.InvalidParam,
|
|
1110
|
+
`friendslist.exist.users ${request.users} have too many addresses, max ${MAX_FRIENDS_SIZE_ONCE}`
|
|
1111
|
+
);
|
|
1112
|
+
}
|
|
1113
|
+
const result = await manager.existInFriendsList(acc, addresses);
|
|
1114
|
+
return { op: "exist", result };
|
|
1115
|
+
}
|
|
1116
|
+
default:
|
|
1117
|
+
throw new import_types.MessengerError(
|
|
1118
|
+
import_types.MessengerErrorCode.INVALID_INPUT,
|
|
1119
|
+
`friendslist.unknown op: ${request}`
|
|
1120
|
+
);
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
async function guardlist(request) {
|
|
1124
|
+
const acc = await import_account.Account.Instance().get_address(request.account);
|
|
1125
|
+
if (!acc) {
|
|
1126
|
+
(0, import_exception.W_ERROR)(
|
|
1127
|
+
import_exception.WErrors.AccountNotFound,
|
|
1128
|
+
`guardlist.account ${request.account}`
|
|
1129
|
+
);
|
|
1130
|
+
}
|
|
1131
|
+
const manager = getMessengerManager();
|
|
1132
|
+
switch (request.op) {
|
|
1133
|
+
case "add": {
|
|
1134
|
+
const uniqueGuardsMap = /* @__PURE__ */ new Map();
|
|
1135
|
+
for (const g of request.guards) {
|
|
1136
|
+
uniqueGuardsMap.set(g.guard.toLowerCase(), g);
|
|
1137
|
+
}
|
|
1138
|
+
const guards = Array.from(uniqueGuardsMap.values());
|
|
1139
|
+
if (guards.length === 0) {
|
|
1140
|
+
(0, import_exception.W_ERROR)(
|
|
1141
|
+
import_exception.WErrors.InvalidParam,
|
|
1142
|
+
`guardlist.add.guards ${request.guards} have not valid guards`
|
|
1143
|
+
);
|
|
1144
|
+
}
|
|
1145
|
+
if (guards.length > MAX_GUARDS_SIZE_ONCE) {
|
|
1146
|
+
(0, import_exception.W_ERROR)(
|
|
1147
|
+
import_exception.WErrors.InvalidParam,
|
|
1148
|
+
`guardlist.add.guards ${request.guards} have too many guards, max ${MAX_GUARDS_SIZE_ONCE}`
|
|
1149
|
+
);
|
|
1150
|
+
}
|
|
1151
|
+
for (const g of guards) {
|
|
1152
|
+
if (!(0, import_common.isValidU64)(g.passportValiditySeconds) || g.passportValiditySeconds < MIN_PASSPORT_VALIDITY || g.passportValiditySeconds > MAX_PASSPORT_VALIDITY) {
|
|
1153
|
+
(0, import_exception.W_ERROR)(
|
|
1154
|
+
import_exception.WErrors.InvalidParam,
|
|
1155
|
+
`Guard ${g.guard}: passport validity ${g.passportValiditySeconds} must be between ${MIN_PASSPORT_VALIDITY} and ${MAX_PASSPORT_VALIDITY} seconds`
|
|
1156
|
+
);
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
const addresses = await import_local.LocalMark.Instance().get_many_address(
|
|
1160
|
+
guards.map((g) => g.guard)
|
|
1161
|
+
);
|
|
1162
|
+
if (addresses.length !== guards.length) {
|
|
1163
|
+
const foundAddresses = new Set(addresses);
|
|
1164
|
+
const missingGuards = [];
|
|
1165
|
+
for (const g of guards) {
|
|
1166
|
+
if (!foundAddresses.has(g.guard) && !g.guard.startsWith("0x")) {
|
|
1167
|
+
missingGuards.push(g.guard);
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
(0, import_exception.W_ERROR)(
|
|
1171
|
+
import_exception.WErrors.InvalidParam,
|
|
1172
|
+
`Guard not found: ${missingGuards.join(", ")}`
|
|
1173
|
+
);
|
|
1174
|
+
}
|
|
1175
|
+
const objs = await (0, import_object.query_objects)({
|
|
1176
|
+
objects: addresses,
|
|
1177
|
+
no_cache: false,
|
|
1178
|
+
network: manager.getConfig().network
|
|
1179
|
+
});
|
|
1180
|
+
if (!objs || !objs.objects || objs.objects.length === 0) {
|
|
1181
|
+
(0, import_exception.W_ERROR)(
|
|
1182
|
+
import_exception.WErrors.InvalidParam,
|
|
1183
|
+
`Guard not found: ${guards.map((g) => g.guard).join(", ")}`
|
|
1184
|
+
);
|
|
1185
|
+
}
|
|
1186
|
+
objs.objects.forEach((obj) => {
|
|
1187
|
+
if (obj.type !== "Guard") {
|
|
1188
|
+
(0, import_exception.W_ERROR)(
|
|
1189
|
+
import_exception.WErrors.InvalidParam,
|
|
1190
|
+
`Guard ${obj.object} is not a Guard`
|
|
1191
|
+
);
|
|
1192
|
+
}
|
|
1193
|
+
});
|
|
1194
|
+
const guardListItems = guards.map((g, index) => ({
|
|
1195
|
+
guardAddress: addresses[index],
|
|
1196
|
+
passportValiditySeconds: g.passportValiditySeconds
|
|
1197
|
+
}));
|
|
1198
|
+
const result = await manager.addToGuardList(acc, guardListItems);
|
|
1199
|
+
return { op: "add", result };
|
|
1200
|
+
}
|
|
1201
|
+
case "remove": {
|
|
1202
|
+
const guards = [
|
|
1203
|
+
...new Set(request.guards.map((g) => g.toLowerCase()))
|
|
1204
|
+
];
|
|
1205
|
+
if (guards.length === 0) {
|
|
1206
|
+
(0, import_exception.W_ERROR)(
|
|
1207
|
+
import_exception.WErrors.InvalidParam,
|
|
1208
|
+
`guardlist.remove.guards ${request.guards} have not valid guards`
|
|
1209
|
+
);
|
|
1210
|
+
}
|
|
1211
|
+
if (guards.length > MAX_GUARDS_SIZE_ONCE) {
|
|
1212
|
+
(0, import_exception.W_ERROR)(
|
|
1213
|
+
import_exception.WErrors.InvalidParam,
|
|
1214
|
+
`guardlist.remove.guards ${request.guards} have too many guards, max ${MAX_GUARDS_SIZE_ONCE}`
|
|
1215
|
+
);
|
|
1216
|
+
}
|
|
1217
|
+
const addresses = await import_local.LocalMark.Instance().get_many_address(guards);
|
|
1218
|
+
if (addresses.length !== guards.length) {
|
|
1219
|
+
const foundAddresses = new Set(addresses);
|
|
1220
|
+
const missingGuards = [];
|
|
1221
|
+
for (const g of guards) {
|
|
1222
|
+
if (!foundAddresses.has(g) && !g.startsWith("0x")) {
|
|
1223
|
+
missingGuards.push(g);
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
(0, import_exception.W_ERROR)(
|
|
1227
|
+
import_exception.WErrors.InvalidParam,
|
|
1228
|
+
`Guard not found: ${missingGuards.join(", ")}`
|
|
1229
|
+
);
|
|
1230
|
+
}
|
|
1231
|
+
const result = await manager.removeFromGuardList(
|
|
1232
|
+
acc,
|
|
1233
|
+
addresses
|
|
1234
|
+
);
|
|
1235
|
+
return { op: "remove", result };
|
|
1236
|
+
}
|
|
1237
|
+
case "get": {
|
|
1238
|
+
const result = await manager.getGuardList(acc);
|
|
1239
|
+
return { op: "get", result };
|
|
1240
|
+
}
|
|
1241
|
+
default:
|
|
1242
|
+
throw new import_types.MessengerError(
|
|
1243
|
+
import_types.MessengerErrorCode.INVALID_INPUT,
|
|
1244
|
+
`guardlist.unknown op: ${request}`
|
|
1245
|
+
);
|
|
1246
|
+
}
|
|
1247
|
+
}
|