diff --git a/src/ldp/UnsecureWebSocketsProtocol.ts b/src/ldp/UnsecureWebSocketsProtocol.ts index 65df58142..40741a270 100644 --- a/src/ldp/UnsecureWebSocketsProtocol.ts +++ b/src/ldp/UnsecureWebSocketsProtocol.ts @@ -6,10 +6,10 @@ import { WebSocketHandler } from '../server/WebSocketHandler'; import { parseForwarded } from '../util/HeaderUtil'; import type { ResourceIdentifier } from './representation/ResourceIdentifier'; -const VERSION = 'solid/0.1.0-alpha'; +const VERSION = 'solid-0.1'; /** - * Implementation of Solid WebSockets API Spec solid/0.1.0-alpha + * Implementation of Solid WebSockets API Spec solid-0.1 * at https://github.com/solid/solid-spec/blob/master/api-websockets.md */ class WebSocketListener extends EventEmitter { @@ -30,7 +30,6 @@ class WebSocketListener extends EventEmitter { public start({ headers, socket }: HttpRequest): void { // Greet the client this.sendMessage('protocol', VERSION); - this.sendMessage('warning', 'Unstandardized protocol version, proceed with care'); // Verify the WebSocket protocol version const protocolHeader = headers['sec-websocket-protocol']; @@ -116,7 +115,7 @@ class WebSocketListener extends EventEmitter { /** * Provides live update functionality following - * the Solid WebSockets API Spec solid/0.1.0-alpha + * the Solid WebSockets API Spec solid-0.1 */ export class UnsecureWebSocketsProtocol extends WebSocketHandler { private readonly logger = getLoggerFor(this); diff --git a/test/integration/WebSocketsProtocol.test.ts b/test/integration/WebSocketsProtocol.test.ts index f8a7e3866..210af516a 100644 --- a/test/integration/WebSocketsProtocol.test.ts +++ b/test/integration/WebSocketsProtocol.test.ts @@ -49,7 +49,7 @@ describe('A server with the Solid WebSockets API behind a proxy', (): void => { const messages = new Array(); beforeAll(async(): Promise => { - client = new WebSocket(`ws://localhost:${port}`, [ 'solid/0.1.0-alpha' ], { headers }); + client = new WebSocket(`ws://localhost:${port}`, [ 'solid-0.1' ], { headers }); client.on('message', (message: string): any => messages.push(message)); await new Promise((resolve): any => client.on('open', resolve)); }); @@ -64,8 +64,7 @@ describe('A server with the Solid WebSockets API behind a proxy', (): void => { it('sends the protocol version.', (): void => { expect(messages).toEqual([ - 'protocol solid/0.1.0-alpha', - 'warning Unstandardized protocol version, proceed with care', + 'protocol solid-0.1', ]); }); diff --git a/test/unit/ldp/UnsecureWebSocketsProtocol.test.ts b/test/unit/ldp/UnsecureWebSocketsProtocol.test.ts index 0009b13e1..3fa182daa 100644 --- a/test/unit/ldp/UnsecureWebSocketsProtocol.test.ts +++ b/test/unit/ldp/UnsecureWebSocketsProtocol.test.ts @@ -22,7 +22,7 @@ describe('An UnsecureWebSocketsProtocol', (): void => { const upgradeRequest = { headers: { host: 'mypod.example', - 'sec-websocket-protocol': 'solid/0.1.0-alpha, other/1.0.0', + 'sec-websocket-protocol': 'solid-0.1, other/1.0.0', }, socket: { secure: true, @@ -36,9 +36,8 @@ describe('An UnsecureWebSocketsProtocol', (): void => { }); it('sends a protocol message.', (): void => { - expect(webSocket.messages).toHaveLength(2); - expect(webSocket.messages.shift()).toBe('protocol solid/0.1.0-alpha'); - expect(webSocket.messages.shift()).toBe('warning Unstandardized protocol version, proceed with care'); + expect(webSocket.messages).toHaveLength(1); + expect(webSocket.messages.shift()).toBe('protocol solid-0.1'); }); it('warns when receiving an unexpected message.', (): void => { @@ -146,9 +145,9 @@ describe('An UnsecureWebSocketsProtocol', (): void => { socket: {}, } as any as HttpRequest; await protocol.handle({ webSocket, upgradeRequest } as any); - expect(webSocket.messages).toHaveLength(3); + expect(webSocket.messages).toHaveLength(2); expect(webSocket.messages.pop()) - .toBe('warning Missing Sec-WebSocket-Protocol header, expected value \'solid/0.1.0-alpha\''); + .toBe('warning Missing Sec-WebSocket-Protocol header, expected value \'solid-0.1\''); expect(webSocket.close).toHaveBeenCalledTimes(0); }); @@ -161,8 +160,8 @@ describe('An UnsecureWebSocketsProtocol', (): void => { socket: {}, } as any as HttpRequest; await protocol.handle({ webSocket, upgradeRequest } as any); - expect(webSocket.messages).toHaveLength(3); - expect(webSocket.messages.pop()).toBe('error Client does not support protocol solid/0.1.0-alpha'); + expect(webSocket.messages).toHaveLength(2); + expect(webSocket.messages.pop()).toBe('error Client does not support protocol solid-0.1'); expect(webSocket.close).toHaveBeenCalledTimes(1); expect(webSocket.listenerCount('message')).toBe(0); expect(webSocket.listenerCount('close')).toBe(0); @@ -174,13 +173,13 @@ describe('An UnsecureWebSocketsProtocol', (): void => { const upgradeRequest = { headers: { forwarded: 'proto=https;host=other.example', - 'sec-websocket-protocol': 'solid/0.1.0-alpha', + 'sec-websocket-protocol': 'solid-0.1', }, socket: {}, } as any as HttpRequest; await protocol.handle({ webSocket, upgradeRequest } as any); webSocket.emit('message', 'sub https://other.example/protocol/foo'); - expect(webSocket.messages).toHaveLength(3); + expect(webSocket.messages).toHaveLength(2); expect(webSocket.messages.pop()).toBe('ack https://other.example/protocol/foo'); }); });