New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@clerk/types

Package Overview
Dependencies
Maintainers
9
Versions
2273
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@clerk/types - npm Package Compare versions

Comparing version 2.0.0-alpha.9 to 2.0.1-alpha.0

dist/attributes.d.ts

33

dist/clerk.d.ts

@@ -1,7 +0,5 @@

import { OrganizationMembershipResource } from '.';
import { EnvironmentResource } from '.';
import { ClientResource } from './client';
import { DisplayThemeJSON } from './json';
import { OrganizationResource } from './organization';
import { MembershipRole } from './organizationMembership';
import { MembershipRole, OrganizationMembershipResource } from './organizationMembership';
import { ActiveSessionResource } from './session';

@@ -14,2 +12,14 @@ import { UserResource } from './user';

export declare type SignOutCallback = () => void | Promise<any>;
export declare type SignOutOptions = {
/**
* Specify a specific session to sign out. Useful for
* multi-session applications.
*/
sessionId?: string;
};
export interface SignOut {
(options?: SignOutOptions): Promise<void>;
(signOutCallback?: SignOutCallback, options?: SignOutOptions): Promise<void>;
}
export declare type SetSession = (session: ActiveSessionResource | string | null, beforeEmit?: BeforeEmitCallback) => Promise<void>;
/**

@@ -31,19 +41,10 @@ * Main Clerk SDK object.

user?: UserResource | null;
/** Clerk environment. */
__unstable__environment?: EnvironmentResource | null;
/**
* Signs out the current user on single-session instances, or all users on multi-session instances.
*
* Signs out the current user on single-session instances, or all users on multi-session instances
* @param signOutCallback - Optional A callback that runs after sign out completes.
* @param options - Optional Configuration options, see {@link SignOutOptions}
* @returns A promise that resolves when the sign out process completes.
*/
signOut: (signOutCallback?: SignOutCallback) => Promise<void>;
signOut: SignOut;
/**
* Signs out the current user.
*
* @param signOutCallback - Optional A callback that runs after sign out completes.
* @returns A promise that resolves when the sign out process completes.
*/
signOutOne: (signOutCallback?: SignOutCallback) => Promise<void>;
/**
* Opens the Clerk sign in modal.

@@ -141,3 +142,3 @@ *

*/
setSession: (session: ActiveSessionResource | string | null, beforeEmit?: BeforeEmitCallback) => Promise<void>;
setSession: SetSession;
/**

@@ -144,0 +145,0 @@ * Function used to commit a navigation after certain steps in the Clerk processes.

import { DisplayThemeJSON, ImageJSON } from './json';
import { ClerkResource } from './resource';
import { PreferredSignInStrategy } from './signIn';
export declare type PreferredSignInStrategy = 'password' | 'otp';
export interface DisplayConfigJSON {
object: 'display_config';
id: string;
instance_environment_type: string;
application_name: string;
theme: DisplayThemeJSON;
preferred_sign_in_strategy: PreferredSignInStrategy;
logo_image: ImageJSON;
favicon_image: ImageJSON;
backend_host: string;
home_url: string;
sign_in_url: string;
sign_up_url: string;
user_profile_url: string;
after_sign_in_url: string;
after_sign_up_url: string;
after_sign_out_url: string;
after_sign_out_one_url: string;
after_sign_out_all_url: string;
after_switch_session_url: string;
branded: boolean;
}
export interface DisplayConfigResource extends ClerkResource {

@@ -5,0 +27,0 @@ id: string;

import { IdentificationLinkResource } from './identificationLink';
import { ClerkResource } from './resource';
import { EmailCodeStrategy, EmailLinkStrategy } from './strategies';
import { CreateMagicLinkFlowReturn, StartMagicLinkFlowParams, VerificationResource } from './verification';
export declare type EmailAddressVerificationStrategy = 'email_code' | 'email_link';
export declare type PrepareEmailAddressVerificationParams = {
strategy: Extract<EmailAddressVerificationStrategy, 'email_code'>;
strategy: EmailCodeStrategy;
} | {
strategy: Extract<EmailAddressVerificationStrategy, 'email_link'>;
redirect_url: string;
strategy: EmailLinkStrategy;
redirectUrl: string;
};
export declare type VerifyEmailAddressWithMagicLinkParams = {
redirect_url: string;
signal?: AbortSignal;
export declare type AttemptEmailAddressVerificationParams = {
code: string;
};

@@ -22,9 +21,6 @@ export interface EmailAddressResource extends ClerkResource {

prepareVerification: (params?: PrepareEmailAddressVerificationParams) => Promise<EmailAddressResource>;
attemptVerification(code: string): Promise<EmailAddressResource>;
attemptVerification(params: {
code: string;
}): Promise<EmailAddressResource>;
createMagicLinkFlow(): CreateMagicLinkFlowReturn<StartMagicLinkFlowParams, EmailAddressResource>;
attemptVerification: (params: AttemptEmailAddressVerificationParams) => Promise<EmailAddressResource>;
createMagicLinkFlow: () => CreateMagicLinkFlowReturn<StartMagicLinkFlowParams, EmailAddressResource>;
destroy: () => Promise<void>;
}
//# sourceMappingURL=emailAddress.d.ts.map

@@ -29,4 +29,8 @@ export * from './api';

export * from './ssr';
export * from './web3Wallet';
export * from './strategies';
export * from './web3';
export * from './web3Wallet';
export * from './identifiers';
export * from './factors';
export * from './attributes';
//# sourceMappingURL=index.d.ts.map

@@ -45,4 +45,8 @@ "use strict";

__exportStar(require("./ssr"), exports);
__exportStar(require("./web3Wallet"), exports);
__exportStar(require("./strategies"), exports);
__exportStar(require("./web3"), exports);
__exportStar(require("./web3Wallet"), exports);
__exportStar(require("./identifiers"), exports);
__exportStar(require("./factors"), exports);
__exportStar(require("./attributes"), exports);
//# sourceMappingURL=index.js.map
/**
* Currently representing API DTOs in their JSON form.
*/
import { OAuthProvider, OAuthStrategy } from './oauth';
import { DisplayConfigJSON } from './displayConfig';
import { OAuthProvider } from './oauth';
import { OrganizationInvitationStatus } from './organizationInvitation';
import { MembershipRole } from './organizationMembership';
import { SessionStatus } from './session';
import { PreferredSignInStrategy, SignInFactor, SignInIdentifier, SignInStatus, UserData } from './signIn';
import { SignInFirstFactor, SignInJSON, SignInSecondFactor } from './signIn';
import { SignUpField, SignUpIdentificationField, SignUpStatus } from './signUp';
import { OAuthStrategy } from './strategies';
import { BoxShadow, Color, EmUnit, FontFamily, FontWeight, HexColor } from './theme';
import { UserSettingsJSON } from './userSettings';
import { VerificationStatus } from './verification';
import { CamelToSnake } from './utils';
export interface ClerkResourceJSON {

@@ -37,24 +40,2 @@ id: string;

}
export interface DisplayConfigJSON {
object: 'display_config';
id: string;
instance_environment_type: string;
application_name: string;
theme: DisplayThemeJSON;
preferred_sign_in_strategy: PreferredSignInStrategy;
logo_image: ImageJSON;
favicon_image: ImageJSON;
backend_host: string;
home_url: string;
sign_in_url: string;
sign_up_url: string;
user_profile_url: string;
after_sign_in_url: string;
after_sign_up_url: string;
after_sign_out_url: string;
after_sign_out_one_url: string;
after_sign_out_all_url: string;
after_switch_session_url: string;
branded: boolean;
}
export interface ImageJSON {

@@ -117,16 +98,2 @@ object: 'image';

}
export interface SignInJSON extends ClerkResourceJSON {
object: 'sign_in';
id: string;
status: SignInStatus;
supported_identifiers: SignInIdentifier[];
supported_external_accounts: OAuthStrategy[];
identifier: string;
user_data: UserData;
supported_first_factors: SignInFactor[];
supported_second_factors: SignInFactor[];
first_factor_verification: VerificationJSON | null;
second_factor_verification: VerificationJSON | null;
created_session_id: string | null;
}
export interface EmailAddressJSON extends ClerkResourceJSON {

@@ -276,2 +243,9 @@ object: 'email_address';

}
export interface UserDataJSON {
first_name?: string;
last_name?: string;
profile_image_url?: string;
}
export declare type SignInFirstFactorJSON = CamelToSnake<SignInFirstFactor>;
export declare type SignInSecondFactorJSON = CamelToSnake<SignInSecondFactor>;
//# sourceMappingURL=json.d.ts.map

@@ -1,3 +0,2 @@

