Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ZemerTeam/zemer-cipher/llms.txt

Use this file to discover all available pages before exploring further.

PlayerConfigParser is the security and validation boundary for all player config data. Every value that will be evaluated as JavaScript in the cipher WebView is validated against strict regex patterns before use. Pure JVM — no Android imports, fully unit-testable. Package: com.zemer.cipher The parser is the only code path that can promote untrusted JSON into the in-memory config table. PlayerConfigStore always routes both the bundled asset and the remote download through PlayerConfigParser.parse() before applying any result. Constant: SUPPORTED_SCHEMA_VERSION = 1

Members

parse

fun parse(jsonText: String): ParseResult
Parses and validates a player_configs.json string. Returns ParseResult.Success with the validated config map and a list of skipped entry keys, or ParseResult.Failure with a human-readable reason string.
jsonText
String
required
The full text of a player_configs.json file to parse and validate.

File-level failures

The following conditions cause ParseResult.Failure to be returned for the entire file. The caller keeps its previous config table unchanged.
ConditionExample
Malformed JSONSyntax error anywhere in the document
schemaVersion missing or not an integer"schemaVersion": "1" (string instead of int)
schemaVersion is zero or negative"schemaVersion": 0
schemaVersion exceeds SUPPORTED_SCHEMA_VERSION (1)"schemaVersion": 2
players field missing or not a JSON object"players": []
Duplicate primary hash or alias key anywhere in the fileTwo entries sharing the same hash or alias

Entry-level failures

The following conditions cause an individual entry to be skipped and its key added to skippedEntries. The rest of the file is still processed and a ParseResult.Success is returned.
ConditionRegex / constraint
Hash key format invalidMust match ^[a-f0-9]{8}$
sig missing or format invalidMust match ^[A-Za-z0-9$_]{1,8}\(\d+,\d+,INPUT\)$
nClass missing or format invalidMust match ^[A-Za-z0-9$_]{1,8}$
sts missing, not an integer, or not positiveMust be a positive integer literal (not a string)
aliases not an arrayAny non-array value for the aliases key
Any alias element not an 8-hex stringMust match ^[a-f0-9]{8}$

merge

fun merge(
    bundled: Map<String, FunctionNameExtractor.HardcodedPlayerConfig>,
    remote: Map<String, FunctionNameExtractor.HardcodedPlayerConfig>,
): Map<String, FunctionNameExtractor.HardcodedPlayerConfig>
Overlays remote onto bundled. Remote entries win on a per-key basis; keys present only in bundled survive unchanged. The result is a new immutable map.
bundled
Map<String, HardcodedPlayerConfig>
required
The config map parsed from the bundled APK asset. Acts as the baseline.
remote
Map<String, HardcodedPlayerConfig>
required
The config map parsed from the remote (GitHub) copy. Wins over bundled entries on collision.

buildNJsExpression

fun buildNJsExpression(nClass: String): String
Builds the n-transform IIFE for a given nClass identifier. The IIFE template is defined locally in the library — it is never taken from the remote config file, so a compromised remote cannot inject arbitrary JavaScript for the n-transform path. INPUT in the returned string is a placeholder that CipherWebView replaces with the actual n-value at evaluation time.
nClass
String
required
The URL class identifier extracted from the nClass field of a config entry. Must already be validated against ^[A-Za-z0-9$_]{1,8}$ before this function is called.
Example — for nClass = "Yx":
(function(n){try{var u=new g.Yx('https://x.googlevideo.com/videoplayback?n='+n,true);var t=u.get('n');return(t&&t!==n)?t:n;}catch(e){return n;}})(INPUT)

Types

ParseResult

Sealed class representing the outcome of a parse() call.

ParseResult.Success

data class ParseResult.Success(
    val configs: Map<String, HardcodedPlayerConfig>,
    val skippedEntries: List<String>,
) : ParseResult()
Returned when the file-level structure is valid. configs is the fully-merged map ready for use (primary hashes and all alias hashes are already registered as keys). skippedEntries lists the primary hash keys of individually-invalid entries that were excluded; an empty list means every entry passed validation.
configs
Map<String, HardcodedPlayerConfig>
The validated, alias-expanded config map. Keys are 8-hex strings (both primary hashes and aliases from aliases arrays).
skippedEntries
List<String>
Primary hash keys of entries that failed individual validation and were excluded from configs. May be empty.

ParseResult.Failure

data class ParseResult.Failure(val reason: String) : ParseResult()
Returned when the file has a file-level defect. The caller must not apply this result to the config table.
reason
String
Human-readable description of why the file was rejected (e.g. "duplicate hash/alias 'a1b2c3d4' (entry 9c249f6f)").

Build docs developers (and LLMs) love