diff --git a/packages/react-client/src/__tests__/ReactFlight-test.js b/packages/react-client/src/__tests__/ReactFlight-test.js index 82206b6151caa..a04a9e2bca9f6 100644 --- a/packages/react-client/src/__tests__/ReactFlight-test.js +++ b/packages/react-client/src/__tests__/ReactFlight-test.js @@ -1475,7 +1475,7 @@ describe('ReactFlight', () => { name: 'Seb', age: 'rather not say', }; - ReactServer.unstable_taintShallowObject( + ReactServer.experimental_taintObjectReference( "Don't pass the raw user object to the client", user, ); @@ -1497,7 +1497,7 @@ describe('ReactFlight', () => { const User = clientReference(UserClient); function change() {} - ReactServer.unstable_taintShallowObject( + ReactServer.experimental_taintObjectReference( 'A change handler cannot be passed to a client component', change, ); @@ -1525,7 +1525,7 @@ describe('ReactFlight', () => { SECRET: '3e971ecc1485fe78625598bf9b6f85db', }, }; - ReactServer.unstable_taintValue( + ReactServer.experimental_taintUniqueValue( 'Cannot pass a secret token to the client', process, process.env.SECRET, @@ -1555,7 +1555,7 @@ describe('ReactFlight', () => { name: 'Seb', token: BigInt('0x3e971ecc1485fe78625598bf9b6f85dc'), }; - ReactServer.unstable_taintValue( + ReactServer.experimental_taintUniqueValue( 'Cannot pass a secret token to the client', currentUser, currentUser.token, @@ -1586,7 +1586,7 @@ describe('ReactFlight', () => { name: 'Seb', token: new Uint32Array([0x3e971ecc, 0x1485fe78, 0x625598bf, 0x9b6f85dd]), }; - ReactServer.unstable_taintValue( + ReactServer.experimental_taintUniqueValue( 'Cannot pass a secret token to the client', currentUser, currentUser.token, @@ -1619,7 +1619,7 @@ describe('ReactFlight', () => { name: 'Seb', token: '3e971ecc1485fe78625598bf9b6f85db', }; - ReactServer.unstable_taintValue( + ReactServer.experimental_taintUniqueValue( 'Cannot pass a secret token to the client', user, user.token, diff --git a/packages/react/src/ReactSharedSubset.experimental.js b/packages/react/src/ReactSharedSubset.experimental.js index 94d142e1c22d5..45baaadc89f7b 100644 --- a/packages/react/src/ReactSharedSubset.experimental.js +++ b/packages/react/src/ReactSharedSubset.experimental.js @@ -16,8 +16,8 @@ export {default as __SECRET_SERVER_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED} fr // These are server-only export { - taintValue as unstable_taintValue, - taintShallowObject as unstable_taintShallowObject, + taintUniqueValue as experimental_taintUniqueValue, + taintObjectReference as experimental_taintObjectReference, } from './ReactTaint'; export { diff --git a/packages/react/src/ReactTaint.js b/packages/react/src/ReactTaint.js index cc54f89b17688..51afbf60d4749 100644 --- a/packages/react/src/ReactTaint.js +++ b/packages/react/src/ReactTaint.js @@ -52,7 +52,7 @@ const finalizationRegistry = ? new FinalizationRegistry(cleanup) : null; -export function taintValue( +export function taintUniqueValue( message: ?string, lifetime: Reference, value: string | bigint | $ArrayBufferView, @@ -89,7 +89,7 @@ export function taintValue( const kind = value === null ? 'null' : typeof value; if (kind === 'object' || kind === 'function') { throw new Error( - 'taintValue cannot taint objects or functions. Try taintShallowObject instead.', + 'taintUniqueValue cannot taint objects or functions. Try taintObjectReference instead.', ); } throw new Error( @@ -113,7 +113,10 @@ export function taintValue( } } -export function taintShallowObject(message: ?string, object: Reference): void { +export function taintObjectReference( + message: ?string, + object: Reference, +): void { if (!enableTaint) { throw new Error('Not implemented.'); } @@ -121,7 +124,7 @@ export function taintShallowObject(message: ?string, object: Reference): void { message = '' + (message || defaultMessage); if (typeof object === 'string' || typeof object === 'bigint') { throw new Error( - 'Only objects or functions can be passed to taintShallowObject. Try taintValue instead.', + 'Only objects or functions can be passed to taintObjectReference. Try taintUniqueValue instead.', ); } if ( @@ -129,7 +132,7 @@ export function taintShallowObject(message: ?string, object: Reference): void { (typeof object !== 'object' && typeof object !== 'function') ) { throw new Error( - 'Only objects or functions can be passed to taintShallowObject.', + 'Only objects or functions can be passed to taintObjectReference.', ); } TaintRegistryObjects.set(object, message); diff --git a/scripts/error-codes/codes.json b/scripts/error-codes/codes.json index 373bc8762c68c..2b29b27be8b2e 100644 --- a/scripts/error-codes/codes.json +++ b/scripts/error-codes/codes.json @@ -479,8 +479,8 @@ "491": "It should not be possible to postpone both at the root of an element as well as a slot below. This is a bug in React.", "492": "The \"react\" package in this environment is not configured correctly. The \"react-server\" condition must be enabled in any environment that runs React Server Components.", "493": "To taint a value, a life time must be defined by passing an object that holds the value.", - "494": "taintValue cannot taint objects or functions. Try taintShallowObject instead.", + "494": "taintUniqueValue cannot taint objects or functions. Try taintObjectReference instead.", "495": "Cannot taint a %s because the value is too general and cannot be a secret by", - "496": "Only objects or functions can be passed to taintShallowObject. Try taintValue instead.", - "497": "Only objects or functions can be passed to taintShallowObject." + "496": "Only objects or functions can be passed to taintObjectReference. Try taintUniqueValue instead.", + "497": "Only objects or functions can be passed to taintObjectReference." } \ No newline at end of file