diff --git a/docs/api-reference/avm-web-client.mdx b/docs/api-reference/avm-web-client.mdx index c09e7d4..2c8126d 100644 --- a/docs/api-reference/avm-web-client.mdx +++ b/docs/api-reference/avm-web-client.mdx @@ -27,6 +27,22 @@ import TOCInline from '@theme/TOCInline'; ## Methods +### `disable([params])` + +> Sends a request to remove the client from providers. + +#### Parameters + +| Name | Type | Required | Default | Description | +|--------|------------------------------------------|----------|---------|-------------------------------------------------------------------------| +| params | [`IDisableParams`](types#idisableparams) | no | - | Params that specify which provider,network and/or specific session IDs. | + +#### Returns + +| Type | Description | +|--------|-------------| +| `void` | - | + ### `discover([params])` > Sends a request to get information relating to available providers. This should be called before interacting with any providers to ensure networks and methods are supported. @@ -70,6 +86,17 @@ import TOCInline from '@theme/TOCInline'; | [`IAVMWebClientConfig`](types#iavmwebclientconfig) | The client's configuration. | +### `onDisable(listener)` + +> Listens to `disable` messages sent from providers. This will replace any previous set listeners. If null is supplied, the listener will be removed. + +#### Parameters + +| Name | Type | Required | Default | Description | +|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|----------|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------| +| listener | (`result`?: [`IDisableResult`](types#idisableresult) \| `null`, `error`?: [`IBaseError`](types#ibaseerror) \| `null`) => (`void` \| `Promise`) \| `null` | yes | - | The callback is called when a response message is received, or null to remove the listener. If the result was successful, the `error` parameter will be null. | + + ### `onDiscover(listener)` > Listens to `discover` messages sent from providers. This will replace any previous set listeners. If null is supplied, the listener will be removed. diff --git a/docs/api-reference/avm-web-provider.mdx b/docs/api-reference/avm-web-provider.mdx index 696fea5..4b51285 100644 --- a/docs/api-reference/avm-web-provider.mdx +++ b/docs/api-reference/avm-web-provider.mdx @@ -38,9 +38,25 @@ import TOCInline from '@theme/TOCInline'; |--------------------------------------------------------|-------------------------------| | [`IAVMWebProviderConfig`](types#iavmwebproviderconfig) | The provider's configuration. | +### `onDisable(listener)` + +> Listens to `disable` messages sent from clients. This will replace any previous set listeners. If null is supplied, the listener will be removed. + +#### Parameters + +| Name | Type | Required | Default | Description | +|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------|---------|----------------------------------------------------------------------------------------| +| listener | (`params`?: [`IDisableParams`](types#idisableparams)) => ([`IDisableResult`](types#idisableresult) \| [`Promise`](types#idiscoverresult)) \| `null` | yes | - | The listener to call when the request message is sent, or null to remove the listener. | + +#### Returns + +| Type | Description | +|--------|-------------| +| `void` | - | + ### `onDiscover(listener)` -> Listens to discover messages sent from clients. This will replace any previous set listeners. If null is supplied, the listener will be removed. +> Listens to `discover` messages sent from clients. This will replace any previous set listeners. If null is supplied, the listener will be removed. #### Parameters @@ -56,7 +72,7 @@ import TOCInline from '@theme/TOCInline'; ### `onEnable(listener)` -> Listens to enable messages sent from clients. This will replace any previous set listeners. If null is supplied, the listener will be removed. +> Listens to `enable` messages sent from clients. This will replace any previous set listeners. If null is supplied, the listener will be removed. #### Parameters diff --git a/docs/api-reference/types.mdx b/docs/api-reference/types.mdx index 61d27ad..4628444 100644 --- a/docs/api-reference/types.mdx +++ b/docs/api-reference/types.mdx @@ -48,10 +48,27 @@ This is the basic type for an error. For specific details on errors check out th ### `IAccount` -| Name | Type | Required | Default | Description | -|--------|----------|----------|---------|-----------------------------------------| -| addess | `string` | yes | - | The address of the account. | -| name | `string` | no | - | A human-readable name for this account. | +| Name | Type | Required | Default | Description | +|---------|----------|----------|---------|-----------------------------------------| +| address | `string` | yes | - | The address of the account. | +| name | `string` | no | - | A human-readable name for this account. | + +### `IDisableParams` + +| Name | Type | Required | Default | Description | +|-------------|------------|----------|---------|------------------------------------------------------------------------------| +| genesisHash | `string` | no | - | The unique identifier for the network that is the hash of the genesis block. | +| providerId | `string` | no | - | The ID of the provider. | +| sessionIds | `string[]` | no | - | A list of specific session IDs to remove. | + +### `IDisableResult` + +| Name | Type | Required | Default | Description | +|-------------|------------|----------|---------|------------------------------------------------------------------------------| +| genesisHash | `string` | yes | - | The unique identifier for the network that is the hash of the genesis block. | +| genesisId | `string` | yes | - | A human-readable identifier for the network. | +| providerId | `string` | yes | - | The ID of the provider. | +| sessionIds | `string[]` | no | - | A list of removed session IDs. | ### `IDiscoverParams` diff --git a/docs/clients/disabling-a-client.mdx b/docs/clients/disabling-a-client.mdx new file mode 100644 index 0000000..85f8d11 --- /dev/null +++ b/docs/clients/disabling-a-client.mdx @@ -0,0 +1,239 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import TOCInline from '@theme/TOCInline'; + +# Disabling A Client + + + +## Overview + +The disable method is not required for providers to implement. However, it is useful for providers that have a sessioning system in place when a client has previously called [`enable()`](../../api-reference/avm-web-client#enableparams). + +The aim of the disable method is for clients to request that these sessions be removed from the provider. + +## Disabling the client with all providers + +Assuming a client has been [enabled](enabling-a-client) with one or all providers, you can remove the client from all available providers by: + + + + +```js +// initialized client +client.onDisable((result, error) => { + if (error) { + console.error('error:', error); + + return; + } + + console.log(result); + /* + { + genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=', + genesisId: 'testnet-v1.0', + providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e', + } + */ +}); + +// broadcast a disable request +client.disable(); +``` + + + + +```typescript +import type { BaseARC0027Error, IDisableResult } from '@agoralabs-sh/avm-web-provider'; + +// initialized client +client.onDisable((result: IDisableResult: null, error: BaseARC0027Error | null) => { + if (error) { + console.error('error:', error); + + return; + } + + console.log(result); + /* + { + genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=', + genesisId: 'testnet-v1.0', + providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e', + } + */ +}); + +// broadcast a disable request +client.disable(); +``` + + + + +:::caution + +If any providers do not support the `disable` method, then a [`MethodNotSupportedError`](../../api-reference/errors#methodnotsupportederror) will be returned. + +::: + +## Disabling the client with a specific provider and network + +If you want to target a specific provider and network, you can simply pass the ID of the provider and the genesis hash of the network in the params: + + + + +```js +// initialized client +client.onDisable((result, error) => { + if (error) { + console.error('error:', error); + + return; + } + + console.log(result); + /* + genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=', + genesisId: 'testnet-v1.0', + providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e', + } + */ +}); + +// broadcast an disable request +client.disable({ + genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=', + providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e', +}); + ``` + + + + +```typescript +import type { BaseARC0027Error, IDisableResult } from '@agoralabs-sh/avm-web-provider'; + +const providerId: string = '02657eaf-be17-4efc-b0a4-19d654b2448e'; + +// initialized client +client.onEnable((result: IDisableResult: null, error: BaseARC0027Error | null) => { + if (error) { + console.error('error:', error); + + return; + } + + console.log(result); + /* + { + genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=', + genesisId: 'testnet-v1.0', + providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e', + } + */ +}); + +// broadcast an disable request +client.disable({ + genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=', + providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e', +}); +``` + + + + +:::caution + +If the network and the provider ID is specified, and the provider does not support the network, then a [`NetworkNotSupportedError`](../../api-reference/errors#networknotsupportederror) will be thrown. + +::: + +## Disabling a client for a specific session + +If you want to remove a specific session, you can provide the session ID(s) in the params: + + + + +```js +// initialized client +client.onDisable((result, error) => { + if (error) { + console.error('error:', error); + + return; + } + + console.log(result); + /* + { + genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=', + genesisId: 'testnet-v1.0', + providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e', + sessionIds: ['ab192498-0c63-4028-80fd-f148710611d8'], + } + */ +}); + +// broadcast an disable request +client.disable({ + sessionIds: ['ab192498-0c63-4028-80fd-f148710611d8'], +}); +``` + + + + +```typescript +import type { BaseARC0027Error, IDisableResult } from '@agoralabs-sh/avm-web-provider'; + +// initialized client +client.onEnable((result: IDisableResult: null, error: BaseARC0027Error | null) => { + if (error) { + console.error('error:', error); + + return; + } + + console.log(result); + /* + { + genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=', + genesisId: 'testnet-v1.0', + providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e', + sessionIds: ['ab192498-0c63-4028-80fd-f148710611d8'], + } + */ +}); + +// broadcast an disable request +client.disable({ + sessionIds: ['ab192498-0c63-4028-80fd-f148710611d8'], +}); +``` + + + diff --git a/docs/clients/enabling-a-client.mdx b/docs/clients/enabling-a-client.mdx index e9ce0dc..21d40cb 100644 --- a/docs/clients/enabling-a-client.mdx +++ b/docs/clients/enabling-a-client.mdx @@ -18,7 +18,7 @@ Before we can start interacting with a provider, we need ask the provider to ena :::note -It should be safe to call [`enable()`](../../api-reference/avm-web-client#enable) as many times as your client needs; the provider should assume this. +It should be safe to call [`enable()`](../../api-reference/avm-web-client#enableparams). as many times as your client needs; the provider should assume this. ::: diff --git a/docs/clients/index.md b/docs/clients/index.md index 5832233..ddcc3cd 100644 --- a/docs/clients/index.md +++ b/docs/clients/index.md @@ -3,3 +3,5 @@ * [Getting Started](clients/getting-started) * [Discover Providers](clients/discover-providers) * [Enabling A Client](clients/enabling-a-client) +* [Posting Transactions](clients/posting-transactions) +* [Disabling A Client](clients/disabling-a-client) diff --git a/docs/providers/index.md b/docs/providers/index.md index 98f049d..e03d790 100644 --- a/docs/providers/index.md +++ b/docs/providers/index.md @@ -3,3 +3,5 @@ * [Getting Started](providers/getting-started) * [Responding To Discover Requests](providers/responding-to-discover-requests) * [Responding To Enable Requests](providers/responding-to-enable-requests) +* [Responding To Disable Requests](providers/responding-to-disable-requests) +* [Responding To Enable Requests](providers/responding-to-post-transactions-requests) diff --git a/docs/providers/responding-to-disable-requests.mdx b/docs/providers/responding-to-disable-requests.mdx new file mode 100644 index 0000000..9fb85f7 --- /dev/null +++ b/docs/providers/responding-to-disable-requests.mdx @@ -0,0 +1,214 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import TOCInline from '@theme/TOCInline'; + +# Responding To Disable Requests + + + +## Overview + +Providers that implement a session for a client, a disable request can be called by a client that instructs the provider to remove the client's session. + +## Responding to an anonymous request + +For clients that have not specified a provider, it means the client would like to disable with all providers. Once our provider object has been initialized, we can simply listen to events and respond: + + + + +```js +// initialized provider +provider.onDisable((params) => { + if (!params || !params.providerId) { + // ... remove all sessions + + return { + genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=', + genesisId: 'testnet-v1.0', + providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e', + }; + } +}); +``` + + + + +```typescript +import type { IDisableParams } from '@agoralabs-sh/avm-web-provider'; + +// initialized provider +provider.onEnable((params?: IDisableParams) => { + if (!params || !params.providerId) { + // ... remove all sessions + + return { + genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=', + genesisId: 'testnet-v1.0', + providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e', + }; + } +}); +``` + + + + +:::note + +If no network or session IDs have been specified, you can assume all sessions for this client should be removed. + +::: + +## Responding to a specific provider and network request + +The `disable` request allows the client to specify the provider and the network. This is denoted in the supplied `params.providerId` and `params.genesisHash` parameters. Providers with the matching ID should respond: + + + + +```js +const { ARC0027NetworkNotSupportedError } = require('@agoralabs-sh/avm-web-provider'); + +const genesisHash = 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI='; +const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e'; + +// initialized provider +provider.onDisable((params) => { + if (!params || params.providerId === providerId) { + // if the genesis hash has been defined, it is recommended that you throw and error + if (param.genesisHash && param.genesisHash !== genesisHash) { + throw new ARC0027NetworkNotSupportedError({ + genesisHashes: [param.genesisHash], + providerId, + }); + } + + // ... remove all sessions for the network + + return { + genesisHash, + genesisId: 'testnet-v1.0', + providerId, + }; + } +}); +``` + + + + +```typescript +import type { ARC0027NetworkNotSupportedError, IDisableParams } from '@agoralabs-sh/avm-web-provider'; + +const genesisHash = 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI='; +const providerId: string = '02657eaf-be17-4efc-b0a4-19d654b2448e'; + +// initialized provider +provider.onDisable((params?: IDisableParams) => { + if (!params || params.providerId === providerId) { + // if the genesis hash has been defined, it is recommended that you throw and error + if (param.genesisHash && param.genesisHash !== genesisHash) { + throw new ARC0027NetworkNotSupportedError({ + genesisHashes: [param.genesisHash], + providerId, + }); + } + + // ... remove all sessions for the network + + return { + genesisHash, + genesisId: 'testnet-v1.0', + providerId, + }; + } +}); +``` + + + + +:::caution + +If the network and the provider ID is specified, and the provider does not support the network, then a [`NetworkNotSupportedError`](../../api-reference/errors#networknotsupportederror) should be thrown. + +::: + +## Responding to specific session IDs + +A requesting client can specify the particular session. This can be used instead of specifying the network, or if the provider supports multiple sessions. + + + + +```js +const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e'; +const sessionId = '2802dff6-930e-4f79-8f67-ba9d41e88cf8'; + +// initialized provider +provider.onDisable((params) => { + if (params && params.sessionIds.indexOf(sessionId) >= 0) { + // ... remove sessions specified in the session ids list + + return { + genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=', + genesisId: 'testnet-v1.0', + providerId, + sessionIds: [sessionId], + }; + } +}); +``` + + + + +```typescript +import type { IDisableParams } from '@agoralabs-sh/avm-web-provider'; + +const providerId: string = '02657eaf-be17-4efc-b0a4-19d654b2448e'; +const sessionId: string = '2802dff6-930e-4f79-8f67-ba9d41e88cf8'; + +// initialized provider +provider.onDisable((params?: IDisableParams) => { + if (params && params.sessionIds.includes(sessionId)) { + // ... remove sessions specified in the session ids list + + return { + genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=', + genesisId: 'testnet-v1.0', + providerId, + sessionIds: [sessionId], + }; + } +}); +``` + + + + +:::note + +It is recommended that when removing specific session IDs, only return the removed session IDs in the result. + +::: diff --git a/docs/scripts/sidebars.js b/docs/scripts/sidebars.js index add9735..1457941 100644 --- a/docs/scripts/sidebars.js +++ b/docs/scripts/sidebars.js @@ -11,6 +11,7 @@ const sidebars = { 'clients/discover-providers', 'clients/enabling-a-client', 'clients/posting-transactions', + 'clients/disabling-a-client', ], label: 'Clients', link: { @@ -24,6 +25,7 @@ const sidebars = { 'providers/getting-started', 'providers/responding-to-discover-requests', 'providers/responding-to-enable-requests', + 'providers/responding-to-disable-requests', 'providers/responding-to-post-transactions-requests', ], label: 'Providers', diff --git a/src/controllers/AVMWebClient.test.ts b/src/controllers/AVMWebClient.test.ts index d13c5eb..e8a91ab 100644 --- a/src/controllers/AVMWebClient.test.ts +++ b/src/controllers/AVMWebClient.test.ts @@ -13,6 +13,7 @@ import { ARC0027MethodNotSupportedError } from '@app/errors'; // types import { IAVMWebClientConfig, + IDisableResult, IDiscoverResult, IEnableResult, IPostTransactionsResult, @@ -64,6 +65,68 @@ describe(AVMWebClient.name, () => { }); }); + describe(`${AVMWebClient.name}#disable`, () => { + it('should return an error', (done) => { + // arrange + const expectedError: ARC0027MethodNotSupportedError = + new ARC0027MethodNotSupportedError({ + method: ARC0027MethodEnum.Disable, + providerId, + }); + + provider = AVMWebProvider.init(providerId); + client = AVMWebClient.init(); + + provider.onDisable(async () => await Promise.reject(expectedError)); + client.onDisable((result, error) => { + // assert + expect(result).toBeNull(); + expect(error).toEqual(expectedError); + + done(); + }); + + // act + client.disable(); + }); + + it('should return the removed sessions', (done) => { + // arrange + const genesisHash: string = randomBytes(32).toString('base64'); + const sessionIds: string[] = [ + '25a90d91-8a96-4828-8bd5-da40b5ad33ed', + '6d12962e-2d8d-450c-b32e-dd6f7dd11230', + 'c12424a1-789c-49c1-b6a4-226c3d575060', + ]; + const expectedResult: IDisableResult = { + genesisHash, + genesisId: 'jest-test-v1.0', + providerId, + sessionIds, + }; + + provider = AVMWebProvider.init(providerId); + client = AVMWebClient.init(); + + provider.onDisable(() => expectedResult); + client.onDisable((result, error) => { + // assert + expect(error).toBeNull(); + expect(result).toBeDefined(); + expect(result).toEqual(expectedResult); + + done(); + }); + + // act + client.disable({ + genesisHash, + providerId, + sessionIds, + }); + }); + }); + describe(`${AVMWebClient.name}#discover`, () => { it('should return the provider information', (done) => { // arrange diff --git a/src/controllers/AVMWebClient.ts b/src/controllers/AVMWebClient.ts index b3fa7ac..14a9fac 100644 --- a/src/controllers/AVMWebClient.ts +++ b/src/controllers/AVMWebClient.ts @@ -20,6 +20,8 @@ import { import type { IAVMWebClientConfig, IAVMWebClientInitOptions, + IDisableParams, + IDisableResult, IDiscoverParams, IDiscoverResult, IEnableParams, @@ -112,6 +114,7 @@ export default class AVMWebClient extends BaseController { // ensure we have a listener for the response and the request id is known if (listener && this.requestIds.includes(message.data.requestId)) { switch (message.data.reference) { + case `${createMessageReference(ARC0027MethodEnum.Disable, ARC0027MessageTypeEnum.Response)}`: case `${createMessageReference(ARC0027MethodEnum.Discover, ARC0027MessageTypeEnum.Response)}`: case `${createMessageReference(ARC0027MethodEnum.Enable, ARC0027MessageTypeEnum.Response)}`: case `${createMessageReference(ARC0027MethodEnum.PostTransactions, ARC0027MessageTypeEnum.Response)}`: @@ -145,6 +148,17 @@ export default class AVMWebClient extends BaseController { * public methods */ + /** + * Sends a request to remove the client from providers. + * @param {IDisableParams} params - [optional] params that specify which provider,network and/or specific session IDs. + */ + public disable(params?: IDisableParams): void { + return this.sendRequestMessage({ + method: ARC0027MethodEnum.Disable, + params, + }); + } + /** * Sends a request to get information relating to available providers. This should be called before interacting with * any providers to ensure networks and methods are supported. @@ -169,6 +183,28 @@ export default class AVMWebClient extends BaseController { }); } + /** + * Listens to `disable` messages sent from providers. This will replace any previous set listeners. If null is + * supplied, the listener will be removed. + * @param {TAVMWebClientListener | null} listener - callback that is called when a response message + * is received, or null to remove the listener. + */ + onDisable(listener: TAVMWebClientListener | null): void { + const responseReference: string = createMessageReference( + ARC0027MethodEnum.Disable, + ARC0027MessageTypeEnum.Response + ); + + // if the listener is null, delete it from the map + if (!listener) { + this.listeners.delete(responseReference); + + return; + } + + this.listeners.set(responseReference, listener); + } + /** * Listens to `discover` messages sent from providers. This will replace any previous set listeners. If null is * supplied, the listener will be removed. diff --git a/src/controllers/AVMWebProvider.test.ts b/src/controllers/AVMWebProvider.test.ts index c1d2681..7801336 100644 --- a/src/controllers/AVMWebProvider.test.ts +++ b/src/controllers/AVMWebProvider.test.ts @@ -52,6 +52,20 @@ describe(AVMWebProvider.name, () => { }); }); + describe(`${AVMWebProvider.name}#onDisable`, () => { + it('should receive the client request', (done) => { + // arrange + provider = AVMWebProvider.init(providerId); + client = AVMWebClient.init(); + + // assert + provider.onDisable(done); + + // act + client.disable(); + }); + }); + describe(`${AVMWebProvider.name}#onDiscover`, () => { it('should receive the client request', (done) => { // arrange diff --git a/src/controllers/AVMWebProvider.ts b/src/controllers/AVMWebProvider.ts index a7db4e6..8f90887 100644 --- a/src/controllers/AVMWebProvider.ts +++ b/src/controllers/AVMWebProvider.ts @@ -20,6 +20,8 @@ import { import type { IAVMWebProviderConfig, IAVMWebProviderInitOptions, + IDisableParams, + IDisableResult, IDiscoverParams, IDiscoverResult, IEnableParams, @@ -127,6 +129,9 @@ export default class AVMWebProvider extends BaseController | null} listener - the listener to call when the + * request message is sent, or null to remove the listener. + */ + onDisable( + listener: TAVMWebProviderListener | null + ): void { + const requestReference: string = createMessageReference( + ARC0027MethodEnum.Disable, + ARC0027MessageTypeEnum.Request + ); + + // if the listener is null, delete it from the map + if (!listener) { + this.listeners.delete(requestReference); + + return; + } + + this.listeners.set(requestReference, listener); + } + /** * Listens to `discover` messages sent from clients. This will replace any previous set listeners. If null is * supplied, the listener will be removed. diff --git a/src/types/IDisableParams.ts b/src/types/IDisableParams.ts new file mode 100644 index 0000000..51f2247 --- /dev/null +++ b/src/types/IDisableParams.ts @@ -0,0 +1,13 @@ +/** + * @property {string} genesisHash - [optional] the unique identifier for the network that is the hash of the genesis + * block. + * @property {string} providerId - [optional] a unique identifier for the provider. + * @property {string[]} sessionIds - [optional] a list of specific session IDs to remove. + */ +interface IDisableParams { + genesisHash?: string; + providerId?: string; + sessionIds?: string[]; +} + +export default IDisableParams; diff --git a/src/types/IDisableResult.ts b/src/types/IDisableResult.ts new file mode 100644 index 0000000..04103ad --- /dev/null +++ b/src/types/IDisableResult.ts @@ -0,0 +1,14 @@ +/** + * @property {string} genesisHash - the unique identifier for the network that is the hash of the genesis block. + * @property {string} genesisId - a human-readable identifier for the network. + * @property {string} providerId - a unique identifier for the provider. + * @property {string[]} sessionIds - [optional] a list of removed session IDs. + */ +interface IDisableResult { + genesisHash: string; + genesisId: string; + providerId: string; + sessionIds?: string[]; +} + +export default IDisableResult; diff --git a/src/types/TRequestParams.ts b/src/types/TRequestParams.ts index 847d1e4..0266570 100644 --- a/src/types/TRequestParams.ts +++ b/src/types/TRequestParams.ts @@ -1,8 +1,13 @@ // types +import type IDisableParams from './IDisableParams'; import type IDiscoverParams from './IDiscoverParams'; import type IEnableParams from './IEnableParams'; import type IPostTransactionsParams from './IPostTransactionsParams'; -type TRequestParams = IDiscoverParams | IEnableParams | IPostTransactionsParams; +type TRequestParams = + | IDisableParams + | IDiscoverParams + | IEnableParams + | IPostTransactionsParams; export default TRequestParams; diff --git a/src/types/TResponseResults.ts b/src/types/TResponseResults.ts index e9f2858..0637594 100644 --- a/src/types/TResponseResults.ts +++ b/src/types/TResponseResults.ts @@ -1,9 +1,11 @@ // types +import type IDisableResult from './IDisableResult'; import type IDiscoverResult from './IDiscoverResult'; import type IEnableResult from './IEnableResult'; import type IPostTransactionsResult from './IPostTransactionsResult'; type TResponseResults = + | IDisableResult | IDiscoverResult | IEnableResult | IPostTransactionsResult; diff --git a/src/types/index.ts b/src/types/index.ts index bbfc1b1..d340f23 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -5,6 +5,8 @@ export type { default as IAVMWebProviderConfig } from './IAVMWebProviderConfig'; export type { default as IAVMWebProviderInitOptions } from './IAVMWebProviderInitOptions'; export type { default as IBaseConfig } from './IBaseConfig'; export type { default as IBaseResponseMessage } from './IBaseResponseMessage'; +export type { default as IDisableParams } from './IDisableParams'; +export type { default as IDisableResult } from './IDisableResult'; export type { default as IDiscoverParams } from './IDiscoverParams'; export type { default as IDiscoverResult } from './IDiscoverResult'; export type { default as IEnableParams } from './IEnableParams';