Skip to content

Commit

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

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)

TODO I don't think we actually need to do this
  • Loading branch information
lawrence-forooghian committed Aug 15, 2023
1 parent e92e722 commit 349cc38
Show file tree
Hide file tree
Showing 11 changed files with 9 additions and 26 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';

/**
`DefaultRealtime` is the class that the non tree-shakable version of the SDK exports as `Realtime`. It ensures that this version of the SDK includes all of the functionality which is optionally available in the tree-shakable version.
Expand All @@ -18,15 +18,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,7 +1,7 @@
import { BaseRest } from './baserest';
import ClientOptions from '../../types/ClientOptions';
import { allCommonModules } from './modulesmap';
import Platform from 'common/platform';
import { IUntypedCryptoStatic } from 'common/types/ICryptoStatic';

/**
`DefaultRest` is the class that the non tree-shakable version of the SDK exports as `Rest`. It ensures that this version of the SDK includes all of the functionality which is optionally available in the tree-shakable version.
Expand All @@ -11,15 +11,15 @@ export class DefaultRest extends BaseRest {
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 @@ -16,7 +16,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
4 changes: 1 addition & 3 deletions src/platform/web/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ import WebStorage from './lib/util/webstorage';
import PlatformDefaults from './lib/util/defaults';
import msgpack from './lib/util/msgpack';

const Crypto = createCryptoClass(Config, BufferUtils);

Platform.Crypto = Crypto;
Platform.BufferUtils = BufferUtils;
Platform.Http = Http;
Platform.Config = Config;
Platform.Transports = Transports;
Platform.WebStorage = WebStorage;

const Crypto = createCryptoClass(Config, BufferUtils);
[DefaultRest, DefaultRealtime].forEach((clientClass) => (clientClass.Crypto = Crypto));
Message._Crypto = Crypto;

Expand Down
4 changes: 0 additions & 4 deletions src/platform/web/modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import Platform from '../../common/platform';
// Platform Specific
import BufferUtils from './lib/util/bufferutils';
// @ts-ignore
import { createCryptoClass } from './lib/util/crypto';
import Http from './lib/util/http';
import Config from './config';
// @ts-ignore
Expand All @@ -16,9 +15,6 @@ import { getDefaults } from '../../common/lib/util/defaults';
import WebStorage from './lib/util/webstorage';
import PlatformDefaults from './lib/util/defaults';

const Crypto = createCryptoClass(Config, BufferUtils);

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 349cc38

Please sign in to comment.