wangzhibo
2026-05-09 53418655c061ac26f66058253f39200aced1ab1d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
'use strict'
 
const ExtensionResponse = require('../extension-response')
 
/**
 * Implements the "Who Am I" extension defined by
 * https://www.rfc-editor.org/rfc/rfc4532.
 */
class WhoAmIResponse extends ExtensionResponse {
  /**
   * Given a basic {@link ExtensionResponse} with a buffer string in
   * `responseValue`, parse into a specific {@link WhoAmIResponse}
   * instance.
   *
   * @param {ExtensionResponse} response
   *
   * @returns {WhoAmIResponse}
   */
  static fromResponse (response) {
    if (response.responseValue === undefined) {
      return new WhoAmIResponse()
    }
 
    const valueBuffer = Buffer.from(response.responseValue.substring(8), 'hex')
    const responseValue = valueBuffer.toString('utf8')
    return new WhoAmIResponse({ responseValue })
  }
}
 
module.exports = WhoAmIResponse