Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 0 additions & 82 deletions e2e/next-sandbox/pages/api/auth/legacy-token.ts

This file was deleted.

5 changes: 0 additions & 5 deletions e2e/next-sandbox/pages/auth/acc-token.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ export default function Home() {
with ID token
</Link>
</li>
<li>
<Link href={"/auth/secret-legacy?room=" + encodeURIComponent(text)}>
with legacy token
</Link>
</li>
</ul>
</div>
<div>
Expand Down
5 changes: 0 additions & 5 deletions e2e/next-sandbox/pages/auth/id-token.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ export default function Home() {
</Link>{" "}
👈
</li>
<li>
<Link href={"/auth/secret-legacy?room=" + encodeURIComponent(text)}>
with legacy token
</Link>
</li>
</ul>
</div>
<div>
Expand Down
5 changes: 0 additions & 5 deletions e2e/next-sandbox/pages/auth/pubkey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ export default function Home() {
with ID token
</Link>
</li>
<li>
<Link href={"/auth/secret-legacy?room=" + encodeURIComponent(text)}>
with legacy token
</Link>
</li>
</ul>
</div>
<div>
Expand Down
101 changes: 0 additions & 101 deletions e2e/next-sandbox/pages/auth/secret-legacy.tsx

This file was deleted.

5 changes: 0 additions & 5 deletions e2e/next-sandbox/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,6 @@ export default function Home() {
With public key
</Link>
</li>
<li>
<Link href="/auth/secret-legacy?room=e2e-modern-auth">
With legacy token
</Link>
</li>
<li>
<Link href="/auth/id-token?room=e2e-modern-auth">
With ID token
Expand Down
20 changes: 1 addition & 19 deletions packages/liveblocks-core/src/__tests__/_behaviors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@ import { ServerMsgCode } from "../protocol/ServerMsg";
import type { WebsocketCloseCodes } from "../types/IWebSocket";
import type { MockWebSocket } from "./_MockWebSocketServer";
import { MockWebSocketServer } from "./_MockWebSocketServer";
import {
makeAccessToken,
makeIDToken,
makeSecretLegacyToken,
serverMessage,
} from "./_utils";
import { makeAccessToken, makeIDToken, serverMessage } from "./_utils";

type AuthBehavior = () => AuthValue;
type SocketBehavior = (wss: MockWebSocketServer) => MockWebSocket;
Expand Down Expand Up @@ -84,7 +79,6 @@ export function defineBehavior(
export const AUTH_SUCCESS = ROUND_ROBIN(
ALWAYS_AUTH_WITH_ACCESS_TOKEN,
ALWAYS_AUTH_WITH_ID_TOKEN,
ALWAYS_AUTH_WITH_LEGACY_TOKEN(1),
ALWAYS_AUTH_WITH_PUBKEY
);

Expand All @@ -108,18 +102,6 @@ export function ALWAYS_AUTH_WITH_PUBKEY(): AuthValue {
};
}

export function ALWAYS_AUTH_WITH_LEGACY_TOKEN(
actor: number,
scopes: string[] = []
): () => AuthValue {
return () => {
return {
type: "secret",
token: makeParsed(makeSecretLegacyToken(actor, scopes)),
};
};
}

export function ALWAYS_AUTH_WITH_ID_TOKEN(): AuthValue {
return {
type: "secret",
Expand Down
30 changes: 3 additions & 27 deletions packages/liveblocks-core/src/__tests__/_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ import type { Json, JsonObject } from "../lib/Json";
import { makePosition } from "../lib/position";
import { Signal } from "../lib/signals";
import { deepClone } from "../lib/utils";
import type {
AccessToken,
IDToken,
LegacySecretToken,
} from "../protocol/AuthToken";
import type { AccessToken, IDToken } from "../protocol/AuthToken";
import { Permission, TokenKind } from "../protocol/AuthToken";
import type { BaseUserMeta } from "../protocol/BaseUserMeta";
import type { ClientMsg } from "../protocol/ClientMsg";
Expand All @@ -40,7 +36,7 @@ import { createRoom } from "../room";
import { WebsocketCloseCodes } from "../types/IWebSocket";
import type { LiveblocksError } from "../types/LiveblocksError";
import {
ALWAYS_AUTH_WITH_LEGACY_TOKEN,
ALWAYS_AUTH_WITH_ACCESS_TOKEN,
defineBehavior,
SOCKET_AUTOCONNECT_AND_ROOM_STATE,
} from "./_behaviors";
Expand All @@ -49,26 +45,6 @@ import { MockWebSocket } from "./_MockWebSocketServer";
import type { JsonStorageUpdate } from "./_updatesUtils";
import { serializeUpdateToJson } from "./_updatesUtils";

export function makeSecretLegacyToken(
actor: number,
scopes: string[]
): LegacySecretToken {
// NOTE: This is not the complete JWT token, but one that has enough fields
// to we can run the unit tests. The actual full shape of these JWT tokens is
// defined in the (private) backend in case you're interested, see
// https://github.com/liveblocks/liveblocks-cloudflare/blob/main/src/security.ts
return {
k: TokenKind.SECRET_LEGACY,
iat: Date.now() / 1000,
exp: Date.now() / 1000 + 60, // Valid for 1 minute
appId: "my-app",
roomId: "my-room",
id: "user1",
actor,
scopes,
};
}

export function makeAccessToken(): AccessToken {
return {
k: TokenKind.ACCESS_TOKEN,
Expand Down Expand Up @@ -159,7 +135,7 @@ export function prepareRoomWithStorage_loadWithDelay<
delay = 0
) {
const { wss, delegates } = defineBehavior(
ALWAYS_AUTH_WITH_LEGACY_TOKEN(actor, scopes),
ALWAYS_AUTH_WITH_ACCESS_TOKEN,
SOCKET_AUTOCONNECT_AND_ROOM_STATE(actor, scopes)
);

Expand Down
Loading
Loading