@didit-protocol/sdk-node 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.
- package/dist/index.cjs +163 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +210 -78
- package/dist/index.d.ts +210 -78
- package/dist/index.js +163 -25
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -188,6 +188,52 @@ function makeStatusError(status, body, headers, secrets = []) {
|
|
|
188
188
|
const ErrorClass = STATUS_ERRORS[status] ?? (status >= 500 ? InternalServerError : APIStatusError);
|
|
189
189
|
return new ErrorClass(message, status, cleanBody, redactHeaders(headers, secrets));
|
|
190
190
|
}
|
|
191
|
+
var REDACTED = "[redacted]";
|
|
192
|
+
function redactStructured(value, secrets) {
|
|
193
|
+
const active = secrets.filter((s) => s.length > 0);
|
|
194
|
+
const text = (input) => active.some((secret) => input.includes(secret)) ? REDACTED : input;
|
|
195
|
+
const scrub = (input) => {
|
|
196
|
+
if (typeof input === "string") return text(input);
|
|
197
|
+
if (Array.isArray(input)) return input.map(scrub);
|
|
198
|
+
if (isRecord(input)) {
|
|
199
|
+
const out = /* @__PURE__ */ new Map();
|
|
200
|
+
const taken = new Set(Object.keys(input).filter((key) => text(key) === key));
|
|
201
|
+
let next = 1;
|
|
202
|
+
for (const [key, item] of Object.entries(input)) {
|
|
203
|
+
let name = key;
|
|
204
|
+
if (text(key) !== key) {
|
|
205
|
+
do {
|
|
206
|
+
name = next === 1 ? REDACTED : `${REDACTED}${next}`;
|
|
207
|
+
next++;
|
|
208
|
+
} while (taken.has(name));
|
|
209
|
+
taken.add(name);
|
|
210
|
+
}
|
|
211
|
+
out.set(name, scrub(item));
|
|
212
|
+
}
|
|
213
|
+
return Object.fromEntries(out);
|
|
214
|
+
}
|
|
215
|
+
return input;
|
|
216
|
+
};
|
|
217
|
+
return scrub(value);
|
|
218
|
+
}
|
|
219
|
+
function sanitizeResponse(headers, text, secrets) {
|
|
220
|
+
const clean = new Headers();
|
|
221
|
+
headers.forEach((value, name) => {
|
|
222
|
+
const folded = name.toLowerCase();
|
|
223
|
+
if (!secrets.some((secret) => secret && folded.includes(secret.toLowerCase()))) {
|
|
224
|
+
clean.append(name, redactStructured(value, secrets));
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
let body = REDACTED;
|
|
228
|
+
if (text) {
|
|
229
|
+
try {
|
|
230
|
+
body = JSON.stringify(redactStructured(JSON.parse(text), secrets));
|
|
231
|
+
} catch {
|
|
232
|
+
body = REDACTED;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return { headers: clean, text: body };
|
|
236
|
+
}
|
|
191
237
|
|
|
192
238
|
// src/core/api-promise.ts
|
|
193
239
|
var APIPromise = class extends Promise {
|
|
@@ -278,7 +324,7 @@ function decodeDates(value, plan, named, depth = 0) {
|
|
|
278
324
|
}
|
|
279
325
|
|
|
280
326
|
// src/core/version.ts
|
|
281
|
-
var VERSION = "2.
|
|
327
|
+
var VERSION = "2.14.0";
|
|
282
328
|
|
|
283
329
|
// src/core/runtime.ts
|
|
284
330
|
function processLike() {
|
|
@@ -1670,7 +1716,8 @@ var DATE_PLANS = {
|
|
|
1670
1716
|
data_unmasked: "TravelRuleDataUnmasked",
|
|
1671
1717
|
counterparty_vasp: { p: { dd_assessed_at: 1 } },
|
|
1672
1718
|
delivery: "TravelRuleDelivery",
|
|
1673
|
-
discovery: { i: "TravelRuleDiscoveryStep" }
|
|
1719
|
+
discovery: { i: "TravelRuleDiscoveryStep" },
|
|
1720
|
+
user_choice: "TravelRuleUserChoice"
|
|
1674
1721
|
}
|
|
1675
1722
|
},
|
|
1676
1723
|
TransactionNote: { p: { created_at: 1 } },
|
|
@@ -1682,7 +1729,8 @@ var DATE_PLANS = {
|
|
|
1682
1729
|
counterparty_vasp: { p: { dd_assessed_at: 1 } },
|
|
1683
1730
|
delivery: "TravelRuleDelivery",
|
|
1684
1731
|
discovery: { i: "TravelRuleDiscoveryStep" },
|
|
1685
|
-
deliveries: { i: "TravelRuleDeliveryLogEntry" }
|
|
1732
|
+
deliveries: { i: "TravelRuleDeliveryLogEntry" },
|
|
1733
|
+
user_choice: "TravelRuleUserChoice"
|
|
1686
1734
|
}
|
|
1687
1735
|
},
|
|
1688
1736
|
TransactionWalletOwnershipAction: { p: { expires_at: 1 } },
|
|
@@ -1776,12 +1824,15 @@ var DATE_PLANS = {
|
|
|
1776
1824
|
created_at: 1,
|
|
1777
1825
|
delivery: "TravelRuleDelivery",
|
|
1778
1826
|
discovery: { i: "TravelRuleDiscoveryStep" },
|
|
1779
|
-
deliveries: { i: "TravelRuleDeliveryLogEntry" }
|
|
1827
|
+
deliveries: { i: "TravelRuleDeliveryLogEntry" },
|
|
1828
|
+
user_choice: "TravelRuleUserChoice"
|
|
1780
1829
|
}
|
|
1781
1830
|
},
|
|
1782
1831
|
TravelRuleTransferRow: { p: { txn_date: 1, deadline_at: 1, created_at: 1 } },
|
|
1783
1832
|
TravelRuleTransfersListResponse: { p: { results: { i: "TravelRuleTransferRow" } } },
|
|
1784
1833
|
TravelRuleUnmatchedDepositsListResponse: { p: { results: { i: "TravelRuleTransferRow" } } },
|
|
1834
|
+
TravelRuleUserChoice: { p: { link_expires_at: 1 } },
|
|
1835
|
+
TravelRuleUserLinkResponse: { p: { expires_at: 1 } },
|
|
1785
1836
|
TravelRuleWalletAddressesListResponse: { p: { results: { i: "WalletAddressEntry" } } },
|
|
1786
1837
|
TravelRuleWalletProofReview: { p: { method_chosen_at: 1, decided_at: 1, created_at: 1 } },
|
|
1787
1838
|
TravelRuleWalletProofsListResponse: { p: { results: { i: "TravelRuleWalletProofReview" } } },
|
|
@@ -2783,6 +2834,12 @@ var Businesses = class extends APIResource {
|
|
|
2783
2834
|
};
|
|
2784
2835
|
|
|
2785
2836
|
// src/resources/cases.ts
|
|
2837
|
+
var CASES_BLUEPRINTS_AI_DRAFT = {
|
|
2838
|
+
method: "POST",
|
|
2839
|
+
path: "/v3/organization/{organization_id}/application/{application_id}/cases/blueprints/ai-draft/",
|
|
2840
|
+
scope: "application",
|
|
2841
|
+
body: "json"
|
|
2842
|
+
};
|
|
2786
2843
|
var CASES_BLUEPRINTS_CREATE = {
|
|
2787
2844
|
method: "POST",
|
|
2788
2845
|
path: "/v3/organization/{organization_id}/application/{application_id}/cases/blueprints/",
|
|
@@ -3257,10 +3314,20 @@ var CASES_UPDATE = {
|
|
|
3257
3314
|
dates: "CaseDetail"
|
|
3258
3315
|
};
|
|
3259
3316
|
var CasesBlueprints = class extends APIResource {
|
|
3317
|
+
/**
|
|
3318
|
+
* Draft case blueprint with AI
|
|
3319
|
+
*
|
|
3320
|
+
* Generate an unsaved blueprint proposal. Requires write:cases. Returns a draft object, not a blueprint UUID; no blueprint or saved policy draft is created. Review the proposal, choose assignees and any teams, approvals or routing, then create or update a blueprint separately. Invalid generated content or generation failure returns 503. See [blueprint AI drafts](/management-api/case-blueprints/ai-draft).
|
|
3321
|
+
*
|
|
3322
|
+
* `POST /v3/organization/{organization_id}/application/{application_id}/cases/blueprints/ai-draft/`
|
|
3323
|
+
*/
|
|
3324
|
+
aiDraft(params, options) {
|
|
3325
|
+
return this._client.request(CASES_BLUEPRINTS_AI_DRAFT, [], params, options);
|
|
3326
|
+
}
|
|
3260
3327
|
/**
|
|
3261
3328
|
* Create blueprint
|
|
3262
3329
|
*
|
|
3263
|
-
* Create a case blueprint: general settings (assignment, escalation, transfer, 4-eyes pairing) plus content_config, the six sections that drive the case page. Set publish=false to create an unpublished draft; Publish creates its first live version. Discarding a never-published draft deletes it.
|
|
3330
|
+
* Create a case blueprint: general settings (assignment, escalation, transfer, 4-eyes pairing) plus content_config, the six sections that drive the case page. Set publish=false to create an unpublished draft; Publish creates its first live version. Discarding a never-published draft deletes it. applies_to accepts the six case-type values. content_config.stages.items[].worked_by is an optional active review-team UUID from this application. These settings are preserved in case policy snapshots; later edits do not change existing snapshots.
|
|
3264
3331
|
*
|
|
3265
3332
|
* `POST /v3/organization/{organization_id}/application/{application_id}/cases/blueprints/`
|
|
3266
3333
|
*/
|
|
@@ -3374,7 +3441,7 @@ var CasesBlueprints = class extends APIResource {
|
|
|
3374
3441
|
/**
|
|
3375
3442
|
* Update blueprint
|
|
3376
3443
|
*
|
|
3377
|
-
* Partially update a blueprint's general settings or content_config.
|
|
3444
|
+
* Partially update a blueprint's general settings or content_config. applies_to accepts the six case-type values. content_config.stages.items[].worked_by is an optional active review-team UUID from this application. These settings are preserved in case policy snapshots; later edits do not change existing snapshots.
|
|
3378
3445
|
*
|
|
3379
3446
|
* `PATCH /v3/organization/{organization_id}/application/{application_id}/cases/blueprints/{blueprint_uuid}/`
|
|
3380
3447
|
*
|
|
@@ -3415,7 +3482,7 @@ var CasesLinks = class extends APIResource {
|
|
|
3415
3482
|
/**
|
|
3416
3483
|
* Add case link
|
|
3417
3484
|
*
|
|
3418
|
-
* Attach a session, business session, or
|
|
3485
|
+
* Attach a session, business session, transaction, or network to the case. Rejected with 400 if the entity belongs to a different subject than the case. Network links require write:cases plus read:networks, Networks access and investigation access for the network scope. The network must be visible and contain the case subject. Manually adding links to network-generated cases is not allowed.
|
|
3419
3486
|
*
|
|
3420
3487
|
* `POST /v3/organization/{organization_id}/application/{application_id}/cases/{case_uuid}/links/`
|
|
3421
3488
|
*
|
|
@@ -3832,7 +3899,7 @@ var Cases = class extends APIResource {
|
|
|
3832
3899
|
/**
|
|
3833
3900
|
* Create case
|
|
3834
3901
|
*
|
|
3835
|
-
* Create a case anchored to exactly one subject (a user or a business), directly or by deriving the subject from an attached session/transaction link. Source is always `MANUAL` for API-created cases.
|
|
3902
|
+
* Create a case anchored to exactly one subject (a user or a business), directly or by deriving the subject from an attached session/transaction link. Source is always `MANUAL` for API-created cases. Network links require write:cases plus read:networks, Networks access and investigation access for the network scope. The network must be visible and contain the case subject. Manually adding links to network-generated cases is not allowed. An explicit subject is required whenever links includes a network.
|
|
3836
3903
|
*
|
|
3837
3904
|
* `POST /v3/organization/{organization_id}/application/{application_id}/cases/`
|
|
3838
3905
|
*/
|
|
@@ -8060,6 +8127,12 @@ var TRANSACTIONS_TRAVEL_RULE_CREATE_MESSAGE = {
|
|
|
8060
8127
|
body: "json",
|
|
8061
8128
|
dates: "TravelRuleMessage"
|
|
8062
8129
|
};
|
|
8130
|
+
var TRANSACTIONS_TRAVEL_RULE_CREATE_USER_LINK = {
|
|
8131
|
+
method: "POST",
|
|
8132
|
+
path: "/v3/transactions/{transaction_id}/travel-rule/user-link/",
|
|
8133
|
+
body: "json",
|
|
8134
|
+
dates: "TravelRuleUserLinkResponse"
|
|
8135
|
+
};
|
|
8063
8136
|
var TRANSACTIONS_TRAVEL_RULE_LIST_DELIVERIES = {
|
|
8064
8137
|
method: "GET",
|
|
8065
8138
|
path: "/v3/transactions/{transaction_id}/travel-rule/deliveries/",
|
|
@@ -8311,6 +8384,23 @@ var TransactionsTravelRule = class extends APIResource {
|
|
|
8311
8384
|
options
|
|
8312
8385
|
);
|
|
8313
8386
|
}
|
|
8387
|
+
/**
|
|
8388
|
+
* Create or email a Travel Rule end-user link
|
|
8389
|
+
*
|
|
8390
|
+
* Issue a new link and revoke previous open links for this transfer. Requires write access to transactions and an outbound transfer in AWAITING_COUNTERPARTY, COUNTERPARTY_VASP_NOT_FOUND, COUNTERPARTY_VASP_NOT_REACHABLE, UNCONFIRMED_OWNERSHIP or ON_HOLD. channel=email uses the end user's Didit-record email and verification-session language when available. A send failure returns the link with emailed_to empty; email_available reports address availability, not delivery. See [User links](/management-api/travel-rule/create-user-link).
|
|
8391
|
+
*
|
|
8392
|
+
* `POST /v3/transactions/{transaction_id}/travel-rule/user-link/`
|
|
8393
|
+
*
|
|
8394
|
+
* @param transactionId Didit-stable transaction UUID that owns the transfer.
|
|
8395
|
+
*/
|
|
8396
|
+
createUserLink(transactionId, params = {}, options) {
|
|
8397
|
+
return this._client.request(
|
|
8398
|
+
TRANSACTIONS_TRAVEL_RULE_CREATE_USER_LINK,
|
|
8399
|
+
[transactionId],
|
|
8400
|
+
params,
|
|
8401
|
+
options
|
|
8402
|
+
);
|
|
8403
|
+
}
|
|
8314
8404
|
/**
|
|
8315
8405
|
* List Travel Rule delivery history
|
|
8316
8406
|
*
|
|
@@ -8361,9 +8451,9 @@ var TransactionsTravelRule = class extends APIResource {
|
|
|
8361
8451
|
);
|
|
8362
8452
|
}
|
|
8363
8453
|
/**
|
|
8364
|
-
*
|
|
8454
|
+
* Update a Travel Rule transfer
|
|
8365
8455
|
*
|
|
8366
|
-
* Provide `payment_txn_id` to report the on-chain hash and move an outbound COMPLETED transfer to FINISHED (its INTERNAL-rail counterpart also moves to FINISHED), `{"action": "cancel"}` to cancel a non-terminal transfer, or `{"action": "resend"}` to route an outbound transfer stuck in COUNTERPARTY_VASP_NOT_FOUND, COUNTERPARTY_VASP_NOT_REACHABLE, or NOT_ENOUGH_COUNTERPARTY_DATA again (improve the counterparty data first, e.g. add a travel_address to the destination wallet entry). resend applies to outbound transfers only. `{"action": "update_compliance_email", "compliance_email": "desk@example.com"}` replaces the compliance email of an outbound transfer in one of those three statuses, the fix for `reason: email_undeliverable`: the status does not change, and the next `resend` sends the request to that address. A resend is queued, not run inside the request: the response shows the transfer back in AWAITING_COUNTERPARTY with a `resend queued` timeline entry and a queued `delivery`, and where it went arrives as a `travel_rule.status.updated` webhook. When the transfer went over GTR, VerifyVASP or Sygna Bridge, the network learns the on-chain hash or the cancellation after the response, with retries; `delivery` shows how that message stands. `{"action": "update_originator_wallet", "wallet_address": "..."}` records the wallet the funds actually left from on an outbound transfer, for example the address a UTXO withdrawal was broadcast from rather than the main wallet you declared. It changes the record only: nothing is sent to the counterparty again and the status stays. The originator becomes `chain_details.originator` with `source: updated`, the change is added to the `timeline` with the previous and the new wallet, and the INTERNAL-rail counterpart of the transfer is updated the same way. `{"action": "beneficiary_vasp", "beneficiary_vasp": "<directory VASP id>"}` names the counterparty yourself when discovery could not, on an outbound transfer in COUNTERPARTY_VASP_NOT_FOUND, COUNTERPARTY_VASP_NOT_REACHABLE or NOT_ENOUGH_COUNTERPARTY_DATA: the transfer is routed to that VASP and sent again.
|
|
8456
|
+
* Provide `payment_txn_id` to report the on-chain hash and move an outbound COMPLETED transfer to FINISHED (its INTERNAL-rail counterpart also moves to FINISHED), `{"action": "cancel"}` to cancel a non-terminal transfer, or `{"action": "resend"}` to route an outbound transfer stuck in COUNTERPARTY_VASP_NOT_FOUND, COUNTERPARTY_VASP_NOT_REACHABLE, or NOT_ENOUGH_COUNTERPARTY_DATA again (improve the counterparty data first, e.g. add a travel_address to the destination wallet entry). resend applies to outbound transfers only. `{"action": "update_compliance_email", "compliance_email": "desk@example.com"}` replaces the compliance email of an outbound transfer in one of those three statuses, the fix for `reason: email_undeliverable`: the status does not change, and the next `resend` sends the request to that address. A resend is queued, not run inside the request: the response shows the transfer back in AWAITING_COUNTERPARTY with a `resend queued` timeline entry and a queued `delivery`, and where it went arrives as a `travel_rule.status.updated` webhook. When the transfer went over GTR, VerifyVASP or Sygna Bridge, the network learns the on-chain hash or the cancellation after the response, with retries; `delivery` shows how that message stands. `{"action": "update_originator_wallet", "wallet_address": "..."}` records the wallet the funds actually left from on an outbound transfer, for example the address a UTXO withdrawal was broadcast from rather than the main wallet you declared. It changes the record only: nothing is sent to the counterparty again and the status stays. The originator becomes `chain_details.originator` with `source: updated`, the change is added to the `timeline` with the previous and the new wallet, and the INTERNAL-rail counterpart of the transfer is updated the same way. `{"action": "beneficiary_vasp", "beneficiary_vasp": "<directory VASP id>"}` names the counterparty yourself when discovery could not, on an outbound transfer in COUNTERPARTY_VASP_NOT_FOUND, COUNTERPARTY_VASP_NOT_REACHABLE or NOT_ENOUGH_COUNTERPARTY_DATA: the transfer is routed to that VASP and sent again. Cancellation accepts an optional reason and returns cancel_reason and cancelled_by. Resend accepts notify_on_answer; omission preserves the saved preference, initially false. Resend invalidates the previous counterparty pickup link. action=add_vasp_hint requires name, accepts lei and country, saves the hint and re-runs discovery under the same outbound/status restrictions as resend. update_compliance_email also accepts vasp_name and saves the address as an application-private contact when the transfer has a known directory VASP.
|
|
8367
8457
|
*
|
|
8368
8458
|
* `PATCH /v3/transactions/{transaction_id}/travel-rule/`
|
|
8369
8459
|
*
|
|
@@ -8550,6 +8640,7 @@ var TRAVEL_RULE_TRANSFERS_LIST = {
|
|
|
8550
8640
|
method: "GET",
|
|
8551
8641
|
path: "/v3/travel-rule/transfers/",
|
|
8552
8642
|
query: [
|
|
8643
|
+
"search",
|
|
8553
8644
|
"direction",
|
|
8554
8645
|
"status",
|
|
8555
8646
|
"rail",
|
|
@@ -8663,6 +8754,12 @@ var TRAVEL_RULE_CLEAR_VASP_DECISION = {
|
|
|
8663
8754
|
path: "/v3/travel-rule/vasps/{vasp_id}/decision/",
|
|
8664
8755
|
dates: "TravelRuleCounterpartyDecisionResponse"
|
|
8665
8756
|
};
|
|
8757
|
+
var TRAVEL_RULE_CREATE_VASP = {
|
|
8758
|
+
method: "POST",
|
|
8759
|
+
path: "/v3/travel-rule/vasps/",
|
|
8760
|
+
body: "json",
|
|
8761
|
+
dates: "VaspDirectoryEntry"
|
|
8762
|
+
};
|
|
8666
8763
|
var TRAVEL_RULE_CREATE_WIDGET_SESSION = {
|
|
8667
8764
|
method: "POST",
|
|
8668
8765
|
path: "/v3/travel-rule/widget-session/",
|
|
@@ -9052,6 +9149,16 @@ var TravelRule = class extends APIResource {
|
|
|
9052
9149
|
clearVaspDecision(vaspId, options) {
|
|
9053
9150
|
return this._client.request(TRAVEL_RULE_CLEAR_VASP_DECISION, [vaspId], void 0, options);
|
|
9054
9151
|
}
|
|
9152
|
+
/**
|
|
9153
|
+
* Create a private VASP directory entry
|
|
9154
|
+
*
|
|
9155
|
+
* Add a VASP privately to your application and optionally invite it. Requires write access to transactions. The response uses source=added_by_you. A matching visible name or LEI returns 409 with the existing vasp_id. See [Search the directory](/management-api/travel-rule/search-vasps).
|
|
9156
|
+
*
|
|
9157
|
+
* `POST /v3/travel-rule/vasps/`
|
|
9158
|
+
*/
|
|
9159
|
+
createVasp(params, options) {
|
|
9160
|
+
return this._client.request(TRAVEL_RULE_CREATE_VASP, [], params, options);
|
|
9161
|
+
}
|
|
9055
9162
|
/**
|
|
9056
9163
|
* Mint a wallet-ownership widget session
|
|
9057
9164
|
*
|
|
@@ -9077,7 +9184,7 @@ var TravelRule = class extends APIResource {
|
|
|
9077
9184
|
/**
|
|
9078
9185
|
* Search the VASP directory
|
|
9079
9186
|
*
|
|
9080
|
-
* Paginated, name-sorted search of the VASP directory: the shared directory entries, which Didit builds from the ESMA interim MiCA register, the public TRISA directory, the global LEI register and its own curation, plus the members of the Didit network. Each row carries the routes your application has to it today. Your own application's profile is never listed. Rows also carry the shared due-diligence assessment and your application's own decision, entity screening and questionnaires.
|
|
9187
|
+
* Paginated, name-sorted search of the VASP directory: the shared directory entries, which Didit builds from the ESMA interim MiCA register, the public TRISA directory, the global LEI register and its own curation, plus the members of the Didit network. Each row carries the routes your application has to it today. Your own application's profile is never listed. Rows also carry the shared due-diligence assessment and your application's own decision, entity screening and questionnaires. Includes entries your application added privately. The optional source field distinguishes their provenance; kind=didit member results may omit source.
|
|
9081
9188
|
*
|
|
9082
9189
|
* `GET /v3/travel-rule/vasps/`
|
|
9083
9190
|
*/
|
|
@@ -11171,11 +11278,15 @@ async function send(transport, request) {
|
|
|
11171
11278
|
log(null, null, "timeout");
|
|
11172
11279
|
return new APITimeoutError(
|
|
11173
11280
|
`The issuer did not answer ${method} ${path} within ${transport.timeout} ms.`,
|
|
11174
|
-
|
|
11281
|
+
// A request that carries secrets keeps no cause: a transport may quote the serialized body in it.
|
|
11282
|
+
request.structuredRedaction ? void 0 : { cause }
|
|
11175
11283
|
);
|
|
11176
11284
|
}
|
|
11177
11285
|
log(null, null, "connection_error");
|
|
11178
|
-
return new APIConnectionError(
|
|
11286
|
+
return new APIConnectionError(
|
|
11287
|
+
`Could not reach the issuer for ${method} ${path}.`,
|
|
11288
|
+
request.structuredRedaction ? void 0 : { cause }
|
|
11289
|
+
);
|
|
11179
11290
|
};
|
|
11180
11291
|
let status;
|
|
11181
11292
|
let responseHeaders;
|
|
@@ -11203,19 +11314,28 @@ async function send(transport, request) {
|
|
|
11203
11314
|
} finally {
|
|
11204
11315
|
clearTimeout(timer);
|
|
11205
11316
|
}
|
|
11206
|
-
|
|
11317
|
+
const secrets = request.secrets ?? [];
|
|
11318
|
+
const sanitized = request.structuredRedaction ? sanitizeResponse(responseHeaders, text, secrets) : null;
|
|
11319
|
+
const errorHeaders = sanitized?.headers ?? responseHeaders;
|
|
11320
|
+
log(status, errorHeaders);
|
|
11207
11321
|
if (status < 200 || status > 299) {
|
|
11208
|
-
throw makeStatusError(
|
|
11322
|
+
throw makeStatusError(
|
|
11323
|
+
status,
|
|
11324
|
+
bodyOf(sanitized?.text ?? text),
|
|
11325
|
+
errorHeaders,
|
|
11326
|
+
sanitized ? [] : secrets
|
|
11327
|
+
);
|
|
11209
11328
|
}
|
|
11210
|
-
if (status === 204 || !text)
|
|
11329
|
+
if (status === 204 || !text)
|
|
11330
|
+
return { status, headers: responseHeaders, errorHeaders, data: null };
|
|
11211
11331
|
try {
|
|
11212
|
-
return { status, headers: responseHeaders, data: JSON.parse(text) };
|
|
11332
|
+
return { status, headers: responseHeaders, errorHeaders, data: JSON.parse(text) };
|
|
11213
11333
|
} catch {
|
|
11214
|
-
const type =
|
|
11334
|
+
const type = errorHeaders.get("content-type") ?? "no content type";
|
|
11215
11335
|
throw new APIResponseValidationError(
|
|
11216
11336
|
`Expected a JSON response from ${method} ${path}, got ${type}.`,
|
|
11217
11337
|
status,
|
|
11218
|
-
|
|
11338
|
+
errorHeaders
|
|
11219
11339
|
);
|
|
11220
11340
|
}
|
|
11221
11341
|
}
|
|
@@ -11320,10 +11440,16 @@ function textList(value, name) {
|
|
|
11320
11440
|
}
|
|
11321
11441
|
return [...value];
|
|
11322
11442
|
}
|
|
11443
|
+
var MIN_SECRET_LENGTH = 16;
|
|
11323
11444
|
function assertionSecrets(value) {
|
|
11324
|
-
if (typeof value === "string") return value.length
|
|
11445
|
+
if (typeof value === "string") return value.length >= MIN_SECRET_LENGTH ? [value] : [];
|
|
11325
11446
|
if (Array.isArray(value)) return value.flatMap(assertionSecrets);
|
|
11326
|
-
if (isRecord4(value))
|
|
11447
|
+
if (isRecord4(value)) {
|
|
11448
|
+
return Object.entries(value).flatMap(([key, item]) => [
|
|
11449
|
+
...assertionSecrets(key),
|
|
11450
|
+
...assertionSecrets(item)
|
|
11451
|
+
]);
|
|
11452
|
+
}
|
|
11327
11453
|
return [];
|
|
11328
11454
|
}
|
|
11329
11455
|
function optionalText(value, name) {
|
|
@@ -11603,7 +11729,6 @@ var Authentication = class _Authentication {
|
|
|
11603
11729
|
if (assertion !== void 0 && assertion !== null) {
|
|
11604
11730
|
if (!isRecord4(assertion)) throw new TypeError("assertion must be an object.");
|
|
11605
11731
|
body.assertion = assertion;
|
|
11606
|
-
secrets.push(...assertionSecrets(assertion));
|
|
11607
11732
|
}
|
|
11608
11733
|
const scopes = given.scopes;
|
|
11609
11734
|
if (scopes !== void 0 && scopes !== null) body.scopes = textList(scopes, "scopes");
|
|
@@ -11618,7 +11743,19 @@ var Authentication = class _Authentication {
|
|
|
11618
11743
|
}
|
|
11619
11744
|
body.lifetime = lifetime;
|
|
11620
11745
|
}
|
|
11621
|
-
|
|
11746
|
+
let sent;
|
|
11747
|
+
try {
|
|
11748
|
+
sent = JSON.parse(JSON.stringify(body));
|
|
11749
|
+
} catch {
|
|
11750
|
+
throw new TypeError("Could not encode the agent consent request.");
|
|
11751
|
+
}
|
|
11752
|
+
secrets.push(...assertionSecrets(sent.assertion));
|
|
11753
|
+
const call = {
|
|
11754
|
+
...this.#bearerCall("POST", AGENT_CONSENT_PATH, token),
|
|
11755
|
+
json: sent,
|
|
11756
|
+
secrets,
|
|
11757
|
+
structuredRedaction: true
|
|
11758
|
+
};
|
|
11622
11759
|
return await this.#object(call);
|
|
11623
11760
|
}
|
|
11624
11761
|
/**
|
|
@@ -11634,7 +11771,8 @@ var Authentication = class _Authentication {
|
|
|
11634
11771
|
const call = {
|
|
11635
11772
|
...this.#bearerCall("POST", AGENT_CONSENT_PASSKEY_PATH, token),
|
|
11636
11773
|
json: { challenge },
|
|
11637
|
-
secrets: [token, challenge]
|
|
11774
|
+
secrets: [token, challenge],
|
|
11775
|
+
structuredRedaction: true
|
|
11638
11776
|
};
|
|
11639
11777
|
return await this.#object(call);
|
|
11640
11778
|
}
|
|
@@ -11654,7 +11792,7 @@ var Authentication = class _Authentication {
|
|
|
11654
11792
|
throw new APIResponseValidationError(
|
|
11655
11793
|
`Expected a JSON object from ${call.method} ${pathOf(call.url)}.`,
|
|
11656
11794
|
response.status,
|
|
11657
|
-
response.
|
|
11795
|
+
response.errorHeaders
|
|
11658
11796
|
);
|
|
11659
11797
|
}
|
|
11660
11798
|
return response.data;
|