Skip to content

Commit 27230ec

Browse files
committed
lib,crypto: rewire CryptoKey on the native class
JS-side `CryptoKey` now extends the native `NativeCryptoKey` created via `createCryptoKeyClass`. `InternalCryptoKey` caches the `[type, extractable, algorithm, usages, handle]` slot tuple in a `#slots` private field on first access; the public getters and `isCryptoKey` route through dedicated `getCryptoKey{Type,Extractable, Algorithm,Usages,Handle}` helpers re-exported from this module. Symbol property storage (`kKeyObject`, `kAlgorithm`, `kExtractable`, `kKeyUsages`, `kCachedAlgorithm`, `kCachedKeyUsages`) is gone; `kKeyObject` is dropped from `internal/crypto/util` exports. `deepStrictEqual` on CryptoKey switches to the new accessors plus `handle.equals()` (instead of structural compare on wrapper objects). An ESLint rule forbids destructuring `getCryptoKeyHandle` from `internalBinding('crypto')`; it must come from `internal/crypto/keys` so the brand-check path is used. Signed-off-by: Filip Skokan <[email protected]>
1 parent 0a1e601 commit 27230ec

4 files changed

Lines changed: 238 additions & 201 deletions

File tree

lib/eslint.config_partial.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ export default [
7171
selector: "CallExpression[callee.type='Identifier'][callee.name='ReflectApply'][arguments.2.type='ArrayExpression']",
7272
message: 'Use `FunctionPrototypeCall` to avoid creating an ad-hoc array',
7373
},
74+
{
75+
selector: "VariableDeclarator[init.type='CallExpression'][init.callee.name='internalBinding'][init.arguments.0.value='crypto'] > ObjectPattern > Property[key.name='getCryptoKeyHandle']",
76+
message: "Use `const { getCryptoKeyHandle } = require('internal/crypto/keys');` instead of destructuring it from `internalBinding('crypto')`.",
77+
},
7478
],
7579
'no-restricted-globals': [
7680
'error',

0 commit comments

Comments
 (0)