didit-sdk 2.13.0 → 2.14.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +33 -0
- data/lib/didit/authentication/agent_consent_request.rb +32 -15
- data/lib/didit/authentication/http.rb +45 -10
- data/lib/didit/authentication.rb +7 -4
- data/lib/didit/internal/errors.rb +32 -0
- data/lib/didit/internal/util.rb +34 -0
- data/lib/didit/resources/cases.rb +62 -16
- data/lib/didit/resources/transactions.rb +62 -6
- data/lib/didit/resources/travel_rule.rb +40 -1
- data/lib/didit/resources/workflows.rb +12 -0
- data/lib/didit/types/cases.rb +0 -9
- data/lib/didit/types/components.rb +146 -61
- data/lib/didit/types/transactions.rb +33 -1
- data/lib/didit/types.rb +16 -9
- data/lib/didit/version.rb +1 -1
- data/sig/didit/authentication/agent_consent_request.rbs +3 -2
- data/sig/didit/authentication/http.rbs +4 -1
- data/sig/didit/authentication.rbs +1 -1
- data/sig/didit/internal.rbs +4 -0
- data/sig/didit/resources/cases.rbs +4 -3
- data/sig/didit/resources/transactions.rbs +2 -1
- data/sig/didit/resources/travel_rule.rbs +2 -1
- data/sig/didit/resources/workflows.rbs +2 -2
- data/sig/didit/types/cases.rbs +5 -13
- data/sig/didit/types/components.rbs +127 -55
- data/sig/didit/types/transactions.rbs +29 -2
- data/sig/didit/types/travel_rule.rbs +2 -0
- data/sig/didit/types/workflows.rbs +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4e55798faefc9d3341a382fe76d456d76883ba16eae42b7769aab8eb4f8d4af9
|
|
4
|
+
data.tar.gz: b05f6207b63989f297d2971738b896d6c34a861fc66e1ccbe6ff5f6fb4cf874c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f00a6e6cfac1315d42db66cfd8f39542bd5bad36ef29d780347b6aabb5ac42380ea1d31ef82d2b47caccd9e80c9d1f34227341ce8d904644472517ad0c172b63
|
|
7
|
+
data.tar.gz: 3d188859a29d32fc473c8f6b9d9b39426a25f389fce2eab175cc28d8cf9951b7406fbdcb09b0f01438d7bda2720c6cbac7d70938ccc6e4eb9edc23aa48d8b5f8
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.14.0](https://github.com/didit-protocol/sdk-ruby/compare/v2.13.1...v2.14.0) (2026-11-12)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### API changes that can break typed code
|
|
7
|
+
|
|
8
|
+
* **spec:** `cases.blueprints.publish` (`POST /v3/organization/{organization_id}/application/{application_id}/cases/blueprints/{blueprint_uuid}/publish/`): response `content_config`: type changed from any to object ([f28c0c9](https://github.com/didit-protocol/sdk-ruby/commit/f28c0c91f98e2d6081605397792d6af844c0939b))
|
|
9
|
+
* **spec:** `cases.create` (`POST /v3/organization/{organization_id}/application/{application_id}/cases/`): request body `links[].entity_type`: added (required) ([f28c0c9](https://github.com/didit-protocol/sdk-ruby/commit/f28c0c91f98e2d6081605397792d6af844c0939b))
|
|
10
|
+
* **spec:** `cases.create` (`POST /v3/organization/{organization_id}/application/{application_id}/cases/`): request body `links[].entity_uuid`: added (required) ([f28c0c9](https://github.com/didit-protocol/sdk-ruby/commit/f28c0c91f98e2d6081605397792d6af844c0939b))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* **spec:** sync API spec 2026-11-12 ([f28c0c9](https://github.com/didit-protocol/sdk-ruby/commit/f28c0c91f98e2d6081605397792d6af844c0939b))
|
|
16
|
+
|
|
17
|
+
## [2.13.1](https://github.com/didit-protocol/sdk-ruby/compare/v2.13.0...v2.13.1) (2026-11-12)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **authentication:** a body nested past the depth limit is not JSON ([c0cb38e](https://github.com/didit-protocol/sdk-ruby/commit/c0cb38edf6f8302c640bfac2bac2e8191b3c123f))
|
|
23
|
+
* **authentication:** a failure to encode a consent request has a fixed message ([2f2bdb7](https://github.com/didit-protocol/sdk-ruby/commit/2f2bdb7302fb6b56db5b1b29cd90cf447ef588a5))
|
|
24
|
+
* **authentication:** a malformed 2xx consent error keeps no parser exception as its cause ([e9cad91](https://github.com/didit-protocol/sdk-ruby/commit/e9cad918b725708f14ee37f5f07922ab78d074be))
|
|
25
|
+
* **authentication:** a malformed 2xx consent message reads the content type from the sanitized response ([fa0e897](https://github.com/didit-protocol/sdk-ruby/commit/fa0e897c76d810f473b2f4c69cd6025883ba1ce5))
|
|
26
|
+
* **authentication:** collect consent secrets from the JSON the request carries ([ada5949](https://github.com/didit-protocol/sdk-ruby/commit/ada5949ad9afd041cbf8f2766e5889f66600dae7))
|
|
27
|
+
* **authentication:** read consent secrets from the bytes that were sent ([02a0be4](https://github.com/didit-protocol/sdk-ruby/commit/02a0be4ef2688595a66aeda5f03e512f20109b94))
|
|
28
|
+
* **authentication:** redact every string of the consent assertion from errors ([c1ed630](https://github.com/didit-protocol/sdk-ruby/commit/c1ed63076c21fd9a66939045b026bb68592ad580))
|
|
29
|
+
* **authentication:** redact the parsed agent-consent response, not its raw text ([9d8dfef](https://github.com/didit-protocol/sdk-ruby/commit/9d8dfef87e9c2d2f5433551b75de28a98608cd1b))
|
|
30
|
+
* **authentication:** sanitize the whole consent response once on receipt ([d7f875d](https://github.com/didit-protocol/sdk-ruby/commit/d7f875deabe3cb4a0311ced9d6bf416a4c7ef19d))
|
|
31
|
+
* **authentication:** successful consent responses reach the caller unchanged; fold header-name case ([9becd6d](https://github.com/didit-protocol/sdk-ruby/commit/9becd6d166d122deeec244248890a0a4f5c8b847))
|
|
32
|
+
* **authentication:** the approval-options call encodes through the same fixed-message wrapper ([570043e](https://github.com/didit-protocol/sdk-ruby/commit/570043e36c63e494708c2f7cc8ab0ae412633c1f))
|
|
33
|
+
* **authentication:** treat only assertion strings of 16+ characters as secrets ([e072900](https://github.com/didit-protocol/sdk-ruby/commit/e072900a01bb52e865159ef88811c2398bd442e2))
|
|
34
|
+
* **authentication:** withhold transport causes, redact empty bodies, headers and request id, keep safe key names ([d966dc2](https://github.com/didit-protocol/sdk-ruby/commit/d966dc27fe9dcc0909446272961258cdb22178fb))
|
|
35
|
+
|
|
3
36
|
## [2.13.0](https://github.com/didit-protocol/sdk-ruby/compare/v2.12.0...v2.13.0) (2026-11-11)
|
|
4
37
|
|
|
5
38
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module Didit
|
|
4
4
|
class Authentication
|
|
5
5
|
# Builds and checks the body of +POST agents/consent/+, and names the strings of it that
|
|
6
|
-
# must never reach an error
|
|
6
|
+
# must never reach an error: the challenge and every string of the assertion.
|
|
7
7
|
#
|
|
8
8
|
# @api private
|
|
9
9
|
module AgentConsentRequest
|
|
@@ -12,9 +12,6 @@ module Didit
|
|
|
12
12
|
UUID = /\A[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\z/i
|
|
13
13
|
LIFETIMES = [86_400, 604_800, 2_592_000].freeze
|
|
14
14
|
DECISIONS = %w[approve deny].freeze
|
|
15
|
-
# The assertion members that are secrets.
|
|
16
|
-
ASSERTION_SECRETS = %w[clientDataJSON authenticatorData signature userHandle].freeze
|
|
17
|
-
|
|
18
15
|
# @return [Array(Hash, Array<String>)] the JSON body and its secret strings
|
|
19
16
|
# @raise [Didit::ConfigurationError]
|
|
20
17
|
def self.build(challenge, decision, assertion, scopes, extras = {})
|
|
@@ -25,17 +22,30 @@ module Didit
|
|
|
25
22
|
|
|
26
23
|
# @type var body: Hash[String, untyped]
|
|
27
24
|
body = { "challenge" => challenge, "decision" => decision }
|
|
28
|
-
|
|
29
|
-
unless assertion.nil?
|
|
30
|
-
body["assertion"] = checked_assertion(assertion)
|
|
31
|
-
secrets.concat(assertion_secrets(assertion))
|
|
32
|
-
end
|
|
25
|
+
body["assertion"] = checked_assertion(assertion) unless assertion.nil?
|
|
33
26
|
body["scopes"] = checked_scopes(scopes) unless scopes.nil?
|
|
34
27
|
organization_ids = extras[:organization_ids]
|
|
35
28
|
lifetime = extras[:lifetime]
|
|
36
29
|
body["organization_ids"] = checked_organization_ids(organization_ids) unless organization_ids.nil?
|
|
37
30
|
body["lifetime"] = checked_lifetime(lifetime) unless lifetime.nil?
|
|
38
|
-
|
|
31
|
+
# Encoded exactly once: the plain body decoded from these bytes is what is sent, and the secrets are
|
|
32
|
+
# read from it, so a caller's object is never serialized a second time.
|
|
33
|
+
body = encode_once(body)
|
|
34
|
+
[body, [challenge, *assertion_secrets(body["assertion"])]]
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# A nested object's serializer may put the challenge or a credential in its error message: any failure
|
|
38
|
+
# is a fixed-message error with no cause.
|
|
39
|
+
def self.encode_once(body)
|
|
40
|
+
encoded = nil
|
|
41
|
+
begin
|
|
42
|
+
encoded = JSON.parse(JSON.generate(body))
|
|
43
|
+
rescue StandardError, SystemStackError
|
|
44
|
+
encoded = nil
|
|
45
|
+
end
|
|
46
|
+
raise ConfigurationError, "could not encode the agent consent request." if encoded.nil?
|
|
47
|
+
|
|
48
|
+
encoded
|
|
39
49
|
end
|
|
40
50
|
|
|
41
51
|
def self.checked_organization_ids(ids)
|
|
@@ -63,12 +73,19 @@ module Didit
|
|
|
63
73
|
raise ConfigurationError, "scopes must be a non-empty array of strings such as [\"read\", \"act\"]."
|
|
64
74
|
end
|
|
65
75
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
76
|
+
# Strings shorter than this are not secrets: field names such as "id" and values such as "public-key"
|
|
77
|
+
# would otherwise erase error codes like "invalid_grant" (docs/DESIGN.md section 10).
|
|
78
|
+
# Sensitive values are 16+ chars: user handles are 16-byte ids (22 base64url), credential ids 16+ bytes.
|
|
79
|
+
MIN_SECRET_LENGTH = 16
|
|
69
80
|
|
|
70
|
-
|
|
71
|
-
|
|
81
|
+
# Every string of at least 16 characters inside the assertion, at any depth: object keys and values,
|
|
82
|
+
# array items.
|
|
83
|
+
def self.assertion_secrets(value)
|
|
84
|
+
case value
|
|
85
|
+
when String then value.length >= MIN_SECRET_LENGTH ? [value] : []
|
|
86
|
+
when Hash then value.flat_map { |key, item| assertion_secrets(key.to_s) + assertion_secrets(item) }
|
|
87
|
+
when Array then value.flat_map { |item| assertion_secrets(item) }
|
|
88
|
+
else []
|
|
72
89
|
end
|
|
73
90
|
end
|
|
74
91
|
end
|
|
@@ -24,13 +24,17 @@ module Didit
|
|
|
24
24
|
# @return [Array<String>] tokens, codes and verifiers redacted from errors
|
|
25
25
|
attr_reader :secrets
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
# @return [Boolean] redact errors from the parsed body, never from its raw text
|
|
28
|
+
attr_reader :structured
|
|
29
|
+
|
|
30
|
+
def initialize(http_method, uri, bearer: nil, form: nil, json: nil, secrets: [], structured: false)
|
|
28
31
|
@http_method = http_method
|
|
29
32
|
@uri = uri
|
|
30
33
|
@bearer = bearer
|
|
31
34
|
@form = form
|
|
32
35
|
@json = json
|
|
33
36
|
@secrets = secrets
|
|
37
|
+
@structured = structured
|
|
34
38
|
freeze
|
|
35
39
|
end
|
|
36
40
|
|
|
@@ -61,9 +65,21 @@ module Didit
|
|
|
61
65
|
# @return [Didit::Internal::Transport::Response]
|
|
62
66
|
# @raise [Didit::APIConnectionError, Didit::APITimeoutError] when no response arrives
|
|
63
67
|
def perform(call)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
error_class = APIConnectionError
|
|
69
|
+
begin
|
|
70
|
+
verb = VERBS.fetch(call.http_method)
|
|
71
|
+
response = @transport.execute(verb, call.uri, headers_for(call), body_for(call), @timeout)
|
|
72
|
+
# A successful response reaches the caller unchanged; errors are built from a sanitized copy only.
|
|
73
|
+
return response
|
|
74
|
+
rescue Internal::Transport::Failure => e
|
|
75
|
+
error_class = e.timeout? ? APITimeoutError : APIConnectionError
|
|
76
|
+
rescue StandardError
|
|
77
|
+
# A request that carries secrets reports a fixed error for anything a transport raises.
|
|
78
|
+
raise unless call.structured
|
|
79
|
+
|
|
80
|
+
error_class = APIConnectionError
|
|
81
|
+
end
|
|
82
|
+
# Raised outside the handlers, so no cause carries the transport's text, which may quote the request.
|
|
67
83
|
raise error_class.new(http_method: call.http_method, url: call.display_url)
|
|
68
84
|
end
|
|
69
85
|
|
|
@@ -82,18 +98,26 @@ module Didit
|
|
|
82
98
|
def read(call, response)
|
|
83
99
|
body = response.body.to_s
|
|
84
100
|
unless (200..299).cover?(response.status)
|
|
101
|
+
response = error_response(call, response)
|
|
102
|
+
body = response.body.to_s
|
|
85
103
|
raise Internal::Errors.status_error(
|
|
86
|
-
status: response.status, headers: response.headers, raw_body: body, redact: call
|
|
104
|
+
status: response.status, headers: response.headers, raw_body: body, redact: redactions(call)
|
|
87
105
|
)
|
|
88
106
|
end
|
|
89
107
|
return nil if response.status == 204 || body.empty?
|
|
90
108
|
|
|
109
|
+
parsed = nil
|
|
110
|
+
failed = false
|
|
91
111
|
begin
|
|
92
|
-
JSON.parse(text_of(body))
|
|
112
|
+
parsed = JSON.parse(text_of(body))
|
|
93
113
|
rescue JSON::ParserError
|
|
94
|
-
|
|
95
|
-
raise validation_error(call, response, "Expected a JSON response from #{call.describe}, got #{content_type}.")
|
|
114
|
+
failed = true
|
|
96
115
|
end
|
|
116
|
+
return parsed unless failed
|
|
117
|
+
|
|
118
|
+
# Raised outside the rescue: the parser's error quotes the raw input, so it is never the cause.
|
|
119
|
+
content_type = error_response(call, response).headers.fetch("content-type", "no content type")
|
|
120
|
+
raise validation_error(call, response, "Expected a JSON response from #{call.describe}, got #{content_type}.")
|
|
97
121
|
end
|
|
98
122
|
|
|
99
123
|
# The JSON object of a 2xx response.
|
|
@@ -108,16 +132,27 @@ module Didit
|
|
|
108
132
|
|
|
109
133
|
# @return [Didit::APIResponseValidationError]
|
|
110
134
|
def validation_error(call, response, message)
|
|
135
|
+
response = error_response(call, response)
|
|
111
136
|
body = response.body.to_s
|
|
137
|
+
shown = body.empty? ? nil : Internal::Util.redact(text_of(body), redactions(call))
|
|
112
138
|
APIResponseValidationError.new(
|
|
113
|
-
message, status: response.status, headers: response.headers,
|
|
114
|
-
body: body.empty? ? nil : Internal::Util.redact(text_of(body), call.secrets),
|
|
139
|
+
message, status: response.status, headers: response.headers, body: shown,
|
|
115
140
|
request_id: Internal::Util.request_id(response.headers)
|
|
116
141
|
)
|
|
117
142
|
end
|
|
118
143
|
|
|
119
144
|
private
|
|
120
145
|
|
|
146
|
+
# The response an error is built from: a sanitized copy for a consent call, else the response.
|
|
147
|
+
def error_response(call, response)
|
|
148
|
+
call.structured ? Internal::Errors.sanitized_response(response, call.secrets) : response
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# A structured call's response is already sanitized, so nothing is replaced again.
|
|
152
|
+
def redactions(call)
|
|
153
|
+
call.structured ? [] : call.secrets
|
|
154
|
+
end
|
|
155
|
+
|
|
121
156
|
def headers_for(call)
|
|
122
157
|
headers = {
|
|
123
158
|
"Accept" => "application/json",
|
data/lib/didit/authentication.rb
CHANGED
|
@@ -296,7 +296,8 @@ module Didit
|
|
|
296
296
|
def create_agent_approval_options(access_token, challenge:)
|
|
297
297
|
challenge = required_text(challenge, "challenge")
|
|
298
298
|
AgentApprovalOptions.new(
|
|
299
|
-
agent_request(AgentConsentRequest::OPTIONS_PATH, access_token,
|
|
299
|
+
agent_request(AgentConsentRequest::OPTIONS_PATH, access_token,
|
|
300
|
+
AgentConsentRequest.encode_once({ "challenge" => challenge }), [challenge])
|
|
300
301
|
)
|
|
301
302
|
end
|
|
302
303
|
|
|
@@ -488,16 +489,18 @@ module Didit
|
|
|
488
489
|
TokenResponse.new(send_object(call))
|
|
489
490
|
end
|
|
490
491
|
|
|
491
|
-
def bearer_call(http_method, uri, access_token, json: nil, secrets: [])
|
|
492
|
+
def bearer_call(http_method, uri, access_token, json: nil, secrets: [], structured: false)
|
|
492
493
|
token = required_text(access_token, "access_token")
|
|
493
494
|
# Sent in a header: printable ASCII only, so it can never split or extend the request.
|
|
494
495
|
raise ConfigurationError, "access_token contains invalid characters." if token.b.match?(/[^\x21-\x7e]/n)
|
|
495
496
|
|
|
496
|
-
Http::Call.new(http_method, uri, bearer: token, json: json, secrets: [token, *secrets]
|
|
497
|
+
Http::Call.new(http_method, uri, bearer: token, json: json, secrets: [token, *secrets],
|
|
498
|
+
structured: structured)
|
|
497
499
|
end
|
|
498
500
|
|
|
499
501
|
def agent_request(path, access_token, body, secrets)
|
|
500
|
-
send_object(bearer_call("POST", issuer_uri(path), access_token, json: body, secrets: secrets
|
|
502
|
+
send_object(bearer_call("POST", issuer_uri(path), access_token, json: body, secrets: secrets,
|
|
503
|
+
structured: true))
|
|
501
504
|
end
|
|
502
505
|
|
|
503
506
|
def send_object(call)
|
|
@@ -32,6 +32,38 @@ module Didit
|
|
|
32
32
|
klass.new(message, status: status, headers: headers, body: body, request_id: Util.request_id(headers))
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
+
# The response of a call whose answer may echo secrets (the agent consent calls), sanitized once on
|
|
36
|
+
# receipt: status kept; each header whose name contains a secret dropped and the other values redacted;
|
|
37
|
+
# the body redacted structurally, never from its raw text (the parsed JSON with every string that
|
|
38
|
+
# contains a secret replaced whole, "[redacted]" when it is not JSON, cut at the size limit or empty).
|
|
39
|
+
# Every error of these calls is built from this response only.
|
|
40
|
+
#
|
|
41
|
+
# @return [Didit::Internal::Transport::Response]
|
|
42
|
+
def sanitized_response(response, secrets)
|
|
43
|
+
# @type var headers: Hash[String, String]
|
|
44
|
+
headers = {}
|
|
45
|
+
response.headers.each do |name, value|
|
|
46
|
+
# Header names are case-insensitive: compare case-folded.
|
|
47
|
+
next if secrets.any? { |secret| secret && !secret.empty? && name.downcase.include?(secret.downcase) }
|
|
48
|
+
|
|
49
|
+
headers[name] = Util.redact_structured(value, secrets)
|
|
50
|
+
end
|
|
51
|
+
Transport::Response.new(status: response.status, headers: headers,
|
|
52
|
+
body: sanitized_body(response.body.to_s, secrets))
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# @return [String] the redacted JSON text, or "[redacted]"
|
|
56
|
+
def sanitized_body(raw_body, secrets)
|
|
57
|
+
return Util::REDACTED if raw_body.empty?
|
|
58
|
+
|
|
59
|
+
text = raw_body.dup.force_encoding(Encoding::UTF_8)
|
|
60
|
+
text = text.scrub unless text.valid_encoding?
|
|
61
|
+
JSON.generate(Util.redact_structured(JSON.parse(text), secrets))
|
|
62
|
+
rescue JSON::ParserError, SystemStackError
|
|
63
|
+
# Not JSON, or nested past the parser's or the walk's depth limit: not JSON.
|
|
64
|
+
Util::REDACTED
|
|
65
|
+
end
|
|
66
|
+
|
|
35
67
|
# The parsed JSON body, else the text, else nil.
|
|
36
68
|
def parse_body(raw_body)
|
|
37
69
|
return nil if raw_body.nil? || raw_body.empty?
|
data/lib/didit/internal/util.rb
CHANGED
|
@@ -39,6 +39,40 @@ module Didit
|
|
|
39
39
|
redact_value(value, secrets)
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
+
# Redacts a parsed JSON value structurally: every string (object key or value) that contains a secret
|
|
43
|
+
# anywhere in it becomes "[redacted]" as a whole. Strings are compared as decoded, so the spelling
|
|
44
|
+
# of the raw JSON text does not matter. A redacted key that collides with another key is numbered.
|
|
45
|
+
def redact_structured(value, secrets)
|
|
46
|
+
secrets = secrets.compact.reject(&:empty?)
|
|
47
|
+
case value
|
|
48
|
+
when String then secrets.any? { |secret| value.include?(secret) } ? REDACTED : value
|
|
49
|
+
when Array then value.map { |item| redact_structured(item, secrets) }
|
|
50
|
+
when Hash then redact_structured_hash(value, secrets)
|
|
51
|
+
else value
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def redact_structured_hash(value, secrets)
|
|
56
|
+
# Reserve every safe key name first, so a placeholder never takes one.
|
|
57
|
+
taken = value.keys.select { |key| redact_structured(key, secrets) == key }
|
|
58
|
+
number = 1
|
|
59
|
+
# @type var result: Hash[untyped, untyped]
|
|
60
|
+
result = {}
|
|
61
|
+
value.each do |key, item|
|
|
62
|
+
name = key
|
|
63
|
+
if redact_structured(key, secrets) != key
|
|
64
|
+
loop do
|
|
65
|
+
name = number == 1 ? REDACTED : "#{REDACTED}#{number}"
|
|
66
|
+
number += 1
|
|
67
|
+
break unless taken.include?(name)
|
|
68
|
+
end
|
|
69
|
+
taken << name
|
|
70
|
+
end
|
|
71
|
+
result[name] = redact_structured(item, secrets)
|
|
72
|
+
end
|
|
73
|
+
result
|
|
74
|
+
end
|
|
75
|
+
|
|
42
76
|
def redact_value(value, secrets)
|
|
43
77
|
case value
|
|
44
78
|
when String then secrets.reduce(value) { |text, secret| text.gsub(secret, REDACTED) }
|
|
@@ -204,7 +204,10 @@ module Didit
|
|
|
204
204
|
# Create case
|
|
205
205
|
#
|
|
206
206
|
# Create a case anchored to exactly one subject (a user or a business), directly or by deriving the subject from
|
|
207
|
-
# an attached session/transaction link. Source is always `MANUAL` for API-created cases.
|
|
207
|
+
# an attached session/transaction link. Source is always `MANUAL` for API-created cases. Network links require
|
|
208
|
+
# write:cases plus read:networks, Networks access and investigation access for the network scope. The network
|
|
209
|
+
# must be visible and contain the case subject. Manually adding links to network-generated cases is not allowed.
|
|
210
|
+
# An explicit subject is required whenever links includes a network.
|
|
208
211
|
#
|
|
209
212
|
# +POST /v3/organization/{organization_id}/application/{application_id}/cases/+
|
|
210
213
|
#
|
|
@@ -213,10 +216,11 @@ module Didit
|
|
|
213
216
|
# @param priority [String]
|
|
214
217
|
# @param due_at [Time, String, nil]
|
|
215
218
|
# @param tags [Array<String>]
|
|
216
|
-
# @param subject [Hash]
|
|
217
|
-
#
|
|
218
|
-
#
|
|
219
|
-
#
|
|
219
|
+
# @param subject [Hash] Exactly one user or business. Supply explicitly when any network link is supplied, even
|
|
220
|
+
# alongside other link types; otherwise may be derived from links.
|
|
221
|
+
# @param links [Array<Hash>] Up to 500 session, business_session, transaction or network links; at most 20 when
|
|
222
|
+
# review_duplicates=true. When any network link is present, subject must be supplied explicitly. Otherwise the
|
|
223
|
+
# subject may be derived from a linked record.
|
|
220
224
|
# @param assigned_to [String, nil] User UUID to assign immediately.
|
|
221
225
|
# @param review_duplicates [Boolean] Recheck existing investigations before creating the case. When true, a
|
|
222
226
|
# subject with existing cases requires a nonblank separate_incident_reason. The console always enables this
|
|
@@ -770,11 +774,39 @@ module Didit
|
|
|
770
774
|
|
|
771
775
|
# The +cases.blueprints+ resource.
|
|
772
776
|
class Blueprints < Didit::Resource
|
|
777
|
+
# Draft case blueprint with AI
|
|
778
|
+
#
|
|
779
|
+
# Generate an unsaved blueprint proposal. Requires write:cases. Returns a draft object, not a blueprint UUID;
|
|
780
|
+
# no blueprint or saved policy draft is created. Review the proposal, choose assignees and any teams,
|
|
781
|
+
# approvals or routing, then create or update a blueprint separately. Invalid generated content or generation
|
|
782
|
+
# failure returns 503. See [blueprint AI drafts](/management-api/case-blueprints/ai-draft).
|
|
783
|
+
#
|
|
784
|
+
# +POST /v3/organization/{organization_id}/application/{application_id}/cases/blueprints/ai-draft/+
|
|
785
|
+
#
|
|
786
|
+
# @param prompt [String] Nonblank description of the review policy to propose.
|
|
787
|
+
# @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
|
|
788
|
+
# @return [Didit::Types::CaseBlueprintAiDraftResponse]
|
|
789
|
+
def ai_draft(prompt:, request_options: nil)
|
|
790
|
+
@client.request(
|
|
791
|
+
:post,
|
|
792
|
+
"/v3/organization/{organization_id}/application/{application_id}/cases/blueprints/ai-draft/",
|
|
793
|
+
body: {
|
|
794
|
+
"prompt" => prompt
|
|
795
|
+
},
|
|
796
|
+
scope: :application,
|
|
797
|
+
response: Types::CaseBlueprintAiDraftResponse,
|
|
798
|
+
request_options: request_options
|
|
799
|
+
)
|
|
800
|
+
end
|
|
801
|
+
|
|
773
802
|
# Create blueprint
|
|
774
803
|
#
|
|
775
804
|
# Create a case blueprint: general settings (assignment, escalation, transfer, 4-eyes pairing) plus
|
|
776
805
|
# content_config, the six sections that drive the case page. Set publish=false to create an unpublished draft;
|
|
777
|
-
# Publish creates its first live version. Discarding a never-published draft deletes it.
|
|
806
|
+
# Publish creates its first live version. Discarding a never-published draft deletes it. applies_to accepts
|
|
807
|
+
# the six case-type values. content_config.stages.items[].worked_by is an optional active review-team UUID
|
|
808
|
+
# from this application. These settings are preserved in case policy snapshots; later edits do not change
|
|
809
|
+
# existing snapshots.
|
|
778
810
|
#
|
|
779
811
|
# +POST /v3/organization/{organization_id}/application/{application_id}/cases/blueprints/+
|
|
780
812
|
#
|
|
@@ -792,14 +824,16 @@ module Didit
|
|
|
792
824
|
# @param four_eyes_checker_blueprint [String, nil] Setting this enables 4-eyes review: resolutions on this
|
|
793
825
|
# blueprint stage on the checker blueprint's queue.
|
|
794
826
|
# @param require_resolution_note [Boolean]
|
|
795
|
-
# @param content_config [Hash]
|
|
796
|
-
#
|
|
827
|
+
# @param content_config [Hash] Case content sections and optional review stages. Unknown sections or keys are
|
|
828
|
+
# rejected. Cases retain the policy snapshot accepted when opened; later blueprint edits do not rewrite it.
|
|
797
829
|
# @param is_active [Boolean]
|
|
798
830
|
# @param default_deadline_hours [Integer, nil] Default deadline for newly opened cases. Existing case
|
|
799
831
|
# deadlines are unchanged.
|
|
800
832
|
# @param publish [Boolean] Set false to save a never-published draft. The record remains inactive at version 0
|
|
801
833
|
# until the draft is explicitly published. Omitting this field preserves immediate creation for existing
|
|
802
834
|
# integrations.
|
|
835
|
+
# @param applies_to [Array<String>] Case types this blueprint describes. Optional on create and update; new
|
|
836
|
+
# blueprints default to an empty list. Stored in the accepted case policy snapshot.
|
|
803
837
|
# @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
|
|
804
838
|
# @return [Didit::Types::CaseBlueprintDetail]
|
|
805
839
|
def create(
|
|
@@ -817,6 +851,7 @@ module Didit
|
|
|
817
851
|
is_active: OMIT,
|
|
818
852
|
default_deadline_hours: OMIT,
|
|
819
853
|
publish: OMIT,
|
|
854
|
+
applies_to: OMIT,
|
|
820
855
|
request_options: nil
|
|
821
856
|
)
|
|
822
857
|
@client.request(
|
|
@@ -836,7 +871,8 @@ module Didit
|
|
|
836
871
|
"content_config" => content_config,
|
|
837
872
|
"is_active" => is_active,
|
|
838
873
|
"default_deadline_hours" => default_deadline_hours,
|
|
839
|
-
"publish" => publish
|
|
874
|
+
"publish" => publish,
|
|
875
|
+
"applies_to" => applies_to
|
|
840
876
|
},
|
|
841
877
|
scope: :application,
|
|
842
878
|
response: Types::CaseBlueprintDetail,
|
|
@@ -1063,7 +1099,10 @@ module Didit
|
|
|
1063
1099
|
|
|
1064
1100
|
# Update blueprint
|
|
1065
1101
|
#
|
|
1066
|
-
# Partially update a blueprint's general settings or content_config.
|
|
1102
|
+
# Partially update a blueprint's general settings or content_config. applies_to accepts the six case-type
|
|
1103
|
+
# values. content_config.stages.items[].worked_by is an optional active review-team UUID from this
|
|
1104
|
+
# application. These settings are preserved in case policy snapshots; later edits do not change existing
|
|
1105
|
+
# snapshots.
|
|
1067
1106
|
#
|
|
1068
1107
|
# +PATCH /v3/organization/{organization_id}/application/{application_id}/cases/blueprints/{blueprint_uuid}/+
|
|
1069
1108
|
#
|
|
@@ -1082,13 +1121,15 @@ module Didit
|
|
|
1082
1121
|
# @param four_eyes_checker_blueprint [String, nil] Setting this enables 4-eyes review: resolutions on this
|
|
1083
1122
|
# blueprint stage on the checker blueprint's queue.
|
|
1084
1123
|
# @param require_resolution_note [Boolean]
|
|
1085
|
-
# @param content_config [Hash]
|
|
1086
|
-
#
|
|
1124
|
+
# @param content_config [Hash] Case content sections and optional review stages. Unknown sections or keys are
|
|
1125
|
+
# rejected. Cases retain the policy snapshot accepted when opened; later blueprint edits do not rewrite it.
|
|
1087
1126
|
# @param is_active [Boolean]
|
|
1088
1127
|
# @param default_deadline_hours [Integer, nil] Default deadline for newly opened cases. Existing case
|
|
1089
1128
|
# deadlines are unchanged.
|
|
1090
1129
|
# @param expected_version [Integer] The version opened by the editor. A stale version returns 409 without
|
|
1091
1130
|
# changing the review policy.
|
|
1131
|
+
# @param applies_to [Array<String>] Case types this blueprint describes. Optional on create and update; new
|
|
1132
|
+
# blueprints default to an empty list. Stored in the accepted case policy snapshot.
|
|
1092
1133
|
# @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
|
|
1093
1134
|
# @return [Didit::Types::CaseBlueprintDetail]
|
|
1094
1135
|
def update(
|
|
@@ -1107,6 +1148,7 @@ module Didit
|
|
|
1107
1148
|
is_active: OMIT,
|
|
1108
1149
|
default_deadline_hours: OMIT,
|
|
1109
1150
|
expected_version: OMIT,
|
|
1151
|
+
applies_to: OMIT,
|
|
1110
1152
|
request_options: nil
|
|
1111
1153
|
)
|
|
1112
1154
|
@client.request(
|
|
@@ -1127,7 +1169,8 @@ module Didit
|
|
|
1127
1169
|
"content_config" => content_config,
|
|
1128
1170
|
"is_active" => is_active,
|
|
1129
1171
|
"default_deadline_hours" => default_deadline_hours,
|
|
1130
|
-
"expected_version" => expected_version
|
|
1172
|
+
"expected_version" => expected_version,
|
|
1173
|
+
"applies_to" => applies_to
|
|
1131
1174
|
},
|
|
1132
1175
|
scope: :application,
|
|
1133
1176
|
response: Types::CaseBlueprintDetail,
|
|
@@ -1190,13 +1233,16 @@ module Didit
|
|
|
1190
1233
|
class Links < Didit::Resource
|
|
1191
1234
|
# Add case link
|
|
1192
1235
|
#
|
|
1193
|
-
# Attach a session, business session, or
|
|
1194
|
-
# different subject than the case.
|
|
1236
|
+
# Attach a session, business session, transaction, or network to the case. Rejected with 400 if the entity
|
|
1237
|
+
# belongs to a different subject than the case. Network links require write:cases plus read:networks, Networks
|
|
1238
|
+
# access and investigation access for the network scope. The network must be visible and contain the case
|
|
1239
|
+
# subject. Manually adding links to network-generated cases is not allowed.
|
|
1195
1240
|
#
|
|
1196
1241
|
# +POST /v3/organization/{organization_id}/application/{application_id}/cases/{case_uuid}/links/+
|
|
1197
1242
|
#
|
|
1198
1243
|
# @param case_uuid [String] Case UUID.
|
|
1199
|
-
# @param entity_type [String]
|
|
1244
|
+
# @param entity_type [String] Type of record to attach. A network must be visible and contain the selected
|
|
1245
|
+
# case subject.
|
|
1200
1246
|
# @param entity_uuid [String]
|
|
1201
1247
|
# @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
|
|
1202
1248
|
# @return [Didit::Types::CaseLink]
|
|
@@ -850,6 +850,35 @@ module Didit
|
|
|
850
850
|
)
|
|
851
851
|
end
|
|
852
852
|
|
|
853
|
+
# Create or email a Travel Rule end-user link
|
|
854
|
+
#
|
|
855
|
+
# Issue a new link and revoke previous open links for this transfer. Requires write access to transactions and
|
|
856
|
+
# an outbound transfer in AWAITING_COUNTERPARTY, COUNTERPARTY_VASP_NOT_FOUND, COUNTERPARTY_VASP_NOT_REACHABLE,
|
|
857
|
+
# UNCONFIRMED_OWNERSHIP or ON_HOLD. channel=email uses the end user's Didit-record email and
|
|
858
|
+
# verification-session language when available. A send failure returns the link with emailed_to empty;
|
|
859
|
+
# email_available reports address availability, not delivery. See [User
|
|
860
|
+
# links](/management-api/travel-rule/create-user-link).
|
|
861
|
+
#
|
|
862
|
+
# +POST /v3/transactions/{transaction_id}/travel-rule/user-link/+
|
|
863
|
+
#
|
|
864
|
+
# @param transaction_id [String] Didit-stable transaction UUID that owns the transfer.
|
|
865
|
+
# @param channel [String] link returns a new link; email also attempts to send it to the end user's
|
|
866
|
+
# Didit-record email.
|
|
867
|
+
# @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
|
|
868
|
+
# @return [Didit::Types::TravelRuleUserLinkResponse]
|
|
869
|
+
def create_user_link(transaction_id, channel: OMIT, request_options: nil)
|
|
870
|
+
@client.request(
|
|
871
|
+
:post,
|
|
872
|
+
"/v3/transactions/{transaction_id}/travel-rule/user-link/",
|
|
873
|
+
path_params: { "transaction_id" => transaction_id },
|
|
874
|
+
body: {
|
|
875
|
+
"channel" => channel
|
|
876
|
+
},
|
|
877
|
+
response: Types::TravelRuleUserLinkResponse,
|
|
878
|
+
request_options: request_options
|
|
879
|
+
)
|
|
880
|
+
end
|
|
881
|
+
|
|
853
882
|
# List Travel Rule delivery history
|
|
854
883
|
#
|
|
855
884
|
# Read the complete delivery history for a transaction, oldest first. Requires transaction read permission.
|
|
@@ -946,7 +975,7 @@ module Didit
|
|
|
946
975
|
)
|
|
947
976
|
end
|
|
948
977
|
|
|
949
|
-
#
|
|
978
|
+
# Update a Travel Rule transfer
|
|
950
979
|
#
|
|
951
980
|
# Provide `payment_txn_id` to report the on-chain hash and move an outbound COMPLETED transfer to FINISHED
|
|
952
981
|
# (its INTERNAL-rail counterpart also moves to FINISHED), `{"action": "cancel"}` to cancel a non-terminal
|
|
@@ -968,7 +997,12 @@ module Didit
|
|
|
968
997
|
# updated the same way. `{"action": "beneficiary_vasp", "beneficiary_vasp": "<directory VASP id>"}` names the
|
|
969
998
|
# counterparty yourself when discovery could not, on an outbound transfer in COUNTERPARTY_VASP_NOT_FOUND,
|
|
970
999
|
# COUNTERPARTY_VASP_NOT_REACHABLE or NOT_ENOUGH_COUNTERPARTY_DATA: the transfer is routed to that VASP and
|
|
971
|
-
# sent again.
|
|
1000
|
+
# sent again. Cancellation accepts an optional reason and returns cancel_reason and cancelled_by. Resend
|
|
1001
|
+
# accepts notify_on_answer; omission preserves the saved preference, initially false. Resend invalidates the
|
|
1002
|
+
# previous counterparty pickup link. action=add_vasp_hint requires name, accepts lei and country, saves the
|
|
1003
|
+
# hint and re-runs discovery under the same outbound/status restrictions as resend. update_compliance_email
|
|
1004
|
+
# also accepts vasp_name and saves the address as an application-private contact when the transfer has a known
|
|
1005
|
+
# directory VASP.
|
|
972
1006
|
#
|
|
973
1007
|
# +PATCH /v3/transactions/{transaction_id}/travel-rule/+
|
|
974
1008
|
#
|
|
@@ -980,15 +1014,25 @@ module Didit
|
|
|
980
1014
|
# NOT_ENOUGH_COUNTERPARTY_DATA. "update_compliance_email" replaces the compliance email the request goes to,
|
|
981
1015
|
# on an outbound transfer in one of those three statuses; send "resend" afterwards. "update_originator_wallet"
|
|
982
1016
|
# records the walle...
|
|
983
|
-
# @param compliance_email [String] Required with
|
|
984
|
-
#
|
|
985
|
-
#
|
|
1017
|
+
# @param compliance_email [String] Required with action=update_compliance_email. Saved in
|
|
1018
|
+
# beneficiary_data.counterparty_vasp_email. If the transfer has a known directory VASP, also saved as your
|
|
1019
|
+
# application-private contact for that VASP.
|
|
986
1020
|
# @param wallet_address [String] With `action: update_originator_wallet`: the wallet the funds left from. When
|
|
987
1021
|
# the transfer's UTXO inputs are known it must be one of them.
|
|
988
1022
|
# @param memo [String] With `action: update_originator_wallet`: the wallet's memo or tag on a memo network.
|
|
989
1023
|
# Optional.
|
|
990
1024
|
# @param beneficiary_vasp [String] Required with action=beneficiary_vasp: the `id` of a directory VASP, from
|
|
991
1025
|
# `GET /v3/travel-rule/vasps/`. Your choice outranks every automatic discovery step, which never overrides it.
|
|
1026
|
+
# @param reason [String] With action=cancel: your cancellation reason. Omitted or empty means unspecified.
|
|
1027
|
+
# @param notify_on_answer [Boolean] With action=resend: whether your team should be notified when the
|
|
1028
|
+
# counterparty answers. Initially false; omission preserves the saved preference.
|
|
1029
|
+
# @param name [String] Required with action=add_vasp_hint. Counterparty VASP name.
|
|
1030
|
+
# @param lei [String] With action=add_vasp_hint: optional LEI, normalized to uppercase. Empty clears the
|
|
1031
|
+
# previous LEI hint.
|
|
1032
|
+
# @param country [String] With action=add_vasp_hint: optional country hint, normalized to uppercase. Empty
|
|
1033
|
+
# clears the previous country hint.
|
|
1034
|
+
# @param vasp_name [String] With action=update_compliance_email: optional counterparty name saved with the
|
|
1035
|
+
# address when nonempty.
|
|
992
1036
|
# @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
|
|
993
1037
|
# @return [Didit::Types::TravelRuleTransferDetail]
|
|
994
1038
|
def update_transfer(
|
|
@@ -999,6 +1043,12 @@ module Didit
|
|
|
999
1043
|
wallet_address: OMIT,
|
|
1000
1044
|
memo: OMIT,
|
|
1001
1045
|
beneficiary_vasp: OMIT,
|
|
1046
|
+
reason: OMIT,
|
|
1047
|
+
notify_on_answer: OMIT,
|
|
1048
|
+
name: OMIT,
|
|
1049
|
+
lei: OMIT,
|
|
1050
|
+
country: OMIT,
|
|
1051
|
+
vasp_name: OMIT,
|
|
1002
1052
|
request_options: nil
|
|
1003
1053
|
)
|
|
1004
1054
|
@client.request(
|
|
@@ -1011,7 +1061,13 @@ module Didit
|
|
|
1011
1061
|
"compliance_email" => compliance_email,
|
|
1012
1062
|
"wallet_address" => wallet_address,
|
|
1013
1063
|
"memo" => memo,
|
|
1014
|
-
"beneficiary_vasp" => beneficiary_vasp
|
|
1064
|
+
"beneficiary_vasp" => beneficiary_vasp,
|
|
1065
|
+
"reason" => reason,
|
|
1066
|
+
"notify_on_answer" => notify_on_answer,
|
|
1067
|
+
"name" => name,
|
|
1068
|
+
"lei" => lei,
|
|
1069
|
+
"country" => country,
|
|
1070
|
+
"vasp_name" => vasp_name
|
|
1015
1071
|
},
|
|
1016
1072
|
response: Types::TravelRuleTransferDetail,
|
|
1017
1073
|
request_options: request_options
|