diff --git a/README.md b/README.md index da62f12780..03c9c1e3bc 100644 --- a/README.md +++ b/README.md @@ -290,7 +290,7 @@ When a 128 bit or 256 bit key is provided to the library, the `data` attributes ```javascript // Generate a random 256-bit key for demonstration purposes (in // practice you need to create one and distribute it to clients yourselves) -Ably.Realtime.Platform.Crypto.generateRandomKey(function (err, key) { +Ably.Realtime.Crypto.generateRandomKey(function (err, key) { var channel = client.channels.get('channelName', { cipher: { key: key } }); channel.subscribe(function (message) { diff --git a/src/common/lib/client/rest.ts b/src/common/lib/client/rest.ts index 2f2051ca81..6f5182e9b5 100644 --- a/src/common/lib/client/rest.ts +++ b/src/common/lib/client/rest.ts @@ -240,8 +240,8 @@ class Rest { static Callbacks = Rest; static Platform = Platform; static Crypto?: typeof Platform.Crypto; - static Message?: typeof Message; - static PresenceMessage?: typeof PresenceMessage; + static Message = Message; + static PresenceMessage = PresenceMessage; } class Channels { diff --git a/src/common/types/platform-bufferutils.d.ts b/src/common/types/platform-bufferutils.d.ts deleted file mode 100644 index f4c020f797..0000000000 --- a/src/common/types/platform-bufferutils.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -declare module 'platform-bufferutils' { - export const base64CharSet: string; - export const hexCharSet: string; - export const isBuffer: (buffer: unknown) => buffer is Buffer | ArrayBuffer | DataView; - export const toBuffer: (buffer: Buffer | TypedArray) => Buffer; - export const toArrayBuffer: (buffer: Buffer) => ArrayBuffer; - export const base64Encode: (buffer: Buffer | TypedArray) => string; - export const base64Decode: (string: string) => Buffer; - export const hexEncode: (buffer: Buffer | TypedArray) => string; - export const hexDecode: (string: string) => Buffer; - export const utf8Encode: (string: string) => Buffer; - export const utf8Decode: (buffer: Buffer) => string; - export const bufferCompare: (buffer1: Buffer, buffer2: Buffer) => number; - export const byteLength: (buffer: Buffer | ArrayBuffer | DataView) => number; - export const typedArrayToBuffer: (typedArray: TypedArray) => Buffer; -} diff --git a/src/common/types/platform-crypto.d.ts b/src/common/types/platform-crypto.d.ts deleted file mode 100644 index cda5ea8153..0000000000 --- a/src/common/types/platform-crypto.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -declare module 'platform-crypto' { - export const getCipher: Function; -} diff --git a/src/common/types/platform-http.d.ts b/src/common/types/platform-http.d.ts deleted file mode 100644 index 81aca4b8b2..0000000000 --- a/src/common/types/platform-http.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -declare module 'platform-http' { - const Http: typeof import('./http').IHttp; - export default Http; -} diff --git a/src/common/types/platform-transports.d.ts b/src/common/types/platform-transports.d.ts deleted file mode 100644 index f892e727d1..0000000000 --- a/src/common/types/platform-transports.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -declare module 'platform-transports' { - type Transport = import('../lib/transport/transport').default; - type ConnectionManager = import('../lib/transport/connectionmanager').default; - const PlatformTransports: Array<(connectionManager: typeof ConnectionManager) => Transport>; - export default PlatformTransports; -} diff --git a/src/common/types/platform-webstorage.d.ts b/src/common/types/platform-webstorage.d.ts deleted file mode 100644 index 4900205188..0000000000 --- a/src/common/types/platform-webstorage.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -declare module 'platform-webstorage' { - export const get: typeof import('../../platform/web/lib/util/webstorage').get; - export const getSession: typeof import('../../platform/web/lib/util/webstorage').getSession; - export const set: typeof import('../../platform/web/lib/util/webstorage').set; - export const setSession: typeof import('../../platform/web/lib/util/webstorage').setSession; - export const remove: typeof import('../../platform/web/lib/util/webstorage').remove; - export const removeSession: typeof import('../../platform/web/lib/util/webstorage').removeSession; -} diff --git a/src/platform/nativescript/index.ts b/src/platform/nativescript/index.ts index 9ca1e47d44..9457b30c12 100644 --- a/src/platform/nativescript/index.ts +++ b/src/platform/nativescript/index.ts @@ -14,13 +14,10 @@ import Config from './config'; import Transports from '../web/lib/transport'; import Logger from '../../common/lib/util/logger'; import { getDefaults } from '../../common/lib/util/defaults'; -import ConnectionManager from '../../common/lib/transport/connectionmanager'; // @ts-ignore import WebStorage from './lib/util/webstorage'; import PlatformDefaults from '../web/lib/util/defaults'; import msgpack from '../web/lib/util/msgpack'; -import Message from 'common/lib/types/message'; -import PresenceMessage from 'common/lib/types/presencemessage'; Platform.Crypto = Crypto; Platform.BufferUtils = BufferUtils; @@ -32,14 +29,6 @@ Platform.WebStorage = WebStorage; Rest.Crypto = Crypto; Realtime.Crypto = Crypto; -Rest.Message = Message; -Realtime.Message = Message; - -Rest.PresenceMessage = PresenceMessage; -Realtime.PresenceMessage = PresenceMessage; - -Realtime.ConnectionManager = ConnectionManager; - Logger.initLogHandlers(); Platform.Defaults = getDefaults(PlatformDefaults); diff --git a/src/platform/nodejs/index.ts b/src/platform/nodejs/index.ts index 2b05e01e5c..9460725ab3 100644 --- a/src/platform/nodejs/index.ts +++ b/src/platform/nodejs/index.ts @@ -13,10 +13,7 @@ import Config from './config'; import Transports from './lib/transport'; import Logger from '../../common/lib/util/logger'; import { getDefaults } from '../../common/lib/util/defaults'; -import ConnectionManager from '../../common/lib/transport/connectionmanager'; import PlatformDefaults from './lib/util/defaults'; -import Message from 'common/lib/types/message'; -import PresenceMessage from 'common/lib/types/presencemessage'; Platform.Crypto = Crypto; Platform.BufferUtils = BufferUtils; @@ -28,14 +25,6 @@ Platform.WebStorage = null; Rest.Crypto = Crypto; Realtime.Crypto = Crypto; -Rest.Message = Message; -Realtime.Message = Message; - -Rest.PresenceMessage = PresenceMessage; -Realtime.PresenceMessage = PresenceMessage; - -Realtime.ConnectionManager = ConnectionManager; - Logger.initLogHandlers(); Platform.Defaults = getDefaults(PlatformDefaults); diff --git a/src/platform/react-native/index.ts b/src/platform/react-native/index.ts index 210c7005a5..b304d7fcef 100644 --- a/src/platform/react-native/index.ts +++ b/src/platform/react-native/index.ts @@ -13,12 +13,9 @@ import Config from './config'; import Transports from '../web/lib/transport'; import Logger from '../../common/lib/util/logger'; import { getDefaults } from '../../common/lib/util/defaults'; -import ConnectionManager from '../../common/lib/transport/connectionmanager'; import WebStorage from '../web/lib/util/webstorage'; import PlatformDefaults from '../web/lib/util/defaults'; import msgpack from '../web/lib/util/msgpack'; -import Message from 'common/lib/types/message'; -import PresenceMessage from 'common/lib/types/presencemessage'; Platform.Crypto = Crypto; Platform.BufferUtils = BufferUtils; @@ -30,14 +27,6 @@ Platform.WebStorage = WebStorage; Rest.Crypto = Crypto; Realtime.Crypto = Crypto; -Rest.Message = Message; -Realtime.Message = Message; - -Rest.PresenceMessage = PresenceMessage; -Realtime.PresenceMessage = PresenceMessage; - -Realtime.ConnectionManager = ConnectionManager; - Logger.initLogHandlers(); Platform.Defaults = getDefaults(PlatformDefaults); diff --git a/src/platform/web-noencryption/index.ts b/src/platform/web-noencryption/index.ts index 62c7620784..0b5f275886 100644 --- a/src/platform/web-noencryption/index.ts +++ b/src/platform/web-noencryption/index.ts @@ -12,12 +12,9 @@ import Config from '../web/config'; import Transports from '../web/lib/transport'; import Logger from '../../common/lib/util/logger'; import { getDefaults } from '../../common/lib/util/defaults'; -import ConnectionManager from '../../common/lib/transport/connectionmanager'; import WebStorage from '../web/lib/util/webstorage'; import PlatformDefaults from '../web/lib/util/defaults'; import msgpack from '../web/lib/util/msgpack'; -import Message from 'common/lib/types/message'; -import PresenceMessage from 'common/lib/types/presencemessage'; Platform.Crypto = null; Platform.BufferUtils = BufferUtils; @@ -26,16 +23,8 @@ Platform.Config = Config; Platform.Transports = Transports; Platform.WebStorage = WebStorage; -Rest.Crypto = Crypto; -Realtime.Crypto = Crypto; - -Rest.Message = Message; -Realtime.Message = Message; - -Rest.PresenceMessage = PresenceMessage; -Realtime.PresenceMessage = PresenceMessage; - -Realtime.ConnectionManager = ConnectionManager; +Rest.Crypto = null; +Realtime.Crypto = null; Logger.initLogHandlers(); diff --git a/src/platform/web/index.ts b/src/platform/web/index.ts index d945aa3517..33b36e706b 100644 --- a/src/platform/web/index.ts +++ b/src/platform/web/index.ts @@ -13,12 +13,9 @@ import Config from './config'; import Transports from './lib/transport'; import Logger from '../../common/lib/util/logger'; import { getDefaults } from '../../common/lib/util/defaults'; -import ConnectionManager from '../../common/lib/transport/connectionmanager'; import WebStorage from './lib/util/webstorage'; import PlatformDefaults from './lib/util/defaults'; import msgpack from './lib/util/msgpack'; -import Message from 'common/lib/types/message'; -import PresenceMessage from 'common/lib/types/presencemessage'; Platform.Crypto = Crypto; Platform.BufferUtils = BufferUtils; @@ -30,14 +27,6 @@ Platform.WebStorage = WebStorage; Rest.Crypto = Crypto; Realtime.Crypto = Crypto; -Rest.Message = Message; -Realtime.Message = Message; - -Rest.PresenceMessage = PresenceMessage; -Realtime.PresenceMessage = PresenceMessage; - -Realtime.ConnectionManager = ConnectionManager; - Logger.initLogHandlers(); Platform.Defaults = getDefaults(PlatformDefaults);