Skip to content

Commit 1772977

Browse files
Translate experimental_taintUniqueValue.md to Portuguese (#1057)
1 parent 9c48ce2 commit 1772977

File tree

1 file changed

+44
-48
lines changed

1 file changed

+44
-48
lines changed

src/content/reference/react/experimental_taintUniqueValue.md

Lines changed: 44 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,146 +4,144 @@ title: experimental_taintUniqueValue
44

55
<Wip>
66

7-
**This API is experimental and is not available in a stable version of React yet.**
7+
**Esta API é experimental e ainda não está disponível em uma versão estável do React.**
88

9-
You can try it by upgrading React packages to the most recent experimental version:
9+
Você pode experimentá-la atualizando os pacotes do React para a versão experimental mais recente:
1010

1111
- `react@experimental`
1212
- `react-dom@experimental`
1313
- `eslint-plugin-react-hooks@experimental`
1414

15-
Experimental versions of React may contain bugs. Don't use them in production.
15+
As versões experimentais do React podem conter erros. Não as use na produção.
1616

17-
This API is only available inside [React Server Components](/reference/rsc/use-client).
17+
Esta API só está disponível dentro de [Componentes de Servidor React](/reference/rsc/use-client).
1818

1919
</Wip>
2020

21-
2221
<Intro>
2322

24-
`taintUniqueValue` lets you prevent unique values from being passed to Client Components like passwords, keys, or tokens.
23+
`taintUniqueValue` permite impedir que valores exclusivos sejam passados para Componentes de Cliente, como senhas, chaves ou tokens.
2524

2625
```js
2726
taintUniqueValue(errMessage, lifetime, value)
2827
```
2928

30-
To prevent passing an object containing sensitive data, see [`taintObjectReference`](/reference/react/experimental_taintObjectReference).
29+
Para impedir a passagem de um objeto contendo dados sensíveis, consulte [`taintObjectReference`](/reference/react/experimental_taintObjectReference).
3130

3231
</Intro>
3332

3433
<InlineToc />
3534

3635
---
3736

38-
## Reference {/*reference*/}
37+
## Referência {/*reference*/}
3938

4039
### `taintUniqueValue(message, lifetime, value)` {/*taintuniquevalue*/}
4140

42-
Call `taintUniqueValue` with a password, token, key or hash to register it with React as something that should not be allowed to be passed to the Client as is:
41+
Chame `taintUniqueValue` com uma senha, token, chave ou hash para registrá-lo com o React como algo que não deve ser permitido passar para o Cliente como está:
4342

4443
```js
4544
import {experimental_taintUniqueValue} from 'react';
4645

4746
experimental_taintUniqueValue(
48-
'Do not pass secret keys to the client.',
47+
'Não passe chaves secretas para o cliente.',
4948
process,
5049
process.env.SECRET_KEY
5150
);
5251
```
5352

54-
[See more examples below.](#usage)
53+
[Veja mais exemplos abaixo.](#usage)
5554

56-
#### Parameters {/*parameters*/}
55+
#### Parâmetros {/*parameters*/}
5756

58-
* `message`: The message you want to display if `value` is passed to a Client Component. This message will be displayed as a part of the Error that will be thrown if `value` is passed to a Client Component.
57+
* `message`: A mensagem que você deseja exibir se `value` for passado para um Componente de Cliente. Esta mensagem será exibida como parte do Erro que será lançado se `value` for passado para um Componente de Cliente.
5958

60-
* `lifetime`: Any object that indicates how long `value` should be tainted. `value` will be blocked from being sent to any Client Component while this object still exists. For example, passing `globalThis` blocks the value for the lifetime of an app. `lifetime` is typically an object whose properties contains `value`.
59+
* `lifetime`: Qualquer objeto que indique por quanto tempo `value` deve ser contaminado. `value` será bloqueado de ser enviado para qualquer Componente de Cliente enquanto este objeto ainda existir. Por exemplo, passar `globalThis` bloqueia o valor durante o tempo de vida de um aplicativo. `lifetime` é tipicamente um objeto cujas propriedades contêm `value`.
6160

62-
* `value`: A string, bigint or TypedArray. `value` must be a unique sequence of characters or bytes with high entropy such as a cryptographic token, private key, hash, or a long password. `value` will be blocked from being sent to any Client Component.
61+
* `value`: Uma string, bigint ou TypedArray. `value` deve ser uma sequência exclusiva de caracteres ou bytes com alta entropia, como um token criptográfico, chave privada, hash ou uma senha longa. `value` será bloqueado de ser enviado para qualquer Componente de Cliente.
6362

64-
#### Returns {/*returns*/}
63+
#### Retorna {/*returns*/}
6564

66-
`experimental_taintUniqueValue` returns `undefined`.
65+
`experimental_taintUniqueValue` retorna `undefined`.
6766

68-
#### Caveats {/*caveats*/}
67+
#### Ressalvas {/*caveats*/}
6968

70-
* Deriving new values from tainted values can compromise tainting protection. New values created by uppercasing tainted values, concatenating tainted string values into a larger string, converting tainted values to base64, substringing tainted values, and other similar transformations are not tainted unless you explicitly call `taintUniqueValue` on these newly created values.
71-
* Do not use `taintUniqueValue` to protect low-entropy values such as PIN codes or phone numbers. If any value in a request is controlled by an attacker, they could infer which value is tainted by enumerating all possible values of the secret.
69+
* Derivar novos valores de valores contaminados pode comprometer a proteção contra contaminação. Novos valores criados por uppercase de valores contaminados, concatenando valores de string contaminados em uma string maior, convertendo valores contaminados para base64, substringando valores contaminados e outras transformações semelhantes não são contaminados, a menos que você explicitamente chame `taintUniqueValue` nesses valores recém-criados.
70+
* Não use `taintUniqueValue` para proteger valores de baixa entropia, como códigos PIN ou números de telefone. Se algum valor em uma solicitação for controlado por um invasor, ele poderá inferir qual valor está contaminado enumerando todos os valores possíveis do segredo.
7271

7372
---
7473

75-
## Usage {/*usage*/}
74+
## Uso {/*usage*/}
7675

77-
### Prevent a token from being passed to Client Components {/*prevent-a-token-from-being-passed-to-client-components*/}
76+
### Impedir que um token seja passado para Componentes de Cliente {/*prevent-a-token-from-being-passed-to-client-components*/}
7877

79-
To ensure that sensitive information such as passwords, session tokens, or other unique values do not inadvertently get passed to Client Components, the `taintUniqueValue` function provides a layer of protection. When a value is tainted, any attempt to pass it to a Client Component will result in an error.
78+
Para garantir que informações confidenciais, como senhas, tokens de sessão ou outros valores exclusivos, não sejam passados inadvertidamente para Componentes de Cliente, a função `taintUniqueValue` oferece uma camada de proteção. Quando um valor é contaminado, qualquer tentativa de passá-lo para um Componente de Cliente resultará em um erro.
8079

81-
The `lifetime` argument defines the duration for which the value remains tainted. For values that should remain tainted indefinitely, objects like [`globalThis`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis) or `process` can serve as the `lifetime` argument. These objects have a lifespan that spans the entire duration of your app's execution.
80+
O argumento `lifetime` define a duração em que o valor permanece contaminado. Para valores que devem permanecer contaminados indefinidamente, objetos como [`globalThis`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis) ou `process` podem servir como argumento `lifetime`. Esses objetos têm um tempo de vida que abrange toda a duração da execução do seu aplicativo.
8281

8382
```js
8483
import {experimental_taintUniqueValue} from 'react';
8584

8685
experimental_taintUniqueValue(
87-
'Do not pass a user password to the client.',
86+
'Não passe uma senha de usuário para o cliente.',
8887
globalThis,
8988
process.env.SECRET_KEY
9089
);
9190
```
9291

93-
If the tainted value's lifespan is tied to a object, the `lifetime` should be the object that encapsulates the value. This ensures the tainted value remains protected for the lifetime of the encapsulating object.
92+
Se o tempo de vida do valor contaminado estiver ligado a um objeto, o `lifetime` deve ser o objeto que encapsula o valor. Isso garante que o valor contaminado permaneça protegido durante a vida útil do objeto encapsulador.
9493

9594
```js
9695
import {experimental_taintUniqueValue} from 'react';
9796

9897
export async function getUser(id) {
9998
const user = await db`SELECT * FROM users WHERE id = ${id}`;
10099
experimental_taintUniqueValue(
101-
'Do not pass a user session token to the client.',
100+
'Não passe um token de sessão do usuário para o cliente.',
102101
user,
103102
user.session.token
104103
);
105104
return user;
106105
}
107106
```
108107

109-
In this example, the `user` object serves as the `lifetime` argument. If this object gets stored in a global cache or is accessible by another request, the session token remains tainted.
108+
Neste exemplo, o objeto `user` serve como argumento `lifetime`. Se este objeto for armazenado em um cache global ou for acessível por outra requisição, o token da sessão permanecerá contaminado.
110109

111110
<Pitfall>
112111

113-
**Do not rely solely on tainting for security.** Tainting a value doesn't block every possible derived value. For example, creating a new value by upper casing a tainted string will not taint the new value.
114-
112+
**Não confie apenas na contaminação para segurança.** Contaminar um valor não bloqueia todos os valores derivados possíveis. Por exemplo, a criação de um novo valor por upper casing de uma string contaminada não contaminará o novo valor.
115113

116114
```js
117115
import {experimental_taintUniqueValue} from 'react';
118116

119117
const password = 'correct horse battery staple';
120118

121119
experimental_taintUniqueValue(
122-
'Do not pass the password to the client.',
120+
'Não passe a senha para o cliente.',
123121
globalThis,
124122
password
125123
);
126124

127-
const uppercasePassword = password.toUpperCase() // `uppercasePassword` is not tainted
125+
const uppercasePassword = password.toUpperCase() // `uppercasePassword` não está contaminado
128126
```
129127

130-
In this example, the constant `password` is tainted. Then `password` is used to create a new value `uppercasePassword` by calling the `toUpperCase` method on `password`. The newly created `uppercasePassword` is not tainted.
128+
Neste exemplo, a constante `password` está contaminada. Então `password` é usado para criar um novo valor `uppercasePassword` chamando o método `toUpperCase` em `password`. O `uppercasePassword` recém-criado não está contaminado.
131129

132-
Other similar ways of deriving new values from tainted values like concatenating it into a larger string, converting it to base64, or returning a substring create untained values.
130+
Outras formas semelhantes de derivar novos valores de valores contaminados, como concatená-lo em uma string maior, convertê-lo para base64 ou retornar uma substring, criam valores não contaminados.
133131

134-
Tainting only protects against simple mistakes like explicitly passing secret values to the client. Mistakes in calling the `taintUniqueValue` like using a global store outside of React, without the corresponding lifetime object, can cause the tainted value to become untainted. Tainting is a layer of protection; a secure app will have multiple layers of protection, well designed APIs, and isolation patterns.
132+
A contaminação só protege contra erros simples, como passar explicitamente valores secretos para o cliente. Erros na chamada de `taintUniqueValue`, como usar um armazenamento global fora do React, sem o objeto de tempo de vida correspondente, podem fazer com que o valor contaminado se torne não contaminado. A contaminação é uma camada de proteção; um aplicativo seguro terá várias camadas de proteção, APIs bem projetadas e padrões de isolamento.
135133

136134
</Pitfall>
137135

138136
<DeepDive>
139137

140-
#### Using `server-only` and `taintUniqueValue` to prevent leaking secrets {/*using-server-only-and-taintuniquevalue-to-prevent-leaking-secrets*/}
138+
#### Usando `server-only` e `taintUniqueValue` para evitar vazamento de segredos {/*using-server-only-and-taintuniquevalue-to-prevent-leaking-secrets*/}
141139

142-
If you're running a Server Components environment that has access to private keys or passwords such as database passwords, you have to be careful not to pass that to a Client Component.
140+
Se você estiver executando um ambiente de Componentes de Servidor que tenha acesso a chaves privadas ou senhas, como senhas de banco de dados, você deve ter cuidado para não passá-las para um Componente de Cliente.
143141

144142
```js
145143
export async function Dashboard(props) {
146-
// DO NOT DO THIS
144+
// NÃO FAÇA ISSO
147145
return <Overview password={process.env.API_PASSWORD} />;
148146
}
149147
```
@@ -162,11 +160,11 @@ export async function Overview({ password }) {
162160
}
163161
```
164162

165-
This example would leak the secret API token to the client. If this API token can be used to access data this particular user shouldn't have access to, it could lead to a data breach.
163+
Este exemplo vazaria o token secreto da API para o cliente. Se este token da API puder ser usado para acessar dados que este usuário em particular não deveria ter acesso, isso poderia levar a uma violação de dados.
166164

167165
[comment]: <> (TODO: Link to `server-only` docs once they are written)
168166

169-
Ideally, secrets like this are abstracted into a single helper file that can only be imported by trusted data utilities on the server. The helper can even be tagged with [`server-only`](https://www.npmjs.com/package/server-only) to ensure that this file isn't imported on the client.
167+
Idealmente, segredos como este são abstraídos em um único arquivo auxiliar que só pode ser importado por utilitários de dados confiáveis no servidor. O auxiliar pode até ser marcado com [`server-only`](https://www.npmjs.com/package/server-only) para garantir que este arquivo não seja importado no cliente.
170168

171169
```js
172170
import "server-only";
@@ -177,23 +175,21 @@ export function fetchAPI(url) {
177175
}
178176
```
179177

180-
Sometimes mistakes happen during refactoring and not all of your colleagues might know about this.
181-
To protect against this mistakes happening down the line we can "taint" the actual password:
178+
Às vezes, erros acontecem durante a refatoração e nem todos os seus colegas podem saber sobre isso.
179+
Para se proteger contra a ocorrência desses erros no futuro, podemos "contaminar" a senha real:
182180

183181
```js
184182
import "server-only";
185183
import {experimental_taintUniqueValue} from 'react';
186184

187185
experimental_taintUniqueValue(
188-
'Do not pass the API token password to the client. ' +
189-
'Instead do all fetches on the server.'
186+
'Não passe a senha do token da API para o cliente. ' +
187+
'Em vez disso, faça todas as buscas no servidor.'
190188
process,
191189
process.env.API_PASSWORD
192190
);
193191
```
194192

195-
Now whenever anyone tries to pass this password to a Client Component, or send the password to a Client Component with a Server Function, an error will be thrown with message you defined when you called `taintUniqueValue`.
193+
Agora, sempre que alguém tentar passar esta senha para um Componente de Cliente, ou enviar a senha para um Componente de Cliente com uma Função de Servidor, um erro será lançado com a mensagem que você definiu quando chamou `taintUniqueValue`.
196194

197-
</DeepDive>
198-
199-
---
195+
</DeepDive>

0 commit comments

Comments
 (0)