mirror of
https://github.com/zebrajr/node.git
synced 2025-12-07 00:20:38 +01:00
Expose the POSIX credential accessors through
`internalBinding('credentials')` instead of setting them on the
process or bootstrapper object from C++ directly. Also moves
`SafeGetEnv` from `internalBinding('util')` to
`internalBinding('credentials')` since it's closely related to
the credentials.
In the JS land, instead of wrapping the bindings then writing
to the process object directly in main_thread_only.js, return
the wrapped functions back to bootstrap/node.js where they get
written to the process object conditionally for clarity.
Refs: https://github.com/nodejs/node/issues/24961
PR-URL: https://github.com/nodejs/node/pull/25066
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
37 lines
852 B
JavaScript
37 lines
852 B
JavaScript
'use strict';
|
|
// Flags: --expose_internals
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const fixtures = require('../common/fixtures');
|
|
const { internalBinding } = require('internal/test/binding');
|
|
|
|
const {
|
|
getHiddenValue,
|
|
setHiddenValue,
|
|
arrow_message_private_symbol: kArrowMessagePrivateSymbolIndex
|
|
} = internalBinding('util');
|
|
|
|
assert.strictEqual(
|
|
getHiddenValue({}, kArrowMessagePrivateSymbolIndex),
|
|
undefined);
|
|
|
|
const obj = {};
|
|
assert.strictEqual(
|
|
setHiddenValue(obj, kArrowMessagePrivateSymbolIndex, 'bar'),
|
|
true);
|
|
assert.strictEqual(
|
|
getHiddenValue(obj, kArrowMessagePrivateSymbolIndex),
|
|
'bar');
|
|
|
|
let arrowMessage;
|
|
|
|
try {
|
|
require(fixtures.path('syntax', 'bad_syntax'));
|
|
} catch (err) {
|
|
arrowMessage =
|
|
getHiddenValue(err, kArrowMessagePrivateSymbolIndex);
|
|
}
|
|
|
|
assert(/bad_syntax\.js:1/.test(arrowMessage));
|