export declare type OAuthProvider = 'facebook' | 'google' | 'hubspot' | 'github' | 'tiktok' | 'gitlab' | 'discord' | 'twitter' | 'twitch' | 'linkedin' | 'dropbox' | 'bitbucket' | 'microsoft' | 'notion' | 'apple';
export declare type OAuthStrategy = `oauth_${OAuthProvider}`;
import { OAuthStrategy } from './strategies';
export interface OAuthProviderData {

@@ -9,2 +8,18 @@ provider: OAuthProvider;

}
export declare type FacebookOauthProvider = 'facebook';
export declare type GoogleOauthProvider = 'google';
export declare type HubspotOauthProvider = 'hubspot';
export declare type GithubOauthProvider = 'github';
export declare type TiktokOauthProvider = 'tiktok';
export declare type GitlabOauthProvider = 'gitlab';
export declare type DiscordOauthProvider = 'discord';
export declare type TwitterOauthProvider = 'twitter';
export declare type TwitchOauthProvider = 'twitch';
export declare type LinkedinOauthProvider = 'linkedin';
export declare type DropboxOauthProvider = 'dropbox';
export declare type BitbucketOauthProvider = 'bitbucket';
export declare type MicrosoftOauthProvider = 'microsoft';
export declare type NotionOauthProvider = 'notion';
export declare type AppleOauthProvider = 'apple';
export declare type OAuthProvider = FacebookOauthProvider | GoogleOauthProvider | HubspotOauthProvider | GithubOauthProvider | TiktokOauthProvider | GitlabOauthProvider | DiscordOauthProvider | TwitterOauthProvider | TwitchOauthProvider | LinkedinOauthProvider | DropboxOauthProvider | BitbucketOauthProvider | MicrosoftOauthProvider | NotionOauthProvider | AppleOauthProvider;
export declare const OAUTH_PROVIDERS: OAuthProviderData[];

@@ -15,3 +30,3 @@ interface getOAuthProviderDataProps {

}
export declare function getOAuthProviderData({ provider, strategy }: getOAuthProviderDataProps): OAuthProviderData | undefined | null;
export declare function getOAuthProviderData({ provider, strategy, }: getOAuthProviderDataProps): OAuthProviderData | undefined | null;
export declare function sortedOAuthProviders(sortingArray: OAuthStrategy[]): OAuthProviderData[];

@@ -23,3 +38,2 @@ export declare type AuthenticateWithRedirectParams = {

strategy: OAuthStrategy;
} & {
/**

@@ -26,0 +40,0 @@ * Full URL or path to the route that will complete the OAuth flow.

@@ -105,5 +105,3 @@ "use strict";

function sortedOAuthProviders(sortingArray) {
return exports.OAUTH_PROVIDERS
.slice()
.sort(function (a, b) {
return exports.OAUTH_PROVIDERS.slice().sort(function (a, b) {
var aPos = sortingArray.indexOf(a.strategy);

@@ -110,0 +108,0 @@ if (aPos == -1) {

@@ -9,2 +9,3 @@ import { OrganizationInvitationResource } from './organizationInvitation';

updatedAt: Date;
update: (params: UpdateOrganizationParams) => Promise<OrganizationResource>;
getMemberships: (params?: GetMembershipsParams) => Promise<OrganizationMembershipResource[]>;

@@ -29,2 +30,5 @@ getPendingInvitations: () => Promise<OrganizationInvitationResource[]>;

}
export interface UpdateOrganizationParams {
name: string;
}
//# sourceMappingURL=organization.d.ts.map
import { IdentificationLinkResource } from './identificationLink';
import { ClerkResource } from './resource';
import { PhoneCodeStrategy } from './strategies';
import { VerificationResource } from './verification';
export declare type PhoneNumberVerificationStrategy = 'phone_code';
export declare type PhoneNumberVerificationStrategy = PhoneCodeStrategy;
export declare type PreparePhoneNumberVerificationParams = {
strategy: PhoneNumberVerificationStrategy;
};
export declare type AttemptPhoneNumberVerificationParams = {
code: string;
};
export declare type SetReservedForSecondFactorParams = {
reserved: boolean;
};
export interface PhoneNumberResource extends ClerkResource {

@@ -17,7 +24,7 @@ id: string;

prepareVerification: () => Promise<PhoneNumberResource>;
attemptVerification: (code: string) => Promise<PhoneNumberResource>;
attemptVerification: (params: AttemptPhoneNumberVerificationParams) => Promise<PhoneNumberResource>;
makeDefaultSecondFactor: () => Promise<PhoneNumberResource>;
setReservedForSecondFactor: (reserve: boolean) => Promise<PhoneNumberResource>;
setReservedForSecondFactor: (params: SetReservedForSecondFactorParams) => Promise<PhoneNumberResource>;
destroy: () => Promise<void>;
}
//# sourceMappingURL=phoneNumber.d.ts.map
import { ClerkResource } from './resource';
import { GetSessionTokenOptions, TokenResource } from './token';
import { TokenResource } from './token';
import { UserResource } from './user';

@@ -15,3 +15,3 @@ export interface SessionResource extends ClerkResource {

touch: () => Promise<SessionResource>;
getToken: (options?: GetSessionTokenOptions) => Promise<string>;
getToken: GetToken;
createdAt: Date;

@@ -51,2 +51,8 @@ updatedAt: Date;

}
export declare type GetTokenOptions = {
template: string;
leewayInSeconds?: number;
skipCache?: boolean;
};
export declare type GetToken = (options?: GetTokenOptions) => Promise<string>;
//# sourceMappingURL=session.d.ts.map

@@ -1,7 +0,8 @@

import { EmailAddressVerificationStrategy } from './emailAddress';
import { AuthenticateWithRedirectParams, OAuthStrategy } from './oauth';
import { EmailCodeAttempt, EmailCodeConfig, EmailCodeFactor, EmailLinkConfig, EmailLinkFactor, OAuthConfig, OauthFactor, PasswordAttempt, PasswordFactor, PhoneCodeAttempt, PhoneCodeConfig, PhoneCodeFactor, PhoneCodeSecondFactorConfig, Web3Attempt, Web3SignatureConfig, Web3SignatureFactor } from './factors';
import { EmailAddressIdentifier, PhoneNumberIdentifier, UsernameIdentifier, Web3WalletIdentifier } from './identifiers';
import { ClerkResourceJSON, SignInFirstFactorJSON, SignInSecondFactorJSON, UserDataJSON, VerificationJSON } from './json';
import { AuthenticateWithRedirectParams } from './oauth';
import { ClerkResource } from './resource';
import { SnakeToCamel } from './utils';
import { EmailCodeStrategy, EmailLinkStrategy, OAuthStrategy, PasswordStrategy, PhoneCodeStrategy, TicketStrategy, Web3Strategy } from './strategies';
import { CreateMagicLinkFlowReturn, StartMagicLinkFlowParams, VerificationResource } from './verification';
import { Web3Strategy } from './web3';
import { AuthenticateWithWeb3Params } from './web3Wallet';

@@ -11,4 +12,4 @@ export interface SignInResource extends ClerkResource {

supportedIdentifiers: SignInIdentifier[];
supportedFirstFactors: SignInFactor[];
supportedSecondFactors: SignInFactor[];
supportedFirstFactors: SignInFirstFactor[];
supportedSecondFactors: SignInSecondFactor[];
firstFactorVerification: VerificationResource;

@@ -19,111 +20,69 @@ secondFactorVerification: VerificationResource;

userData: UserData;
create: (params: SignInParams) => Promise<SignInResource>;
prepareFirstFactor: (strategy: PrepareFirstFactorParams) => Promise<SignInResource>;
attemptFirstFactor: (params: AttemptFactorParams) => Promise<SignInResource>;
create: (params: SignInCreateParams) => Promise<SignInResource>;
prepareFirstFactor: (params: PrepareFirstFactorParams) => Promise<SignInResource>;
attemptFirstFactor: (params: AttemptFirstFactorParams) => Promise<SignInResource>;
prepareSecondFactor: (params: PrepareSecondFactorParams) => Promise<SignInResource>;
attemptSecondFactor: (params: AttemptFactorParams) => Promise<SignInResource>;
attemptSecondFactor: (params: AttemptSecondFactorParams) => Promise<SignInResource>;
authenticateWithRedirect: (params: AuthenticateWithRedirectParams) => Promise<void>;
createMagicLinkFlow: () => CreateMagicLinkFlowReturn<SignInStartMagicLinkFlowParams, SignInResource>;
authenticateWithWeb3: (params: AuthenticateWithWeb3Params) => Promise<SignInResource>;
authenticateWithMetamask: () => Promise<SignInResource>;
createMagicLinkFlow: () => CreateMagicLinkFlowReturn<SignInStartMagicLinkFlowParams, SignInResource>;
}
export declare type AttemptFirstFactorWithMagicLinkParams = {
email_address_id: string;
redirect_url: string;
signal?: AbortSignal;
};
export declare type SignInIdentifier = 'username' | 'email_address' | 'phone_number' | 'web3_wallet';
export declare type IdentificationStrategy = SignInIdentifier | OAuthStrategy;
export declare type SignInStrategyName = 'password' | 'phone_code' | Web3Strategy | EmailAddressVerificationStrategy | OAuthStrategy | 'ticket';
export declare type SignInStatus = 'needs_identifier' | 'needs_first_factor' | 'needs_second_factor' | 'complete';
export declare type PreferredSignInStrategy = 'password' | 'otp';
export declare type EmailCodeFactor = {
strategy: Extract<SignInStrategyName, 'email_code'>;
email_address_id: string;
safe_identifier: string;
};
export declare type EmailLinkFactor = {
strategy: Extract<SignInStrategyName, 'email_link'>;
email_address_id: string;
safe_identifier: string;
};
export declare type PhoneCodeFactor = {
strategy: Extract<SignInStrategyName, 'phone_code'>;
phone_number_id: string;
safe_identifier: string;
default?: boolean;
};
export declare type Web3SignatureFactor = {
strategy: Extract<SignInStrategyName, Web3Strategy>;
web3_wallet_id: string;
};
export declare type PasswordFactor = {
strategy: Extract<SignInStrategyName, 'password'>;
};
export declare type OauthFactor = {
export declare type SignInIdentifier = UsernameIdentifier | EmailAddressIdentifier | PhoneNumberIdentifier | Web3WalletIdentifier;
export declare type SignInFirstFactor = EmailCodeFactor | EmailLinkFactor | PhoneCodeFactor | PasswordFactor | Web3SignatureFactor | OauthFactor;
export declare type SignInSecondFactor = PhoneCodeFactor;
export interface UserData {
firstName?: string;
lastName?: string;
profileImageUrl?: string;
}
export declare type SignInFactor = SignInFirstFactor | SignInSecondFactor;
export declare type PrepareFirstFactorParams = EmailCodeConfig | EmailLinkConfig | PhoneCodeConfig | Web3SignatureConfig | OAuthConfig;
export declare type AttemptFirstFactorParams = EmailCodeAttempt | PhoneCodeAttempt | PasswordAttempt | Web3Attempt;
export declare type PrepareSecondFactorParams = PhoneCodeSecondFactorConfig;
export declare type AttemptSecondFactorParams = PhoneCodeAttempt;
export declare type SignInCreateParams = ({
strategy: OAuthStrategy;
};
export declare type SignInFactor = EmailCodeFactor | EmailLinkFactor | PhoneCodeFactor | PasswordFactor | Web3SignatureFactor | OauthFactor;
export declare type PrepareFirstFactorParams = Omit<EmailCodeFactor, 'safe_identifier'> | (Omit<EmailLinkFactor, 'safe_identifier'> & {
redirect_url: string;
}) | Omit<PhoneCodeFactor, 'safe_identifier'> | Web3SignatureFactor | (OauthFactor & {
redirect_url: string;
action_complete_redirect_url: string;
});
export declare type PrepareSecondFactorParams = Pick<PhoneCodeFactor, 'strategy'> & {
phone_number_id?: string;
};
export declare type AttemptFactorParams = {
strategy: Extract<SignInStrategyName, 'email_code' | 'phone_code'>;
code: string;
redirectUrl: string;
actionCompleteRedirectUrl?: string;
} | {
strategy: Extract<SignInStrategyName, 'password'>;
strategy: TicketStrategy;
ticket: string;
} | {
strategy: PasswordStrategy;
password: string;
identifier: string;
} | {
strategy: Extract<SignInStrategyName, Web3Strategy>;
signature: string;
strategy: PhoneCodeStrategy | EmailCodeStrategy | Web3Strategy;
identifier: string;
} | {
strategy: EmailLinkStrategy;
identifier: string;
redirectUrl?: string;
} | {
identifier: string;
} | {
transfer?: boolean;
}) & {
transfer?: boolean;
};
export interface UserData {
first_name?: string;
last_name?: string;
profile_image_url?: string;
}
declare type SignInAttributes = {
/**
* An email address, phone or username to identify the attempt.
*/
identifier?: string;
/**
* The first step of the strategy to perform.
*/
strategy?: SignInStrategyName;
/**
* Required if the strategy is "password".
* The password to attempt to sign in with.
*/
password?: string;
/**
* Required if the strategy is one of the OAuth providers.
* This is the URL that the user will be redirected to after the OAuth verification completes.
*/
redirect_url?: string;
/**
* Organization invitation ticket.
* The logic is handled by the backend after the token and strategy is sent.
*/
ticket?: string;
/**
* Optional if the strategy is one of the OAuth providers.
* If the OAuth verification results in a completed Sign in, this is the URL that
* the user will be redirected to.
*/
action_complete_redirect_url?: string;
} & {
transfer: boolean;
};
export declare type SignInParams = Partial<SnakeToCamel<SignInAttributes> & SignInAttributes>;
export interface SignInStartMagicLinkFlowParams extends StartMagicLinkFlowParams {
emailAddressId: string;
}
export {};
export declare type SignInStrategy = PasswordStrategy | PhoneCodeStrategy | EmailCodeStrategy | EmailLinkStrategy | TicketStrategy | Web3Strategy | OAuthStrategy;
export interface SignInJSON extends ClerkResourceJSON {
object: 'sign_in';
id: string;
status: SignInStatus;
supported_identifiers: SignInIdentifier[];
supported_external_accounts: OAuthStrategy[];
identifier: string;
user_data: UserDataJSON;
supported_first_factors: SignInFirstFactorJSON[];
supported_second_factors: SignInSecondFactorJSON[];
first_factor_verification: VerificationJSON | null;
second_factor_verification: VerificationJSON | null;
created_session_id: string | null;
}
//# sourceMappingURL=signIn.d.ts.map

