@didit-protocol/sdk-node 2.10.0 → 2.11.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/README.md +1 -0
- package/dist/index.cjs +101 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +293 -4
- package/dist/index.d.ts +293 -4
- package/dist/index.js +101 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -307,6 +307,7 @@ try {
|
|
|
307
307
|
- `refresh(refreshToken)`: serialise refreshes for one session; reusing a consumed refresh token revokes the session.
|
|
308
308
|
- `getSession(accessToken)` for an instant revocation check, `revokeSession(accessToken)`.
|
|
309
309
|
- `createStepUp(accessToken, { action, amount?, currency?, returnTo? })` and `retrieveStepUp(accessToken, id)`: act only on status `approved`. The issuer currently requires `returnTo` and answers 400 without it.
|
|
310
|
+
- `submitAgentConsent(accessToken, { challenge, decision, assertion?, scopes?, organizationIds?, lifetime? })` approves or denies an agent request (approval returns `{ code, redirect_uri, state }`, denial `{ status: "denied" }`; test `"code" in result`) and `createAgentApprovalOptions(accessToken, { challenge })` returns the WebAuthn `options` for the fresh passkey assertion a humans-only application requires (403 `passkey_required` without it). Neither is retried; the challenge and assertion are never logged.
|
|
310
311
|
|
|
311
312
|
Authentication is in early access and reaches production with the 2026-11-01 Didit release.
|
|
312
313
|
|
package/dist/index.cjs
CHANGED
|
@@ -282,7 +282,7 @@ function decodeDates(value, plan, named, depth = 0) {
|
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
// src/core/version.ts
|
|
285
|
-
var VERSION = "2.
|
|
285
|
+
var VERSION = "2.11.0";
|
|
286
286
|
|
|
287
287
|
// src/core/runtime.ts
|
|
288
288
|
function processLike() {
|
|
@@ -1952,6 +1952,8 @@ var AccountApplications = class extends APIResource {
|
|
|
1952
1952
|
*
|
|
1953
1953
|
* Create an application inside an organization, in the data location you choose (`data_location`, the European Union by default; it can't be changed afterwards). The response includes `api_key`; persist it now (recoverable via GET). Requires owner/admin JWT.
|
|
1954
1954
|
*
|
|
1955
|
+
* Set initiate_login_uri to your HTTPS sign-in page on the exact website_url hostname, or an empty string to disable admin-sent sign-in links. Changing website_url also revalidates the saved sign-in URI. Invalid values return 400 with an initiate_login_uri field error; hostname and URI policy failures use https_url_on_registered_website_required.
|
|
1956
|
+
*
|
|
1955
1957
|
* `POST /organizations/me/{org_id}/applications/`
|
|
1956
1958
|
*
|
|
1957
1959
|
* @param orgId UUID of the organization. Look it up with `GET /organizations/me/`.
|
|
@@ -1989,6 +1991,8 @@ var AccountApplications = class extends APIResource {
|
|
|
1989
1991
|
*
|
|
1990
1992
|
* Update application metadata (name, URLs, redirect URIs). `api_key` and `client_id` are never rotated. `products` is read-only: a `products` key in the body is ignored. `data_location` can't be changed after the application is created, except once on the live application created with your organization, while it is unused (see the request body). Requires owner/admin JWT.
|
|
1991
1993
|
*
|
|
1994
|
+
* Set initiate_login_uri to your HTTPS sign-in page on the exact website_url hostname, or an empty string to disable admin-sent sign-in links. Changing website_url also revalidates the saved sign-in URI. Invalid values return 400 with an initiate_login_uri field error; hostname and URI policy failures use https_url_on_registered_website_required.
|
|
1995
|
+
*
|
|
1992
1996
|
* `PATCH /organizations/me/{org_id}/applications/{app_id}/`
|
|
1993
1997
|
*
|
|
1994
1998
|
* @param orgId UUID of the organization that owns the application.
|
|
@@ -6524,6 +6528,21 @@ var ReportTemplates = class extends APIResource {
|
|
|
6524
6528
|
}
|
|
6525
6529
|
};
|
|
6526
6530
|
|
|
6531
|
+
// src/resources/sandbox.ts
|
|
6532
|
+
var SANDBOX_LIST_SCENARIOS = { method: "GET", path: "/v1/sandbox/scenarios/" };
|
|
6533
|
+
var Sandbox = class extends APIResource {
|
|
6534
|
+
/**
|
|
6535
|
+
* List sandbox scenarios and Test VASP metadata
|
|
6536
|
+
*
|
|
6537
|
+
* Read the sandbox catalog Didit serves for testing. Authenticate with your application's API key or access token; a sandbox session's `Session-Token` also reads it, narrowed to the scenarios that session's workflow can produce. `scenarios`, `magic_values`, `risk_cases`, `sample_identity` and `delivery_conventions` describe the mocked session outcomes and the values that trigger them. `travel_rule` is the Didit Test VASP: its identity, the `routes` it answers over, and each scenario's own `route`. Every Test VASP exchange runs in process inside Didit, so `TEST_VASP` is not a live network or email transport and no real VASP is contacted. Pick a Travel Rule scenario by its beneficiary wallet address or by a beneficiary name of the form `Didit Test VASP <suffix>`. See [Travel Rule sandbox testing](/transaction-monitoring/travel-rule-sandbox).
|
|
6538
|
+
*
|
|
6539
|
+
* `GET /v1/sandbox/scenarios/`
|
|
6540
|
+
*/
|
|
6541
|
+
listScenarios(options) {
|
|
6542
|
+
return this._client.request(SANDBOX_LIST_SCENARIOS, [], void 0, options);
|
|
6543
|
+
}
|
|
6544
|
+
};
|
|
6545
|
+
|
|
6527
6546
|
// src/resources/sessions.ts
|
|
6528
6547
|
var SESSIONS_IMPORTS_CANCEL = {
|
|
6529
6548
|
method: "POST",
|
|
@@ -10638,6 +10657,7 @@ var DiditResources = class extends APIClient {
|
|
|
10638
10657
|
questionnaires = new Questionnaires(this);
|
|
10639
10658
|
regulatoryReports = new RegulatoryReports(this);
|
|
10640
10659
|
reportTemplates = new ReportTemplates(this);
|
|
10660
|
+
sandbox = new Sandbox(this);
|
|
10641
10661
|
sessions = new Sessions(this);
|
|
10642
10662
|
transactions = new Transactions(this);
|
|
10643
10663
|
travelRule = new TravelRule(this);
|
|
@@ -11235,6 +11255,8 @@ var JWKS_PATH = ".well-known/jwks.json";
|
|
|
11235
11255
|
var TOKEN_PATH = "token/";
|
|
11236
11256
|
var SESSION_PATH = "session/";
|
|
11237
11257
|
var STEP_UP_PATH = "step-up/";
|
|
11258
|
+
var AGENT_CONSENT_PATH = "agents/consent/";
|
|
11259
|
+
var AGENT_CONSENT_PASSKEY_PATH = "agents/consent/passkey/";
|
|
11238
11260
|
var DECIMAL_TEXT = /^-?[0-9]+(\.[0-9]+)?$/;
|
|
11239
11261
|
function fieldsOf(value) {
|
|
11240
11262
|
return value ?? {};
|
|
@@ -11253,6 +11275,23 @@ function bearerToken(value, name) {
|
|
|
11253
11275
|
}
|
|
11254
11276
|
return token;
|
|
11255
11277
|
}
|
|
11278
|
+
function textList(value, name) {
|
|
11279
|
+
if (!Array.isArray(value) || value.some((item) => typeof item !== "string")) {
|
|
11280
|
+
throw new TypeError(`${name} must be a list of strings.`);
|
|
11281
|
+
}
|
|
11282
|
+
return [...value];
|
|
11283
|
+
}
|
|
11284
|
+
function assertionSecrets(assertion) {
|
|
11285
|
+
const response = isRecord4(assertion.response) ? assertion.response : {};
|
|
11286
|
+
return [
|
|
11287
|
+
assertion.id,
|
|
11288
|
+
assertion.rawId,
|
|
11289
|
+
response.clientDataJSON,
|
|
11290
|
+
response.authenticatorData,
|
|
11291
|
+
response.signature,
|
|
11292
|
+
response.userHandle
|
|
11293
|
+
].filter((value) => typeof value === "string" && value.length > 0);
|
|
11294
|
+
}
|
|
11256
11295
|
function optionalText(value, name) {
|
|
11257
11296
|
if (value === void 0 || value === null) return void 0;
|
|
11258
11297
|
if (typeof value !== "string") throw new TypeError(`${name} must be a string.`);
|
|
@@ -11505,6 +11544,66 @@ var Authentication = class _Authentication {
|
|
|
11505
11544
|
const path = `${STEP_UP_PATH}${pathSegment(id, "id")}/`;
|
|
11506
11545
|
return await this.#object(this.#bearerCall("GET", path, token));
|
|
11507
11546
|
}
|
|
11547
|
+
/**
|
|
11548
|
+
* Approve or deny an agent's access request (`POST agents/consent/`) with a
|
|
11549
|
+
* token of the signed-in person. Approval returns `{ code, redirect_uri,
|
|
11550
|
+
* state }` (the agent exchanges the single-use code, valid 60 seconds, itself;
|
|
11551
|
+
* no token is returned here); denial returns `{ status: "denied" }`. Tell them
|
|
11552
|
+
* apart with `"code" in result`. A POST: never retried. The `challenge` and
|
|
11553
|
+
* the `assertion` are never logged and are removed from error messages.
|
|
11554
|
+
* Typical failures: 400 `invalid_grant` (unknown or expired request) and 403
|
|
11555
|
+
* `passkey_required` (humans-only application: call
|
|
11556
|
+
* `createAgentApprovalOptions`, run the passkey ceremony, pass the assertion).
|
|
11557
|
+
*/
|
|
11558
|
+
async submitAgentConsent(accessToken, params) {
|
|
11559
|
+
const token = bearerToken(accessToken, "accessToken");
|
|
11560
|
+
const given = fieldsOf(params);
|
|
11561
|
+
const challenge = requiredText(given.challenge, "challenge");
|
|
11562
|
+
const decision = requiredText(given.decision, "decision");
|
|
11563
|
+
if (decision !== "approve" && decision !== "deny") {
|
|
11564
|
+
throw new TypeError('decision must be "approve" or "deny".');
|
|
11565
|
+
}
|
|
11566
|
+
const body = { challenge, decision };
|
|
11567
|
+
const secrets = [token, challenge];
|
|
11568
|
+
const assertion = given.assertion;
|
|
11569
|
+
if (assertion !== void 0 && assertion !== null) {
|
|
11570
|
+
if (!isRecord4(assertion)) throw new TypeError("assertion must be an object.");
|
|
11571
|
+
body.assertion = assertion;
|
|
11572
|
+
secrets.push(...assertionSecrets(assertion));
|
|
11573
|
+
}
|
|
11574
|
+
const scopes = given.scopes;
|
|
11575
|
+
if (scopes !== void 0 && scopes !== null) body.scopes = textList(scopes, "scopes");
|
|
11576
|
+
const organizationIds = given.organizationIds;
|
|
11577
|
+
if (organizationIds !== void 0 && organizationIds !== null) {
|
|
11578
|
+
body.organization_ids = textList(organizationIds, "organizationIds");
|
|
11579
|
+
}
|
|
11580
|
+
const lifetime = given.lifetime;
|
|
11581
|
+
if (lifetime !== void 0 && lifetime !== null) {
|
|
11582
|
+
if (typeof lifetime !== "number" || !Number.isInteger(lifetime)) {
|
|
11583
|
+
throw new TypeError("lifetime must be an integer number of seconds.");
|
|
11584
|
+
}
|
|
11585
|
+
body.lifetime = lifetime;
|
|
11586
|
+
}
|
|
11587
|
+
const call = { ...this.#bearerCall("POST", AGENT_CONSENT_PATH, token), json: body, secrets };
|
|
11588
|
+
return await this.#object(call);
|
|
11589
|
+
}
|
|
11590
|
+
/**
|
|
11591
|
+
* Get WebAuthn request options bound to a pending agent request
|
|
11592
|
+
* (`POST agents/consent/passkey/`) with a token of the signed-in person. Pass
|
|
11593
|
+
* `options` to `navigator.credentials.get()` (decode the base64url fields),
|
|
11594
|
+
* then send the result as `assertion` to `submitAgentConsent`. A POST: never
|
|
11595
|
+
* retried; the `challenge` is never logged.
|
|
11596
|
+
*/
|
|
11597
|
+
async createAgentApprovalOptions(accessToken, params) {
|
|
11598
|
+
const token = bearerToken(accessToken, "accessToken");
|
|
11599
|
+
const challenge = requiredText(fieldsOf(params).challenge, "challenge");
|
|
11600
|
+
const call = {
|
|
11601
|
+
...this.#bearerCall("POST", AGENT_CONSENT_PASSKEY_PATH, token),
|
|
11602
|
+
json: { challenge },
|
|
11603
|
+
secrets: [token, challenge]
|
|
11604
|
+
};
|
|
11605
|
+
return await this.#object(call);
|
|
11606
|
+
}
|
|
11508
11607
|
// Requests ------------------------------------------------------------------
|
|
11509
11608
|
#url(path) {
|
|
11510
11609
|
return `${this.issuer}/${path}`;
|
|
@@ -11760,6 +11859,7 @@ exports.Questionnaires = Questionnaires;
|
|
|
11760
11859
|
exports.RateLimitError = RateLimitError;
|
|
11761
11860
|
exports.RegulatoryReports = RegulatoryReports;
|
|
11762
11861
|
exports.ReportTemplates = ReportTemplates;
|
|
11862
|
+
exports.Sandbox = Sandbox;
|
|
11763
11863
|
exports.Sessions = Sessions;
|
|
11764
11864
|
exports.SessionsImports = SessionsImports;
|
|
11765
11865
|
exports.SessionsReviews = SessionsReviews;
|