wowok 1.8.2 → 2.1.9
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/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 +31 -0
- package/dist/cjs/w/call/guard-ins.js +4391 -0
- package/dist/cjs/w/call/guard.d.ts +254 -0
- package/dist/cjs/w/call/guard.js +1210 -0
- package/dist/cjs/w/call/index.d.ts +37 -0
- package/dist/cjs/w/call/index.js +71 -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 +31 -0
- package/dist/esm/w/call/guard-ins.js +4371 -0
- package/dist/esm/w/call/guard.d.ts +254 -0
- package/dist/esm/w/call/guard.js +1202 -0
- package/dist/esm/w/call/index.d.ts +37 -0
- package/dist/esm/w/call/index.js +57 -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 +295 -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 -94
- package/dist/repository.d.ts.map +0 -1
- package/dist/repository.js +0 -783
- 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,911 @@
|
|
|
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 __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
31
|
+
var wip_exports = {};
|
|
32
|
+
__export(wip_exports, {
|
|
33
|
+
DEFAULT_LIMITS: () => DEFAULT_LIMITS,
|
|
34
|
+
WIP: () => WIP,
|
|
35
|
+
WipError: () => WipError,
|
|
36
|
+
WipSizeError: () => WipSizeError,
|
|
37
|
+
WipValidationError: () => WipValidationError,
|
|
38
|
+
createWip: () => createWip,
|
|
39
|
+
default: () => wip_default,
|
|
40
|
+
generate_wip: () => generate_wip,
|
|
41
|
+
loadWip: () => loadWip,
|
|
42
|
+
sign_wip: () => sign_wip,
|
|
43
|
+
verifyWip: () => verifyWip,
|
|
44
|
+
verify_wip: () => verify_wip,
|
|
45
|
+
wip2html: () => wip2html,
|
|
46
|
+
wipToHtml: () => wipToHtml
|
|
47
|
+
});
|
|
48
|
+
module.exports = __toCommonJS(wip_exports);
|
|
49
|
+
var import_sha256 = require("@noble/hashes/sha256");
|
|
50
|
+
var import_utils = require("@noble/hashes/utils");
|
|
51
|
+
var fs = __toESM(require("fs"));
|
|
52
|
+
var path = __toESM(require("path"));
|
|
53
|
+
const WIP_SCHEMA_URL = "https://schema.wip/v1";
|
|
54
|
+
const WIP_VERSION = "1.0.0";
|
|
55
|
+
const DEFAULT_LIMITS = {
|
|
56
|
+
maxImageSize: 2 * 1024 * 1024,
|
|
57
|
+
// 2MB
|
|
58
|
+
maxTotalSize: 10 * 1024 * 1024,
|
|
59
|
+
// 10MB
|
|
60
|
+
maxImageCount: 10,
|
|
61
|
+
maxTextLength: 1e4
|
|
62
|
+
};
|
|
63
|
+
class WipError extends Error {
|
|
64
|
+
constructor(message) {
|
|
65
|
+
super(message);
|
|
66
|
+
this.name = "WipError";
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
class WipValidationError extends WipError {
|
|
70
|
+
constructor(message) {
|
|
71
|
+
super(message);
|
|
72
|
+
this.name = "WipValidationError";
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
class WipSizeError extends WipError {
|
|
76
|
+
constructor(message) {
|
|
77
|
+
super(message);
|
|
78
|
+
this.name = "WipSizeError";
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function detectMimeType(buffer) {
|
|
82
|
+
if (buffer.length >= 4 && buffer[0] === 137 && buffer[1] === 80 && buffer[2] === 78 && buffer[3] === 71) {
|
|
83
|
+
return "image/png";
|
|
84
|
+
}
|
|
85
|
+
if (buffer.length >= 3 && buffer[0] === 255 && buffer[1] === 216 && buffer[2] === 255) {
|
|
86
|
+
return "image/jpeg";
|
|
87
|
+
}
|
|
88
|
+
if (buffer.length >= 6 && buffer[0] === 71 && buffer[1] === 73 && buffer[2] === 70) {
|
|
89
|
+
return "image/gif";
|
|
90
|
+
}
|
|
91
|
+
if (buffer.length >= 12 && buffer[0] === 82 && buffer[1] === 73 && buffer[2] === 70 && buffer[3] === 70 && buffer[8] === 87 && buffer[9] === 69 && buffer[10] === 66 && buffer[11] === 80) {
|
|
92
|
+
return "image/webp";
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
function uint8ArrayToBase64(array) {
|
|
97
|
+
let binary = "";
|
|
98
|
+
const len = array.length;
|
|
99
|
+
for (let i = 0; i < len; i++) {
|
|
100
|
+
binary += String.fromCharCode(array[i]);
|
|
101
|
+
}
|
|
102
|
+
return btoa(binary);
|
|
103
|
+
}
|
|
104
|
+
function base64ToUint8Array(base64) {
|
|
105
|
+
const binary = atob(base64);
|
|
106
|
+
const len = binary.length;
|
|
107
|
+
const array = new Uint8Array(len);
|
|
108
|
+
for (let i = 0; i < len; i++) {
|
|
109
|
+
array[i] = binary.charCodeAt(i);
|
|
110
|
+
}
|
|
111
|
+
return array;
|
|
112
|
+
}
|
|
113
|
+
function canonicalizeJson(obj) {
|
|
114
|
+
if (obj === null || typeof obj !== "object") {
|
|
115
|
+
return JSON.stringify(obj);
|
|
116
|
+
}
|
|
117
|
+
if (Array.isArray(obj)) {
|
|
118
|
+
return "[" + obj.map(canonicalizeJson).join(",") + "]";
|
|
119
|
+
}
|
|
120
|
+
const sortedObj = obj;
|
|
121
|
+
const keys = Object.keys(sortedObj).sort();
|
|
122
|
+
const pairs = keys.map(
|
|
123
|
+
(key) => `"${key}":${canonicalizeJson(sortedObj[key])}`
|
|
124
|
+
);
|
|
125
|
+
return "{" + pairs.join(",") + "}";
|
|
126
|
+
}
|
|
127
|
+
function computeHash(data) {
|
|
128
|
+
const hash = (0, import_sha256.sha256)(new TextEncoder().encode(data));
|
|
129
|
+
return "sha256:" + (0, import_utils.bytesToHex)(hash);
|
|
130
|
+
}
|
|
131
|
+
function generateId(prefix) {
|
|
132
|
+
const timestamp = Date.now().toString(36);
|
|
133
|
+
const random = Math.random().toString(36).substring(2, 8);
|
|
134
|
+
return `${prefix}-${timestamp}-${random}`;
|
|
135
|
+
}
|
|
136
|
+
function getExtensionFromMimeType(mimeType) {
|
|
137
|
+
const map = {
|
|
138
|
+
"image/png": "png",
|
|
139
|
+
"image/jpeg": "jpg",
|
|
140
|
+
"image/gif": "gif",
|
|
141
|
+
"image/webp": "webp"
|
|
142
|
+
};
|
|
143
|
+
return map[mimeType] || "bin";
|
|
144
|
+
}
|
|
145
|
+
class ResourceLoader {
|
|
146
|
+
constructor(maxSize) {
|
|
147
|
+
__publicField(this, "maxSize");
|
|
148
|
+
this.maxSize = maxSize;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* 加载资源
|
|
152
|
+
*/
|
|
153
|
+
async load(source) {
|
|
154
|
+
if (source.startsWith("data:")) {
|
|
155
|
+
return this.loadFromDataUrl(source);
|
|
156
|
+
}
|
|
157
|
+
if (source.startsWith("http://") || source.startsWith("https://")) {
|
|
158
|
+
return this.loadFromNetwork(source);
|
|
159
|
+
}
|
|
160
|
+
return this.loadFromFile(source);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* 从 Data URL 加载
|
|
164
|
+
*/
|
|
165
|
+
loadFromDataUrl(dataUrl) {
|
|
166
|
+
const match = dataUrl.match(/^data:image\/(\w+);base64,(.+)$/);
|
|
167
|
+
if (!match) {
|
|
168
|
+
throw new WipValidationError(
|
|
169
|
+
`Invalid data URL format: ${dataUrl.substring(0, 50)}...`
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
const base64Data = match[2];
|
|
173
|
+
try {
|
|
174
|
+
return base64ToUint8Array(base64Data);
|
|
175
|
+
} catch (error) {
|
|
176
|
+
throw new WipError(`Failed to decode data URL: ${error}`);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* 从网络加载
|
|
181
|
+
*/
|
|
182
|
+
async loadFromNetwork(url) {
|
|
183
|
+
try {
|
|
184
|
+
const controller = new AbortController();
|
|
185
|
+
const timeoutId = setTimeout(() => controller.abort(), 3e4);
|
|
186
|
+
const response = await fetch(url, {
|
|
187
|
+
signal: controller.signal,
|
|
188
|
+
headers: {
|
|
189
|
+
Accept: "image/png,image/jpeg,image/gif,image/webp,image/*"
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
clearTimeout(timeoutId);
|
|
193
|
+
if (!response.ok) {
|
|
194
|
+
throw new WipError(
|
|
195
|
+
`Failed to fetch: ${response.status} ${response.statusText}`
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
const contentLength = response.headers.get("content-length");
|
|
199
|
+
if (contentLength && parseInt(contentLength) > this.maxSize) {
|
|
200
|
+
throw new WipSizeError(
|
|
201
|
+
`Resource from ${url} size (${contentLength} bytes) exceeds limit (${this.maxSize} bytes)`
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
205
|
+
if (arrayBuffer.byteLength > this.maxSize) {
|
|
206
|
+
throw new WipSizeError(
|
|
207
|
+
`Resource from ${url} size (${arrayBuffer.byteLength} bytes) exceeds limit (${this.maxSize} bytes)`
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
return new Uint8Array(arrayBuffer);
|
|
211
|
+
} catch (error) {
|
|
212
|
+
if (error instanceof WipError) {
|
|
213
|
+
throw error;
|
|
214
|
+
}
|
|
215
|
+
if (error instanceof Error) {
|
|
216
|
+
if (error.name === "AbortError") {
|
|
217
|
+
throw new WipError(
|
|
218
|
+
`Network timeout while fetching: ${url}`
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
throw new WipError(`Network error: ${error.message}`);
|
|
222
|
+
}
|
|
223
|
+
throw error;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* 从本地文件加载
|
|
228
|
+
*/
|
|
229
|
+
loadFromFile(filePath) {
|
|
230
|
+
const resolvedPath = path.resolve(filePath);
|
|
231
|
+
if (!fs.existsSync(resolvedPath)) {
|
|
232
|
+
throw new WipError(`File not found: ${resolvedPath}`);
|
|
233
|
+
}
|
|
234
|
+
const stats = fs.statSync(resolvedPath);
|
|
235
|
+
if (!stats.isFile()) {
|
|
236
|
+
throw new WipError(`Path is not a file: ${resolvedPath}`);
|
|
237
|
+
}
|
|
238
|
+
if (stats.size > this.maxSize) {
|
|
239
|
+
throw new WipSizeError(
|
|
240
|
+
`File ${resolvedPath} size (${stats.size} bytes) exceeds limit (${this.maxSize} bytes)`
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
const buffer = fs.readFileSync(resolvedPath);
|
|
244
|
+
return new Uint8Array(buffer);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
class WIP {
|
|
248
|
+
constructor(limits = {}) {
|
|
249
|
+
__publicField(this, "limits");
|
|
250
|
+
__publicField(this, "resourceLoader");
|
|
251
|
+
this.limits = { ...DEFAULT_LIMITS, ...limits };
|
|
252
|
+
this.resourceLoader = new ResourceLoader(this.limits.maxImageSize);
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* 创建 WIP 文件
|
|
256
|
+
*/
|
|
257
|
+
async create(options) {
|
|
258
|
+
if (options.text.length > this.limits.maxTextLength) {
|
|
259
|
+
throw new WipSizeError(
|
|
260
|
+
`Text length (${options.text.length}) exceeds limit (${this.limits.maxTextLength})`
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
const media = [];
|
|
264
|
+
if (options.images && options.images.length > 0) {
|
|
265
|
+
if (options.images.length > this.limits.maxImageCount) {
|
|
266
|
+
throw new WipSizeError(
|
|
267
|
+
`Image count (${options.images.length}) exceeds limit (${this.limits.maxImageCount})`
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
for (let i = 0; i < options.images.length; i++) {
|
|
271
|
+
const wipMedia = await this.processImage(options.images[i], i);
|
|
272
|
+
media.push(wipMedia);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
const payload = {
|
|
276
|
+
content: {
|
|
277
|
+
text: options.text,
|
|
278
|
+
format: options.textFormat || "plain"
|
|
279
|
+
},
|
|
280
|
+
media
|
|
281
|
+
};
|
|
282
|
+
const canonicalPayload = canonicalizeJson(payload);
|
|
283
|
+
const hash = computeHash(canonicalPayload);
|
|
284
|
+
const meta = {
|
|
285
|
+
type: "wip",
|
|
286
|
+
version: WIP_VERSION,
|
|
287
|
+
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
288
|
+
hash,
|
|
289
|
+
algorithm: "sha256"
|
|
290
|
+
};
|
|
291
|
+
if (options.signKeyPair) {
|
|
292
|
+
const signatureValue = await this.sign(
|
|
293
|
+
hash,
|
|
294
|
+
options.signKeyPair.privateKey,
|
|
295
|
+
options.signAlgorithm || "Ed25519"
|
|
296
|
+
);
|
|
297
|
+
meta.signature = {
|
|
298
|
+
value: signatureValue,
|
|
299
|
+
publicKey: options.signKeyPair.publicKey,
|
|
300
|
+
algorithm: options.signAlgorithm || "Ed25519"
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
const wipFile = {
|
|
304
|
+
wip: WIP_SCHEMA_URL,
|
|
305
|
+
payload,
|
|
306
|
+
meta
|
|
307
|
+
};
|
|
308
|
+
const jsonString = JSON.stringify(wipFile);
|
|
309
|
+
if (jsonString.length > this.limits.maxTotalSize) {
|
|
310
|
+
throw new WipSizeError(
|
|
311
|
+
`Total WIP file size (${jsonString.length} bytes) exceeds limit (${this.limits.maxTotalSize} bytes)`
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
return wipFile;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* 处理图片源
|
|
318
|
+
*/
|
|
319
|
+
async processImage(source, index) {
|
|
320
|
+
const data = await this.resourceLoader.load(source.source);
|
|
321
|
+
const mimeType = detectMimeType(data);
|
|
322
|
+
if (!mimeType) {
|
|
323
|
+
throw new WipValidationError(
|
|
324
|
+
`Unsupported image format: ${source.source}`
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
let filename = source.filename;
|
|
328
|
+
if (!filename) {
|
|
329
|
+
if (source.source.startsWith("http")) {
|
|
330
|
+
const url = new URL(source.source);
|
|
331
|
+
const pathname = url.pathname;
|
|
332
|
+
filename = pathname.substring(pathname.lastIndexOf("/") + 1) || `image-${index}`;
|
|
333
|
+
} else {
|
|
334
|
+
filename = source.source.substring(
|
|
335
|
+
source.source.lastIndexOf("/") + 1
|
|
336
|
+
) || `image-${index}`;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
return {
|
|
340
|
+
id: source.id || generateId("img"),
|
|
341
|
+
type: mimeType,
|
|
342
|
+
data: uint8ArrayToBase64(data),
|
|
343
|
+
filename
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* 签名(真实实现)
|
|
348
|
+
*/
|
|
349
|
+
async sign(data, privateKey, algorithm) {
|
|
350
|
+
if (algorithm !== "Ed25519") {
|
|
351
|
+
throw new WipError(`Unsupported signature algorithm: ${algorithm}`);
|
|
352
|
+
}
|
|
353
|
+
const { Ed25519Keypair } = await import("../../keypairs/ed25519/index.js");
|
|
354
|
+
const keypair = Ed25519Keypair.fromSecretKey(privateKey);
|
|
355
|
+
const signature = await keypair.sign(new TextEncoder().encode(data));
|
|
356
|
+
return uint8ArrayToBase64(signature);
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* 验证 WIP 文件
|
|
360
|
+
*/
|
|
361
|
+
async verify(wipFile) {
|
|
362
|
+
try {
|
|
363
|
+
if (!wipFile.wip || !wipFile.payload || !wipFile.meta) {
|
|
364
|
+
return { valid: false, error: "Invalid WIP file structure" };
|
|
365
|
+
}
|
|
366
|
+
if (wipFile.meta.type !== "wip") {
|
|
367
|
+
return {
|
|
368
|
+
valid: false,
|
|
369
|
+
error: `Invalid meta.type: ${wipFile.meta.type}`
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
const canonicalPayload = canonicalizeJson(wipFile.payload);
|
|
373
|
+
const computedHash = computeHash(canonicalPayload);
|
|
374
|
+
if (computedHash !== wipFile.meta.hash) {
|
|
375
|
+
return {
|
|
376
|
+
valid: false,
|
|
377
|
+
error: "Hash mismatch - content has been tampered"
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
const signatures = [];
|
|
381
|
+
if (wipFile.meta.signature) {
|
|
382
|
+
const sigArray = Array.isArray(wipFile.meta.signature) ? wipFile.meta.signature : [wipFile.meta.signature];
|
|
383
|
+
for (const sig of sigArray) {
|
|
384
|
+
const signValid = await this.verifySignature(
|
|
385
|
+
wipFile.meta.hash,
|
|
386
|
+
sig.value,
|
|
387
|
+
sig.publicKey,
|
|
388
|
+
sig.algorithm
|
|
389
|
+
);
|
|
390
|
+
signatures.push({
|
|
391
|
+
address: sig.address,
|
|
392
|
+
valid: signValid
|
|
393
|
+
});
|
|
394
|
+
if (!signValid) {
|
|
395
|
+
return {
|
|
396
|
+
valid: false,
|
|
397
|
+
error: "Invalid signature",
|
|
398
|
+
signatures
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
return { valid: true, signatures };
|
|
404
|
+
} catch (error) {
|
|
405
|
+
return { valid: false, error: `Verification error: ${error}` };
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* 验证签名
|
|
410
|
+
*/
|
|
411
|
+
async verifySignature(data, signature, publicKey, algorithm) {
|
|
412
|
+
if (algorithm !== "Ed25519") {
|
|
413
|
+
throw new WipError(`Unsupported signature algorithm: ${algorithm}`);
|
|
414
|
+
}
|
|
415
|
+
try {
|
|
416
|
+
const { Ed25519PublicKey } = await import("../../keypairs/ed25519/publickey.js");
|
|
417
|
+
let pkToUse = publicKey;
|
|
418
|
+
if (publicKey.startsWith("0x")) {
|
|
419
|
+
const buffer = Buffer.from(publicKey.slice(2), "hex");
|
|
420
|
+
if (buffer.length === 33) {
|
|
421
|
+
pkToUse = buffer.slice(1).toString("base64");
|
|
422
|
+
} else if (buffer.length === 32) {
|
|
423
|
+
pkToUse = buffer.toString("base64");
|
|
424
|
+
}
|
|
425
|
+
} else {
|
|
426
|
+
try {
|
|
427
|
+
const buffer = Buffer.from(publicKey, "base64");
|
|
428
|
+
if (buffer.length === 33) {
|
|
429
|
+
pkToUse = buffer.slice(1).toString("base64");
|
|
430
|
+
}
|
|
431
|
+
} catch {
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
const pubKey = new Ed25519PublicKey(pkToUse);
|
|
435
|
+
const signatureBytes = Uint8Array.from(
|
|
436
|
+
Buffer.from(signature, "base64")
|
|
437
|
+
);
|
|
438
|
+
return await pubKey.verify(
|
|
439
|
+
new TextEncoder().encode(data),
|
|
440
|
+
signatureBytes
|
|
441
|
+
);
|
|
442
|
+
} catch (error) {
|
|
443
|
+
console.error("Signature verification error:", error);
|
|
444
|
+
return false;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* 转换为 HTML
|
|
449
|
+
*/
|
|
450
|
+
async toHtml(wipFile, options = {}) {
|
|
451
|
+
const { title = "WIP Document", theme = "light" } = options;
|
|
452
|
+
const { payload, meta } = wipFile;
|
|
453
|
+
const escapeHtml = (text) => {
|
|
454
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
455
|
+
};
|
|
456
|
+
const formatText = (text, format) => {
|
|
457
|
+
switch (format) {
|
|
458
|
+
case "html":
|
|
459
|
+
return text;
|
|
460
|
+
case "markdown":
|
|
461
|
+
return text.replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>").replace(/\*(.+?)\*/g, "<em>$1</em>").replace(/\n/g, "<br>");
|
|
462
|
+
case "plain":
|
|
463
|
+
default:
|
|
464
|
+
return escapeHtml(text).replace(/\n/g, "<br>");
|
|
465
|
+
}
|
|
466
|
+
};
|
|
467
|
+
const bgColor = theme === "dark" ? "#1a1a1a" : "#ffffff";
|
|
468
|
+
const textColor = theme === "dark" ? "#e0e0e0" : "#333333";
|
|
469
|
+
const borderColor = theme === "dark" ? "#444444" : "#e0e0e0";
|
|
470
|
+
const verifiedColor = "#4caf50";
|
|
471
|
+
const warningColor = "#ff9800";
|
|
472
|
+
const verifyResult = await this.verify(wipFile);
|
|
473
|
+
const statusBadge = verifyResult.valid ? `<span style="background: ${verifiedColor}; color: white; padding: 4px 8px; border-radius: 4px; font-size: 12px;">\u2713 Verified</span>` : `<span style="background: ${warningColor}; color: white; padding: 4px 8px; border-radius: 4px; font-size: 12px;">\u26A0 Tampered</span>`;
|
|
474
|
+
const imagesHtml = payload.media.map(
|
|
475
|
+
(media) => `
|
|
476
|
+
<div style="margin: 16px 0; border: 1px solid ${borderColor}; border-radius: 8px; overflow: hidden;">
|
|
477
|
+
<img src="data:${media.type};base64,${media.data}"
|
|
478
|
+
style="max-width: 100%; height: auto; display: block;"
|
|
479
|
+
alt="${escapeHtml(media.filename || media.id)}" />
|
|
480
|
+
${media.filename ? `<div style="padding: 8px; font-size: 12px; color: #666; background: ${theme === "dark" ? "#2a2a2a" : "#f5f5f5"}; border-top: 1px solid ${borderColor};">${escapeHtml(media.filename)}</div>` : ""}
|
|
481
|
+
</div>
|
|
482
|
+
`
|
|
483
|
+
).join("");
|
|
484
|
+
return `<!DOCTYPE html>
|
|
485
|
+
<html lang="en">
|
|
486
|
+
<head>
|
|
487
|
+
<meta charset="UTF-8">
|
|
488
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
489
|
+
<title>${escapeHtml(title)}</title>
|
|
490
|
+
</head>
|
|
491
|
+
<body style="margin: 0; padding: 20px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: ${bgColor}; color: ${textColor}; line-height: 1.6;">
|
|
492
|
+
<div style="max-width: 800px; margin: 0 auto; background: ${theme === "dark" ? "#252525" : "#ffffff"}; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); overflow: hidden;">
|
|
493
|
+
<div style="padding: 20px 24px; border-bottom: 1px solid ${borderColor};">
|
|
494
|
+
<div style="display: flex; justify-content: space-between; align-items: center;">
|
|
495
|
+
<div>
|
|
496
|
+
<h1 style="margin: 0; font-size: 20px; font-weight: 600;">${escapeHtml(title)}</h1>
|
|
497
|
+
<div style="font-size: 12px; color: #666; margin-top: 4px;">
|
|
498
|
+
WIP v${meta.version} \u2022 ${new Date(meta.created).toLocaleString()}
|
|
499
|
+
</div>
|
|
500
|
+
</div>
|
|
501
|
+
${statusBadge}
|
|
502
|
+
</div>
|
|
503
|
+
<div style="font-size: 11px; color: #999; margin-top: 12px; padding: 8px; background: ${theme === "dark" ? "#2a2a2a" : "#f5f5f5"}; border-radius: 4px; font-style: italic;">
|
|
504
|
+
Important Note: This page is for document browsing and verification reference only. Please verify the document integrity through the API using the WIP file.
|
|
505
|
+
</div>
|
|
506
|
+
${verifyResult.signatures && verifyResult.signatures.length > 0 ? `
|
|
507
|
+
<div style="margin-top: 12px; padding: 8px; background: ${theme === "dark" ? "#2a3f2a" : "#e8f5e9"}; border-radius: 4px;">
|
|
508
|
+
<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>
|
|
509
|
+
${verifyResult.signatures.map(
|
|
510
|
+
(s, idx) => `
|
|
511
|
+
<div style="font-size: 10px; color: ${textColor}; margin-left: 8px;">
|
|
512
|
+
${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>'}
|
|
513
|
+
</div>
|
|
514
|
+
`
|
|
515
|
+
).join("")}
|
|
516
|
+
</div>
|
|
517
|
+
` : ""}
|
|
518
|
+
</div>
|
|
519
|
+
<div style="padding: 24px;">
|
|
520
|
+
<div style="font-size: 16px; line-height: 1.8; margin-bottom: 24px;">
|
|
521
|
+
${formatText(payload.content.text, payload.content.format)}
|
|
522
|
+
</div>
|
|
523
|
+
${imagesHtml}
|
|
524
|
+
</div>
|
|
525
|
+
<div style="padding: 16px 24px; background: ${theme === "dark" ? "#2a2a2a" : "#f8f9fa"}; border-top: 1px solid ${borderColor}; font-size: 11px; color: #666;">
|
|
526
|
+
<div style="display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px;">
|
|
527
|
+
<div>
|
|
528
|
+
<strong>Hash:</strong> <code style="background: ${theme === "dark" ? "#333" : "#e9ecef"}; padding: 2px 6px; border-radius: 3px;">${escapeHtml(meta.hash)}</code>
|
|
529
|
+
</div>
|
|
530
|
+
<div>
|
|
531
|
+
${verifyResult.valid ? "Content integrity verified" : `Verification failed: ${escapeHtml(verifyResult.error || "Unknown error")}`}
|
|
532
|
+
</div>
|
|
533
|
+
</div>
|
|
534
|
+
</div>
|
|
535
|
+
</div>
|
|
536
|
+
</body>
|
|
537
|
+
</html>`;
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* 序列化为 JSON
|
|
541
|
+
*/
|
|
542
|
+
stringify(wipFile, pretty = true) {
|
|
543
|
+
return pretty ? JSON.stringify(wipFile, null, 2) : JSON.stringify(wipFile);
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* 从 JSON 解析
|
|
547
|
+
*/
|
|
548
|
+
parse(jsonString) {
|
|
549
|
+
try {
|
|
550
|
+
const obj = JSON.parse(jsonString);
|
|
551
|
+
if (!obj.wip || !obj.payload || !obj.meta) {
|
|
552
|
+
throw new WipValidationError("Invalid WIP file structure");
|
|
553
|
+
}
|
|
554
|
+
return obj;
|
|
555
|
+
} catch (error) {
|
|
556
|
+
if (error instanceof WipError) {
|
|
557
|
+
throw error;
|
|
558
|
+
}
|
|
559
|
+
throw new WipValidationError(`Failed to parse WIP file: ${error}`);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* 从 URL 或本地路径加载 WIP 文件
|
|
564
|
+
*/
|
|
565
|
+
async load(source) {
|
|
566
|
+
const data = await this.resourceLoader.load(source);
|
|
567
|
+
const content = new TextDecoder().decode(data);
|
|
568
|
+
return this.parse(content);
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* 提取图片
|
|
572
|
+
*/
|
|
573
|
+
extractImages(wipFile, outputDir) {
|
|
574
|
+
if (!fs.existsSync(outputDir)) {
|
|
575
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
576
|
+
}
|
|
577
|
+
const savedPaths = [];
|
|
578
|
+
for (const media of wipFile.payload.media) {
|
|
579
|
+
const ext = getExtensionFromMimeType(media.type);
|
|
580
|
+
const filename = media.filename || `${media.id}.${ext}`;
|
|
581
|
+
const outputPath = path.join(outputDir, filename);
|
|
582
|
+
const buffer = Buffer.from(base64ToUint8Array(media.data));
|
|
583
|
+
fs.writeFileSync(outputPath, buffer);
|
|
584
|
+
savedPaths.push(outputPath);
|
|
585
|
+
}
|
|
586
|
+
return savedPaths;
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* 保存到文件
|
|
590
|
+
*/
|
|
591
|
+
save(wipFile, filePath, pretty = true) {
|
|
592
|
+
const dir = path.dirname(filePath);
|
|
593
|
+
if (!fs.existsSync(dir)) {
|
|
594
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
595
|
+
}
|
|
596
|
+
fs.writeFileSync(filePath, this.stringify(wipFile, pretty), "utf-8");
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* 获取限制配置
|
|
600
|
+
*/
|
|
601
|
+
getLimits() {
|
|
602
|
+
return { ...this.limits };
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* 更新限制配置
|
|
606
|
+
*/
|
|
607
|
+
setLimits(limits) {
|
|
608
|
+
this.limits = { ...this.limits, ...limits };
|
|
609
|
+
this.resourceLoader = new ResourceLoader(this.limits.maxImageSize);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
async function createWip(options, limits) {
|
|
613
|
+
const wip = new WIP(limits);
|
|
614
|
+
return wip.create(options);
|
|
615
|
+
}
|
|
616
|
+
async function verifyWip(wipFile, hash_equal) {
|
|
617
|
+
if (hash_equal !== void 0 && wipFile.meta.hash.toLowerCase() !== hash_equal.toLowerCase()) {
|
|
618
|
+
return { valid: false, error: "Hash mismatch" };
|
|
619
|
+
}
|
|
620
|
+
const wip = new WIP();
|
|
621
|
+
return wip.verify(wipFile);
|
|
622
|
+
}
|
|
623
|
+
async function wipToHtml(wipFile, options) {
|
|
624
|
+
const wip = new WIP();
|
|
625
|
+
return wip.toHtml(wipFile, options);
|
|
626
|
+
}
|
|
627
|
+
async function loadWip(source, limits) {
|
|
628
|
+
const wip = new WIP(limits);
|
|
629
|
+
return wip.load(source);
|
|
630
|
+
}
|
|
631
|
+
async function generate_wip(options, outputPath) {
|
|
632
|
+
const wip = new WIP(DEFAULT_LIMITS);
|
|
633
|
+
let wipFile = await wip.create({
|
|
634
|
+
text: options.markdown_text,
|
|
635
|
+
textFormat: "markdown",
|
|
636
|
+
images: options.images
|
|
637
|
+
});
|
|
638
|
+
if (options.account) {
|
|
639
|
+
const { Account } = await import("./account.js");
|
|
640
|
+
const address = await Account.Instance().get_address(options.account);
|
|
641
|
+
if (!address) {
|
|
642
|
+
throw new WipValidationError(
|
|
643
|
+
`Account not found: ${options.account}`
|
|
644
|
+
);
|
|
645
|
+
}
|
|
646
|
+
const signature = await Account.Instance().sign(
|
|
647
|
+
address,
|
|
648
|
+
wipFile.meta.hash
|
|
649
|
+
);
|
|
650
|
+
const accountData = await Account.Instance().get(address);
|
|
651
|
+
if (!accountData || !accountData.pubkey) {
|
|
652
|
+
throw new WipValidationError(
|
|
653
|
+
`Cannot get public key for account: ${address}`
|
|
654
|
+
);
|
|
655
|
+
}
|
|
656
|
+
let publicKeyBase64;
|
|
657
|
+
if (accountData.pubkey.startsWith("0x")) {
|
|
658
|
+
const buffer = Buffer.from(accountData.pubkey.slice(2), "hex");
|
|
659
|
+
if (buffer.length === 33) {
|
|
660
|
+
publicKeyBase64 = buffer.slice(1).toString("base64");
|
|
661
|
+
} else if (buffer.length === 32) {
|
|
662
|
+
publicKeyBase64 = buffer.toString("base64");
|
|
663
|
+
} else {
|
|
664
|
+
throw new WipValidationError(
|
|
665
|
+
`Invalid public key length: ${buffer.length}, expected 32 or 33 bytes`
|
|
666
|
+
);
|
|
667
|
+
}
|
|
668
|
+
} else {
|
|
669
|
+
publicKeyBase64 = accountData.pubkey;
|
|
670
|
+
}
|
|
671
|
+
const signatureBase64 = Buffer.from(signature.slice(2), "hex").toString(
|
|
672
|
+
"base64"
|
|
673
|
+
);
|
|
674
|
+
const newSignature = {
|
|
675
|
+
value: signatureBase64,
|
|
676
|
+
publicKey: publicKeyBase64,
|
|
677
|
+
algorithm: "Ed25519",
|
|
678
|
+
address
|
|
679
|
+
};
|
|
680
|
+
let signatures;
|
|
681
|
+
if (wipFile.meta.signature) {
|
|
682
|
+
signatures = Array.isArray(wipFile.meta.signature) ? [...wipFile.meta.signature, newSignature] : [wipFile.meta.signature, newSignature];
|
|
683
|
+
} else {
|
|
684
|
+
signatures = [newSignature];
|
|
685
|
+
}
|
|
686
|
+
wipFile = {
|
|
687
|
+
...wipFile,
|
|
688
|
+
meta: {
|
|
689
|
+
...wipFile.meta,
|
|
690
|
+
signature: signatures
|
|
691
|
+
}
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
wip.save(wipFile, outputPath, true);
|
|
695
|
+
return outputPath;
|
|
696
|
+
}
|
|
697
|
+
async function verify_wip(wipFilePath, hash_equal) {
|
|
698
|
+
const wip = new WIP();
|
|
699
|
+
let wipFile;
|
|
700
|
+
try {
|
|
701
|
+
wipFile = await wip.load(wipFilePath);
|
|
702
|
+
} catch (error) {
|
|
703
|
+
return {
|
|
704
|
+
valid: false,
|
|
705
|
+
error: `Failed to load WIP file: ${error}`,
|
|
706
|
+
hashValid: false,
|
|
707
|
+
hasSignature: false
|
|
708
|
+
};
|
|
709
|
+
}
|
|
710
|
+
if (!wipFile.wip || !wipFile.payload || !wipFile.meta) {
|
|
711
|
+
return {
|
|
712
|
+
valid: false,
|
|
713
|
+
error: "Invalid WIP file structure",
|
|
714
|
+
hashValid: false,
|
|
715
|
+
hasSignature: false
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
if (wipFile.meta.type !== "wip") {
|
|
719
|
+
return {
|
|
720
|
+
valid: false,
|
|
721
|
+
error: `Invalid meta.type: ${wipFile.meta.type}`,
|
|
722
|
+
hashValid: false,
|
|
723
|
+
hasSignature: !!wipFile.meta.signature
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
if (hash_equal !== void 0 && wipFile.meta.hash.toLowerCase() !== hash_equal.toLowerCase()) {
|
|
727
|
+
return {
|
|
728
|
+
valid: false,
|
|
729
|
+
error: "Hash mismatch",
|
|
730
|
+
hashValid: false,
|
|
731
|
+
hasSignature: !!wipFile.meta.signature
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
const canonicalPayload = canonicalizeJson(wipFile.payload);
|
|
735
|
+
const computedHash = computeHash(canonicalPayload);
|
|
736
|
+
const hashValid = computedHash === wipFile.meta.hash;
|
|
737
|
+
if (!hashValid) {
|
|
738
|
+
return {
|
|
739
|
+
valid: false,
|
|
740
|
+
error: "Hash mismatch - content has been tampered",
|
|
741
|
+
hashValid: false,
|
|
742
|
+
hasSignature: !!wipFile.meta.signature
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
let signatureValid;
|
|
746
|
+
const signatures = [];
|
|
747
|
+
if (wipFile.meta.signature) {
|
|
748
|
+
const sigArray = Array.isArray(wipFile.meta.signature) ? wipFile.meta.signature : [wipFile.meta.signature];
|
|
749
|
+
let allValid = true;
|
|
750
|
+
for (const sig of sigArray) {
|
|
751
|
+
const isValid = await wip["verifySignature"](
|
|
752
|
+
wipFile.meta.hash,
|
|
753
|
+
sig.value,
|
|
754
|
+
sig.publicKey,
|
|
755
|
+
sig.algorithm
|
|
756
|
+
);
|
|
757
|
+
let address;
|
|
758
|
+
try {
|
|
759
|
+
const { Ed25519PublicKey } = await import("../../keypairs/ed25519/publickey.js");
|
|
760
|
+
const pubKey = new Ed25519PublicKey(sig.publicKey);
|
|
761
|
+
address = pubKey.toWAddress();
|
|
762
|
+
} catch {
|
|
763
|
+
}
|
|
764
|
+
signatures.push({
|
|
765
|
+
publicKey: sig.publicKey,
|
|
766
|
+
address,
|
|
767
|
+
valid: isValid
|
|
768
|
+
});
|
|
769
|
+
if (!isValid) {
|
|
770
|
+
allValid = false;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
signatureValid = allValid;
|
|
774
|
+
if (!signatureValid) {
|
|
775
|
+
const failedAddresses = signatures.filter((s) => !s.valid && s.address).map((s) => s.address);
|
|
776
|
+
return {
|
|
777
|
+
valid: false,
|
|
778
|
+
error: `Signatures from the following addresses are invalid: ${failedAddresses.join(", ")}`,
|
|
779
|
+
hashValid: true,
|
|
780
|
+
signatureValid: false,
|
|
781
|
+
hasSignature: true,
|
|
782
|
+
signatures
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
return {
|
|
787
|
+
valid: true,
|
|
788
|
+
hashValid: true,
|
|
789
|
+
signatureValid,
|
|
790
|
+
hasSignature: !!wipFile.meta.signature,
|
|
791
|
+
signatures: signatures.length > 0 ? signatures : void 0
|
|
792
|
+
};
|
|
793
|
+
}
|
|
794
|
+
async function sign_wip(wipFilePath, account, outputPath) {
|
|
795
|
+
const wip = new WIP();
|
|
796
|
+
const wipFile = await wip.load(wipFilePath);
|
|
797
|
+
if (!wipFile.wip || !wipFile.payload || !wipFile.meta) {
|
|
798
|
+
throw new WipValidationError("Invalid WIP file structure");
|
|
799
|
+
}
|
|
800
|
+
if (wipFile.meta.type !== "wip") {
|
|
801
|
+
throw new WipValidationError(`Invalid meta.type: ${wipFile.meta.type}`);
|
|
802
|
+
}
|
|
803
|
+
const { Account } = await import("./account.js");
|
|
804
|
+
const address = await Account.Instance().get_address(account);
|
|
805
|
+
if (!address) {
|
|
806
|
+
throw new WipValidationError(`Account not found: ${account}`);
|
|
807
|
+
}
|
|
808
|
+
const signResult = await Account.Instance().signData(
|
|
809
|
+
address,
|
|
810
|
+
wipFile.meta.hash
|
|
811
|
+
);
|
|
812
|
+
let publicKeyBase64;
|
|
813
|
+
const pk = signResult.publicKey;
|
|
814
|
+
if (pk.startsWith("0x")) {
|
|
815
|
+
const buffer = Buffer.from(pk.slice(2), "hex");
|
|
816
|
+
if (buffer.length === 33) {
|
|
817
|
+
publicKeyBase64 = buffer.slice(1).toString("base64");
|
|
818
|
+
} else if (buffer.length === 32) {
|
|
819
|
+
publicKeyBase64 = buffer.toString("base64");
|
|
820
|
+
} else {
|
|
821
|
+
throw new WipValidationError(
|
|
822
|
+
`Invalid public key length: ${buffer.length}, expected 32 or 33 bytes`
|
|
823
|
+
);
|
|
824
|
+
}
|
|
825
|
+
} else {
|
|
826
|
+
publicKeyBase64 = pk;
|
|
827
|
+
}
|
|
828
|
+
const newSignature = {
|
|
829
|
+
value: Buffer.from(signResult.signature.slice(2), "hex").toString(
|
|
830
|
+
"base64"
|
|
831
|
+
),
|
|
832
|
+
publicKey: publicKeyBase64,
|
|
833
|
+
algorithm: "Ed25519",
|
|
834
|
+
address: signResult.address
|
|
835
|
+
};
|
|
836
|
+
let signatures;
|
|
837
|
+
if (wipFile.meta.signature) {
|
|
838
|
+
const existingSigs = Array.isArray(wipFile.meta.signature) ? [...wipFile.meta.signature] : [wipFile.meta.signature];
|
|
839
|
+
const existingIndex = existingSigs.findIndex(
|
|
840
|
+
(sig) => sig.publicKey === publicKeyBase64
|
|
841
|
+
);
|
|
842
|
+
if (existingIndex >= 0) {
|
|
843
|
+
existingSigs[existingIndex] = newSignature;
|
|
844
|
+
signatures = existingSigs;
|
|
845
|
+
} else {
|
|
846
|
+
signatures = [...existingSigs, newSignature];
|
|
847
|
+
}
|
|
848
|
+
} else {
|
|
849
|
+
signatures = [newSignature];
|
|
850
|
+
}
|
|
851
|
+
const signedWipFile = {
|
|
852
|
+
...wipFile,
|
|
853
|
+
meta: {
|
|
854
|
+
...wipFile.meta,
|
|
855
|
+
signature: signatures
|
|
856
|
+
}
|
|
857
|
+
};
|
|
858
|
+
let savePath;
|
|
859
|
+
if (outputPath) {
|
|
860
|
+
savePath = outputPath;
|
|
861
|
+
} else {
|
|
862
|
+
const dir = path.dirname(wipFilePath);
|
|
863
|
+
const ext = path.extname(wipFilePath);
|
|
864
|
+
const baseName = path.basename(wipFilePath, ext);
|
|
865
|
+
savePath = path.join(dir, `signed_${baseName}${ext}`);
|
|
866
|
+
}
|
|
867
|
+
wip.save(signedWipFile, savePath, true);
|
|
868
|
+
return savePath;
|
|
869
|
+
}
|
|
870
|
+
async function wip2html(wipPath, options = {}) {
|
|
871
|
+
const fs2 = await import("fs");
|
|
872
|
+
const path2 = await import("path");
|
|
873
|
+
const stats = fs2.statSync(wipPath);
|
|
874
|
+
if (stats.isFile()) {
|
|
875
|
+
const wip = new WIP();
|
|
876
|
+
const wipFile = await wip.load(wipPath);
|
|
877
|
+
const html = await wip.toHtml(wipFile, options);
|
|
878
|
+
if (options.outputPath) {
|
|
879
|
+
fs2.writeFileSync(options.outputPath, html);
|
|
880
|
+
return options.outputPath;
|
|
881
|
+
}
|
|
882
|
+
return html;
|
|
883
|
+
} else if (stats.isDirectory()) {
|
|
884
|
+
const files = fs2.readdirSync(wipPath);
|
|
885
|
+
const wipFiles = files.filter((f) => f.endsWith(".wip"));
|
|
886
|
+
if (wipFiles.length === 0) {
|
|
887
|
+
throw new WipValidationError(
|
|
888
|
+
`No .wip files found in directory: ${wipPath}`
|
|
889
|
+
);
|
|
890
|
+
}
|
|
891
|
+
const results = [];
|
|
892
|
+
const wip = new WIP();
|
|
893
|
+
for (const file of wipFiles) {
|
|
894
|
+
const filePath = path2.join(wipPath, file);
|
|
895
|
+
const wipFile = await wip.load(filePath);
|
|
896
|
+
const html = await wip.toHtml(wipFile, options);
|
|
897
|
+
const outputFileName = file.replace(".wip", ".html");
|
|
898
|
+
const outputFilePath = options.outputPath ? path2.join(options.outputPath, outputFileName) : path2.join(wipPath, outputFileName);
|
|
899
|
+
const outputDir = path2.dirname(outputFilePath);
|
|
900
|
+
if (!fs2.existsSync(outputDir)) {
|
|
901
|
+
fs2.mkdirSync(outputDir, { recursive: true });
|
|
902
|
+
}
|
|
903
|
+
fs2.writeFileSync(outputFilePath, html);
|
|
904
|
+
results.push(outputFilePath);
|
|
905
|
+
}
|
|
906
|
+
return results;
|
|
907
|
+
} else {
|
|
908
|
+
throw new WipValidationError(`Invalid path: ${wipPath}`);
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
var wip_default = WIP;
|