@andco/protocol 0.0.12 → 0.0.13
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/errors.d.ts +59 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +72 -0
- package/dist/issues.d.ts +4 -3
- package/dist/issues.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/errors.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { GrantedOrganizationSubject } from "./rar/subject.js";
|
|
1
2
|
/**
|
|
2
3
|
* Conditions Andco's own client code detects, in the shape the Andco API already uses for the codes
|
|
3
4
|
* it sends: lower snake_case, no prefix. Both vocabularies end up in the same `error.code` field, so
|
|
@@ -212,6 +213,26 @@ export declare const ANDCO_ERROR_CODES: {
|
|
|
212
213
|
};
|
|
213
214
|
/** One of the conditions {@link ANDCO_ERROR_CODES} names. */
|
|
214
215
|
export type AndcoErrorCode = (typeof ANDCO_ERROR_CODES)[keyof typeof ANDCO_ERROR_CODES];
|
|
216
|
+
/**
|
|
217
|
+
* The codes of the failures the SDK's own credentials throw instead of a token, which stop a call
|
|
218
|
+
* before it goes out:
|
|
219
|
+
*
|
|
220
|
+
* - `session_missing`, `storage_failed`, `browser_required`, `refresh_failed` and
|
|
221
|
+
* `invalid_token_response`, from the credentials of a session.
|
|
222
|
+
* - `ambiguous_grant`, `invalid_grant` and `invalid_response`, which `AndcoService`'s token exchange
|
|
223
|
+
* relays from the Authorization Server (or raises when the issuer answers something unusable).
|
|
224
|
+
* - `invalid_configuration`, from a `Bank` built without credentials.
|
|
225
|
+
*
|
|
226
|
+
* `authorization_required` is one more, thrown as an {@link AndcoAuthorizationRequiredError}. Any
|
|
227
|
+
* other code the Authorization Server relays (its vocabulary is open) and any code a resolver an
|
|
228
|
+
* integrator wrote throws reach the caller as `request_failed` with the error as `cause`.
|
|
229
|
+
*
|
|
230
|
+
* `no_token_for_resource` is not here: the credentials turn it into a call without an
|
|
231
|
+
* `Authorization` header, so the API answers it instead.
|
|
232
|
+
*/
|
|
233
|
+
export declare const ANDCO_CREDENTIALS_ERROR_CODES: readonly ["session_missing", "storage_failed", "browser_required", "refresh_failed", "invalid_token_response", "ambiguous_grant", "invalid_grant", "invalid_response", "invalid_configuration"];
|
|
234
|
+
/** One of the codes {@link ANDCO_CREDENTIALS_ERROR_CODES} lists. */
|
|
235
|
+
export type AndcoCredentialsErrorCode = (typeof ANDCO_CREDENTIALS_ERROR_CODES)[number];
|
|
215
236
|
/**
|
|
216
237
|
* The subset a widget may report to its host page over postMessage.
|
|
217
238
|
*
|
|
@@ -296,6 +317,22 @@ export declare class AndcoError<Code extends string = string> extends Error {
|
|
|
296
317
|
static from(cause: unknown, fallbackCode: AndcoErrorCode): AndcoError;
|
|
297
318
|
/** Whether a value is an `AndcoError`. */
|
|
298
319
|
static is(cause: unknown): cause is AndcoError;
|
|
320
|
+
/**
|
|
321
|
+
* Whether a value is one of the failures the SDK's own credentials throw instead of a token: an
|
|
322
|
+
* `AndcoError` with a code of {@link ANDCO_CREDENTIALS_ERROR_CODES}, or an
|
|
323
|
+
* {@link AndcoAuthorizationRequiredError}. Any other `AndcoError` is not, whatever its code.
|
|
324
|
+
*
|
|
325
|
+
* @example
|
|
326
|
+
* ```ts
|
|
327
|
+
* try {
|
|
328
|
+
* return await credentials.accessTokenFor(resource);
|
|
329
|
+
* } catch (cause) {
|
|
330
|
+
* if (AndcoError.isCredentialsError(cause)) return signOut(cause.code);
|
|
331
|
+
* throw cause;
|
|
332
|
+
* }
|
|
333
|
+
* ```
|
|
334
|
+
*/
|
|
335
|
+
static isCredentialsError(cause: unknown): cause is AndcoCredentialsError;
|
|
299
336
|
/**
|
|
300
337
|
* Whether the Grant or session behind a failure no longer works, so the only way out is for the
|
|
301
338
|
* person to authorize again. It is `true` for:
|
|
@@ -321,4 +358,26 @@ export declare class AndcoError<Code extends string = string> extends Error {
|
|
|
321
358
|
*/
|
|
322
359
|
static isAuthorizationEnded(cause: unknown): boolean;
|
|
323
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* No approved Grant covers a Service's subject and resource. Version one never opens a login flow:
|
|
363
|
+
* a person approves the Grant in Platform.
|
|
364
|
+
*
|
|
365
|
+
* @example
|
|
366
|
+
* ```ts
|
|
367
|
+
* const { error } = await bank.client.http.GET("/accounts");
|
|
368
|
+
* if (error?.code === "authorization_required") console.error(error.subject, error.resource);
|
|
369
|
+
* ```
|
|
370
|
+
*/
|
|
371
|
+
export declare class AndcoAuthorizationRequiredError extends AndcoError<"authorization_required"> {
|
|
372
|
+
readonly subject: GrantedOrganizationSubject;
|
|
373
|
+
readonly resource: string;
|
|
374
|
+
constructor(subject: GrantedOrganizationSubject, resource: string);
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* What the SDK's own credentials throw instead of a token: an `AndcoError` of one of the
|
|
378
|
+
* {@link AndcoCredentialsErrorCode}s, or an {@link AndcoAuthorizationRequiredError}, which carries
|
|
379
|
+
* the subject and the resource. It is part of the error of every operation that sends a request
|
|
380
|
+
* (see `AndcoOperationError` in `@andco/sdk`), so comparing `code` narrows it.
|
|
381
|
+
*/
|
|
382
|
+
export type AndcoCredentialsError = AndcoError<AndcoCredentialsErrorCode> | AndcoAuthorizationRequiredError;
|
|
324
383
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,iBAAiB;IAE5B,uGAAuG;;IAEvG,6EAA6E;;IAE7E,uGAAuG;;IAEvG,6DAA6D;;IAE7D,wFAAwF;;IAMxF,+GAA+G;;IAE/G,wEAAwE;;IAExE,6DAA6D;;IAE7D,0DAA0D;;IAE1D,iEAAiE;;IAEjE,wGAAwG;;IAExG,mEAAmE;;IAEn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AAI,EACV,OAAO,GAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;KAAO;IASnH,uEAAuE;WACzD,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,GAAG,UAAU;IAM5E,0CAA0C;WAC5B,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU;IAIrD;;;;;;;;;;;;;;OAcG;WACW,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,qBAAqB;IAMhF;;;;;;;;;;;;;;;;;;;;;;OAsBG;WACW,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;CAkB5D;AAED;;;;;;;;;GASG;AACH,qBAAa,+BAAgC,SAAQ,UAAU,CAAC,wBAAwB,CAAC;aAErE,OAAO,EAAE,0BAA0B;aACnC,QAAQ,EAAE,MAAM;gBADhB,OAAO,EAAE,0BAA0B,EACnC,QAAQ,EAAE,MAAM;CAOnC;AAED;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAAG,UAAU,CAAC,yBAAyB,CAAC,GAAG,+BAA+B,CAAC"}
|
package/dist/errors.js
CHANGED
|
@@ -218,6 +218,34 @@ export const ANDCO_ERROR_CODES = {
|
|
|
218
218
|
/** A failure the SDK could not attribute to any condition above. Its cause carries what is known. */
|
|
219
219
|
UNKNOWN_ERROR: "unknown_error",
|
|
220
220
|
};
|
|
221
|
+
/**
|
|
222
|
+
* The codes of the failures the SDK's own credentials throw instead of a token, which stop a call
|
|
223
|
+
* before it goes out:
|
|
224
|
+
*
|
|
225
|
+
* - `session_missing`, `storage_failed`, `browser_required`, `refresh_failed` and
|
|
226
|
+
* `invalid_token_response`, from the credentials of a session.
|
|
227
|
+
* - `ambiguous_grant`, `invalid_grant` and `invalid_response`, which `AndcoService`'s token exchange
|
|
228
|
+
* relays from the Authorization Server (or raises when the issuer answers something unusable).
|
|
229
|
+
* - `invalid_configuration`, from a `Bank` built without credentials.
|
|
230
|
+
*
|
|
231
|
+
* `authorization_required` is one more, thrown as an {@link AndcoAuthorizationRequiredError}. Any
|
|
232
|
+
* other code the Authorization Server relays (its vocabulary is open) and any code a resolver an
|
|
233
|
+
* integrator wrote throws reach the caller as `request_failed` with the error as `cause`.
|
|
234
|
+
*
|
|
235
|
+
* `no_token_for_resource` is not here: the credentials turn it into a call without an
|
|
236
|
+
* `Authorization` header, so the API answers it instead.
|
|
237
|
+
*/
|
|
238
|
+
export const ANDCO_CREDENTIALS_ERROR_CODES = [
|
|
239
|
+
ANDCO_ERROR_CODES.SESSION_MISSING,
|
|
240
|
+
ANDCO_ERROR_CODES.STORAGE_FAILED,
|
|
241
|
+
ANDCO_ERROR_CODES.BROWSER_REQUIRED,
|
|
242
|
+
ANDCO_ERROR_CODES.REFRESH_FAILED,
|
|
243
|
+
ANDCO_ERROR_CODES.INVALID_TOKEN_RESPONSE,
|
|
244
|
+
"ambiguous_grant",
|
|
245
|
+
"invalid_grant",
|
|
246
|
+
ANDCO_ERROR_CODES.INVALID_RESPONSE,
|
|
247
|
+
ANDCO_ERROR_CODES.INVALID_CONFIGURATION,
|
|
248
|
+
];
|
|
221
249
|
/**
|
|
222
250
|
* The subset a widget may report to its host page over postMessage.
|
|
223
251
|
*
|
|
@@ -344,6 +372,28 @@ export class AndcoError extends Error {
|
|
|
344
372
|
static is(cause) {
|
|
345
373
|
return cause instanceof AndcoError;
|
|
346
374
|
}
|
|
375
|
+
/**
|
|
376
|
+
* Whether a value is one of the failures the SDK's own credentials throw instead of a token: an
|
|
377
|
+
* `AndcoError` with a code of {@link ANDCO_CREDENTIALS_ERROR_CODES}, or an
|
|
378
|
+
* {@link AndcoAuthorizationRequiredError}. Any other `AndcoError` is not, whatever its code.
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
* ```ts
|
|
382
|
+
* try {
|
|
383
|
+
* return await credentials.accessTokenFor(resource);
|
|
384
|
+
* } catch (cause) {
|
|
385
|
+
* if (AndcoError.isCredentialsError(cause)) return signOut(cause.code);
|
|
386
|
+
* throw cause;
|
|
387
|
+
* }
|
|
388
|
+
* ```
|
|
389
|
+
*/
|
|
390
|
+
static isCredentialsError(cause) {
|
|
391
|
+
if (cause instanceof AndcoAuthorizationRequiredError)
|
|
392
|
+
return true;
|
|
393
|
+
if (!AndcoError.is(cause))
|
|
394
|
+
return false;
|
|
395
|
+
return ANDCO_CREDENTIALS_ERROR_CODES.includes(cause.code);
|
|
396
|
+
}
|
|
347
397
|
/**
|
|
348
398
|
* Whether the Grant or session behind a failure no longer works, so the only way out is for the
|
|
349
399
|
* person to authorize again. It is `true` for:
|
|
@@ -388,3 +438,25 @@ export class AndcoError extends Error {
|
|
|
388
438
|
}
|
|
389
439
|
}
|
|
390
440
|
}
|
|
441
|
+
/**
|
|
442
|
+
* No approved Grant covers a Service's subject and resource. Version one never opens a login flow:
|
|
443
|
+
* a person approves the Grant in Platform.
|
|
444
|
+
*
|
|
445
|
+
* @example
|
|
446
|
+
* ```ts
|
|
447
|
+
* const { error } = await bank.client.http.GET("/accounts");
|
|
448
|
+
* if (error?.code === "authorization_required") console.error(error.subject, error.resource);
|
|
449
|
+
* ```
|
|
450
|
+
*/
|
|
451
|
+
export class AndcoAuthorizationRequiredError extends AndcoError {
|
|
452
|
+
subject;
|
|
453
|
+
resource;
|
|
454
|
+
constructor(subject, resource) {
|
|
455
|
+
super("authorization_required", {
|
|
456
|
+
message: "No approved Grant covers this subject and resource; approve one in Platform",
|
|
457
|
+
details: { subject, resource },
|
|
458
|
+
});
|
|
459
|
+
this.subject = subject;
|
|
460
|
+
this.resource = resource;
|
|
461
|
+
}
|
|
462
|
+
}
|
package/dist/issues.d.ts
CHANGED
|
@@ -3,8 +3,9 @@ import * as v from "valibot";
|
|
|
3
3
|
* One problem with an input, with no words in it: `type` is its public code, a Valibot issue type
|
|
4
4
|
* (`max_length`, `regex`, `strict_object`, ...) when the shape is wrong, or the code of a rule
|
|
5
5
|
* (`note_too_long`) when the shape is right and a rule refuses it. `path` lists the keys that lead
|
|
6
|
-
* to the value, and is `undefined` when the input as a whole is the problem
|
|
7
|
-
*
|
|
6
|
+
* to the value, and is absent or `undefined` when the input as a whole is the problem, as in a
|
|
7
|
+
* Valibot issue, which is assignable to this type as it is. `requirement` is what was expected, when
|
|
8
|
+
* there is one to say: `140` for a note that is too long.
|
|
8
9
|
*
|
|
9
10
|
* A screen chooses its own words from `type`, so the same issue reads right in any language.
|
|
10
11
|
*
|
|
@@ -14,7 +15,7 @@ import * as v from "valibot";
|
|
|
14
15
|
*/
|
|
15
16
|
export type Issue = {
|
|
16
17
|
readonly type: string;
|
|
17
|
-
readonly path
|
|
18
|
+
readonly path?: readonly {
|
|
18
19
|
readonly key: unknown;
|
|
19
20
|
}[] | undefined;
|
|
20
21
|
readonly requirement?: unknown;
|
package/dist/issues.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issues.d.ts","sourceRoot":"","sources":["../src/issues.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B
|
|
1
|
+
{"version":3,"file":"issues.d.ts","sourceRoot":"","sources":["../src/issues.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,KAAK,GAAG;IAClB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS;QAAE,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAA;KAAE,EAAE,GAAG,SAAS,CAAC;IACjE,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAEF;;;GAGG;AACH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