@idp.global/interfaces 30.2.0 → 30.4.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 +40 -0
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/data/activity.d.ts +5 -3
- package/dist_ts/data/activity.js +8 -2
- package/dist_ts/data/index.d.ts +1 -0
- package/dist_ts/data/index.js +2 -1
- package/dist_ts/data/loginsession.d.ts +3 -1
- package/dist_ts/data/loginsession.js +10 -2
- package/dist_ts/data/mfa.d.ts +4 -1
- package/dist_ts/data/mfa.js +8 -2
- package/dist_ts/data/oidc.d.ts +10 -0
- package/dist_ts/data/upstreamidentity.d.ts +26 -0
- package/dist_ts/data/upstreamidentity.js +7 -0
- package/dist_ts/data/user.d.ts +28 -0
- package/dist_ts/data/user.js +22 -1
- package/dist_ts/dto/activity.d.ts +6 -1
- package/dist_ts/dto/index.d.ts +1 -0
- package/dist_ts/dto/index.js +2 -1
- package/dist_ts/dto/upstreamidentity.d.ts +15 -0
- package/dist_ts/dto/upstreamidentity.js +2 -0
- package/dist_ts/request/authorization.d.ts +3 -1
- package/dist_ts/request/authorization.js +1 -1
- package/dist_ts/request/index.d.ts +1 -0
- package/dist_ts/request/index.js +2 -1
- package/dist_ts/request/upstreamidentity.d.ts +108 -0
- package/dist_ts/request/upstreamidentity.js +4 -0
- package/package.json +1 -1
- package/readme.md +46 -2
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/data/activity.ts +15 -3
- package/ts/data/index.ts +1 -0
- package/ts/data/loginsession.ts +12 -4
- package/ts/data/mfa.ts +12 -1
- package/ts/data/oidc.ts +11 -0
- package/ts/data/upstreamidentity.ts +34 -0
- package/ts/data/user.ts +39 -0
- package/ts/dto/activity.ts +12 -1
- package/ts/dto/index.ts +1 -0
- package/ts/dto/upstreamidentity.ts +16 -0
- package/ts/readme.md +3 -1
- package/ts/request/authorization.ts +7 -1
- package/ts/request/index.ts +1 -0
- package/ts/request/upstreamidentity.ts +134 -0
package/changelog.md
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2026-11-13 - 30.4.0
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- the contract for signing in to idp.global with Apple or Google (data, dto, request; AGL-1801)
|
|
8
|
+
- `upstreamIdentityProviders` (`apple`, `google`) and `TUpstreamIdentityProvider` are the one source of every
|
|
9
|
+
provider value. New runtime lists derive from it: `loginSessionPrimaryAuthenticationMethods`,
|
|
10
|
+
`mfaChallengePrimaryAuthMethods` and `activityAuthenticationMethods`; `userEmailVerificationMethods` gains the
|
|
11
|
+
providers.
|
|
12
|
+
- Five requests: `IReq_StartUpstreamSignIn` (provider, the S256 hash of a verifier the browser keeps, optional
|
|
13
|
+
OIDC transaction; answers the flow `id` and the provider's authorization URL), `IReq_FinishUpstreamSignIn`
|
|
14
|
+
(`{ id, verifier }`; answers like password sign-in, or with `linkRequired`), `IReq_ConfirmUpstreamIdentityLink`,
|
|
15
|
+
`IReq_GetUpstreamIdentities` and `IReq_UnlinkUpstreamIdentity`. Links are listed as `dto.IUpstreamIdentityDto`
|
|
16
|
+
(provider, link time, email at link time, private-relay flag).
|
|
17
|
+
- A refused request throws a `TypedResponseError` whose `errorData` is `IUpstreamIdentityRefusal` with a closed
|
|
18
|
+
`code` (`TUpstreamIdentityRefusalCode`).
|
|
19
|
+
- `provider_hint` on `IAuthorizationRequest`, returned to the login UI as `providerHint` by
|
|
20
|
+
`IReq_InspectOidcAuthorizationV2`: a relying app's own "Sign in with Apple" button starts that provider at once.
|
|
21
|
+
- Activity: actions `upstream_identity_linked` and `upstream_identity_unlinked` (fact `provider`) and target type
|
|
22
|
+
`upstream_identity`; the `login` fact's `authenticationMethod` may name a provider.
|
|
23
|
+
- Widened unions: `TLoginSessionPrimaryAuthenticationMethod`, `IMfaChallenge.data.primaryAuthMethod`,
|
|
24
|
+
`TUserEmailVerificationMethod`, `TActivityAuthenticationMethod`, `TActivityAction` and `TActivityTargetType` gain
|
|
25
|
+
members. Code that handles one of them exhaustively (a `switch` with a `never` check, a
|
|
26
|
+
`Record<TActivityAction, …>` table) must add the new members when it moves to this version.
|
|
27
|
+
|
|
28
|
+
## 2026-11-12 - 30.3.0
|
|
29
|
+
|
|
30
|
+
### Features
|
|
31
|
+
|
|
32
|
+
- a stored email verification on the user (data)
|
|
33
|
+
- `IUser.data.emailVerification` is required: `IUserEmailVerification` (`address`, `verifiedAt` in epoch ms, `method`)
|
|
34
|
+
or `null` while the current address is unverified. `address` always equals `IUser.data.email`; changing the email
|
|
35
|
+
resets the verification to `null`.
|
|
36
|
+
- Code that builds `IUser['data']` must now set `emailVerification` (the idp.global app is the only producer).
|
|
37
|
+
- `TUserEmailVerificationMethod` is the closed set `registration`, `sign-in-code`, `magic-link`, `password-reset`
|
|
38
|
+
and `fixture` (local development fixtures, never a proof of control); `userEmailVerificationMethods` lists it for
|
|
39
|
+
validators.
|
|
40
|
+
- `IIdTokenClaims.email_verified` and `IUserInfoResponse.email_verified` are documented as
|
|
41
|
+
`emailVerification !== null`, independent of the account `status`.
|
|
42
|
+
|
|
3
43
|
## 2026-11-12 - 30.2.0
|
|
4
44
|
|
|
5
45
|
### Features
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@idp.global/interfaces',
|
|
6
|
-
version: '30.
|
|
6
|
+
version: '30.4.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=
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type TActivityAction = 'login' | 'logout' | 'session_created' | 'session_revoked' | 'passport_device_enrolled' | 'passport_device_revoked' | 'passport_challenge_approved' | 'passport_challenge_rejected' | 'org_created' | 'org_updated' | 'org_deleted' | 'org_ownership_transferred' | 'org_joined' | 'org_left' | 'role_changed' | 'org_app_role_mappings_updated' | 'profile_updated' | 'totp_enabled' | 'totp_disabled' | 'backup_codes_regenerated' | 'mfa_completed' | 'passkey_registered' | 'passkey_revoked' | 'passkey_login' | 'app_connected' | 'app_disconnected' | 'user_suspended' | 'user_unsuspended' | 'global_admin_granted' | 'global_admin_removed' | 'global_capabilities_changed' | 'break_glass_requested' | 'break_glass_activated' | 'break_glass_used' | 'break_glass_reviewed' | 'administrator_recovery_requested' | 'administrator_recovery_activated' | 'administrator_recovery_completed' | 'account_deletion_requested' | 'account_deletion_cancelled' | 'account_purged' | 'sso_connection_created' | 'sso_connection_updated' | 'sso_connection_deleted' | 'sso_domain_verified' | 'sso_login' | 'scim_token_created' | 'scim_token_revoked' | 'scim_user_provisioned' | 'scim_user_updated' | 'scim_user_deactivated' | 'scim_group_membership_changed' | 'oidc_authorization_granted' | 'oidc_code_exchanged' | 'oidc_refresh_rotated' | 'oidc_refresh_reuse_detected' | 'oidc_token_revoked' | 'oidc_logout' | 'oidc_client_created' | 'oidc_client_updated' | 'oidc_client_activation_changed' | 'oidc_client_deleted' | 'oidc_client_secret_rotated' | 'oidc_client_app_connection_requests_enabled' | 'oidc_client_app_connection_requests_disabled' | 'oidc_signing_key_rotated' | 'oidc_lifecycle_revoked' | 'org_suspended' | 'org_unsuspended';
|
|
1
|
+
export type TActivityAction = 'login' | 'logout' | 'session_created' | 'session_revoked' | 'passport_device_enrolled' | 'passport_device_revoked' | 'passport_challenge_approved' | 'passport_challenge_rejected' | 'org_created' | 'org_updated' | 'org_deleted' | 'org_ownership_transferred' | 'org_joined' | 'org_left' | 'role_changed' | 'org_app_role_mappings_updated' | 'profile_updated' | 'totp_enabled' | 'totp_disabled' | 'backup_codes_regenerated' | 'mfa_completed' | 'passkey_registered' | 'passkey_revoked' | 'passkey_login' | 'app_connected' | 'app_disconnected' | 'user_suspended' | 'user_unsuspended' | 'global_admin_granted' | 'global_admin_removed' | 'global_capabilities_changed' | 'break_glass_requested' | 'break_glass_activated' | 'break_glass_used' | 'break_glass_reviewed' | 'administrator_recovery_requested' | 'administrator_recovery_activated' | 'administrator_recovery_completed' | 'account_deletion_requested' | 'account_deletion_cancelled' | 'account_purged' | 'sso_connection_created' | 'sso_connection_updated' | 'sso_connection_deleted' | 'sso_domain_verified' | 'sso_login' | 'scim_token_created' | 'scim_token_revoked' | 'scim_user_provisioned' | 'scim_user_updated' | 'scim_user_deactivated' | 'scim_group_membership_changed' | 'oidc_authorization_granted' | 'oidc_code_exchanged' | 'oidc_refresh_rotated' | 'oidc_refresh_reuse_detected' | 'oidc_token_revoked' | 'oidc_logout' | 'oidc_client_created' | 'oidc_client_updated' | 'oidc_client_activation_changed' | 'oidc_client_deleted' | 'oidc_client_secret_rotated' | 'oidc_client_app_connection_requests_enabled' | 'oidc_client_app_connection_requests_disabled' | 'oidc_signing_key_rotated' | 'oidc_lifecycle_revoked' | 'org_suspended' | 'org_unsuspended' | 'upstream_identity_linked' | 'upstream_identity_unlinked';
|
|
2
2
|
export type TActivityOutcome = 'attempted' | 'succeeded' | 'denied' | 'failed';
|
|
3
3
|
/**
|
|
4
4
|
* Public failure reasons are deliberately finite and non-descriptive. They
|
|
@@ -6,8 +6,10 @@ export type TActivityOutcome = 'attempted' | 'succeeded' | 'denied' | 'failed';
|
|
|
6
6
|
* caller-authored text across the public contract boundary.
|
|
7
7
|
*/
|
|
8
8
|
export type TActivityReasonCode = 'account_inactive' | 'authentication_failed' | 'authorization_denied' | 'conflict' | 'expired' | 'invalid_request' | 'policy_denied' | 'rate_limited' | 'replay_detected' | 'revoked' | 'step_up_required' | 'upstream_unavailable' | 'user_cancelled';
|
|
9
|
-
export type TActivityTargetType = 'account' | 'administrator_recovery' | 'application_connection' | 'break_glass_access' | 'mfa_method' | 'oidc_authorization' | 'oidc_client' | 'oidc_lifecycle' | 'oidc_signing_key' | 'oidc_token' | 'organization' | 'organization_membership' | 'organization_role_mapping' | 'passkey' | 'passport_challenge' | 'passport_device' | 'profile' | 'scim_group_membership' | 'scim_token' | 'scim_user' | 'session' | 'sso_connection' | 'sso_domain';
|
|
10
|
-
|
|
9
|
+
export type TActivityTargetType = 'account' | 'administrator_recovery' | 'application_connection' | 'break_glass_access' | 'mfa_method' | 'oidc_authorization' | 'oidc_client' | 'oidc_lifecycle' | 'oidc_signing_key' | 'oidc_token' | 'organization' | 'organization_membership' | 'organization_role_mapping' | 'passkey' | 'passport_challenge' | 'passport_device' | 'profile' | 'scim_group_membership' | 'scim_token' | 'scim_user' | 'session' | 'sso_connection' | 'sso_domain' | 'upstream_identity';
|
|
10
|
+
/** The first factor of a `login` event; an upstream provider names itself. */
|
|
11
|
+
export declare const activityAuthenticationMethods: readonly ["magic_link", "password", "apple", "google"];
|
|
12
|
+
export type TActivityAuthenticationMethod = (typeof activityAuthenticationMethods)[number];
|
|
11
13
|
export type TActivitySessionKind = 'browser' | 'oidc';
|
|
12
14
|
export type TActivityRevocationScope = 'account' | 'all_sessions' | 'application' | 'current_session' | 'organization' | 'token_family';
|
|
13
15
|
export type TActivityRoleChange = 'assigned' | 'removed' | 'replaced';
|
package/dist_ts/data/activity.js
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { upstreamIdentityProviders } from './upstreamidentity.js';
|
|
2
|
+
/** The first factor of a `login` event; an upstream provider names itself. */
|
|
3
|
+
export const activityAuthenticationMethods = [
|
|
4
|
+
'magic_link',
|
|
5
|
+
'password',
|
|
6
|
+
...upstreamIdentityProviders,
|
|
7
|
+
];
|
|
8
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWN0aXZpdHkuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90cy9kYXRhL2FjdGl2aXR5LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSx5QkFBeUIsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBMkhsRSw4RUFBOEU7QUFDOUUsTUFBTSxDQUFDLE1BQU0sNkJBQTZCLEdBQUc7SUFDM0MsWUFBWTtJQUNaLFVBQVU7SUFDVixHQUFHLHlCQUF5QjtDQUNwQixDQUFDIn0=
|
package/dist_ts/data/index.d.ts
CHANGED
package/dist_ts/data/index.js
CHANGED
|
@@ -22,6 +22,7 @@ export * from './registrationsession.js';
|
|
|
22
22
|
export * from './role.js';
|
|
23
23
|
export * from './user.js';
|
|
24
24
|
export * from './userinvitation.js';
|
|
25
|
+
export * from './upstreamidentity.js';
|
|
25
26
|
export * from './ssoconnection.js';
|
|
26
27
|
export * from './scim.js';
|
|
27
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
28
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90cy9kYXRhL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsa0JBQWtCLENBQUM7QUFDakMsY0FBYyxlQUFlLENBQUM7QUFDOUIsY0FBYyxZQUFZLENBQUM7QUFDM0IsY0FBYyxnQkFBZ0IsQ0FBQztBQUMvQixjQUFjLFVBQVUsQ0FBQztBQUN6QixjQUFjLG9CQUFvQixDQUFDO0FBQ25DLGNBQWMsdUJBQXVCLENBQUM7QUFDdEMsY0FBYyxXQUFXLENBQUM7QUFDMUIsY0FBYyxvQkFBb0IsQ0FBQztBQUNuQyxjQUFjLGtCQUFrQixDQUFDO0FBQ2pDLGNBQWMsYUFBYSxDQUFDO0FBQzVCLGNBQWMsVUFBVSxDQUFDO0FBQ3pCLGNBQWMsbUJBQW1CLENBQUM7QUFDbEMsY0FBYyxVQUFVLENBQUM7QUFDekIsY0FBYyxtQkFBbUIsQ0FBQztBQUNsQyxjQUFjLHlCQUF5QixDQUFDO0FBQ3hDLGNBQWMsY0FBYyxDQUFDO0FBQzdCLGNBQWMsd0JBQXdCLENBQUM7QUFDdkMsY0FBYyxxQkFBcUIsQ0FBQztBQUNwQyxjQUFjLG9CQUFvQixDQUFDO0FBQ25DLGNBQWMsMEJBQTBCLENBQUM7QUFDekMsY0FBYyxXQUFXLENBQUM7QUFDMUIsY0FBYyxXQUFXLENBQUM7QUFDMUIsY0FBYyxxQkFBcUIsQ0FBQztBQUNwQyxjQUFjLHVCQUF1QixDQUFDO0FBQ3RDLGNBQWMsb0JBQW9CLENBQUM7QUFDbkMsY0FBYyxXQUFXLENBQUMifQ==
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/** How a session's person first authenticated; an upstream provider names itself. */
|
|
2
|
+
export declare const loginSessionPrimaryAuthenticationMethods: readonly ["magic_link", "passkey", "password", "saml", "apple", "google"];
|
|
3
|
+
export type TLoginSessionPrimaryAuthenticationMethod = (typeof loginSessionPrimaryAuthenticationMethods)[number];
|
|
2
4
|
export type TLoginSessionMfaFactor = 'backup_code' | 'passkey' | 'totp';
|
|
3
5
|
export interface ILoginSessionAuthenticationEvidence {
|
|
4
6
|
primaryMethod: TLoginSessionPrimaryAuthenticationMethod;
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { upstreamIdentityProviders } from './upstreamidentity.js';
|
|
2
|
+
/** How a session's person first authenticated; an upstream provider names itself. */
|
|
3
|
+
export const loginSessionPrimaryAuthenticationMethods = [
|
|
4
|
+
'magic_link',
|
|
5
|
+
'passkey',
|
|
6
|
+
'password',
|
|
7
|
+
'saml',
|
|
8
|
+
...upstreamIdentityProviders,
|
|
9
|
+
];
|
|
10
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9naW5zZXNzaW9uLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vdHMvZGF0YS9sb2dpbnNlc3Npb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLHlCQUF5QixFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFFbEUscUZBQXFGO0FBQ3JGLE1BQU0sQ0FBQyxNQUFNLHdDQUF3QyxHQUFHO0lBQ3RELFlBQVk7SUFDWixTQUFTO0lBQ1QsVUFBVTtJQUNWLE1BQU07SUFDTixHQUFHLHlCQUF5QjtDQUNwQixDQUFDIn0=
|
package/dist_ts/data/mfa.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export type TMfaMethod = 'totp' | 'backupCode' | 'passkey';
|
|
2
2
|
export type TMfaChallengeStatus = 'pending' | 'completed' | 'expired';
|
|
3
|
+
/** The first factor an MFA challenge follows; an upstream provider names itself. */
|
|
4
|
+
export declare const mfaChallengePrimaryAuthMethods: readonly ["password", "email", "apple", "google"];
|
|
5
|
+
export type TMfaChallengePrimaryAuthMethod = (typeof mfaChallengePrimaryAuthMethods)[number];
|
|
3
6
|
export type TTotpCredentialStatus = 'pending' | 'active' | 'disabled';
|
|
4
7
|
export interface ITotpBackupCode {
|
|
5
8
|
id: string;
|
|
@@ -32,7 +35,7 @@ export interface IMfaChallenge {
|
|
|
32
35
|
tokenHash: string;
|
|
33
36
|
status: TMfaChallengeStatus;
|
|
34
37
|
availableMethods: TMfaMethod[];
|
|
35
|
-
primaryAuthMethod:
|
|
38
|
+
primaryAuthMethod: TMfaChallengePrimaryAuthMethod;
|
|
36
39
|
createdAt: number;
|
|
37
40
|
expiresAt: number;
|
|
38
41
|
completedAt?: number | null;
|
package/dist_ts/data/mfa.js
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { upstreamIdentityProviders } from './upstreamidentity.js';
|
|
2
|
+
/** The first factor an MFA challenge follows; an upstream provider names itself. */
|
|
3
|
+
export const mfaChallengePrimaryAuthMethods = [
|
|
4
|
+
'password',
|
|
5
|
+
'email',
|
|
6
|
+
...upstreamIdentityProviders,
|
|
7
|
+
];
|
|
8
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWZhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vdHMvZGF0YS9tZmEudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLHlCQUF5QixFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFNbEUsb0ZBQW9GO0FBQ3BGLE1BQU0sQ0FBQyxNQUFNLDhCQUE4QixHQUFHO0lBQzVDLFVBQVU7SUFDVixPQUFPO0lBQ1AsR0FBRyx5QkFBeUI7Q0FDcEIsQ0FBQyJ9
|
package/dist_ts/data/oidc.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* OIDC (OpenID Connect) data interfaces for third-party client support
|
|
3
3
|
*/
|
|
4
|
+
import type { TUpstreamIdentityProvider } from './upstreamidentity.js';
|
|
4
5
|
/**
|
|
5
6
|
* Supported OIDC scopes
|
|
6
7
|
*/
|
|
@@ -78,6 +79,7 @@ export interface IIdTokenClaims {
|
|
|
78
79
|
preferred_username?: string;
|
|
79
80
|
picture?: string;
|
|
80
81
|
email?: string;
|
|
82
|
+
/** Whether `IUser.data.emailVerification` records a verification of `email`. */
|
|
81
83
|
email_verified?: boolean;
|
|
82
84
|
organizations?: IOrganizationClaim[];
|
|
83
85
|
roles?: string[];
|
|
@@ -104,6 +106,7 @@ export interface IUserInfoResponse {
|
|
|
104
106
|
preferred_username?: string;
|
|
105
107
|
picture?: string;
|
|
106
108
|
email?: string;
|
|
109
|
+
/** Whether `IUser.data.emailVerification` records a verification of `email`. */
|
|
107
110
|
email_verified?: boolean;
|
|
108
111
|
organizations?: IOrganizationClaim[];
|
|
109
112
|
roles?: string[];
|
|
@@ -190,6 +193,13 @@ export interface IAuthorizationRequest {
|
|
|
190
193
|
* `type` with `invalid_authorization_details` (RFC 9396 section 5) and never ignores it.
|
|
191
194
|
*/
|
|
192
195
|
authorization_details?: string;
|
|
196
|
+
/**
|
|
197
|
+
* The idp.global `provider_hint` parameter: the relying app's own "Sign in with …" button asks
|
|
198
|
+
* the login UI to start that provider's sign-in at once instead of showing the sign-in choice.
|
|
199
|
+
* It is a hint only; it never skips MFA or any other step of the sign-in. A value that names
|
|
200
|
+
* no provider this installation offers is ignored: the login UI shows the sign-in choice.
|
|
201
|
+
*/
|
|
202
|
+
provider_hint?: TUpstreamIdentityProvider;
|
|
193
203
|
}
|
|
194
204
|
/**
|
|
195
205
|
* Token request for authorization_code grant
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The identity providers a person can sign in to idp.global with. The list is closed and is
|
|
3
|
+
* the one source of every provider value in these contracts: login-session evidence, the MFA
|
|
4
|
+
* challenge, the email verification method and the activity vocabulary derive from it.
|
|
5
|
+
*/
|
|
6
|
+
export declare const upstreamIdentityProviders: readonly ['apple', 'google'];
|
|
7
|
+
export type TUpstreamIdentityProvider = (typeof upstreamIdentityProviders)[number];
|
|
8
|
+
/**
|
|
9
|
+
* Why an upstream sign-in, link or unlink was refused. A refused request throws a
|
|
10
|
+
* `TypedResponseError` whose `errorData` is `IUpstreamIdentityRefusal`; any other failure
|
|
11
|
+
* (an expired or spent flow, a wrong verifier, an unavailable provider) carries no code.
|
|
12
|
+
* - `sso_domain_required`: the email is under a verified SSO domain; sign in through its
|
|
13
|
+
* organization's single sign-on;
|
|
14
|
+
* - `provider_email_unverified`: the provider did not vouch for the email of an identity that
|
|
15
|
+
* is not linked yet. It is answered before any account lookup, so it never tells whether an
|
|
16
|
+
* account has that email; nothing is created or linked;
|
|
17
|
+
* - `upstream_identity_linked_elsewhere`: this provider identity is linked to another account;
|
|
18
|
+
* - `provider_already_linked`: the account already has a link to this provider;
|
|
19
|
+
* - `last_sign_in_method`: after the unlink the account would have no password, no active
|
|
20
|
+
* passkey and no other link while its email is this link's private-relay address.
|
|
21
|
+
*/
|
|
22
|
+
export type TUpstreamIdentityRefusalCode = 'sso_domain_required' | 'provider_email_unverified' | 'upstream_identity_linked_elsewhere' | 'provider_already_linked' | 'last_sign_in_method';
|
|
23
|
+
/** The `errorData` of a refused upstream identity request. */
|
|
24
|
+
export interface IUpstreamIdentityRefusal {
|
|
25
|
+
code: TUpstreamIdentityRefusalCode;
|
|
26
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The identity providers a person can sign in to idp.global with. The list is closed and is
|
|
3
|
+
* the one source of every provider value in these contracts: login-session evidence, the MFA
|
|
4
|
+
* challenge, the email verification method and the activity vocabulary derive from it.
|
|
5
|
+
*/
|
|
6
|
+
export const upstreamIdentityProviders = ['apple', 'google'];
|
|
7
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXBzdHJlYW1pZGVudGl0eS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3RzL2RhdGEvdXBzdHJlYW1pZGVudGl0eS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7OztHQUlHO0FBQ0gsTUFBTSxDQUFDLE1BQU0seUJBQXlCLEdBQUcsQ0FBQyxPQUFPLEVBQUUsUUFBUSxDQUFVLENBQUMifQ==
|
package/dist_ts/data/user.d.ts
CHANGED
|
@@ -49,12 +49,40 @@ export type TAdministratorRecovery = IAdministratorRecoveryBase & ({
|
|
|
49
49
|
completedAt: number;
|
|
50
50
|
passkeyCredentialRef: string;
|
|
51
51
|
});
|
|
52
|
+
/**
|
|
53
|
+
* How idp.global learned that the user controls an email address. The set is closed:
|
|
54
|
+
* - `registration`: the registration's emailed code or link was confirmed before the
|
|
55
|
+
* account was created;
|
|
56
|
+
* - `sign-in-code`: an emailed sign-in code was entered;
|
|
57
|
+
* - `magic-link`: an emailed sign-in link was followed;
|
|
58
|
+
* - `password-reset`: an emailed password-reset link was completed;
|
|
59
|
+
* - `fixture`: a local development fixture (development IdP persona, seed data); nobody
|
|
60
|
+
* proved control of the address;
|
|
61
|
+
* - an upstream provider (`apple`, `google`): the account was created from that provider's
|
|
62
|
+
* signed assertion that the address is verified.
|
|
63
|
+
*/
|
|
64
|
+
export declare const userEmailVerificationMethods: readonly ["registration", "sign-in-code", "magic-link", "password-reset", "fixture", "apple", "google"];
|
|
65
|
+
export type TUserEmailVerificationMethod = (typeof userEmailVerificationMethods)[number];
|
|
66
|
+
/** A verification of the user's current email address. */
|
|
67
|
+
export interface IUserEmailVerification {
|
|
68
|
+
/** The verified address; always equal to `IUser.data.email`. */
|
|
69
|
+
address: string;
|
|
70
|
+
/** epoch ms when the verification was recorded */
|
|
71
|
+
verifiedAt: number;
|
|
72
|
+
method: TUserEmailVerificationMethod;
|
|
73
|
+
}
|
|
52
74
|
export interface IUser {
|
|
53
75
|
id: string;
|
|
54
76
|
data: {
|
|
55
77
|
name: string;
|
|
56
78
|
username: string;
|
|
57
79
|
email: string;
|
|
80
|
+
/**
|
|
81
|
+
* The verification of `email`, or null while it is unverified. Changing `email`
|
|
82
|
+
* resets it to null. The OIDC `email_verified` claim is `emailVerification !== null`;
|
|
83
|
+
* the account `status` does not affect it.
|
|
84
|
+
*/
|
|
85
|
+
emailVerification: IUserEmailVerification | null;
|
|
58
86
|
/**
|
|
59
87
|
* mobile number used for verification
|
|
60
88
|
*/
|
package/dist_ts/data/user.js
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
1
|
import * as plugins from '../plugins.js';
|
|
2
2
|
import {} from './role.js';
|
|
3
|
-
|
|
3
|
+
import { upstreamIdentityProviders } from './upstreamidentity.js';
|
|
4
|
+
/**
|
|
5
|
+
* How idp.global learned that the user controls an email address. The set is closed:
|
|
6
|
+
* - `registration`: the registration's emailed code or link was confirmed before the
|
|
7
|
+
* account was created;
|
|
8
|
+
* - `sign-in-code`: an emailed sign-in code was entered;
|
|
9
|
+
* - `magic-link`: an emailed sign-in link was followed;
|
|
10
|
+
* - `password-reset`: an emailed password-reset link was completed;
|
|
11
|
+
* - `fixture`: a local development fixture (development IdP persona, seed data); nobody
|
|
12
|
+
* proved control of the address;
|
|
13
|
+
* - an upstream provider (`apple`, `google`): the account was created from that provider's
|
|
14
|
+
* signed assertion that the address is verified.
|
|
15
|
+
*/
|
|
16
|
+
export const userEmailVerificationMethods = [
|
|
17
|
+
'registration',
|
|
18
|
+
'sign-in-code',
|
|
19
|
+
'magic-link',
|
|
20
|
+
'password-reset',
|
|
21
|
+
'fixture',
|
|
22
|
+
...upstreamIdentityProviders,
|
|
23
|
+
];
|
|
24
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXNlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3RzL2RhdGEvdXNlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssT0FBTyxNQUFNLGVBQWUsQ0FBQztBQUN6QyxPQUFPLEVBQWMsTUFBTSxXQUFXLENBQUM7QUFLdkMsT0FBTyxFQUFFLHlCQUF5QixFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFtRWxFOzs7Ozs7Ozs7OztHQVdHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sNEJBQTRCLEdBQUc7SUFDMUMsY0FBYztJQUNkLGNBQWM7SUFDZCxZQUFZO0lBQ1osZ0JBQWdCO0lBQ2hCLFNBQVM7SUFDVCxHQUFHLHlCQUF5QjtDQUNwQixDQUFDIn0=
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TActivityAction, TActivityAuthenticationMethod, TActivityMembershipChange, TActivityMfaFactor, TActivityOidcTokenType, TActivityOutcome, TActivityReasonCode, TActivityRevocationScope, TActivityRoleChange, TActivitySessionKind, TActivityTargetType } from '../data/activity.js';
|
|
2
2
|
import type { TOAuthClientType } from '../data/app.js';
|
|
3
|
+
import type { TUpstreamIdentityProvider } from '../data/upstreamidentity.js';
|
|
3
4
|
type TActivityEventFor<TAction extends TActivityAction, TTargetType extends TActivityTargetType, TFacts> = TAction extends TActivityAction ? {
|
|
4
5
|
action: TAction;
|
|
5
6
|
timestamp: number;
|
|
@@ -65,5 +66,9 @@ export type TActivityEventDto = TActivityEventFor<'login', 'account', {
|
|
|
65
66
|
clientType: TOAuthClientType;
|
|
66
67
|
}> | TActivityEventFor<'oidc_signing_key_rotated', 'oidc_signing_key', null> | TActivityEventFor<'oidc_lifecycle_revoked', 'oidc_lifecycle', {
|
|
67
68
|
revocationScope: TActivityRevocationScope;
|
|
68
|
-
}> | TActivityEventFor<'org_suspended', 'organization', null> | TActivityEventFor<'org_unsuspended', 'organization', null
|
|
69
|
+
}> | TActivityEventFor<'org_suspended', 'organization', null> | TActivityEventFor<'org_unsuspended', 'organization', null> | TActivityEventFor<'upstream_identity_linked', 'upstream_identity', {
|
|
70
|
+
provider: TUpstreamIdentityProvider;
|
|
71
|
+
}> | TActivityEventFor<'upstream_identity_unlinked', 'upstream_identity', {
|
|
72
|
+
provider: TUpstreamIdentityProvider;
|
|
73
|
+
}>;
|
|
69
74
|
export {};
|
package/dist_ts/dto/index.d.ts
CHANGED
package/dist_ts/dto/index.js
CHANGED
|
@@ -8,4 +8,5 @@ export * from './organization.js';
|
|
|
8
8
|
export * from './passport.js';
|
|
9
9
|
export * from './user.js';
|
|
10
10
|
export * from './ssoconnection.js';
|
|
11
|
-
|
|
11
|
+
export * from './upstreamidentity.js';
|
|
12
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90cy9kdG8vaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxlQUFlLENBQUM7QUFDOUIsY0FBYyxZQUFZLENBQUM7QUFDM0IsY0FBYyxVQUFVLENBQUM7QUFDekIsY0FBYyxjQUFjLENBQUM7QUFDN0IsY0FBYyxpQkFBaUIsQ0FBQztBQUNoQyxjQUFjLFVBQVUsQ0FBQztBQUN6QixjQUFjLG1CQUFtQixDQUFDO0FBQ2xDLGNBQWMsZUFBZSxDQUFDO0FBQzlCLGNBQWMsV0FBVyxDQUFDO0FBQzFCLGNBQWMsb0JBQW9CLENBQUM7QUFDbkMsY0FBYyx1QkFBdUIsQ0FBQyJ9
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TUpstreamIdentityProvider } from '../data/upstreamidentity.js';
|
|
2
|
+
/**
|
|
3
|
+
* A link between the account and an upstream provider identity, as the account UI shows it.
|
|
4
|
+
* An account has at most one link per provider, so the provider names the link. The provider's
|
|
5
|
+
* subject and every provider token stay server-side.
|
|
6
|
+
*/
|
|
7
|
+
export interface IUpstreamIdentityDto {
|
|
8
|
+
provider: TUpstreamIdentityProvider;
|
|
9
|
+
/** epoch ms when the link was made */
|
|
10
|
+
linkedAt: number;
|
|
11
|
+
/** The email the provider asserted when the link was made; later provider emails never replace it. */
|
|
12
|
+
email: string;
|
|
13
|
+
/** The provider signed that `email` is a private relay address (Apple's `is_private_email`). */
|
|
14
|
+
isPrivateEmail: boolean;
|
|
15
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as plugins from '../plugins.js';
|
|
2
|
-
import { type IOidcAppConnectionView, type TOidcScope } from '../data/index.js';
|
|
2
|
+
import { type IOidcAppConnectionView, type TOidcScope, type TUpstreamIdentityProvider } from '../data/index.js';
|
|
3
3
|
export interface IReq_CompleteOidcAuthorization extends plugins.typedRequestInterfaces.implementsTR<plugins.typedRequestInterfaces.ITypedRequest, IReq_CompleteOidcAuthorization> {
|
|
4
4
|
method: 'completeOidcAuthorization';
|
|
5
5
|
request: {
|
|
@@ -57,6 +57,8 @@ export interface IReq_InspectOidcAuthorizationV2 extends plugins.typedRequestInt
|
|
|
57
57
|
appConnection?: {
|
|
58
58
|
requiresPasskey: true;
|
|
59
59
|
};
|
|
60
|
+
/** The authorize request's `provider_hint`: the login UI starts this provider's sign-in itself. */
|
|
61
|
+
providerHint?: TUpstreamIdentityProvider;
|
|
60
62
|
};
|
|
61
63
|
}
|
|
62
64
|
export interface IReq_PrepareOidcAuthorizationV2 extends plugins.typedRequestInterfaces.implementsTR<plugins.typedRequestInterfaces.ITypedRequest, IReq_PrepareOidcAuthorizationV2> {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as plugins from '../plugins.js';
|
|
2
2
|
import {} from '../data/index.js';
|
|
3
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXV0aG9yaXphdGlvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3RzL3JlcXVlc3QvYXV0aG9yaXphdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssT0FBTyxNQUFNLGVBQWUsQ0FBQztBQUN6QyxPQUFPLEVBSU4sTUFBTSxrQkFBa0IsQ0FBQyJ9
|
package/dist_ts/request/index.js
CHANGED
|
@@ -15,4 +15,5 @@ export * from './registration.js';
|
|
|
15
15
|
export * from './user.js';
|
|
16
16
|
export * from './userinvitation.js';
|
|
17
17
|
export * from './ssoconnection.js';
|
|
18
|
-
|
|
18
|
+
export * from './upstreamidentity.js';
|
|
19
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90cy9yZXF1ZXN0L2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsWUFBWSxDQUFDO0FBQzNCLGNBQWMsa0JBQWtCLENBQUM7QUFDakMsY0FBYyxZQUFZLENBQUM7QUFDM0IsY0FBYyxVQUFVLENBQUM7QUFDekIsY0FBYyxvQkFBb0IsQ0FBQztBQUNuQyxjQUFjLGNBQWMsQ0FBQztBQUM3QixjQUFjLGtCQUFrQixDQUFDO0FBQ2pDLGNBQWMsVUFBVSxDQUFDO0FBQ3pCLGNBQWMsWUFBWSxDQUFDO0FBQzNCLGNBQWMsVUFBVSxDQUFDO0FBQ3pCLGNBQWMsbUJBQW1CLENBQUM7QUFDbEMsY0FBYyxlQUFlLENBQUM7QUFDOUIsY0FBYyxXQUFXLENBQUM7QUFDMUIsY0FBYyxtQkFBbUIsQ0FBQztBQUNsQyxjQUFjLFdBQVcsQ0FBQztBQUMxQixjQUFjLHFCQUFxQixDQUFDO0FBQ3BDLGNBQWMsb0JBQW9CLENBQUM7QUFDbkMsY0FBYyx1QkFBdUIsQ0FBQyJ9
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import * as plugins from '../plugins.js';
|
|
2
|
+
import * as data from '../data/index.js';
|
|
3
|
+
import * as dto from '../dto/index.js';
|
|
4
|
+
import type { IReq_LoginWithEmailOrUsernameAndPassword } from './login.js';
|
|
5
|
+
/**
|
|
6
|
+
* Public: starts a sign-in with an upstream provider. The browser keeps a random verifier
|
|
7
|
+
* (in sessionStorage) and sends only its S256 hash here. The server records the flow for
|
|
8
|
+
* ten minutes; `id` names that record and is the OAuth `state` inside `authorizationUrl`.
|
|
9
|
+
* The provider returns to the issuer's callback, which redirects the browser to
|
|
10
|
+
* `<login>/login?upstream=<id>` (plus `&tx=<oidcTransactionId>` when one was given).
|
|
11
|
+
*/
|
|
12
|
+
export interface IReq_StartUpstreamSignIn extends plugins.typedRequestInterfaces.implementsTR<plugins.typedRequestInterfaces.ITypedRequest, IReq_StartUpstreamSignIn> {
|
|
13
|
+
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
|
+
};
|
|
24
|
+
response: {
|
|
25
|
+
id: string;
|
|
26
|
+
/** The provider's authorization URL; the browser navigates to it. */
|
|
27
|
+
authorizationUrl: string;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The provider identity is not linked, and the email the provider vouched for names an
|
|
32
|
+
* existing account. Never answered for an email the provider did not vouch for.
|
|
33
|
+
*/
|
|
34
|
+
export interface IUpstreamSignInLinkRequired {
|
|
35
|
+
provider: data.TUpstreamIdentityProvider;
|
|
36
|
+
/** The email the provider asserted. */
|
|
37
|
+
email: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Public: finishes an upstream sign-in after the provider returned. It can be called once
|
|
41
|
+
* per flow and answers like password sign-in: a refresh token, or an MFA challenge to answer
|
|
42
|
+
* through `verifyMfaChallenge` or the passkey MFA requests. Either answer ends the flow.
|
|
43
|
+
* `linkRequired` is the third outcome: it mints nothing and leaves the flow open until its
|
|
44
|
+
* ten-minute expiry for exactly one `confirmUpstreamIdentityLink`, which the person sends
|
|
45
|
+
* with the same `id` and `verifier` after signing in to that account normally in the same
|
|
46
|
+
* browser.
|
|
47
|
+
* Refusal codes (`data.IUpstreamIdentityRefusal`): `sso_domain_required`,
|
|
48
|
+
* `provider_email_unverified`.
|
|
49
|
+
*/
|
|
50
|
+
export interface IReq_FinishUpstreamSignIn extends plugins.typedRequestInterfaces.implementsTR<plugins.typedRequestInterfaces.ITypedRequest, IReq_FinishUpstreamSignIn> {
|
|
51
|
+
method: 'finishUpstreamSignIn';
|
|
52
|
+
request: {
|
|
53
|
+
id: string;
|
|
54
|
+
/** The verifier whose hash `startUpstreamSignIn` received. */
|
|
55
|
+
verifier: string;
|
|
56
|
+
};
|
|
57
|
+
response: IReq_LoginWithEmailOrUsernameAndPassword['response'] & {
|
|
58
|
+
linkRequired?: IUpstreamSignInLinkRequired;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Links the returned provider identity to the signed-in account. An authentication change:
|
|
63
|
+
* it needs the account's strongest enrolled proof, fresh (a passkey step-up while the
|
|
64
|
+
* account has an active passkey, otherwise a fresh primary sign-in).
|
|
65
|
+
*
|
|
66
|
+
* The same requests link from the account UI: `startUpstreamSignIn` without
|
|
67
|
+
* `oidcTransactionId`, the provider round trip, then this request with the returned `id`
|
|
68
|
+
* and `verifier`, without `finishUpstreamSignIn`.
|
|
69
|
+
* Refusal codes: `sso_domain_required`, `upstream_identity_linked_elsewhere`,
|
|
70
|
+
* `provider_already_linked`.
|
|
71
|
+
*/
|
|
72
|
+
export interface IReq_ConfirmUpstreamIdentityLink extends plugins.typedRequestInterfaces.implementsTR<plugins.typedRequestInterfaces.ITypedRequest, IReq_ConfirmUpstreamIdentityLink> {
|
|
73
|
+
method: 'confirmUpstreamIdentityLink';
|
|
74
|
+
request: {
|
|
75
|
+
jwt: string;
|
|
76
|
+
id: string;
|
|
77
|
+
verifier: string;
|
|
78
|
+
};
|
|
79
|
+
response: {
|
|
80
|
+
upstreamIdentity: dto.IUpstreamIdentityDto;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Lists the signed-in account's upstream identity links.
|
|
85
|
+
*/
|
|
86
|
+
export interface IReq_GetUpstreamIdentities extends plugins.typedRequestInterfaces.implementsTR<plugins.typedRequestInterfaces.ITypedRequest, IReq_GetUpstreamIdentities> {
|
|
87
|
+
method: 'getUpstreamIdentities';
|
|
88
|
+
request: {
|
|
89
|
+
jwt: string;
|
|
90
|
+
};
|
|
91
|
+
response: {
|
|
92
|
+
upstreamIdentities: dto.IUpstreamIdentityDto[];
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Removes the signed-in account's link to a provider. An authentication change, gated like
|
|
97
|
+
* `confirmUpstreamIdentityLink`. Refusal code: `last_sign_in_method`.
|
|
98
|
+
*/
|
|
99
|
+
export interface IReq_UnlinkUpstreamIdentity extends plugins.typedRequestInterfaces.implementsTR<plugins.typedRequestInterfaces.ITypedRequest, IReq_UnlinkUpstreamIdentity> {
|
|
100
|
+
method: 'unlinkUpstreamIdentity';
|
|
101
|
+
request: {
|
|
102
|
+
jwt: string;
|
|
103
|
+
provider: data.TUpstreamIdentityProvider;
|
|
104
|
+
};
|
|
105
|
+
response: {
|
|
106
|
+
success: boolean;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as plugins from '../plugins.js';
|
|
2
|
+
import * as data from '../data/index.js';
|
|
3
|
+
import * as dto from '../dto/index.js';
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXBzdHJlYW1pZGVudGl0eS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3RzL3JlcXVlc3QvdXBzdHJlYW1pZGVudGl0eS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssT0FBTyxNQUFNLGVBQWUsQ0FBQztBQUN6QyxPQUFPLEtBQUssSUFBSSxNQUFNLGtCQUFrQixDQUFDO0FBQ3pDLE9BQU8sS0FBSyxHQUFHLE1BQU0saUJBQWlCLENBQUMifQ==
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -137,6 +137,19 @@ The target hash is derived server-side from the canonical, authorized
|
|
|
137
137
|
data. Opaque tokens and the transfer target remain limited to the request and
|
|
138
138
|
response contracts that transport them.
|
|
139
139
|
|
|
140
|
+
`data.upstreamIdentityProviders` (`'apple'`, `'google'`) is the one closed list
|
|
141
|
+
of upstream identity providers, typed as `data.TUpstreamIdentityProvider`.
|
|
142
|
+
Every list that names a provider derives from it and is exported for runtime
|
|
143
|
+
validation: `loginSessionPrimaryAuthenticationMethods` (a session's
|
|
144
|
+
`authentication.primaryMethod`), `mfaChallengePrimaryAuthMethods`
|
|
145
|
+
(`IMfaChallenge.data.primaryAuthMethod`), `userEmailVerificationMethods` (an
|
|
146
|
+
account created from a provider's verified email records that provider) and
|
|
147
|
+
`activityAuthenticationMethods` (the `login` event's `authenticationMethod`).
|
|
148
|
+
Linking and unlinking are the `upstream_identity_linked` and
|
|
149
|
+
`upstream_identity_unlinked` activity actions, target type
|
|
150
|
+
`upstream_identity`, with the provider as their only fact; an upstream sign-in
|
|
151
|
+
is an ordinary `login` event.
|
|
152
|
+
|
|
140
153
|
## TypedRequest Contracts
|
|
141
154
|
|
|
142
155
|
Use `request` when registering handlers or creating typed clients with `@api.global/typedrequest` or `@api.global/typedsocket`.
|
|
@@ -179,7 +192,7 @@ and when a transfer token is consumed. The server authorizes and canonicalizes
|
|
|
179
192
|
the target before binding its server-derived hash to the outstanding transfer
|
|
180
193
|
token.
|
|
181
194
|
|
|
182
|
-
Request groups cover login, registration, JWT refresh, user/session queries, organization membership, invitations, apps, billing, admin actions, alerts, passport device flows, password reset, device IDs, and OIDC authorization.
|
|
195
|
+
Request groups cover login, upstream sign-in and identity links, registration, JWT refresh, user/session queries, organization membership, invitations, apps, billing, admin actions, alerts, passport device flows, password reset, device IDs, and OIDC authorization.
|
|
183
196
|
|
|
184
197
|
The OIDC V2 authorization contracts
|
|
185
198
|
`IReq_InspectOidcAuthorizationV2`, `IReq_PrepareOidcAuthorizationV2`,
|
|
@@ -193,6 +206,37 @@ or email-code proof and registration completion return the authoritative stored
|
|
|
193
206
|
value. Implementations should keep it out of registration email links and use
|
|
194
207
|
the existing authenticated OIDC prepare/complete requests for final binding.
|
|
195
208
|
|
|
209
|
+
An authorization request may carry `provider_hint`
|
|
210
|
+
(`data.IAuthorizationRequest`); `IReq_InspectOidcAuthorizationV2` returns it to
|
|
211
|
+
the login UI as `providerHint`, and the login UI starts that provider's sign-in
|
|
212
|
+
itself. The hint never skips a step of the sign-in, and a value that names no
|
|
213
|
+
offered provider is ignored.
|
|
214
|
+
|
|
215
|
+
Upstream sign-in (Apple, Google) binds the redirect flow to the browser that
|
|
216
|
+
started it. `IReq_StartUpstreamSignIn` takes the provider, the S256 hash of a
|
|
217
|
+
verifier the browser keeps, and optionally the opaque OIDC transaction; it
|
|
218
|
+
returns the flow `id` (the OAuth `state`) and the provider's authorization URL.
|
|
219
|
+
After the provider's callback, `IReq_FinishUpstreamSignIn` sends `{ id, verifier }`
|
|
220
|
+
once per flow and answers like password sign-in (a refresh token or an MFA
|
|
221
|
+
challenge, which end the flow), or with `linkRequired` (provider and asserted
|
|
222
|
+
email) when the email the provider vouched for names an existing account that
|
|
223
|
+
is not linked yet. `linkRequired` mints nothing and leaves the flow open until
|
|
224
|
+
its ten-minute expiry for exactly one `IReq_ConfirmUpstreamIdentityLink`, which
|
|
225
|
+
the person sends with the same `id` and verifier after signing in to that
|
|
226
|
+
account normally in the same browser. An identity that is not linked and whose
|
|
227
|
+
email the provider did not vouch for is refused with
|
|
228
|
+
`provider_email_unverified` before any account lookup. A signed-in person links from the account UI with
|
|
229
|
+
the same requests: start, the provider round trip, then confirm, without
|
|
230
|
+
finish. `IReq_GetUpstreamIdentities` lists the account's links as
|
|
231
|
+
`dto.IUpstreamIdentityDto` (provider, link time, the email at link time, and the
|
|
232
|
+
private-relay flag; never the provider subject or a provider token), and
|
|
233
|
+
`IReq_UnlinkUpstreamIdentity` removes the link to one provider. Confirming and
|
|
234
|
+
unlinking are authentication changes. A refused request throws a
|
|
235
|
+
`TypedResponseError` whose `errorData` is `data.IUpstreamIdentityRefusal`, a
|
|
236
|
+
closed `code`: `sso_domain_required`, `provider_email_unverified`,
|
|
237
|
+
`upstream_identity_linked_elsewhere`, `provider_already_linked` or
|
|
238
|
+
`last_sign_in_method`.
|
|
239
|
+
|
|
196
240
|
OIDC app contracts expose only client configuration and safe credential
|
|
197
241
|
metadata. Client-secret hashes, signing private keys, and persistence records
|
|
198
242
|
for authorization codes, access tokens, refresh tokens, and token families
|
|
@@ -200,7 +244,7 @@ remain backend-internal; protocol request and response values remain public.
|
|
|
200
244
|
|
|
201
245
|
## DTO Contracts
|
|
202
246
|
|
|
203
|
-
Use `dto` for normalized transfer objects grouped by activity, alerts, apps, billing, invitations, MFA, organizations, passport, and users. `dto.TActivityEventDto` is a discriminated structured event: it exposes only a finite action, timestamp, outcome, optional reason code, fixed target type, and allowlisted action-specific facts. It never carries event, actor, or target identifiers; free text; network data; integrity material; or delivery state. Public OIDC support includes `data.IOidcSettings` and redacted `data.IJwtVerificationKey` records.
|
|
247
|
+
Use `dto` for normalized transfer objects grouped by activity, alerts, apps, billing, invitations, MFA, organizations, passport, upstream identity links, and users. `dto.TActivityEventDto` is a discriminated structured event: it exposes only a finite action, timestamp, outcome, optional reason code, fixed target type, and allowlisted action-specific facts. It never carries event, actor, or target identifiers; free text; network data; integrity material; or delivery state. Public OIDC support includes `data.IOidcSettings` and redacted `data.IJwtVerificationKey` records.
|
|
204
248
|
|
|
205
249
|
```ts
|
|
206
250
|
const activity: dto.TActivityEventDto = {
|
package/ts/00_commitinfo_data.ts
CHANGED
package/ts/data/activity.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { upstreamIdentityProviders } from './upstreamidentity.js';
|
|
2
|
+
|
|
1
3
|
export type TActivityAction =
|
|
2
4
|
| 'login'
|
|
3
5
|
| 'logout'
|
|
@@ -67,7 +69,9 @@ export type TActivityAction =
|
|
|
67
69
|
| 'oidc_signing_key_rotated'
|
|
68
70
|
| 'oidc_lifecycle_revoked'
|
|
69
71
|
| 'org_suspended'
|
|
70
|
-
| 'org_unsuspended'
|
|
72
|
+
| 'org_unsuspended'
|
|
73
|
+
| 'upstream_identity_linked'
|
|
74
|
+
| 'upstream_identity_unlinked';
|
|
71
75
|
|
|
72
76
|
export type TActivityOutcome = 'attempted' | 'succeeded' | 'denied' | 'failed';
|
|
73
77
|
|
|
@@ -114,9 +118,17 @@ export type TActivityTargetType =
|
|
|
114
118
|
| 'scim_user'
|
|
115
119
|
| 'session'
|
|
116
120
|
| 'sso_connection'
|
|
117
|
-
| 'sso_domain'
|
|
121
|
+
| 'sso_domain'
|
|
122
|
+
| 'upstream_identity';
|
|
123
|
+
|
|
124
|
+
/** The first factor of a `login` event; an upstream provider names itself. */
|
|
125
|
+
export const activityAuthenticationMethods = [
|
|
126
|
+
'magic_link',
|
|
127
|
+
'password',
|
|
128
|
+
...upstreamIdentityProviders,
|
|
129
|
+
] as const;
|
|
118
130
|
|
|
119
|
-
export type TActivityAuthenticationMethod =
|
|
131
|
+
export type TActivityAuthenticationMethod = (typeof activityAuthenticationMethods)[number];
|
|
120
132
|
export type TActivitySessionKind = 'browser' | 'oidc';
|
|
121
133
|
export type TActivityRevocationScope =
|
|
122
134
|
| 'account'
|
package/ts/data/index.ts
CHANGED
package/ts/data/loginsession.ts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
import { upstreamIdentityProviders } from './upstreamidentity.js';
|
|
2
|
+
|
|
3
|
+
/** How a session's person first authenticated; an upstream provider names itself. */
|
|
4
|
+
export const loginSessionPrimaryAuthenticationMethods = [
|
|
5
|
+
'magic_link',
|
|
6
|
+
'passkey',
|
|
7
|
+
'password',
|
|
8
|
+
'saml',
|
|
9
|
+
...upstreamIdentityProviders,
|
|
10
|
+
] as const;
|
|
11
|
+
|
|
1
12
|
export type TLoginSessionPrimaryAuthenticationMethod =
|
|
2
|
-
|
|
3
|
-
| 'passkey'
|
|
4
|
-
| 'password'
|
|
5
|
-
| 'saml';
|
|
13
|
+
(typeof loginSessionPrimaryAuthenticationMethods)[number];
|
|
6
14
|
|
|
7
15
|
export type TLoginSessionMfaFactor = 'backup_code' | 'passkey' | 'totp';
|
|
8
16
|
|
package/ts/data/mfa.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
|
+
import { upstreamIdentityProviders } from './upstreamidentity.js';
|
|
2
|
+
|
|
1
3
|
export type TMfaMethod = 'totp' | 'backupCode' | 'passkey';
|
|
2
4
|
|
|
3
5
|
export type TMfaChallengeStatus = 'pending' | 'completed' | 'expired';
|
|
4
6
|
|
|
7
|
+
/** The first factor an MFA challenge follows; an upstream provider names itself. */
|
|
8
|
+
export const mfaChallengePrimaryAuthMethods = [
|
|
9
|
+
'password',
|
|
10
|
+
'email',
|
|
11
|
+
...upstreamIdentityProviders,
|
|
12
|
+
] as const;
|
|
13
|
+
|
|
14
|
+
export type TMfaChallengePrimaryAuthMethod = (typeof mfaChallengePrimaryAuthMethods)[number];
|
|
15
|
+
|
|
5
16
|
export type TTotpCredentialStatus = 'pending' | 'active' | 'disabled';
|
|
6
17
|
|
|
7
18
|
export interface ITotpBackupCode {
|
|
@@ -37,7 +48,7 @@ export interface IMfaChallenge {
|
|
|
37
48
|
tokenHash: string;
|
|
38
49
|
status: TMfaChallengeStatus;
|
|
39
50
|
availableMethods: TMfaMethod[];
|
|
40
|
-
primaryAuthMethod:
|
|
51
|
+
primaryAuthMethod: TMfaChallengePrimaryAuthMethod;
|
|
41
52
|
createdAt: number;
|
|
42
53
|
expiresAt: number;
|
|
43
54
|
completedAt?: number | null;
|
package/ts/data/oidc.ts
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* OIDC (OpenID Connect) data interfaces for third-party client support
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
import type { TUpstreamIdentityProvider } from './upstreamidentity.js';
|
|
6
|
+
|
|
5
7
|
/**
|
|
6
8
|
* Supported OIDC scopes
|
|
7
9
|
*/
|
|
@@ -87,6 +89,7 @@ export interface IIdTokenClaims {
|
|
|
87
89
|
|
|
88
90
|
// Email scope claims
|
|
89
91
|
email?: string;
|
|
92
|
+
/** Whether `IUser.data.emailVerification` records a verification of `email`. */
|
|
90
93
|
email_verified?: boolean;
|
|
91
94
|
|
|
92
95
|
// Custom claims for organizations scope
|
|
@@ -123,6 +126,7 @@ export interface IUserInfoResponse {
|
|
|
123
126
|
|
|
124
127
|
// Email scope
|
|
125
128
|
email?: string;
|
|
129
|
+
/** Whether `IUser.data.emailVerification` records a verification of `email`. */
|
|
126
130
|
email_verified?: boolean;
|
|
127
131
|
|
|
128
132
|
// Organizations scope (custom)
|
|
@@ -219,6 +223,13 @@ export interface IAuthorizationRequest {
|
|
|
219
223
|
* `type` with `invalid_authorization_details` (RFC 9396 section 5) and never ignores it.
|
|
220
224
|
*/
|
|
221
225
|
authorization_details?: string;
|
|
226
|
+
/**
|
|
227
|
+
* The idp.global `provider_hint` parameter: the relying app's own "Sign in with …" button asks
|
|
228
|
+
* the login UI to start that provider's sign-in at once instead of showing the sign-in choice.
|
|
229
|
+
* It is a hint only; it never skips MFA or any other step of the sign-in. A value that names
|
|
230
|
+
* no provider this installation offers is ignored: the login UI shows the sign-in choice.
|
|
231
|
+
*/
|
|
232
|
+
provider_hint?: TUpstreamIdentityProvider;
|
|
222
233
|
}
|
|
223
234
|
|
|
224
235
|
/**
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The identity providers a person can sign in to idp.global with. The list is closed and is
|
|
3
|
+
* the one source of every provider value in these contracts: login-session evidence, the MFA
|
|
4
|
+
* challenge, the email verification method and the activity vocabulary derive from it.
|
|
5
|
+
*/
|
|
6
|
+
export const upstreamIdentityProviders = ['apple', 'google'] as const;
|
|
7
|
+
|
|
8
|
+
export type TUpstreamIdentityProvider = (typeof upstreamIdentityProviders)[number];
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Why an upstream sign-in, link or unlink was refused. A refused request throws a
|
|
12
|
+
* `TypedResponseError` whose `errorData` is `IUpstreamIdentityRefusal`; any other failure
|
|
13
|
+
* (an expired or spent flow, a wrong verifier, an unavailable provider) carries no code.
|
|
14
|
+
* - `sso_domain_required`: the email is under a verified SSO domain; sign in through its
|
|
15
|
+
* organization's single sign-on;
|
|
16
|
+
* - `provider_email_unverified`: the provider did not vouch for the email of an identity that
|
|
17
|
+
* is not linked yet. It is answered before any account lookup, so it never tells whether an
|
|
18
|
+
* account has that email; nothing is created or linked;
|
|
19
|
+
* - `upstream_identity_linked_elsewhere`: this provider identity is linked to another account;
|
|
20
|
+
* - `provider_already_linked`: the account already has a link to this provider;
|
|
21
|
+
* - `last_sign_in_method`: after the unlink the account would have no password, no active
|
|
22
|
+
* passkey and no other link while its email is this link's private-relay address.
|
|
23
|
+
*/
|
|
24
|
+
export type TUpstreamIdentityRefusalCode =
|
|
25
|
+
| 'sso_domain_required'
|
|
26
|
+
| 'provider_email_unverified'
|
|
27
|
+
| 'upstream_identity_linked_elsewhere'
|
|
28
|
+
| 'provider_already_linked'
|
|
29
|
+
| 'last_sign_in_method';
|
|
30
|
+
|
|
31
|
+
/** The `errorData` of a refused upstream identity request. */
|
|
32
|
+
export interface IUpstreamIdentityRefusal {
|
|
33
|
+
code: TUpstreamIdentityRefusalCode;
|
|
34
|
+
}
|
package/ts/data/user.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
TBreakGlassEligibleGlobalCapability,
|
|
5
5
|
TDelegableGlobalCapability,
|
|
6
6
|
} from './authorization.js';
|
|
7
|
+
import { upstreamIdentityProviders } from './upstreamidentity.js';
|
|
7
8
|
|
|
8
9
|
export type TBreakGlassJustificationCode =
|
|
9
10
|
| 'access_recovery'
|
|
@@ -70,12 +71,50 @@ export type TAdministratorRecovery = IAdministratorRecoveryBase & (
|
|
|
70
71
|
}
|
|
71
72
|
);
|
|
72
73
|
|
|
74
|
+
/**
|
|
75
|
+
* How idp.global learned that the user controls an email address. The set is closed:
|
|
76
|
+
* - `registration`: the registration's emailed code or link was confirmed before the
|
|
77
|
+
* account was created;
|
|
78
|
+
* - `sign-in-code`: an emailed sign-in code was entered;
|
|
79
|
+
* - `magic-link`: an emailed sign-in link was followed;
|
|
80
|
+
* - `password-reset`: an emailed password-reset link was completed;
|
|
81
|
+
* - `fixture`: a local development fixture (development IdP persona, seed data); nobody
|
|
82
|
+
* proved control of the address;
|
|
83
|
+
* - an upstream provider (`apple`, `google`): the account was created from that provider's
|
|
84
|
+
* signed assertion that the address is verified.
|
|
85
|
+
*/
|
|
86
|
+
export const userEmailVerificationMethods = [
|
|
87
|
+
'registration',
|
|
88
|
+
'sign-in-code',
|
|
89
|
+
'magic-link',
|
|
90
|
+
'password-reset',
|
|
91
|
+
'fixture',
|
|
92
|
+
...upstreamIdentityProviders,
|
|
93
|
+
] as const;
|
|
94
|
+
|
|
95
|
+
export type TUserEmailVerificationMethod = (typeof userEmailVerificationMethods)[number];
|
|
96
|
+
|
|
97
|
+
/** A verification of the user's current email address. */
|
|
98
|
+
export interface IUserEmailVerification {
|
|
99
|
+
/** The verified address; always equal to `IUser.data.email`. */
|
|
100
|
+
address: string;
|
|
101
|
+
/** epoch ms when the verification was recorded */
|
|
102
|
+
verifiedAt: number;
|
|
103
|
+
method: TUserEmailVerificationMethod;
|
|
104
|
+
}
|
|
105
|
+
|
|
73
106
|
export interface IUser {
|
|
74
107
|
id: string;
|
|
75
108
|
data: {
|
|
76
109
|
name: string;
|
|
77
110
|
username: string;
|
|
78
111
|
email: string;
|
|
112
|
+
/**
|
|
113
|
+
* The verification of `email`, or null while it is unverified. Changing `email`
|
|
114
|
+
* resets it to null. The OIDC `email_verified` claim is `emailVerification !== null`;
|
|
115
|
+
* the account `status` does not affect it.
|
|
116
|
+
*/
|
|
117
|
+
emailVerification: IUserEmailVerification | null;
|
|
79
118
|
|
|
80
119
|
/**
|
|
81
120
|
* mobile number used for verification
|
package/ts/dto/activity.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
TActivityTargetType,
|
|
13
13
|
} from '../data/activity.js';
|
|
14
14
|
import type { TOAuthClientType } from '../data/app.js';
|
|
15
|
+
import type { TUpstreamIdentityProvider } from '../data/upstreamidentity.js';
|
|
15
16
|
|
|
16
17
|
type TActivityEventFor<
|
|
17
18
|
TAction extends TActivityAction,
|
|
@@ -171,7 +172,17 @@ export type TActivityEventDto =
|
|
|
171
172
|
{ revocationScope: TActivityRevocationScope }
|
|
172
173
|
>
|
|
173
174
|
| TActivityEventFor<'org_suspended', 'organization', null>
|
|
174
|
-
| TActivityEventFor<'org_unsuspended', 'organization', null
|
|
175
|
+
| TActivityEventFor<'org_unsuspended', 'organization', null>
|
|
176
|
+
| TActivityEventFor<
|
|
177
|
+
'upstream_identity_linked',
|
|
178
|
+
'upstream_identity',
|
|
179
|
+
{ provider: TUpstreamIdentityProvider }
|
|
180
|
+
>
|
|
181
|
+
| TActivityEventFor<
|
|
182
|
+
'upstream_identity_unlinked',
|
|
183
|
+
'upstream_identity',
|
|
184
|
+
{ provider: TUpstreamIdentityProvider }
|
|
185
|
+
>;
|
|
175
186
|
|
|
176
187
|
type TAssertNoMissingActivityActions<TValue extends never> = TValue;
|
|
177
188
|
type TActivityEventDtoHasEveryAction = TAssertNoMissingActivityActions<
|
package/ts/dto/index.ts
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { TUpstreamIdentityProvider } from '../data/upstreamidentity.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A link between the account and an upstream provider identity, as the account UI shows it.
|
|
5
|
+
* An account has at most one link per provider, so the provider names the link. The provider's
|
|
6
|
+
* subject and every provider token stay server-side.
|
|
7
|
+
*/
|
|
8
|
+
export interface IUpstreamIdentityDto {
|
|
9
|
+
provider: TUpstreamIdentityProvider;
|
|
10
|
+
/** epoch ms when the link was made */
|
|
11
|
+
linkedAt: number;
|
|
12
|
+
/** The email the provider asserted when the link was made; later provider emails never replace it. */
|
|
13
|
+
email: string;
|
|
14
|
+
/** The provider signed that `email` is a private relay address (Apple's `is_private_email`). */
|
|
15
|
+
isPrivateEmail: boolean;
|
|
16
|
+
}
|
package/ts/readme.md
CHANGED
|
@@ -57,6 +57,7 @@ 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 their refusal codes
|
|
60
61
|
|
|
61
62
|
### `request`
|
|
62
63
|
|
|
@@ -71,10 +72,11 @@ The `request` export includes typed request contracts for:
|
|
|
71
72
|
- billing and JWT validation-keyset support
|
|
72
73
|
- alert and passport approval flows
|
|
73
74
|
- OIDC authorization preparation and completion
|
|
75
|
+
- upstream sign-in (Apple, Google) and identity links
|
|
74
76
|
|
|
75
77
|
### `dto`
|
|
76
78
|
|
|
77
|
-
The `dto` export includes normalized transfer objects for activity, alerts, apps, billing, invitations, MFA, organizations, passport, and users. Activity responses use the discriminated `TActivityEventDto` union, which contains only finite classifications and allowlisted per-action facts. Persistence identities, actor and target identities, free text, network data, integrity fields, and sink delivery state are backend-private.
|
|
79
|
+
The `dto` export includes normalized transfer objects for activity, alerts, apps, billing, invitations, MFA, organizations, passport, upstream identity links, and users. Activity responses use the discriminated `TActivityEventDto` union, which contains only finite classifications and allowlisted per-action facts. Persistence identities, actor and target identities, free text, network data, integrity fields, and sink delivery state are backend-private.
|
|
78
80
|
|
|
79
81
|
### `tags`
|
|
80
82
|
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import * as plugins from '../plugins.js';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
type IOidcAppConnectionView,
|
|
4
|
+
type TOidcScope,
|
|
5
|
+
type TUpstreamIdentityProvider,
|
|
6
|
+
} from '../data/index.js';
|
|
3
7
|
|
|
4
8
|
export interface IReq_CompleteOidcAuthorization
|
|
5
9
|
extends plugins.typedRequestInterfaces.implementsTR<
|
|
@@ -70,6 +74,8 @@ export interface IReq_InspectOidcAuthorizationV2
|
|
|
70
74
|
prompt: 'none' | 'login' | 'consent' | null;
|
|
71
75
|
/** The transaction asks for an app connection: the sign-in must use a passkey. Nothing more before the sign-in. */
|
|
72
76
|
appConnection?: { requiresPasskey: true };
|
|
77
|
+
/** The authorize request's `provider_hint`: the login UI starts this provider's sign-in itself. */
|
|
78
|
+
providerHint?: TUpstreamIdentityProvider;
|
|
73
79
|
};
|
|
74
80
|
}
|
|
75
81
|
|
package/ts/request/index.ts
CHANGED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import * as plugins from '../plugins.js';
|
|
2
|
+
import * as data from '../data/index.js';
|
|
3
|
+
import * as dto from '../dto/index.js';
|
|
4
|
+
import type { IReq_LoginWithEmailOrUsernameAndPassword } from './login.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Public: starts a sign-in with an upstream provider. The browser keeps a random verifier
|
|
8
|
+
* (in sessionStorage) and sends only its S256 hash here. The server records the flow for
|
|
9
|
+
* ten minutes; `id` names that record and is the OAuth `state` inside `authorizationUrl`.
|
|
10
|
+
* The provider returns to the issuer's callback, which redirects the browser to
|
|
11
|
+
* `<login>/login?upstream=<id>` (plus `&tx=<oidcTransactionId>` when one was given).
|
|
12
|
+
*/
|
|
13
|
+
export interface IReq_StartUpstreamSignIn
|
|
14
|
+
extends plugins.typedRequestInterfaces.implementsTR<
|
|
15
|
+
plugins.typedRequestInterfaces.ITypedRequest,
|
|
16
|
+
IReq_StartUpstreamSignIn
|
|
17
|
+
> {
|
|
18
|
+
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
|
+
};
|
|
29
|
+
response: {
|
|
30
|
+
id: string;
|
|
31
|
+
/** The provider's authorization URL; the browser navigates to it. */
|
|
32
|
+
authorizationUrl: string;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The provider identity is not linked, and the email the provider vouched for names an
|
|
38
|
+
* existing account. Never answered for an email the provider did not vouch for.
|
|
39
|
+
*/
|
|
40
|
+
export interface IUpstreamSignInLinkRequired {
|
|
41
|
+
provider: data.TUpstreamIdentityProvider;
|
|
42
|
+
/** The email the provider asserted. */
|
|
43
|
+
email: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Public: finishes an upstream sign-in after the provider returned. It can be called once
|
|
48
|
+
* per flow and answers like password sign-in: a refresh token, or an MFA challenge to answer
|
|
49
|
+
* through `verifyMfaChallenge` or the passkey MFA requests. Either answer ends the flow.
|
|
50
|
+
* `linkRequired` is the third outcome: it mints nothing and leaves the flow open until its
|
|
51
|
+
* ten-minute expiry for exactly one `confirmUpstreamIdentityLink`, which the person sends
|
|
52
|
+
* with the same `id` and `verifier` after signing in to that account normally in the same
|
|
53
|
+
* browser.
|
|
54
|
+
* Refusal codes (`data.IUpstreamIdentityRefusal`): `sso_domain_required`,
|
|
55
|
+
* `provider_email_unverified`.
|
|
56
|
+
*/
|
|
57
|
+
export interface IReq_FinishUpstreamSignIn
|
|
58
|
+
extends plugins.typedRequestInterfaces.implementsTR<
|
|
59
|
+
plugins.typedRequestInterfaces.ITypedRequest,
|
|
60
|
+
IReq_FinishUpstreamSignIn
|
|
61
|
+
> {
|
|
62
|
+
method: 'finishUpstreamSignIn';
|
|
63
|
+
request: {
|
|
64
|
+
id: string;
|
|
65
|
+
/** The verifier whose hash `startUpstreamSignIn` received. */
|
|
66
|
+
verifier: string;
|
|
67
|
+
};
|
|
68
|
+
response: IReq_LoginWithEmailOrUsernameAndPassword['response'] & {
|
|
69
|
+
linkRequired?: IUpstreamSignInLinkRequired;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Links the returned provider identity to the signed-in account. An authentication change:
|
|
75
|
+
* it needs the account's strongest enrolled proof, fresh (a passkey step-up while the
|
|
76
|
+
* account has an active passkey, otherwise a fresh primary sign-in).
|
|
77
|
+
*
|
|
78
|
+
* The same requests link from the account UI: `startUpstreamSignIn` without
|
|
79
|
+
* `oidcTransactionId`, the provider round trip, then this request with the returned `id`
|
|
80
|
+
* and `verifier`, without `finishUpstreamSignIn`.
|
|
81
|
+
* Refusal codes: `sso_domain_required`, `upstream_identity_linked_elsewhere`,
|
|
82
|
+
* `provider_already_linked`.
|
|
83
|
+
*/
|
|
84
|
+
export interface IReq_ConfirmUpstreamIdentityLink
|
|
85
|
+
extends plugins.typedRequestInterfaces.implementsTR<
|
|
86
|
+
plugins.typedRequestInterfaces.ITypedRequest,
|
|
87
|
+
IReq_ConfirmUpstreamIdentityLink
|
|
88
|
+
> {
|
|
89
|
+
method: 'confirmUpstreamIdentityLink';
|
|
90
|
+
request: {
|
|
91
|
+
jwt: string;
|
|
92
|
+
id: string;
|
|
93
|
+
verifier: string;
|
|
94
|
+
};
|
|
95
|
+
response: {
|
|
96
|
+
upstreamIdentity: dto.IUpstreamIdentityDto;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Lists the signed-in account's upstream identity links.
|
|
102
|
+
*/
|
|
103
|
+
export interface IReq_GetUpstreamIdentities
|
|
104
|
+
extends plugins.typedRequestInterfaces.implementsTR<
|
|
105
|
+
plugins.typedRequestInterfaces.ITypedRequest,
|
|
106
|
+
IReq_GetUpstreamIdentities
|
|
107
|
+
> {
|
|
108
|
+
method: 'getUpstreamIdentities';
|
|
109
|
+
request: {
|
|
110
|
+
jwt: string;
|
|
111
|
+
};
|
|
112
|
+
response: {
|
|
113
|
+
upstreamIdentities: dto.IUpstreamIdentityDto[];
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Removes the signed-in account's link to a provider. An authentication change, gated like
|
|
119
|
+
* `confirmUpstreamIdentityLink`. Refusal code: `last_sign_in_method`.
|
|
120
|
+
*/
|
|
121
|
+
export interface IReq_UnlinkUpstreamIdentity
|
|
122
|
+
extends plugins.typedRequestInterfaces.implementsTR<
|
|
123
|
+
plugins.typedRequestInterfaces.ITypedRequest,
|
|
124
|
+
IReq_UnlinkUpstreamIdentity
|
|
125
|
+
> {
|
|
126
|
+
method: 'unlinkUpstreamIdentity';
|
|
127
|
+
request: {
|
|
128
|
+
jwt: string;
|
|
129
|
+
provider: data.TUpstreamIdentityProvider;
|
|
130
|
+
};
|
|
131
|
+
response: {
|
|
132
|
+
success: boolean;
|
|
133
|
+
};
|
|
134
|
+
}
|