MCPcopy Create free account
hub / github.com/node-apn/node-apn / token

Function token

lib/token.js:7–23  ·  view source on GitHub ↗

* Validates a device token * * Will convert to string and removes invalid characters as required.

(input)

Source from the content-addressed store, hash-verified

5 * Will convert to string and removes invalid characters as required.
6 */
7function token(input) {
8 let token;
9
10 if (typeof input === "string") {
11 token = input;
12 } else if (Buffer.isBuffer(input)) {
13 token = input.toString("hex");
14 }
15
16 token = token.replace(/[^0-9a-f]/gi, "");
17
18 if (token.length === 0) {
19 throw new Error("Token has invalid length");
20 }
21
22 return token;
23}
24
25module.exports = token;

Callers 3

prepareTokenFunction · 0.85
regenerateFunction · 0.85
token.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…