@didit-protocol/sdk-node 2.10.0 → 2.11.1

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 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
@@ -150,7 +150,7 @@ function errorDetail(body) {
150
150
  return null;
151
151
  }
152
152
  function spellings(secret) {
153
- const out = /* @__PURE__ */ new Set([secret]);
153
+ const out = /* @__PURE__ */ new Set([secret, JSON.stringify(secret).slice(1, -1)]);
154
154
  try {
155
155
  out.add(encodeURIComponent(secret));
156
156
  out.add(new URLSearchParams({ s: secret }).toString().slice(2));
@@ -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.10.0";
285
+ var VERSION = "2.11.1";
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,18 @@ 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(value) {
11285
+ if (typeof value === "string") return value.length > 0 ? [value] : [];
11286
+ if (Array.isArray(value)) return value.flatMap(assertionSecrets);
11287
+ if (isRecord4(value)) return Object.values(value).flatMap(assertionSecrets);
11288
+ return [];
11289
+ }
11256
11290
  function optionalText(value, name) {
11257
11291
  if (value === void 0 || value === null) return void 0;
11258
11292
  if (typeof value !== "string") throw new TypeError(`${name} must be a string.`);
@@ -11505,6 +11539,66 @@ var Authentication = class _Authentication {
11505
11539
  const path = `${STEP_UP_PATH}${pathSegment(id, "id")}/`;
11506
11540
  return await this.#object(this.#bearerCall("GET", path, token));
11507
11541
  }
11542
+ /**
11543
+ * Approve or deny an agent's access request (`POST agents/consent/`) with a
11544
+ * token of the signed-in person. Approval returns `{ code, redirect_uri,
11545
+ * state }` (the agent exchanges the single-use code, valid 60 seconds, itself;
11546
+ * no token is returned here); denial returns `{ status: "denied" }`. Tell them
11547
+ * apart with `"code" in result`. A POST: never retried. The `challenge` and
11548
+ * the `assertion` are never logged and are removed from error messages.
11549
+ * Typical failures: 400 `invalid_grant` (unknown or expired request) and 403
11550
+ * `passkey_required` (humans-only application: call
11551
+ * `createAgentApprovalOptions`, run the passkey ceremony, pass the assertion).
11552
+ */
11553
+ async submitAgentConsent(accessToken, params) {
11554
+ const token = bearerToken(accessToken, "accessToken");
11555
+ const given = fieldsOf(params);
11556
+ const challenge = requiredText(given.challenge, "challenge");
11557
+ const decision = requiredText(given.decision, "decision");
11558
+ if (decision !== "approve" && decision !== "deny") {
11559
+ throw new TypeError('decision must be "approve" or "deny".');
11560
+ }
11561
+ const body = { challenge, decision };
11562
+ const secrets = [token, challenge];
11563
+ const assertion = given.assertion;
11564
+ if (assertion !== void 0 && assertion !== null) {
11565
+ if (!isRecord4(assertion)) throw new TypeError("assertion must be an object.");
11566
+ body.assertion = assertion;
11567
+ secrets.push(...assertionSecrets(assertion));
11568
+ }
11569
+ const scopes = given.scopes;
11570
+ if (scopes !== void 0 && scopes !== null) body.scopes = textList(scopes, "scopes");
11571
+ const organizationIds = given.organizationIds;
11572
+ if (organizationIds !== void 0 && organizationIds !== null) {
11573
+ body.organization_ids = textList(organizationIds, "organizationIds");
11574
+ }
11575
+ const lifetime = given.lifetime;
11576
+ if (lifetime !== void 0 && lifetime !== null) {
11577
+ if (typeof lifetime !== "number" || !Number.isInteger(lifetime)) {
11578
+ throw new TypeError("lifetime must be an integer number of seconds.");
11579
+ }
11580
+ body.lifetime = lifetime;
11581
+ }
11582
+ const call = { ...this.#bearerCall("POST", AGENT_CONSENT_PATH, token), json: body, secrets };
11583
+ return await this.#object(call);
11584
+ }
11585
+ /**
11586
+ * Get WebAuthn request options bound to a pending agent request
11587
+ * (`POST agents/consent/passkey/`) with a token of the signed-in person. Pass
11588
+ * `options` to `navigator.credentials.get()` (decode the base64url fields),
11589
+ * then send the result as `assertion` to `submitAgentConsent`. A POST: never
11590
+ * retried; the `challenge` is never logged.
11591
+ */
11592
+ async createAgentApprovalOptions(accessToken, params) {
11593
+ const token = bearerToken(accessToken, "accessToken");
11594
+ const challenge = requiredText(fieldsOf(params).challenge, "challenge");
11595
+ const call = {
11596
+ ...this.#bearerCall("POST", AGENT_CONSENT_PASSKEY_PATH, token),
11597
+ json: { challenge },
11598
+ secrets: [token, challenge]
11599
+ };
11600
+ return await this.#object(call);
11601
+ }
11508
11602
  // Requests ------------------------------------------------------------------
11509
11603
  #url(path) {
11510
11604
  return `${this.issuer}/${path}`;
@@ -11760,6 +11854,7 @@ exports.Questionnaires = Questionnaires;
11760
11854
  exports.RateLimitError = RateLimitError;
11761
11855
  exports.RegulatoryReports = RegulatoryReports;
11762
11856
  exports.ReportTemplates = ReportTemplates;
11857
+ exports.Sandbox = Sandbox;
11763
11858
  exports.Sessions = Sessions;
11764
11859
  exports.SessionsImports = SessionsImports;
11765
11860
  exports.SessionsReviews = SessionsReviews;