Socket
Socket
Sign inDemoInstall

@liveblocks/client

Package Overview
Dependencies
Maintainers
2
Versions
379
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@liveblocks/client - npm Package Compare versions

Comparing version 0.2.1 to 0.3.0

lib/cjs/authentication.d.ts

62

lib/cjs/room.js
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -28,2 +47,3 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

const utils_1 = require("./utils");
const authentication_1 = __importStar(require("./authentication"));
const BACKOFF_RETRY_DELAYS = [

@@ -229,5 +249,4 @@ 250,

try {
const response = yield authorize(authEndpoint, name);
token = response.token;
actor = response.actor;
token = yield authentication_1.default(authEndpoint, name);
actor = authentication_1.parseToken(token).actor;
}

@@ -257,2 +276,3 @@ catch (er) {

state = types_1.RoomState.Default;
_users = {};
clearTimeout(retryTimeoutId);

@@ -375,37 +395,1 @@ _listeners.open = [];

exports.createRoom = createRoom;
function authorize(endpoint, room) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield fetch(endpoint, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
room,
}),
});
if (!res.ok) {
throw new AuthenticationError(`Authentication error. Liveblocks could not parse the response of your authentication "${endpoint}"`);
}
let authResponse = null;
try {
authResponse = yield res.json();
}
catch (er) {
throw new AuthenticationError(`Authentication error. Liveblocks could not parse the response of your authentication "${endpoint}"`);
}
if (typeof authResponse.token !== "string" ||
typeof authResponse.actor !== "number") {
throw new AuthenticationError(`Authentication error. Liveblocks could not parse the response of your authentication "${endpoint}"`);
}
return {
token: authResponse.token,
actor: authResponse.actor,
};
});
}
class AuthenticationError extends Error {
constructor(message) {
super(message);
}
}

@@ -13,6 +13,11 @@ import { RecordData, Record, List } from "./doc";

};
declare type AuthEndpointCallback = (room: string) => Promise<string>;
export declare type AuthEndpoint = string | AuthEndpointCallback;
export declare type ClientOptions = {
authEndpoint: string;
authEndpoint: AuthEndpoint;
liveblocksServer?: string;
};
export declare type AuthorizeResponse = {
token: string;
};
export declare type Room = {

@@ -19,0 +24,0 @@ connect(): void;

@@ -25,2 +25,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

import { remove } from "./utils";
import auth, { parseToken } from "./authentication";
const BACKOFF_RETRY_DELAYS = [

@@ -226,5 +227,4 @@ 250,

try {
const response = yield authorize(authEndpoint, name);
token = response.token;
actor = response.actor;
token = yield auth(authEndpoint, name);
actor = parseToken(token).actor;
}

@@ -254,2 +254,3 @@ catch (er) {

state = RoomState.Default;
_users = {};
clearTimeout(retryTimeoutId);

@@ -371,37 +372,1 @@ _listeners.open = [];

}
function authorize(endpoint, room) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield fetch(endpoint, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
room,
}),
});
if (!res.ok) {
throw new AuthenticationError(`Authentication error. Liveblocks could not parse the response of your authentication "${endpoint}"`);
}
let authResponse = null;
try {
authResponse = yield res.json();
}
catch (er) {
throw new AuthenticationError(`Authentication error. Liveblocks could not parse the response of your authentication "${endpoint}"`);
}
if (typeof authResponse.token !== "string" ||
typeof authResponse.actor !== "number") {
throw new AuthenticationError(`Authentication error. Liveblocks could not parse the response of your authentication "${endpoint}"`);
}
return {
token: authResponse.token,
actor: authResponse.actor,
};
});
}
class AuthenticationError extends Error {
constructor(message) {
super(message);
}
}

@@ -13,6 +13,11 @@ import { RecordData, Record, List } from "./doc";

};
declare type AuthEndpointCallback = (room: string) => Promise<string>;
export declare type AuthEndpoint = string | AuthEndpointCallback;
export declare type ClientOptions = {
authEndpoint: string;
authEndpoint: AuthEndpoint;
liveblocksServer?: string;
};
export declare type AuthorizeResponse = {
token: string;
};
export declare type Room = {

@@ -19,0 +24,0 @@ connect(): void;

{
"name": "@liveblocks/client",
"version": "0.2.1",
"version": "0.3.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "./lib/cjs/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc