Skip to content

Commit

Permalink
Remove Platform.Crypto
Browse files Browse the repository at this point in the history
Unused as of 480aaa6.

Resolves #1396.

TODO can we make some stuff generic now? if not, update comments that
relate to it

(note that to see the correct bundle sizes you need to `build` first)
  • Loading branch information
lawrence-forooghian committed Aug 3, 2023
1 parent c189ce4 commit 288923f
Show file tree
Hide file tree
Showing 11 changed files with 8 additions and 21 deletions.
6 changes: 3 additions & 3 deletions src/common/lib/client/defaultrealtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { allCommonModules } from './modulesmap';
import * as Utils from '../util/utils';
import ConnectionManager from '../transport/connectionmanager';
import ProtocolMessage from '../types/protocolmessage';
import Platform from 'common/platform';
import { IUntypedCryptoStatic } from 'common/types/ICryptoStatic';

export class DefaultRealtime extends BaseRealtime {
constructor(options: ClientOptions) {
Expand All @@ -15,15 +15,15 @@ export class DefaultRealtime extends BaseRealtime {
static ConnectionManager = ConnectionManager;
static ProtocolMessage = ProtocolMessage;

private static _Crypto: typeof Platform.Crypto = null;
private static _Crypto: IUntypedCryptoStatic | null = null;
static get Crypto() {
if (this._Crypto === null) {
throw new Error('TODO');
}

return this._Crypto;
}
static set Crypto(newValue: typeof Platform.Crypto) {
static set Crypto(newValue: IUntypedCryptoStatic | null) {
this._Crypto = newValue;
}
}
6 changes: 3 additions & 3 deletions src/common/lib/client/defaultrest.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import BaseRest from './baserest';
import ClientOptions from '../../types/ClientOptions';
import { allCommonModules } from './modulesmap';
import Platform from 'common/platform';
import { IUntypedCryptoStatic } from 'common/types/ICryptoStatic';

export class DefaultRest extends BaseRest {
constructor(options: ClientOptions | string) {
super(options, { ...allCommonModules, Crypto: DefaultRest.Crypto ?? undefined });
}

private static _Crypto: typeof Platform.Crypto = null;
private static _Crypto: IUntypedCryptoStatic | null = null;
static get Crypto() {
if (this._Crypto === null) {
throw new Error('TODO');
}

return this._Crypto;
}
static set Crypto(newValue: typeof Platform.Crypto) {
static set Crypto(newValue: IUntypedCryptoStatic | null) {
this._Crypto = newValue;
}
}
7 changes: 0 additions & 7 deletions src/common/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import IBufferUtils from './types/IBufferUtils';
import Transport from './lib/transport/transport';
import * as WebBufferUtils from '../platform/web/lib/util/bufferutils';
import * as NodeBufferUtils from '../platform/nodejs/lib/util/bufferutils';
import { IUntypedCryptoStatic } from '../common/types/ICryptoStatic';

type Bufferlike = WebBufferUtils.Bufferlike | NodeBufferUtils.Bufferlike;
type BufferUtilsOutput = WebBufferUtils.Output | NodeBufferUtils.Output;
Expand All @@ -23,12 +22,6 @@ export default class Platform {
can in reality handle.
*/
static BufferUtils: IBufferUtils<Bufferlike, BufferUtilsOutput, ToBufferOutput>;
/*
We’d like this to be ICryptoStatic with the correct generic arguments,
but Platform doesn’t currently allow that, as described in the BufferUtils
comment above
*/
static Crypto: IUntypedCryptoStatic | null;
static Http: typeof IHttp;
static Transports: Array<(connectionManager: typeof ConnectionManager) => Transport>;
static Defaults: IDefaults;
Expand Down
1 change: 0 additions & 1 deletion src/platform/nativescript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import msgpack from '../web/lib/util/msgpack';

const Crypto = createCryptoClass(Config, BufferUtils);

Platform.Crypto = Crypto;
Platform.BufferUtils = BufferUtils;
Platform.Http = Http;
Platform.Config = Config;
Expand Down
1 change: 0 additions & 1 deletion src/platform/nodejs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import PlatformDefaults from './lib/util/defaults';

const Crypto = createCryptoClass(BufferUtils);

Platform.Crypto = Crypto;
Platform.BufferUtils = BufferUtils as typeof Platform.BufferUtils;
Platform.Http = Http;
Platform.Config = Config;
Expand Down
1 change: 0 additions & 1 deletion src/platform/react-native/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const Config = configFactory(BufferUtils);

const Crypto = createCryptoClass(Config, BufferUtils);

Platform.Crypto = Crypto;
Platform.BufferUtils = BufferUtils;
Platform.Http = Http;
Platform.Config = Config;
Expand Down
1 change: 0 additions & 1 deletion src/platform/web-noencryption/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import WebStorage from '../web/lib/util/webstorage';
import PlatformDefaults from '../web/lib/util/defaults';
import msgpack from '../web/lib/util/msgpack';

Platform.Crypto = null;
Platform.BufferUtils = BufferUtils;
Platform.Http = Http;
Platform.Config = Config;
Expand Down
1 change: 0 additions & 1 deletion src/platform/web/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import WebStorage from './lib/util/webstorage';
import PlatformDefaults from './lib/util/defaults';
import msgpack from './lib/util/msgpack';

Platform.Crypto = Crypto;
Platform.BufferUtils = BufferUtils;
Platform.Http = Http;
Platform.Config = Config;
Expand Down
1 change: 0 additions & 1 deletion src/platform/web/modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { getDefaults } from '../../common/lib/util/defaults';
import WebStorage from './lib/util/webstorage';
import PlatformDefaults from './lib/util/defaults';

Platform.Crypto = Crypto;
Platform.BufferUtils = BufferUtils;
Platform.Http = Http;
Platform.Config = Config;
Expand Down
2 changes: 1 addition & 1 deletion test/realtime/crypto.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, helper, async
var expect = chai.expect;
var loadTestData = helper.loadTestData;
var BufferUtils = Ably.Realtime.Platform.BufferUtils;
var Crypto = Ably.Realtime.Platform.Crypto;
var Crypto = Ably.Realtime.Crypto;
var Message = Ably.Realtime.Message;
var displayError = helper.displayError;
var testResourcesPath = helper.testResourcesPath;
Expand Down
2 changes: 1 addition & 1 deletion test/rest/presence.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, helper, async
var rest;
var cipherConfig;
var expect = chai.expect;
var Crypto = Ably.Realtime.Platform.Crypto;
var Crypto = Ably.Realtime.Crypto;
var BufferUtils = Ably.Realtime.Platform.BufferUtils;
var arrFind = helper.arrFind;

Expand Down

0 comments on commit 288923f

Please sign in to comment.