@liveblocks/core 3.13.3-rc1 → 3.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +44 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +44 -49
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6,7 +6,7 @@ var __export = (target, all) => {
|
|
|
6
6
|
|
|
7
7
|
// src/version.ts
|
|
8
8
|
var PKG_NAME = "@liveblocks/core";
|
|
9
|
-
var PKG_VERSION = "3.13.3
|
|
9
|
+
var PKG_VERSION = "3.13.3";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -3222,7 +3222,7 @@ var BACKOFF_DELAYS_SLOW = [2e3, 3e4, 6e4, 3e5];
|
|
|
3222
3222
|
var HEARTBEAT_INTERVAL = 3e4;
|
|
3223
3223
|
var PONG_TIMEOUT = 2e3;
|
|
3224
3224
|
var AUTH_TIMEOUT = 1e4;
|
|
3225
|
-
var SOCKET_CONNECT_TIMEOUT =
|
|
3225
|
+
var SOCKET_CONNECT_TIMEOUT = 2e4;
|
|
3226
3226
|
var StopRetrying = class extends Error {
|
|
3227
3227
|
constructor(reason) {
|
|
3228
3228
|
super(reason);
|
|
@@ -4167,41 +4167,6 @@ var TreePool = class {
|
|
|
4167
4167
|
}
|
|
4168
4168
|
};
|
|
4169
4169
|
|
|
4170
|
-
// src/protocol/AuthToken.ts
|
|
4171
|
-
var Permission = /* @__PURE__ */ ((Permission2) => {
|
|
4172
|
-
Permission2["Read"] = "room:read";
|
|
4173
|
-
Permission2["Write"] = "room:write";
|
|
4174
|
-
Permission2["PresenceWrite"] = "room:presence:write";
|
|
4175
|
-
Permission2["CommentsWrite"] = "comments:write";
|
|
4176
|
-
Permission2["CommentsRead"] = "comments:read";
|
|
4177
|
-
return Permission2;
|
|
4178
|
-
})(Permission || {});
|
|
4179
|
-
function canWriteStorage(scopes) {
|
|
4180
|
-
return scopes.includes("room:write" /* Write */);
|
|
4181
|
-
}
|
|
4182
|
-
function canComment(scopes) {
|
|
4183
|
-
return scopes.includes("comments:write" /* CommentsWrite */) || scopes.includes("room:write" /* Write */);
|
|
4184
|
-
}
|
|
4185
|
-
function isValidAuthTokenPayload(data) {
|
|
4186
|
-
return isPlainObject(data) && (data.k === "acc" /* ACCESS_TOKEN */ || data.k === "id" /* ID_TOKEN */ || data.k === "sec-legacy" /* SECRET_LEGACY */);
|
|
4187
|
-
}
|
|
4188
|
-
function parseAuthToken(rawTokenString) {
|
|
4189
|
-
const tokenParts = rawTokenString.split(".");
|
|
4190
|
-
if (tokenParts.length !== 3) {
|
|
4191
|
-
throw new Error("Authentication error: invalid JWT token");
|
|
4192
|
-
}
|
|
4193
|
-
const payload = tryParseJson(b64decode(tokenParts[1]));
|
|
4194
|
-
if (!(payload && isValidAuthTokenPayload(payload))) {
|
|
4195
|
-
throw new Error(
|
|
4196
|
-
"Authentication error: expected a valid token but did not get one. Hint: if you are using a callback, ensure the room is passed when creating the token. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientCallback"
|
|
4197
|
-
);
|
|
4198
|
-
}
|
|
4199
|
-
return {
|
|
4200
|
-
raw: rawTokenString,
|
|
4201
|
-
parsed: payload
|
|
4202
|
-
};
|
|
4203
|
-
}
|
|
4204
|
-
|
|
4205
4170
|
// src/ai.ts
|
|
4206
4171
|
var DEFAULT_REQUEST_TIMEOUT = 4e3;
|
|
4207
4172
|
function defineAiTool() {
|
|
@@ -4730,8 +4695,8 @@ function createAi(config) {
|
|
|
4730
4695
|
if (authValue.type === "secret") {
|
|
4731
4696
|
const token = authValue.token.parsed;
|
|
4732
4697
|
context.staticSessionInfoSig.set({
|
|
4733
|
-
userId: token.
|
|
4734
|
-
userInfo: token.
|
|
4698
|
+
userId: token.uid,
|
|
4699
|
+
userInfo: token.ui
|
|
4735
4700
|
});
|
|
4736
4701
|
} else {
|
|
4737
4702
|
context.staticSessionInfoSig.set({
|
|
@@ -5153,6 +5118,41 @@ function createReceivingToolInvocation(invocationId, name, partialArgsText = "")
|
|
|
5153
5118
|
};
|
|
5154
5119
|
}
|
|
5155
5120
|
|
|
5121
|
+
// src/protocol/AuthToken.ts
|
|
5122
|
+
var Permission = /* @__PURE__ */ ((Permission2) => {
|
|
5123
|
+
Permission2["Read"] = "room:read";
|
|
5124
|
+
Permission2["Write"] = "room:write";
|
|
5125
|
+
Permission2["PresenceWrite"] = "room:presence:write";
|
|
5126
|
+
Permission2["CommentsWrite"] = "comments:write";
|
|
5127
|
+
Permission2["CommentsRead"] = "comments:read";
|
|
5128
|
+
return Permission2;
|
|
5129
|
+
})(Permission || {});
|
|
5130
|
+
function canWriteStorage(scopes) {
|
|
5131
|
+
return scopes.includes("room:write" /* Write */);
|
|
5132
|
+
}
|
|
5133
|
+
function canComment(scopes) {
|
|
5134
|
+
return scopes.includes("comments:write" /* CommentsWrite */) || scopes.includes("room:write" /* Write */);
|
|
5135
|
+
}
|
|
5136
|
+
function isValidAuthTokenPayload(data) {
|
|
5137
|
+
return isPlainObject(data) && (data.k === "acc" /* ACCESS_TOKEN */ || data.k === "id" /* ID_TOKEN */);
|
|
5138
|
+
}
|
|
5139
|
+
function parseAuthToken(rawTokenString) {
|
|
5140
|
+
const tokenParts = rawTokenString.split(".");
|
|
5141
|
+
if (tokenParts.length !== 3) {
|
|
5142
|
+
throw new Error("Authentication error: invalid JWT token");
|
|
5143
|
+
}
|
|
5144
|
+
const payload = tryParseJson(b64decode(tokenParts[1]));
|
|
5145
|
+
if (!(payload && isValidAuthTokenPayload(payload))) {
|
|
5146
|
+
throw new Error(
|
|
5147
|
+
"Authentication error: expected a valid token but did not get one. Hint: if you are using a callback, ensure the room is passed when creating the token. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientCallback"
|
|
5148
|
+
);
|
|
5149
|
+
}
|
|
5150
|
+
return {
|
|
5151
|
+
raw: rawTokenString,
|
|
5152
|
+
parsed: payload
|
|
5153
|
+
};
|
|
5154
|
+
}
|
|
5155
|
+
|
|
5156
5156
|
// src/auth-manager.ts
|
|
5157
5157
|
var NON_RETRY_STATUS_CODES = [
|
|
5158
5158
|
400,
|
|
@@ -5287,10 +5287,8 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
5287
5287
|
const BUFFER = 30;
|
|
5288
5288
|
const expiresAt = Math.floor(Date.now() / 1e3) + (token.parsed.exp - token.parsed.iat) - BUFFER;
|
|
5289
5289
|
seenTokens.add(token.raw);
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
expiryTimes.push(expiresAt);
|
|
5293
|
-
}
|
|
5290
|
+
tokens.push(token);
|
|
5291
|
+
expiryTimes.push(expiresAt);
|
|
5294
5292
|
return { type: "secret", token };
|
|
5295
5293
|
} finally {
|
|
5296
5294
|
if (requestOptions.roomId) {
|
|
@@ -8894,8 +8892,8 @@ function createRoom(options, config) {
|
|
|
8894
8892
|
if (authValue.type === "secret") {
|
|
8895
8893
|
const token = authValue.token.parsed;
|
|
8896
8894
|
context.staticSessionInfoSig.set({
|
|
8897
|
-
userId: token.
|
|
8898
|
-
userInfo: token.
|
|
8895
|
+
userId: token.uid,
|
|
8896
|
+
userInfo: token.ui
|
|
8899
8897
|
});
|
|
8900
8898
|
} else {
|
|
8901
8899
|
context.staticSessionInfoSig.set({
|
|
@@ -10376,8 +10374,7 @@ function createClient(options) {
|
|
|
10376
10374
|
const baseUrl = getBaseUrl(clientOptions.baseUrl);
|
|
10377
10375
|
const currentUserId = new Signal(void 0);
|
|
10378
10376
|
const authManager = createAuthManager(options, (token) => {
|
|
10379
|
-
|
|
10380
|
-
currentUserId.set(() => userId);
|
|
10377
|
+
currentUserId.set(() => token.uid);
|
|
10381
10378
|
});
|
|
10382
10379
|
const fetchPolyfill = _optionalChain([clientOptions, 'access', _209 => _209.polyfills, 'optionalAccess', _210 => _210.fetch]) || /* istanbul ignore next */
|
|
10383
10380
|
_optionalChain([globalThis, 'access', _211 => _211.fetch, 'optionalAccess', _212 => _212.bind, 'call', _213 => _213(globalThis)]);
|
|
@@ -10408,8 +10405,6 @@ function createClient(options) {
|
|
|
10408
10405
|
throw new StopRetrying(
|
|
10409
10406
|
"Cannot use AI Copilots with a public API key"
|
|
10410
10407
|
);
|
|
10411
|
-
} else if (resp.token.parsed.k === "sec-legacy" /* SECRET_LEGACY */) {
|
|
10412
|
-
throw new StopRetrying("AI Copilots requires an ID or Access token");
|
|
10413
10408
|
}
|
|
10414
10409
|
return resp;
|
|
10415
10410
|
},
|