@estiva-app/identity 0.2.0 → 0.2.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/CHANGELOG.md +23 -0
- package/README.md +4 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/signer.d.ts +15 -0
- package/dist/signer.d.ts.map +1 -1
- package/dist/signer.js +20 -1
- package/dist/signer.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +2 -1
- package/src/signer.ts +22 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @estiva-app/identity
|
|
2
2
|
|
|
3
|
+
## 0.2.1 — 2026-09-08
|
|
4
|
+
|
|
5
|
+
**Additive.** `SignRefused` is new; nothing that catches `Error` or reads a
|
|
6
|
+
message changes.
|
|
7
|
+
|
|
8
|
+
- **A `/sign` refusal that is not an expiry now throws `SignRefused`, carrying
|
|
9
|
+
the HTTP `status`.** A `401` still throws `SignerTokenExpired`, which is the
|
|
10
|
+
one refusal a new token fixes.
|
|
11
|
+
|
|
12
|
+
The status belongs on the error because **consumers classify on it and a
|
|
13
|
+
message is not an API.** Found while wiring Peek as the third consumer:
|
|
14
|
+
`reasonForSignFailure` maps `/sign` failures into the auth shell's reason
|
|
15
|
+
vocabulary by regexing `POST /sign failed: (\d{3})` out of the message Peek's
|
|
16
|
+
own copy threw. `403` is `identity_inactive` — an administrator has to restore
|
|
17
|
+
the identity — while a `422` policy refusal is not, and neither is a `502`.
|
|
18
|
+
|
|
19
|
+
Swapping in this package's differently worded message would have collapsed
|
|
20
|
+
every one of those into a single reason. **Nothing would have failed**: Peek's
|
|
21
|
+
tests pass literal strings rather than real errors, so the regex kept matching
|
|
22
|
+
in the test suite while matching nothing in production. That is the shape worth
|
|
23
|
+
recording — the test and the code agreed with each other and both stopped
|
|
24
|
+
describing the app.
|
|
25
|
+
|
|
3
26
|
## 0.2.0 — 2026-09-07
|
|
4
27
|
|
|
5
28
|
**MINOR because it adds a peer dependency**, which is a break for a consumer
|
package/README.md
CHANGED
|
@@ -90,7 +90,10 @@ built with. There were three copies of this round trip before SHA-4 and only one
|
|
|
90
90
|
of them checked; the one that did not was Ship's, through which every write in
|
|
91
91
|
Ship passes.
|
|
92
92
|
|
|
93
|
-
A `401` throws `SignerTokenExpired
|
|
93
|
+
A `401` throws `SignerTokenExpired`; any other refusal throws `SignRefused`
|
|
94
|
+
carrying the HTTP `status`, because consumers classify on it and a message is not
|
|
95
|
+
an API — `403` means an administrator has to restore the identity, while a `422`
|
|
96
|
+
policy refusal means something else entirely. And
|
|
94
97
|
`estivaIdSigner` renews **once** and retries. Never twice: a second `401` after
|
|
95
98
|
a successful renewal is a token the service will not accept, and retrying that
|
|
96
99
|
is how one refused signature becomes a hot loop. Anything that is not an expiry
|
package/dist/index.d.ts
CHANGED
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
* The thing that made it possible was not cleverness — it was that a browser API
|
|
47
47
|
* an app must inject is also a browser API a test can observe.
|
|
48
48
|
*/
|
|
49
|
-
export declare const IDENTITY_VERSION = "0.2.
|
|
49
|
+
export declare const IDENTITY_VERSION = "0.2.1";
|
|
50
50
|
export { type KeyValueStore, type ShellPhase, type ShellReason, type ShellState, type BootObservation, type BootAction, type ShellEvent, isRecoverable, SHELL_COPY, CONTINUE_LABEL, RETRY_LABEL, PROBE_TIMEOUT_MS, GUARD_TTL_MS, GUARD_KEY, decideBoot, reasonForCallbackError, readGuard, markGuard, clearGuard, logShellEvent, } from './shell.js';
|
|
51
51
|
export { type EstivaIdConfig, type EstivaIdClient, type StoredToken, type FetchLike, type RenewalHandlers, type RenewalSchedule, SignInError, createEstivaId, } from './client.js';
|
|
52
|
-
export { type SignViaEstivaIdOptions, type EstivaIdSignerOptions, type SignFetchLike, SignerTokenExpired, signViaEstivaId, estivaIdSigner, } from './signer.js';
|
|
52
|
+
export { type SignViaEstivaIdOptions, type EstivaIdSignerOptions, type SignFetchLike, SignerTokenExpired, SignRefused, signViaEstivaId, estivaIdSigner, } from './signer.js';
|
|
53
53
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,eAAO,MAAM,gBAAgB,UAAU,CAAA;AAEvC,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,aAAa,EACb,UAAU,EACV,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,SAAS,EACT,UAAU,EACV,sBAAsB,EACtB,SAAS,EACT,SAAS,EACT,UAAU,EACV,aAAa,GACd,MAAM,YAAY,CAAA;AAEnB,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,WAAW,EACX,cAAc,GACf,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAClB,kBAAkB,EAClB,eAAe,EACf,cAAc,GACf,MAAM,aAAa,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,eAAO,MAAM,gBAAgB,UAAU,CAAA;AAEvC,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,aAAa,EACb,UAAU,EACV,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,SAAS,EACT,UAAU,EACV,sBAAsB,EACtB,SAAS,EACT,SAAS,EACT,UAAU,EACV,aAAa,GACd,MAAM,YAAY,CAAA;AAEnB,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,WAAW,EACX,cAAc,GACf,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAClB,kBAAkB,EAClB,WAAW,EACX,eAAe,EACf,cAAc,GACf,MAAM,aAAa,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
* The thing that made it possible was not cleverness — it was that a browser API
|
|
47
47
|
* an app must inject is also a browser API a test can observe.
|
|
48
48
|
*/
|
|
49
|
-
export const IDENTITY_VERSION = '0.2.
|
|
49
|
+
export const IDENTITY_VERSION = '0.2.1';
|
|
50
50
|
export { isRecoverable, SHELL_COPY, CONTINUE_LABEL, RETRY_LABEL, PROBE_TIMEOUT_MS, GUARD_TTL_MS, GUARD_KEY, decideBoot, reasonForCallbackError, readGuard, markGuard, clearGuard, logShellEvent, } from './shell.js';
|
|
51
51
|
export { SignInError, createEstivaId, } from './client.js';
|
|
52
|
-
export { SignerTokenExpired, signViaEstivaId, estivaIdSigner, } from './signer.js';
|
|
52
|
+
export { SignerTokenExpired, SignRefused, signViaEstivaId, estivaIdSigner, } from './signer.js';
|
|
53
53
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAA;AAEvC,OAAO,EAQL,aAAa,EACb,UAAU,EACV,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,SAAS,EACT,UAAU,EACV,sBAAsB,EACtB,SAAS,EACT,SAAS,EACT,UAAU,EACV,aAAa,GACd,MAAM,YAAY,CAAA;AAEnB,OAAO,EAOL,WAAW,EACX,cAAc,GACf,MAAM,aAAa,CAAA;AAEpB,OAAO,EAIL,kBAAkB,EAClB,eAAe,EACf,cAAc,GACf,MAAM,aAAa,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAA;AAEvC,OAAO,EAQL,aAAa,EACb,UAAU,EACV,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,SAAS,EACT,UAAU,EACV,sBAAsB,EACtB,SAAS,EACT,SAAS,EACT,UAAU,EACV,aAAa,GACd,MAAM,YAAY,CAAA;AAEnB,OAAO,EAOL,WAAW,EACX,cAAc,GACf,MAAM,aAAa,CAAA;AAEpB,OAAO,EAIL,kBAAkB,EAClB,WAAW,EACX,eAAe,EACf,cAAc,GACf,MAAM,aAAa,CAAA"}
|
package/dist/signer.d.ts
CHANGED
|
@@ -67,6 +67,21 @@ export type SignFetchLike = typeof fetch;
|
|
|
67
67
|
export declare class SignerTokenExpired extends Error {
|
|
68
68
|
constructor();
|
|
69
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* A refusal that is not an expiry, **carrying the status that says which**.
|
|
72
|
+
*
|
|
73
|
+
* The status is on the error rather than only in its text because consumers
|
|
74
|
+
* classify on it and a message is not an API. Peek maps `/sign` failures into
|
|
75
|
+
* the auth shell's reason vocabulary — `403` is `identity_inactive`, an
|
|
76
|
+
* administrator's problem, while a `422` policy refusal is not — and it did that
|
|
77
|
+
* by regexing its own thrown string. A package that threw a differently worded
|
|
78
|
+
* message would have quietly collapsed every one of those into the same reason,
|
|
79
|
+
* and Peek's tests pass literal strings, so nothing would have failed.
|
|
80
|
+
*/
|
|
81
|
+
export declare class SignRefused extends Error {
|
|
82
|
+
readonly status: number;
|
|
83
|
+
constructor(status: number, message: string);
|
|
84
|
+
}
|
|
70
85
|
export interface SignViaEstivaIdOptions {
|
|
71
86
|
/** Origin of the identity service, e.g. `https://id.estiva.app`. */
|
|
72
87
|
base: string;
|
package/dist/signer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAE9E;;;;;;;;GAQG;AACH,OAAO,CAAC,MAAM,KAAK,EAAE,CACnB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,KACpE,OAAO,CAAC;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAA;CAAE,CAAC,CAAA;AAEtE,kFAAkF;AAClF,MAAM,MAAM,aAAa,GAAG,OAAO,KAAK,CAAA;AAExC,mEAAmE;AACnE,qBAAa,kBAAmB,SAAQ,KAAK;;CAK5C;AAED,MAAM,WAAW,sBAAsB;IACrC,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAA;IACZ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name = 'SignerTokenExpired';
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* A refusal that is not an expiry, **carrying the status that says which**.
|
|
10
|
+
*
|
|
11
|
+
* The status is on the error rather than only in its text because consumers
|
|
12
|
+
* classify on it and a message is not an API. Peek maps `/sign` failures into
|
|
13
|
+
* the auth shell's reason vocabulary — `403` is `identity_inactive`, an
|
|
14
|
+
* administrator's problem, while a `422` policy refusal is not — and it did that
|
|
15
|
+
* by regexing its own thrown string. A package that threw a differently worded
|
|
16
|
+
* message would have quietly collapsed every one of those into the same reason,
|
|
17
|
+
* and Peek's tests pass literal strings, so nothing would have failed.
|
|
18
|
+
*/
|
|
19
|
+
export class SignRefused extends Error {
|
|
20
|
+
status;
|
|
21
|
+
constructor(status, message) {
|
|
22
|
+
super(message);
|
|
23
|
+
this.status = status;
|
|
24
|
+
this.name = 'SignRefused';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
8
27
|
/**
|
|
9
28
|
* One `POST /sign`.
|
|
10
29
|
*
|
|
@@ -53,7 +72,7 @@ export async function signViaEstivaId(unsigned, options) {
|
|
|
53
72
|
// Keep the raw text. `/sign`'s error bodies are not reliably JSON, and the
|
|
54
73
|
// raw text is more use to a person than "unparseable response".
|
|
55
74
|
}
|
|
56
|
-
throw new
|
|
75
|
+
throw new SignRefused(response.status, `Estiva ID refused to sign kind:${unsigned.kind} — ${reason}`);
|
|
57
76
|
}
|
|
58
77
|
const event = JSON.parse(text).event;
|
|
59
78
|
if (!event)
|
package/dist/signer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer.js","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AA+DA,mEAAmE;AACnE,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C;QACE,KAAK,CAAC,+BAA+B,CAAC,CAAA;QACtC,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAA;IAClC,CAAC;CACF;AAwBD;;;;;;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gBACJ,KAAK,EAAE,IAAI;gBACX,sEAAsE;gBACtE,qEAAqE;gBACrE,kEAAkE;gBAClE,iEAAiE;gBACjE,+DAA+D;gBAC/D,cAAc,EAAE,MAAM;gBACtB,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACjC,CAAC,CAAA;YAEJ,IAAI,CAAC;gBACH,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,CAAA;YAC3B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf;;;;;;;;kBAQE;gBACF,IAAI,CAAC,CAAC,KAAK,YAAY,kBAAkB,CAAC,IAAI,CAAC,KAAK;oBAAE,MAAM,KAAK,CAAA;gBACjE,MAAM,OAAO,GAAG,MAAM,KAAK,EAAE,CAAA;gBAC7B,IAAI,CAAC,OAAO;oBAAE,MAAM,KAAK,CAAA;gBACzB,MAAM,GAAG,OAAO,CAAA;gBAChB,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,CAAA;YAC3B,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@estiva-app/identity",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Estiva ID sign-in: authorization code + PKCE, token storage, silent renewal, sign-out, signing via POST /sign, and the auth-shell state machine. Knows nothing about any app's data layer.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
package/src/index.ts
CHANGED
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
* The thing that made it possible was not cleverness — it was that a browser API
|
|
47
47
|
* an app must inject is also a browser API a test can observe.
|
|
48
48
|
*/
|
|
49
|
-
export const IDENTITY_VERSION = '0.2.
|
|
49
|
+
export const IDENTITY_VERSION = '0.2.1'
|
|
50
50
|
|
|
51
51
|
export {
|
|
52
52
|
type KeyValueStore,
|
|
@@ -87,6 +87,7 @@ export {
|
|
|
87
87
|
type EstivaIdSignerOptions,
|
|
88
88
|
type SignFetchLike,
|
|
89
89
|
SignerTokenExpired,
|
|
90
|
+
SignRefused,
|
|
90
91
|
signViaEstivaId,
|
|
91
92
|
estivaIdSigner,
|
|
92
93
|
} from './signer.js'
|
package/src/signer.ts
CHANGED
|
@@ -69,6 +69,27 @@ export class SignerTokenExpired extends Error {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
/**
|
|
73
|
+
* A refusal that is not an expiry, **carrying the status that says which**.
|
|
74
|
+
*
|
|
75
|
+
* The status is on the error rather than only in its text because consumers
|
|
76
|
+
* classify on it and a message is not an API. Peek maps `/sign` failures into
|
|
77
|
+
* the auth shell's reason vocabulary — `403` is `identity_inactive`, an
|
|
78
|
+
* administrator's problem, while a `422` policy refusal is not — and it did that
|
|
79
|
+
* by regexing its own thrown string. A package that threw a differently worded
|
|
80
|
+
* message would have quietly collapsed every one of those into the same reason,
|
|
81
|
+
* and Peek's tests pass literal strings, so nothing would have failed.
|
|
82
|
+
*/
|
|
83
|
+
export class SignRefused extends Error {
|
|
84
|
+
constructor(
|
|
85
|
+
readonly status: number,
|
|
86
|
+
message: string,
|
|
87
|
+
) {
|
|
88
|
+
super(message)
|
|
89
|
+
this.name = 'SignRefused'
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
72
93
|
export interface SignViaEstivaIdOptions {
|
|
73
94
|
/** Origin of the identity service, e.g. `https://id.estiva.app`. */
|
|
74
95
|
base: string
|
|
@@ -142,7 +163,7 @@ export async function signViaEstivaId(
|
|
|
142
163
|
// Keep the raw text. `/sign`'s error bodies are not reliably JSON, and the
|
|
143
164
|
// raw text is more use to a person than "unparseable response".
|
|
144
165
|
}
|
|
145
|
-
throw new
|
|
166
|
+
throw new SignRefused(response.status, `Estiva ID refused to sign kind:${unsigned.kind} — ${reason}`)
|
|
146
167
|
}
|
|
147
168
|
|
|
148
169
|
const event = (JSON.parse(text) as { event?: SignedEvent }).event
|