@idp.global/interfaces 30.4.0 → 30.5.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 +21 -0
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/data/loginsession.d.ts +16 -0
- package/dist_ts/data/loginsession.js +15 -1
- package/dist_ts/data/upstreamidentity.d.ts +23 -7
- package/dist_ts/data/upstreamidentity.js +9 -1
- package/dist_ts/dto/upstreamidentity.d.ts +1 -1
- package/dist_ts/request/upstreamidentity.d.ts +74 -36
- package/package.json +1 -1
- package/readme.md +52 -21
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/data/loginsession.ts +22 -0
- package/ts/data/upstreamidentity.ts +25 -7
- package/ts/dto/upstreamidentity.ts +1 -1
- package/ts/readme.md +2 -1
- package/ts/request/upstreamidentity.ts +78 -36
package/changelog.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2026-11-13 - 30.5.0
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- the purpose of an upstream flow and the authentication-change gate's refusal data (data, request; AGL-1801)
|
|
8
|
+
- `upstreamSignInPurposes` (`sign-in`, `link`) and `TUpstreamSignInPurpose`. `IReq_StartUpstreamSignIn` takes
|
|
9
|
+
`TStartUpstreamSignInRequest`: a start without `purpose` is a sign-in, and a link start that carries
|
|
10
|
+
`oidcTransactionId` does not compile. Callers written against 30.4.0 compile unchanged.
|
|
11
|
+
- The link flow replaces the account-page link path 30.4.0 described (start, provider round trip, confirm without
|
|
12
|
+
finish); a confirm on a flow that was not finished now fails. The account page sends the person to
|
|
13
|
+
`<login>/login?link=<provider>`, the provider returns to `<login>/login?upstream=<id>`, and
|
|
14
|
+
`finishUpstreamSignIn` on a link flow never mints a session, never creates an account and looks up no account
|
|
15
|
+
and no link. `confirmUpstreamIdentityLink` accepts only a flow whose finish answered `linkRequired`, after a
|
|
16
|
+
new sign-in and an explicit confirmation; a refused confirm leaves the flow open.
|
|
17
|
+
- The provider's email is always vouched for: `linkRequired` and every link carry an email the provider's signed
|
|
18
|
+
token marks as verified. Both flows refuse `provider_email_unverified` otherwise; a finish refused with a code
|
|
19
|
+
ends the flow, and only a wrong verifier leaves it usable.
|
|
20
|
+
- `authenticationChangeRefusalCodes` (`fresh_passkey_sign_in_required`, `fresh_sign_in_required`),
|
|
21
|
+
`TAuthenticationChangeRefusalCode` and `IAuthenticationChangeRefusal`: the `errorData` of a request the
|
|
22
|
+
authentication-change gate refuses when a new sign-in would satisfy it.
|
|
23
|
+
|
|
3
24
|
## 2026-11-13 - 30.4.0
|
|
4
25
|
|
|
5
26
|
### Features
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@idp.global/interfaces',
|
|
6
|
-
version: '30.
|
|
6
|
+
version: '30.5.0',
|
|
7
7
|
description: 'Shared TypeScript interfaces and TypedRequest contracts for the idp.global ecosystem.'
|
|
8
8
|
};
|
|
9
9
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSx3QkFBd0I7SUFDOUIsT0FBTyxFQUFFLFFBQVE7SUFDakIsV0FBVyxFQUFFLHVGQUF1RjtDQUNyRyxDQUFBIn0=
|
|
@@ -8,6 +8,22 @@ export interface ILoginSessionAuthenticationEvidence {
|
|
|
8
8
|
mfaFactor: TLoginSessionMfaFactor | null;
|
|
9
9
|
mfaAuthenticatedAt: number | null;
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Why the authentication-change gate refused a request. The gate guards every change to how
|
|
13
|
+
* an account signs in and judges the session's authentication evidence. Wherever a new sign-in
|
|
14
|
+
* would satisfy it, a refused request throws a `TypedResponseError` whose `errorData` is
|
|
15
|
+
* `IAuthenticationChangeRefusal`; a refusal that no new sign-in can satisfy carries no code.
|
|
16
|
+
* The proof is always a new sign-in on the login origin: there is no in-session step-up
|
|
17
|
+
* request. The list is closed.
|
|
18
|
+
* - `fresh_passkey_sign_in_required`: sign in again with a passkey, then retry;
|
|
19
|
+
* - `fresh_sign_in_required`: sign in again, then retry.
|
|
20
|
+
*/
|
|
21
|
+
export declare const authenticationChangeRefusalCodes: readonly ['fresh_passkey_sign_in_required', 'fresh_sign_in_required'];
|
|
22
|
+
export type TAuthenticationChangeRefusalCode = (typeof authenticationChangeRefusalCodes)[number];
|
|
23
|
+
/** The `errorData` of a request the authentication-change gate refused. */
|
|
24
|
+
export interface IAuthenticationChangeRefusal {
|
|
25
|
+
code: TAuthenticationChangeRefusalCode;
|
|
26
|
+
}
|
|
11
27
|
export interface ILoginSession {
|
|
12
28
|
id: string;
|
|
13
29
|
data: {
|
|
@@ -7,4 +7,18 @@ export const loginSessionPrimaryAuthenticationMethods = [
|
|
|
7
7
|
'saml',
|
|
8
8
|
...upstreamIdentityProviders,
|
|
9
9
|
];
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Why the authentication-change gate refused a request. The gate guards every change to how
|
|
12
|
+
* an account signs in and judges the session's authentication evidence. Wherever a new sign-in
|
|
13
|
+
* would satisfy it, a refused request throws a `TypedResponseError` whose `errorData` is
|
|
14
|
+
* `IAuthenticationChangeRefusal`; a refusal that no new sign-in can satisfy carries no code.
|
|
15
|
+
* The proof is always a new sign-in on the login origin: there is no in-session step-up
|
|
16
|
+
* request. The list is closed.
|
|
17
|
+
* - `fresh_passkey_sign_in_required`: sign in again with a passkey, then retry;
|
|
18
|
+
* - `fresh_sign_in_required`: sign in again, then retry.
|
|
19
|
+
*/
|
|
20
|
+
export const authenticationChangeRefusalCodes = [
|
|
21
|
+
'fresh_passkey_sign_in_required',
|
|
22
|
+
'fresh_sign_in_required',
|
|
23
|
+
];
|
|
24
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9naW5zZXNzaW9uLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vdHMvZGF0YS9sb2dpbnNlc3Npb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLHlCQUF5QixFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFFbEUscUZBQXFGO0FBQ3JGLE1BQU0sQ0FBQyxNQUFNLHdDQUF3QyxHQUFHO0lBQ3RELFlBQVk7SUFDWixTQUFTO0lBQ1QsVUFBVTtJQUNWLE1BQU07SUFDTixHQUFHLHlCQUF5QjtDQUNwQixDQUFDO0FBY1g7Ozs7Ozs7OztHQVNHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sZ0NBQWdDLEdBQUc7SUFDOUMsZ0NBQWdDO0lBQ2hDLHdCQUF3QjtDQUNoQixDQUFDIn0=
|
|
@@ -5,15 +5,31 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export declare const upstreamIdentityProviders: readonly ['apple', 'google'];
|
|
7
7
|
export type TUpstreamIdentityProvider = (typeof upstreamIdentityProviders)[number];
|
|
8
|
+
/**
|
|
9
|
+
* What an upstream flow is for. The server records it on the flow at start and never changes
|
|
10
|
+
* it, so a sign-in flow that answered `linkRequired` stays a sign-in flow. The list is closed.
|
|
11
|
+
* - `sign-in`: sign in to idp.global, or create an account, with the provider identity;
|
|
12
|
+
* - `link`: link the provider identity to an existing account. A link flow never mints a
|
|
13
|
+
* session and never creates an account.
|
|
14
|
+
*/
|
|
15
|
+
export declare const upstreamSignInPurposes: readonly ['sign-in', 'link'];
|
|
16
|
+
export type TUpstreamSignInPurpose = (typeof upstreamSignInPurposes)[number];
|
|
8
17
|
/**
|
|
9
18
|
* Why an upstream sign-in, link or unlink was refused. A refused request throws a
|
|
10
|
-
* `TypedResponseError` whose `errorData` is `IUpstreamIdentityRefusal
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* - `
|
|
15
|
-
*
|
|
16
|
-
*
|
|
19
|
+
* `TypedResponseError` whose `errorData` is `IUpstreamIdentityRefusal`. The authentication-change
|
|
20
|
+
* gate refuses with its own `IAuthenticationChangeRefusal`, whose codes differ from these; any
|
|
21
|
+
* other failure (an expired or spent flow, a wrong verifier, an unavailable provider) carries
|
|
22
|
+
* no code.
|
|
23
|
+
* - `sso_domain_required`: the email of the account concerned is under a verified SSO domain;
|
|
24
|
+
* sign in through its organization's single sign-on. At finish on a sign-in flow that is the
|
|
25
|
+
* vouched email of an identity not linked yet, or the account's email for a linked identity;
|
|
26
|
+
* at `confirmUpstreamIdentityLink` it is the signed-in account's email. The provider's email
|
|
27
|
+
* on a link flow is not judged;
|
|
28
|
+
* - `provider_email_unverified`: the provider did not vouch for an email: the signed token
|
|
29
|
+
* carries none, or does not say it is verified. A sign-in flow answers it for an identity
|
|
30
|
+
* that is not linked yet, before any account lookup; a link flow answers it for every
|
|
31
|
+
* identity, before any lookup. It never tells whether an account or a link exists; nothing
|
|
32
|
+
* is created or linked, and the flow is ended;
|
|
17
33
|
* - `upstream_identity_linked_elsewhere`: this provider identity is linked to another account;
|
|
18
34
|
* - `provider_already_linked`: the account already has a link to this provider;
|
|
19
35
|
* - `last_sign_in_method`: after the unlink the account would have no password, no active
|
|
@@ -4,4 +4,12 @@
|
|
|
4
4
|
* challenge, the email verification method and the activity vocabulary derive from it.
|
|
5
5
|
*/
|
|
6
6
|
export const upstreamIdentityProviders = ['apple', 'google'];
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* What an upstream flow is for. The server records it on the flow at start and never changes
|
|
9
|
+
* it, so a sign-in flow that answered `linkRequired` stays a sign-in flow. The list is closed.
|
|
10
|
+
* - `sign-in`: sign in to idp.global, or create an account, with the provider identity;
|
|
11
|
+
* - `link`: link the provider identity to an existing account. A link flow never mints a
|
|
12
|
+
* session and never creates an account.
|
|
13
|
+
*/
|
|
14
|
+
export const upstreamSignInPurposes = ['sign-in', 'link'];
|
|
15
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXBzdHJlYW1pZGVudGl0eS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3RzL2RhdGEvdXBzdHJlYW1pZGVudGl0eS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7OztHQUlHO0FBQ0gsTUFBTSxDQUFDLE1BQU0seUJBQXlCLEdBQUcsQ0FBQyxPQUFPLEVBQUUsUUFBUSxDQUFVLENBQUM7QUFJdEU7Ozs7OztHQU1HO0FBQ0gsTUFBTSxDQUFDLE1BQU0sc0JBQXNCLEdBQUcsQ0FBQyxTQUFTLEVBQUUsTUFBTSxDQUFVLENBQUMifQ==
|
|
@@ -8,7 +8,7 @@ export interface IUpstreamIdentityDto {
|
|
|
8
8
|
provider: TUpstreamIdentityProvider;
|
|
9
9
|
/** epoch ms when the link was made */
|
|
10
10
|
linkedAt: number;
|
|
11
|
-
/** The email the provider
|
|
11
|
+
/** The email the provider vouched for when the link was made; later provider emails never replace it. */
|
|
12
12
|
email: string;
|
|
13
13
|
/** The provider signed that `email` is a private relay address (Apple's `is_private_email`). */
|
|
14
14
|
isPrivateEmail: boolean;
|
|
@@ -3,24 +3,39 @@ import * as data from '../data/index.js';
|
|
|
3
3
|
import * as dto from '../dto/index.js';
|
|
4
4
|
import type { IReq_LoginWithEmailOrUsernameAndPassword } from './login.js';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
* The fields of `startUpstreamSignIn`. `purpose` defaults to `sign-in`; only a sign-in flow
|
|
7
|
+
* may carry an OIDC authorization transaction.
|
|
8
|
+
*/
|
|
9
|
+
export type TStartUpstreamSignInRequest = {
|
|
10
|
+
provider: data.TUpstreamIdentityProvider;
|
|
11
|
+
/** base64url(SHA-256(verifier)) of the verifier the login page keeps */
|
|
12
|
+
verifierChallenge: string;
|
|
13
|
+
} & ({
|
|
14
|
+
purpose?: Extract<data.TUpstreamSignInPurpose, 'sign-in'>;
|
|
15
|
+
/**
|
|
16
|
+
* Optional opaque OIDC authorization transaction to resume through the existing
|
|
17
|
+
* prepare/complete requests once the sign-in is complete.
|
|
18
|
+
*/
|
|
19
|
+
oidcTransactionId?: string;
|
|
20
|
+
} | {
|
|
21
|
+
purpose: Extract<data.TUpstreamSignInPurpose, 'link'>;
|
|
22
|
+
oidcTransactionId?: never;
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Public: starts an upstream flow; no session is needed. The login page makes a random
|
|
26
|
+
* verifier, sends only its S256 hash here and keeps the verifier in the login origin's
|
|
27
|
+
* sessionStorage under the answered `id`. The server records the flow and its purpose for ten
|
|
28
|
+
* minutes; the purpose never changes. `id` names that record and is the OAuth `state` inside
|
|
29
|
+
* `authorizationUrl`. The provider returns to the issuer's callback, which always redirects the
|
|
30
|
+
* browser to `<login>/login?upstream=<id>` (plus `&tx=<oidcTransactionId>` when one was given).
|
|
31
|
+
*
|
|
32
|
+
* A sign-in flow starts on the login page, optionally with an OIDC authorization transaction.
|
|
33
|
+
* A link flow starts when the account UI's "Link" navigates to `<login>/login?link=<provider>`;
|
|
34
|
+
* that page starts it with `purpose: 'link'` and goes to the provider.
|
|
11
35
|
*/
|
|
12
36
|
export interface IReq_StartUpstreamSignIn extends plugins.typedRequestInterfaces.implementsTR<plugins.typedRequestInterfaces.ITypedRequest, IReq_StartUpstreamSignIn> {
|
|
13
37
|
method: 'startUpstreamSignIn';
|
|
14
|
-
request:
|
|
15
|
-
provider: data.TUpstreamIdentityProvider;
|
|
16
|
-
/** base64url(SHA-256(verifier)) of the verifier the browser keeps */
|
|
17
|
-
verifierChallenge: string;
|
|
18
|
-
/**
|
|
19
|
-
* Optional opaque OIDC authorization transaction to resume through the existing
|
|
20
|
-
* prepare/complete requests once the sign-in is complete.
|
|
21
|
-
*/
|
|
22
|
-
oidcTransactionId?: string;
|
|
23
|
-
};
|
|
38
|
+
request: TStartUpstreamSignInRequest;
|
|
24
39
|
response: {
|
|
25
40
|
id: string;
|
|
26
41
|
/** The provider's authorization URL; the browser navigates to it. */
|
|
@@ -28,24 +43,37 @@ export interface IReq_StartUpstreamSignIn extends plugins.typedRequestInterfaces
|
|
|
28
43
|
};
|
|
29
44
|
}
|
|
30
45
|
/**
|
|
31
|
-
* The provider identity
|
|
32
|
-
*
|
|
46
|
+
* The returned provider identity can be linked to an existing account. `finishUpstreamSignIn`
|
|
47
|
+
* answers it in two situations:
|
|
48
|
+
* - on a sign-in flow, when the provider identity is not linked and the email the provider
|
|
49
|
+
* vouched for names an existing account. A sign-in flow never answers it for an email the
|
|
50
|
+
* provider did not vouch for;
|
|
51
|
+
* - on a link flow, for every identity whose email the provider vouched for, without any
|
|
52
|
+
* account or link lookup.
|
|
53
|
+
*
|
|
54
|
+
* It mints nothing. The flow stays open until its ten-minute expiry for
|
|
55
|
+
* `confirmUpstreamIdentityLink`.
|
|
33
56
|
*/
|
|
34
57
|
export interface IUpstreamSignInLinkRequired {
|
|
35
58
|
provider: data.TUpstreamIdentityProvider;
|
|
36
|
-
/** The email the provider
|
|
59
|
+
/** The email the provider vouched for; the confirmation screen names it. */
|
|
37
60
|
email: string;
|
|
38
61
|
}
|
|
39
62
|
/**
|
|
40
|
-
* Public: finishes an upstream
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
63
|
+
* Public: finishes an upstream flow after the provider returned. The page at
|
|
64
|
+
* `<login>/login?upstream=<id>` calls it when it holds a verifier for that `id`, and calls
|
|
65
|
+
* nothing otherwise; it never needs to know the flow's purpose. It answers once per flow.
|
|
66
|
+
*
|
|
67
|
+
* On a sign-in flow it answers like password sign-in: a refresh token, or an MFA challenge to
|
|
68
|
+
* answer through `verifyMfaChallenge` or the passkey MFA requests. Either answer ends the flow.
|
|
69
|
+
* `linkRequired` is the third outcome. Refusal codes (`data.IUpstreamIdentityRefusal`), in
|
|
70
|
+
* this order: `provider_email_unverified`, then `sso_domain_required`. A refusal with a code
|
|
71
|
+
* ends the flow; only a wrong verifier leaves the flow usable.
|
|
72
|
+
*
|
|
73
|
+
* On a link flow it never mints a session, never creates an account and looks up no account
|
|
74
|
+
* and no link: it answers `linkRequired` when the provider vouched for the email, whatever
|
|
75
|
+
* identity the provider returned. Refusal code: `provider_email_unverified`. A refusal with a
|
|
76
|
+
* code ends the flow.
|
|
49
77
|
*/
|
|
50
78
|
export interface IReq_FinishUpstreamSignIn extends plugins.typedRequestInterfaces.implementsTR<plugins.typedRequestInterfaces.ITypedRequest, IReq_FinishUpstreamSignIn> {
|
|
51
79
|
method: 'finishUpstreamSignIn';
|
|
@@ -59,15 +87,24 @@ export interface IReq_FinishUpstreamSignIn extends plugins.typedRequestInterface
|
|
|
59
87
|
};
|
|
60
88
|
}
|
|
61
89
|
/**
|
|
62
|
-
* Links the
|
|
63
|
-
*
|
|
64
|
-
*
|
|
90
|
+
* Links the provider identity of a flow whose `finishUpstreamSignIn` answered `linkRequired`;
|
|
91
|
+
* any other flow fails without a code. The link stores the provider's vouched email and
|
|
92
|
+
* private-relay flag as the flow recorded them. It links to the signed-in account and carries
|
|
93
|
+
* the flow's `id` and `verifier`. One confirmation screen on the login origin serves sign-in
|
|
94
|
+
* and link flows alike. It always asks for a new sign-in to the account, whatever session the
|
|
95
|
+
* browser holds, then names the provider, the provider's email and the signed-in account; only
|
|
96
|
+
* the person's explicit confirmation sends this request, never a URL on its own.
|
|
97
|
+
*
|
|
98
|
+
* An authentication change: it needs the account's strongest enrolled proof, fresh (a fresh
|
|
99
|
+
* passkey sign-in while the account has an active passkey, otherwise a fresh primary sign-in);
|
|
100
|
+
* an administrator-recovery session does not count. The gate is checked at entry and again
|
|
101
|
+
* when the link is written, and can refuse with `data.IAuthenticationChangeRefusal`.
|
|
65
102
|
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* `
|
|
103
|
+
* A refused confirm, the gate's refusal included, leaves the flow open until its ten-minute
|
|
104
|
+
* expiry; only the link write spends it.
|
|
105
|
+
* Refusal codes (`data.IUpstreamIdentityRefusal`): `sso_domain_required` (the signed-in
|
|
106
|
+
* account's email), `provider_already_linked`, `upstream_identity_linked_elsewhere`. Never
|
|
107
|
+
* `provider_email_unverified`: no flow reaches this request without a vouched email.
|
|
71
108
|
*/
|
|
72
109
|
export interface IReq_ConfirmUpstreamIdentityLink extends plugins.typedRequestInterfaces.implementsTR<plugins.typedRequestInterfaces.ITypedRequest, IReq_ConfirmUpstreamIdentityLink> {
|
|
73
110
|
method: 'confirmUpstreamIdentityLink';
|
|
@@ -94,7 +131,8 @@ export interface IReq_GetUpstreamIdentities extends plugins.typedRequestInterfac
|
|
|
94
131
|
}
|
|
95
132
|
/**
|
|
96
133
|
* Removes the signed-in account's link to a provider. An authentication change, gated like
|
|
97
|
-
* `confirmUpstreamIdentityLink
|
|
134
|
+
* `confirmUpstreamIdentityLink`; the gate can refuse with `data.IAuthenticationChangeRefusal`.
|
|
135
|
+
* Refusal code (`data.IUpstreamIdentityRefusal`): `last_sign_in_method`.
|
|
98
136
|
*/
|
|
99
137
|
export interface IReq_UnlinkUpstreamIdentity extends plugins.typedRequestInterfaces.implementsTR<plugins.typedRequestInterfaces.ITypedRequest, IReq_UnlinkUpstreamIdentity> {
|
|
100
138
|
method: 'unlinkUpstreamIdentity';
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -213,29 +213,60 @@ itself. The hint never skips a step of the sign-in, and a value that names no
|
|
|
213
213
|
offered provider is ignored.
|
|
214
214
|
|
|
215
215
|
Upstream sign-in (Apple, Google) binds the redirect flow to the browser that
|
|
216
|
-
started it
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
`
|
|
229
|
-
|
|
230
|
-
|
|
216
|
+
started it, and everything runs on the login origin. `IReq_StartUpstreamSignIn`
|
|
217
|
+
takes the provider, the S256 hash of a verifier the login page keeps in its
|
|
218
|
+
sessionStorage, and a `purpose` (`data.upstreamSignInPurposes`: `sign-in`, the
|
|
219
|
+
default, or `link`); only a sign-in flow may carry the opaque OIDC transaction,
|
|
220
|
+
and `link` with `oidcTransactionId` does not compile
|
|
221
|
+
(`request.TStartUpstreamSignInRequest`). It needs no session and returns the
|
|
222
|
+
flow `id` (the OAuth `state`) and the provider's authorization URL. The server
|
|
223
|
+
records the purpose on the flow and never changes it, so a sign-in flow that
|
|
224
|
+
answered `linkRequired` stays a sign-in flow. The account UI's "Link"
|
|
225
|
+
navigates to `<login>/login?link=<provider>`, which starts a link flow. The
|
|
226
|
+
provider's callback always returns to `<login>/login?upstream=<id>` (plus `tx`
|
|
227
|
+
when one was given); that page sends `IReq_FinishUpstreamSignIn` with
|
|
228
|
+
`{ id, verifier }` once when it holds a verifier for the id, and nothing
|
|
229
|
+
otherwise. On a sign-in flow finish answers like password sign-in (a refresh
|
|
230
|
+
token or an MFA challenge, which end the flow), or with `linkRequired`
|
|
231
|
+
(provider and vouched email) when the email the provider vouched for names an
|
|
232
|
+
existing account that is not linked yet. On a link flow it never mints a
|
|
233
|
+
session, never creates an account and looks up no account and no link: it
|
|
234
|
+
answers `linkRequired` when the provider vouched for the email, whatever
|
|
235
|
+
identity the provider returned. The provider vouched for an email when its
|
|
236
|
+
signed token carries one and says it is verified; otherwise finish refuses with
|
|
237
|
+
`provider_email_unverified`, on a sign-in flow for an identity that is not
|
|
238
|
+
linked yet, before any account lookup, and on a link flow for every identity,
|
|
239
|
+
before any lookup. On a sign-in flow `sso_domain_required` follows; it judges
|
|
240
|
+
the vouched email of an identity not linked yet, or the account's email for a
|
|
241
|
+
linked identity. A finish refused with a code ends the flow; only a wrong
|
|
242
|
+
verifier leaves it usable. `linkRequired` mints nothing and leaves the flow
|
|
243
|
+
open until its ten-minute expiry for `IReq_ConfirmUpstreamIdentityLink` with
|
|
244
|
+
the same `id` and verifier, which the person sends after a new sign-in to the
|
|
245
|
+
account on the login origin and an explicit confirmation. Confirm accepts only
|
|
246
|
+
a flow whose finish answered `linkRequired` (any other flow fails without a
|
|
247
|
+
code) and stores the provider's vouched email and private-relay flag as the
|
|
248
|
+
flow recorded them. It refuses with `sso_domain_required` (judging the
|
|
249
|
+
signed-in account's email), `provider_already_linked` or
|
|
250
|
+
`upstream_identity_linked_elsewhere`, never with `provider_email_unverified`;
|
|
251
|
+
the provider's email on a link flow is never judged for SSO. A refused confirm
|
|
252
|
+
leaves the flow open, and only the link write spends it.
|
|
253
|
+
`IReq_GetUpstreamIdentities` lists the account's links as
|
|
231
254
|
`dto.IUpstreamIdentityDto` (provider, link time, the email at link time, and the
|
|
232
255
|
private-relay flag; never the provider subject or a provider token), and
|
|
233
|
-
`IReq_UnlinkUpstreamIdentity` removes the link to one provider.
|
|
234
|
-
|
|
235
|
-
`
|
|
236
|
-
|
|
237
|
-
`
|
|
238
|
-
|
|
256
|
+
`IReq_UnlinkUpstreamIdentity` removes the link to one provider. A refused
|
|
257
|
+
request throws a `TypedResponseError` whose `errorData` is
|
|
258
|
+
`data.IUpstreamIdentityRefusal`, a closed `code`: `sso_domain_required`,
|
|
259
|
+
`provider_email_unverified`, `upstream_identity_linked_elsewhere`,
|
|
260
|
+
`provider_already_linked` or `last_sign_in_method`.
|
|
261
|
+
|
|
262
|
+
Confirming and unlinking are authentication changes. The authentication-change
|
|
263
|
+
gate, which guards every change to how an account signs in, refuses with
|
|
264
|
+
`errorData` `data.IAuthenticationChangeRefusal` (`code`
|
|
265
|
+
`fresh_passkey_sign_in_required` or `fresh_sign_in_required`,
|
|
266
|
+
`data.authenticationChangeRefusalCodes`) wherever a new sign-in would satisfy
|
|
267
|
+
it; a refusal that no new sign-in can satisfy carries no code. The proof is
|
|
268
|
+
always a new sign-in on the login origin; there is no in-session step-up
|
|
269
|
+
request.
|
|
239
270
|
|
|
240
271
|
OIDC app contracts expose only client configuration and safe credential
|
|
241
272
|
metadata. Client-secret hashes, signing private keys, and persistence records
|
package/ts/00_commitinfo_data.ts
CHANGED
package/ts/data/loginsession.ts
CHANGED
|
@@ -21,6 +21,28 @@ export interface ILoginSessionAuthenticationEvidence {
|
|
|
21
21
|
mfaAuthenticatedAt: number | null;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Why the authentication-change gate refused a request. The gate guards every change to how
|
|
26
|
+
* an account signs in and judges the session's authentication evidence. Wherever a new sign-in
|
|
27
|
+
* would satisfy it, a refused request throws a `TypedResponseError` whose `errorData` is
|
|
28
|
+
* `IAuthenticationChangeRefusal`; a refusal that no new sign-in can satisfy carries no code.
|
|
29
|
+
* The proof is always a new sign-in on the login origin: there is no in-session step-up
|
|
30
|
+
* request. The list is closed.
|
|
31
|
+
* - `fresh_passkey_sign_in_required`: sign in again with a passkey, then retry;
|
|
32
|
+
* - `fresh_sign_in_required`: sign in again, then retry.
|
|
33
|
+
*/
|
|
34
|
+
export const authenticationChangeRefusalCodes = [
|
|
35
|
+
'fresh_passkey_sign_in_required',
|
|
36
|
+
'fresh_sign_in_required',
|
|
37
|
+
] as const;
|
|
38
|
+
|
|
39
|
+
export type TAuthenticationChangeRefusalCode = (typeof authenticationChangeRefusalCodes)[number];
|
|
40
|
+
|
|
41
|
+
/** The `errorData` of a request the authentication-change gate refused. */
|
|
42
|
+
export interface IAuthenticationChangeRefusal {
|
|
43
|
+
code: TAuthenticationChangeRefusalCode;
|
|
44
|
+
}
|
|
45
|
+
|
|
24
46
|
export interface ILoginSession {
|
|
25
47
|
id: string;
|
|
26
48
|
data: {
|
|
@@ -7,15 +7,33 @@ export const upstreamIdentityProviders = ['apple', 'google'] as const;
|
|
|
7
7
|
|
|
8
8
|
export type TUpstreamIdentityProvider = (typeof upstreamIdentityProviders)[number];
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* What an upstream flow is for. The server records it on the flow at start and never changes
|
|
12
|
+
* it, so a sign-in flow that answered `linkRequired` stays a sign-in flow. The list is closed.
|
|
13
|
+
* - `sign-in`: sign in to idp.global, or create an account, with the provider identity;
|
|
14
|
+
* - `link`: link the provider identity to an existing account. A link flow never mints a
|
|
15
|
+
* session and never creates an account.
|
|
16
|
+
*/
|
|
17
|
+
export const upstreamSignInPurposes = ['sign-in', 'link'] as const;
|
|
18
|
+
|
|
19
|
+
export type TUpstreamSignInPurpose = (typeof upstreamSignInPurposes)[number];
|
|
20
|
+
|
|
10
21
|
/**
|
|
11
22
|
* Why an upstream sign-in, link or unlink was refused. A refused request throws a
|
|
12
|
-
* `TypedResponseError` whose `errorData` is `IUpstreamIdentityRefusal
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* - `
|
|
17
|
-
*
|
|
18
|
-
*
|
|
23
|
+
* `TypedResponseError` whose `errorData` is `IUpstreamIdentityRefusal`. The authentication-change
|
|
24
|
+
* gate refuses with its own `IAuthenticationChangeRefusal`, whose codes differ from these; any
|
|
25
|
+
* other failure (an expired or spent flow, a wrong verifier, an unavailable provider) carries
|
|
26
|
+
* no code.
|
|
27
|
+
* - `sso_domain_required`: the email of the account concerned is under a verified SSO domain;
|
|
28
|
+
* sign in through its organization's single sign-on. At finish on a sign-in flow that is the
|
|
29
|
+
* vouched email of an identity not linked yet, or the account's email for a linked identity;
|
|
30
|
+
* at `confirmUpstreamIdentityLink` it is the signed-in account's email. The provider's email
|
|
31
|
+
* on a link flow is not judged;
|
|
32
|
+
* - `provider_email_unverified`: the provider did not vouch for an email: the signed token
|
|
33
|
+
* carries none, or does not say it is verified. A sign-in flow answers it for an identity
|
|
34
|
+
* that is not linked yet, before any account lookup; a link flow answers it for every
|
|
35
|
+
* identity, before any lookup. It never tells whether an account or a link exists; nothing
|
|
36
|
+
* is created or linked, and the flow is ended;
|
|
19
37
|
* - `upstream_identity_linked_elsewhere`: this provider identity is linked to another account;
|
|
20
38
|
* - `provider_already_linked`: the account already has a link to this provider;
|
|
21
39
|
* - `last_sign_in_method`: after the unlink the account would have no password, no active
|
|
@@ -9,7 +9,7 @@ export interface IUpstreamIdentityDto {
|
|
|
9
9
|
provider: TUpstreamIdentityProvider;
|
|
10
10
|
/** epoch ms when the link was made */
|
|
11
11
|
linkedAt: number;
|
|
12
|
-
/** The email the provider
|
|
12
|
+
/** The email the provider vouched for when the link was made; later provider emails never replace it. */
|
|
13
13
|
email: string;
|
|
14
14
|
/** The provider signed that `email` is a private relay address (Apple's `is_private_email`). */
|
|
15
15
|
isPrivateEmail: boolean;
|
package/ts/readme.md
CHANGED
|
@@ -57,7 +57,8 @@ The `data` export includes types for:
|
|
|
57
57
|
- abuse windows
|
|
58
58
|
- OIDC data structures
|
|
59
59
|
- invitations
|
|
60
|
-
- upstream identity providers (Apple, Google) and
|
|
60
|
+
- upstream identity providers (Apple, Google), flow purposes and refusal codes
|
|
61
|
+
- the authentication-change gate's refusal codes
|
|
61
62
|
|
|
62
63
|
### `request`
|
|
63
64
|
|
|
@@ -4,11 +4,39 @@ import * as dto from '../dto/index.js';
|
|
|
4
4
|
import type { IReq_LoginWithEmailOrUsernameAndPassword } from './login.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
* The fields of `startUpstreamSignIn`. `purpose` defaults to `sign-in`; only a sign-in flow
|
|
8
|
+
* may carry an OIDC authorization transaction.
|
|
9
|
+
*/
|
|
10
|
+
export type TStartUpstreamSignInRequest = {
|
|
11
|
+
provider: data.TUpstreamIdentityProvider;
|
|
12
|
+
/** base64url(SHA-256(verifier)) of the verifier the login page keeps */
|
|
13
|
+
verifierChallenge: string;
|
|
14
|
+
} & (
|
|
15
|
+
| {
|
|
16
|
+
purpose?: Extract<data.TUpstreamSignInPurpose, 'sign-in'>;
|
|
17
|
+
/**
|
|
18
|
+
* Optional opaque OIDC authorization transaction to resume through the existing
|
|
19
|
+
* prepare/complete requests once the sign-in is complete.
|
|
20
|
+
*/
|
|
21
|
+
oidcTransactionId?: string;
|
|
22
|
+
}
|
|
23
|
+
| {
|
|
24
|
+
purpose: Extract<data.TUpstreamSignInPurpose, 'link'>;
|
|
25
|
+
oidcTransactionId?: never;
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Public: starts an upstream flow; no session is needed. The login page makes a random
|
|
31
|
+
* verifier, sends only its S256 hash here and keeps the verifier in the login origin's
|
|
32
|
+
* sessionStorage under the answered `id`. The server records the flow and its purpose for ten
|
|
33
|
+
* minutes; the purpose never changes. `id` names that record and is the OAuth `state` inside
|
|
34
|
+
* `authorizationUrl`. The provider returns to the issuer's callback, which always redirects the
|
|
35
|
+
* browser to `<login>/login?upstream=<id>` (plus `&tx=<oidcTransactionId>` when one was given).
|
|
36
|
+
*
|
|
37
|
+
* A sign-in flow starts on the login page, optionally with an OIDC authorization transaction.
|
|
38
|
+
* A link flow starts when the account UI's "Link" navigates to `<login>/login?link=<provider>`;
|
|
39
|
+
* that page starts it with `purpose: 'link'` and goes to the provider.
|
|
12
40
|
*/
|
|
13
41
|
export interface IReq_StartUpstreamSignIn
|
|
14
42
|
extends plugins.typedRequestInterfaces.implementsTR<
|
|
@@ -16,16 +44,7 @@ export interface IReq_StartUpstreamSignIn
|
|
|
16
44
|
IReq_StartUpstreamSignIn
|
|
17
45
|
> {
|
|
18
46
|
method: 'startUpstreamSignIn';
|
|
19
|
-
request:
|
|
20
|
-
provider: data.TUpstreamIdentityProvider;
|
|
21
|
-
/** base64url(SHA-256(verifier)) of the verifier the browser keeps */
|
|
22
|
-
verifierChallenge: string;
|
|
23
|
-
/**
|
|
24
|
-
* Optional opaque OIDC authorization transaction to resume through the existing
|
|
25
|
-
* prepare/complete requests once the sign-in is complete.
|
|
26
|
-
*/
|
|
27
|
-
oidcTransactionId?: string;
|
|
28
|
-
};
|
|
47
|
+
request: TStartUpstreamSignInRequest;
|
|
29
48
|
response: {
|
|
30
49
|
id: string;
|
|
31
50
|
/** The provider's authorization URL; the browser navigates to it. */
|
|
@@ -34,25 +53,38 @@ export interface IReq_StartUpstreamSignIn
|
|
|
34
53
|
}
|
|
35
54
|
|
|
36
55
|
/**
|
|
37
|
-
* The provider identity
|
|
38
|
-
*
|
|
56
|
+
* The returned provider identity can be linked to an existing account. `finishUpstreamSignIn`
|
|
57
|
+
* answers it in two situations:
|
|
58
|
+
* - on a sign-in flow, when the provider identity is not linked and the email the provider
|
|
59
|
+
* vouched for names an existing account. A sign-in flow never answers it for an email the
|
|
60
|
+
* provider did not vouch for;
|
|
61
|
+
* - on a link flow, for every identity whose email the provider vouched for, without any
|
|
62
|
+
* account or link lookup.
|
|
63
|
+
*
|
|
64
|
+
* It mints nothing. The flow stays open until its ten-minute expiry for
|
|
65
|
+
* `confirmUpstreamIdentityLink`.
|
|
39
66
|
*/
|
|
40
67
|
export interface IUpstreamSignInLinkRequired {
|
|
41
68
|
provider: data.TUpstreamIdentityProvider;
|
|
42
|
-
/** The email the provider
|
|
69
|
+
/** The email the provider vouched for; the confirmation screen names it. */
|
|
43
70
|
email: string;
|
|
44
71
|
}
|
|
45
72
|
|
|
46
73
|
/**
|
|
47
|
-
* Public: finishes an upstream
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
74
|
+
* Public: finishes an upstream flow after the provider returned. The page at
|
|
75
|
+
* `<login>/login?upstream=<id>` calls it when it holds a verifier for that `id`, and calls
|
|
76
|
+
* nothing otherwise; it never needs to know the flow's purpose. It answers once per flow.
|
|
77
|
+
*
|
|
78
|
+
* On a sign-in flow it answers like password sign-in: a refresh token, or an MFA challenge to
|
|
79
|
+
* answer through `verifyMfaChallenge` or the passkey MFA requests. Either answer ends the flow.
|
|
80
|
+
* `linkRequired` is the third outcome. Refusal codes (`data.IUpstreamIdentityRefusal`), in
|
|
81
|
+
* this order: `provider_email_unverified`, then `sso_domain_required`. A refusal with a code
|
|
82
|
+
* ends the flow; only a wrong verifier leaves the flow usable.
|
|
83
|
+
*
|
|
84
|
+
* On a link flow it never mints a session, never creates an account and looks up no account
|
|
85
|
+
* and no link: it answers `linkRequired` when the provider vouched for the email, whatever
|
|
86
|
+
* identity the provider returned. Refusal code: `provider_email_unverified`. A refusal with a
|
|
87
|
+
* code ends the flow.
|
|
56
88
|
*/
|
|
57
89
|
export interface IReq_FinishUpstreamSignIn
|
|
58
90
|
extends plugins.typedRequestInterfaces.implementsTR<
|
|
@@ -71,15 +103,24 @@ export interface IReq_FinishUpstreamSignIn
|
|
|
71
103
|
}
|
|
72
104
|
|
|
73
105
|
/**
|
|
74
|
-
* Links the
|
|
75
|
-
*
|
|
76
|
-
*
|
|
106
|
+
* Links the provider identity of a flow whose `finishUpstreamSignIn` answered `linkRequired`;
|
|
107
|
+
* any other flow fails without a code. The link stores the provider's vouched email and
|
|
108
|
+
* private-relay flag as the flow recorded them. It links to the signed-in account and carries
|
|
109
|
+
* the flow's `id` and `verifier`. One confirmation screen on the login origin serves sign-in
|
|
110
|
+
* and link flows alike. It always asks for a new sign-in to the account, whatever session the
|
|
111
|
+
* browser holds, then names the provider, the provider's email and the signed-in account; only
|
|
112
|
+
* the person's explicit confirmation sends this request, never a URL on its own.
|
|
113
|
+
*
|
|
114
|
+
* An authentication change: it needs the account's strongest enrolled proof, fresh (a fresh
|
|
115
|
+
* passkey sign-in while the account has an active passkey, otherwise a fresh primary sign-in);
|
|
116
|
+
* an administrator-recovery session does not count. The gate is checked at entry and again
|
|
117
|
+
* when the link is written, and can refuse with `data.IAuthenticationChangeRefusal`.
|
|
77
118
|
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* `
|
|
119
|
+
* A refused confirm, the gate's refusal included, leaves the flow open until its ten-minute
|
|
120
|
+
* expiry; only the link write spends it.
|
|
121
|
+
* Refusal codes (`data.IUpstreamIdentityRefusal`): `sso_domain_required` (the signed-in
|
|
122
|
+
* account's email), `provider_already_linked`, `upstream_identity_linked_elsewhere`. Never
|
|
123
|
+
* `provider_email_unverified`: no flow reaches this request without a vouched email.
|
|
83
124
|
*/
|
|
84
125
|
export interface IReq_ConfirmUpstreamIdentityLink
|
|
85
126
|
extends plugins.typedRequestInterfaces.implementsTR<
|
|
@@ -116,7 +157,8 @@ export interface IReq_GetUpstreamIdentities
|
|
|
116
157
|
|
|
117
158
|
/**
|
|
118
159
|
* Removes the signed-in account's link to a provider. An authentication change, gated like
|
|
119
|
-
* `confirmUpstreamIdentityLink
|
|
160
|
+
* `confirmUpstreamIdentityLink`; the gate can refuse with `data.IAuthenticationChangeRefusal`.
|
|
161
|
+
* Refusal code (`data.IUpstreamIdentityRefusal`): `last_sign_in_method`.
|
|
120
162
|
*/
|
|
121
163
|
export interface IReq_UnlinkUpstreamIdentity
|
|
122
164
|
extends plugins.typedRequestInterfaces.implementsTR<
|