MCPcopy Create free account
hub / github.com/LibPDF-js/core / authenticate

Method authenticate

src/security/standard-handler.ts:130–149  ·  view source on GitHub ↗

* Authenticate with a password. * * Tries both user and owner password validation. * Call with empty Uint8Array for documents with no password. * * @param password - UTF-8 encoded password bytes * @returns Authentication result

(password: Uint8Array)

Source from the content-addressed store, hash-verified

128 * @returns Authentication result
129 */
130 authenticate(password: Uint8Array): AuthResult {
131 // Try user password first (most common)
132 const userResult = this.tryUserPassword(password);
133 if (userResult.authenticated) {
134 return userResult;
135 }
136
137 // Try owner password
138 const ownerResult = this.tryOwnerPassword(password);
139 if (ownerResult.authenticated) {
140 return ownerResult;
141 }
142
143 // Authentication failed
144 return {
145 authenticated: false,
146 permissions: this.encryptDict.permissions,
147 isOwner: false,
148 };
149 }
150
151 /**
152 * Authenticate with a string password (convenience method).

Callers 2

generateEncryptionFunction · 0.95

Calls 2

tryUserPasswordMethod · 0.95
tryOwnerPasswordMethod · 0.95

Tested by

no test coverage detected