Decrypt Data
使用 AES 解密数据。
解密由 crypto.encrypt 生成的 v1.<iv>.<tag>.<ciphertext> 令牌,并在 data 中返回原始 JSON 值。
工作原理
- 解析配置;
encrypted通常为{{ $json.encrypted }}。 - 当
encrypted为空时,以encrypted data is required从error输出。 - 选择密钥:优先
connection_id,否则使用字面量key。 - 检查格式:由点号分隔的四段,第一段为
v1。 - 使用 AES-256-GCM 解密并校验认证标签:密钥错误或令牌被篡改都会失败。
- 从
out返回{ data: <原始值> },审计记录位于meta.crypto。
在工作流中
节点在工作流文件(draft_nodes[])中的写法,以及一次成功运行的 envelope。
{
"node_id": "node-decrypt-payment",
"label": "Decrypt payment details",
"operator_slug": "crypto.decrypt",
"operator_version": "2.0.0",
"config": {
"connection_id": "pi-credential-xxxx",
"encrypted": "{{ $json.encrypted }}"
}
}{
"ok": true,
"port": "out",
"data": {
"data": {
"card_last4": "4242",
"amount": 129.9,
"currency": "USD"
}
},
"meta": {
"crypto": {
"op": "decrypt",
"key_source": "credential",
"alias": "connection",
"credential_id": "pi-credential-xxxx",
"algorithm": "aes-256-gcm",
"ok": true
},
"warnings": []
}
}配置
-
connection_idstring 可选 -
Sommatic AI credential resolved server-side (recommended). Accepts credentials of type `encryption-key`.
-
keystring 可选 -
Encryption key as a literal. Allowed, but it is stored in the flow, its version history and Git: prefer connection_id.
-
encryptedstring 必填 -
v1.<iv>.<tag>.<ciphertext>
代码中的行为
除 schema 描述之外,实现代码对这些键的实际处理。
-
connection_id - 优先于字面量
key。凭据在节点运行时于服务端解析,密钥不会出现在流程中。字符串密钥直接作为密钥使用;对象密钥必须包含key或secret。必须与crypto.encrypt使用的密钥相同。 -
key - 字面量密钥可以使用,但会保存在流程、版本历史和 Git 中,并且每次运行都会在
meta.warnings中报告。建议使用connection_id。
输出端口
out 默认 令牌已解密并通过认证。
{
"data": {
"card_last4": "4242",
"amount": 129.9,
"currency": "USD"
}
}error 令牌缺失或格式错误、密钥错误,或凭据无法解析。
{
"error": "Decryption failed: wrong key or tampered value"
}在表达式中
后续节点可通过 $("Decrypt Data").item.json.<路径> 读取此节点输出中的内容(请把 Decrypt Data 换成你的节点标签)。Editor 标记工作流编辑器在 Previous Nodes 中提示的路径(输出契约);Worker 标记 worker 实际通过 out 返回的路径,依据“端口”一节所示的输出。
| 表达式 | Editor | Worker |
|---|---|---|
$("Decrypt Data").item.json.dataDecrypted value | ||
$("Decrypt Data").item.json.data.card_last4 | — | |
$("Decrypt Data").item.json.data.amount | — | |
$("Decrypt Data").item.json.data.currency | — |
— Worker: worker 会返回它,但编辑器不会提示:请手动输入。对象内部的键可能取决于你的数据或配置(例如每个标签一个键)。
错误
| 消息 | 端口 | 原因与处理 |
|---|---|---|
encrypted data is required | error | encrypted 为空。 |
Invalid encrypted value: expected v1.<iv>.<tag>.<ciphertext> | error | 该值不是 crypto.encrypt 生成的令牌(例如传入了整个 { encrypted, algorithm } 对象,而不是 encrypted)。 |
Decryption failed: wrong key or tampered value | error | 密钥与加密时使用的不同,或令牌被修改或截断。 |
A key is required: pass { credential: "<alias>" } (recommended) or { key } | error | connection_id 和字面量密钥字段都未设置。请在 connection_id 中选择一个凭据。 |
credential binding 'connection' has no key usable for symmetric | error | 凭据已解析,但其密钥为空,或是缺少可用字段的对象。请将密钥存为字符串,或存为包含本操作所读字段的对象(见 connection_id)。 |
Failed to resolve connection <connection_id>: <detail> | error | 凭据 id 不存在,或该工作流无权使用。请检查 id 和凭据类型。 |
输入契约
-
connection_idstring 可选 -
keystring 可选 -
encryptedstring 必填
输出契约
-
dataany 可选 -
Decrypted value
契约(JSON Schema)
与编排器声明完全一致的定义。All 是完整的 *.definition.js;可与上方各节对照,找出文档与 schema 之间的差异。发布前可用它校验节点。
{
"slug": "crypto.decrypt",
"name": "Decrypt Data",
"category": "identity",
"version": "2.0.0",
"description": "Decrypts a value produced by crypto.encrypt or $encrypt. Fails if the key is wrong or the value was altered.",
"capabilities": [
"crypto",
"decryption"
],
"config_schema": {
"type": "object",
"properties": {
"connection_id": {
"type": "string",
"title": "Encryption key credential",
"description": "Sommatic AI credential resolved server-side (recommended). Accepts credentials of type `encryption-key`.",
"ui_widget": "connection_picker",
"ui_options": {
"credential_types": [
"encryption-key"
]
}
},
"key": {
"type": "string",
"ui_widget": "password",
"x-literal-secret": true,
"description": "Encryption key as a literal. Allowed, but it is stored in the flow, its version history and Git: prefer connection_id."
},
"encrypted": {
"type": "string",
"description": "v1.<iv>.<tag>.<ciphertext>"
}
},
"required": [
"encrypted"
]
},
"input_contract_schema": {
"type": "object",
"properties": {
"connection_id": {
"type": "string"
},
"key": {
"type": "string"
},
"encrypted": {
"type": "string"
}
},
"required": [
"encrypted"
]
},
"output_contract_schema": {
"type": "object",
"properties": {
"data": {
"description": "Decrypted value"
}
}
},
"ports": [
{
"port_id": "out",
"label": "Decrypted",
"description": "Decrypted string",
"is_default": true,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"description": "Decryption failed",
"is_default": false,
"supports_condition": false
}
],
"execution_mode": "sync",
"required_resources": [],
"compatible_worker_pools": [
"standard"
],
"tags": [
"crypto",
"security"
],
"is_stateful": false,
"publisher": {
"identity": "org_veripass",
"profile": {
"name": "Veripass",
"verified": true,
"url": "https://me.veripass.com/veripass",
"logo_url": null
}
}
}{
"type": "object",
"properties": {
"connection_id": {
"type": "string",
"title": "Encryption key credential",
"description": "Sommatic AI credential resolved server-side (recommended). Accepts credentials of type `encryption-key`.",
"ui_widget": "connection_picker",
"ui_options": {
"credential_types": [
"encryption-key"
]
}
},
"key": {
"type": "string",
"ui_widget": "password",
"x-literal-secret": true,
"description": "Encryption key as a literal. Allowed, but it is stored in the flow, its version history and Git: prefer connection_id."
},
"encrypted": {
"type": "string",
"description": "v1.<iv>.<tag>.<ciphertext>"
}
},
"required": [
"encrypted"
]
}{
"type": "object",
"properties": {
"connection_id": {
"type": "string"
},
"key": {
"type": "string"
},
"encrypted": {
"type": "string"
}
},
"required": [
"encrypted"
]
}{
"type": "object",
"properties": {
"data": {
"description": "Decrypted value"
}
}
}[
{
"port_id": "out",
"label": "Decrypted",
"description": "Decrypted string",
"is_default": true,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"description": "Decryption failed",
"is_default": false,
"supports_condition": false
}
]执行
- 执行方式
sync- 有状态
- 否
- 能力
cryptodecryption- 标签
cryptosecurity
说明与限制
- 解密值位于
data.data:在下游用{{ $json.data.amount }}读取。 - 从这里开始,解密后的值在运行中是明文数据:避免把它发送到不需要的日志或外部系统。
- 从
error端口输出不会使运行失败:引擎沿error上的连线继续;若没有连线,该分支直接结束。
已对照编排器代码核实 · 31e874b · 2026-11-26