()
| 844 | } |
| 845 | |
| 846 | async #getHandshakeCommands(): Promise< |
| 847 | Array<{ cmd: CommandArguments } & { errorHandler?: (err: Error) => void }> |
| 848 | > { |
| 849 | const commands = []; |
| 850 | const cp = this.#options.credentialsProvider; |
| 851 | const resp = this.#options.RESP ?? DEFAULT_RESP; |
| 852 | |
| 853 | if (resp !== 2) { |
| 854 | const hello: HelloOptions = {}; |
| 855 | |
| 856 | if (cp && cp.type === 'async-credentials-provider') { |
| 857 | const credentials = await cp.credentials(); |
| 858 | if (credentials.password) { |
| 859 | hello.AUTH = { |
| 860 | username: credentials.username ?? 'default', |
| 861 | password: credentials.password |
| 862 | }; |
| 863 | } |
| 864 | } |
| 865 | |
| 866 | if (cp && cp.type === 'streaming-credentials-provider') { |
| 867 | const [credentials, disposable] = |
| 868 | await this.#subscribeForStreamingCredentials(cp); |
| 869 | this.#credentialsSubscription = disposable; |
| 870 | |
| 871 | if (credentials.password) { |
| 872 | hello.AUTH = { |
| 873 | username: credentials.username ?? 'default', |
| 874 | password: credentials.password |
| 875 | }; |
| 876 | } |
| 877 | } |
| 878 | |
| 879 | if (this.#options.name) { |
| 880 | hello.SETNAME = this.#options.name; |
| 881 | } |
| 882 | |
| 883 | commands.push({ cmd: parseArgs(HELLO, resp, hello) }); |
| 884 | } else { |
| 885 | if (cp && cp.type === 'async-credentials-provider') { |
| 886 | const credentials = await cp.credentials(); |
| 887 | |
| 888 | if (credentials.username || credentials.password) { |
| 889 | commands.push({ |
| 890 | cmd: parseArgs(COMMANDS.AUTH, { |
| 891 | username: credentials.username, |
| 892 | password: credentials.password ?? '' |
| 893 | }) |
| 894 | }); |
| 895 | } |
| 896 | } |
| 897 | |
| 898 | if (cp && cp.type === 'streaming-credentials-provider') { |
| 899 | const [credentials, disposable] = |
| 900 | await this.#subscribeForStreamingCredentials(cp); |
| 901 | this.#credentialsSubscription = disposable; |
| 902 | |
| 903 | if (credentials.username || credentials.password) { |
no test coverage detected