@passageidentity/passage-node
Version:
Passkey Complete for Node.js - Integrate into your Node.js API or service to enable a completely passwordless standalone auth solution with Passage by 1Password
1,087 lines (1,053 loc) • 28.5 kB
TypeScript
interface ConfigurationParameters {
basePath?: string;
fetchApi?: FetchAPI;
middleware?: Middleware[];
queryParamsStringify?: (params: HTTPQuery) => string;
username?: string;
password?: string;
apiKey?: string | Promise<string> | ((name: string) => string | Promise<string>);
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string | Promise<string>);
headers?: HTTPHeaders;
credentials?: RequestCredentials;
}
declare class Configuration {
private configuration;
constructor(configuration?: ConfigurationParameters);
set config(configuration: Configuration);
get basePath(): string;
get fetchApi(): FetchAPI | undefined;
get middleware(): Middleware[];
get queryParamsStringify(): (params: HTTPQuery) => string;
get username(): string | undefined;
get password(): string | undefined;
get apiKey(): ((name: string) => string | Promise<string>) | undefined;
get accessToken(): ((name?: string, scopes?: string[]) => string | Promise<string>) | undefined;
get headers(): HTTPHeaders | undefined;
get credentials(): RequestCredentials | undefined;
}
declare class ResponseError extends Error {
response: Response;
name: "ResponseError";
constructor(response: Response, msg?: string);
}
type FetchAPI = WindowOrWorkerGlobalScope['fetch'];
type HTTPHeaders = {
[key: string]: string;
};
type HTTPQuery = {
[key: string]: string | number | null | boolean | Array<string | number | null | boolean> | Set<string | number | null | boolean> | HTTPQuery;
};
interface FetchParams {
url: string;
init: RequestInit;
}
interface RequestContext {
fetch: FetchAPI;
url: string;
init: RequestInit;
}
interface ResponseContext {
fetch: FetchAPI;
url: string;
init: RequestInit;
response: Response;
}
interface ErrorContext {
fetch: FetchAPI;
url: string;
init: RequestInit;
error: unknown;
response?: Response;
}
interface Middleware {
pre?(context: RequestContext): Promise<FetchParams | void>;
post?(context: ResponseContext): Promise<Response | void>;
onError?(context: ErrorContext): Promise<Response | void>;
}
/**
* Passage Management API
* Passage\'s management API to manage your Passage apps and users.
*
* The version of the OpenAPI document: 1
* Contact: support@passage.id
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface AppleUserSocialConnection
*/
interface AppleUserSocialConnection {
/**
* The external ID of the Social Connection.
* @type {string}
* @memberof AppleUserSocialConnection
*/
providerId: string;
/**
*
* @type {Date}
* @memberof AppleUserSocialConnection
*/
createdAt: Date;
/**
*
* @type {Date}
* @memberof AppleUserSocialConnection
*/
lastLoginAt: Date;
/**
* The email of connected social user.
* @type {string}
* @memberof AppleUserSocialConnection
*/
providerIdentifier: string;
}
/**
* Passage Management API
* Passage\'s management API to manage your Passage apps and users.
*
* The version of the OpenAPI document: 1
* Contact: support@passage.id
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
* The channel for magic link delivery: "email" or "phone". Required if "send" is true.
* @export
*/
declare const MagicLinkChannel: {
readonly Email: "email";
readonly Phone: "phone";
};
type MagicLinkChannel = typeof MagicLinkChannel[keyof typeof MagicLinkChannel];
/**
* Passage Management API
* Passage\'s management API to manage your Passage apps and users.
*
* The version of the OpenAPI document: 1
* Contact: support@passage.id
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
* language of the email or sms to send
* @export
*/
declare const MagicLinkLanguage: {
readonly De: "de";
readonly En: "en";
readonly Es: "es";
readonly It: "it";
readonly Pl: "pl";
readonly Pt: "pt";
readonly Zh: "zh";
};
type MagicLinkLanguage = typeof MagicLinkLanguage[keyof typeof MagicLinkLanguage];
/**
* Passage Management API
* Passage\'s management API to manage your Passage apps and users.
*
* The version of the OpenAPI document: 1
* Contact: support@passage.id
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
* The type of magic link to create: "login" or "verify_identifier". Defaults to "login".
* @export
*/
declare const MagicLinkType: {
readonly Login: "login";
readonly VerifyIdentifier: "verify_identifier";
};
type MagicLinkType = typeof MagicLinkType[keyof typeof MagicLinkType];
/**
* Passage Management API
* Passage\'s management API to manage your Passage apps and users.
*
* The version of the OpenAPI document: 1
* Contact: support@passage.id
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface CreateUserArgs
*/
interface CreateUserArgs {
/**
* Email of the new user. Either this or `phone` is required; both may be provided.
* @type {string}
* @memberof CreateUserArgs
*/
email?: string;
/**
* Phone number of the new user. Either this or `email` is required; both may be provided.
* @type {string}
* @memberof CreateUserArgs
*/
phone?: string;
/**
*
* @type {object}
* @memberof CreateUserArgs
*/
userMetadata?: object;
}
/**
* Passage Management API
* Passage\'s management API to manage your Passage apps and users.
*
* The version of the OpenAPI document: 1
* Contact: support@passage.id
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface GithubUserSocialConnection
*/
interface GithubUserSocialConnection {
/**
* The external ID of the Social Connection.
* @type {string}
* @memberof GithubUserSocialConnection
*/
providerId: string;
/**
*
* @type {Date}
* @memberof GithubUserSocialConnection
*/
createdAt: Date;
/**
*
* @type {Date}
* @memberof GithubUserSocialConnection
*/
lastLoginAt: Date;
/**
* The email of connected social user.
* @type {string}
* @memberof GithubUserSocialConnection
*/
providerIdentifier: string;
}
/**
* Passage Management API
* Passage\'s management API to manage your Passage apps and users.
*
* The version of the OpenAPI document: 1
* Contact: support@passage.id
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface GoogleUserSocialConnection
*/
interface GoogleUserSocialConnection {
/**
* The external ID of the Social Connection.
* @type {string}
* @memberof GoogleUserSocialConnection
*/
providerId: string;
/**
*
* @type {Date}
* @memberof GoogleUserSocialConnection
*/
createdAt: Date;
/**
*
* @type {Date}
* @memberof GoogleUserSocialConnection
*/
lastLoginAt: Date;
/**
* The email of connected social user.
* @type {string}
* @memberof GoogleUserSocialConnection
*/
providerIdentifier: string;
}
/**
* Passage Management API
* Passage\'s management API to manage your Passage apps and users.
*
* The version of the OpenAPI document: 1
* Contact: support@passage.id
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
* Contains the light and dark SVG icons that represent the brand of those devices
* Values can be null or base64 encoded SVG. Example of SVG output:
* data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDE5MiAxOTIiIGhlaWdodD0iMjRweCIgdmlld0JveD0iMCAwIDE5MiAxOTIiIHdpZHRoPSIyNHB4Ij48cmVjdCBmaWxsPSJub25lIiBoZWlnaHQ9IjE5MiIgd2lkdGg9IjE5MiIgeT0iMCIvPjxnPjxwYXRoIGQ9Ik02OS4yOSwxMDZjLTMuNDYsNS45Ny05LjkxLDEwLTE3LjI5LDEwYy0xMS4wMywwLTIwLTguOTctMjAtMjBzOC45Ny0yMCwyMC0yMCBjNy4zOCwwLDEzLjgzLDQuMDMsMTcuMjksMTBoMjUuNTVDOTAuMyw2Ni41NCw3Mi44Miw1Miw1Miw1MkMyNy43NCw1Miw4LDcxLjc0LDgsOTZzMTkuNzQsNDQsNDQsNDRjMjAuODIsMCwzOC4zLTE0LjU0LDQyLjg0LTM0IEg2OS4yOXoiIGZpbGw9IiM0Mjg1RjQiLz48cmVjdCBmaWxsPSIjRkJCQzA0IiBoZWlnaHQ9IjI0IiB3aWR0aD0iNDQiIHg9Ijk0IiB5PSI4NCIvPjxwYXRoIGQ9Ik05NC4zMiw4NEg2OHYwLjA1YzIuNSwzLjM0LDQsNy40Nyw0LDExLjk1cy0xLjUsOC42MS00LDExLjk1VjEwOGgyNi4zMiBjMS4wOC0zLjgyLDEuNjgtNy44NCwxLjY4LTEyUzk1LjQxLDg3LjgyLDk0LjMyLDg0eiIgZmlsbD0iI0VBNDMzNSIvPjxwYXRoIGQ9Ik0xODQsMTA2djI2aC0xNnYtOGMwLTQuNDItMy41OC04LTgtOHMtOCwzLjU4LTgsOHY4aC0xNnYtMjZIMTg0eiIgZmlsbD0iIzM0QTg1MyIvPjxyZWN0IGZpbGw9IiMxODgwMzgiIGhlaWdodD0iMjQiIHdpZHRoPSI0OCIgeD0iMTM2IiB5PSI4NCIvPjwvZz48L3N2Zz4=
* @export
* @interface WebAuthnIcons
*/
interface WebAuthnIcons {
/**
*
* @type {string}
* @memberof WebAuthnIcons
*/
light: string | null;
/**
*
* @type {string}
* @memberof WebAuthnIcons
*/
dark: string | null;
}
/**
* Passage Management API
* Passage\'s management API to manage your Passage apps and users.
*
* The version of the OpenAPI document: 1
* Contact: support@passage.id
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
* The type of this credential
* @export
*/
declare const WebAuthnType: {
readonly Passkey: "passkey";
readonly SecurityKey: "security_key";
readonly Platform: "platform";
};
type WebAuthnType = typeof WebAuthnType[keyof typeof WebAuthnType];
/**
* Passage Management API
* Passage\'s management API to manage your Passage apps and users.
*
* The version of the OpenAPI document: 1
* Contact: support@passage.id
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface WebAuthnDevices
*/
interface WebAuthnDevices {
/**
* The first time this webAuthn device was used to authenticate the user
* @type {Date}
* @memberof WebAuthnDevices
*/
createdAt: Date;
/**
* The CredID for this webAuthn device
* @type {string}
* @memberof WebAuthnDevices
*/
credId: string;
/**
* The friendly name for the webAuthn device used to authenticate
* @type {string}
* @memberof WebAuthnDevices
*/
friendlyName: string;
/**
* The ID of the webAuthn device used for authentication
* @type {string}
* @memberof WebAuthnDevices
*/
id: string;
/**
* The last time this webAuthn device was used to authenticate the user
* @type {Date}
* @memberof WebAuthnDevices
*/
lastLoginAt: Date;
/**
*
* @type {WebAuthnType}
* @memberof WebAuthnDevices
*/
type: WebAuthnType;
/**
* The last time this webAuthn device was updated
* @type {Date}
* @memberof WebAuthnDevices
*/
updatedAt: Date;
/**
* How many times this webAuthn device has been used to authenticate the user
* @type {number}
* @memberof WebAuthnDevices
*/
usageCount: number;
/**
*
* @type {WebAuthnIcons}
* @memberof WebAuthnDevices
*/
icons: WebAuthnIcons;
}
/**
* Passage Management API
* Passage\'s management API to manage your Passage apps and users.
*
* The version of the OpenAPI document: 1
* Contact: support@passage.id
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
*/
declare const UserStatus: {
readonly Active: "active";
readonly Inactive: "inactive";
readonly Pending: "pending";
};
type UserStatus = typeof UserStatus[keyof typeof UserStatus];
/**
* Passage Management API
* Passage\'s management API to manage your Passage apps and users.
*
* The version of the OpenAPI document: 1
* Contact: support@passage.id
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface MagicLink
*/
interface MagicLink {
/**
*
* @type {boolean}
* @memberof MagicLink
*/
activated: boolean;
/**
*
* @type {string}
* @memberof MagicLink
*/
appId: string;
/**
*
* @type {string}
* @memberof MagicLink
*/
id: string;
/**
*
* @type {string}
* @memberof MagicLink
*/
identifier: string;
/**
*
* @type {string}
* @memberof MagicLink
*/
redirectUrl: string;
/**
*
* @type {string}
* @memberof MagicLink
*/
secret: string;
/**
* time to live in minutes
* @type {number}
* @memberof MagicLink
*/
ttl: number;
/**
*
* @type {MagicLinkType}
* @memberof MagicLink
*/
type: MagicLinkType;
/**
*
* @type {string}
* @memberof MagicLink
*/
url: string;
/**
*
* @type {string}
* @memberof MagicLink
*/
userId: string;
}
/**
* Passage Management API
* Passage\'s management API to manage your Passage apps and users.
*
* The version of the OpenAPI document: 1
* Contact: support@passage.id
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
*/
declare const SocialConnectionType: {
readonly Apple: "apple";
readonly Github: "github";
readonly Google: "google";
};
type SocialConnectionType = typeof SocialConnectionType[keyof typeof SocialConnectionType];
/**
* Passage Management API
* Passage\'s management API to manage your Passage apps and users.
*
* The version of the OpenAPI document: 1
* Contact: support@passage.id
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
*/
declare const UserEventAction: {
readonly Register: "register";
readonly Login: "login";
readonly Other: "other";
};
type UserEventAction = typeof UserEventAction[keyof typeof UserEventAction];
/**
* Passage Management API
* Passage\'s management API to manage your Passage apps and users.
*
* The version of the OpenAPI document: 1
* Contact: support@passage.id
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
*/
declare const UserEventStatus: {
readonly Complete: "complete";
readonly Incomplete: "incomplete";
};
type UserEventStatus = typeof UserEventStatus[keyof typeof UserEventStatus];
/**
* Passage Management API
* Passage\'s management API to manage your Passage apps and users.
*
* The version of the OpenAPI document: 1
* Contact: support@passage.id
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface UserRecentEvent
*/
interface UserRecentEvent {
/**
*
* @type {Date}
* @memberof UserRecentEvent
*/
createdAt: Date;
/**
*
* @type {Date}
* @memberof UserRecentEvent
*/
completedAt: Date | null;
/**
*
* @type {string}
* @memberof UserRecentEvent
*/
id: string;
/**
*
* @type {string}
* @memberof UserRecentEvent
*/
ipAddr: string;
/**
*
* @type {UserEventStatus}
* @memberof UserRecentEvent
*/
status: UserEventStatus;
/**
*
* @type {string}
* @memberof UserRecentEvent
*/
type: string;
/**
* The raw user agent value from the originating device
* @type {string}
* @memberof UserRecentEvent
*/
userAgent: string;
/**
* A display-friendly version of the user agent
* @type {string}
* @memberof UserRecentEvent
*/
userAgentDisplay: string;
/**
*
* @type {UserEventAction}
* @memberof UserRecentEvent
*/
action: UserEventAction;
/**
*
* @type {SocialConnectionType}
* @memberof UserRecentEvent
*/
socialLoginType: SocialConnectionType | null;
}
/**
* Passage Management API
* Passage\'s management API to manage your Passage apps and users.
*
* The version of the OpenAPI document: 1
* Contact: support@passage.id
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface UserSocialConnections
*/
interface UserSocialConnections {
/**
*
* @type {AppleUserSocialConnection}
* @memberof UserSocialConnections
*/
apple?: AppleUserSocialConnection;
/**
*
* @type {GithubUserSocialConnection}
* @memberof UserSocialConnections
*/
github?: GithubUserSocialConnection;
/**
*
* @type {GoogleUserSocialConnection}
* @memberof UserSocialConnections
*/
google?: GoogleUserSocialConnection;
}
/**
* Passage Management API
* Passage\'s management API to manage your Passage apps and users.
*
* The version of the OpenAPI document: 1
* Contact: support@passage.id
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface PassageUser
*/
interface PassageUser {
/**
*
* @type {Date}
* @memberof PassageUser
*/
createdAt: Date;
/**
*
* @type {string}
* @memberof PassageUser
*/
email: string;
/**
*
* @type {boolean}
* @memberof PassageUser
*/
emailVerified: boolean;
/**
* The external ID of the user. Only set if the user was created in a Flex app.
* @type {string}
* @memberof PassageUser
*/
externalId: string;
/**
*
* @type {string}
* @memberof PassageUser
*/
id: string;
/**
*
* @type {Date}
* @memberof PassageUser
*/
lastLoginAt: Date;
/**
*
* @type {number}
* @memberof PassageUser
*/
loginCount: number;
/**
*
* @type {string}
* @memberof PassageUser
*/
phone: string;
/**
*
* @type {boolean}
* @memberof PassageUser
*/
phoneVerified: boolean;
/**
*
* @type {Array<UserRecentEvent>}
* @memberof PassageUser
*/
recentEvents: Array<UserRecentEvent>;
/**
*
* @type {UserSocialConnections}
* @memberof PassageUser
*/
socialConnections: UserSocialConnections;
/**
*
* @type {UserStatus}
* @memberof PassageUser
*/
status: UserStatus;
/**
*
* @type {Date}
* @memberof PassageUser
*/
updatedAt: Date;
/**
*
* @type {object}
* @memberof PassageUser
*/
userMetadata: object | null;
/**
*
* @type {boolean}
* @memberof PassageUser
*/
webauthn: boolean;
/**
*
* @type {Array<WebAuthnDevices>}
* @memberof PassageUser
*/
webauthnDevices: Array<WebAuthnDevices>;
/**
* List of credential types that have been used for authentication
* @type {Array<WebAuthnType>}
* @memberof PassageUser
*/
webauthnTypes: Array<WebAuthnType>;
}
/**
* Passage Management API
* Passage\'s management API to manage your Passage apps and users.
*
* The version of the OpenAPI document: 1
* Contact: support@passage.id
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface UpdateUserArgs
*/
interface UpdateUserArgs {
/**
*
* @type {string}
* @memberof UpdateUserArgs
*/
email?: string;
/**
*
* @type {string}
* @memberof UpdateUserArgs
*/
phone?: string;
/**
*
* @type {object}
* @memberof UpdateUserArgs
*/
userMetadata?: object;
}
interface PassageInstanceConfig {
appId: string;
apiConfiguration: Configuration;
}
/**
* Base class for Passage sub-classes.
*/
declare class PassageBase {
protected readonly config: PassageInstanceConfig;
/**
* PassageBase class constructor.
* @param {PassageInstanceConfig} config config properties for Passage instance
*/
constructor(config: PassageInstanceConfig);
/**
* Handle errors from PassageFlex API
* @param {unknown} err error from node-fetch request
* @return {Promise<void>}
*/
protected parseError(err: unknown): Promise<Error>;
}
type MagicLinkArgsBase = {
type: MagicLinkType;
send: boolean;
};
type MagicLinkWithEmailArgs = {
email: string;
} & MagicLinkArgsBase;
type MagicLinkWithPhoneArgs = {
phone: string;
} & MagicLinkArgsBase;
type MagicLinkWithUserArgs = {
userId: string;
channel: MagicLinkChannel;
} & MagicLinkArgsBase;
type CreateMagicLinkArgs = MagicLinkWithEmailArgs | MagicLinkWithPhoneArgs | MagicLinkWithUserArgs;
type MagicLinkOptions = {
language?: MagicLinkLanguage;
magicLinkPath?: string;
redirectUrl?: string;
ttl?: number;
};
/**
* Auth class that provides methods for validating JWTs and creating Magic Links.
*/
declare class Auth extends PassageBase {
private readonly jwks;
private readonly magicLinksApi;
/**
* Auth class constructor.
* @param {PassageInstanceConfig} config config properties for Passage instance
*/
constructor(config: PassageInstanceConfig);
/**
* Validate that a JWT is valid and return the Passage user ID associated with the token.
*
* @param {string} jwt The authentication token to be validated
* @return {string} User ID of the Passage user
*/
validateJwt(jwt: string): Promise<string>;
/**
* Create a Magic Link for your app.
*
* @param {CreateMagicLinkArgs} args options for creating a MagicLink.
* @param {MagicLinkOptions} options options for creating a MagicLink.
* @return {Promise<MagicLink>} Passage MagicLink object
*/
createMagicLink(args: CreateMagicLinkArgs, options?: MagicLinkOptions): Promise<MagicLink>;
}
/**
* User class for handling operations to get and update user information.
*/
declare class User extends PassageBase {
private readonly usersApi;
private readonly userDevicesApi;
private readonly tokensApi;
/**
* User class constructor.
* @param {PassageInstanceConfig} config config properties for Passage instance
*/
constructor(config: PassageInstanceConfig);
/**
* Get a user's object using their user ID.
*
* @param {string} userId The Passage user ID
* @return {Promise<PassageUser>} Passage User object
*/
get(userId: string): Promise<PassageUser>;
/**
* Get a user's object using their user identifier.
*
* @param {string} identifier The Passage user email or phone number
* @return {Promise<PassageUser>} Passage User object
*/
getByIdentifier(identifier: string): Promise<PassageUser>;
/**
* Activate a user using their user ID.
*
* @param {string} userId The Passage user ID
* @return {Promise<PassageUser>} Passage User object
*/
activate(userId: string): Promise<PassageUser>;
/**
* Deactivate a user using their user ID.
*
* @param {string} userId The Passage user ID
* @return {Promise<PassageUser>} Passage User object
*/
deactivate(userId: string): Promise<PassageUser>;
/**
* Update a user.
*
* @param {string} userId The Passage user ID
* @param {UpdateUserArgs} options The user attributes to be updated
* @return {Promise<PassageUser>} Passage User object
*/
update(userId: string, options: UpdateUserArgs): Promise<PassageUser>;
/**
* Create a user.
*
* @param {CreateUserArgs} args Arguments for creating a user
* @return {Promise<PassageUser>} Passage User object
*/
create(args: CreateUserArgs): Promise<PassageUser>;
/**
* Delete a user using their user ID.
*
* @param {string} userId The Passage user ID used to delete the corresponding user.
* @return {Promise<void>}
*/
delete(userId: string): Promise<void>;
/**
* Get a user's devices using their user ID.
*
* @param {string} userId The Passage user ID
* @return {Promise<WebAuthnDevices[]>} List of devices
*/
listDevices(userId: string): Promise<WebAuthnDevices[]>;
/**
* Revoke a user's device using their user ID and the device ID.
*
* @param {string} userId The Passage user ID
* @param {string} deviceId The Passage user's device ID
* @return {Promise<void>}
*/
revokeDevice(userId: string, deviceId: string): Promise<void>;
/**
* Revokes all of a user's Refresh Tokens using their User ID.
*
* @param {string} userId The Passage user ID
* @return {Promise<void>}
*/
revokeRefreshTokens(userId: string): Promise<void>;
}
type PassageConfig = {
/** The App ID for your Passage Application. */
appId: string;
/** The API Key for your Passage Application. */
apiKey: string;
/** Optional fetch API to use. Will use node-fetch by default if not provided. */
fetchApi?: FetchAPI;
};
/**
* Passage Class
*/
declare class Passage {
readonly user: User;
readonly auth: Auth;
/**
* Initialize a new Passage instance.
* @param {PassageConfig} config The default config for Passage initialization
*/
constructor(config: PassageConfig);
/**
* Configure the API with the provided configuration parameters.
* @param {ConfigurationParameters} config The configuration parameters
* @return {Configuration} The configured API
*/
private configureApi;
}
/**
* Passage Class
*/
declare class PassageError extends Error {
name: 'PassageError';
readonly statusCode: number | undefined;
readonly errorCode: string | undefined;
readonly message: string;
/**
* Private constructor to be used by the async fromResponseError method.
* @param {string} message error message
* @param {string} errorCode error code
* @param {ResponseError} err ResponseError
*/
private constructor();
/**
* Maps a ResponseError to a PassageError.
* @param {error} err ResponseError
* @param {string} message Optional message to prefix the error message
* @return {PassageError} PassageError
*/
static fromResponseError(err: ResponseError): Promise<PassageError>;
}
export { Auth, type CreateMagicLinkArgs, type CreateUserArgs, type MagicLink, MagicLinkChannel, MagicLinkLanguage, type MagicLinkOptions, MagicLinkType, type MagicLinkWithEmailArgs, type MagicLinkWithPhoneArgs, type MagicLinkWithUserArgs, Passage, PassageError, type PassageUser, type UpdateUserArgs, User, type UserRecentEvent, type UserSocialConnections, UserStatus, type WebAuthnDevices, type WebAuthnIcons, WebAuthnType, Passage as default };