@@ -43,7 +43,7 @@ const originalStep = KerberosClient.prototype.step;
4343 */
4444KerberosClient . prototype . step = async function step ( challenge ) {
4545 if ( typeof challenge !== 'string' ) {
46- throw new Error ( 'parameter `challenge` must be a string.' ) ;
46+ throw new TypeError ( 'parameter `challenge` must be a string.' ) ;
4747 }
4848 return await promisify ( originalStep . bind ( this ) ) ( challenge ) ;
4949} ;
@@ -60,15 +60,11 @@ const originalWrap = KerberosClient.prototype.wrap;
6060 * @param {boolean } [options.protect] Indicates if the wrap should request message confidentiality
6161 * @return {Promise<string> }
6262 */
63- KerberosClient . prototype . wrap = async function wrap ( challenge , options ) {
63+ KerberosClient . prototype . wrap = async function wrap ( challenge , options = { } ) {
6464 if ( typeof challenge !== 'string' ) {
65- throw new Error ( 'parameter `challenge` must be a string.' ) ;
65+ throw new TypeError ( 'parameter `challenge` must be a string.' ) ;
6666 }
6767
68- // eslint-disable-next-line no-restricted-syntax
69- if ( typeof challenge !== 'object' || challenge === null ) {
70- throw new Error ( 'parameter `challenge` must be an object.' ) ;
71- }
7268 return await promisify ( originalWrap . bind ( this ) ) ( challenge , options ) ;
7369} ;
7470
@@ -83,7 +79,7 @@ const originalUnwrap = KerberosClient.prototype.unwrap;
8379 */
8480KerberosClient . prototype . unwrap = async function unwrap ( challenge ) {
8581 if ( typeof challenge !== 'string' ) {
86- throw new Error ( 'parameter `challenge` must be a string.' ) ;
82+ throw new TypeError ( 'parameter `challenge` must be a string.' ) ;
8783 }
8884 return await promisify ( originalUnwrap . bind ( this ) ) ( challenge ) ;
8985} ;
@@ -108,7 +104,7 @@ const originalServerStep = KerberosServer.prototype.step;
108104 */
109105KerberosServer . prototype . step = async function step ( challenge ) {
110106 if ( typeof challenge !== 'string' ) {
111- throw new Error ( 'parameter `challenge` must be a string.' ) ;
107+ throw new TypeError ( 'parameter `challenge` must be a string.' ) ;
112108 }
113109 return await promisify ( originalServerStep . bind ( this ) ) ( challenge ) ;
114110} ;
@@ -139,16 +135,16 @@ KerberosServer.prototype.step = async function step(challenge) {
139135 */
140136async function checkPassword ( username , password , service , defaultRealm ) {
141137 if ( typeof username !== 'string' ) {
142- throw new Error ( 'parameter `username` must be a string.' ) ;
138+ throw new TypeError ( 'parameter `username` must be a string.' ) ;
143139 }
144140 if ( typeof password !== 'string' ) {
145- throw new Error ( 'parameter `password` must be a string.' ) ;
141+ throw new TypeError ( 'parameter `password` must be a string.' ) ;
146142 }
147143 if ( typeof service !== 'string' ) {
148- throw new Error ( 'parameter `service` must be a string.' ) ;
144+ throw new TypeError ( 'parameter `service` must be a string.' ) ;
149145 }
150146 if ( defaultRealm && typeof defaultRealm !== 'string' ) {
151- throw new Error ( 'if specified, parameter `defaultRealm` must be a string.' ) ;
147+ throw new TypeError ( 'if specified, parameter `defaultRealm` must be a string.' ) ;
152148 }
153149 return await promisify ( kerberos . checkPassword ) ( username , password , service , defaultRealm ) ;
154150}
@@ -165,10 +161,10 @@ async function checkPassword(username, password, service, defaultRealm) {
165161 */
166162async function principalDetails ( service , hostname ) {
167163 if ( typeof service !== 'string' ) {
168- throw new Error ( 'parameter `service` must be a string.' ) ;
164+ throw new TypeError ( 'parameter `service` must be a string.' ) ;
169165 }
170166 if ( typeof hostname !== 'string' ) {
171- throw new Error ( 'parameter `hostname` must be a string.' ) ;
167+ throw new TypeError ( 'parameter `hostname` must be a string.' ) ;
172168 }
173169 return await promisify ( kerberos . principalDetails ) ( service , hostname ) ;
174170}
@@ -186,7 +182,7 @@ async function principalDetails(service, hostname) {
186182 */
187183async function initializeClient ( service , options = { mechOID : GSS_C_NO_OID } ) {
188184 if ( typeof service !== 'string' ) {
189- throw new Error ( 'parameter `service` must be a string.' ) ;
185+ throw new TypeError ( 'parameter `service` must be a string.' ) ;
190186 }
191187 return await promisify ( kerberos . initializeClient ) ( service , options ) ;
192188}
@@ -200,7 +196,7 @@ async function initializeClient(service, options = { mechOID: GSS_C_NO_OID }) {
200196 */
201197async function initializeServer ( service ) {
202198 if ( typeof service !== 'string' ) {
203- throw new Error ( 'parameter `service` must be a string.' ) ;
199+ throw new TypeError ( 'parameter `service` must be a string.' ) ;
204200 }
205201 return await promisify ( kerberos . initializeServer ) ( service ) ;
206202}
0 commit comments