@onlyworlds/sdk 4.140.0 → 4.141.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/CHANGELOG.md +6 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.js +9 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,12 @@ earlier history lives in git log only.
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [4.141.0] - 2026-11-10
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `OwSignInError.param`: the field the server named when it refused the code exchange, such as `ai_uses` or `ai_lifetime_minutes` on a 422 for an AI door token asked with `completeSignIn`, so that refusal can be told from any other 422 there.
|
|
13
|
+
|
|
8
14
|
## [4.140.0] - 2026-11-10
|
|
9
15
|
|
|
10
16
|
### Added
|
package/dist/index.d.ts
CHANGED
|
@@ -4369,11 +4369,15 @@ declare class OwSignInError extends Error {
|
|
|
4369
4369
|
readonly status?: number;
|
|
4370
4370
|
/** keel's error code, when its answer carried one. */
|
|
4371
4371
|
readonly code?: string;
|
|
4372
|
+
/** The field the server's answer named, when it named one: `ai_uses` or `ai_lifetime_minutes` on a 422 that
|
|
4373
|
+
* refused the AI door token asked in the exchange (the code is spent either way). */
|
|
4374
|
+
readonly param?: string;
|
|
4372
4375
|
/** Seconds to wait before trying again, from `Retry-After` (on a 429). */
|
|
4373
4376
|
readonly retryAfter?: number;
|
|
4374
4377
|
constructor(reason: OwSignInReason, message: string, opts?: {
|
|
4375
4378
|
status?: number;
|
|
4376
4379
|
code?: string;
|
|
4380
|
+
param?: string;
|
|
4377
4381
|
retryAfter?: number;
|
|
4378
4382
|
});
|
|
4379
4383
|
}
|
|
@@ -5422,7 +5426,9 @@ declare class OwV2Client {
|
|
|
5422
5426
|
* state, on success and on refusal; a return with another state leaves the sign-in pending;
|
|
5423
5427
|
* the SDK keeps no token: the tool does. Refusals are `OwSignInError`: `state_mismatch` (no
|
|
5424
5428
|
* pending sign-in, a different state, or the wrong page; nothing sent), `invalid_grant` (keel's
|
|
5425
|
-
* 400: used, expired, or another client's code), `rate_limited`, `offline`, `failed`.
|
|
5429
|
+
* 400: used, expired, or another client's code), `rate_limited`, `offline`, `failed`. Each carries the server's
|
|
5430
|
+
* `status`, `code` and, when its answer named a field, `param`: a 422 that refused the AI door token asked
|
|
5431
|
+
* here names `ai_uses` or `ai_lifetime_minutes` (the code is spent either way).
|
|
5426
5432
|
*/
|
|
5427
5433
|
completeSignIn(opts: OwSignInComplete): Promise<OwSignInResult>;
|
|
5428
5434
|
/**
|
package/dist/index.js
CHANGED
|
@@ -469,12 +469,13 @@ var OwNetworkError = class extends Error {
|
|
|
469
469
|
};
|
|
470
470
|
var OwSignInError = class extends Error {
|
|
471
471
|
constructor(reason, message, opts = {}) {
|
|
472
|
-
refuseUnknownOptions("OwSignInError", opts, ["status", "code", "retryAfter"]);
|
|
472
|
+
refuseUnknownOptions("OwSignInError", opts, ["status", "code", "param", "retryAfter"]);
|
|
473
473
|
super(message);
|
|
474
474
|
this.name = "OwSignInError";
|
|
475
475
|
this.reason = reason;
|
|
476
476
|
if (opts.status !== void 0) this.status = opts.status;
|
|
477
477
|
if (opts.code !== void 0) this.code = opts.code;
|
|
478
|
+
if (opts.param !== void 0) this.param = opts.param;
|
|
478
479
|
if (opts.retryAfter !== void 0) this.retryAfter = opts.retryAfter;
|
|
479
480
|
}
|
|
480
481
|
};
|
|
@@ -764,16 +765,17 @@ async function completeSignIn(baseUrl, fetchImpl, opts) {
|
|
|
764
765
|
}
|
|
765
766
|
const err = body?.error;
|
|
766
767
|
const errCode = typeof err?.code === "string" ? err.code : void 0;
|
|
768
|
+
const errParam = typeof err?.param === "string" && err.param !== "" ? err.param : void 0;
|
|
767
769
|
const errMessage = typeof err?.message === "string" ? err.message : void 0;
|
|
768
770
|
if (res.status === 429) {
|
|
769
|
-
throw new OwSignInError("rate_limited", errMessage ?? "Too many sign-in attempts. Wait a while, then try again.", { status: 429, code: errCode, retryAfter });
|
|
771
|
+
throw new OwSignInError("rate_limited", errMessage ?? "Too many sign-in attempts. Wait a while, then try again.", { status: 429, code: errCode, param: errParam, retryAfter });
|
|
770
772
|
}
|
|
771
773
|
if (res.status === 400 && errCode === "invalid_grant") {
|
|
772
|
-
throw new OwSignInError("invalid_grant", errMessage ?? "The sign-in code could not be exchanged: it was used, expired, or made for another tool. Start again.", { status: 400, code: errCode });
|
|
774
|
+
throw new OwSignInError("invalid_grant", errMessage ?? "The sign-in code could not be exchanged: it was used, expired, or made for another tool. Start again.", { status: 400, code: errCode, param: errParam });
|
|
773
775
|
}
|
|
774
776
|
const ok = body;
|
|
775
777
|
if (!res.ok || typeof ok?.token !== "string" || ok.token === "" || typeof ok.account?.id !== "string") {
|
|
776
|
-
throw new OwSignInError("failed", errMessage ?? `Signing in did not work (${res.status}).`, { status: res.status, code: errCode });
|
|
778
|
+
throw new OwSignInError("failed", errMessage ?? `Signing in did not work (${res.status}).`, { status: res.status, code: errCode, param: errParam });
|
|
777
779
|
}
|
|
778
780
|
return {
|
|
779
781
|
token: ok.token,
|
|
@@ -2184,7 +2186,9 @@ var OwV2Client = class {
|
|
|
2184
2186
|
* state, on success and on refusal; a return with another state leaves the sign-in pending;
|
|
2185
2187
|
* the SDK keeps no token: the tool does. Refusals are `OwSignInError`: `state_mismatch` (no
|
|
2186
2188
|
* pending sign-in, a different state, or the wrong page; nothing sent), `invalid_grant` (keel's
|
|
2187
|
-
* 400: used, expired, or another client's code), `rate_limited`, `offline`, `failed`.
|
|
2189
|
+
* 400: used, expired, or another client's code), `rate_limited`, `offline`, `failed`. Each carries the server's
|
|
2190
|
+
* `status`, `code` and, when its answer named a field, `param`: a 422 that refused the AI door token asked
|
|
2191
|
+
* here names `ai_uses` or `ai_lifetime_minutes` (the code is spent either way).
|
|
2188
2192
|
*/
|
|
2189
2193
|
async completeSignIn(opts) {
|
|
2190
2194
|
only("completeSignIn", opts, ["clientId", "storage", "url", "aiUses", "aiLifetimeMinutes"]);
|