@@ -1,9 +0,11 @@

import { EmailAddressVerificationStrategy, PrepareEmailAddressVerificationParams } from './emailAddress';
import { AuthenticateWithRedirectParams, OAuthStrategy } from './oauth';
import { PhoneNumberVerificationStrategy, PreparePhoneNumberVerificationParams } from './phoneNumber';
import { BirthdayAttribute, FirstNameAttribute, GenderAttribute, LastNameAttribute, PasswordAttribute } from './attributes';
import { AttemptEmailAddressVerificationParams, PrepareEmailAddressVerificationParams } from './emailAddress';
import { EmailAddressIdentifier, EmailAddressOrPhoneNumberIdentifier, PhoneNumberIdentifier, UsernameIdentifier, Web3WalletIdentifier } from './identifiers';
import { AuthenticateWithRedirectParams } from './oauth';
import { AttemptPhoneNumberVerificationParams, PreparePhoneNumberVerificationParams } from './phoneNumber';
import { ClerkResource } from './resource';
import { SnakeToCamel } from './utils';
import { CreateMagicLinkFlowReturn, StartMagicLinkFlowParams, VerificationAttemptParams, VerificationResource } from './verification';
import { Web3Strategy } from './web3';
import { AuthenticateWithWeb3Params } from './web3Wallet';
import { EmailCodeStrategy, EmailLinkStrategy, OAuthStrategy, PhoneCodeStrategy, TicketStrategy, Web3Strategy } from './strategies';
import { CreateMagicLinkFlowReturn, StartMagicLinkFlowParams, VerificationResource } from './verification';
import { AuthenticateWithWeb3Params, GenerateSignature } from './web3Wallet';
import type { SnakeToCamel } from './utils';
export interface SignUpResource extends ClerkResource {

@@ -22,3 +24,2 @@ status: SignUpStatus | null;

web3wallet: string | null;
externalAccount: any;
hasPassword: boolean;

@@ -28,12 +29,13 @@ unsafeMetadata: Record<string, unknown>;

abandonAt: number | null;
create: (params: SignUpParams) => Promise<SignUpResource>;
update: (params: SignUpParams) => Promise<SignUpResource>;
prepareVerification: (strategy: SignUpVerificationStrategy) => Promise<SignUpResource>;
attemptVerification: (params: SignUpVerificationAttemptParams) => Promise<SignUpResource>;
prepareEmailAddressVerification: (p?: PrepareEmailAddressVerificationParams) => Promise<SignUpResource>;
attemptEmailAddressVerification: (params: VerificationAttemptParams) => Promise<SignUpResource>;
create: (params: SignUpCreateParams) => Promise<SignUpResource>;
update: (params: SignUpUpdateParams) => Promise<SignUpResource>;
prepareVerification: (params: PrepareVerificationParams) => Promise<SignUpResource>;
attemptVerification: (params: AttemptVerificationParams) => Promise<SignUpResource>;
prepareEmailAddressVerification: (params?: PrepareEmailAddressVerificationParams) => Promise<SignUpResource>;
attemptEmailAddressVerification: (params: AttemptEmailAddressVerificationParams) => Promise<SignUpResource>;
preparePhoneNumberVerification: (params?: PreparePhoneNumberVerificationParams) => Promise<SignUpResource>;
attemptPhoneNumberVerification: (params: AttemptPhoneNumberVerificationParams) => Promise<SignUpResource>;
prepareWeb3WalletVerification: () => Promise<SignUpResource>;
attemptWeb3WalletVerification: (params: AttemptWeb3WalletVerificationParams) => Promise<SignUpResource>;
createMagicLinkFlow: () => CreateMagicLinkFlowReturn<StartMagicLinkFlowParams, SignUpResource>;
preparePhoneNumberVerification: (p?: PreparePhoneNumberVerificationParams) => Promise<SignUpResource>;
attemptPhoneNumberVerification: (params: VerificationAttemptParams) => Promise<SignUpResource>;
attemptWeb3WalletVerification: (params: AuthenticateWithWeb3Params) => Promise<SignUpResource>;
authenticateWithRedirect: (params: AuthenticateWithRedirectParams) => Promise<void>;

@@ -44,20 +46,41 @@ authenticateWithWeb3: (params: AuthenticateWithWeb3Params) => Promise<SignUpResource>;

export declare type SignUpStatus = 'missing_requirements' | 'complete' | 'abandoned';
export declare type SignUpField = SignUpAttribute | SignUpIdentificationField;
export declare type SignUpIdentificationField = 'email_address' | 'phone_number' | 'username' | 'email_address_or_phone_number' | 'web3_wallet';
export declare type SignUpIdentification = SignUpIdentificationField | OAuthStrategy;
export declare type SignUpAttribute = 'first_name' | 'last_name' | 'password' | 'birthday' | 'gender';
declare type OrganizationSignUpStrategy = 'ticket';
export declare type SignUpAttributes = {
external_account_strategy: string;
external_account_redirect_url: string;
external_account_action_complete_redirect_url: string;
strategy: OAuthStrategy | OrganizationSignUpStrategy;
redirect_url: string;
action_complete_redirect_url: string;
export declare type SignUpField = SignUpAttributeField | SignUpIdentificationField;
export declare type PrepareVerificationParams = {
strategy: EmailCodeStrategy;
} | {
strategy: EmailLinkStrategy;
redirectUrl?: string;
} | {
strategy: PhoneCodeStrategy;
} | {
strategy: Web3Strategy;
};
export declare type AttemptVerificationParams = {
strategy: EmailCodeStrategy;
code: string;
} | {
strategy: PhoneCodeStrategy;
code: string;
} | {
strategy: Web3Strategy;
signature: string;
};
export declare type AttemptWeb3WalletVerificationParams = {
generateSignature: GenerateSignature;
};
export declare type SignUpAttributeField = FirstNameAttribute | LastNameAttribute | PasswordAttribute | BirthdayAttribute | GenderAttribute;
export declare type SignUpVerifiableField = UsernameIdentifier | EmailAddressIdentifier | PhoneNumberIdentifier | EmailAddressOrPhoneNumberIdentifier | Web3WalletIdentifier;
export declare type SignUpIdentificationField = SignUpVerifiableField | OAuthStrategy;
export declare type SignUpCreateParams = Partial<{
externalAccountStrategy: string;
externalAccountRedirectUrl: string;
externalAccountActionCompleteRedirectUrl: string;
strategy: OAuthStrategy | TicketStrategy;
redirectUrl: string;
actionCompleteRedirectUrl: string;
transfer: boolean;
unsafe_metadata: Record<string, unknown>;
invitation_token: string;
unsafeMetadata: Record<string, unknown>;
ticket: string;
} & Record<SignUpAttribute | Exclude<SignUpIdentification, OAuthStrategy>, string>;
export declare type SignUpParams = Partial<SnakeToCamel<SignUpAttributes> & SignUpAttributes>;
} & SnakeToCamel<Record<SignUpAttributeField | SignUpVerifiableField, string>>>;
export declare type SignUpUpdateParams = SignUpCreateParams;
export interface SignUpVerificationsResource {

@@ -73,10 +96,2 @@ emailAddress: SignUpVerificationResource;

}
export declare type SignUpVerificationStrategy = EmailAddressVerificationStrategy | PhoneNumberVerificationStrategy | Web3Strategy;
export declare type BaseVerificationAttemptParams = {
strategy: SignUpVerificationStrategy;
};
export declare type SignUpVerificationAttemptParams = {
strategy: SignUpVerificationStrategy;
} & VerificationAttemptParams;
export {};
//# sourceMappingURL=signUp.d.ts.map
import { SessionJSON, UserJSON } from './json';
import { SessionResource } from './session';
import { GetSessionTokenOptions } from './token';
import { UserResource } from './user';
export declare type ServerGetTokenOptions = {
template?: string;
};
export declare type ServerGetToken = (options?: ServerGetTokenOptions) => Promise<string>;
export declare type ServerSideAuth = {
sessionId: string | null;
userId: string | null;
getToken: (options?: GetSessionTokenOptions) => Promise<string | null>;
getToken: ServerGetToken;
};

@@ -10,0 +13,0 @@ declare type SsrSessionState<SessionType> = {

import { JWT } from './jwt';
import { ClerkResource } from './resource';
export declare type JWTService = 'clerk' | 'hasura' | 'firebase';
export declare type GetUserTokenOptions = {
leewayInSeconds?: number;
};
export declare type GetSessionTokenOptions = {
leewayInSeconds?: number;
template?: string;
throwOnError?: boolean;
skipCache?: boolean;
};
export interface TokenResource extends ClerkResource {

@@ -14,0 +4,0 @@ jwt: JWT;

@@ -33,12 +33,21 @@ import { EmailAddressResource } from './emailAddress';

update: (params: UpdateUserParams) => Promise<UserResource>;
createEmailAddress: (email: string) => Promise<EmailAddressResource>;
createPhoneNumber: (phoneNumber: string) => Promise<PhoneNumberResource>;
createEmailAddress: (params: CreateEmailAddressParams) => Promise<EmailAddressResource>;
createPhoneNumber: (params: CreatePhoneNumberParams) => Promise<PhoneNumberResource>;
twoFactorEnabled: () => boolean;
isPrimaryIdentification: (ident: EmailAddressResource | PhoneNumberResource) => boolean;
getSessions: () => Promise<SessionWithActivitiesResource[]>;
setProfileImage: (file: Blob | File) => Promise<ImageResource>;
setProfileImage: (params: SetProfileImageParams) => Promise<ImageResource>;
}
export declare type CreateEmailAddressParams = {
email: string;
};
export declare type CreatePhoneNumberParams = {
phoneNumber: string;
};
export declare type SetProfileImageParams = {
file: Blob | File;
};
declare type UpdateUserJSON = Pick<UserJSON, 'username' | 'password' | 'first_name' | 'last_name' | 'primary_email_address_id' | 'primary_phone_number_id' | 'primary_web3_wallet_id' | 'unsafe_metadata'>;
export declare type UpdateUserParams = Partial<SnakeToCamel<UpdateUserJSON> & UpdateUserJSON>;
export declare type UpdateUserParams = Partial<SnakeToCamel<UpdateUserJSON>>;
export {};
//# sourceMappingURL=user.d.ts.map
import { ClerkResourceJSON } from './json';
import { OAuthStrategy } from './oauth';
import { ClerkResource } from './resource';
import { Web3Strategy } from './web3';
import { OAuthStrategy, Web3Strategy } from './strategies';
declare type Attribute = 'email_address' | 'phone_number' | 'username' | 'first_name' | 'last_name' | 'password' | 'web3_wallet';

@@ -6,0 +5,0 @@ declare type VerificationStrategy = 'email_link' | 'email_code' | 'phone_code';

@@ -1,3 +0,3 @@

export declare type Web3Provider = 'metamask';
export declare type Web3Strategy = `web3_${Web3Provider}_signature`;
export declare type MetamaskWeb3Provider = 'metamask';
export declare type Web3Provider = MetamaskWeb3Provider;
//# sourceMappingURL=web3.d.ts.map
import { ClerkResource } from './resource';
import { VerificationResource } from './verification';
import { Web3Strategy } from './web3';
export declare type PrepareWeb3WalletVerificationParams = {
strategy: Web3Strategy;
};
export interface Web3WalletResource extends ClerkResource {

@@ -12,5 +8,6 @@ id: string;

}
export declare type GenerateSignature = (opts: GenerateSignatureParams) => Promise<string>;
export interface AuthenticateWithWeb3Params {
identifier: string;
generateSignature: (opts: GenerateSignatureParams) => Promise<string>;
generateSignature: GenerateSignature;
}

@@ -17,0 +14,0 @@ export interface GenerateSignatureParams {

{
"name": "@clerk/types",
"version": "2.0.0-alpha.9",
"version": "2.0.1-alpha.0",
"license": "MIT",

@@ -51,3 +51,3 @@ "description": "Typings for Clerk libraries.",

"homepage": "https://clerk.dev/",
"gitHead": "512055698ef62a9c760afb092aac0ca33a8e5408"
"gitHead": "c452dd2bbf65275752616dc1c61eb6612025a26c"
}

@@ -16,3 +16,3 @@ <p align="center">

[Changelog](CHANGELOG.md)
[Changelog](https://github.com/clerkinc/javascript/blob/main/packages/types/CHANGELOG.md)
·

@@ -81,3 +81,3 @@ [Report a Bug](https://github.com/clerkinc/javascript/issues/new?assignees=&labels=bug&template=bug_report.md&title=Bug%3A+)

We're open to all community contributions! If you'd like to contribute in any way, please read [our contribution guidelines](docs/CONTRIBUTING.md).
We're open to all community contributions! If you'd like to contribute in any way, please read [our contribution guidelines](https://github.com/clerkinc/javascript/blob/main/packages/types/docs/CONTRIBUTING.md).

@@ -90,3 +90,3 @@ ## Security

_For more information and to report security issues, please refer to our [security documentation](docs/SECURITY.md)._
_For more information and to report security issues, please refer to our [security documentation](https://github.com/clerkinc/javascript/blob/main/packages/types/docs/SECURITY.md)._

@@ -97,2 +97,2 @@ ## License

See [LICENSE](LICENSE) for more information.
See [LICENSE](https://github.com/clerkinc/javascript/blob/main/packages/types/LICENSE) for more information.

@@ -1,7 +0,8 @@

import { OrganizationMembershipResource } from '.';
import { EnvironmentResource } from '.';
import { ClientResource } from './client';
import { DisplayThemeJSON } from './json';
import { OrganizationResource } from './organization';
import { MembershipRole } from './organizationMembership';
import {
MembershipRole,
OrganizationMembershipResource,
} from './organizationMembership';
import { ActiveSessionResource } from './session';

@@ -16,4 +17,23 @@ import { UserResource } from './user';

) => void | Promise<any>;
export type SignOutCallback = () => void | Promise<any>;
export type SignOutOptions = {
/**
* Specify a specific session to sign out. Useful for
* multi-session applications.
*/
sessionId?: string;
};
export interface SignOut {
(options?: SignOutOptions): Promise<void>;
(signOutCallback?: SignOutCallback, options?: SignOutOptions): Promise<void>;
}
export type SetSession = (
session: ActiveSessionResource | string | null,
beforeEmit?: BeforeEmitCallback,
) => Promise<void>;
/**

@@ -40,22 +60,11 @@ * Main Clerk SDK object.

/** Clerk environment. */
__unstable__environment?: EnvironmentResource | null;
/**
* Signs out the current user on single-session instances, or all users on multi-session instances.
*
* Signs out the current user on single-session instances, or all users on multi-session instances
* @param signOutCallback - Optional A callback that runs after sign out completes.
* @param options - Optional Configuration options, see {@link SignOutOptions}
* @returns A promise that resolves when the sign out process completes.
*/
signOut: (signOutCallback?: SignOutCallback) => Promise<void>;
signOut: SignOut;
/**
* Signs out the current user.
*
* @param signOutCallback - Optional A callback that runs after sign out completes.
* @returns A promise that resolves when the sign out process completes.
*/
signOutOne: (signOutCallback?: SignOutCallback) => Promise<void>;
/**
* Opens the Clerk sign in modal.

@@ -172,6 +181,3 @@ *

*/
setSession: (
session: ActiveSessionResource | string | null,
beforeEmit?: BeforeEmitCallback,
) => Promise<void>;
setSession: SetSession;

@@ -178,0 +184,0 @@ /**

import { DisplayThemeJSON, ImageJSON } from './json';
import { ClerkResource } from './resource';
import { PreferredSignInStrategy } from './signIn';
export type PreferredSignInStrategy = 'password' | 'otp';
export interface DisplayConfigJSON {
object: 'display_config';
id: string;
instance_environment_type: string;
application_name: string;
theme: DisplayThemeJSON;
preferred_sign_in_strategy: PreferredSignInStrategy;
logo_image: ImageJSON;
favicon_image: ImageJSON;
backend_host: string;
home_url: string;
sign_in_url: string;
sign_up_url: string;
user_profile_url: string;
after_sign_in_url: string;
after_sign_up_url: string;
after_sign_out_url: string;
after_sign_out_one_url: string;
after_sign_out_all_url: string;
after_switch_session_url: string;
branded: boolean;
}
export interface DisplayConfigResource extends ClerkResource {

@@ -6,0 +30,0 @@ id: string;

import { IdentificationLinkResource } from './identificationLink';
import { ClerkResource } from './resource';
import { EmailCodeStrategy, EmailLinkStrategy } from './strategies';
import {

@@ -9,16 +10,13 @@ CreateMagicLinkFlowReturn,

export type EmailAddressVerificationStrategy = 'email_code' | 'email_link';
export type PrepareEmailAddressVerificationParams =
| {
strategy: Extract<EmailAddressVerificationStrategy, 'email_code'>;
strategy: EmailCodeStrategy;
}
| {
strategy: Extract<EmailAddressVerificationStrategy, 'email_link'>;
redirect_url: string;
strategy: EmailLinkStrategy;
redirectUrl: string;
};
export type VerifyEmailAddressWithMagicLinkParams = {
redirect_url: string;
signal?: AbortSignal;
export type AttemptEmailAddressVerificationParams = {
code: string;
};

@@ -35,11 +33,10 @@

) => Promise<EmailAddressResource>;
attemptVerification(code: string): Promise<EmailAddressResource>;
attemptVerification(params: { code: string }): Promise<EmailAddressResource>;
createMagicLinkFlow(): CreateMagicLinkFlowReturn<
attemptVerification: (
params: AttemptEmailAddressVerificationParams,
) => Promise<EmailAddressResource>;
createMagicLinkFlow: () => CreateMagicLinkFlowReturn<
StartMagicLinkFlowParams,
EmailAddressResource
>;
destroy: () => Promise<void>;
}

@@ -29,3 +29,7 @@ export * from './api';

export * from './ssr';
export * from './web3Wallet';
export * from './strategies';
export * from './web3';
export * from './web3Wallet';
export * from './identifiers';
export * from './factors';
export * from './attributes';

@@ -5,24 +5,14 @@ /**

import { OAuthProvider, OAuthStrategy } from './oauth';
import { DisplayConfigJSON } from './displayConfig';
import { OAuthProvider } from './oauth';
import { OrganizationInvitationStatus } from './organizationInvitation';
import { MembershipRole } from './organizationMembership';
import { SessionStatus } from './session';
import {
PreferredSignInStrategy,
SignInFactor,
SignInIdentifier,
SignInStatus,
UserData,
} from './signIn';
import { SignInFirstFactor, SignInJSON, SignInSecondFactor } from './signIn';
import { SignUpField, SignUpIdentificationField, SignUpStatus } from './signUp';
import {
BoxShadow,
Color,
EmUnit,
FontFamily,
FontWeight,
HexColor,
} from './theme';
import { OAuthStrategy } from './strategies';
import { BoxShadow, Color, EmUnit, FontFamily, FontWeight, HexColor } from './theme';
import { UserSettingsJSON } from './userSettings';
import { VerificationStatus } from './verification';
import { CamelToSnake } from './utils';

@@ -56,25 +46,2 @@ export interface ClerkResourceJSON {

export interface DisplayConfigJSON {
object: 'display_config';
id: string;
instance_environment_type: string;
application_name: string;
theme: DisplayThemeJSON;
preferred_sign_in_strategy: PreferredSignInStrategy;
logo_image: ImageJSON;
favicon_image: ImageJSON;
backend_host: string;
home_url: string;
sign_in_url: string;
sign_up_url: string;
user_profile_url: string;
after_sign_in_url: string;
after_sign_up_url: string;
after_sign_out_url: string;
after_sign_out_one_url: string;
after_sign_out_all_url: string;
after_switch_session_url: string;
branded: boolean;
}
export interface ImageJSON {

@@ -142,17 +109,2 @@ object: 'image';

export interface SignInJSON extends ClerkResourceJSON {
object: 'sign_in';
id: string;
status: SignInStatus;
supported_identifiers: SignInIdentifier[];
supported_external_accounts: OAuthStrategy[];
identifier: string;
user_data: UserData;
supported_first_factors: SignInFactor[];
supported_second_factors: SignInFactor[];
first_factor_verification: VerificationJSON | null;
second_factor_verification: VerificationJSON | null;
created_session_id: string | null;
}
export interface EmailAddressJSON extends ClerkResourceJSON {

@@ -319,1 +271,10 @@ object: 'email_address';

}
export interface UserDataJSON {
first_name?: string;
last_name?: string;
profile_image_url?: string;
}
export type SignInFirstFactorJSON = CamelToSnake<SignInFirstFactor>;
export type SignInSecondFactorJSON = CamelToSnake<SignInSecondFactor>;

@@ -1,23 +0,6 @@

export type OAuthProvider =
| 'facebook'
| 'google'
| 'hubspot'
| 'github'
| 'tiktok'
| 'gitlab'
| 'discord'
| 'twitter'
| 'twitch'
| 'linkedin'
| 'dropbox'
| 'bitbucket'
| 'microsoft'
| 'notion'
| 'apple';
import { OAuthStrategy } from './strategies';
export type OAuthStrategy = `oauth_${OAuthProvider}`;
export interface OAuthProviderData {
provider: OAuthProvider;
strategy: OAuthStrategy,
strategy: OAuthStrategy;
name: string;

@@ -27,2 +10,35 @@ docsUrl: string;

export type FacebookOauthProvider = 'facebook';
export type GoogleOauthProvider = 'google';
export type HubspotOauthProvider = 'hubspot';
export type GithubOauthProvider = 'github';
export type TiktokOauthProvider = 'tiktok';
export type GitlabOauthProvider = 'gitlab';
export type DiscordOauthProvider = 'discord';
export type TwitterOauthProvider = 'twitter';
export type TwitchOauthProvider = 'twitch';
export type LinkedinOauthProvider = 'linkedin';
export type DropboxOauthProvider = 'dropbox';
export type BitbucketOauthProvider = 'bitbucket';
export type MicrosoftOauthProvider = 'microsoft';
export type NotionOauthProvider = 'notion';
export type AppleOauthProvider = 'apple';
export type OAuthProvider =
| FacebookOauthProvider
| GoogleOauthProvider
| HubspotOauthProvider
| GithubOauthProvider
| TiktokOauthProvider
| GitlabOauthProvider
| DiscordOauthProvider
| TwitterOauthProvider
| TwitchOauthProvider
| LinkedinOauthProvider
| DropboxOauthProvider
| BitbucketOauthProvider
| MicrosoftOauthProvider
| NotionOauthProvider
| AppleOauthProvider;
export const OAUTH_PROVIDERS: OAuthProviderData[] = [

@@ -122,7 +138,10 @@ {

interface getOAuthProviderDataProps {
provider?: OAuthProvider,
strategy?: OAuthStrategy,
provider?: OAuthProvider;
strategy?: OAuthStrategy;
}
export function getOAuthProviderData({ provider, strategy }: getOAuthProviderDataProps): OAuthProviderData | undefined | null {
export function getOAuthProviderData({
provider,
strategy,
}: getOAuthProviderDataProps): OAuthProviderData | undefined | null {
if (provider) {

@@ -136,19 +155,15 @@ return OAUTH_PROVIDERS.find(oauth_provider => oauth_provider.provider == provider);

export function sortedOAuthProviders(sortingArray: OAuthStrategy[]) {
return OAUTH_PROVIDERS
.slice()
.sort(
(a, b) => {
let aPos = sortingArray.indexOf(a.strategy);
if (aPos == -1) {
aPos = Number.MAX_SAFE_INTEGER;
}
return OAUTH_PROVIDERS.slice().sort((a, b) => {
let aPos = sortingArray.indexOf(a.strategy);
if (aPos == -1) {
aPos = Number.MAX_SAFE_INTEGER;
}
let bPos = sortingArray.indexOf(b.strategy);
if (bPos == -1) {
bPos = Number.MAX_SAFE_INTEGER;
}
let bPos = sortingArray.indexOf(b.strategy);
if (bPos == -1) {
bPos = Number.MAX_SAFE_INTEGER;
}
return aPos - bPos;
}
)
return aPos - bPos;
});
}

@@ -161,3 +176,2 @@

strategy: OAuthStrategy;
} & {
/**

@@ -164,0 +178,0 @@ * Full URL or path to the route that will complete the OAuth flow.

@@ -10,2 +10,3 @@ import { OrganizationInvitationResource } from './organizationInvitation';

updatedAt: Date;
update: (params: UpdateOrganizationParams) => Promise<OrganizationResource>;
getMemberships: (

@@ -39,1 +40,5 @@ params?: GetMembershipsParams,

}
export interface UpdateOrganizationParams {
name: string;
}
import { IdentificationLinkResource } from './identificationLink';
import { ClerkResource } from './resource';
import { PhoneCodeStrategy } from './strategies';
import { VerificationResource } from './verification';
export type PhoneNumberVerificationStrategy = 'phone_code';
export type PhoneNumberVerificationStrategy = PhoneCodeStrategy;

@@ -11,2 +12,10 @@ export type PreparePhoneNumberVerificationParams = {

export type AttemptPhoneNumberVerificationParams = {
code: string;
};
export type SetReservedForSecondFactorParams = {
reserved: boolean;
};
export interface PhoneNumberResource extends ClerkResource {

@@ -21,8 +30,6 @@ id: string;

prepareVerification: () => Promise<PhoneNumberResource>;
attemptVerification: (code: string) => Promise<PhoneNumberResource>;
attemptVerification: (params: AttemptPhoneNumberVerificationParams) => Promise<PhoneNumberResource>;
makeDefaultSecondFactor: () => Promise<PhoneNumberResource>;
setReservedForSecondFactor: (
reserve: boolean,
) => Promise<PhoneNumberResource>;
setReservedForSecondFactor: (params: SetReservedForSecondFactorParams) => Promise<PhoneNumberResource>;
destroy: () => Promise<void>;
}
import { ClerkResource } from './resource';
import { GetSessionTokenOptions, TokenResource } from './token';
import { TokenResource } from './token';
import { UserResource } from './user';

@@ -16,3 +16,3 @@

touch: () => Promise<SessionResource>;
getToken: (options?: GetSessionTokenOptions) => Promise<string>;
getToken: GetToken;
createdAt: Date;

@@ -64,1 +64,4 @@ updatedAt: Date;

}
export type GetTokenOptions = { template: string; leewayInSeconds?: number; skipCache?: boolean };
export type GetToken = (options?: GetTokenOptions) => Promise<string>;

@@ -1,6 +0,44 @@

import { EmailAddressVerificationStrategy } from './emailAddress';
import { AuthenticateWithRedirectParams, OAuthStrategy } from './oauth';
import {
EmailCodeAttempt,
EmailCodeConfig,
EmailCodeFactor,
EmailLinkConfig,
EmailLinkFactor,
OAuthConfig,
OauthFactor,
PasswordAttempt,
PasswordFactor,
PhoneCodeAttempt,
PhoneCodeConfig,
PhoneCodeFactor,
PhoneCodeSecondFactorConfig,
Web3Attempt,
Web3SignatureConfig,
Web3SignatureFactor,
} from './factors';
import {
EmailAddressIdentifier,
PhoneNumberIdentifier,
UsernameIdentifier,
Web3WalletIdentifier,
} from './identifiers';
import {
ClerkResourceJSON,
SignInFirstFactorJSON,
SignInSecondFactorJSON,
UserDataJSON,
VerificationJSON,
} from './json';
import { AuthenticateWithRedirectParams } from './oauth';
import { ClerkResource } from './resource';
import { SnakeToCamel } from './utils';
import {
EmailCodeStrategy,
EmailLinkStrategy,
OAuthStrategy,
PasswordStrategy,
PhoneCodeStrategy,
TicketStrategy,
Web3Strategy,
} from './strategies';
import {
CreateMagicLinkFlowReturn,

@@ -10,3 +48,2 @@ StartMagicLinkFlowParams,

} from './verification';
import { Web3Strategy } from './web3';
import { AuthenticateWithWeb3Params } from './web3Wallet';

@@ -17,4 +54,4 @@

supportedIdentifiers: SignInIdentifier[];
supportedFirstFactors: SignInFactor[];
supportedSecondFactors: SignInFactor[];
supportedFirstFactors: SignInFirstFactor[];
supportedSecondFactors: SignInSecondFactor[];
firstFactorVerification: VerificationResource;

@@ -26,9 +63,11 @@ secondFactorVerification: VerificationResource;

create: (params: SignInParams) => Promise<SignInResource>;
create: (params: SignInCreateParams) => Promise<SignInResource>;
prepareFirstFactor: (
strategy: PrepareFirstFactorParams,
params: PrepareFirstFactorParams,
) => Promise<SignInResource>;
attemptFirstFactor: (params: AttemptFactorParams) => Promise<SignInResource>;
attemptFirstFactor: (
params: AttemptFirstFactorParams,
) => Promise<SignInResource>;

@@ -39,3 +78,5 @@ prepareSecondFactor: (

attemptSecondFactor: (params: AttemptFactorParams) => Promise<SignInResource>;
attemptSecondFactor: (
params: AttemptSecondFactorParams,
) => Promise<SignInResource>;

@@ -46,7 +87,2 @@ authenticateWithRedirect: (

createMagicLinkFlow: () => CreateMagicLinkFlowReturn<
SignInStartMagicLinkFlowParams,
SignInResource
>;
authenticateWithWeb3: (

@@ -57,26 +93,9 @@ params: AuthenticateWithWeb3Params,

authenticateWithMetamask: () => Promise<SignInResource>;
createMagicLinkFlow: () => CreateMagicLinkFlowReturn<
SignInStartMagicLinkFlowParams,
SignInResource
>;
}
export type AttemptFirstFactorWithMagicLinkParams = {
email_address_id: string;
redirect_url: string;
signal?: AbortSignal;
};
export type SignInIdentifier =
| 'username'
| 'email_address'
| 'phone_number'
| 'web3_wallet';
export type IdentificationStrategy = SignInIdentifier | OAuthStrategy;
export type SignInStrategyName =
| 'password'
| 'phone_code'
| Web3Strategy
| EmailAddressVerificationStrategy
| OAuthStrategy
| 'ticket';
export type SignInStatus =

@@ -88,37 +107,9 @@ | 'needs_identifier'

export type PreferredSignInStrategy = 'password' | 'otp';
export type SignInIdentifier =
| UsernameIdentifier
| EmailAddressIdentifier
| PhoneNumberIdentifier
| Web3WalletIdentifier;
export type EmailCodeFactor = {
strategy: Extract<SignInStrategyName, 'email_code'>;
email_address_id: string;
safe_identifier: string;
};
export type EmailLinkFactor = {
strategy: Extract<SignInStrategyName, 'email_link'>;
email_address_id: string;
safe_identifier: string;
};
export type PhoneCodeFactor = {
strategy: Extract<SignInStrategyName, 'phone_code'>;
phone_number_id: string;
safe_identifier: string;
default?: boolean;
};
export type Web3SignatureFactor = {
strategy: Extract<SignInStrategyName, Web3Strategy>;
web3_wallet_id: string;
};
export type PasswordFactor = {
strategy: Extract<SignInStrategyName, 'password'>;
};
export type OauthFactor = {
strategy: OAuthStrategy;
};
export type SignInFactor =
export type SignInFirstFactor =
| EmailCodeFactor

@@ -131,77 +122,59 @@ | EmailLinkFactor

export type SignInSecondFactor = PhoneCodeFactor;
export interface UserData {
firstName?: string;
lastName?: string;
profileImageUrl?: string;
}
export type SignInFactor = SignInFirstFactor | SignInSecondFactor;
export type PrepareFirstFactorParams =
| Omit<EmailCodeFactor, 'safe_identifier'>
| (Omit<EmailLinkFactor, 'safe_identifier'> & { redirect_url: string })
| Omit<PhoneCodeFactor, 'safe_identifier'>
| Web3SignatureFactor
| (OauthFactor & {
redirect_url: string;
action_complete_redirect_url: string;
});
| EmailCodeConfig
| EmailLinkConfig
| PhoneCodeConfig
| Web3SignatureConfig
| OAuthConfig;
export type PrepareSecondFactorParams = Pick<PhoneCodeFactor, 'strategy'> & {
phone_number_id?: string;
};
export type AttemptFirstFactorParams =
| EmailCodeAttempt
| PhoneCodeAttempt
| PasswordAttempt
| Web3Attempt;
export type AttemptFactorParams =
export type PrepareSecondFactorParams = PhoneCodeSecondFactorConfig;
export type AttemptSecondFactorParams = PhoneCodeAttempt;
export type SignInCreateParams = (
| {
strategy: Extract<SignInStrategyName, 'email_code' | 'phone_code'>;
code: string;
strategy: OAuthStrategy;
redirectUrl: string;
actionCompleteRedirectUrl?: string;
}
| {
strategy: Extract<SignInStrategyName, 'password'>;
strategy: TicketStrategy;
ticket: string;
}
| {
strategy: PasswordStrategy;
password: string;
identifier: string;
}
| {
strategy: Extract<SignInStrategyName, Web3Strategy>;
signature: string;
};
strategy: PhoneCodeStrategy | EmailCodeStrategy | Web3Strategy;
identifier: string;
}
| {
strategy: EmailLinkStrategy;
identifier: string;
redirectUrl?: string;
}
| {
identifier: string;
}
| { transfer?: boolean }
) & { transfer?: boolean };
export interface UserData {
first_name?: string;
last_name?: string;
profile_image_url?: string;
}
type SignInAttributes = {
/**
* An email address, phone or username to identify the attempt.
*/
identifier?: string;
/**
* The first step of the strategy to perform.
*/
strategy?: SignInStrategyName;
/**
* Required if the strategy is "password".
* The password to attempt to sign in with.
*/
password?: string;
/**
* Required if the strategy is one of the OAuth providers.
* This is the URL that the user will be redirected to after the OAuth verification completes.
*/
redirect_url?: string;
/**
* Organization invitation ticket.
* The logic is handled by the backend after the token and strategy is sent.
*/
ticket?: string;
/**
* Optional if the strategy is one of the OAuth providers.
* If the OAuth verification results in a completed Sign in, this is the URL that
* the user will be redirected to.
*/
action_complete_redirect_url?: string;
} & { transfer: boolean };
export type SignInParams = Partial<
SnakeToCamel<SignInAttributes> & SignInAttributes
>;
export interface SignInStartMagicLinkFlowParams

@@ -211,1 +184,25 @@ extends StartMagicLinkFlowParams {

}
export type SignInStrategy =
| PasswordStrategy
| PhoneCodeStrategy
| EmailCodeStrategy
| EmailLinkStrategy
| TicketStrategy
| Web3Strategy
| OAuthStrategy;
export interface SignInJSON extends ClerkResourceJSON {
object: 'sign_in';
id: string;
status: SignInStatus;
supported_identifiers: SignInIdentifier[];
supported_external_accounts: OAuthStrategy[];
identifier: string;
user_data: UserDataJSON;
supported_first_factors: SignInFirstFactorJSON[];
supported_second_factors: SignInSecondFactorJSON[];
first_factor_verification: VerificationJSON | null;
second_factor_verification: VerificationJSON | null;
created_session_id: string | null;
}
import {
EmailAddressVerificationStrategy,
PrepareEmailAddressVerificationParams,
} from './emailAddress';
import { AuthenticateWithRedirectParams, OAuthStrategy } from './oauth';
BirthdayAttribute,
FirstNameAttribute,
GenderAttribute,
LastNameAttribute,
PasswordAttribute,
} from './attributes';
import { AttemptEmailAddressVerificationParams, PrepareEmailAddressVerificationParams } from './emailAddress';
import {
PhoneNumberVerificationStrategy,
PreparePhoneNumberVerificationParams,
} from './phoneNumber';
EmailAddressIdentifier,
EmailAddressOrPhoneNumberIdentifier,
PhoneNumberIdentifier,
UsernameIdentifier,
Web3WalletIdentifier,
} from './identifiers';
import { AuthenticateWithRedirectParams } from './oauth';
import { AttemptPhoneNumberVerificationParams, PreparePhoneNumberVerificationParams } from './phoneNumber';
import { ClerkResource } from './resource';
import { SnakeToCamel } from './utils';
import {
CreateMagicLinkFlowReturn,
StartMagicLinkFlowParams,
VerificationAttemptParams,
VerificationResource,
} from './verification';
import { Web3Strategy } from './web3';
import { AuthenticateWithWeb3Params } from './web3Wallet';
EmailCodeStrategy,
EmailLinkStrategy,
OAuthStrategy,
PhoneCodeStrategy,
TicketStrategy,
Web3Strategy,
} from './strategies';
import { CreateMagicLinkFlowReturn, StartMagicLinkFlowParams, VerificationResource } from './verification';
import { AuthenticateWithWeb3Params, GenerateSignature } from './web3Wallet';
import type { SnakeToCamel } from './utils';

@@ -35,3 +45,2 @@ export interface SignUpResource extends ClerkResource {

web3wallet: string | null;
externalAccount: any;
hasPassword: boolean;

@@ -42,47 +51,28 @@ unsafeMetadata: Record<string, unknown>;

create: (params: SignUpParams) => Promise<SignUpResource>;
create: (params: SignUpCreateParams) => Promise<SignUpResource>;
update: (params: SignUpParams) => Promise<SignUpResource>;
update: (params: SignUpUpdateParams) => Promise<SignUpResource>;
prepareVerification: (
strategy: SignUpVerificationStrategy,
) => Promise<SignUpResource>;
prepareVerification: (params: PrepareVerificationParams) => Promise<SignUpResource>;
attemptVerification: (
params: SignUpVerificationAttemptParams,
) => Promise<SignUpResource>;
attemptVerification: (params: AttemptVerificationParams) => Promise<SignUpResource>;
prepareEmailAddressVerification: (
p?: PrepareEmailAddressVerificationParams,
) => Promise<SignUpResource>;
prepareEmailAddressVerification: (params?: PrepareEmailAddressVerificationParams) => Promise<SignUpResource>;
attemptEmailAddressVerification: (
params: VerificationAttemptParams,
) => Promise<SignUpResource>;
attemptEmailAddressVerification: (params: AttemptEmailAddressVerificationParams) => Promise<SignUpResource>;
createMagicLinkFlow: () => CreateMagicLinkFlowReturn<
StartMagicLinkFlowParams,
SignUpResource
>;
preparePhoneNumberVerification: (params?: PreparePhoneNumberVerificationParams) => Promise<SignUpResource>;
preparePhoneNumberVerification: (
p?: PreparePhoneNumberVerificationParams,
) => Promise<SignUpResource>;
attemptPhoneNumberVerification: (params: AttemptPhoneNumberVerificationParams) => Promise<SignUpResource>;
attemptPhoneNumberVerification: (
params: VerificationAttemptParams,
) => Promise<SignUpResource>;
prepareWeb3WalletVerification: () => Promise<SignUpResource>;
attemptWeb3WalletVerification: (
params: AuthenticateWithWeb3Params,
) => Promise<SignUpResource>;
attemptWeb3WalletVerification: (params: AttemptWeb3WalletVerificationParams) => Promise<SignUpResource>;
authenticateWithRedirect: (
params: AuthenticateWithRedirectParams,
) => Promise<void>;
createMagicLinkFlow: () => CreateMagicLinkFlowReturn<StartMagicLinkFlowParams, SignUpResource>;
authenticateWithWeb3: (
params: AuthenticateWithWeb3Params,
) => Promise<SignUpResource>;
authenticateWithRedirect: (params: AuthenticateWithRedirectParams) => Promise<void>;
authenticateWithWeb3: (params: AuthenticateWithWeb3Params) => Promise<SignUpResource>;
authenticateWithMetamask: () => Promise<SignUpResource>;

@@ -93,42 +83,72 @@ }

export type SignUpField = SignUpAttribute | SignUpIdentificationField;
export type SignUpField = SignUpAttributeField | SignUpIdentificationField;
export type SignUpIdentificationField =
| 'email_address'
| 'phone_number'
| 'username'
| 'email_address_or_phone_number'
| 'web3_wallet';
export type PrepareVerificationParams =
| {
strategy: EmailCodeStrategy;
}
| {
strategy: EmailLinkStrategy;
redirectUrl?: string;
}
| {
strategy: PhoneCodeStrategy;
}
| {
strategy: Web3Strategy;
};
export type SignUpIdentification = SignUpIdentificationField | OAuthStrategy;
export type AttemptVerificationParams =
| {
strategy: EmailCodeStrategy;
code: string;
}
| {
strategy: PhoneCodeStrategy;
code: string;
}
| {
strategy: Web3Strategy;
signature: string;
};
export type SignUpAttribute =
| 'first_name'
| 'last_name'
| 'password'
| 'birthday'
| 'gender';
export type AttemptWeb3WalletVerificationParams = {
generateSignature: GenerateSignature;
};
type OrganizationSignUpStrategy = 'ticket';
export type SignUpAttributeField =
| FirstNameAttribute
| LastNameAttribute
| PasswordAttribute
| BirthdayAttribute
| GenderAttribute;
export type SignUpAttributes = {
external_account_strategy: string;
external_account_redirect_url: string;
external_account_action_complete_redirect_url: string;
strategy: OAuthStrategy | OrganizationSignUpStrategy;
redirect_url: string;
action_complete_redirect_url: string;
transfer: boolean;
unsafe_metadata: Record<string, unknown>;
invitation_token: string;
ticket: string;
} & Record<
SignUpAttribute | Exclude<SignUpIdentification, OAuthStrategy>,
string
>;
// TODO: SignUpVerifiableField or SignUpIdentifier?
export type SignUpVerifiableField =
| UsernameIdentifier
| EmailAddressIdentifier
| PhoneNumberIdentifier
| EmailAddressOrPhoneNumberIdentifier
| Web3WalletIdentifier;
export type SignUpParams = Partial<
SnakeToCamel<SignUpAttributes> & SignUpAttributes
// TODO: Does it make sense that the identification *field* holds a *strategy*?
export type SignUpIdentificationField = SignUpVerifiableField | OAuthStrategy;
// TODO: Replace with discriminated union type
export type SignUpCreateParams = Partial<
{
externalAccountStrategy: string;
externalAccountRedirectUrl: string;
externalAccountActionCompleteRedirectUrl: string;
strategy: OAuthStrategy | TicketStrategy;
redirectUrl: string;
actionCompleteRedirectUrl: string;
transfer: boolean;
unsafeMetadata: Record<string, unknown>;
ticket: string;
} & SnakeToCamel<Record<SignUpAttributeField | SignUpVerifiableField, string>>
>;
export type SignUpUpdateParams = SignUpCreateParams;
export interface SignUpVerificationsResource {

@@ -145,14 +165,1 @@ emailAddress: SignUpVerificationResource;

}
export type SignUpVerificationStrategy =
| EmailAddressVerificationStrategy
| PhoneNumberVerificationStrategy
| Web3Strategy;
export type BaseVerificationAttemptParams = {
strategy: SignUpVerificationStrategy;
};
export type SignUpVerificationAttemptParams = {
strategy: SignUpVerificationStrategy;
} & VerificationAttemptParams;
import { SessionJSON, UserJSON } from './json';
import { SessionResource } from './session';
import { GetSessionTokenOptions } from './token';
import { UserResource } from './user';
export type ServerGetTokenOptions = { template?: string };
export type ServerGetToken = (options?: ServerGetTokenOptions) => Promise<string>;
export type ServerSideAuth = {
sessionId: string | null;
userId: string | null;
getToken: (options?: GetSessionTokenOptions) => Promise<string | null>;
getToken: ServerGetToken;
};

@@ -11,0 +13,0 @@

import { JWT } from './jwt';
import { ClerkResource } from './resource';
export type JWTService = 'clerk' | 'hasura' | 'firebase';
export type GetUserTokenOptions = {
leewayInSeconds?: number;
};
export type GetSessionTokenOptions = {
leewayInSeconds?: number;
template?: string;
throwOnError?: boolean;
skipCache?: boolean;
};
export interface TokenResource extends ClerkResource {

@@ -18,0 +5,0 @@ jwt: JWT;

@@ -35,4 +35,8 @@ import { EmailAddressResource } from './emailAddress';

update: (params: UpdateUserParams) => Promise<UserResource>;
createEmailAddress: (email: string) => Promise<EmailAddressResource>;
createPhoneNumber: (phoneNumber: string) => Promise<PhoneNumberResource>;
createEmailAddress: (
params: CreateEmailAddressParams,
) => Promise<EmailAddressResource>;
createPhoneNumber: (
params: CreatePhoneNumberParams,
) => Promise<PhoneNumberResource>;
twoFactorEnabled: () => boolean;

@@ -43,5 +47,9 @@ isPrimaryIdentification: (

getSessions: () => Promise<SessionWithActivitiesResource[]>;
setProfileImage: (file: Blob | File) => Promise<ImageResource>;
setProfileImage: (params: SetProfileImageParams) => Promise<ImageResource>;
}
export type CreateEmailAddressParams = { email: string };
export type CreatePhoneNumberParams = { phoneNumber: string };
export type SetProfileImageParams = { file: Blob | File };
type UpdateUserJSON = Pick<

@@ -59,4 +67,2 @@ UserJSON,

export type UpdateUserParams = Partial<
SnakeToCamel<UpdateUserJSON> & UpdateUserJSON
>;
export type UpdateUserParams = Partial<SnakeToCamel<UpdateUserJSON>>;
import { ClerkResourceJSON } from './json';
import { OAuthStrategy } from './oauth';
import { ClerkResource } from './resource';
import { Web3Strategy } from './web3';
import { OAuthStrategy, Web3Strategy } from './strategies';

@@ -6,0 +5,0 @@ type Attribute =

@@ -15,8 +15,3 @@ import { ClerkAPIError } from './api';

export type VerificationStatus =
| 'unverified'
| 'verified'
| 'transferable'
| 'failed'
| 'expired';
export type VerificationStatus = 'unverified' | 'verified' | 'transferable' | 'failed' | 'expired';

@@ -33,5 +28,3 @@ export interface CodeVerificationAttemptParam {

export type VerificationAttemptParams =
| CodeVerificationAttemptParam
| SignatureVerificationAttemptParam;
export type VerificationAttemptParams = CodeVerificationAttemptParam | SignatureVerificationAttemptParam;

@@ -38,0 +31,0 @@ export interface StartMagicLinkFlowParams {

@@ -1,3 +0,3 @@

export type Web3Provider = 'metamask';
export type MetamaskWeb3Provider = 'metamask';
export type Web3Strategy = `web3_${Web3Provider}_signature`;
export type Web3Provider = MetamaskWeb3Provider;
import { ClerkResource } from './resource';
import { VerificationResource } from './verification';
import { Web3Strategy } from './web3';
export type PrepareWeb3WalletVerificationParams = {
strategy: Web3Strategy;
};
export interface Web3WalletResource extends ClerkResource {

@@ -15,5 +10,7 @@ id: string;

export type GenerateSignature = (opts: GenerateSignatureParams) => Promise<string>;
export interface AuthenticateWithWeb3Params {
identifier: string;
generateSignature: (opts: GenerateSignatureParams) => Promise<string>;
generateSignature: GenerateSignature;
}

@@ -20,0 +17,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc