| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,6 +7,7 @@ const { | |||
| 7 | 7 | ObjectDefineProperties, | |
| 8 | 8 | ObjectSetPrototypeOf, | |
| 9 | 9 | Symbol, | |
| 10 | + SymbolToStringTag, | ||
| 10 | 11 | Uint8Array, | |
| 11 | 12 | } = primordials; | |
| 12 | 13 | ||
@@ -139,6 +140,14 @@ const { | |||
| 139 | 140 | } | |
| 140 | 141 | } | |
| 141 | 142 | ||
| 143 | + ObjectDefineProperties(KeyObject.prototype, { | ||
| 144 | + [SymbolToStringTag]: { | ||
| 145 | + __proto__: null, | ||
| 146 | + configurable: true, | ||
| 147 | + value: 'KeyObject', | ||
| 148 | + }, | ||
| 149 | + }); | ||
| 150 | + | ||
| 142 | 151 | class SecretKeyObject extends KeyObject { | |
| 143 | 152 | constructor(handle) { | |
| 144 | 153 | super('secret', handle); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -69,6 +69,7 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem', | |||
| 69 | 69 | const keybuf = randomBytes(32); | |
| 70 | 70 | const key = createSecretKey(keybuf); | |
| 71 | 71 | assert.strictEqual(key.type, 'secret'); | |
| 72 | + assert.strictEqual(key.toString(), '[object KeyObject]'); | ||
| 72 | 73 | assert.strictEqual(key.symmetricKeySize, 32); | |
| 73 | 74 | assert.strictEqual(key.asymmetricKeyType, undefined); | |
| 74 | 75 | assert.strictEqual(key.asymmetricKeyDetails, undefined); | |
@@ -150,27 +151,32 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem', | |||
| 150 | 151 | ||
| 151 | 152 | const publicKey = createPublicKey(publicPem); | |
| 152 | 153 | assert.strictEqual(publicKey.type, 'public'); | |
| 154 | + assert.strictEqual(publicKey.toString(), '[object KeyObject]'); | ||
| 153 | 155 | assert.strictEqual(publicKey.asymmetricKeyType, 'rsa'); | |
| 154 | 156 | assert.strictEqual(publicKey.symmetricKeySize, undefined); | |
| 155 | 157 | ||
| 156 | 158 | const privateKey = createPrivateKey(privatePem); | |
| 157 | 159 | assert.strictEqual(privateKey.type, 'private'); | |
| 160 | + assert.strictEqual(privateKey.toString(), '[object KeyObject]'); | ||
| 158 | 161 | assert.strictEqual(privateKey.asymmetricKeyType, 'rsa'); | |
| 159 | 162 | assert.strictEqual(privateKey.symmetricKeySize, undefined); | |
| 160 | 163 | ||
| 161 | 164 | // It should be possible to derive a public key from a private key. | |
| 162 | 165 | const derivedPublicKey = createPublicKey(privateKey); | |
| 163 | 166 | assert.strictEqual(derivedPublicKey.type, 'public'); | |
| 167 | + assert.strictEqual(derivedPublicKey.toString(), '[object KeyObject]'); | ||
| 164 | 168 | assert.strictEqual(derivedPublicKey.asymmetricKeyType, 'rsa'); | |
| 165 | 169 | assert.strictEqual(derivedPublicKey.symmetricKeySize, undefined); | |
| 166 | 170 | ||
| 167 | 171 | const publicKeyFromJwk = createPublicKey({ key: publicJwk, format: 'jwk' }); | |
| 168 | 172 | assert.strictEqual(publicKey.type, 'public'); | |
| 173 | + assert.strictEqual(publicKey.toString(), '[object KeyObject]'); | ||
| 169 | 174 | assert.strictEqual(publicKey.asymmetricKeyType, 'rsa'); | |
| 170 | 175 | assert.strictEqual(publicKey.symmetricKeySize, undefined); | |
| 171 | 176 | ||
| 172 | 177 | const privateKeyFromJwk = createPrivateKey({ key: jwk, format: 'jwk' }); | |
| 173 | 178 | assert.strictEqual(privateKey.type, 'private'); | |
| 179 | + assert.strictEqual(privateKey.toString(), '[object KeyObject]'); | ||
| 174 | 180 | assert.strictEqual(privateKey.asymmetricKeyType, 'rsa'); | |
| 175 | 181 | assert.strictEqual(privateKey.symmetricKeySize, undefined); | |
| 176 | 182 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments