@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.cjs
CHANGED
|
@@ -192,6 +192,52 @@ function makeStatusError(status, body, headers, secrets = []) {
|
|
|
192
192
|
const ErrorClass = STATUS_ERRORS[status] ?? (status >= 500 ? InternalServerError : APIStatusError);
|
|
193
193
|
return new ErrorClass(message, status, cleanBody, redactHeaders(headers, secrets));
|
|
194
194
|
}
|
|
195
|
+
var REDACTED = "[redacted]";
|
|
196
|
+
function redactStructured(value, secrets) {
|
|
197
|
+
const active = secrets.filter((s) => s.length > 0);
|
|
198
|
+
const text = (input) => active.some((secret) => input.includes(secret)) ? REDACTED : input;
|
|
199
|
+
const scrub = (input) => {
|
|
200
|
+
if (typeof input === "string") return text(input);
|
|
201
|
+
if (Array.isArray(input)) return input.map(scrub);
|
|
202
|
+
if (isRecord(input)) {
|
|
203
|
+
const out = /* @__PURE__ */ new Map();
|
|
204
|
+
const taken = new Set(Object.keys(input).filter((key) => text(key) === key));
|
|
205
|
+
let next = 1;
|
|
206
|
+
for (const [key, item] of Object.entries(input)) {
|
|
207
|
+
let name = key;
|
|
208
|
+
if (text(key) !== key) {
|
|
209
|
+
do {
|
|
210
|
+
name = next === 1 ? REDACTED : `${REDACTED}${next}`;
|
|
211
|
+
next++;
|
|
212
|
+
} while (taken.has(name));
|
|
213
|
+
taken.add(name);
|
|
214
|
+
}
|
|
215
|
+
out.set(name, scrub(item));
|
|
216
|
+
}
|
|
217
|
+
return Object.fromEntries(out);
|
|
218
|
+
}
|
|
219
|
+
return input;
|
|
220
|
+
};
|
|
221
|
+
return scrub(value);
|
|
222
|
+
}
|
|
223
|
+
function sanitizeResponse(headers, text, secrets) {
|
|
224
|
+
const clean = new Headers();
|
|
225
|
+
headers.forEach((value, name) => {
|
|
226
|
+
const folded = name.toLowerCase();
|
|
227
|
+
if (!secrets.some((secret) => secret && folded.includes(secret.toLowerCase()))) {
|
|
228
|
+
clean.append(name, redactStructured(value, secrets));
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
let body = REDACTED;
|
|
232
|
+
if (text) {
|
|
233
|
+
try {
|
|
234
|
+
body = JSON.stringify(redactStructured(JSON.parse(text), secrets));
|
|
235
|
+
} catch {
|
|
236
|
+
body = REDACTED;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return { headers: clean, text: body };
|
|
240
|
+
}
|
|
195
241
|
|
|
196
242
|
// src/core/api-promise.ts
|
|
197
243
|
var APIPromise = class extends Promise {
|
|
@@ -282,7 +328,7 @@ function decodeDates(value, plan, named, depth = 0) {
|
|
|
282
328
|
}
|
|
283
329
|
|
|
284
330
|
// src/core/version.ts
|
|
285
|
-
var VERSION = "2.
|
|
331
|
+
var VERSION = "2.14.0";
|
|
286
332
|
|
|
287
333
|
// src/core/runtime.ts
|
|
288
334
|
function processLike() {
|
|
@@ -1674,7 +1720,8 @@ var DATE_PLANS = {
|
|
|
1674
1720
|
data_unmasked: "TravelRuleDataUnmasked",
|
|
1675
1721
|
counterparty_vasp: { p: { dd_assessed_at: 1 } },
|
|
1676
1722
|
delivery: "TravelRuleDelivery",
|
|
1677
|
-
discovery: { i: "TravelRuleDiscoveryStep" }
|
|
1723
|
+
discovery: { i: "TravelRuleDiscoveryStep" },
|
|
1724
|
+
user_choice: "TravelRuleUserChoice"
|
|
1678
1725
|
}
|
|
1679
1726
|
},
|
|
1680
1727
|
TransactionNote: { p: { created_at: 1 } },
|
|
@@ -1686,7 +1733,8 @@ var DATE_PLANS = {
|
|
|
1686
1733
|
counterparty_vasp: { p: { dd_assessed_at: 1 } },
|
|
1687
1734
|
delivery: "TravelRuleDelivery",
|
|
1688
1735
|
discovery: { i: "TravelRuleDiscoveryStep" },
|
|
1689
|
-
deliveries: { i: "TravelRuleDeliveryLogEntry" }
|
|
1736
|
+
deliveries: { i: "TravelRuleDeliveryLogEntry" },
|
|
1737
|
+
user_choice: "TravelRuleUserChoice"
|
|
1690
1738
|
}
|
|
1691
1739
|
},
|
|
1692
1740
|
TransactionWalletOwnershipAction: { p: { expires_at: 1 } },
|
|
@@ -1780,12 +1828,15 @@ var DATE_PLANS = {
|
|
|
1780
1828
|
created_at: 1,
|
|
1781
1829
|
delivery: "TravelRuleDelivery",
|
|
1782
1830
|
discovery: { i: "TravelRuleDiscoveryStep" },
|
|
1783
|
-
deliveries: { i: "TravelRuleDeliveryLogEntry" }
|
|
1831
|
+
deliveries: { i: "TravelRuleDeliveryLogEntry" },
|
|
1832
|
+
user_choice: "TravelRuleUserChoice"
|
|
1784
1833
|
}
|
|
1785
1834
|
},
|
|
1786
1835
|
TravelRuleTransferRow: { p: { txn_date: 1, deadline_at: 1, created_at: 1 } },
|
|
1787
1836
|
TravelRuleTransfersListResponse: { p: { results: { i: "TravelRuleTransferRow" } } },
|
|
1788
1837
|
TravelRuleUnmatchedDepositsListResponse: { p: { results: { i: "TravelRuleTransferRow" } } },
|
|
1838
|
+
TravelRuleUserChoice: { p: { link_expires_at: 1 } },
|
|
1839
|
+
TravelRuleUserLinkResponse: { p: { expires_at: 1 } },
|
|
1789
1840
|
TravelRuleWalletAddressesListResponse: { p: { results: { i: "WalletAddressEntry" } } },
|
|
1790
1841
|
TravelRuleWalletProofReview: { p: { method_chosen_at: 1, decided_at: 1, created_at: 1 } },
|
|
1791
1842
|
TravelRuleWalletProofsListResponse: { p: { results: { i: "TravelRuleWalletProofReview" } } },
|
|
@@ -2787,6 +2838,12 @@ var Businesses = class extends APIResource {
|
|
|
2787
2838
|
};
|
|
2788
2839
|
|
|
2789
2840
|
// src/resources/cases.ts
|
|
2841
|
+
var CASES_BLUEPRINTS_AI_DRAFT = {
|
|
2842
|
+
method: "POST",
|
|
2843
|
+
path: "/v3/organization/{organization_id}/application/{application_id}/cases/blueprints/ai-draft/",
|
|
2844
|
+
scope: "application",
|
|
2845
|
+
body: "json"
|
|
2846
|
+
};
|
|
2790
2847
|
var CASES_BLUEPRINTS_CREATE = {
|
|
2791
2848
|
method: "POST",
|
|
2792
2849
|
path: "/v3/organization/{organization_id}/application/{application_id}/cases/blueprints/",
|
|
@@ -3261,10 +3318,20 @@ var CASES_UPDATE = {
|
|
|
3261
3318
|
dates: "CaseDetail"
|
|
3262
3319
|
};
|
|
3263
3320
|
var CasesBlueprints = class extends APIResource {
|
|
3321
|
+
/**
|
|
3322
|
+
* Draft case blueprint with AI
|
|
3323
|
+
*
|
|
3324
|
+
* 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).
|
|
3325
|
+
*
|
|
3326
|
+
* `POST /v3/organization/{organization_id}/application/{application_id}/cases/blueprints/ai-draft/`
|
|
3327
|
+
*/
|
|
3328
|
+
aiDraft(params, options) {
|
|
3329
|
+
return this._client.request(CASES_BLUEPRINTS_AI_DRAFT, [], params, options);
|
|
3330
|
+
}
|
|
3264
3331
|
/**
|
|
3265
3332
|
* Create blueprint
|
|
3266
3333
|
*
|
|
3267
|
-
* 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.
|
|
3334
|
+
* 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.
|
|
3268
3335
|
*
|
|
3269
3336
|
* `POST /v3/organization/{organization_id}/application/{application_id}/cases/blueprints/`
|
|
3270
3337
|
*/
|
|
@@ -3378,7 +3445,7 @@ var CasesBlueprints = class extends APIResource {
|
|
|
3378
3445
|
/**
|
|
3379
3446
|
* Update blueprint
|
|
3380
3447
|
*
|
|
3381
|
-
* Partially update a blueprint's general settings or content_config.
|
|
3448
|
+
* 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.
|
|
3382
3449
|
*
|
|
3383
3450
|
* `PATCH /v3/organization/{organization_id}/application/{application_id}/cases/blueprints/{blueprint_uuid}/`
|
|
3384
3451
|
*
|
|
@@ -3419,7 +3486,7 @@ var CasesLinks = class extends APIResource {
|
|
|
3419
3486
|
/**
|
|
3420
3487
|
* Add case link
|
|
3421
3488
|
*
|
|
3422
|
-
* Attach a session, business session, or
|
|
3489
|
+
* 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.
|
|
3423
3490
|
*
|
|
3424
3491
|
* `POST /v3/organization/{organization_id}/application/{application_id}/cases/{case_uuid}/links/`
|
|
3425
3492
|
*
|
|
@@ -3836,7 +3903,7 @@ var Cases = class extends APIResource {
|
|
|
3836
3903
|
/**
|
|
3837
3904
|
* Create case
|
|
3838
3905
|
*
|
|
3839
|
-
* 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.
|
|
3906
|
+
* 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.
|
|
3840
3907
|
*
|
|
3841
3908
|
* `POST /v3/organization/{organization_id}/application/{application_id}/cases/`
|
|
3842
3909
|
*/
|
|
@@ -8064,6 +8131,12 @@ var TRANSACTIONS_TRAVEL_RULE_CREATE_MESSAGE = {
|
|
|
8064
8131
|
body: "json",
|
|
8065
8132
|
dates: "TravelRuleMessage"
|
|
8066
8133
|
};
|
|
8134
|
+
var TRANSACTIONS_TRAVEL_RULE_CREATE_USER_LINK = {
|
|
8135
|
+
method: "POST",
|
|
8136
|
+
path: "/v3/transactions/{transaction_id}/travel-rule/user-link/",
|
|
8137
|
+
body: "json",
|
|
8138
|
+
dates: "TravelRuleUserLinkResponse"
|
|
8139
|
+
};
|
|
8067
8140
|
var TRANSACTIONS_TRAVEL_RULE_LIST_DELIVERIES = {
|
|
8068
8141
|
method: "GET",
|
|
8069
8142
|
path: "/v3/transactions/{transaction_id}/travel-rule/deliveries/",
|
|
@@ -8315,6 +8388,23 @@ var TransactionsTravelRule = class extends APIResource {
|
|
|
8315
8388
|
options
|
|
8316
8389
|
);
|
|
8317
8390
|
}
|
|
8391
|
+
/**
|
|
8392
|
+
* Create or email a Travel Rule end-user link
|
|
8393
|
+
*
|
|
8394
|
+
* 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).
|
|
8395
|
+
*
|
|
8396
|
+
* `POST /v3/transactions/{transaction_id}/travel-rule/user-link/`
|
|
8397
|
+
*
|
|
8398
|
+
* @param transactionId Didit-stable transaction UUID that owns the transfer.
|
|
8399
|
+
*/
|
|
8400
|
+
createUserLink(transactionId, params = {}, options) {
|
|
8401
|
+
return this._client.request(
|
|
8402
|
+
TRANSACTIONS_TRAVEL_RULE_CREATE_USER_LINK,
|
|
8403
|
+
[transactionId],
|
|
8404
|
+
params,
|
|
8405
|
+
options
|
|
8406
|
+
);
|
|
8407
|
+
}
|
|
8318
8408
|
/**
|
|
8319
8409
|
* List Travel Rule delivery history
|
|
8320
8410
|
*
|
|
@@ -8365,9 +8455,9 @@ var TransactionsTravelRule = class extends APIResource {
|
|
|
8365
8455
|
);
|
|
8366
8456
|
}
|
|
8367
8457
|
/**
|
|
8368
|
-
*
|
|
8458
|
+
* Update a Travel Rule transfer
|
|
8369
8459
|
*
|
|
8370
|
-
* 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.
|
|
8460
|
+
* 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.
|
|
8371
8461
|
*
|
|
8372
8462
|
* `PATCH /v3/transactions/{transaction_id}/travel-rule/`
|
|
8373
8463
|
*
|
|
@@ -8554,6 +8644,7 @@ var TRAVEL_RULE_TRANSFERS_LIST = {
|
|
|
8554
8644
|
method: "GET",
|
|
8555
8645
|
path: "/v3/travel-rule/transfers/",
|
|
8556
8646
|
query: [
|
|
8647
|
+
"search",
|
|
8557
8648
|
"direction",
|
|
8558
8649
|
"status",
|
|
8559
8650
|
"rail",
|
|
@@ -8667,6 +8758,12 @@ var TRAVEL_RULE_CLEAR_VASP_DECISION = {
|
|
|
8667
8758
|
path: "/v3/travel-rule/vasps/{vasp_id}/decision/",
|
|
8668
8759
|
dates: "TravelRuleCounterpartyDecisionResponse"
|
|
8669
8760
|
};
|
|
8761
|
+
var TRAVEL_RULE_CREATE_VASP = {
|
|
8762
|
+
method: "POST",
|
|
8763
|
+
path: "/v3/travel-rule/vasps/",
|
|
8764
|
+
body: "json",
|
|
8765
|
+
dates: "VaspDirectoryEntry"
|
|
8766
|
+
};
|
|
8670
8767
|
var TRAVEL_RULE_CREATE_WIDGET_SESSION = {
|
|
8671
8768
|
method: "POST",
|
|
8672
8769
|
path: "/v3/travel-rule/widget-session/",
|
|
@@ -9056,6 +9153,16 @@ var TravelRule = class extends APIResource {
|
|
|
9056
9153
|
clearVaspDecision(vaspId, options) {
|
|
9057
9154
|
return this._client.request(TRAVEL_RULE_CLEAR_VASP_DECISION, [vaspId], void 0, options);
|
|
9058
9155
|
}
|
|
9156
|
+
/**
|
|
9157
|
+
* Create a private VASP directory entry
|
|
9158
|
+
*
|
|
9159
|
+
* 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).
|
|
9160
|
+
*
|
|
9161
|
+
* `POST /v3/travel-rule/vasps/`
|
|
9162
|
+
*/
|
|
9163
|
+
createVasp(params, options) {
|
|
9164
|
+
return this._client.request(TRAVEL_RULE_CREATE_VASP, [], params, options);
|
|
9165
|
+
}
|
|
9059
9166
|
/**
|
|
9060
9167
|
* Mint a wallet-ownership widget session
|
|
9061
9168
|
*
|
|
@@ -9081,7 +9188,7 @@ var TravelRule = class extends APIResource {
|
|
|
9081
9188
|
/**
|
|
9082
9189
|
* Search the VASP directory
|
|
9083
9190
|
*
|
|
9084
|
-
* 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.
|
|
9191
|
+
* 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.
|
|
9085
9192
|
*
|
|
9086
9193
|
* `GET /v3/travel-rule/vasps/`
|
|
9087
9194
|
*/
|
|
@@ -11175,11 +11282,15 @@ async function send(transport, request) {
|
|
|
11175
11282
|
log(null, null, "timeout");
|
|
11176
11283
|
return new APITimeoutError(
|
|
11177
11284
|
`The issuer did not answer ${method} ${path} within ${transport.timeout} ms.`,
|
|
11178
|
-
|
|
11285
|
+
// A request that carries secrets keeps no cause: a transport may quote the serialized body in it.
|
|
11286
|
+
request.structuredRedaction ? void 0 : { cause }
|
|
11179
11287
|
);
|
|
11180
11288
|
}
|
|
11181
11289
|
log(null, null, "connection_error");
|
|
11182
|
-
return new APIConnectionError(
|
|
11290
|
+
return new APIConnectionError(
|
|
11291
|
+
`Could not reach the issuer for ${method} ${path}.`,
|
|
11292
|
+
request.structuredRedaction ? void 0 : { cause }
|
|
11293
|
+
);
|
|
11183
11294
|
};
|
|
11184
11295
|
let status;
|
|
11185
11296
|
let responseHeaders;
|
|
@@ -11207,19 +11318,28 @@ async function send(transport, request) {
|
|
|
11207
11318
|
} finally {
|
|
11208
11319
|
clearTimeout(timer);
|
|
11209
11320
|
}
|
|
11210
|
-
|
|
11321
|
+
const secrets = request.secrets ?? [];
|
|
11322
|
+
const sanitized = request.structuredRedaction ? sanitizeResponse(responseHeaders, text, secrets) : null;
|
|
11323
|
+
const errorHeaders = sanitized?.headers ?? responseHeaders;
|
|
11324
|
+
log(status, errorHeaders);
|
|
11211
11325
|
if (status < 200 || status > 299) {
|
|
11212
|
-
throw makeStatusError(
|
|
11326
|
+
throw makeStatusError(
|
|
11327
|
+
status,
|
|
11328
|
+
bodyOf(sanitized?.text ?? text),
|
|
11329
|
+
errorHeaders,
|
|
11330
|
+
sanitized ? [] : secrets
|
|
11331
|
+
);
|
|
11213
11332
|
}
|
|
11214
|
-
if (status === 204 || !text)
|
|
11333
|
+
if (status === 204 || !text)
|
|
11334
|
+
return { status, headers: responseHeaders, errorHeaders, data: null };
|
|
11215
11335
|
try {
|
|
11216
|
-
return { status, headers: responseHeaders, data: JSON.parse(text) };
|
|
11336
|
+
return { status, headers: responseHeaders, errorHeaders, data: JSON.parse(text) };
|
|
11217
11337
|
} catch {
|
|
11218
|
-
const type =
|
|
11338
|
+
const type = errorHeaders.get("content-type") ?? "no content type";
|
|
11219
11339
|
throw new APIResponseValidationError(
|
|
11220
11340
|
`Expected a JSON response from ${method} ${path}, got ${type}.`,
|
|
11221
11341
|
status,
|
|
11222
|
-
|
|
11342
|
+
errorHeaders
|
|
11223
11343
|
);
|
|
11224
11344
|
}
|
|
11225
11345
|
}
|
|
@@ -11324,10 +11444,16 @@ function textList(value, name) {
|
|
|
11324
11444
|
}
|
|
11325
11445
|
return [...value];
|
|
11326
11446
|
}
|
|
11447
|
+
var MIN_SECRET_LENGTH = 16;
|
|
11327
11448
|
function assertionSecrets(value) {
|
|
11328
|
-
if (typeof value === "string") return value.length
|
|
11449
|
+
if (typeof value === "string") return value.length >= MIN_SECRET_LENGTH ? [value] : [];
|
|
11329
11450
|
if (Array.isArray(value)) return value.flatMap(assertionSecrets);
|
|
11330
|
-
if (isRecord4(value))
|
|
11451
|
+
if (isRecord4(value)) {
|
|
11452
|
+
return Object.entries(value).flatMap(([key, item]) => [
|
|
11453
|
+
...assertionSecrets(key),
|
|
11454
|
+
...assertionSecrets(item)
|
|
11455
|
+
]);
|
|
11456
|
+
}
|
|
11331
11457
|
return [];
|
|
11332
11458
|
}
|
|
11333
11459
|
function optionalText(value, name) {
|
|
@@ -11607,7 +11733,6 @@ var Authentication = class _Authentication {
|
|
|
11607
11733
|
if (assertion !== void 0 && assertion !== null) {
|
|
11608
11734
|
if (!isRecord4(assertion)) throw new TypeError("assertion must be an object.");
|
|
11609
11735
|
body.assertion = assertion;
|
|
11610
|
-
secrets.push(...assertionSecrets(assertion));
|
|
11611
11736
|
}
|
|
11612
11737
|
const scopes = given.scopes;
|
|
11613
11738
|
if (scopes !== void 0 && scopes !== null) body.scopes = textList(scopes, "scopes");
|
|
@@ -11622,7 +11747,19 @@ var Authentication = class _Authentication {
|
|
|
11622
11747
|
}
|
|
11623
11748
|
body.lifetime = lifetime;
|
|
11624
11749
|
}
|
|
11625
|
-
|
|
11750
|
+
let sent;
|
|
11751
|
+
try {
|
|
11752
|
+
sent = JSON.parse(JSON.stringify(body));
|
|
11753
|
+
} catch {
|
|
11754
|
+
throw new TypeError("Could not encode the agent consent request.");
|
|
11755
|
+
}
|
|
11756
|
+
secrets.push(...assertionSecrets(sent.assertion));
|
|
11757
|
+
const call = {
|
|
11758
|
+
...this.#bearerCall("POST", AGENT_CONSENT_PATH, token),
|
|
11759
|
+
json: sent,
|
|
11760
|
+
secrets,
|
|
11761
|
+
structuredRedaction: true
|
|
11762
|
+
};
|
|
11626
11763
|
return await this.#object(call);
|
|
11627
11764
|
}
|
|
11628
11765
|
/**
|
|
@@ -11638,7 +11775,8 @@ var Authentication = class _Authentication {
|
|
|
11638
11775
|
const call = {
|
|
11639
11776
|
...this.#bearerCall("POST", AGENT_CONSENT_PASSKEY_PATH, token),
|
|
11640
11777
|
json: { challenge },
|
|
11641
|
-
secrets: [token, challenge]
|
|
11778
|
+
secrets: [token, challenge],
|
|
11779
|
+
structuredRedaction: true
|
|
11642
11780
|
};
|
|
11643
11781
|
return await this.#object(call);
|
|
11644
11782
|
}
|
|
@@ -11658,7 +11796,7 @@ var Authentication = class _Authentication {
|
|
|
11658
11796
|
throw new APIResponseValidationError(
|
|
11659
11797
|
`Expected a JSON object from ${call.method} ${pathOf(call.url)}.`,
|
|
11660
11798
|
response.status,
|
|
11661
|
-
response.
|
|
11799
|
+
response.errorHeaders
|
|
11662
11800
|
);
|
|
11663
11801
|
}
|
|
11664
11802
|
return response.data;
|