@unconfirmed/effect-sui 0.0.0-stage → 0.1.0
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/LICENSE +202 -0
- package/README.md +10 -2
- package/dist/Address.d.ts +18 -0
- package/dist/Address.d.ts.map +1 -0
- package/dist/Address.js +33 -0
- package/dist/Address.js.map +1 -0
- package/dist/AddressAlias.d.ts +107 -0
- package/dist/AddressAlias.d.ts.map +1 -0
- package/dist/AddressAlias.js +104 -0
- package/dist/AddressAlias.js.map +1 -0
- package/dist/Bip32.d.ts +6 -0
- package/dist/Bip32.d.ts.map +1 -0
- package/dist/Bip32.js +34 -0
- package/dist/Bip32.js.map +1 -0
- package/dist/Chain.d.ts +23 -0
- package/dist/Chain.d.ts.map +1 -0
- package/dist/Chain.js +7 -0
- package/dist/Chain.js.map +1 -0
- package/dist/CheckpointData.d.ts +74 -0
- package/dist/CheckpointData.d.ts.map +1 -0
- package/dist/CheckpointData.js +48 -0
- package/dist/CheckpointData.js.map +1 -0
- package/dist/Checkpoints.d.ts +23 -0
- package/dist/Checkpoints.d.ts.map +1 -0
- package/dist/Checkpoints.js +7 -0
- package/dist/Checkpoints.js.map +1 -0
- package/dist/CoinReservation.d.ts +18 -0
- package/dist/CoinReservation.d.ts.map +1 -0
- package/dist/CoinReservation.js +58 -0
- package/dist/CoinReservation.js.map +1 -0
- package/dist/Coins.d.ts +42 -0
- package/dist/Coins.d.ts.map +1 -0
- package/dist/Coins.js +49 -0
- package/dist/Coins.js.map +1 -0
- package/dist/DynamicFields.d.ts +115 -0
- package/dist/DynamicFields.d.ts.map +1 -0
- package/dist/DynamicFields.js +101 -0
- package/dist/DynamicFields.js.map +1 -0
- package/dist/Ecdsa.d.ts +39 -0
- package/dist/Ecdsa.d.ts.map +1 -0
- package/dist/Ecdsa.js +76 -0
- package/dist/Ecdsa.js.map +1 -0
- package/dist/Ed25519.d.ts +22 -0
- package/dist/Ed25519.d.ts.map +1 -0
- package/dist/Ed25519.js +77 -0
- package/dist/Ed25519.js.map +1 -0
- package/dist/Events.d.ts +105 -0
- package/dist/Events.d.ts.map +1 -0
- package/dist/Events.js +51 -0
- package/dist/Events.js.map +1 -0
- package/dist/Hash.d.ts +16 -0
- package/dist/Hash.d.ts.map +1 -0
- package/dist/Hash.js +32 -0
- package/dist/Hash.js.map +1 -0
- package/dist/MlDsa65.d.ts +17 -0
- package/dist/MlDsa65.d.ts.map +1 -0
- package/dist/MlDsa65.js +84 -0
- package/dist/MlDsa65.js.map +1 -0
- package/dist/Mnemonic.d.ts +20 -0
- package/dist/Mnemonic.d.ts.map +1 -0
- package/dist/Mnemonic.js +71 -0
- package/dist/Mnemonic.js.map +1 -0
- package/dist/Move.d.ts +261 -0
- package/dist/Move.d.ts.map +1 -0
- package/dist/Move.js +232 -0
- package/dist/Move.js.map +1 -0
- package/dist/MultiSig.d.ts +106 -0
- package/dist/MultiSig.d.ts.map +1 -0
- package/dist/MultiSig.js +254 -0
- package/dist/MultiSig.js.map +1 -0
- package/dist/Objects.d.ts +95 -0
- package/dist/Objects.d.ts.map +1 -0
- package/dist/Objects.js +57 -0
- package/dist/Objects.js.map +1 -0
- package/dist/Packages.d.ts +49 -0
- package/dist/Packages.d.ts.map +1 -0
- package/dist/Packages.js +16 -0
- package/dist/Packages.js.map +1 -0
- package/dist/Passkey.d.ts +11 -0
- package/dist/Passkey.d.ts.map +1 -0
- package/dist/Passkey.js +11 -0
- package/dist/Passkey.js.map +1 -0
- package/dist/PrivateKey.d.ts +39 -0
- package/dist/PrivateKey.d.ts.map +1 -0
- package/dist/PrivateKey.js +118 -0
- package/dist/PrivateKey.js.map +1 -0
- package/dist/Ptb.d.ts +413 -0
- package/dist/Ptb.d.ts.map +1 -0
- package/dist/Ptb.js +338 -0
- package/dist/Ptb.js.map +1 -0
- package/dist/Resolve.d.ts +502 -0
- package/dist/Resolve.d.ts.map +1 -0
- package/dist/Resolve.js +1188 -0
- package/dist/Resolve.js.map +1 -0
- package/dist/RpcError.d.ts +19 -0
- package/dist/RpcError.d.ts.map +1 -0
- package/dist/RpcError.js +37 -0
- package/dist/RpcError.js.map +1 -0
- package/dist/Secp256k1.d.ts +11 -0
- package/dist/Secp256k1.d.ts.map +1 -0
- package/dist/Secp256k1.js +23 -0
- package/dist/Secp256k1.js.map +1 -0
- package/dist/Secp256r1.d.ts +11 -0
- package/dist/Secp256r1.d.ts.map +1 -0
- package/dist/Secp256r1.js +23 -0
- package/dist/Secp256r1.js.map +1 -0
- package/dist/SignatureScheme.d.ts +103 -0
- package/dist/SignatureScheme.d.ts.map +1 -0
- package/dist/SignatureScheme.js +93 -0
- package/dist/SignatureScheme.js.map +1 -0
- package/dist/Signer.d.ts +54 -0
- package/dist/Signer.d.ts.map +1 -0
- package/dist/Signer.js +31 -0
- package/dist/Signer.js.map +1 -0
- package/dist/Testing.d.ts +171 -0
- package/dist/Testing.d.ts.map +1 -0
- package/dist/Testing.js +531 -0
- package/dist/Testing.js.map +1 -0
- package/dist/TransactionData.d.ts +3218 -0
- package/dist/TransactionData.d.ts.map +1 -0
- package/dist/TransactionData.js +105 -0
- package/dist/TransactionData.js.map +1 -0
- package/dist/TransactionJson.d.ts +1544 -0
- package/dist/TransactionJson.d.ts.map +1 -0
- package/dist/TransactionJson.js +926 -0
- package/dist/TransactionJson.js.map +1 -0
- package/dist/Transactions.d.ts +181 -0
- package/dist/Transactions.d.ts.map +1 -0
- package/dist/Transactions.js +49 -0
- package/dist/Transactions.js.map +1 -0
- package/dist/Tx.d.ts +1419 -0
- package/dist/Tx.d.ts.map +1 -0
- package/dist/Tx.js +266 -0
- package/dist/Tx.js.map +1 -0
- package/dist/TypeTag.d.ts +42 -0
- package/dist/TypeTag.d.ts.map +1 -0
- package/dist/TypeTag.js +110 -0
- package/dist/TypeTag.js.map +1 -0
- package/dist/Verify.d.ts +23 -0
- package/dist/Verify.d.ts.map +1 -0
- package/dist/Verify.js +29 -0
- package/dist/Verify.js.map +1 -0
- package/dist/enoki/EnokiClient.d.ts +184 -0
- package/dist/enoki/EnokiClient.d.ts.map +1 -0
- package/dist/enoki/EnokiClient.js +105 -0
- package/dist/enoki/EnokiClient.js.map +1 -0
- package/dist/enoki/EnokiHttp.d.ts +33 -0
- package/dist/enoki/EnokiHttp.d.ts.map +1 -0
- package/dist/enoki/EnokiHttp.js +160 -0
- package/dist/enoki/EnokiHttp.js.map +1 -0
- package/dist/enoki/Sponsor.d.ts +119 -0
- package/dist/enoki/Sponsor.d.ts.map +1 -0
- package/dist/enoki/Sponsor.js +170 -0
- package/dist/enoki/Sponsor.js.map +1 -0
- package/dist/enoki/ZkLoginFlow.d.ts +84 -0
- package/dist/enoki/ZkLoginFlow.d.ts.map +1 -0
- package/dist/enoki/ZkLoginFlow.js +138 -0
- package/dist/enoki/ZkLoginFlow.js.map +1 -0
- package/dist/enoki/index.d.ts +9 -0
- package/dist/enoki/index.d.ts.map +1 -0
- package/dist/enoki/index.js +9 -0
- package/dist/enoki/index.js.map +1 -0
- package/dist/graphql/ChainGraphQL.d.ts +35 -0
- package/dist/graphql/ChainGraphQL.d.ts.map +1 -0
- package/dist/graphql/ChainGraphQL.js +62 -0
- package/dist/graphql/ChainGraphQL.js.map +1 -0
- package/dist/graphql/CheckpointDataGraphQL.d.ts +785 -0
- package/dist/graphql/CheckpointDataGraphQL.d.ts.map +1 -0
- package/dist/graphql/CheckpointDataGraphQL.js +157 -0
- package/dist/graphql/CheckpointDataGraphQL.js.map +1 -0
- package/dist/graphql/CheckpointsGraphQL.d.ts +91 -0
- package/dist/graphql/CheckpointsGraphQL.d.ts.map +1 -0
- package/dist/graphql/CheckpointsGraphQL.js +80 -0
- package/dist/graphql/CheckpointsGraphQL.js.map +1 -0
- package/dist/graphql/CoinsGraphQL.d.ts +81 -0
- package/dist/graphql/CoinsGraphQL.d.ts.map +1 -0
- package/dist/graphql/CoinsGraphQL.js +63 -0
- package/dist/graphql/CoinsGraphQL.js.map +1 -0
- package/dist/graphql/DynamicFieldsGraphQL.d.ts +94 -0
- package/dist/graphql/DynamicFieldsGraphQL.d.ts.map +1 -0
- package/dist/graphql/DynamicFieldsGraphQL.js +126 -0
- package/dist/graphql/DynamicFieldsGraphQL.js.map +1 -0
- package/dist/graphql/EventsGraphQL.d.ts +266 -0
- package/dist/graphql/EventsGraphQL.d.ts.map +1 -0
- package/dist/graphql/EventsGraphQL.js +249 -0
- package/dist/graphql/EventsGraphQL.js.map +1 -0
- package/dist/graphql/ObjectsGraphQL.d.ts +130 -0
- package/dist/graphql/ObjectsGraphQL.d.ts.map +1 -0
- package/dist/graphql/ObjectsGraphQL.js +79 -0
- package/dist/graphql/ObjectsGraphQL.js.map +1 -0
- package/dist/graphql/PackagesGraphQL.d.ts +82 -0
- package/dist/graphql/PackagesGraphQL.d.ts.map +1 -0
- package/dist/graphql/PackagesGraphQL.js +145 -0
- package/dist/graphql/PackagesGraphQL.js.map +1 -0
- package/dist/graphql/SuiGraphQL.d.ts +37 -0
- package/dist/graphql/SuiGraphQL.d.ts.map +1 -0
- package/dist/graphql/SuiGraphQL.js +47 -0
- package/dist/graphql/SuiGraphQL.js.map +1 -0
- package/dist/graphql/TransactionsGraphQL.d.ts +1309 -0
- package/dist/graphql/TransactionsGraphQL.d.ts.map +1 -0
- package/dist/graphql/TransactionsGraphQL.js +206 -0
- package/dist/graphql/TransactionsGraphQL.js.map +1 -0
- package/dist/graphql/convert.d.ts +505 -0
- package/dist/graphql/convert.d.ts.map +1 -0
- package/dist/graphql/convert.js +384 -0
- package/dist/graphql/convert.js.map +1 -0
- package/dist/graphql/index.d.ts +41 -0
- package/dist/graphql/index.d.ts.map +1 -0
- package/dist/graphql/index.js +20 -0
- package/dist/graphql/index.js.map +1 -0
- package/dist/graphql/merge.d.ts +8 -0
- package/dist/graphql/merge.d.ts.map +1 -0
- package/dist/graphql/merge.js +55 -0
- package/dist/graphql/merge.js.map +1 -0
- package/dist/graphql/paging.d.ts +219 -0
- package/dist/graphql/paging.d.ts.map +1 -0
- package/dist/graphql/paging.js +74 -0
- package/dist/graphql/paging.js.map +1 -0
- package/dist/graphql/subscription.d.ts +27 -0
- package/dist/graphql/subscription.d.ts.map +1 -0
- package/dist/graphql/subscription.js +47 -0
- package/dist/graphql/subscription.js.map +1 -0
- package/dist/graphql/tip.d.ts +31 -0
- package/dist/graphql/tip.d.ts.map +1 -0
- package/dist/graphql/tip.js +29 -0
- package/dist/graphql/tip.js.map +1 -0
- package/dist/grpc/ChainGrpc.d.ts +11 -0
- package/dist/grpc/ChainGrpc.d.ts.map +1 -0
- package/dist/grpc/ChainGrpc.js +40 -0
- package/dist/grpc/ChainGrpc.js.map +1 -0
- package/dist/grpc/CheckpointDataGrpc.d.ts +6 -0
- package/dist/grpc/CheckpointDataGrpc.d.ts.map +1 -0
- package/dist/grpc/CheckpointDataGrpc.js +27 -0
- package/dist/grpc/CheckpointDataGrpc.js.map +1 -0
- package/dist/grpc/CheckpointsGrpc.d.ts +6 -0
- package/dist/grpc/CheckpointsGrpc.d.ts.map +1 -0
- package/dist/grpc/CheckpointsGrpc.js +25 -0
- package/dist/grpc/CheckpointsGrpc.js.map +1 -0
- package/dist/grpc/CoinsGrpc.d.ts +7 -0
- package/dist/grpc/CoinsGrpc.d.ts.map +1 -0
- package/dist/grpc/CoinsGrpc.js +34 -0
- package/dist/grpc/CoinsGrpc.js.map +1 -0
- package/dist/grpc/DynamicFieldsGrpc.d.ts +11 -0
- package/dist/grpc/DynamicFieldsGrpc.d.ts.map +1 -0
- package/dist/grpc/DynamicFieldsGrpc.js +91 -0
- package/dist/grpc/DynamicFieldsGrpc.js.map +1 -0
- package/dist/grpc/EventsGrpc.d.ts +13 -0
- package/dist/grpc/EventsGrpc.d.ts.map +1 -0
- package/dist/grpc/EventsGrpc.js +88 -0
- package/dist/grpc/EventsGrpc.js.map +1 -0
- package/dist/grpc/GrpcWeb.d.ts +71 -0
- package/dist/grpc/GrpcWeb.d.ts.map +1 -0
- package/dist/grpc/GrpcWeb.js +243 -0
- package/dist/grpc/GrpcWeb.js.map +1 -0
- package/dist/grpc/ObjectsGrpc.d.ts +10 -0
- package/dist/grpc/ObjectsGrpc.d.ts.map +1 -0
- package/dist/grpc/ObjectsGrpc.js +72 -0
- package/dist/grpc/ObjectsGrpc.js.map +1 -0
- package/dist/grpc/PackagesGrpc.d.ts +9 -0
- package/dist/grpc/PackagesGrpc.d.ts.map +1 -0
- package/dist/grpc/PackagesGrpc.js +78 -0
- package/dist/grpc/PackagesGrpc.js.map +1 -0
- package/dist/grpc/Rpc.d.ts +46 -0
- package/dist/grpc/Rpc.d.ts.map +1 -0
- package/dist/grpc/Rpc.js +111 -0
- package/dist/grpc/Rpc.js.map +1 -0
- package/dist/grpc/TransactionsGrpc.d.ts +6 -0
- package/dist/grpc/TransactionsGrpc.d.ts.map +1 -0
- package/dist/grpc/TransactionsGrpc.js +56 -0
- package/dist/grpc/TransactionsGrpc.js.map +1 -0
- package/dist/grpc/cache.d.ts +7 -0
- package/dist/grpc/cache.d.ts.map +1 -0
- package/dist/grpc/cache.js +55 -0
- package/dist/grpc/cache.js.map +1 -0
- package/dist/grpc/convert.d.ts +43 -0
- package/dist/grpc/convert.d.ts.map +1 -0
- package/dist/grpc/convert.js +198 -0
- package/dist/grpc/convert.js.map +1 -0
- package/dist/grpc/generated/lean.d.ts +36 -0
- package/dist/grpc/generated/lean.d.ts.map +1 -0
- package/dist/grpc/generated/lean.js +205 -0
- package/dist/grpc/generated/lean.js.map +1 -0
- package/dist/grpc/generated/proto.d.ts +2000 -0
- package/dist/grpc/generated/proto.d.ts.map +1 -0
- package/dist/grpc/generated/proto.js +356 -0
- package/dist/grpc/generated/proto.js.map +1 -0
- package/dist/grpc/generated/rpc.d.ts +62 -0
- package/dist/grpc/generated/rpc.d.ts.map +1 -0
- package/dist/grpc/generated/rpc.js +324 -0
- package/dist/grpc/generated/rpc.js.map +1 -0
- package/dist/grpc/index.d.ts +58 -0
- package/dist/grpc/index.d.ts.map +1 -0
- package/dist/grpc/index.js +43 -0
- package/dist/grpc/index.js.map +1 -0
- package/dist/grpc/scan.d.ts +79 -0
- package/dist/grpc/scan.d.ts.map +1 -0
- package/dist/grpc/scan.js +126 -0
- package/dist/grpc/scan.js.map +1 -0
- package/dist/grpc/transaction.d.ts +9 -0
- package/dist/grpc/transaction.d.ts.map +1 -0
- package/dist/grpc/transaction.js +168 -0
- package/dist/grpc/transaction.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/allowances.d.ts +18 -0
- package/dist/internal/allowances.d.ts.map +1 -0
- package/dist/internal/allowances.js +194 -0
- package/dist/internal/allowances.js.map +1 -0
- package/dist/internal/mnemonic.d.ts +53 -0
- package/dist/internal/mnemonic.d.ts.map +1 -0
- package/dist/internal/mnemonic.js +66 -0
- package/dist/internal/mnemonic.js.map +1 -0
- package/dist/internal/passkey/BrowserProvider.d.ts +10 -0
- package/dist/internal/passkey/BrowserProvider.d.ts.map +1 -0
- package/dist/internal/passkey/BrowserProvider.js +101 -0
- package/dist/internal/passkey/BrowserProvider.js.map +1 -0
- package/dist/internal/passkey/Passkey.d.ts +104 -0
- package/dist/internal/passkey/Passkey.d.ts.map +1 -0
- package/dist/internal/passkey/Passkey.js +333 -0
- package/dist/internal/passkey/Passkey.js.map +1 -0
- package/dist/internal/passkey/SoftwareProvider.d.ts +23 -0
- package/dist/internal/passkey/SoftwareProvider.d.ts.map +1 -0
- package/dist/internal/passkey/SoftwareProvider.js +61 -0
- package/dist/internal/passkey/SoftwareProvider.js.map +1 -0
- package/dist/lifecycle/Evidence.d.ts +62 -0
- package/dist/lifecycle/Evidence.d.ts.map +1 -0
- package/dist/lifecycle/Evidence.js +30 -0
- package/dist/lifecycle/Evidence.js.map +1 -0
- package/dist/lifecycle/EvidenceGraphQL.d.ts +59 -0
- package/dist/lifecycle/EvidenceGraphQL.d.ts.map +1 -0
- package/dist/lifecycle/EvidenceGraphQL.js +53 -0
- package/dist/lifecycle/EvidenceGraphQL.js.map +1 -0
- package/dist/lifecycle/EvidenceGrpc.d.ts +4 -0
- package/dist/lifecycle/EvidenceGrpc.d.ts.map +1 -0
- package/dist/lifecycle/EvidenceGrpc.js +37 -0
- package/dist/lifecycle/EvidenceGrpc.js.map +1 -0
- package/dist/lifecycle/Journal.d.ts +69 -0
- package/dist/lifecycle/Journal.d.ts.map +1 -0
- package/dist/lifecycle/Journal.js +70 -0
- package/dist/lifecycle/Journal.js.map +1 -0
- package/dist/lifecycle/JournalEntry.d.ts +67 -0
- package/dist/lifecycle/JournalEntry.d.ts.map +1 -0
- package/dist/lifecycle/JournalEntry.js +45 -0
- package/dist/lifecycle/JournalEntry.js.map +1 -0
- package/dist/lifecycle/JournalKeyValueStore.d.ts +30 -0
- package/dist/lifecycle/JournalKeyValueStore.d.ts.map +1 -0
- package/dist/lifecycle/JournalKeyValueStore.js +217 -0
- package/dist/lifecycle/JournalKeyValueStore.js.map +1 -0
- package/dist/lifecycle/KeyValueStoreIndexedDb.d.ts +54 -0
- package/dist/lifecycle/KeyValueStoreIndexedDb.d.ts.map +1 -0
- package/dist/lifecycle/KeyValueStoreIndexedDb.js +321 -0
- package/dist/lifecycle/KeyValueStoreIndexedDb.js.map +1 -0
- package/dist/lifecycle/KeyValueStoreOpfs.d.ts +65 -0
- package/dist/lifecycle/KeyValueStoreOpfs.d.ts.map +1 -0
- package/dist/lifecycle/KeyValueStoreOpfs.js +207 -0
- package/dist/lifecycle/KeyValueStoreOpfs.js.map +1 -0
- package/dist/lifecycle/Lifecycle.d.ts +416 -0
- package/dist/lifecycle/Lifecycle.d.ts.map +1 -0
- package/dist/lifecycle/Lifecycle.js +666 -0
- package/dist/lifecycle/Lifecycle.js.map +1 -0
- package/dist/lifecycle/Outcome.d.ts +132 -0
- package/dist/lifecycle/Outcome.d.ts.map +1 -0
- package/dist/lifecycle/Outcome.js +106 -0
- package/dist/lifecycle/Outcome.js.map +1 -0
- package/dist/lifecycle/SenderLock.d.ts +37 -0
- package/dist/lifecycle/SenderLock.d.ts.map +1 -0
- package/dist/lifecycle/SenderLock.js +57 -0
- package/dist/lifecycle/SenderLock.js.map +1 -0
- package/dist/lifecycle/SenderLockWebLocks.d.ts +37 -0
- package/dist/lifecycle/SenderLockWebLocks.d.ts.map +1 -0
- package/dist/lifecycle/SenderLockWebLocks.js +100 -0
- package/dist/lifecycle/SenderLockWebLocks.js.map +1 -0
- package/dist/lifecycle/SignedTransaction.d.ts +55 -0
- package/dist/lifecycle/SignedTransaction.d.ts.map +1 -0
- package/dist/lifecycle/SignedTransaction.js +109 -0
- package/dist/lifecycle/SignedTransaction.js.map +1 -0
- package/dist/lifecycle/SubmitConfig.d.ts +44 -0
- package/dist/lifecycle/SubmitConfig.d.ts.map +1 -0
- package/dist/lifecycle/SubmitConfig.js +39 -0
- package/dist/lifecycle/SubmitConfig.js.map +1 -0
- package/dist/lifecycle/index.d.ts +13 -0
- package/dist/lifecycle/index.d.ts.map +1 -0
- package/dist/lifecycle/index.js +13 -0
- package/dist/lifecycle/index.js.map +1 -0
- package/dist/wallet/Features.d.ts +91 -0
- package/dist/wallet/Features.d.ts.map +1 -0
- package/dist/wallet/Features.js +14 -0
- package/dist/wallet/Features.js.map +1 -0
- package/dist/wallet/Wallet.d.ts +151 -0
- package/dist/wallet/Wallet.d.ts.map +1 -0
- package/dist/wallet/Wallet.js +399 -0
- package/dist/wallet/Wallet.js.map +1 -0
- package/dist/wallet/index.d.ts +6 -0
- package/dist/wallet/index.d.ts.map +1 -0
- package/dist/wallet/index.js +6 -0
- package/dist/wallet/index.js.map +1 -0
- package/dist/zklogin/AddressSeed.d.ts +40 -0
- package/dist/zklogin/AddressSeed.d.ts.map +1 -0
- package/dist/zklogin/AddressSeed.js +91 -0
- package/dist/zklogin/AddressSeed.js.map +1 -0
- package/dist/zklogin/Errors.d.ts +24 -0
- package/dist/zklogin/Errors.d.ts.map +1 -0
- package/dist/zklogin/Errors.js +25 -0
- package/dist/zklogin/Errors.js.map +1 -0
- package/dist/zklogin/Jwt.d.ts +51 -0
- package/dist/zklogin/Jwt.d.ts.map +1 -0
- package/dist/zklogin/Jwt.js +159 -0
- package/dist/zklogin/Jwt.js.map +1 -0
- package/dist/zklogin/Nonce.d.ts +9 -0
- package/dist/zklogin/Nonce.d.ts.map +1 -0
- package/dist/zklogin/Nonce.js +34 -0
- package/dist/zklogin/Nonce.js.map +1 -0
- package/dist/zklogin/Poseidon.d.ts +24 -0
- package/dist/zklogin/Poseidon.d.ts.map +1 -0
- package/dist/zklogin/Poseidon.js +54 -0
- package/dist/zklogin/Poseidon.js.map +1 -0
- package/dist/zklogin/PublicIdentifier.d.ts +49 -0
- package/dist/zklogin/PublicIdentifier.d.ts.map +1 -0
- package/dist/zklogin/PublicIdentifier.js +90 -0
- package/dist/zklogin/PublicIdentifier.js.map +1 -0
- package/dist/zklogin/Signature.d.ts +55 -0
- package/dist/zklogin/Signature.d.ts.map +1 -0
- package/dist/zklogin/Signature.js +70 -0
- package/dist/zklogin/Signature.js.map +1 -0
- package/dist/zklogin/ZkLogin.d.ts +41 -0
- package/dist/zklogin/ZkLogin.d.ts.map +1 -0
- package/dist/zklogin/ZkLogin.js +87 -0
- package/dist/zklogin/ZkLogin.js.map +1 -0
- package/dist/zklogin/ZkLoginAddress.d.ts +30 -0
- package/dist/zklogin/ZkLoginAddress.d.ts.map +1 -0
- package/dist/zklogin/ZkLoginAddress.js +31 -0
- package/dist/zklogin/ZkLoginAddress.js.map +1 -0
- package/dist/zklogin/ZkLoginVerifier.d.ts +37 -0
- package/dist/zklogin/ZkLoginVerifier.d.ts.map +1 -0
- package/dist/zklogin/ZkLoginVerifier.js +4 -0
- package/dist/zklogin/ZkLoginVerifier.js.map +1 -0
- package/dist/zklogin/ZkLoginVerifierGrpc.d.ts +12 -0
- package/dist/zklogin/ZkLoginVerifierGrpc.d.ts.map +1 -0
- package/dist/zklogin/ZkLoginVerifierGrpc.js +53 -0
- package/dist/zklogin/ZkLoginVerifierGrpc.js.map +1 -0
- package/dist/zklogin/index.d.ts +17 -0
- package/dist/zklogin/index.d.ts.map +1 -0
- package/dist/zklogin/index.js +17 -0
- package/dist/zklogin/index.js.map +1 -0
- package/dist/zklogin/internal/parse.d.ts +9 -0
- package/dist/zklogin/internal/parse.d.ts.map +1 -0
- package/dist/zklogin/internal/parse.js +33 -0
- package/dist/zklogin/internal/parse.js.map +1 -0
- package/dist/zklogin/internal/poseidon.d.ts +21 -0
- package/dist/zklogin/internal/poseidon.d.ts.map +1 -0
- package/dist/zklogin/internal/poseidon.js +40 -0
- package/dist/zklogin/internal/poseidon.js.map +1 -0
- package/package.json +69 -4
- package/src/Address.ts +45 -0
- package/src/AddressAlias.ts +160 -0
- package/src/Bip32.ts +37 -0
- package/src/Chain.ts +21 -0
- package/src/CheckpointData.ts +106 -0
- package/src/Checkpoints.ts +18 -0
- package/src/CoinReservation.ts +65 -0
- package/src/Coins.ts +86 -0
- package/src/DynamicFields.ts +179 -0
- package/src/Ecdsa.ts +103 -0
- package/src/Ed25519.ts +84 -0
- package/src/Events.ts +133 -0
- package/src/Hash.ts +39 -0
- package/src/MlDsa65.ts +92 -0
- package/src/Mnemonic.ts +109 -0
- package/src/Move.ts +440 -0
- package/src/MultiSig.ts +320 -0
- package/src/Objects.ts +112 -0
- package/src/Packages.ts +52 -0
- package/src/Passkey.ts +10 -0
- package/src/PrivateKey.ts +138 -0
- package/src/Ptb.ts +579 -0
- package/src/Resolve.ts +1367 -0
- package/src/RpcError.ts +41 -0
- package/src/Secp256k1.ts +29 -0
- package/src/Secp256r1.ts +29 -0
- package/src/SignatureScheme.ts +166 -0
- package/src/Signer.ts +62 -0
- package/src/Testing.ts +830 -0
- package/src/TransactionData.ts +134 -0
- package/src/TransactionJson.ts +1002 -0
- package/src/Transactions.ts +211 -0
- package/src/Tx.ts +367 -0
- package/src/TypeTag.ts +123 -0
- package/src/Verify.ts +42 -0
- package/src/enoki/EnokiClient.ts +204 -0
- package/src/enoki/EnokiHttp.ts +222 -0
- package/src/enoki/Sponsor.ts +280 -0
- package/src/enoki/ZkLoginFlow.ts +176 -0
- package/src/enoki/index.ts +8 -0
- package/src/graphql/ChainGraphQL.ts +76 -0
- package/src/graphql/CheckpointDataGraphQL.ts +191 -0
- package/src/graphql/CheckpointsGraphQL.ts +96 -0
- package/src/graphql/CoinsGraphQL.ts +85 -0
- package/src/graphql/DynamicFieldsGraphQL.ts +167 -0
- package/src/graphql/EventsGraphQL.ts +301 -0
- package/src/graphql/ObjectsGraphQL.ts +112 -0
- package/src/graphql/PackagesGraphQL.ts +173 -0
- package/src/graphql/SuiGraphQL.ts +77 -0
- package/src/graphql/TransactionsGraphQL.ts +292 -0
- package/src/graphql/convert.ts +450 -0
- package/src/graphql/index.ts +74 -0
- package/src/graphql/merge.ts +62 -0
- package/src/graphql/paging.ts +110 -0
- package/src/graphql/subscription.ts +58 -0
- package/src/graphql/tip.ts +38 -0
- package/src/grpc/ChainGrpc.ts +51 -0
- package/src/grpc/CheckpointDataGrpc.ts +47 -0
- package/src/grpc/CheckpointsGrpc.ts +37 -0
- package/src/grpc/CoinsGrpc.ts +50 -0
- package/src/grpc/DynamicFieldsGrpc.ts +128 -0
- package/src/grpc/EventsGrpc.ts +101 -0
- package/src/grpc/GrpcWeb.ts +343 -0
- package/src/grpc/ObjectsGrpc.ts +95 -0
- package/src/grpc/PackagesGrpc.ts +98 -0
- package/src/grpc/Rpc.ts +156 -0
- package/src/grpc/TransactionsGrpc.ts +88 -0
- package/src/grpc/cache.ts +68 -0
- package/src/grpc/convert.ts +227 -0
- package/src/grpc/generated/lean.ts +276 -0
- package/src/grpc/generated/proto.ts +2130 -0
- package/src/grpc/generated/rpc.ts +417 -0
- package/src/grpc/index.ts +97 -0
- package/src/grpc/scan.ts +183 -0
- package/src/grpc/transaction.ts +182 -0
- package/src/index.ts +35 -0
- package/src/internal/allowances.ts +238 -0
- package/src/internal/mnemonic.ts +99 -0
- package/src/internal/passkey/BrowserProvider.ts +131 -0
- package/src/internal/passkey/Passkey.ts +408 -0
- package/src/internal/passkey/SoftwareProvider.ts +90 -0
- package/src/lifecycle/Evidence.ts +85 -0
- package/src/lifecycle/EvidenceGraphQL.ts +67 -0
- package/src/lifecycle/EvidenceGrpc.ts +47 -0
- package/src/lifecycle/Journal.ts +117 -0
- package/src/lifecycle/JournalEntry.ts +68 -0
- package/src/lifecycle/JournalKeyValueStore.ts +276 -0
- package/src/lifecycle/KeyValueStoreIndexedDb.ts +361 -0
- package/src/lifecycle/KeyValueStoreOpfs.ts +230 -0
- package/src/lifecycle/Lifecycle.ts +990 -0
- package/src/lifecycle/Outcome.ts +130 -0
- package/src/lifecycle/SenderLock.ts +73 -0
- package/src/lifecycle/SenderLockWebLocks.ts +136 -0
- package/src/lifecycle/SignedTransaction.ts +133 -0
- package/src/lifecycle/SubmitConfig.ts +77 -0
- package/src/lifecycle/index.ts +12 -0
- package/src/wallet/Features.ts +114 -0
- package/src/wallet/Wallet.ts +550 -0
- package/src/wallet/index.ts +5 -0
- package/src/zklogin/AddressSeed.ts +130 -0
- package/src/zklogin/Errors.ts +27 -0
- package/src/zklogin/Jwt.ts +186 -0
- package/src/zklogin/Nonce.ts +46 -0
- package/src/zklogin/Poseidon.ts +62 -0
- package/src/zklogin/PublicIdentifier.ts +111 -0
- package/src/zklogin/Signature.ts +88 -0
- package/src/zklogin/ZkLogin.ts +145 -0
- package/src/zklogin/ZkLoginAddress.ts +72 -0
- package/src/zklogin/ZkLoginVerifier.ts +37 -0
- package/src/zklogin/ZkLoginVerifierGrpc.ts +66 -0
- package/src/zklogin/index.ts +16 -0
- package/src/zklogin/internal/parse.ts +30 -0
- package/src/zklogin/internal/poseidon.ts +47 -0
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A `KeyValueStore` (`effect/persistence`) over IndexedDB: the recommended
|
|
3
|
+
* durable store for `JournalKeyValueStore` in a browser.
|
|
4
|
+
*
|
|
5
|
+
* - One object store (default `kv`) in one database (default
|
|
6
|
+
* `@unconfirmed/effect-sui/lifecycle`), opened once per layer scope and closed when
|
|
7
|
+
* the scope closes. Keys are the store's strings; strings are stored as
|
|
8
|
+
* strings and `Uint8Array`s as bytes (structured clone), so both round-trip.
|
|
9
|
+
* `get` of a binary value answers its Base64, and `getUint8Array` of a
|
|
10
|
+
* string its UTF-8, as `KeyValueStore.layerMemory` does.
|
|
11
|
+
* - One IDB transaction per operation, resolved on the transaction's
|
|
12
|
+
* `complete` (not the request's `success`), with `durability: "strict"` on
|
|
13
|
+
* writes where the browser supports it (Chromium; Firefox and Safari treat
|
|
14
|
+
* every commit as strict and ignore the hint). `modify` reads and writes in
|
|
15
|
+
* one transaction, so it is atomic across tabs.
|
|
16
|
+
* - Another tab upgrading or deleting the database fires `versionchange`: the
|
|
17
|
+
* connection is closed at once (so it never blocks the other tab) and the
|
|
18
|
+
* next operation reopens it. A connection the browser closes under us
|
|
19
|
+
* (`close` event, storage cleared) is reopened the same way. When the store
|
|
20
|
+
* is missing (a new database, or one created by other code under this name)
|
|
21
|
+
* the database is reopened one version up to create it; if a connection
|
|
22
|
+
* that ignores `versionchange` blocks that upgrade, opening fails with
|
|
23
|
+
* `KeyValueStoreError` rather than hanging.
|
|
24
|
+
* - Every failure is a `KeyValueStoreError` (the `cause` holds the
|
|
25
|
+
* `DOMException`, the `message` its name): IndexedDB missing (`indexedDB`
|
|
26
|
+
* undefined, as in some embedded webviews and old private modes), `open`
|
|
27
|
+
* refused (Firefox < 115 private mode: `InvalidStateError`), quota
|
|
28
|
+
* (`QuotaExceededError`, usually as a transaction abort), an aborted
|
|
29
|
+
* transaction, `InvalidStateError` / `TransactionInactiveError`, or a value
|
|
30
|
+
* of another type under a key.
|
|
31
|
+
*
|
|
32
|
+
* The write order `JournalKeyValueStore` relies on holds: each operation's
|
|
33
|
+
* effect completes only once its transaction has committed, and IndexedDB
|
|
34
|
+
* orders overlapping readwrite transactions by creation.
|
|
35
|
+
*/
|
|
36
|
+
import * as Effect from "effect/Effect"
|
|
37
|
+
import * as Base64 from "effect/encoding/Base64"
|
|
38
|
+
import * as Layer from "effect/Layer"
|
|
39
|
+
import * as KeyValueStore from "effect/persistence/KeyValueStore"
|
|
40
|
+
import type * as Scope from "effect/Scope"
|
|
41
|
+
|
|
42
|
+
export const DEFAULT_DATABASE = "@unconfirmed/effect-sui/lifecycle"
|
|
43
|
+
export const DEFAULT_STORE = "kv"
|
|
44
|
+
|
|
45
|
+
export interface Options {
|
|
46
|
+
/** The database name. Default {@link DEFAULT_DATABASE}. */
|
|
47
|
+
readonly database?: string
|
|
48
|
+
/** The object store name. Default {@link DEFAULT_STORE}. */
|
|
49
|
+
readonly store?: string
|
|
50
|
+
/** The `IDBFactory` to use instead of `globalThis.indexedDB` (tests, or a worker's own). */
|
|
51
|
+
readonly indexedDB?: IDBFactory
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const describe = (cause: unknown): string =>
|
|
55
|
+
cause instanceof Error || (typeof cause === "object" && cause !== null && "name" in cause && "message" in cause)
|
|
56
|
+
? `${(cause as Error).name}: ${(cause as Error).message}`
|
|
57
|
+
: String(cause)
|
|
58
|
+
|
|
59
|
+
const storeError = (method: string, cause: unknown, key?: string): KeyValueStore.KeyValueStoreError =>
|
|
60
|
+
new KeyValueStore.KeyValueStoreError({
|
|
61
|
+
method,
|
|
62
|
+
...(key === undefined ? {} : { key }),
|
|
63
|
+
message: `IndexedDB ${method}${key === undefined ? "" : ` of ${JSON.stringify(key)}`} failed: ${describe(cause)}`,
|
|
64
|
+
cause
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
const isInvalidState = (cause: unknown) =>
|
|
68
|
+
typeof cause === "object" && cause !== null && (cause as { name?: unknown }).name === "InvalidStateError"
|
|
69
|
+
|
|
70
|
+
const encoder = new TextEncoder()
|
|
71
|
+
|
|
72
|
+
/** A stored value as a string (`get`), or the reason it is not one we wrote. */
|
|
73
|
+
const asString = (value: unknown): string | { readonly invalid: string } =>
|
|
74
|
+
typeof value === "string"
|
|
75
|
+
? value
|
|
76
|
+
: value instanceof Uint8Array
|
|
77
|
+
? Base64.encode(value)
|
|
78
|
+
: value instanceof ArrayBuffer
|
|
79
|
+
? Base64.encode(new Uint8Array(value))
|
|
80
|
+
: { invalid: `holds a ${typeof value}, not a string or bytes` }
|
|
81
|
+
|
|
82
|
+
const asBytes = (value: unknown): Uint8Array | { readonly invalid: string } =>
|
|
83
|
+
typeof value === "string"
|
|
84
|
+
? encoder.encode(value)
|
|
85
|
+
: value instanceof Uint8Array
|
|
86
|
+
? value
|
|
87
|
+
: value instanceof ArrayBuffer
|
|
88
|
+
? new Uint8Array(value)
|
|
89
|
+
: { invalid: `holds a ${typeof value}, not a string or bytes` }
|
|
90
|
+
|
|
91
|
+
class Invalid extends Error {
|
|
92
|
+
override readonly name = "InvalidValue"
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Open (or reopen) the connection; `undefined` resolves once a blocked
|
|
97
|
+
* upgrade gives up. The returned connection closes itself on `versionchange`
|
|
98
|
+
* and reports its closing through `onGone`.
|
|
99
|
+
*/
|
|
100
|
+
const openDatabase = (
|
|
101
|
+
factory: IDBFactory,
|
|
102
|
+
name: string,
|
|
103
|
+
store: string,
|
|
104
|
+
onGone: (db: IDBDatabase) => void
|
|
105
|
+
): Promise<IDBDatabase> => {
|
|
106
|
+
const request = (version?: number) =>
|
|
107
|
+
new Promise<IDBDatabase>((resolve, reject) => {
|
|
108
|
+
let settled = false
|
|
109
|
+
const req = version === undefined ? factory.open(name) : factory.open(name, version)
|
|
110
|
+
req.onupgradeneeded = () => {
|
|
111
|
+
const db = req.result
|
|
112
|
+
if (!db.objectStoreNames.contains(store)) db.createObjectStore(store)
|
|
113
|
+
}
|
|
114
|
+
req.onsuccess = () => {
|
|
115
|
+
const db = req.result
|
|
116
|
+
if (settled) return db.close() // blocked earlier and already failed
|
|
117
|
+
settled = true
|
|
118
|
+
resolve(db)
|
|
119
|
+
}
|
|
120
|
+
req.onerror = () => {
|
|
121
|
+
if (settled) return
|
|
122
|
+
settled = true
|
|
123
|
+
reject(req.error ?? new Error("open failed"))
|
|
124
|
+
}
|
|
125
|
+
req.onblocked = () => {
|
|
126
|
+
if (settled) return
|
|
127
|
+
settled = true
|
|
128
|
+
reject(
|
|
129
|
+
Object.assign(new Error(`opening ${name} v${version} is blocked by a connection that ignores versionchange`), {
|
|
130
|
+
name: "BlockedError"
|
|
131
|
+
})
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
const watch = (db: IDBDatabase): IDBDatabase => {
|
|
136
|
+
db.onversionchange = () => {
|
|
137
|
+
db.close()
|
|
138
|
+
onGone(db)
|
|
139
|
+
}
|
|
140
|
+
db.onclose = () => onGone(db)
|
|
141
|
+
return db
|
|
142
|
+
}
|
|
143
|
+
return request().then((db) => {
|
|
144
|
+
if (db.objectStoreNames.contains(store)) return watch(db)
|
|
145
|
+
const next = db.version + 1
|
|
146
|
+
db.close()
|
|
147
|
+
return request(next).then(watch)
|
|
148
|
+
})
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** The store, open for the current scope. Fails with `KeyValueStoreError` when IndexedDB is missing or refuses to open. */
|
|
152
|
+
export const make = (options?: Options): Effect.Effect<KeyValueStore.KeyValueStore, KeyValueStore.KeyValueStoreError, Scope.Scope> =>
|
|
153
|
+
Effect.gen(function*() {
|
|
154
|
+
const factory = options?.indexedDB ?? (globalThis as { indexedDB?: IDBFactory }).indexedDB
|
|
155
|
+
if (factory === undefined || factory === null) {
|
|
156
|
+
return yield* storeError("open", new Error("IndexedDB is not available in this environment"))
|
|
157
|
+
}
|
|
158
|
+
const name = options?.database ?? DEFAULT_DATABASE
|
|
159
|
+
const storeName = options?.store ?? DEFAULT_STORE
|
|
160
|
+
let current: Promise<IDBDatabase> | undefined
|
|
161
|
+
let disposed = false
|
|
162
|
+
const gone = (db: IDBDatabase) => {
|
|
163
|
+
// Forget it only if it is still the current one.
|
|
164
|
+
void current?.then((c) => {
|
|
165
|
+
if (c === db) current = undefined
|
|
166
|
+
}, () => {})
|
|
167
|
+
}
|
|
168
|
+
const connection = (): Promise<IDBDatabase> => {
|
|
169
|
+
if (disposed) return Promise.reject(new Error("the store's scope is closed"))
|
|
170
|
+
if (current === undefined) {
|
|
171
|
+
const opening = openDatabase(factory, name, storeName, gone)
|
|
172
|
+
current = opening
|
|
173
|
+
// A failed open is not cached: the next operation tries again.
|
|
174
|
+
opening.catch(() => {
|
|
175
|
+
if (current === opening) current = undefined
|
|
176
|
+
})
|
|
177
|
+
}
|
|
178
|
+
return current
|
|
179
|
+
}
|
|
180
|
+
const drop = (db: IDBDatabase) => {
|
|
181
|
+
try {
|
|
182
|
+
db.close()
|
|
183
|
+
} catch {
|
|
184
|
+
// already closed
|
|
185
|
+
}
|
|
186
|
+
current = undefined // found closed: the next connection() opens afresh
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
yield* Effect.acquireRelease(
|
|
190
|
+
Effect.tryPromise({ try: connection, catch: (cause) => storeError("open", cause) }),
|
|
191
|
+
() =>
|
|
192
|
+
Effect.promise(async () => {
|
|
193
|
+
disposed = true
|
|
194
|
+
const open = current
|
|
195
|
+
current = undefined
|
|
196
|
+
if (open !== undefined) await open.then((db) => db.close(), () => {})
|
|
197
|
+
})
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Run `body` in one transaction and answer its result once the
|
|
202
|
+
* transaction commits. A connection found closed (`InvalidStateError`
|
|
203
|
+
* from `transaction()`) is reopened once.
|
|
204
|
+
*/
|
|
205
|
+
const run = <A>(
|
|
206
|
+
method: string,
|
|
207
|
+
key: string | undefined,
|
|
208
|
+
mode: IDBTransactionMode,
|
|
209
|
+
body: (store: IDBObjectStore, done: (a: A) => void, fail: (e: unknown) => void) => void
|
|
210
|
+
): Effect.Effect<A, KeyValueStore.KeyValueStoreError> =>
|
|
211
|
+
Effect.callback<A, KeyValueStore.KeyValueStoreError>((resume, signal) => {
|
|
212
|
+
let finished = false
|
|
213
|
+
let tx: IDBTransaction | undefined
|
|
214
|
+
const finish = (effect: Effect.Effect<A, KeyValueStore.KeyValueStoreError>) => {
|
|
215
|
+
if (finished) return
|
|
216
|
+
finished = true
|
|
217
|
+
resume(effect)
|
|
218
|
+
}
|
|
219
|
+
const attempt = (retry: boolean) => {
|
|
220
|
+
connection().then((db) => {
|
|
221
|
+
if (finished || signal.aborted) return
|
|
222
|
+
try {
|
|
223
|
+
tx = mode === "readwrite"
|
|
224
|
+
? db.transaction(storeName, mode, { durability: "strict" })
|
|
225
|
+
: db.transaction(storeName, mode)
|
|
226
|
+
} catch (cause) {
|
|
227
|
+
if (retry && isInvalidState(cause)) {
|
|
228
|
+
drop(db)
|
|
229
|
+
return attempt(false)
|
|
230
|
+
}
|
|
231
|
+
return finish(Effect.fail(storeError(method, cause, key)))
|
|
232
|
+
}
|
|
233
|
+
let result: { readonly value: A } | undefined
|
|
234
|
+
let failure: { readonly cause: unknown } | undefined
|
|
235
|
+
tx.oncomplete = () =>
|
|
236
|
+
finish(failure !== undefined
|
|
237
|
+
? Effect.fail(storeError(method, failure.cause, key))
|
|
238
|
+
: result === undefined
|
|
239
|
+
? Effect.fail(storeError(method, new Error("the transaction committed without a result"), key))
|
|
240
|
+
: Effect.succeed(result.value))
|
|
241
|
+
tx.onabort = () => {
|
|
242
|
+
const cause = tx?.error ?? failure?.cause ??
|
|
243
|
+
Object.assign(new Error("the transaction was aborted"), { name: "AbortError" })
|
|
244
|
+
finish(Effect.fail(storeError(method, cause, key)))
|
|
245
|
+
}
|
|
246
|
+
// A request error bubbles to the transaction and aborts it; onabort reports it.
|
|
247
|
+
tx.onerror = (event) => {
|
|
248
|
+
if (failure === undefined) failure = { cause: (event.target as IDBRequest | null)?.error ?? tx?.error }
|
|
249
|
+
}
|
|
250
|
+
try {
|
|
251
|
+
body(
|
|
252
|
+
tx.objectStore(storeName),
|
|
253
|
+
(a) => {
|
|
254
|
+
result = { value: a }
|
|
255
|
+
},
|
|
256
|
+
(cause) => {
|
|
257
|
+
failure = { cause }
|
|
258
|
+
try {
|
|
259
|
+
tx?.abort()
|
|
260
|
+
} catch {
|
|
261
|
+
// already finishing
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
)
|
|
265
|
+
} catch (cause) {
|
|
266
|
+
failure = { cause }
|
|
267
|
+
try {
|
|
268
|
+
tx.abort()
|
|
269
|
+
} catch {
|
|
270
|
+
finish(Effect.fail(storeError(method, cause, key)))
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}, (cause) => finish(Effect.fail(storeError(method, cause, key))))
|
|
274
|
+
}
|
|
275
|
+
attempt(true)
|
|
276
|
+
// Interrupted: abort the transaction (a no-op once it has committed).
|
|
277
|
+
return Effect.sync(() => {
|
|
278
|
+
finished = true
|
|
279
|
+
try {
|
|
280
|
+
tx?.abort()
|
|
281
|
+
} catch {
|
|
282
|
+
// committed or already aborted
|
|
283
|
+
}
|
|
284
|
+
})
|
|
285
|
+
})
|
|
286
|
+
|
|
287
|
+
const request = <A>(req: IDBRequest, done: (a: A) => void, map: (raw: unknown) => A) => {
|
|
288
|
+
req.onsuccess = () => done(map(req.result))
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
const getWith = <A>(method: string, convert: (value: unknown) => A | { readonly invalid: string }) => (key: string) =>
|
|
292
|
+
run<A | undefined>(method, key, "readonly", (store, done, fail) =>
|
|
293
|
+
request(store.get(key), (raw: unknown) => {
|
|
294
|
+
if (raw === undefined) return done(undefined)
|
|
295
|
+
const value = convert(raw)
|
|
296
|
+
if (typeof value === "object" && value !== null && "invalid" in value) fail(new Invalid(value.invalid))
|
|
297
|
+
else done(value as A)
|
|
298
|
+
}, (raw) => raw))
|
|
299
|
+
|
|
300
|
+
const modifyWith = <V extends string | Uint8Array>(
|
|
301
|
+
method: string,
|
|
302
|
+
convert: (value: unknown) => V | { readonly invalid: string }
|
|
303
|
+
) =>
|
|
304
|
+
(key: string, f: (value: V) => V) =>
|
|
305
|
+
run<V | undefined>(method, key, "readwrite", (store, done, fail) => {
|
|
306
|
+
const req = store.get(key)
|
|
307
|
+
req.onsuccess = () => {
|
|
308
|
+
if (req.result === undefined) return done(undefined)
|
|
309
|
+
const value = convert(req.result)
|
|
310
|
+
if (typeof value === "object" && "invalid" in value) return fail(new Invalid(value.invalid))
|
|
311
|
+
let next: V
|
|
312
|
+
try {
|
|
313
|
+
next = f(value)
|
|
314
|
+
} catch (cause) {
|
|
315
|
+
return fail(cause)
|
|
316
|
+
}
|
|
317
|
+
request(store.put(next, key), done, () => next)
|
|
318
|
+
}
|
|
319
|
+
})
|
|
320
|
+
|
|
321
|
+
const allKeys = (store: IDBObjectStore, done: (keys: Array<string>) => void) =>
|
|
322
|
+
request(store.getAllKeys(), done, (raw) => (raw as Array<IDBValidKey>).filter((k): k is string => typeof k === "string"))
|
|
323
|
+
|
|
324
|
+
return KeyValueStore.make({
|
|
325
|
+
get: getWith("get", asString),
|
|
326
|
+
getUint8Array: getWith("getUint8Array", asBytes),
|
|
327
|
+
set: (key, value) =>
|
|
328
|
+
run<void>("set", key, "readwrite", (store, done) => request(store.put(value, key), done, () => undefined)),
|
|
329
|
+
remove: (key) => run<void>("remove", key, "readwrite", (store, done) => request(store.delete(key), done, () => undefined)),
|
|
330
|
+
has: (key) => run<boolean>("has", key, "readonly", (store, done) => request(store.count(key), done, (n) => (n as number) > 0)),
|
|
331
|
+
clear: run<void>("clear", undefined, "readwrite", (store, done) => request(store.clear(), done, () => undefined)),
|
|
332
|
+
clearPrefix: (prefix) =>
|
|
333
|
+
run<void>("clearPrefix", prefix, "readwrite", (store, done) => {
|
|
334
|
+
const KeyRange = (globalThis as { IDBKeyRange?: typeof IDBKeyRange }).IDBKeyRange
|
|
335
|
+
// With IDBKeyRange, walk from the prefix and stop past it; without, scan every key.
|
|
336
|
+
const ranged = KeyRange !== undefined && prefix.length > 0
|
|
337
|
+
const req = ranged ? store.openKeyCursor(KeyRange.lowerBound(prefix)) : store.openKeyCursor()
|
|
338
|
+
req.onsuccess = () => {
|
|
339
|
+
const cursor = req.result
|
|
340
|
+
if (cursor === null) return done(undefined)
|
|
341
|
+
const key = cursor.primaryKey
|
|
342
|
+
if (typeof key === "string" && key.startsWith(prefix)) {
|
|
343
|
+
store.delete(key)
|
|
344
|
+
cursor.continue()
|
|
345
|
+
} else if (ranged) {
|
|
346
|
+
done(undefined)
|
|
347
|
+
} else {
|
|
348
|
+
cursor.continue()
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}),
|
|
352
|
+
size: run<number>("size", undefined, "readonly", (store, done) => allKeys(store, (keys) => done(keys.length))),
|
|
353
|
+
keys: run<ReadonlyArray<string>>("keys", undefined, "readonly", (store, done) => allKeys(store, done)),
|
|
354
|
+
modify: modifyWith("modify", asString),
|
|
355
|
+
modifyUint8Array: modifyWith("modifyUint8Array", asBytes)
|
|
356
|
+
})
|
|
357
|
+
})
|
|
358
|
+
|
|
359
|
+
/** `KeyValueStore` over IndexedDB, open for the layer's lifetime. */
|
|
360
|
+
export const layer = (options?: Options): Layer.Layer<KeyValueStore.KeyValueStore, KeyValueStore.KeyValueStoreError> =>
|
|
361
|
+
Layer.effect(KeyValueStore.KeyValueStore, make(options))
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A `KeyValueStore` (`effect/persistence`) over the Origin Private File System
|
|
3
|
+
* (`navigator.storage.getDirectory()`): one file per key in a sub-directory
|
|
4
|
+
* (default `sui-lifecycle`; `a/b` nests).
|
|
5
|
+
*
|
|
6
|
+
* - **File names.** A key becomes `k.` plus the key with every character
|
|
7
|
+
* outside `[A-Za-z0-9_-]` written as `%XX` per UTF-8 byte, so `entry:Ab1`
|
|
8
|
+
* is `k.entry%3AAb1`. The mapping is reversible (that is how `keys` works),
|
|
9
|
+
* never yields `/`, `\`, `.` or `..`, and leaves case alone (OPFS names are
|
|
10
|
+
* case-sensitive). Files in the directory that are not of this form
|
|
11
|
+
* (browser swap files, anything else) are ignored by `keys`, `size` and
|
|
12
|
+
* `clear`. A name longer than {@link MAX_NAME_LENGTH} characters is refused
|
|
13
|
+
* with `KeyValueStoreError` before touching the disk.
|
|
14
|
+
* - **Atomic writes.** `set` writes through `createWritable()`, which writes
|
|
15
|
+
* to a swap file and replaces the file only on `close()`; a write that fails
|
|
16
|
+
* (quota, interruption) aborts the stream and leaves the previous value.
|
|
17
|
+
* That works on the main thread and in workers. `createSyncAccessHandle()`
|
|
18
|
+
* is worker-only and writes in place (not atomic), so it is not used.
|
|
19
|
+
* - **Values** are the file's bytes: strings are written as UTF-8, `get`
|
|
20
|
+
* decodes UTF-8 and `getUint8Array` answers the bytes (as
|
|
21
|
+
* `KeyValueStore.layerFileSystem` does), so a string and its UTF-8 bytes
|
|
22
|
+
* are the same value.
|
|
23
|
+
* - **Errors.** Every failure is a `KeyValueStoreError` (the `cause` holds
|
|
24
|
+
* the `DOMException`): OPFS missing (no `navigator.storage.getDirectory`:
|
|
25
|
+
* non-secure context, old browsers; `SecurityError` in some private modes),
|
|
26
|
+
* `QuotaExceededError`, `NoModificationAllowedError` (a worker holds a sync
|
|
27
|
+
* access handle on the file), `TypeMismatchError` (a directory under the
|
|
28
|
+
* name), `createWritable` missing. A missing file (`NotFoundError`) is an
|
|
29
|
+
* absent key: `get` answers `undefined`, `remove` succeeds.
|
|
30
|
+
*
|
|
31
|
+
* Browser caveats:
|
|
32
|
+
* - Safari has `getDirectory` since 15.2 but `createWritable` /
|
|
33
|
+
* `FileSystemWritableFileStream` only since Safari 26; on older Safari this
|
|
34
|
+
* store fails `set` (and the layer fails to build) with `KeyValueStoreError`.
|
|
35
|
+
* Use `KeyValueStoreIndexedDb` there.
|
|
36
|
+
* - Firefox has OPFS since 111; in private browsing `getDirectory` may reject
|
|
37
|
+
* (`SecurityError`), which fails the layer typed.
|
|
38
|
+
* - Two `createWritable` streams on one file (two tabs) do not lock each
|
|
39
|
+
* other: the last `close()` wins, whole. `JournalKeyValueStore` writes whole
|
|
40
|
+
* values per key, so that is enough.
|
|
41
|
+
* - Unlike IndexedDB there is no strict-durability flag: a committed
|
|
42
|
+
* `close()` is on the browser's storage, but whether it is fsynced before
|
|
43
|
+
* a power loss is up to the browser.
|
|
44
|
+
*/
|
|
45
|
+
import * as Effect from "effect/Effect"
|
|
46
|
+
import * as Layer from "effect/Layer"
|
|
47
|
+
import * as KeyValueStore from "effect/persistence/KeyValueStore"
|
|
48
|
+
|
|
49
|
+
export const DEFAULT_DIRECTORY = "sui-lifecycle"
|
|
50
|
+
/** The longest file name produced; longer keys are refused. Most file systems cap names at 255 bytes. */
|
|
51
|
+
export const MAX_NAME_LENGTH = 255
|
|
52
|
+
|
|
53
|
+
const PREFIX = "k."
|
|
54
|
+
|
|
55
|
+
export interface Options {
|
|
56
|
+
/** The sub-directory of the origin's root, `/`-separated for nesting. Default {@link DEFAULT_DIRECTORY}. */
|
|
57
|
+
readonly directory?: string
|
|
58
|
+
/** The root to use instead of `navigator.storage.getDirectory()` (tests, or a worker's own). */
|
|
59
|
+
readonly root?: () => Promise<FileSystemDirectoryHandle>
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const encoder = new TextEncoder()
|
|
63
|
+
const decoder = new TextDecoder("utf-8", { ignoreBOM: true })
|
|
64
|
+
const SAFE = /^[A-Za-z0-9_-]$/
|
|
65
|
+
|
|
66
|
+
/** The file name of a key: reversible, and safe as an OPFS entry name. */
|
|
67
|
+
export const encodeKey = (key: string): string => {
|
|
68
|
+
let out = PREFIX
|
|
69
|
+
for (const ch of key) {
|
|
70
|
+
if (SAFE.test(ch)) out += ch
|
|
71
|
+
else for (const byte of encoder.encode(ch)) out += `%${byte.toString(16).toUpperCase().padStart(2, "0")}`
|
|
72
|
+
}
|
|
73
|
+
return out
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** The key of a file name, or `undefined` for a file this store did not write. */
|
|
77
|
+
export const decodeKey = (name: string): string | undefined => {
|
|
78
|
+
if (!name.startsWith(PREFIX)) return undefined
|
|
79
|
+
const body = name.slice(PREFIX.length)
|
|
80
|
+
if (!/^(?:[A-Za-z0-9_-]|%[0-9A-F]{2})*$/.test(body)) return undefined
|
|
81
|
+
try {
|
|
82
|
+
const key = decodeURIComponent(body)
|
|
83
|
+
return encodeKey(key) === name ? key : undefined
|
|
84
|
+
} catch {
|
|
85
|
+
return undefined
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const describe = (cause: unknown): string =>
|
|
90
|
+
typeof cause === "object" && cause !== null && "name" in cause && "message" in cause
|
|
91
|
+
? `${(cause as Error).name}: ${(cause as Error).message}`
|
|
92
|
+
: String(cause)
|
|
93
|
+
|
|
94
|
+
const storeError = (method: string, cause: unknown, key?: string): KeyValueStore.KeyValueStoreError =>
|
|
95
|
+
new KeyValueStore.KeyValueStoreError({
|
|
96
|
+
method,
|
|
97
|
+
...(key === undefined ? {} : { key }),
|
|
98
|
+
message: `OPFS ${method}${key === undefined ? "" : ` of ${JSON.stringify(key)}`} failed: ${describe(cause)}`,
|
|
99
|
+
cause
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
const isNotFound = (cause: unknown) =>
|
|
103
|
+
typeof cause === "object" && cause !== null && (cause as { name?: unknown }).name === "NotFoundError"
|
|
104
|
+
|
|
105
|
+
const tryAsync = <A>(method: string, key: string | undefined, f: (signal: AbortSignal) => Promise<A>) =>
|
|
106
|
+
Effect.tryPromise({ try: f, catch: (cause) => storeError(method, cause, key) })
|
|
107
|
+
|
|
108
|
+
const nameOf = (method: string, key: string): Effect.Effect<string, KeyValueStore.KeyValueStoreError> => {
|
|
109
|
+
if (decoder.decode(encoder.encode(key)) !== key) {
|
|
110
|
+
return Effect.fail(storeError(method, new Error("the key is not well-formed UTF-16 (a lone surrogate)"), key))
|
|
111
|
+
}
|
|
112
|
+
const name = encodeKey(key)
|
|
113
|
+
return name.length > MAX_NAME_LENGTH
|
|
114
|
+
? Effect.fail(storeError(method, new Error(`the key encodes to ${name.length} characters, over ${MAX_NAME_LENGTH}`), key))
|
|
115
|
+
: Effect.succeed(name)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Our file names in `dir`. */
|
|
119
|
+
const listNames = async (dir: FileSystemDirectoryHandle): Promise<Array<string>> => {
|
|
120
|
+
const names: Array<string> = []
|
|
121
|
+
for await (const [name, handle] of (dir as unknown as { entries(): AsyncIterable<[string, FileSystemHandle]> }).entries()) {
|
|
122
|
+
if (handle.kind === "file" && decodeKey(name) !== undefined) names.push(name)
|
|
123
|
+
}
|
|
124
|
+
return names
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const defaultRoot = (): Promise<FileSystemDirectoryHandle> => {
|
|
128
|
+
const storage = (globalThis as { navigator?: { storage?: StorageManager } }).navigator?.storage
|
|
129
|
+
if (storage === undefined || typeof storage.getDirectory !== "function") {
|
|
130
|
+
return Promise.reject(new Error("the Origin Private File System (navigator.storage.getDirectory) is not available"))
|
|
131
|
+
}
|
|
132
|
+
return storage.getDirectory()
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Write `value` to `handle` atomically: a swap file, committed on `close()`, aborted on failure. */
|
|
136
|
+
const writeAtomic = async (handle: FileSystemFileHandle, value: string | Uint8Array): Promise<void> => {
|
|
137
|
+
if (typeof (handle as { createWritable?: unknown }).createWritable !== "function") {
|
|
138
|
+
throw Object.assign(
|
|
139
|
+
new Error("FileSystemFileHandle.createWritable is not available (Safari before 26); use KeyValueStoreIndexedDb"),
|
|
140
|
+
{ name: "NotSupportedError" }
|
|
141
|
+
)
|
|
142
|
+
}
|
|
143
|
+
const stream = await handle.createWritable({ keepExistingData: false })
|
|
144
|
+
try {
|
|
145
|
+
await stream.write(typeof value === "string" ? value : (value as Uint8Array<ArrayBuffer>))
|
|
146
|
+
} catch (cause) {
|
|
147
|
+
await stream.abort().catch(() => {})
|
|
148
|
+
throw cause
|
|
149
|
+
}
|
|
150
|
+
await stream.close()
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** The store over `directory` (resolved, and created, now). */
|
|
154
|
+
export const make = (options?: Options): Effect.Effect<KeyValueStore.KeyValueStore, KeyValueStore.KeyValueStoreError> =>
|
|
155
|
+
Effect.gen(function*() {
|
|
156
|
+
const path = (options?.directory ?? DEFAULT_DIRECTORY).split("/").filter((p) => p.length > 0)
|
|
157
|
+
const dir = yield* tryAsync("open", undefined, async () => {
|
|
158
|
+
let d = await (options?.root ?? defaultRoot)()
|
|
159
|
+
for (const part of path) d = await d.getDirectoryHandle(part, { create: true })
|
|
160
|
+
return d
|
|
161
|
+
})
|
|
162
|
+
const FileHandle = (globalThis as { FileSystemFileHandle?: { prototype: object } }).FileSystemFileHandle
|
|
163
|
+
if (FileHandle !== undefined && !("createWritable" in FileHandle.prototype)) {
|
|
164
|
+
return yield* storeError(
|
|
165
|
+
"open",
|
|
166
|
+
Object.assign(new Error("FileSystemFileHandle.createWritable is not available (Safari before 26); use KeyValueStoreIndexedDb"), {
|
|
167
|
+
name: "NotSupportedError"
|
|
168
|
+
})
|
|
169
|
+
)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const read = <A>(method: string, convert: (file: File) => Promise<A>) => (key: string) =>
|
|
173
|
+
Effect.flatMap(nameOf(method, key), (name) =>
|
|
174
|
+
tryAsync(method, key, async () => {
|
|
175
|
+
let handle: FileSystemFileHandle
|
|
176
|
+
try {
|
|
177
|
+
handle = await dir.getFileHandle(name)
|
|
178
|
+
} catch (cause) {
|
|
179
|
+
if (isNotFound(cause)) return undefined
|
|
180
|
+
throw cause
|
|
181
|
+
}
|
|
182
|
+
try {
|
|
183
|
+
return await convert(await handle.getFile())
|
|
184
|
+
} catch (cause) {
|
|
185
|
+
if (isNotFound(cause)) return undefined // removed between the two calls
|
|
186
|
+
throw cause
|
|
187
|
+
}
|
|
188
|
+
}))
|
|
189
|
+
|
|
190
|
+
const removeName = async (name: string) => {
|
|
191
|
+
try {
|
|
192
|
+
await dir.removeEntry(name)
|
|
193
|
+
} catch (cause) {
|
|
194
|
+
if (!isNotFound(cause)) throw cause
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return KeyValueStore.make({
|
|
199
|
+
get: read("get", async (file) => decoder.decode(await file.arrayBuffer())),
|
|
200
|
+
getUint8Array: read("getUint8Array", async (file) => new Uint8Array(await file.arrayBuffer())),
|
|
201
|
+
set: (key, value) =>
|
|
202
|
+
Effect.flatMap(nameOf("set", key), (name) =>
|
|
203
|
+
tryAsync("set", key, async () => writeAtomic(await dir.getFileHandle(name, { create: true }), value))),
|
|
204
|
+
remove: (key) => Effect.flatMap(nameOf("remove", key), (name) => tryAsync("remove", key, () => removeName(name))),
|
|
205
|
+
has: (key) =>
|
|
206
|
+
Effect.flatMap(nameOf("has", key), (name) =>
|
|
207
|
+
tryAsync("has", key, async () => {
|
|
208
|
+
try {
|
|
209
|
+
await dir.getFileHandle(name)
|
|
210
|
+
return true
|
|
211
|
+
} catch (cause) {
|
|
212
|
+
if (isNotFound(cause)) return false
|
|
213
|
+
throw cause
|
|
214
|
+
}
|
|
215
|
+
})),
|
|
216
|
+
clear: tryAsync("clear", undefined, async () => {
|
|
217
|
+
for (const name of await listNames(dir)) await removeName(name)
|
|
218
|
+
}),
|
|
219
|
+
clearPrefix: (prefix) =>
|
|
220
|
+
tryAsync("clearPrefix", prefix, async () => {
|
|
221
|
+
for (const name of await listNames(dir)) if (decodeKey(name)!.startsWith(prefix)) await removeName(name)
|
|
222
|
+
}),
|
|
223
|
+
size: tryAsync("size", undefined, async () => (await listNames(dir)).length),
|
|
224
|
+
keys: tryAsync("keys", undefined, async () => (await listNames(dir)).map((name) => decodeKey(name)!))
|
|
225
|
+
})
|
|
226
|
+
})
|
|
227
|
+
|
|
228
|
+
/** `KeyValueStore` over OPFS. */
|
|
229
|
+
export const layer = (options?: Options): Layer.Layer<KeyValueStore.KeyValueStore, KeyValueStore.KeyValueStoreError> =>
|
|
230
|
+
Layer.effect(KeyValueStore.KeyValueStore, make(options))
|