@tezos-x/octez.connect-core 0.9.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/LICENCE +19 -0
- package/README.md +9 -0
- package/dist/cjs/MockAnalytics.d.ts +4 -0
- package/dist/cjs/MockAnalytics.js +11 -0
- package/dist/cjs/MockAnalytics.js.map +1 -0
- package/dist/cjs/MockWindow.d.ts +14 -0
- package/dist/cjs/MockWindow.js +39 -0
- package/dist/cjs/MockWindow.js.map +1 -0
- package/dist/cjs/Serializer.d.ts +19 -0
- package/dist/cjs/Serializer.js +48 -0
- package/dist/cjs/Serializer.js.map +1 -0
- package/dist/cjs/clients/beacon-client/BeaconClient.d.ts +53 -0
- package/dist/cjs/clients/beacon-client/BeaconClient.js +111 -0
- package/dist/cjs/clients/beacon-client/BeaconClient.js.map +1 -0
- package/dist/cjs/clients/beacon-client/BeaconClientOptions.d.ts +26 -0
- package/dist/cjs/clients/beacon-client/BeaconClientOptions.js +3 -0
- package/dist/cjs/clients/beacon-client/BeaconClientOptions.js.map +1 -0
- package/dist/cjs/clients/client/Client.d.ts +91 -0
- package/dist/cjs/clients/client/Client.js +241 -0
- package/dist/cjs/clients/client/Client.js.map +1 -0
- package/dist/cjs/clients/client/ClientOptions.d.ts +42 -0
- package/dist/cjs/clients/client/ClientOptions.js +3 -0
- package/dist/cjs/clients/client/ClientOptions.js.map +1 -0
- package/dist/cjs/constants.d.ts +4 -0
- package/dist/cjs/constants.js +8 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/debug.d.ts +2 -0
- package/dist/cjs/debug.js +17 -0
- package/dist/cjs/debug.js.map +1 -0
- package/dist/cjs/errors/AbortedBeaconError.d.ts +9 -0
- package/dist/cjs/errors/AbortedBeaconError.js +17 -0
- package/dist/cjs/errors/AbortedBeaconError.js.map +1 -0
- package/dist/cjs/errors/BeaconError.d.ts +15 -0
- package/dist/cjs/errors/BeaconError.js +19 -0
- package/dist/cjs/errors/BeaconError.js.map +1 -0
- package/dist/cjs/errors/BroadcastBeaconError.d.ts +9 -0
- package/dist/cjs/errors/BroadcastBeaconError.js +17 -0
- package/dist/cjs/errors/BroadcastBeaconError.js.map +1 -0
- package/dist/cjs/errors/EncryptionTypeNotSupportedBeaconError.d.ts +3 -0
- package/dist/cjs/errors/EncryptionTypeNotSupportedBeaconError.js +18 -0
- package/dist/cjs/errors/EncryptionTypeNotSupportedBeaconError.js.map +1 -0
- package/dist/cjs/errors/NetworkNotSupportedBeaconError.d.ts +9 -0
- package/dist/cjs/errors/NetworkNotSupportedBeaconError.js +17 -0
- package/dist/cjs/errors/NetworkNotSupportedBeaconError.js.map +1 -0
- package/dist/cjs/errors/NoAddressBeaconError.d.ts +9 -0
- package/dist/cjs/errors/NoAddressBeaconError.js +17 -0
- package/dist/cjs/errors/NoAddressBeaconError.js.map +1 -0
- package/dist/cjs/errors/NoPrivateKeyBeaconError.d.ts +9 -0
- package/dist/cjs/errors/NoPrivateKeyBeaconError.js +17 -0
- package/dist/cjs/errors/NoPrivateKeyBeaconError.js.map +1 -0
- package/dist/cjs/errors/NotGrantedBeaconError.d.ts +9 -0
- package/dist/cjs/errors/NotGrantedBeaconError.js +17 -0
- package/dist/cjs/errors/NotGrantedBeaconError.js.map +1 -0
- package/dist/cjs/errors/ParametersInvalidBeaconError.d.ts +9 -0
- package/dist/cjs/errors/ParametersInvalidBeaconError.js +17 -0
- package/dist/cjs/errors/ParametersInvalidBeaconError.js.map +1 -0
- package/dist/cjs/errors/SignatureTypeNotSupportedBeaconError.d.ts +9 -0
- package/dist/cjs/errors/SignatureTypeNotSupportedBeaconError.js +17 -0
- package/dist/cjs/errors/SignatureTypeNotSupportedBeaconError.js.map +1 -0
- package/dist/cjs/errors/TooManyOperationsBeaconError.d.ts +9 -0
- package/dist/cjs/errors/TooManyOperationsBeaconError.js +17 -0
- package/dist/cjs/errors/TooManyOperationsBeaconError.js.map +1 -0
- package/dist/cjs/errors/TransactionInvalidBeaconError.d.ts +14 -0
- package/dist/cjs/errors/TransactionInvalidBeaconError.js +22 -0
- package/dist/cjs/errors/TransactionInvalidBeaconError.js.map +1 -0
- package/dist/cjs/errors/UnknownBeaconError.d.ts +9 -0
- package/dist/cjs/errors/UnknownBeaconError.js +17 -0
- package/dist/cjs/errors/UnknownBeaconError.js.map +1 -0
- package/dist/cjs/errors/get-error.d.ts +8 -0
- package/dist/cjs/errors/get-error.js +53 -0
- package/dist/cjs/errors/get-error.js.map +1 -0
- package/dist/cjs/index.d.ts +53 -0
- package/dist/cjs/index.js +90 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/managers/AccountManager.d.ts +18 -0
- package/dist/cjs/managers/AccountManager.js +73 -0
- package/dist/cjs/managers/AccountManager.js.map +1 -0
- package/dist/cjs/managers/AppMetadataManager.d.ts +16 -0
- package/dist/cjs/managers/AppMetadataManager.js +57 -0
- package/dist/cjs/managers/AppMetadataManager.js.map +1 -0
- package/dist/cjs/managers/PeerManager.d.ts +18 -0
- package/dist/cjs/managers/PeerManager.js +61 -0
- package/dist/cjs/managers/PeerManager.js.map +1 -0
- package/dist/cjs/managers/PermissionManager.d.ts +17 -0
- package/dist/cjs/managers/PermissionManager.js +64 -0
- package/dist/cjs/managers/PermissionManager.js.map +1 -0
- package/dist/cjs/managers/PermissionValidator.d.ts +16 -0
- package/dist/cjs/managers/PermissionValidator.js +58 -0
- package/dist/cjs/managers/PermissionValidator.js.map +1 -0
- package/dist/cjs/managers/StorageManager.d.ts +18 -0
- package/dist/cjs/managers/StorageManager.js +72 -0
- package/dist/cjs/managers/StorageManager.js.map +1 -0
- package/dist/cjs/migrations/migrate-0.7.0.d.ts +20 -0
- package/dist/cjs/migrations/migrate-0.7.0.js +44 -0
- package/dist/cjs/migrations/migrate-0.7.0.js.map +1 -0
- package/dist/cjs/migrations/migrations.d.ts +2 -0
- package/dist/cjs/migrations/migrations.js +44 -0
- package/dist/cjs/migrations/migrations.js.map +1 -0
- package/dist/cjs/storage/ChromeStorage.d.ts +19 -0
- package/dist/cjs/storage/ChromeStorage.js +76 -0
- package/dist/cjs/storage/ChromeStorage.js.map +1 -0
- package/dist/cjs/storage/IndexedDBStorage.d.ts +65 -0
- package/dist/cjs/storage/IndexedDBStorage.js +230 -0
- package/dist/cjs/storage/IndexedDBStorage.js.map +1 -0
- package/dist/cjs/storage/LocalStorage.d.ts +21 -0
- package/dist/cjs/storage/LocalStorage.js +92 -0
- package/dist/cjs/storage/LocalStorage.js.map +1 -0
- package/dist/cjs/storage/StorageValidator.d.ts +12 -0
- package/dist/cjs/storage/StorageValidator.js +110 -0
- package/dist/cjs/storage/StorageValidator.js.map +1 -0
- package/dist/cjs/storage/WCStorage.d.ts +15 -0
- package/dist/cjs/storage/WCStorage.js +84 -0
- package/dist/cjs/storage/WCStorage.js.map +1 -0
- package/dist/cjs/storage/getStorage.d.ts +5 -0
- package/dist/cjs/storage/getStorage.js +34 -0
- package/dist/cjs/storage/getStorage.js.map +1 -0
- package/dist/cjs/transports/Transport.d.ts +85 -0
- package/dist/cjs/transports/Transport.js +171 -0
- package/dist/cjs/transports/Transport.js.map +1 -0
- package/dist/cjs/transports/clients/ClientEvents.d.ts +6 -0
- package/dist/cjs/transports/clients/ClientEvents.js +3 -0
- package/dist/cjs/transports/clients/ClientEvents.js.map +1 -0
- package/dist/cjs/transports/clients/CommunicationClient.d.ts +47 -0
- package/dist/cjs/transports/clients/CommunicationClient.js +86 -0
- package/dist/cjs/transports/clients/CommunicationClient.js.map +1 -0
- package/dist/cjs/transports/clients/MessageBasedClient.d.ts +56 -0
- package/dist/cjs/transports/clients/MessageBasedClient.js +109 -0
- package/dist/cjs/transports/clients/MessageBasedClient.js.map +1 -0
- package/dist/cjs/utils/Logger.d.ts +33 -0
- package/dist/cjs/utils/Logger.js +98 -0
- package/dist/cjs/utils/Logger.js.map +1 -0
- package/dist/cjs/utils/assert-never.d.ts +6 -0
- package/dist/cjs/utils/assert-never.js +14 -0
- package/dist/cjs/utils/assert-never.js.map +1 -0
- package/dist/cjs/utils/get-account-identifier.d.ts +10 -0
- package/dist/cjs/utils/get-account-identifier.js +36 -0
- package/dist/cjs/utils/get-account-identifier.js.map +1 -0
- package/dist/cjs/utils/get-sender-id.d.ts +8 -0
- package/dist/cjs/utils/get-sender-id.js +31 -0
- package/dist/cjs/utils/get-sender-id.js.map +1 -0
- package/dist/cjs/utils/multi-tab-channel.d.ts +17 -0
- package/dist/cjs/utils/multi-tab-channel.js +85 -0
- package/dist/cjs/utils/multi-tab-channel.js.map +1 -0
- package/dist/esm/MockAnalytics.d.ts +4 -0
- package/dist/esm/MockAnalytics.js +7 -0
- package/dist/esm/MockAnalytics.js.map +1 -0
- package/dist/esm/MockWindow.d.ts +14 -0
- package/dist/esm/MockWindow.js +35 -0
- package/dist/esm/MockWindow.js.map +1 -0
- package/dist/esm/Serializer.d.ts +19 -0
- package/dist/esm/Serializer.js +31 -0
- package/dist/esm/Serializer.js.map +1 -0
- package/dist/esm/clients/beacon-client/BeaconClient.d.ts +53 -0
- package/dist/esm/clients/beacon-client/BeaconClient.js +103 -0
- package/dist/esm/clients/beacon-client/BeaconClient.js.map +1 -0
- package/dist/esm/clients/beacon-client/BeaconClientOptions.d.ts +26 -0
- package/dist/esm/clients/beacon-client/BeaconClientOptions.js +2 -0
- package/dist/esm/clients/beacon-client/BeaconClientOptions.js.map +1 -0
- package/dist/esm/clients/client/Client.d.ts +91 -0
- package/dist/esm/clients/client/Client.js +198 -0
- package/dist/esm/clients/client/Client.js.map +1 -0
- package/dist/esm/clients/client/ClientOptions.d.ts +42 -0
- package/dist/esm/clients/client/ClientOptions.js +2 -0
- package/dist/esm/clients/client/ClientOptions.js.map +1 -0
- package/dist/esm/constants.d.ts +4 -0
- package/dist/esm/constants.js +5 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/debug.d.ts +2 -0
- package/dist/esm/debug.js +12 -0
- package/dist/esm/debug.js.map +1 -0
- package/dist/esm/errors/AbortedBeaconError.d.ts +9 -0
- package/dist/esm/errors/AbortedBeaconError.js +13 -0
- package/dist/esm/errors/AbortedBeaconError.js.map +1 -0
- package/dist/esm/errors/BeaconError.d.ts +15 -0
- package/dist/esm/errors/BeaconError.js +17 -0
- package/dist/esm/errors/BeaconError.js.map +1 -0
- package/dist/esm/errors/BroadcastBeaconError.d.ts +9 -0
- package/dist/esm/errors/BroadcastBeaconError.js +13 -0
- package/dist/esm/errors/BroadcastBeaconError.js.map +1 -0
- package/dist/esm/errors/EncryptionTypeNotSupportedBeaconError.d.ts +3 -0
- package/dist/esm/errors/EncryptionTypeNotSupportedBeaconError.js +18 -0
- package/dist/esm/errors/EncryptionTypeNotSupportedBeaconError.js.map +1 -0
- package/dist/esm/errors/NetworkNotSupportedBeaconError.d.ts +9 -0
- package/dist/esm/errors/NetworkNotSupportedBeaconError.js +13 -0
- package/dist/esm/errors/NetworkNotSupportedBeaconError.js.map +1 -0
- package/dist/esm/errors/NoAddressBeaconError.d.ts +9 -0
- package/dist/esm/errors/NoAddressBeaconError.js +13 -0
- package/dist/esm/errors/NoAddressBeaconError.js.map +1 -0
- package/dist/esm/errors/NoPrivateKeyBeaconError.d.ts +9 -0
- package/dist/esm/errors/NoPrivateKeyBeaconError.js +13 -0
- package/dist/esm/errors/NoPrivateKeyBeaconError.js.map +1 -0
- package/dist/esm/errors/NotGrantedBeaconError.d.ts +9 -0
- package/dist/esm/errors/NotGrantedBeaconError.js +13 -0
- package/dist/esm/errors/NotGrantedBeaconError.js.map +1 -0
- package/dist/esm/errors/ParametersInvalidBeaconError.d.ts +9 -0
- package/dist/esm/errors/ParametersInvalidBeaconError.js +13 -0
- package/dist/esm/errors/ParametersInvalidBeaconError.js.map +1 -0
- package/dist/esm/errors/SignatureTypeNotSupportedBeaconError.d.ts +9 -0
- package/dist/esm/errors/SignatureTypeNotSupportedBeaconError.js +13 -0
- package/dist/esm/errors/SignatureTypeNotSupportedBeaconError.js.map +1 -0
- package/dist/esm/errors/TooManyOperationsBeaconError.d.ts +9 -0
- package/dist/esm/errors/TooManyOperationsBeaconError.js +13 -0
- package/dist/esm/errors/TooManyOperationsBeaconError.js.map +1 -0
- package/dist/esm/errors/TransactionInvalidBeaconError.d.ts +14 -0
- package/dist/esm/errors/TransactionInvalidBeaconError.js +19 -0
- package/dist/esm/errors/TransactionInvalidBeaconError.js.map +1 -0
- package/dist/esm/errors/UnknownBeaconError.d.ts +9 -0
- package/dist/esm/errors/UnknownBeaconError.js +13 -0
- package/dist/esm/errors/UnknownBeaconError.js.map +1 -0
- package/dist/esm/errors/get-error.d.ts +8 -0
- package/dist/esm/errors/get-error.js +49 -0
- package/dist/esm/errors/get-error.js.map +1 -0
- package/dist/esm/index.d.ts +53 -0
- package/dist/esm/index.js +67 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/managers/AccountManager.d.ts +18 -0
- package/dist/esm/managers/AccountManager.js +44 -0
- package/dist/esm/managers/AccountManager.js.map +1 -0
- package/dist/esm/managers/AppMetadataManager.d.ts +16 -0
- package/dist/esm/managers/AppMetadataManager.js +32 -0
- package/dist/esm/managers/AppMetadataManager.js.map +1 -0
- package/dist/esm/managers/PeerManager.d.ts +18 -0
- package/dist/esm/managers/PeerManager.js +34 -0
- package/dist/esm/managers/PeerManager.js.map +1 -0
- package/dist/esm/managers/PermissionManager.d.ts +17 -0
- package/dist/esm/managers/PermissionManager.js +37 -0
- package/dist/esm/managers/PermissionManager.js.map +1 -0
- package/dist/esm/managers/PermissionValidator.d.ts +16 -0
- package/dist/esm/managers/PermissionValidator.js +43 -0
- package/dist/esm/managers/PermissionValidator.js.map +1 -0
- package/dist/esm/managers/StorageManager.d.ts +18 -0
- package/dist/esm/managers/StorageManager.js +50 -0
- package/dist/esm/managers/StorageManager.js.map +1 -0
- package/dist/esm/migrations/migrate-0.7.0.d.ts +20 -0
- package/dist/esm/migrations/migrate-0.7.0.js +31 -0
- package/dist/esm/migrations/migrate-0.7.0.js.map +1 -0
- package/dist/esm/migrations/migrations.d.ts +2 -0
- package/dist/esm/migrations/migrations.js +31 -0
- package/dist/esm/migrations/migrations.js.map +1 -0
- package/dist/esm/storage/ChromeStorage.d.ts +19 -0
- package/dist/esm/storage/ChromeStorage.js +53 -0
- package/dist/esm/storage/ChromeStorage.js.map +1 -0
- package/dist/esm/storage/IndexedDBStorage.d.ts +65 -0
- package/dist/esm/storage/IndexedDBStorage.js +212 -0
- package/dist/esm/storage/IndexedDBStorage.js.map +1 -0
- package/dist/esm/storage/LocalStorage.d.ts +21 -0
- package/dist/esm/storage/LocalStorage.js +70 -0
- package/dist/esm/storage/LocalStorage.js.map +1 -0
- package/dist/esm/storage/StorageValidator.d.ts +12 -0
- package/dist/esm/storage/StorageValidator.js +96 -0
- package/dist/esm/storage/StorageValidator.js.map +1 -0
- package/dist/esm/storage/WCStorage.d.ts +15 -0
- package/dist/esm/storage/WCStorage.js +64 -0
- package/dist/esm/storage/WCStorage.js.map +1 -0
- package/dist/esm/storage/getStorage.d.ts +5 -0
- package/dist/esm/storage/getStorage.js +21 -0
- package/dist/esm/storage/getStorage.js.map +1 -0
- package/dist/esm/transports/Transport.d.ts +85 -0
- package/dist/esm/transports/Transport.js +149 -0
- package/dist/esm/transports/Transport.js.map +1 -0
- package/dist/esm/transports/clients/ClientEvents.d.ts +6 -0
- package/dist/esm/transports/clients/ClientEvents.js +2 -0
- package/dist/esm/transports/clients/ClientEvents.js.map +1 -0
- package/dist/esm/transports/clients/CommunicationClient.d.ts +47 -0
- package/dist/esm/transports/clients/CommunicationClient.js +63 -0
- package/dist/esm/transports/clients/CommunicationClient.js.map +1 -0
- package/dist/esm/transports/clients/MessageBasedClient.d.ts +56 -0
- package/dist/esm/transports/clients/MessageBasedClient.js +83 -0
- package/dist/esm/transports/clients/MessageBasedClient.js.map +1 -0
- package/dist/esm/utils/Logger.d.ts +33 -0
- package/dist/esm/utils/Logger.js +92 -0
- package/dist/esm/utils/Logger.js.map +1 -0
- package/dist/esm/utils/assert-never.d.ts +6 -0
- package/dist/esm/utils/assert-never.js +11 -0
- package/dist/esm/utils/assert-never.js.map +1 -0
- package/dist/esm/utils/get-account-identifier.d.ts +10 -0
- package/dist/esm/utils/get-account-identifier.js +23 -0
- package/dist/esm/utils/get-account-identifier.js.map +1 -0
- package/dist/esm/utils/get-sender-id.d.ts +8 -0
- package/dist/esm/utils/get-sender-id.js +18 -0
- package/dist/esm/utils/get-sender-id.js.map +1 -0
- package/dist/esm/utils/multi-tab-channel.d.ts +17 -0
- package/dist/esm/utils/multi-tab-channel.js +66 -0
- package/dist/esm/utils/multi-tab-channel.js.map +1 -0
- package/package.json +46 -0
package/LICENCE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2021 Papers AG
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
14
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
15
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
16
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
17
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
18
|
+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
|
19
|
+
OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# `@tezos-x/octez.connect-core`
|
|
2
|
+
|
|
3
|
+
This package is part of the `@tezos-x/octez.connect-sdk` project. [Read more](https://github.com/trilitech/octez.connect-sdk)
|
|
4
|
+
|
|
5
|
+
## Introduction
|
|
6
|
+
|
|
7
|
+
This package contains internal methods that are used by both the dApp and wallet client.
|
|
8
|
+
|
|
9
|
+
Unless you need to import types from this package, you probably don't need to add it to your project.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MockAnalytics = void 0;
|
|
4
|
+
class MockAnalytics {
|
|
5
|
+
track(_trigger, _section, _label, _data) {
|
|
6
|
+
// console.log('##### TRACK', trigger, section, label, data)
|
|
7
|
+
// noop
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.MockAnalytics = MockAnalytics;
|
|
11
|
+
//# sourceMappingURL=MockAnalytics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MockAnalytics.js","sourceRoot":"","sources":["../../src/MockAnalytics.ts"],"names":[],"mappings":";;;AAEA,MAAa,aAAa;IACxB,KAAK,CACH,QAA2B,EAC3B,QAAgB,EAChB,MAAc,EACd,KAA2B;QAE3B,4DAA4D;QAC5D,OAAO;IACT,CAAC;CACF;AAVD,sCAUC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type Callback = (message: unknown) => void;
|
|
2
|
+
/**
|
|
3
|
+
* A mock for postmessage if run in node.js environment
|
|
4
|
+
*/
|
|
5
|
+
declare let windowRef: {
|
|
6
|
+
postMessage: (message: string | Record<string, unknown>, _target?: string) => void;
|
|
7
|
+
addEventListener: (_name: string, eventCallback: Callback) => void;
|
|
8
|
+
removeEventListener: (_name: string, eventCallback: Callback) => void;
|
|
9
|
+
location: {
|
|
10
|
+
origin: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
declare const clearMockWindowState: () => void;
|
|
14
|
+
export { windowRef, clearMockWindowState };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.clearMockWindowState = exports.windowRef = void 0;
|
|
4
|
+
const cbs = [(_) => undefined];
|
|
5
|
+
/**
|
|
6
|
+
* A mock for postmessage if run in node.js environment
|
|
7
|
+
*/
|
|
8
|
+
let windowRef = {
|
|
9
|
+
postMessage: (message, _target) => {
|
|
10
|
+
console.log('GOT MOCK POST MESSAGE', message);
|
|
11
|
+
cbs.forEach((callbackElement) => {
|
|
12
|
+
callbackElement({ data: message });
|
|
13
|
+
});
|
|
14
|
+
},
|
|
15
|
+
addEventListener: (_name, eventCallback) => {
|
|
16
|
+
cbs.push(eventCallback);
|
|
17
|
+
},
|
|
18
|
+
removeEventListener: (_name, eventCallback) => {
|
|
19
|
+
cbs.splice(cbs.indexOf((element) => element === eventCallback), 1);
|
|
20
|
+
},
|
|
21
|
+
location: {
|
|
22
|
+
origin: '*'
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
exports.windowRef = windowRef;
|
|
26
|
+
try {
|
|
27
|
+
if (typeof window !== 'undefined') {
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
+
exports.windowRef = windowRef = window;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch (windowError) {
|
|
33
|
+
console.log(`not defined: ${windowError}`);
|
|
34
|
+
}
|
|
35
|
+
const clearMockWindowState = () => {
|
|
36
|
+
cbs.length = 0;
|
|
37
|
+
};
|
|
38
|
+
exports.clearMockWindowState = clearMockWindowState;
|
|
39
|
+
//# sourceMappingURL=MockWindow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MockWindow.js","sourceRoot":"","sources":["../../src/MockWindow.ts"],"names":[],"mappings":";;;AAEA,MAAM,GAAG,GAAe,CAAC,CAAC,CAAU,EAAQ,EAAE,CAAC,SAAS,CAAC,CAAA;AAEzD;;GAEG;AACH,IAAI,SAAS,GAAG;IACd,WAAW,EAAE,CAAC,OAAyC,EAAE,OAAgB,EAAQ,EAAE;QACjF,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE,OAAO,CAAC,CAAA;QAC7C,GAAG,CAAC,OAAO,CAAC,CAAC,eAAyB,EAAE,EAAE;YACxC,eAAe,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;QACpC,CAAC,CAAC,CAAA;IACJ,CAAC;IACD,gBAAgB,EAAE,CAAC,KAAa,EAAE,aAAuB,EAAQ,EAAE;QACjE,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;IACzB,CAAC;IACD,mBAAmB,EAAE,CAAC,KAAa,EAAE,aAAuB,EAAQ,EAAE;QACpE,GAAG,CAAC,MAAM,CACR,GAAG,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,KAAK,aAAa,CAAC,EACnD,CAAC,CACF,CAAA;IACH,CAAC;IACD,QAAQ,EAAE;QACR,MAAM,EAAE,GAAG;KACZ;CACF,CAAA;AAeQ,8BAAS;AAblB,IAAI,CAAC;IACH,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,8DAA8D;QAC9D,oBAAA,SAAS,GAAG,MAAa,CAAA;IAC3B,CAAC;AACH,CAAC;AAAC,OAAO,WAAW,EAAE,CAAC;IACrB,OAAO,CAAC,GAAG,CAAC,gBAAgB,WAAW,EAAE,CAAC,CAAA;AAC5C,CAAC;AAED,MAAM,oBAAoB,GAAe,GAAS,EAAE;IAClD,GAAG,CAAC,MAAM,GAAG,CAAC,CAAA;AAChB,CAAC,CAAA;AAEmB,oDAAoB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internalapi
|
|
3
|
+
*
|
|
4
|
+
* The Serializer is used to serialize / deserialize JSON objects and encode them with bs58check
|
|
5
|
+
*/
|
|
6
|
+
export declare class Serializer {
|
|
7
|
+
/**
|
|
8
|
+
* Serialize and bs58check encode an object
|
|
9
|
+
*
|
|
10
|
+
* @param message JSON object to serialize
|
|
11
|
+
*/
|
|
12
|
+
serialize(message: unknown): Promise<string>;
|
|
13
|
+
/**
|
|
14
|
+
* Deserialize a bs58check encoded string
|
|
15
|
+
*
|
|
16
|
+
* @param encoded String to be deserialized
|
|
17
|
+
*/
|
|
18
|
+
deserialize(encoded: string): Promise<unknown>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Serializer = void 0;
|
|
13
|
+
const bs58check_1 = require("bs58check");
|
|
14
|
+
/**
|
|
15
|
+
* @internalapi
|
|
16
|
+
*
|
|
17
|
+
* The Serializer is used to serialize / deserialize JSON objects and encode them with bs58check
|
|
18
|
+
*/
|
|
19
|
+
class Serializer {
|
|
20
|
+
/**
|
|
21
|
+
* Serialize and bs58check encode an object
|
|
22
|
+
*
|
|
23
|
+
* @param message JSON object to serialize
|
|
24
|
+
*/
|
|
25
|
+
serialize(message) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
const str = JSON.stringify(message);
|
|
28
|
+
return bs58check_1.default.encode(Buffer.from(str));
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Deserialize a bs58check encoded string
|
|
33
|
+
*
|
|
34
|
+
* @param encoded String to be deserialized
|
|
35
|
+
*/
|
|
36
|
+
deserialize(encoded) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
if (typeof encoded !== 'string') {
|
|
39
|
+
throw new Error('Encoded payload needs to be a string');
|
|
40
|
+
}
|
|
41
|
+
const decodedBytes = bs58check_1.default.decode(encoded);
|
|
42
|
+
const jsonString = Buffer.from(decodedBytes).toString('utf8');
|
|
43
|
+
return JSON.parse(jsonString);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.Serializer = Serializer;
|
|
48
|
+
//# sourceMappingURL=Serializer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Serializer.js","sourceRoot":"","sources":["../../src/Serializer.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAiC;AAEjC;;;;GAIG;AACH,MAAa,UAAU;IACrB;;;;OAIG;IACU,SAAS,CAAC,OAAgB;;YACrC,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;YAEnC,OAAO,mBAAS,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;QAC3C,CAAC;KAAA;IAED;;;;OAIG;IACU,WAAW,CAAC,OAAe;;YACtC,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;gBAChC,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAA;YACzD,CAAC;YAED,MAAM,YAAY,GAAG,mBAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;YAC9C,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;YAC7D,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;QAC/B,CAAC;KAAA;CACF;AA1BD,gCA0BC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ExposedPromise } from '@tezos-x/octez.connect-utils';
|
|
2
|
+
import { AnalyticsInterface, Storage } from '@tezos-x/octez.connect-types';
|
|
3
|
+
import { BeaconClientOptions } from './BeaconClientOptions';
|
|
4
|
+
import { KeyPair } from '@stablelib/ed25519';
|
|
5
|
+
/**
|
|
6
|
+
* @internalapi
|
|
7
|
+
*
|
|
8
|
+
* The beacon client is an abstract client that handles everything that is shared between all other clients.
|
|
9
|
+
* Specifically, it handles managing the beaconId and and the local keypair.
|
|
10
|
+
*/
|
|
11
|
+
export declare abstract class BeaconClient {
|
|
12
|
+
/**
|
|
13
|
+
* The name of the client
|
|
14
|
+
*/
|
|
15
|
+
readonly name: string;
|
|
16
|
+
/**
|
|
17
|
+
* The URL of the dApp Icon. This can be used to display the icon of the dApp on in the wallet
|
|
18
|
+
*/
|
|
19
|
+
readonly iconUrl?: string;
|
|
20
|
+
/**
|
|
21
|
+
* The URL of the dApp.
|
|
22
|
+
*/
|
|
23
|
+
readonly appUrl?: string;
|
|
24
|
+
/** The beaconId is a public key that is used to identify one specific application (dapp or wallet).
|
|
25
|
+
* This is used inside a message to specify the sender, for example.
|
|
26
|
+
*/
|
|
27
|
+
protected _beaconId: ExposedPromise<string>;
|
|
28
|
+
get beaconId(): Promise<string>;
|
|
29
|
+
protected storage: Storage;
|
|
30
|
+
protected analytics: AnalyticsInterface;
|
|
31
|
+
/**
|
|
32
|
+
* The local keypair that is used for the communication encryption
|
|
33
|
+
*/
|
|
34
|
+
protected _keyPair: ExposedPromise<KeyPair>;
|
|
35
|
+
protected get keyPair(): Promise<KeyPair>;
|
|
36
|
+
constructor(config: BeaconClientOptions);
|
|
37
|
+
/**
|
|
38
|
+
* This resets the SDK. After using this method, this instance is no longer usable. You will have to instanciate a new client.
|
|
39
|
+
*/
|
|
40
|
+
destroy(): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* This method initializes the SDK by setting some values in the storage and generating a keypair.
|
|
43
|
+
*/
|
|
44
|
+
protected initSDK(): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Removes all beacon values from the storage.
|
|
47
|
+
*/
|
|
48
|
+
private removeBeaconEntriesFromStorage;
|
|
49
|
+
/**
|
|
50
|
+
* This method tries to load the seed from storage, if it doesn't exist, a new one will be created and persisted.
|
|
51
|
+
*/
|
|
52
|
+
private loadOrCreateBeaconSecret;
|
|
53
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.BeaconClient = void 0;
|
|
13
|
+
const octez_connect_utils_1 = require("@tezos-x/octez.connect-utils");
|
|
14
|
+
const octez_connect_utils_2 = require("@tezos-x/octez.connect-utils");
|
|
15
|
+
const octez_connect_types_1 = require("@tezos-x/octez.connect-types");
|
|
16
|
+
const constants_1 = require("../../constants");
|
|
17
|
+
const MockWindow_1 = require("../../MockWindow");
|
|
18
|
+
const MockAnalytics_1 = require("../../MockAnalytics");
|
|
19
|
+
/**
|
|
20
|
+
* @internalapi
|
|
21
|
+
*
|
|
22
|
+
* The beacon client is an abstract client that handles everything that is shared between all other clients.
|
|
23
|
+
* Specifically, it handles managing the beaconId and and the local keypair.
|
|
24
|
+
*/
|
|
25
|
+
class BeaconClient {
|
|
26
|
+
get beaconId() {
|
|
27
|
+
return this._beaconId.promise;
|
|
28
|
+
}
|
|
29
|
+
get keyPair() {
|
|
30
|
+
return this._keyPair.promise;
|
|
31
|
+
}
|
|
32
|
+
constructor(config) {
|
|
33
|
+
var _a, _b;
|
|
34
|
+
/** The beaconId is a public key that is used to identify one specific application (dapp or wallet).
|
|
35
|
+
* This is used inside a message to specify the sender, for example.
|
|
36
|
+
*/
|
|
37
|
+
this._beaconId = new octez_connect_utils_1.ExposedPromise();
|
|
38
|
+
/**
|
|
39
|
+
* The local keypair that is used for the communication encryption
|
|
40
|
+
*/
|
|
41
|
+
this._keyPair = new octez_connect_utils_1.ExposedPromise();
|
|
42
|
+
if (!config.name) {
|
|
43
|
+
throw new Error('Name not set');
|
|
44
|
+
}
|
|
45
|
+
if (!config.storage) {
|
|
46
|
+
throw new Error('Storage not set');
|
|
47
|
+
}
|
|
48
|
+
this.name = config.name;
|
|
49
|
+
this.iconUrl = config.iconUrl;
|
|
50
|
+
this.appUrl = (_a = config.appUrl) !== null && _a !== void 0 ? _a : MockWindow_1.windowRef.location.origin;
|
|
51
|
+
this.storage = config.storage;
|
|
52
|
+
this.analytics = (_b = config.analytics) !== null && _b !== void 0 ? _b : new MockAnalytics_1.MockAnalytics();
|
|
53
|
+
// TODO: This is a temporary "workaround" to prevent users from creating multiple Client instances
|
|
54
|
+
if (MockWindow_1.windowRef.beaconCreatedClientInstance) {
|
|
55
|
+
console.error('[OCTEZ.CONNECT] It looks like you created multiple octez.connect SDK Client instances. This can lead to problems. Only create one instance and re-use it everywhere.');
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
;
|
|
59
|
+
MockWindow_1.windowRef.beaconCreatedClientInstance = true;
|
|
60
|
+
}
|
|
61
|
+
this.initSDK().catch(console.error);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* This resets the SDK. After using this method, this instance is no longer usable. You will have to instanciate a new client.
|
|
65
|
+
*/
|
|
66
|
+
destroy() {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
yield this.removeBeaconEntriesFromStorage();
|
|
69
|
+
MockWindow_1.windowRef.beaconCreatedClientInstance = false;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* This method initializes the SDK by setting some values in the storage and generating a keypair.
|
|
74
|
+
*/
|
|
75
|
+
initSDK() {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
this.storage.set(octez_connect_types_1.StorageKey.BEACON_SDK_VERSION, constants_1.SDK_VERSION).catch(console.error);
|
|
78
|
+
this.loadOrCreateBeaconSecret().catch(console.error);
|
|
79
|
+
return this.keyPair.then((keyPair) => {
|
|
80
|
+
this._beaconId.resolve((0, octez_connect_utils_2.toHex)(keyPair.publicKey));
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Removes all beacon values from the storage.
|
|
86
|
+
*/
|
|
87
|
+
removeBeaconEntriesFromStorage() {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
const allKeys = Object.values(octez_connect_types_1.StorageKey);
|
|
90
|
+
yield Promise.all(allKeys.map((key) => this.storage.delete(key)));
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* This method tries to load the seed from storage, if it doesn't exist, a new one will be created and persisted.
|
|
95
|
+
*/
|
|
96
|
+
loadOrCreateBeaconSecret() {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
const storageValue = yield this.storage.get(octez_connect_types_1.StorageKey.BEACON_SDK_SECRET_SEED);
|
|
99
|
+
if (storageValue && typeof storageValue === 'string') {
|
|
100
|
+
this._keyPair.resolve(yield (0, octez_connect_utils_2.getKeypairFromSeed)(storageValue));
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
const key = yield (0, octez_connect_utils_2.generateGUID)();
|
|
104
|
+
yield this.storage.set(octez_connect_types_1.StorageKey.BEACON_SDK_SECRET_SEED, key);
|
|
105
|
+
this._keyPair.resolve(yield (0, octez_connect_utils_2.getKeypairFromSeed)(key));
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.BeaconClient = BeaconClient;
|
|
111
|
+
//# sourceMappingURL=BeaconClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BeaconClient.js","sourceRoot":"","sources":["../../../../src/clients/beacon-client/BeaconClient.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AnalyticsInterface, Storage } from '@tezos-x/octez.connect-types';
|
|
2
|
+
/**
|
|
3
|
+
* @internalapi
|
|
4
|
+
*/
|
|
5
|
+
export interface BeaconClientOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Name of the application
|
|
8
|
+
*/
|
|
9
|
+
name: string;
|
|
10
|
+
/**
|
|
11
|
+
* A URL to the icon of the application
|
|
12
|
+
*/
|
|
13
|
+
iconUrl?: string;
|
|
14
|
+
/**
|
|
15
|
+
* A URL to the website of the application
|
|
16
|
+
*/
|
|
17
|
+
appUrl?: string;
|
|
18
|
+
/**
|
|
19
|
+
* The storage that will be used by the SDK
|
|
20
|
+
*/
|
|
21
|
+
storage: Storage;
|
|
22
|
+
/**
|
|
23
|
+
* The analytics instance that will be used by the SDK
|
|
24
|
+
*/
|
|
25
|
+
analytics?: AnalyticsInterface;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BeaconClientOptions.js","sourceRoot":"","sources":["../../../../src/clients/beacon-client/BeaconClientOptions.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { ExposedPromise } from '@tezos-x/octez.connect-utils';
|
|
2
|
+
import { ConnectionContext, TransportType, TransportStatus, BeaconBaseMessage, AccountInfo, PeerInfo, AppMetadata, BeaconRequestMessage, BeaconMessageWrapper, NodeDistributions } from '@tezos-x/octez.connect-types';
|
|
3
|
+
import { BeaconClient } from '../beacon-client/BeaconClient';
|
|
4
|
+
import { AccountManager } from '../../managers/AccountManager';
|
|
5
|
+
import { ClientOptions } from './ClientOptions';
|
|
6
|
+
import { Transport } from '../../transports/Transport';
|
|
7
|
+
/**
|
|
8
|
+
* @internalapi
|
|
9
|
+
*
|
|
10
|
+
* This abstract class handles the a big part of the logic that is shared between the dapp and wallet client.
|
|
11
|
+
* For example, it selects and manages the transport and accounts.
|
|
12
|
+
*/
|
|
13
|
+
export declare abstract class Client extends BeaconClient {
|
|
14
|
+
protected readonly accountManager: AccountManager;
|
|
15
|
+
protected handleResponse: (_event: BeaconRequestMessage | BeaconMessageWrapper<BeaconBaseMessage>, connectionInfo: ConnectionContext) => void;
|
|
16
|
+
/**
|
|
17
|
+
* How many requests can be sent after another
|
|
18
|
+
*/
|
|
19
|
+
protected readonly rateLimit: number;
|
|
20
|
+
/**
|
|
21
|
+
* The time window in seconds in which the "rateLimit" is checked
|
|
22
|
+
*/
|
|
23
|
+
protected readonly rateLimitWindowInSeconds: number;
|
|
24
|
+
/**
|
|
25
|
+
* Stores the times when requests have been made to determine if the rate limit has been reached
|
|
26
|
+
*/
|
|
27
|
+
protected requestCounter: number[];
|
|
28
|
+
protected readonly matrixNodes: NodeDistributions;
|
|
29
|
+
private transportListeners;
|
|
30
|
+
protected _transport: ExposedPromise<Transport<any>>;
|
|
31
|
+
protected get transport(): Promise<Transport<any>>;
|
|
32
|
+
/**
|
|
33
|
+
* Returns the connection status of the Client
|
|
34
|
+
*/
|
|
35
|
+
get connectionStatus(): TransportStatus;
|
|
36
|
+
/**
|
|
37
|
+
* Returns whether or not the transaport is ready
|
|
38
|
+
*/
|
|
39
|
+
get ready(): Promise<void>;
|
|
40
|
+
constructor(config: ClientOptions);
|
|
41
|
+
protected cleanup(): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Return all locally known accounts
|
|
44
|
+
*/
|
|
45
|
+
getAccounts(): Promise<AccountInfo[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Return the account by ID
|
|
48
|
+
* @param accountIdentifier The ID of an account
|
|
49
|
+
*/
|
|
50
|
+
getAccount(accountIdentifier: string): Promise<AccountInfo | undefined>;
|
|
51
|
+
/**
|
|
52
|
+
* Remove the account by ID
|
|
53
|
+
* @param accountIdentifier The ID of an account
|
|
54
|
+
*/
|
|
55
|
+
removeAccount(accountIdentifier: string): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Remove all locally stored accounts
|
|
58
|
+
*/
|
|
59
|
+
removeAllAccounts(): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Add a new request (current timestamp) to the pending requests, remove old ones and check if we are above the limit
|
|
62
|
+
*/
|
|
63
|
+
addRequestAndCheckIfRateLimited(): Promise<boolean>;
|
|
64
|
+
/**
|
|
65
|
+
* This method initializes the client. It will check if the connection should be established to a
|
|
66
|
+
* browser extension or if the P2P transport should be used.
|
|
67
|
+
*
|
|
68
|
+
* @param transport A transport that can be provided by the user
|
|
69
|
+
*/
|
|
70
|
+
init(transport: Transport<any>): Promise<TransportType>;
|
|
71
|
+
/**
|
|
72
|
+
* Returns the metadata of this DApp
|
|
73
|
+
*/
|
|
74
|
+
getOwnAppMetadata(): Promise<AppMetadata>;
|
|
75
|
+
/**
|
|
76
|
+
* Return all known peers
|
|
77
|
+
*/
|
|
78
|
+
getPeers(): Promise<PeerInfo[]>;
|
|
79
|
+
/**
|
|
80
|
+
* Add a new peer to the known peers
|
|
81
|
+
* @param peer The new peer to add
|
|
82
|
+
*/
|
|
83
|
+
addPeer(peer: PeerInfo): Promise<void>;
|
|
84
|
+
destroy(): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* A "setter" for when the transport needs to be changed.
|
|
87
|
+
*/
|
|
88
|
+
protected setTransport(transport?: Transport<any>): Promise<void>;
|
|
89
|
+
protected addListener(transport: Transport<any>): Promise<void>;
|
|
90
|
+
protected sendDisconnectToPeer(peer: PeerInfo, transport?: Transport<any>): Promise<void>;
|
|
91
|
+
}
|