@workos/oagen-emitters 0.11.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +19 -0
- package/dist/index.d.mts +4 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/{plugin-DW3cnedr.mjs → plugin-CmfzawTp.mjs} +2851 -524
- package/dist/plugin-CmfzawTp.mjs.map +1 -0
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +1 -1
- package/docs/sdk-architecture/rust.md +323 -0
- package/package.json +9 -9
- package/src/index.ts +1 -0
- package/src/plugin.ts +2 -1
- package/src/python/path-expression.ts +75 -26
- package/src/python/resources.ts +0 -9
- package/src/rust/client.ts +62 -0
- package/src/rust/enums.ts +201 -0
- package/src/rust/fixtures.ts +196 -0
- package/src/rust/index.ts +95 -0
- package/src/rust/manifest.ts +31 -0
- package/src/rust/models.ts +165 -0
- package/src/rust/naming.ts +131 -0
- package/src/rust/resources.ts +1324 -0
- package/src/rust/secret.ts +59 -0
- package/src/rust/tests.ts +818 -0
- package/src/rust/type-map.ts +225 -0
- package/test/entrypoint.test.ts +1 -0
- package/test/plugin.test.ts +2 -1
- package/test/python/resources.test.ts +2 -2
- package/test/rust/client.test.ts +62 -0
- package/test/rust/enums.test.ts +117 -0
- package/test/rust/fixtures.test.ts +227 -0
- package/test/rust/manifest.test.ts +73 -0
- package/test/rust/models.test.ts +177 -0
- package/test/rust/resources.test.ts +748 -0
- package/test/rust/tests.test.ts +504 -0
- package/test/rust/type-map.test.ts +83 -0
- package/dist/plugin-DW3cnedr.mjs.map +0 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Heuristics for spotting fields that hold secrets. The Rust emitter wraps
|
|
3
|
+
* such fields in `crate::SecretString` so their `Debug` representation does
|
|
4
|
+
* not accidentally leak the value.
|
|
5
|
+
*
|
|
6
|
+
* The list is intentionally conservative — only fields whose names strongly
|
|
7
|
+
* imply a credential or token are redacted. Generic names like `value` are
|
|
8
|
+
* skipped; the cost of a leaked secret is high enough that we'd rather miss
|
|
9
|
+
* the occasional secret than redact non-secret data and surprise users.
|
|
10
|
+
*/
|
|
11
|
+
const EXACT_NAMES = new Set<string>([
|
|
12
|
+
'password',
|
|
13
|
+
'new_password',
|
|
14
|
+
'old_password',
|
|
15
|
+
'password_hash',
|
|
16
|
+
'secret',
|
|
17
|
+
'client_secret',
|
|
18
|
+
'signing_secret',
|
|
19
|
+
'webhook_secret',
|
|
20
|
+
'token',
|
|
21
|
+
'access_token',
|
|
22
|
+
'refresh_token',
|
|
23
|
+
'id_token',
|
|
24
|
+
'session_token',
|
|
25
|
+
'authentication_token',
|
|
26
|
+
'pending_authentication_token',
|
|
27
|
+
'invitation_token',
|
|
28
|
+
'private_key',
|
|
29
|
+
'pem_private_key',
|
|
30
|
+
'data_key',
|
|
31
|
+
'encrypted_keys',
|
|
32
|
+
'encrypted_data_key',
|
|
33
|
+
'shared_secret',
|
|
34
|
+
'totp_secret',
|
|
35
|
+
'jwt',
|
|
36
|
+
]);
|
|
37
|
+
|
|
38
|
+
/** True when the field name strongly implies it holds a secret value. */
|
|
39
|
+
export function isSensitiveFieldName(name: string): boolean {
|
|
40
|
+
const norm = name.toLowerCase().replace(/-/g, '_');
|
|
41
|
+
if (EXACT_NAMES.has(norm)) return true;
|
|
42
|
+
// Common suffix forms: `*_token`, `*_secret`, `*_password`, `*_api_key`.
|
|
43
|
+
if (/_password(_hash)?$/.test(norm)) return true;
|
|
44
|
+
if (norm.endsWith('_secret')) return true;
|
|
45
|
+
if (norm.endsWith('_token') && norm !== 'csrf_token' && norm !== 'request_token') return true;
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* If `rustType` is `String` or `Option<String>` and `fieldName` looks
|
|
51
|
+
* sensitive, return the redacted equivalent (`crate::SecretString` or
|
|
52
|
+
* `Option<crate::SecretString>`). Otherwise return `rustType` unchanged.
|
|
53
|
+
*/
|
|
54
|
+
export function applySecretRedaction(rustType: string, fieldName: string): string {
|
|
55
|
+
if (!isSensitiveFieldName(fieldName)) return rustType;
|
|
56
|
+
if (rustType === 'String') return 'crate::SecretString';
|
|
57
|
+
if (rustType === 'Option<String>') return 'Option<crate::SecretString>';
|
|
58
|
+
return rustType;
|
|
59
|
+
}
|