Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ably/ably-js
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 288923fd558797ca59bc41c54cc8664d3f97f630
Choose a base ref
..
head repository: ably/ably-js
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 66ac29ad2d18b687508bb8ec862998f682c54df5
Choose a head ref
8 changes: 4 additions & 4 deletions scripts/moduleReport.js
Original file line number Diff line number Diff line change
@@ -7,10 +7,10 @@ const moduleNames = ['Rest', 'Crypto'];
const functions = {
generateRandomKey: ['Crypto'],
getDefaultCryptoParams: ['Crypto'],
messageFromEncoded: [],
messageFromEncodedWithCrypto: ['Crypto'],
messageFromEncodedArray: [],
messageFromEncodedArrayWithCrypto: ['Crypto'],
decodeMessage: [],
decodeEncryptedMessage: ['Crypto'],
decodeMessages: [],
decodeEncryptedMessages: ['Crypto'],
};

function formatBytes(bytes) {
3 changes: 1 addition & 2 deletions src/common/lib/types/message.ts
Original file line number Diff line number Diff line change
@@ -363,8 +363,7 @@ class Message {
return result;
}

// TODO we need to remove this method entirely from Message
static _Crypto: IUntypedCryptoStatic | null;
static _Crypto: IUntypedCryptoStatic | null = null;

static async fromEncoded(encoded: unknown, inputOptions?: API.Types.ChannelOptions): Promise<Message> {
return fromEncoded(this._Crypto, encoded, inputOptions);
3 changes: 0 additions & 3 deletions src/platform/web-noencryption/index.ts
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@
import { DefaultRest } from '../../common/lib/client/defaultrest';
import { DefaultRealtime } from '../../common/lib/client/defaultrealtime';
import Platform from '../../common/platform';
import Message from '../../common/lib/types/message';

// Platform Specific
import BufferUtils from '../web/lib/util/bufferutils';
@@ -23,8 +22,6 @@ Platform.Config = Config;
Platform.Transports = Transports;
Platform.WebStorage = WebStorage;

Message._Crypto = null;

Logger.initLogHandlers();

Platform.Defaults = getDefaults(PlatformDefaults);
3 changes: 2 additions & 1 deletion src/platform/web/index.ts
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import Message from '../../common/lib/types/message';
// Platform Specific
import BufferUtils from './lib/util/bufferutils';
// @ts-ignore
import { Crypto } from './modules/crypto';
import { createCryptoClass } from './lib/util/crypto';
import Http from './lib/util/http';
import Config from './config';
// @ts-ignore
@@ -24,6 +24,7 @@ Platform.Config = Config;
Platform.Transports = Transports;
Platform.WebStorage = WebStorage;

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

4 changes: 1 addition & 3 deletions src/platform/web/modules.ts
Original file line number Diff line number Diff line change
@@ -2,10 +2,10 @@
import BaseRest from '../../common/lib/client/baserest';
import BaseRealtime from '../../common/lib/client/baserealtime';
import Platform from '../../common/platform';
import Message from '../../common/lib/types/message';

// Platform Specific
import BufferUtils from './lib/util/bufferutils';
// @ts-ignore
import Http from './lib/util/http';
import Config from './config';
// @ts-ignore
@@ -21,8 +21,6 @@ Platform.Config = Config;
Platform.Transports = Transports;
Platform.WebStorage = WebStorage;

Message._Crypto = null;

Logger.initLogHandlers();

Platform.Defaults = getDefaults(PlatformDefaults);
8 changes: 4 additions & 4 deletions src/platform/web/modules/message.ts
Original file line number Diff line number Diff line change
@@ -4,18 +4,18 @@ import { fromEncoded, fromEncodedArray } from '../../../common/lib/types/message

// TODO explain the `as` and link to issue

export const messageFromEncoded = ((obj, options) => {
export const decodeMessage = ((obj, options) => {
return fromEncoded(null, obj, options);
}) as API.Types.MessageStatic['fromEncoded'];

export const messageFromEncodedWithCrypto = ((obj, options) => {
export const decodeEncryptedMessage = ((obj, options) => {
return fromEncoded(Crypto, obj, options);
}) as API.Types.MessageStatic['fromEncoded'];

export const messageFromEncodedArray = ((obj, options) => {
export const decodeMessages = ((obj, options) => {
return fromEncodedArray(null, obj, options);
}) as API.Types.MessageStatic['fromEncodedArray'];

export const messageFromEncodedArrayWithCrypto = ((obj, options) => {
export const decodeEncryptedMessages = ((obj, options) => {
return fromEncodedArray(Crypto, obj, options);
}) as API.Types.MessageStatic['fromEncodedArray'];