@meistrari/auth-core 1.42.0 → 2.0.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/dist/index.d.mts +108 -48
- package/dist/index.d.ts +108 -48
- package/dist/index.mjs +57 -12
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -32,17 +32,28 @@ declare const ACRs: {
|
|
|
32
32
|
readonly Unspecified: "urn:tela:auth:unspecified" & zod__default.core.$brand<typeof ACRBrand>;
|
|
33
33
|
};
|
|
34
34
|
declare const AuthMethods: {
|
|
35
|
-
readonly Password: ("unknown" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("password" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("saml" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("oauth" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & zod__default.core.$brand<typeof AuthMethodBrand>);
|
|
36
|
-
readonly EmailOTP: ("unknown" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("password" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("saml" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("oauth" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & zod__default.core.$brand<typeof AuthMethodBrand>);
|
|
37
|
-
readonly OAuth: ("unknown" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("password" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("saml" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("oauth" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & zod__default.core.$brand<typeof AuthMethodBrand>);
|
|
38
|
-
readonly
|
|
39
|
-
readonly
|
|
35
|
+
readonly Password: ("sso" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("unknown" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("password" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("saml" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("oauth" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & zod__default.core.$brand<typeof AuthMethodBrand>);
|
|
36
|
+
readonly EmailOTP: ("sso" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("unknown" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("password" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("saml" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("oauth" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & zod__default.core.$brand<typeof AuthMethodBrand>);
|
|
37
|
+
readonly OAuth: ("sso" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("unknown" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("password" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("saml" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("oauth" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & zod__default.core.$brand<typeof AuthMethodBrand>);
|
|
38
|
+
readonly SSO: ("sso" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("unknown" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("password" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("saml" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("oauth" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & zod__default.core.$brand<typeof AuthMethodBrand>);
|
|
39
|
+
readonly SAML: ("sso" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("unknown" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("password" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("saml" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("oauth" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & zod__default.core.$brand<typeof AuthMethodBrand>);
|
|
40
|
+
readonly Unknown: ("sso" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("unknown" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("password" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("saml" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("oauth" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & zod__default.core.$brand<typeof AuthMethodBrand>);
|
|
40
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* Reads the legacy `saml` AMR as `sso`, so sessions and application policies
|
|
44
|
+
* created before SAML and OIDC were unified keep matching each other.
|
|
45
|
+
*/
|
|
46
|
+
declare function normalizeAmr(amr: AMR): AMR;
|
|
41
47
|
declare const AMR: zod__default.core.$ZodBranded<zod__default.ZodEnum<{
|
|
42
48
|
readonly Pwd: "pwd";
|
|
43
49
|
readonly Otp: "otp";
|
|
44
50
|
readonly Oauth: "oauth";
|
|
45
51
|
readonly Sso: "sso";
|
|
52
|
+
/**
|
|
53
|
+
* @deprecated Issued to SSO sessions before SAML and OIDC were unified
|
|
54
|
+
* under `sso`. Still parsed so existing sessions and application policies
|
|
55
|
+
* remain valid, and read as `sso` (see `normalizeAmr`). Never issued.
|
|
56
|
+
*/
|
|
46
57
|
readonly Saml: "saml";
|
|
47
58
|
}>, typeof AMRBrand, "out">;
|
|
48
59
|
type AMR = zod__default.infer<typeof AMR>;
|
|
@@ -60,6 +71,11 @@ declare const AuthMethod: zod__default.core.$ZodBranded<zod__default.ZodEnum<{
|
|
|
60
71
|
readonly Password: "password";
|
|
61
72
|
readonly EmailOTP: "email_otp";
|
|
62
73
|
readonly OAuth: "oauth";
|
|
74
|
+
readonly SSO: "sso";
|
|
75
|
+
/**
|
|
76
|
+
* @deprecated Recorded on SSO sessions before SAML and OIDC were unified
|
|
77
|
+
* under `sso`. Kept so existing sessions still parse; never recorded.
|
|
78
|
+
*/
|
|
63
79
|
readonly SAML: "saml";
|
|
64
80
|
readonly Unknown: "unknown";
|
|
65
81
|
}>, typeof AuthMethodBrand, "out">;
|
|
@@ -520,6 +536,56 @@ declare class SessionAssuranceService {
|
|
|
520
536
|
completeOAuthStepUp(stepUpToken: string): Promise<OAuthCompleteStepUpResponse>;
|
|
521
537
|
}
|
|
522
538
|
|
|
539
|
+
/**
|
|
540
|
+
* Options for signing in with a social provider (Google or Microsoft).
|
|
541
|
+
*/
|
|
542
|
+
type SocialSignInOptions = {
|
|
543
|
+
/** The social identity provider to authenticate with. */
|
|
544
|
+
provider: 'google' | 'microsoft';
|
|
545
|
+
/** URL to redirect to after successful authentication. */
|
|
546
|
+
callbackURL: string;
|
|
547
|
+
/** URL to redirect to if authentication fails. Falls back to the API's default error page if not provided. */
|
|
548
|
+
errorCallbackURL?: string;
|
|
549
|
+
/** Email address to preselect at the provider, sent as the `login_hint` authorization parameter. */
|
|
550
|
+
loginHint?: string;
|
|
551
|
+
};
|
|
552
|
+
/**
|
|
553
|
+
* Options for signing in via Single Sign-On (SAML or OIDC).
|
|
554
|
+
*/
|
|
555
|
+
type SignInWithSsoOptions = {
|
|
556
|
+
/** The user's email address, used to resolve the correct SSO identity provider. */
|
|
557
|
+
email: string;
|
|
558
|
+
/** URL to redirect to after successful authentication. */
|
|
559
|
+
callbackURL: string;
|
|
560
|
+
/** URL to redirect to if authentication fails. Falls back to the API's default error page if not provided. */
|
|
561
|
+
errorCallbackURL?: string;
|
|
562
|
+
};
|
|
563
|
+
/**
|
|
564
|
+
* Options for signing in with email and password credentials.
|
|
565
|
+
*/
|
|
566
|
+
type SignInWithEmailAndPasswordOptions = {
|
|
567
|
+
/** The user's email address. */
|
|
568
|
+
email: string;
|
|
569
|
+
/** The user's password. */
|
|
570
|
+
password: string;
|
|
571
|
+
/** URL to redirect to after successful authentication. */
|
|
572
|
+
callbackURL: string;
|
|
573
|
+
};
|
|
574
|
+
/**
|
|
575
|
+
* Interactive login methods an environment can enable (`AUTH_LOGIN_METHODS`).
|
|
576
|
+
* Session-carrying mechanisms (JWT, API keys, application tokens) are not
|
|
577
|
+
* login methods.
|
|
578
|
+
*/
|
|
579
|
+
declare const LOGIN_METHODS: readonly ["password", "google", "microsoft", "sso", "otp"];
|
|
580
|
+
type LoginMethod = typeof LOGIN_METHODS[number];
|
|
581
|
+
/**
|
|
582
|
+
* Response of the public `GET /login-methods` endpoint.
|
|
583
|
+
*/
|
|
584
|
+
type LoginMethodsResponse = {
|
|
585
|
+
/** Login methods enabled in the environment, regardless of application. */
|
|
586
|
+
loginMethods: LoginMethod[];
|
|
587
|
+
};
|
|
588
|
+
|
|
523
589
|
declare const DEFAULT_SESSION_ASSURANCE_CONFIG: ApplicationSessionAssuranceConfig;
|
|
524
590
|
declare const DEFAULT_APPLICATION_CONFIG: {
|
|
525
591
|
version: 1;
|
|
@@ -565,6 +631,11 @@ type ListCandidateOrganizationsResponse = FullOrganization[];
|
|
|
565
631
|
type ApplicationAuthContextResponse = {
|
|
566
632
|
/** Minimal application identity shown in the hosted auth flow. */
|
|
567
633
|
application: Pick<Application, 'id' | 'name' | 'config'>;
|
|
634
|
+
/**
|
|
635
|
+
* Login methods usable for this application: the environment allowlist
|
|
636
|
+
* intersected with the application's accepted AMRs.
|
|
637
|
+
*/
|
|
638
|
+
loginMethods: LoginMethod[];
|
|
568
639
|
};
|
|
569
640
|
/**
|
|
570
641
|
* Response returned when starting an authorization flow.
|
|
@@ -3552,6 +3623,23 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
3552
3623
|
}>;
|
|
3553
3624
|
};
|
|
3554
3625
|
};
|
|
3626
|
+
} | {
|
|
3627
|
+
id: "login-methods";
|
|
3628
|
+
getActions: ($fetch: better_auth_client.BetterFetch) => {
|
|
3629
|
+
loginMethods: {
|
|
3630
|
+
get: () => Promise<{
|
|
3631
|
+
data: null;
|
|
3632
|
+
error: {
|
|
3633
|
+
message?: string | undefined;
|
|
3634
|
+
status: number;
|
|
3635
|
+
statusText: string;
|
|
3636
|
+
};
|
|
3637
|
+
} | {
|
|
3638
|
+
data: LoginMethodsResponse;
|
|
3639
|
+
error: null;
|
|
3640
|
+
}>;
|
|
3641
|
+
};
|
|
3642
|
+
};
|
|
3555
3643
|
} | {
|
|
3556
3644
|
id: "email-otp";
|
|
3557
3645
|
version: string;
|
|
@@ -5765,46 +5853,10 @@ declare class OrganizationService {
|
|
|
5765
5853
|
removeTeamMember(teamId: string, userId: string): Promise<void>;
|
|
5766
5854
|
}
|
|
5767
5855
|
|
|
5768
|
-
/**
|
|
5769
|
-
* Options for signing in with a social provider (Google or Microsoft).
|
|
5770
|
-
*/
|
|
5771
|
-
type SocialSignInOptions = {
|
|
5772
|
-
/** The social identity provider to authenticate with. */
|
|
5773
|
-
provider: 'google' | 'microsoft';
|
|
5774
|
-
/** URL to redirect to after successful authentication. */
|
|
5775
|
-
callbackURL: string;
|
|
5776
|
-
/** URL to redirect to if authentication fails. Falls back to the API's default error page if not provided. */
|
|
5777
|
-
errorCallbackURL?: string;
|
|
5778
|
-
/** Email address to preselect at the provider, sent as the `login_hint` authorization parameter. */
|
|
5779
|
-
loginHint?: string;
|
|
5780
|
-
};
|
|
5781
|
-
/**
|
|
5782
|
-
* Options for signing in via SAML Single Sign-On.
|
|
5783
|
-
*/
|
|
5784
|
-
type SignInWithSamlOptions = {
|
|
5785
|
-
/** The user's email address, used to resolve the correct SAML identity provider. */
|
|
5786
|
-
email: string;
|
|
5787
|
-
/** URL to redirect to after successful authentication. */
|
|
5788
|
-
callbackURL: string;
|
|
5789
|
-
/** URL to redirect to if authentication fails. Falls back to the API's default error page if not provided. */
|
|
5790
|
-
errorCallbackURL?: string;
|
|
5791
|
-
};
|
|
5792
|
-
/**
|
|
5793
|
-
* Options for signing in with email and password credentials.
|
|
5794
|
-
*/
|
|
5795
|
-
type SignInWithEmailAndPasswordOptions = {
|
|
5796
|
-
/** The user's email address. */
|
|
5797
|
-
email: string;
|
|
5798
|
-
/** The user's password. */
|
|
5799
|
-
password: string;
|
|
5800
|
-
/** URL to redirect to after successful authentication. */
|
|
5801
|
-
callbackURL: string;
|
|
5802
|
-
};
|
|
5803
|
-
|
|
5804
5856
|
/**
|
|
5805
5857
|
* Service for managing user authentication sessions.
|
|
5806
5858
|
*
|
|
5807
|
-
* Provides methods for signing in with various providers (social,
|
|
5859
|
+
* Provides methods for signing in with various providers (social, SSO, email/password),
|
|
5808
5860
|
* signing out, and password reset functionality.
|
|
5809
5861
|
*/
|
|
5810
5862
|
declare class SessionService {
|
|
@@ -5871,6 +5923,13 @@ declare class SessionService {
|
|
|
5871
5923
|
getToken(): Promise<{
|
|
5872
5924
|
token: string;
|
|
5873
5925
|
}>;
|
|
5926
|
+
/**
|
|
5927
|
+
* Lists the login methods enabled in the environment. Public; safe to call
|
|
5928
|
+
* before authentication to decide which sign-in options to render.
|
|
5929
|
+
*
|
|
5930
|
+
* @returns The enabled login methods
|
|
5931
|
+
*/
|
|
5932
|
+
getLoginMethods(): Promise<("sso" | "google" | "microsoft" | "password" | "otp")[]>;
|
|
5874
5933
|
/**
|
|
5875
5934
|
* Initiates social authentication flow with Google or Microsoft.
|
|
5876
5935
|
*
|
|
@@ -5885,17 +5944,18 @@ declare class SessionService {
|
|
|
5885
5944
|
*/
|
|
5886
5945
|
signInWithSocialProvider({ provider, callbackURL, errorCallbackURL, loginHint, }: SocialSignInOptions): Promise<void>;
|
|
5887
5946
|
/**
|
|
5888
|
-
* Initiates
|
|
5947
|
+
* Initiates the Single Sign-On authentication flow. The provider resolved
|
|
5948
|
+
* from the email's domain determines whether SAML or OIDC is used.
|
|
5889
5949
|
*
|
|
5890
|
-
* @param options -
|
|
5891
|
-
* @param options.email - User's email to determine the
|
|
5950
|
+
* @param options - SSO sign-in configuration
|
|
5951
|
+
* @param options.email - User's email to determine the SSO provider
|
|
5892
5952
|
* @param options.callbackURL - URL to redirect to after successful authentication
|
|
5893
5953
|
* @param options.errorCallbackURL - URL to redirect to on error
|
|
5894
5954
|
*
|
|
5895
5955
|
* @throws {EmailRequired} When email is not provided
|
|
5896
5956
|
* @throws {InvalidCallbackURL} When callback URLs are malformed
|
|
5897
5957
|
*/
|
|
5898
|
-
|
|
5958
|
+
signInWithSso({ email, callbackURL, errorCallbackURL, }: SignInWithSsoOptions): Promise<void>;
|
|
5899
5959
|
/**
|
|
5900
5960
|
* Authenticates a user with email and password credentials.
|
|
5901
5961
|
*
|
|
@@ -6381,5 +6441,5 @@ declare function validateToken(token: string, apiUrl: string): Promise<boolean>;
|
|
|
6381
6441
|
*/
|
|
6382
6442
|
declare function extractTokenPayload(token: string): DecodedJWTPayload;
|
|
6383
6443
|
|
|
6384
|
-
export { AAL, AALBrand, AALs, ACR, ACRBrand, ACRs, AMR, AMRBrand, AMRs, ApiKeyMetadata, ApplicationConfig, ApplicationError, ApplicationSessionAssuranceConfig, ApplicationSessionAssuranceError, ApplicationTokenStorage, AuthClient, AuthMethod, AuthMethodBrand, AuthMethods, AuthorizationFlowError, DEFAULT_APPLICATION_CONFIG, DEFAULT_JWT_ASSURANCE, DEFAULT_SESSION_ASSURANCE_CONFIG, DeviceAccessDeniedError, DeviceAuthorizationPendingError, DeviceAuthorizationSlowDownError, DeviceCodeExpiredError, DeviceTransientServerError, EmailOTPService, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, JWTPayload, JWTPayloadAssurance, JWTPayloadUser, JWTPayloadWorkspace, OAuthBeginStepUpResponse, OAuthCompleteStepUpResponse, OAuthStepUpProvider, RefreshTokenExpiredError, Roles, SENSITIVE_ACTION_ASSURANCE_POLICY, STEP_UP_MAX_AGE_SECONDS, SendOtpResponse, SessionAssurancePolicy, SessionAssuranceRequiredError, SessionAssuranceRequiredPayload, SessionAssuranceResponse, SessionAssuranceService, StepUpOption, UserNotLoggedInError, ac, assuranceFields, canStepUpWithAmr, createAPIClient, extractTokenPayload, getAalRank, invitationAdditionalFields, isAssuranceSufficientForPolicy, isSessionAssuranceSufficient, isTokenExpired, memberAdditionalFields, mergeStepUpAssurance, organizationAdditionalFields, parseSessionAssuranceRequiredPayload, rolesAccessControl, sessionAssurancePluginClient, userAdditionalFields, validateToken };
|
|
6385
|
-
export type { APIClient, AcceptInvitationResult, AdminApplication, AdminApplicationEntitlement, AdminApplicationEntitlementRecord, AdminApplicationIdentity, AdminApplicationMember, AdminApplicationOrganization, AdminApplicationRecord, AdminApplicationRole, AdminApplicationSecret, AdminEntitlementRule, AdminEntitlementRuleType, AdminEntitlementWithRules, AdminMember, AdminOrganization, AdminOrganizationApplication, AdminOrganizationMember, AdminOrganizationMemberApplication, AdminOrganizationMemberRecord, AdminOrganizationMemberTeam, AdminOrganizationSummary, AdminOrganizationTeam, AdminOrganizationTeamRecord, AdminUser, AdminUserAccess, AdminUserAccessApplication, AdminUserAccessOrganization, AdminUserAccessTeam, AdminUserInvitation, AdminUserOrganization, ApiKey, ApiKeyWithoutSecret, Application, ApplicationAuthContextResponse, ApplicationTokenStorageOptions, AssuranceFields, BaseOrganization, BeginOAuthStepUpParams, BillingMode, ClientCredentialsGrant, ClientCredentialsTokenResponse, CompleteAuthorizationFlowResponse, CreateAdminApplicationEntitlementOptions, CreateAdminApplicationOptions, CreateAdminApplicationRoleOptions, CreateAdminApplicationSecretOptions, CreateAdminOrganizationOptions, CreateAdminOrganizationTeamOptions, CreateApiKeyPayload, CreateTeamPayload, CreatedAdminApplicationSecret, DecodedJWTPayload, DeleteAdminOrganizationTeamOptions, DeviceAuthorizationActionResponse, DeviceAuthorizationContextResponse, DeviceAuthorizationResponse, DeviceContextApplication, EmailOTPSignInOptions, FullOrganization, GetAdminOrganizationOptions, GetAdminOrganizationsSummaryOptions, GetTokenOptions, Invitation, InvitationPasswordSetupResult, InvitationSignupStatus, InviteAdminOrganizationUsersOptions, InviteAdminOrganizationUsersResult, InviteUserToOrganizationOptions, JWTPayloadData, ListAdminApplicationsOptions, ListAdminApplicationsResult, ListAdminOrganizationMembersOptions, ListAdminOrganizationMembersResult, ListAdminOrganizationTeamsOptions, ListAdminOrganizationTeamsResult, ListAdminOrganizationsOptions, ListAdminOrganizationsResult, ListAdminUsersOptions, ListAdminUsersResult, ListCandidateOrganizationsResponse, ListMembersOptions, ListOrganizationsOptions, ListOrganizationsWithRoleOptions, Member, NoncePayloadResponse, ExtendedOrganization as Organization, OrganizationSettings, OrganizationWithRole, RemoveAdminMemberOptions, RemoveUserFromOrganizationOptions, ResendAdminInviteOptions, Role, SendVerificationOTPOptions, Session, SessionAssuranceActions, SessionData, SetAdminEntitlementRulesOptions, SetAdminUserApplicationRoleOptions, SetAdminUserTeamOptions, SignInWithEmailAndPasswordOptions,
|
|
6444
|
+
export { AAL, AALBrand, AALs, ACR, ACRBrand, ACRs, AMR, AMRBrand, AMRs, ApiKeyMetadata, ApplicationConfig, ApplicationError, ApplicationSessionAssuranceConfig, ApplicationSessionAssuranceError, ApplicationTokenStorage, AuthClient, AuthMethod, AuthMethodBrand, AuthMethods, AuthorizationFlowError, DEFAULT_APPLICATION_CONFIG, DEFAULT_JWT_ASSURANCE, DEFAULT_SESSION_ASSURANCE_CONFIG, DeviceAccessDeniedError, DeviceAuthorizationPendingError, DeviceAuthorizationSlowDownError, DeviceCodeExpiredError, DeviceTransientServerError, EmailOTPService, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, JWTPayload, JWTPayloadAssurance, JWTPayloadUser, JWTPayloadWorkspace, LOGIN_METHODS, OAuthBeginStepUpResponse, OAuthCompleteStepUpResponse, OAuthStepUpProvider, RefreshTokenExpiredError, Roles, SENSITIVE_ACTION_ASSURANCE_POLICY, STEP_UP_MAX_AGE_SECONDS, SendOtpResponse, SessionAssurancePolicy, SessionAssuranceRequiredError, SessionAssuranceRequiredPayload, SessionAssuranceResponse, SessionAssuranceService, StepUpOption, UserNotLoggedInError, ac, assuranceFields, canStepUpWithAmr, createAPIClient, extractTokenPayload, getAalRank, invitationAdditionalFields, isAssuranceSufficientForPolicy, isSessionAssuranceSufficient, isTokenExpired, memberAdditionalFields, mergeStepUpAssurance, normalizeAmr, organizationAdditionalFields, parseSessionAssuranceRequiredPayload, rolesAccessControl, sessionAssurancePluginClient, userAdditionalFields, validateToken };
|
|
6445
|
+
export type { APIClient, AcceptInvitationResult, AdminApplication, AdminApplicationEntitlement, AdminApplicationEntitlementRecord, AdminApplicationIdentity, AdminApplicationMember, AdminApplicationOrganization, AdminApplicationRecord, AdminApplicationRole, AdminApplicationSecret, AdminEntitlementRule, AdminEntitlementRuleType, AdminEntitlementWithRules, AdminMember, AdminOrganization, AdminOrganizationApplication, AdminOrganizationMember, AdminOrganizationMemberApplication, AdminOrganizationMemberRecord, AdminOrganizationMemberTeam, AdminOrganizationSummary, AdminOrganizationTeam, AdminOrganizationTeamRecord, AdminUser, AdminUserAccess, AdminUserAccessApplication, AdminUserAccessOrganization, AdminUserAccessTeam, AdminUserInvitation, AdminUserOrganization, ApiKey, ApiKeyWithoutSecret, Application, ApplicationAuthContextResponse, ApplicationTokenStorageOptions, AssuranceFields, BaseOrganization, BeginOAuthStepUpParams, BillingMode, ClientCredentialsGrant, ClientCredentialsTokenResponse, CompleteAuthorizationFlowResponse, CreateAdminApplicationEntitlementOptions, CreateAdminApplicationOptions, CreateAdminApplicationRoleOptions, CreateAdminApplicationSecretOptions, CreateAdminOrganizationOptions, CreateAdminOrganizationTeamOptions, CreateApiKeyPayload, CreateTeamPayload, CreatedAdminApplicationSecret, DecodedJWTPayload, DeleteAdminOrganizationTeamOptions, DeviceAuthorizationActionResponse, DeviceAuthorizationContextResponse, DeviceAuthorizationResponse, DeviceContextApplication, EmailOTPSignInOptions, FullOrganization, GetAdminOrganizationOptions, GetAdminOrganizationsSummaryOptions, GetTokenOptions, Invitation, InvitationPasswordSetupResult, InvitationSignupStatus, InviteAdminOrganizationUsersOptions, InviteAdminOrganizationUsersResult, InviteUserToOrganizationOptions, JWTPayloadData, ListAdminApplicationsOptions, ListAdminApplicationsResult, ListAdminOrganizationMembersOptions, ListAdminOrganizationMembersResult, ListAdminOrganizationTeamsOptions, ListAdminOrganizationTeamsResult, ListAdminOrganizationsOptions, ListAdminOrganizationsResult, ListAdminUsersOptions, ListAdminUsersResult, ListCandidateOrganizationsResponse, ListMembersOptions, ListOrganizationsOptions, ListOrganizationsWithRoleOptions, LoginMethod, LoginMethodsResponse, Member, NoncePayloadResponse, ExtendedOrganization as Organization, OrganizationSettings, OrganizationWithRole, RemoveAdminMemberOptions, RemoveUserFromOrganizationOptions, ResendAdminInviteOptions, Role, SendVerificationOTPOptions, Session, SessionAssuranceActions, SessionData, SetAdminEntitlementRulesOptions, SetAdminUserApplicationRoleOptions, SetAdminUserTeamOptions, SignInWithEmailAndPasswordOptions, SignInWithSsoOptions, SocialSignInOptions, StartAuthorizationFlowResponse, Strict, Team, TeamMember, TeamMembersResponse, UpdateAdminApplicationRoleOptions, UpdateAdminEntitlementOptions, UpdateAdminMemberRoleOptions, UpdateAdminOrganizationOptions, UpdateAdminOrganizationTeamOptions, UpdateApiKeyPayload, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload, User, UserProfile, WhoAmIInclude, WhoAmIOptions, WhoAmIOrganization, WhoAmIResponse };
|
package/dist/index.d.ts
CHANGED
|
@@ -32,17 +32,28 @@ declare const ACRs: {
|
|
|
32
32
|
readonly Unspecified: "urn:tela:auth:unspecified" & zod__default.core.$brand<typeof ACRBrand>;
|
|
33
33
|
};
|
|
34
34
|
declare const AuthMethods: {
|
|
35
|
-
readonly Password: ("unknown" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("password" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("saml" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("oauth" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & zod__default.core.$brand<typeof AuthMethodBrand>);
|
|
36
|
-
readonly EmailOTP: ("unknown" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("password" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("saml" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("oauth" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & zod__default.core.$brand<typeof AuthMethodBrand>);
|
|
37
|
-
readonly OAuth: ("unknown" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("password" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("saml" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("oauth" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & zod__default.core.$brand<typeof AuthMethodBrand>);
|
|
38
|
-
readonly
|
|
39
|
-
readonly
|
|
35
|
+
readonly Password: ("sso" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("unknown" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("password" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("saml" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("oauth" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & zod__default.core.$brand<typeof AuthMethodBrand>);
|
|
36
|
+
readonly EmailOTP: ("sso" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("unknown" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("password" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("saml" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("oauth" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & zod__default.core.$brand<typeof AuthMethodBrand>);
|
|
37
|
+
readonly OAuth: ("sso" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("unknown" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("password" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("saml" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("oauth" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & zod__default.core.$brand<typeof AuthMethodBrand>);
|
|
38
|
+
readonly SSO: ("sso" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("unknown" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("password" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("saml" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("oauth" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & zod__default.core.$brand<typeof AuthMethodBrand>);
|
|
39
|
+
readonly SAML: ("sso" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("unknown" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("password" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("saml" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("oauth" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & zod__default.core.$brand<typeof AuthMethodBrand>);
|
|
40
|
+
readonly Unknown: ("sso" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("unknown" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("password" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("saml" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("oauth" & zod__default.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & zod__default.core.$brand<typeof AuthMethodBrand>);
|
|
40
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* Reads the legacy `saml` AMR as `sso`, so sessions and application policies
|
|
44
|
+
* created before SAML and OIDC were unified keep matching each other.
|
|
45
|
+
*/
|
|
46
|
+
declare function normalizeAmr(amr: AMR): AMR;
|
|
41
47
|
declare const AMR: zod__default.core.$ZodBranded<zod__default.ZodEnum<{
|
|
42
48
|
readonly Pwd: "pwd";
|
|
43
49
|
readonly Otp: "otp";
|
|
44
50
|
readonly Oauth: "oauth";
|
|
45
51
|
readonly Sso: "sso";
|
|
52
|
+
/**
|
|
53
|
+
* @deprecated Issued to SSO sessions before SAML and OIDC were unified
|
|
54
|
+
* under `sso`. Still parsed so existing sessions and application policies
|
|
55
|
+
* remain valid, and read as `sso` (see `normalizeAmr`). Never issued.
|
|
56
|
+
*/
|
|
46
57
|
readonly Saml: "saml";
|
|
47
58
|
}>, typeof AMRBrand, "out">;
|
|
48
59
|
type AMR = zod__default.infer<typeof AMR>;
|
|
@@ -60,6 +71,11 @@ declare const AuthMethod: zod__default.core.$ZodBranded<zod__default.ZodEnum<{
|
|
|
60
71
|
readonly Password: "password";
|
|
61
72
|
readonly EmailOTP: "email_otp";
|
|
62
73
|
readonly OAuth: "oauth";
|
|
74
|
+
readonly SSO: "sso";
|
|
75
|
+
/**
|
|
76
|
+
* @deprecated Recorded on SSO sessions before SAML and OIDC were unified
|
|
77
|
+
* under `sso`. Kept so existing sessions still parse; never recorded.
|
|
78
|
+
*/
|
|
63
79
|
readonly SAML: "saml";
|
|
64
80
|
readonly Unknown: "unknown";
|
|
65
81
|
}>, typeof AuthMethodBrand, "out">;
|
|
@@ -520,6 +536,56 @@ declare class SessionAssuranceService {
|
|
|
520
536
|
completeOAuthStepUp(stepUpToken: string): Promise<OAuthCompleteStepUpResponse>;
|
|
521
537
|
}
|
|
522
538
|
|
|
539
|
+
/**
|
|
540
|
+
* Options for signing in with a social provider (Google or Microsoft).
|
|
541
|
+
*/
|
|
542
|
+
type SocialSignInOptions = {
|
|
543
|
+
/** The social identity provider to authenticate with. */
|
|
544
|
+
provider: 'google' | 'microsoft';
|
|
545
|
+
/** URL to redirect to after successful authentication. */
|
|
546
|
+
callbackURL: string;
|
|
547
|
+
/** URL to redirect to if authentication fails. Falls back to the API's default error page if not provided. */
|
|
548
|
+
errorCallbackURL?: string;
|
|
549
|
+
/** Email address to preselect at the provider, sent as the `login_hint` authorization parameter. */
|
|
550
|
+
loginHint?: string;
|
|
551
|
+
};
|
|
552
|
+
/**
|
|
553
|
+
* Options for signing in via Single Sign-On (SAML or OIDC).
|
|
554
|
+
*/
|
|
555
|
+
type SignInWithSsoOptions = {
|
|
556
|
+
/** The user's email address, used to resolve the correct SSO identity provider. */
|
|
557
|
+
email: string;
|
|
558
|
+
/** URL to redirect to after successful authentication. */
|
|
559
|
+
callbackURL: string;
|
|
560
|
+
/** URL to redirect to if authentication fails. Falls back to the API's default error page if not provided. */
|
|
561
|
+
errorCallbackURL?: string;
|
|
562
|
+
};
|
|
563
|
+
/**
|
|
564
|
+
* Options for signing in with email and password credentials.
|
|
565
|
+
*/
|
|
566
|
+
type SignInWithEmailAndPasswordOptions = {
|
|
567
|
+
/** The user's email address. */
|
|
568
|
+
email: string;
|
|
569
|
+
/** The user's password. */
|
|
570
|
+
password: string;
|
|
571
|
+
/** URL to redirect to after successful authentication. */
|
|
572
|
+
callbackURL: string;
|
|
573
|
+
};
|
|
574
|
+
/**
|
|
575
|
+
* Interactive login methods an environment can enable (`AUTH_LOGIN_METHODS`).
|
|
576
|
+
* Session-carrying mechanisms (JWT, API keys, application tokens) are not
|
|
577
|
+
* login methods.
|
|
578
|
+
*/
|
|
579
|
+
declare const LOGIN_METHODS: readonly ["password", "google", "microsoft", "sso", "otp"];
|
|
580
|
+
type LoginMethod = typeof LOGIN_METHODS[number];
|
|
581
|
+
/**
|
|
582
|
+
* Response of the public `GET /login-methods` endpoint.
|
|
583
|
+
*/
|
|
584
|
+
type LoginMethodsResponse = {
|
|
585
|
+
/** Login methods enabled in the environment, regardless of application. */
|
|
586
|
+
loginMethods: LoginMethod[];
|
|
587
|
+
};
|
|
588
|
+
|
|
523
589
|
declare const DEFAULT_SESSION_ASSURANCE_CONFIG: ApplicationSessionAssuranceConfig;
|
|
524
590
|
declare const DEFAULT_APPLICATION_CONFIG: {
|
|
525
591
|
version: 1;
|
|
@@ -565,6 +631,11 @@ type ListCandidateOrganizationsResponse = FullOrganization[];
|
|
|
565
631
|
type ApplicationAuthContextResponse = {
|
|
566
632
|
/** Minimal application identity shown in the hosted auth flow. */
|
|
567
633
|
application: Pick<Application, 'id' | 'name' | 'config'>;
|
|
634
|
+
/**
|
|
635
|
+
* Login methods usable for this application: the environment allowlist
|
|
636
|
+
* intersected with the application's accepted AMRs.
|
|
637
|
+
*/
|
|
638
|
+
loginMethods: LoginMethod[];
|
|
568
639
|
};
|
|
569
640
|
/**
|
|
570
641
|
* Response returned when starting an authorization flow.
|
|
@@ -3552,6 +3623,23 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
3552
3623
|
}>;
|
|
3553
3624
|
};
|
|
3554
3625
|
};
|
|
3626
|
+
} | {
|
|
3627
|
+
id: "login-methods";
|
|
3628
|
+
getActions: ($fetch: better_auth_client.BetterFetch) => {
|
|
3629
|
+
loginMethods: {
|
|
3630
|
+
get: () => Promise<{
|
|
3631
|
+
data: null;
|
|
3632
|
+
error: {
|
|
3633
|
+
message?: string | undefined;
|
|
3634
|
+
status: number;
|
|
3635
|
+
statusText: string;
|
|
3636
|
+
};
|
|
3637
|
+
} | {
|
|
3638
|
+
data: LoginMethodsResponse;
|
|
3639
|
+
error: null;
|
|
3640
|
+
}>;
|
|
3641
|
+
};
|
|
3642
|
+
};
|
|
3555
3643
|
} | {
|
|
3556
3644
|
id: "email-otp";
|
|
3557
3645
|
version: string;
|
|
@@ -5765,46 +5853,10 @@ declare class OrganizationService {
|
|
|
5765
5853
|
removeTeamMember(teamId: string, userId: string): Promise<void>;
|
|
5766
5854
|
}
|
|
5767
5855
|
|
|
5768
|
-
/**
|
|
5769
|
-
* Options for signing in with a social provider (Google or Microsoft).
|
|
5770
|
-
*/
|
|
5771
|
-
type SocialSignInOptions = {
|
|
5772
|
-
/** The social identity provider to authenticate with. */
|
|
5773
|
-
provider: 'google' | 'microsoft';
|
|
5774
|
-
/** URL to redirect to after successful authentication. */
|
|
5775
|
-
callbackURL: string;
|
|
5776
|
-
/** URL to redirect to if authentication fails. Falls back to the API's default error page if not provided. */
|
|
5777
|
-
errorCallbackURL?: string;
|
|
5778
|
-
/** Email address to preselect at the provider, sent as the `login_hint` authorization parameter. */
|
|
5779
|
-
loginHint?: string;
|
|
5780
|
-
};
|
|
5781
|
-
/**
|
|
5782
|
-
* Options for signing in via SAML Single Sign-On.
|
|
5783
|
-
*/
|
|
5784
|
-
type SignInWithSamlOptions = {
|
|
5785
|
-
/** The user's email address, used to resolve the correct SAML identity provider. */
|
|
5786
|
-
email: string;
|
|
5787
|
-
/** URL to redirect to after successful authentication. */
|
|
5788
|
-
callbackURL: string;
|
|
5789
|
-
/** URL to redirect to if authentication fails. Falls back to the API's default error page if not provided. */
|
|
5790
|
-
errorCallbackURL?: string;
|
|
5791
|
-
};
|
|
5792
|
-
/**
|
|
5793
|
-
* Options for signing in with email and password credentials.
|
|
5794
|
-
*/
|
|
5795
|
-
type SignInWithEmailAndPasswordOptions = {
|
|
5796
|
-
/** The user's email address. */
|
|
5797
|
-
email: string;
|
|
5798
|
-
/** The user's password. */
|
|
5799
|
-
password: string;
|
|
5800
|
-
/** URL to redirect to after successful authentication. */
|
|
5801
|
-
callbackURL: string;
|
|
5802
|
-
};
|
|
5803
|
-
|
|
5804
5856
|
/**
|
|
5805
5857
|
* Service for managing user authentication sessions.
|
|
5806
5858
|
*
|
|
5807
|
-
* Provides methods for signing in with various providers (social,
|
|
5859
|
+
* Provides methods for signing in with various providers (social, SSO, email/password),
|
|
5808
5860
|
* signing out, and password reset functionality.
|
|
5809
5861
|
*/
|
|
5810
5862
|
declare class SessionService {
|
|
@@ -5871,6 +5923,13 @@ declare class SessionService {
|
|
|
5871
5923
|
getToken(): Promise<{
|
|
5872
5924
|
token: string;
|
|
5873
5925
|
}>;
|
|
5926
|
+
/**
|
|
5927
|
+
* Lists the login methods enabled in the environment. Public; safe to call
|
|
5928
|
+
* before authentication to decide which sign-in options to render.
|
|
5929
|
+
*
|
|
5930
|
+
* @returns The enabled login methods
|
|
5931
|
+
*/
|
|
5932
|
+
getLoginMethods(): Promise<("sso" | "google" | "microsoft" | "password" | "otp")[]>;
|
|
5874
5933
|
/**
|
|
5875
5934
|
* Initiates social authentication flow with Google or Microsoft.
|
|
5876
5935
|
*
|
|
@@ -5885,17 +5944,18 @@ declare class SessionService {
|
|
|
5885
5944
|
*/
|
|
5886
5945
|
signInWithSocialProvider({ provider, callbackURL, errorCallbackURL, loginHint, }: SocialSignInOptions): Promise<void>;
|
|
5887
5946
|
/**
|
|
5888
|
-
* Initiates
|
|
5947
|
+
* Initiates the Single Sign-On authentication flow. The provider resolved
|
|
5948
|
+
* from the email's domain determines whether SAML or OIDC is used.
|
|
5889
5949
|
*
|
|
5890
|
-
* @param options -
|
|
5891
|
-
* @param options.email - User's email to determine the
|
|
5950
|
+
* @param options - SSO sign-in configuration
|
|
5951
|
+
* @param options.email - User's email to determine the SSO provider
|
|
5892
5952
|
* @param options.callbackURL - URL to redirect to after successful authentication
|
|
5893
5953
|
* @param options.errorCallbackURL - URL to redirect to on error
|
|
5894
5954
|
*
|
|
5895
5955
|
* @throws {EmailRequired} When email is not provided
|
|
5896
5956
|
* @throws {InvalidCallbackURL} When callback URLs are malformed
|
|
5897
5957
|
*/
|
|
5898
|
-
|
|
5958
|
+
signInWithSso({ email, callbackURL, errorCallbackURL, }: SignInWithSsoOptions): Promise<void>;
|
|
5899
5959
|
/**
|
|
5900
5960
|
* Authenticates a user with email and password credentials.
|
|
5901
5961
|
*
|
|
@@ -6381,5 +6441,5 @@ declare function validateToken(token: string, apiUrl: string): Promise<boolean>;
|
|
|
6381
6441
|
*/
|
|
6382
6442
|
declare function extractTokenPayload(token: string): DecodedJWTPayload;
|
|
6383
6443
|
|
|
6384
|
-
export { AAL, AALBrand, AALs, ACR, ACRBrand, ACRs, AMR, AMRBrand, AMRs, ApiKeyMetadata, ApplicationConfig, ApplicationError, ApplicationSessionAssuranceConfig, ApplicationSessionAssuranceError, ApplicationTokenStorage, AuthClient, AuthMethod, AuthMethodBrand, AuthMethods, AuthorizationFlowError, DEFAULT_APPLICATION_CONFIG, DEFAULT_JWT_ASSURANCE, DEFAULT_SESSION_ASSURANCE_CONFIG, DeviceAccessDeniedError, DeviceAuthorizationPendingError, DeviceAuthorizationSlowDownError, DeviceCodeExpiredError, DeviceTransientServerError, EmailOTPService, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, JWTPayload, JWTPayloadAssurance, JWTPayloadUser, JWTPayloadWorkspace, OAuthBeginStepUpResponse, OAuthCompleteStepUpResponse, OAuthStepUpProvider, RefreshTokenExpiredError, Roles, SENSITIVE_ACTION_ASSURANCE_POLICY, STEP_UP_MAX_AGE_SECONDS, SendOtpResponse, SessionAssurancePolicy, SessionAssuranceRequiredError, SessionAssuranceRequiredPayload, SessionAssuranceResponse, SessionAssuranceService, StepUpOption, UserNotLoggedInError, ac, assuranceFields, canStepUpWithAmr, createAPIClient, extractTokenPayload, getAalRank, invitationAdditionalFields, isAssuranceSufficientForPolicy, isSessionAssuranceSufficient, isTokenExpired, memberAdditionalFields, mergeStepUpAssurance, organizationAdditionalFields, parseSessionAssuranceRequiredPayload, rolesAccessControl, sessionAssurancePluginClient, userAdditionalFields, validateToken };
|
|
6385
|
-
export type { APIClient, AcceptInvitationResult, AdminApplication, AdminApplicationEntitlement, AdminApplicationEntitlementRecord, AdminApplicationIdentity, AdminApplicationMember, AdminApplicationOrganization, AdminApplicationRecord, AdminApplicationRole, AdminApplicationSecret, AdminEntitlementRule, AdminEntitlementRuleType, AdminEntitlementWithRules, AdminMember, AdminOrganization, AdminOrganizationApplication, AdminOrganizationMember, AdminOrganizationMemberApplication, AdminOrganizationMemberRecord, AdminOrganizationMemberTeam, AdminOrganizationSummary, AdminOrganizationTeam, AdminOrganizationTeamRecord, AdminUser, AdminUserAccess, AdminUserAccessApplication, AdminUserAccessOrganization, AdminUserAccessTeam, AdminUserInvitation, AdminUserOrganization, ApiKey, ApiKeyWithoutSecret, Application, ApplicationAuthContextResponse, ApplicationTokenStorageOptions, AssuranceFields, BaseOrganization, BeginOAuthStepUpParams, BillingMode, ClientCredentialsGrant, ClientCredentialsTokenResponse, CompleteAuthorizationFlowResponse, CreateAdminApplicationEntitlementOptions, CreateAdminApplicationOptions, CreateAdminApplicationRoleOptions, CreateAdminApplicationSecretOptions, CreateAdminOrganizationOptions, CreateAdminOrganizationTeamOptions, CreateApiKeyPayload, CreateTeamPayload, CreatedAdminApplicationSecret, DecodedJWTPayload, DeleteAdminOrganizationTeamOptions, DeviceAuthorizationActionResponse, DeviceAuthorizationContextResponse, DeviceAuthorizationResponse, DeviceContextApplication, EmailOTPSignInOptions, FullOrganization, GetAdminOrganizationOptions, GetAdminOrganizationsSummaryOptions, GetTokenOptions, Invitation, InvitationPasswordSetupResult, InvitationSignupStatus, InviteAdminOrganizationUsersOptions, InviteAdminOrganizationUsersResult, InviteUserToOrganizationOptions, JWTPayloadData, ListAdminApplicationsOptions, ListAdminApplicationsResult, ListAdminOrganizationMembersOptions, ListAdminOrganizationMembersResult, ListAdminOrganizationTeamsOptions, ListAdminOrganizationTeamsResult, ListAdminOrganizationsOptions, ListAdminOrganizationsResult, ListAdminUsersOptions, ListAdminUsersResult, ListCandidateOrganizationsResponse, ListMembersOptions, ListOrganizationsOptions, ListOrganizationsWithRoleOptions, Member, NoncePayloadResponse, ExtendedOrganization as Organization, OrganizationSettings, OrganizationWithRole, RemoveAdminMemberOptions, RemoveUserFromOrganizationOptions, ResendAdminInviteOptions, Role, SendVerificationOTPOptions, Session, SessionAssuranceActions, SessionData, SetAdminEntitlementRulesOptions, SetAdminUserApplicationRoleOptions, SetAdminUserTeamOptions, SignInWithEmailAndPasswordOptions,
|
|
6444
|
+
export { AAL, AALBrand, AALs, ACR, ACRBrand, ACRs, AMR, AMRBrand, AMRs, ApiKeyMetadata, ApplicationConfig, ApplicationError, ApplicationSessionAssuranceConfig, ApplicationSessionAssuranceError, ApplicationTokenStorage, AuthClient, AuthMethod, AuthMethodBrand, AuthMethods, AuthorizationFlowError, DEFAULT_APPLICATION_CONFIG, DEFAULT_JWT_ASSURANCE, DEFAULT_SESSION_ASSURANCE_CONFIG, DeviceAccessDeniedError, DeviceAuthorizationPendingError, DeviceAuthorizationSlowDownError, DeviceCodeExpiredError, DeviceTransientServerError, EmailOTPService, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, JWTPayload, JWTPayloadAssurance, JWTPayloadUser, JWTPayloadWorkspace, LOGIN_METHODS, OAuthBeginStepUpResponse, OAuthCompleteStepUpResponse, OAuthStepUpProvider, RefreshTokenExpiredError, Roles, SENSITIVE_ACTION_ASSURANCE_POLICY, STEP_UP_MAX_AGE_SECONDS, SendOtpResponse, SessionAssurancePolicy, SessionAssuranceRequiredError, SessionAssuranceRequiredPayload, SessionAssuranceResponse, SessionAssuranceService, StepUpOption, UserNotLoggedInError, ac, assuranceFields, canStepUpWithAmr, createAPIClient, extractTokenPayload, getAalRank, invitationAdditionalFields, isAssuranceSufficientForPolicy, isSessionAssuranceSufficient, isTokenExpired, memberAdditionalFields, mergeStepUpAssurance, normalizeAmr, organizationAdditionalFields, parseSessionAssuranceRequiredPayload, rolesAccessControl, sessionAssurancePluginClient, userAdditionalFields, validateToken };
|
|
6445
|
+
export type { APIClient, AcceptInvitationResult, AdminApplication, AdminApplicationEntitlement, AdminApplicationEntitlementRecord, AdminApplicationIdentity, AdminApplicationMember, AdminApplicationOrganization, AdminApplicationRecord, AdminApplicationRole, AdminApplicationSecret, AdminEntitlementRule, AdminEntitlementRuleType, AdminEntitlementWithRules, AdminMember, AdminOrganization, AdminOrganizationApplication, AdminOrganizationMember, AdminOrganizationMemberApplication, AdminOrganizationMemberRecord, AdminOrganizationMemberTeam, AdminOrganizationSummary, AdminOrganizationTeam, AdminOrganizationTeamRecord, AdminUser, AdminUserAccess, AdminUserAccessApplication, AdminUserAccessOrganization, AdminUserAccessTeam, AdminUserInvitation, AdminUserOrganization, ApiKey, ApiKeyWithoutSecret, Application, ApplicationAuthContextResponse, ApplicationTokenStorageOptions, AssuranceFields, BaseOrganization, BeginOAuthStepUpParams, BillingMode, ClientCredentialsGrant, ClientCredentialsTokenResponse, CompleteAuthorizationFlowResponse, CreateAdminApplicationEntitlementOptions, CreateAdminApplicationOptions, CreateAdminApplicationRoleOptions, CreateAdminApplicationSecretOptions, CreateAdminOrganizationOptions, CreateAdminOrganizationTeamOptions, CreateApiKeyPayload, CreateTeamPayload, CreatedAdminApplicationSecret, DecodedJWTPayload, DeleteAdminOrganizationTeamOptions, DeviceAuthorizationActionResponse, DeviceAuthorizationContextResponse, DeviceAuthorizationResponse, DeviceContextApplication, EmailOTPSignInOptions, FullOrganization, GetAdminOrganizationOptions, GetAdminOrganizationsSummaryOptions, GetTokenOptions, Invitation, InvitationPasswordSetupResult, InvitationSignupStatus, InviteAdminOrganizationUsersOptions, InviteAdminOrganizationUsersResult, InviteUserToOrganizationOptions, JWTPayloadData, ListAdminApplicationsOptions, ListAdminApplicationsResult, ListAdminOrganizationMembersOptions, ListAdminOrganizationMembersResult, ListAdminOrganizationTeamsOptions, ListAdminOrganizationTeamsResult, ListAdminOrganizationsOptions, ListAdminOrganizationsResult, ListAdminUsersOptions, ListAdminUsersResult, ListCandidateOrganizationsResponse, ListMembersOptions, ListOrganizationsOptions, ListOrganizationsWithRoleOptions, LoginMethod, LoginMethodsResponse, Member, NoncePayloadResponse, ExtendedOrganization as Organization, OrganizationSettings, OrganizationWithRole, RemoveAdminMemberOptions, RemoveUserFromOrganizationOptions, ResendAdminInviteOptions, Role, SendVerificationOTPOptions, Session, SessionAssuranceActions, SessionData, SetAdminEntitlementRulesOptions, SetAdminUserApplicationRoleOptions, SetAdminUserTeamOptions, SignInWithEmailAndPasswordOptions, SignInWithSsoOptions, SocialSignInOptions, StartAuthorizationFlowResponse, Strict, Team, TeamMember, TeamMembersResponse, UpdateAdminApplicationRoleOptions, UpdateAdminEntitlementOptions, UpdateAdminMemberRoleOptions, UpdateAdminOrganizationOptions, UpdateAdminOrganizationTeamOptions, UpdateApiKeyPayload, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload, User, UserProfile, WhoAmIInclude, WhoAmIOptions, WhoAmIOrganization, WhoAmIResponse };
|
package/dist/index.mjs
CHANGED
|
@@ -21,7 +21,7 @@ function isTokenExpired(token, expiresInMs) {
|
|
|
21
21
|
return nowInSeconds > expirationTime;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
const version = "
|
|
24
|
+
const version = "2.0.0";
|
|
25
25
|
|
|
26
26
|
function parsedEnumValues(schema) {
|
|
27
27
|
return Object.fromEntries(
|
|
@@ -41,6 +41,11 @@ const AMR = z.enum({
|
|
|
41
41
|
Otp: "otp",
|
|
42
42
|
Oauth: "oauth",
|
|
43
43
|
Sso: "sso",
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated Issued to SSO sessions before SAML and OIDC were unified
|
|
46
|
+
* under `sso`. Still parsed so existing sessions and application policies
|
|
47
|
+
* remain valid, and read as `sso` (see `normalizeAmr`). Never issued.
|
|
48
|
+
*/
|
|
44
49
|
Saml: "saml"
|
|
45
50
|
}).brand(AMRBrand);
|
|
46
51
|
const AAL = z.enum({
|
|
@@ -55,6 +60,11 @@ const AuthMethod = z.enum({
|
|
|
55
60
|
Password: "password",
|
|
56
61
|
EmailOTP: "email_otp",
|
|
57
62
|
OAuth: "oauth",
|
|
63
|
+
SSO: "sso",
|
|
64
|
+
/**
|
|
65
|
+
* @deprecated Recorded on SSO sessions before SAML and OIDC were unified
|
|
66
|
+
* under `sso`. Kept so existing sessions still parse; never recorded.
|
|
67
|
+
*/
|
|
58
68
|
SAML: "saml",
|
|
59
69
|
Unknown: "unknown"
|
|
60
70
|
}).brand(AuthMethodBrand);
|
|
@@ -62,6 +72,9 @@ const AMRs = parsedEnumValues(AMR);
|
|
|
62
72
|
const AALs = parsedEnumValues(AAL);
|
|
63
73
|
const ACRs = parsedEnumValues(ACR);
|
|
64
74
|
const AuthMethods = parsedEnumValues(AuthMethod);
|
|
75
|
+
function normalizeAmr(amr) {
|
|
76
|
+
return amr === AMRs.Saml ? AMRs.Sso : amr;
|
|
77
|
+
}
|
|
65
78
|
const assuranceFields = {
|
|
66
79
|
authMethod: {
|
|
67
80
|
type: "string",
|
|
@@ -438,6 +451,21 @@ function sessionAssurancePluginClient() {
|
|
|
438
451
|
};
|
|
439
452
|
}
|
|
440
453
|
|
|
454
|
+
function loginMethodsPluginClient() {
|
|
455
|
+
return {
|
|
456
|
+
id: "login-methods",
|
|
457
|
+
getActions: ($fetch) => {
|
|
458
|
+
return {
|
|
459
|
+
loginMethods: {
|
|
460
|
+
get: async () => {
|
|
461
|
+
return await $fetch("/login-methods", { method: "GET" });
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
|
|
441
469
|
function createAPIClient(apiUrl, fetchOptions = {}) {
|
|
442
470
|
const serviceName = typeof process !== "undefined" ? process.env.SERVICE_NAME : "";
|
|
443
471
|
const userAgent = `auth-sdk:core:${version}${serviceName ? `@${serviceName}` : ""}`;
|
|
@@ -465,6 +493,7 @@ function createAPIClient(apiUrl, fetchOptions = {}) {
|
|
|
465
493
|
}),
|
|
466
494
|
applicationsPluginClient(),
|
|
467
495
|
sessionAssurancePluginClient(),
|
|
496
|
+
loginMethodsPluginClient(),
|
|
468
497
|
emailOTPClient()
|
|
469
498
|
],
|
|
470
499
|
fetchOptions: {
|
|
@@ -1201,7 +1230,8 @@ function isAssuranceSufficientForPolicy(assurance, policy, now = /* @__PURE__ */
|
|
|
1201
1230
|
if (!assurance.amr.length) {
|
|
1202
1231
|
return false;
|
|
1203
1232
|
}
|
|
1204
|
-
|
|
1233
|
+
const acceptedAmr = new Set(policy.acceptedAmr.map(normalizeAmr));
|
|
1234
|
+
if (!assurance.amr.some((amr) => acceptedAmr.has(normalizeAmr(amr)))) {
|
|
1205
1235
|
return false;
|
|
1206
1236
|
}
|
|
1207
1237
|
if (getAalRank(policy.minAal) >= getAalRank(AALs.Aal2)) {
|
|
@@ -1298,7 +1328,7 @@ const DEFAULT_SESSION_ASSURANCE_CONFIG = {
|
|
|
1298
1328
|
acceptedAmr: [
|
|
1299
1329
|
AMRs.Pwd,
|
|
1300
1330
|
AMRs.Oauth,
|
|
1301
|
-
AMRs.
|
|
1331
|
+
AMRs.Sso
|
|
1302
1332
|
],
|
|
1303
1333
|
minAal: AALs.Aal1
|
|
1304
1334
|
};
|
|
@@ -1307,7 +1337,7 @@ const DEFAULT_APPLICATION_CONFIG = {
|
|
|
1307
1337
|
sessionAssurance: DEFAULT_SESSION_ASSURANCE_CONFIG
|
|
1308
1338
|
};
|
|
1309
1339
|
const ApplicationSessionAssuranceConfig = z.object({
|
|
1310
|
-
acceptedAmr: AMR.array().optional().default(DEFAULT_SESSION_ASSURANCE_CONFIG.acceptedAmr),
|
|
1340
|
+
acceptedAmr: AMR.array().overwrite((amrs) => [...new Set(amrs.map(normalizeAmr))]).optional().default(DEFAULT_SESSION_ASSURANCE_CONFIG.acceptedAmr),
|
|
1311
1341
|
minAal: AAL.refine(
|
|
1312
1342
|
(aal) => aal !== AALs.Aal3,
|
|
1313
1343
|
"Application session assurance currently supports aal1 and aal2 policies"
|
|
@@ -1319,7 +1349,7 @@ const ApplicationConfig = z.object({
|
|
|
1319
1349
|
});
|
|
1320
1350
|
|
|
1321
1351
|
function allowsDefaultAmrPolicy(config) {
|
|
1322
|
-
const acceptedAmr = new Set(config.sessionAssurance.acceptedAmr);
|
|
1352
|
+
const acceptedAmr = new Set(config.sessionAssurance.acceptedAmr.map(normalizeAmr));
|
|
1323
1353
|
const defaultAcceptedAmr = DEFAULT_SESSION_ASSURANCE_CONFIG.acceptedAmr;
|
|
1324
1354
|
return config.sessionAssurance.minAal === DEFAULT_SESSION_ASSURANCE_CONFIG.minAal && defaultAcceptedAmr.every((amr) => acceptedAmr.has(amr));
|
|
1325
1355
|
}
|
|
@@ -1952,6 +1982,19 @@ class SessionService {
|
|
|
1952
1982
|
async getToken() {
|
|
1953
1983
|
return await this.client.token();
|
|
1954
1984
|
}
|
|
1985
|
+
/**
|
|
1986
|
+
* Lists the login methods enabled in the environment. Public; safe to call
|
|
1987
|
+
* before authentication to decide which sign-in options to render.
|
|
1988
|
+
*
|
|
1989
|
+
* @returns The enabled login methods
|
|
1990
|
+
*/
|
|
1991
|
+
async getLoginMethods() {
|
|
1992
|
+
const response = await this.client.loginMethods.get();
|
|
1993
|
+
if (!response.data) {
|
|
1994
|
+
throw new Error("No data returned from the API", { cause: response.error });
|
|
1995
|
+
}
|
|
1996
|
+
return response.data.loginMethods;
|
|
1997
|
+
}
|
|
1955
1998
|
/**
|
|
1956
1999
|
* Initiates social authentication flow with Google or Microsoft.
|
|
1957
2000
|
*
|
|
@@ -1988,17 +2031,18 @@ class SessionService {
|
|
|
1988
2031
|
});
|
|
1989
2032
|
}
|
|
1990
2033
|
/**
|
|
1991
|
-
* Initiates
|
|
2034
|
+
* Initiates the Single Sign-On authentication flow. The provider resolved
|
|
2035
|
+
* from the email's domain determines whether SAML or OIDC is used.
|
|
1992
2036
|
*
|
|
1993
|
-
* @param options -
|
|
1994
|
-
* @param options.email - User's email to determine the
|
|
2037
|
+
* @param options - SSO sign-in configuration
|
|
2038
|
+
* @param options.email - User's email to determine the SSO provider
|
|
1995
2039
|
* @param options.callbackURL - URL to redirect to after successful authentication
|
|
1996
2040
|
* @param options.errorCallbackURL - URL to redirect to on error
|
|
1997
2041
|
*
|
|
1998
2042
|
* @throws {EmailRequired} When email is not provided
|
|
1999
2043
|
* @throws {InvalidCallbackURL} When callback URLs are malformed
|
|
2000
2044
|
*/
|
|
2001
|
-
async
|
|
2045
|
+
async signInWithSso({
|
|
2002
2046
|
email,
|
|
2003
2047
|
callbackURL,
|
|
2004
2048
|
errorCallbackURL
|
|
@@ -2016,8 +2060,7 @@ class SessionService {
|
|
|
2016
2060
|
await this.client.signIn.sso({
|
|
2017
2061
|
email,
|
|
2018
2062
|
callbackURL,
|
|
2019
|
-
errorCallbackURL: errorCallbackURL ?? `${this.apiUrl}/error?callbackURL=${appUrl}
|
|
2020
|
-
providerType: "saml"
|
|
2063
|
+
errorCallbackURL: errorCallbackURL ?? `${this.apiUrl}/error?callbackURL=${appUrl}`
|
|
2021
2064
|
});
|
|
2022
2065
|
}
|
|
2023
2066
|
/**
|
|
@@ -2323,6 +2366,8 @@ const ApiKeyMetadata = z.object({
|
|
|
2323
2366
|
}).optional().nullable()
|
|
2324
2367
|
});
|
|
2325
2368
|
|
|
2369
|
+
const LOGIN_METHODS = ["password", "google", "microsoft", "sso", "otp"];
|
|
2370
|
+
|
|
2326
2371
|
class AuthClient {
|
|
2327
2372
|
/**
|
|
2328
2373
|
* Configured Better Auth client used by the public service wrappers.
|
|
@@ -2524,4 +2569,4 @@ function extractTokenPayload(token) {
|
|
|
2524
2569
|
return payload;
|
|
2525
2570
|
}
|
|
2526
2571
|
|
|
2527
|
-
export { AAL, AALBrand, AALs, ACR, ACRBrand, ACRs, AMR, AMRBrand, AMRs, ApiKeyMetadata, ApplicationConfig, ApplicationError, ApplicationSessionAssuranceConfig, ApplicationSessionAssuranceError, ApplicationTokenStorage, AuthClient, AuthMethod, AuthMethodBrand, AuthMethods, AuthorizationFlowError, DEFAULT_APPLICATION_CONFIG, DEFAULT_JWT_ASSURANCE, DEFAULT_SESSION_ASSURANCE_CONFIG, DeviceAccessDeniedError, DeviceAuthorizationPendingError, DeviceAuthorizationSlowDownError, DeviceCodeExpiredError, DeviceTransientServerError, EmailOTPService, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, JWTPayload, JWTPayloadAssurance, JWTPayloadUser, JWTPayloadWorkspace, OAuthStepUpProvider, RefreshTokenExpiredError, Roles, SENSITIVE_ACTION_ASSURANCE_POLICY, STEP_UP_MAX_AGE_SECONDS, SessionAssurancePolicy, SessionAssuranceRequiredError, SessionAssuranceRequiredPayload, SessionAssuranceService, StepUpOption, UserNotLoggedInError, ac, assuranceFields, canStepUpWithAmr, extractTokenPayload, getAalRank, invitationAdditionalFields, isAssuranceSufficientForPolicy, isSessionAssuranceSufficient, isTokenExpired, memberAdditionalFields, mergeStepUpAssurance, organizationAdditionalFields, parseSessionAssuranceRequiredPayload, rolesAccessControl, sessionAssurancePluginClient, userAdditionalFields, validateToken };
|
|
2572
|
+
export { AAL, AALBrand, AALs, ACR, ACRBrand, ACRs, AMR, AMRBrand, AMRs, ApiKeyMetadata, ApplicationConfig, ApplicationError, ApplicationSessionAssuranceConfig, ApplicationSessionAssuranceError, ApplicationTokenStorage, AuthClient, AuthMethod, AuthMethodBrand, AuthMethods, AuthorizationFlowError, DEFAULT_APPLICATION_CONFIG, DEFAULT_JWT_ASSURANCE, DEFAULT_SESSION_ASSURANCE_CONFIG, DeviceAccessDeniedError, DeviceAuthorizationPendingError, DeviceAuthorizationSlowDownError, DeviceCodeExpiredError, DeviceTransientServerError, EmailOTPService, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, JWTPayload, JWTPayloadAssurance, JWTPayloadUser, JWTPayloadWorkspace, LOGIN_METHODS, OAuthStepUpProvider, RefreshTokenExpiredError, Roles, SENSITIVE_ACTION_ASSURANCE_POLICY, STEP_UP_MAX_AGE_SECONDS, SessionAssurancePolicy, SessionAssuranceRequiredError, SessionAssuranceRequiredPayload, SessionAssuranceService, StepUpOption, UserNotLoggedInError, ac, assuranceFields, canStepUpWithAmr, extractTokenPayload, getAalRank, invitationAdditionalFields, isAssuranceSufficientForPolicy, isSessionAssuranceSufficient, isTokenExpired, memberAdditionalFields, mergeStepUpAssurance, normalizeAmr, organizationAdditionalFields, parseSessionAssuranceRequiredPayload, rolesAccessControl, sessionAssurancePluginClient, userAdditionalFields, validateToken };
|