Skip to content

Commit 4f2c039

Browse files
committed
Rename APIs
1 parent d4f1c3f commit 4f2c039

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

packages/react-client/src/__tests__/ReactFlight-test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,7 +1475,7 @@ describe('ReactFlight', () => {
14751475
name: 'Seb',
14761476
age: 'rather not say',
14771477
};
1478-
ReactServer.unstable_taintShallowObject(
1478+
ReactServer.experimental_taintObjectReference(
14791479
"Don't pass the raw user object to the client",
14801480
user,
14811481
);
@@ -1497,7 +1497,7 @@ describe('ReactFlight', () => {
14971497
const User = clientReference(UserClient);
14981498

14991499
function change() {}
1500-
ReactServer.unstable_taintShallowObject(
1500+
ReactServer.experimental_taintObjectReference(
15011501
'A change handler cannot be passed to a client component',
15021502
change,
15031503
);
@@ -1525,7 +1525,7 @@ describe('ReactFlight', () => {
15251525
SECRET: '3e971ecc1485fe78625598bf9b6f85db',
15261526
},
15271527
};
1528-
ReactServer.unstable_taintValue(
1528+
ReactServer.experimental_taintUniqueValue(
15291529
'Cannot pass a secret token to the client',
15301530
process,
15311531
process.env.SECRET,
@@ -1556,7 +1556,7 @@ describe('ReactFlight', () => {
15561556
name: 'Seb',
15571557
token: BigInt('0x3e971ecc1485fe78625598bf9b6f85dc'),
15581558
};
1559-
ReactServer.unstable_taintValue(
1559+
ReactServer.experimental_taintUniqueValue(
15601560
'Cannot pass a secret token to the client',
15611561
currentUser,
15621562
currentUser.token,
@@ -1587,7 +1587,7 @@ describe('ReactFlight', () => {
15871587
name: 'Seb',
15881588
token: new Uint32Array([0x3e971ecc, 0x1485fe78, 0x625598bf, 0x9b6f85dd]),
15891589
};
1590-
ReactServer.unstable_taintValue(
1590+
ReactServer.experimental_taintUniqueValue(
15911591
'Cannot pass a secret token to the client',
15921592
currentUser,
15931593
currentUser.token,
@@ -1620,7 +1620,7 @@ describe('ReactFlight', () => {
16201620
name: 'Seb',
16211621
token: '3e971ecc1485fe78625598bf9b6f85db',
16221622
};
1623-
ReactServer.unstable_taintValue(
1623+
ReactServer.experimental_taintUniqueValue(
16241624
'Cannot pass a secret token to the client',
16251625
user,
16261626
user.token,

packages/react/src/ReactSharedSubset.experimental.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ export {default as __SECRET_SERVER_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED} fr
1616

1717
// These are server-only
1818
export {
19-
taintValue as unstable_taintValue,
20-
taintShallowObject as unstable_taintShallowObject,
19+
taintUniqueValue as experimental_taintUniqueValue,
20+
taintObjectReference as experimental_taintObjectReference,
2121
} from './ReactTaint';
2222

2323
export {

packages/react/src/ReactTaint.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const finalizationRegistry =
5252
? new FinalizationRegistry(cleanup)
5353
: null;
5454

55-
export function taintValue(
55+
export function taintUniqueValue(
5656
message: ?string,
5757
lifetime: Reference,
5858
value: string | bigint | $ArrayBufferView,
@@ -89,7 +89,7 @@ export function taintValue(
8989
const kind = value === null ? 'null' : typeof value;
9090
if (kind === 'object' || kind === 'function') {
9191
throw new Error(
92-
'taintValue cannot taint objects or functions. Try taintShallowObject instead.',
92+
'taintUniqueValue cannot taint objects or functions. Try taintObjectReference instead.',
9393
);
9494
}
9595
throw new Error(
@@ -113,23 +113,26 @@ export function taintValue(
113113
}
114114
}
115115

116-
export function taintShallowObject(message: ?string, object: Reference): void {
116+
export function taintObjectReference(
117+
message: ?string,
118+
object: Reference,
119+
): void {
117120
if (!enableTaint) {
118121
throw new Error('Not implemented.');
119122
}
120123
// eslint-disable-next-line react-internal/safe-string-coercion
121124
message = '' + (message || defaultMessage);
122125
if (typeof object === 'string' || typeof object === 'bigint') {
123126
throw new Error(
124-
'Only objects or functions can be passed to taintShallowObject. Try taintValue instead.',
127+
'Only objects or functions can be passed to taintObjectReference. Try taintUniqueValue instead.',
125128
);
126129
}
127130
if (
128131
object === null ||
129132
(typeof object !== 'object' && typeof object !== 'function')
130133
) {
131134
throw new Error(
132-
'Only objects or functions can be passed to taintShallowObject.',
135+
'Only objects or functions can be passed to taintObjectReference.',
133136
);
134137
}
135138
TaintRegistryObjects.set(object, message);

scripts/error-codes/codes.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,8 +479,8 @@
479479
"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.",
480480
"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.",
481481
"493": "To taint a value, a life time must be defined by passing an object that holds the value.",
482-
"494": "taintValue cannot taint objects or functions. Try taintShallowObject instead.",
482+
"494": "taintUniqueValue cannot taint objects or functions. Try taintObjectReference instead.",
483483
"495": "Cannot taint a %s because the value is too general and cannot be a secret by",
484-
"496": "Only objects or functions can be passed to taintShallowObject. Try taintValue instead.",
485-
"497": "Only objects or functions can be passed to taintShallowObject."
484+
"496": "Only objects or functions can be passed to taintObjectReference. Try taintUniqueValue instead.",
485+
"497": "Only objects or functions can be passed to taintObjectReference."
486486
}

0 commit comments

Comments
 (0)