function parseNonce
parseNonce(xml: string): string

Reads the nonce from the camera's reply to the nonce request.

Examples

Read the nonce

import { assertEquals } from "@std/assert";
import { parseNonce } from "@hertzg/reolink-api/protocol/login";

const xml = "<body><Encryption><nonce>abc</nonce></Encryption></body>";

assertEquals(parseNonce(xml), "abc");

Parameters

xml: string

The decrypted reply body.

Return Type

string

The text of the first <nonce> element.

Throws

Error

When the reply has no <nonce> element.

Usage

import { parseNonce } from "protocol/login.ts";