@kedaruma/revlm-client 1.0.58 → 1.0.60
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/{chunk-YHUJ52AP.mjs → chunk-367MFQ4K.mjs} +41 -2
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +41 -2
- package/dist/index.mjs +1 -1
- package/dist/revlm-compat.js +41 -2
- package/dist/revlm-compat.mjs +1 -1
- package/package.json +2 -2
|
@@ -8,7 +8,7 @@ var require_package = __commonJS({
|
|
|
8
8
|
"package.json"(exports, module) {
|
|
9
9
|
module.exports = {
|
|
10
10
|
name: "@kedaruma/revlm-client",
|
|
11
|
-
version: "1.0.
|
|
11
|
+
version: "1.0.60",
|
|
12
12
|
private: false,
|
|
13
13
|
description: "TypeScript client SDK for talking to the Revlm server replacement for MongoDB Realm.",
|
|
14
14
|
keywords: [
|
|
@@ -321,6 +321,30 @@ var Revlm = class {
|
|
|
321
321
|
logDebug(...args) {
|
|
322
322
|
if (this.canLog("debug")) console.log(...args);
|
|
323
323
|
}
|
|
324
|
+
maskSecret(value, head = 10, tail = 6) {
|
|
325
|
+
if (!value) return "<empty>";
|
|
326
|
+
if (value.length <= head + tail) return value;
|
|
327
|
+
return `${value.slice(0, head)}***${value.slice(-tail)}`;
|
|
328
|
+
}
|
|
329
|
+
extractRefreshSecret(cookieHeader) {
|
|
330
|
+
if (!cookieHeader) return void 0;
|
|
331
|
+
const match = cookieHeader.match(/(?:^|;\\s*)revlm_refresh=([^;]+)/);
|
|
332
|
+
return match?.[1];
|
|
333
|
+
}
|
|
334
|
+
logRefreshFailureClient(params) {
|
|
335
|
+
const recoverable = typeof params.code === "number" ? params.code >= 1e4 && params.code < 2e4 : params.status === 400 || params.status === 401;
|
|
336
|
+
const line1 = `[refresh-token][${recoverable ? "debug" : "error"}][${recoverable ? "recoverable" : "fatal"}] cause=${params.cause}`;
|
|
337
|
+
const line2 = `session=${this.maskSecret(params.sessionId)} refresh=${this.maskSecret(params.refreshSecret)}`;
|
|
338
|
+
const line3 = `details=${JSON.stringify({
|
|
339
|
+
status: params.status,
|
|
340
|
+
reason: params.reason,
|
|
341
|
+
code: params.code
|
|
342
|
+
})}`;
|
|
343
|
+
this.logError(line1);
|
|
344
|
+
this.logError(line2);
|
|
345
|
+
this.logError(line3);
|
|
346
|
+
this.logError("");
|
|
347
|
+
}
|
|
324
348
|
setToken(token) {
|
|
325
349
|
this._token = token;
|
|
326
350
|
}
|
|
@@ -466,12 +490,27 @@ var Revlm = class {
|
|
|
466
490
|
const refreshFailed = {
|
|
467
491
|
reason: refreshRes.reason,
|
|
468
492
|
status: refreshRes.status,
|
|
469
|
-
error: refreshRes.error
|
|
493
|
+
error: refreshRes.error,
|
|
494
|
+
code: refreshRes.code
|
|
470
495
|
};
|
|
471
496
|
this.logDebug("### refresh failed:", refreshFailed, JSON.stringify(refreshFailed));
|
|
497
|
+
const refreshUrl = `${this.baseUrl}/refresh-token`;
|
|
498
|
+
const cookieHeader = await this.cookieStore?.getCookieHeader?.(refreshUrl);
|
|
499
|
+
const refreshSecret = this.extractRefreshSecret(cookieHeader);
|
|
500
|
+
const refreshFailureLog = {
|
|
501
|
+
cause: refreshRes.reason || "refresh_failed",
|
|
502
|
+
reason: refreshFailed.reason,
|
|
503
|
+
status: refreshFailed.status,
|
|
504
|
+
code: refreshFailed.code
|
|
505
|
+
};
|
|
506
|
+
if (sessionId) refreshFailureLog.sessionId = sessionId;
|
|
507
|
+
if (refreshSecret) refreshFailureLog.refreshSecret = refreshSecret;
|
|
508
|
+
this.logRefreshFailureClient(refreshFailureLog);
|
|
472
509
|
if (refreshRes.reason === "no_refresh_secret") {
|
|
473
510
|
const missingError = new Error("Refresh cookie missing. Provide a cookie-aware fetch implementation for Node/RN.");
|
|
474
511
|
missingError.revlmReason = "no_refresh_secret";
|
|
512
|
+
missingError.revlmCode = refreshRes.code;
|
|
513
|
+
missingError.httpStatus = refreshRes.status;
|
|
475
514
|
throw missingError;
|
|
476
515
|
}
|
|
477
516
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -224,6 +224,9 @@ declare class Revlm {
|
|
|
224
224
|
logWarn(...args: any[]): void;
|
|
225
225
|
logInfo(...args: any[]): void;
|
|
226
226
|
logDebug(...args: any[]): void;
|
|
227
|
+
private maskSecret;
|
|
228
|
+
private extractRefreshSecret;
|
|
229
|
+
private logRefreshFailureClient;
|
|
227
230
|
setToken(token: string): void;
|
|
228
231
|
getToken(): string | undefined;
|
|
229
232
|
clearToken(): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -224,6 +224,9 @@ declare class Revlm {
|
|
|
224
224
|
logWarn(...args: any[]): void;
|
|
225
225
|
logInfo(...args: any[]): void;
|
|
226
226
|
logDebug(...args: any[]): void;
|
|
227
|
+
private maskSecret;
|
|
228
|
+
private extractRefreshSecret;
|
|
229
|
+
private logRefreshFailureClient;
|
|
227
230
|
setToken(token: string): void;
|
|
228
231
|
getToken(): string | undefined;
|
|
229
232
|
clearToken(): void;
|
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ var require_package = __commonJS({
|
|
|
35
35
|
"package.json"(exports2, module2) {
|
|
36
36
|
module2.exports = {
|
|
37
37
|
name: "@kedaruma/revlm-client",
|
|
38
|
-
version: "1.0.
|
|
38
|
+
version: "1.0.60",
|
|
39
39
|
private: false,
|
|
40
40
|
description: "TypeScript client SDK for talking to the Revlm server replacement for MongoDB Realm.",
|
|
41
41
|
keywords: [
|
|
@@ -364,6 +364,30 @@ var Revlm = class {
|
|
|
364
364
|
logDebug(...args) {
|
|
365
365
|
if (this.canLog("debug")) console.log(...args);
|
|
366
366
|
}
|
|
367
|
+
maskSecret(value, head = 10, tail = 6) {
|
|
368
|
+
if (!value) return "<empty>";
|
|
369
|
+
if (value.length <= head + tail) return value;
|
|
370
|
+
return `${value.slice(0, head)}***${value.slice(-tail)}`;
|
|
371
|
+
}
|
|
372
|
+
extractRefreshSecret(cookieHeader) {
|
|
373
|
+
if (!cookieHeader) return void 0;
|
|
374
|
+
const match = cookieHeader.match(/(?:^|;\\s*)revlm_refresh=([^;]+)/);
|
|
375
|
+
return match?.[1];
|
|
376
|
+
}
|
|
377
|
+
logRefreshFailureClient(params) {
|
|
378
|
+
const recoverable = typeof params.code === "number" ? params.code >= 1e4 && params.code < 2e4 : params.status === 400 || params.status === 401;
|
|
379
|
+
const line1 = `[refresh-token][${recoverable ? "debug" : "error"}][${recoverable ? "recoverable" : "fatal"}] cause=${params.cause}`;
|
|
380
|
+
const line2 = `session=${this.maskSecret(params.sessionId)} refresh=${this.maskSecret(params.refreshSecret)}`;
|
|
381
|
+
const line3 = `details=${JSON.stringify({
|
|
382
|
+
status: params.status,
|
|
383
|
+
reason: params.reason,
|
|
384
|
+
code: params.code
|
|
385
|
+
})}`;
|
|
386
|
+
this.logError(line1);
|
|
387
|
+
this.logError(line2);
|
|
388
|
+
this.logError(line3);
|
|
389
|
+
this.logError("");
|
|
390
|
+
}
|
|
367
391
|
setToken(token) {
|
|
368
392
|
this._token = token;
|
|
369
393
|
}
|
|
@@ -509,12 +533,27 @@ var Revlm = class {
|
|
|
509
533
|
const refreshFailed = {
|
|
510
534
|
reason: refreshRes.reason,
|
|
511
535
|
status: refreshRes.status,
|
|
512
|
-
error: refreshRes.error
|
|
536
|
+
error: refreshRes.error,
|
|
537
|
+
code: refreshRes.code
|
|
513
538
|
};
|
|
514
539
|
this.logDebug("### refresh failed:", refreshFailed, JSON.stringify(refreshFailed));
|
|
540
|
+
const refreshUrl = `${this.baseUrl}/refresh-token`;
|
|
541
|
+
const cookieHeader = await this.cookieStore?.getCookieHeader?.(refreshUrl);
|
|
542
|
+
const refreshSecret = this.extractRefreshSecret(cookieHeader);
|
|
543
|
+
const refreshFailureLog = {
|
|
544
|
+
cause: refreshRes.reason || "refresh_failed",
|
|
545
|
+
reason: refreshFailed.reason,
|
|
546
|
+
status: refreshFailed.status,
|
|
547
|
+
code: refreshFailed.code
|
|
548
|
+
};
|
|
549
|
+
if (sessionId) refreshFailureLog.sessionId = sessionId;
|
|
550
|
+
if (refreshSecret) refreshFailureLog.refreshSecret = refreshSecret;
|
|
551
|
+
this.logRefreshFailureClient(refreshFailureLog);
|
|
515
552
|
if (refreshRes.reason === "no_refresh_secret") {
|
|
516
553
|
const missingError = new Error("Refresh cookie missing. Provide a cookie-aware fetch implementation for Node/RN.");
|
|
517
554
|
missingError.revlmReason = "no_refresh_secret";
|
|
555
|
+
missingError.revlmCode = refreshRes.code;
|
|
556
|
+
missingError.httpStatus = refreshRes.status;
|
|
518
557
|
throw missingError;
|
|
519
558
|
}
|
|
520
559
|
}
|
package/dist/index.mjs
CHANGED
package/dist/revlm-compat.js
CHANGED
|
@@ -35,7 +35,7 @@ var require_package = __commonJS({
|
|
|
35
35
|
"package.json"(exports2, module2) {
|
|
36
36
|
module2.exports = {
|
|
37
37
|
name: "@kedaruma/revlm-client",
|
|
38
|
-
version: "1.0.
|
|
38
|
+
version: "1.0.60",
|
|
39
39
|
private: false,
|
|
40
40
|
description: "TypeScript client SDK for talking to the Revlm server replacement for MongoDB Realm.",
|
|
41
41
|
keywords: [
|
|
@@ -362,6 +362,30 @@ var Revlm = class {
|
|
|
362
362
|
logDebug(...args) {
|
|
363
363
|
if (this.canLog("debug")) console.log(...args);
|
|
364
364
|
}
|
|
365
|
+
maskSecret(value, head = 10, tail = 6) {
|
|
366
|
+
if (!value) return "<empty>";
|
|
367
|
+
if (value.length <= head + tail) return value;
|
|
368
|
+
return `${value.slice(0, head)}***${value.slice(-tail)}`;
|
|
369
|
+
}
|
|
370
|
+
extractRefreshSecret(cookieHeader) {
|
|
371
|
+
if (!cookieHeader) return void 0;
|
|
372
|
+
const match = cookieHeader.match(/(?:^|;\\s*)revlm_refresh=([^;]+)/);
|
|
373
|
+
return match?.[1];
|
|
374
|
+
}
|
|
375
|
+
logRefreshFailureClient(params) {
|
|
376
|
+
const recoverable = typeof params.code === "number" ? params.code >= 1e4 && params.code < 2e4 : params.status === 400 || params.status === 401;
|
|
377
|
+
const line1 = `[refresh-token][${recoverable ? "debug" : "error"}][${recoverable ? "recoverable" : "fatal"}] cause=${params.cause}`;
|
|
378
|
+
const line2 = `session=${this.maskSecret(params.sessionId)} refresh=${this.maskSecret(params.refreshSecret)}`;
|
|
379
|
+
const line3 = `details=${JSON.stringify({
|
|
380
|
+
status: params.status,
|
|
381
|
+
reason: params.reason,
|
|
382
|
+
code: params.code
|
|
383
|
+
})}`;
|
|
384
|
+
this.logError(line1);
|
|
385
|
+
this.logError(line2);
|
|
386
|
+
this.logError(line3);
|
|
387
|
+
this.logError("");
|
|
388
|
+
}
|
|
365
389
|
setToken(token) {
|
|
366
390
|
this._token = token;
|
|
367
391
|
}
|
|
@@ -507,12 +531,27 @@ var Revlm = class {
|
|
|
507
531
|
const refreshFailed = {
|
|
508
532
|
reason: refreshRes.reason,
|
|
509
533
|
status: refreshRes.status,
|
|
510
|
-
error: refreshRes.error
|
|
534
|
+
error: refreshRes.error,
|
|
535
|
+
code: refreshRes.code
|
|
511
536
|
};
|
|
512
537
|
this.logDebug("### refresh failed:", refreshFailed, JSON.stringify(refreshFailed));
|
|
538
|
+
const refreshUrl = `${this.baseUrl}/refresh-token`;
|
|
539
|
+
const cookieHeader = await this.cookieStore?.getCookieHeader?.(refreshUrl);
|
|
540
|
+
const refreshSecret = this.extractRefreshSecret(cookieHeader);
|
|
541
|
+
const refreshFailureLog = {
|
|
542
|
+
cause: refreshRes.reason || "refresh_failed",
|
|
543
|
+
reason: refreshFailed.reason,
|
|
544
|
+
status: refreshFailed.status,
|
|
545
|
+
code: refreshFailed.code
|
|
546
|
+
};
|
|
547
|
+
if (sessionId) refreshFailureLog.sessionId = sessionId;
|
|
548
|
+
if (refreshSecret) refreshFailureLog.refreshSecret = refreshSecret;
|
|
549
|
+
this.logRefreshFailureClient(refreshFailureLog);
|
|
513
550
|
if (refreshRes.reason === "no_refresh_secret") {
|
|
514
551
|
const missingError = new Error("Refresh cookie missing. Provide a cookie-aware fetch implementation for Node/RN.");
|
|
515
552
|
missingError.revlmReason = "no_refresh_secret";
|
|
553
|
+
missingError.revlmCode = refreshRes.code;
|
|
554
|
+
missingError.httpStatus = refreshRes.status;
|
|
516
555
|
throw missingError;
|
|
517
556
|
}
|
|
518
557
|
}
|
package/dist/revlm-compat.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kedaruma/revlm-client",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.60",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "TypeScript client SDK for talking to the Revlm server replacement for MongoDB Realm.",
|
|
6
6
|
"keywords": [
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"bson": "^6.10.4",
|
|
60
60
|
"dotenv": "^17.2.3",
|
|
61
|
-
"@kedaruma/revlm-shared": "1.0.
|
|
61
|
+
"@kedaruma/revlm-shared": "1.0.11"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"tsup": "^8.5.1"
|