@nhost/hasura-auth-js
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -1,2 +0,2 @@ | ||
import { SignUpEmailPasswordParams, SignInEmailPasswordParams, SignInPasswordlessEmailParmas, SignInPasswordlessSmsParmas, SignInPasswordlessSmsOtpParams, ApiSignInResponse, ApiSignOutResponse, ApiRefreshTokenResponse } from './utils/types'; | ||
import { ResetPasswordParams, ChangePasswordParams, SendVerificationEmailParams, SignUpEmailPasswordParams, SignInEmailPasswordParams, SignInPasswordlessEmailParams, SignInPasswordlessSmsParams, SignInPasswordlessSmsOtpParams, ChangeEmailParams, DeanonymizeParams, ApiSignInResponse, ApiSignOutResponse, ApiRefreshTokenResponse, ApiResetPasswordResponse, ApiChangePasswordResponse, ApiSendVerificationEmailResponse, ApiChangeEmailResponse, ApiDeanonymizeResponse } from './utils/types'; | ||
export declare class HasuraAuthApi { | ||
@@ -13,4 +13,4 @@ private httpClient; | ||
signInEmailPassword(params: SignInEmailPasswordParams): Promise<ApiSignInResponse>; | ||
signInPasswordlessEmail(params: SignInPasswordlessEmailParmas): Promise<ApiSignInResponse>; | ||
signInPasswordlessSms(params: SignInPasswordlessSmsParmas): Promise<ApiSignInResponse>; | ||
signInPasswordlessEmail(params: SignInPasswordlessEmailParams): Promise<ApiSignInResponse>; | ||
signInPasswordlessSms(params: SignInPasswordlessSmsParams): Promise<ApiSignInResponse>; | ||
signInPasswordlessSmsOtp(params: SignInPasswordlessSmsOtpParams): Promise<ApiSignInResponse>; | ||
@@ -24,2 +24,7 @@ signOut(params: { | ||
}): Promise<ApiRefreshTokenResponse>; | ||
resetPassword(params: ResetPasswordParams): Promise<ApiResetPasswordResponse>; | ||
changePassword(params: ChangePasswordParams): Promise<ApiChangePasswordResponse>; | ||
sendVerificationEmail(params: SendVerificationEmailParams): Promise<ApiSendVerificationEmailResponse>; | ||
changeEmail(params: ChangeEmailParams): Promise<ApiChangeEmailResponse>; | ||
deanonymize(params: DeanonymizeParams): Promise<ApiDeanonymizeResponse>; | ||
verifyEmail(params: { | ||
@@ -26,0 +31,0 @@ email: string; |
@@ -189,10 +189,101 @@ "use strict"; | ||
}; | ||
// resetPassword | ||
// changePassword | ||
// sendVerificationEmail | ||
// changeEmail | ||
HasuraAuthApi.prototype.resetPassword = function (params) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var error_8; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, this.httpClient.post('/user/password/reset', params)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/, { error: null }]; | ||
case 2: | ||
error_8 = _a.sent(); | ||
return [2 /*return*/, { error: error_8 }]; | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
HasuraAuthApi.prototype.changePassword = function (params) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var error_9; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, this.httpClient.post('/user/password', params)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/, { error: null }]; | ||
case 2: | ||
error_9 = _a.sent(); | ||
return [2 /*return*/, { error: error_9 }]; | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
HasuraAuthApi.prototype.sendVerificationEmail = function (params) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var error_10; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, this.httpClient.post('/user/email/send-verification-email', params)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/, { error: null }]; | ||
case 2: | ||
error_10 = _a.sent(); | ||
return [2 /*return*/, { error: error_10 }]; | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
HasuraAuthApi.prototype.changeEmail = function (params) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var error_11; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, this.httpClient.post('/user/email/change', params)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/, { error: null }]; | ||
case 2: | ||
error_11 = _a.sent(); | ||
return [2 /*return*/, { error: error_11 }]; | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
HasuraAuthApi.prototype.deanonymize = function (params) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var error_12; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, this.httpClient.post('/user/deanonymize', params)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/, { error: null }]; | ||
case 2: | ||
error_12 = _a.sent(); | ||
return [2 /*return*/, { error: error_12 }]; | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
// deanonymize | ||
HasuraAuthApi.prototype.verifyEmail = function (params) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var res, error_8; | ||
var res, error_13; | ||
return __generator(this, function (_a) { | ||
@@ -207,4 +298,4 @@ switch (_a.label) { | ||
case 2: | ||
error_8 = _a.sent(); | ||
return [2 /*return*/, { data: null, error: error_8 }]; | ||
error_13 = _a.sent(); | ||
return [2 /*return*/, { data: null, error: error_13 }]; | ||
case 3: return [2 /*return*/]; | ||
@@ -211,0 +302,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { AuthChangedFunction, OnTokenChangedFunction, ClientStorage, ClientStorageType, Session, SignUpParams, SignInParams, SignUpResponse } from './utils/types'; | ||
import { AuthChangedFunction, OnTokenChangedFunction, ClientStorage, ClientStorageType, Session, SignUpParams, SignInParams, ResetPasswordParams, SendVerificationEmailParams, ChangePasswordParams, ChangeEmailParams, DeanonymizeParams, SignUpResponse, ApiResetPasswordResponse, ApiSendVerificationEmailResponse, ApiChangeEmailResponse, ApiChangePasswordResponse, ApiDeanonymizeResponse } from './utils/types'; | ||
export declare class HasuraAuthClient { | ||
@@ -85,2 +85,48 @@ private api; | ||
/** | ||
* Use `resetPassword` to reset a user's password. | ||
* | ||
* @example | ||
* auth.resetPassword({email}) | ||
* | ||
* @docs https://docs.nhost.io/TODO | ||
*/ | ||
resetPassword(params: ResetPasswordParams): Promise<ApiResetPasswordResponse>; | ||
/** | ||
* Use `changePassword` to change a user's password. | ||
* | ||
* @example | ||
* auth.changePassword({oldPassword, newPassword}) | ||
* | ||
* @docs https://docs.nhost.io/TODO | ||
*/ | ||
changePassword(params: ChangePasswordParams): Promise<ApiChangePasswordResponse>; | ||
/** | ||
* Use `sendVerificationEmail` to send a verification email | ||
* to the specified email. | ||
* | ||
* @example | ||
* auth.sendVerificationEmail({email}) | ||
* | ||
* @docs https://docs.nhost.io/TODO | ||
*/ | ||
sendVerificationEmail(params: SendVerificationEmailParams): Promise<ApiSendVerificationEmailResponse>; | ||
/** | ||
* Use `changeEmail` to change a user's email | ||
* | ||
* @example | ||
* auth.changeEmail({newEmail}) | ||
* | ||
* @docs https://docs.nhost.io/TODO | ||
*/ | ||
changeEmail(params: ChangeEmailParams): Promise<ApiChangeEmailResponse>; | ||
/** | ||
* Use `deanonymize` to deanonymize a user | ||
* | ||
* @example | ||
* auth.deanonymize({signInMethod: 'email-password', email}) | ||
* | ||
* @docs https://docs.nhost.io/TODO | ||
*/ | ||
deanonymize(params: DeanonymizeParams): Promise<ApiDeanonymizeResponse>; | ||
/** | ||
* Use `onTokenChanged` to add a custom function that will trigger whenever | ||
@@ -87,0 +133,0 @@ * the access and refresh token is changed. |
@@ -80,3 +80,3 @@ "use strict"; | ||
// ex if the user came from a magic link | ||
if (autoLogin && (0, helpers_1.isBrowser)()) { | ||
if (autoLogin && (0, helpers_1.isBrowser)() && window.location) { | ||
// try { | ||
@@ -295,2 +295,108 @@ var urlParams = query_string_1.default.parse(window.location.toString().split('#')[1]); | ||
/** | ||
* Use `resetPassword` to reset a user's password. | ||
* | ||
* @example | ||
* auth.resetPassword({email}) | ||
* | ||
* @docs https://docs.nhost.io/TODO | ||
*/ | ||
HasuraAuthClient.prototype.resetPassword = function (params) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var error; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.api.resetPassword(params)]; | ||
case 1: | ||
error = (_a.sent()).error; | ||
return [2 /*return*/, { error: error }]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Use `changePassword` to change a user's password. | ||
* | ||
* @example | ||
* auth.changePassword({oldPassword, newPassword}) | ||
* | ||
* @docs https://docs.nhost.io/TODO | ||
*/ | ||
HasuraAuthClient.prototype.changePassword = function (params) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var error; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.api.changePassword(params)]; | ||
case 1: | ||
error = (_a.sent()).error; | ||
return [2 /*return*/, { error: error }]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Use `sendVerificationEmail` to send a verification email | ||
* to the specified email. | ||
* | ||
* @example | ||
* auth.sendVerificationEmail({email}) | ||
* | ||
* @docs https://docs.nhost.io/TODO | ||
*/ | ||
HasuraAuthClient.prototype.sendVerificationEmail = function (params) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var error; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.api.sendVerificationEmail(params)]; | ||
case 1: | ||
error = (_a.sent()).error; | ||
return [2 /*return*/, { error: error }]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Use `changeEmail` to change a user's email | ||
* | ||
* @example | ||
* auth.changeEmail({newEmail}) | ||
* | ||
* @docs https://docs.nhost.io/TODO | ||
*/ | ||
HasuraAuthClient.prototype.changeEmail = function (params) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var error; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.api.changeEmail(params)]; | ||
case 1: | ||
error = (_a.sent()).error; | ||
return [2 /*return*/, { error: error }]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Use `deanonymize` to deanonymize a user | ||
* | ||
* @example | ||
* auth.deanonymize({signInMethod: 'email-password', email}) | ||
* | ||
* @docs https://docs.nhost.io/TODO | ||
*/ | ||
HasuraAuthClient.prototype.deanonymize = function (params) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var error; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.api.deanonymize(params)]; | ||
case 1: | ||
error = (_a.sent()).error; | ||
return [2 /*return*/, { error: error }]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Use `onTokenChanged` to add a custom function that will trigger whenever | ||
@@ -297,0 +403,0 @@ * the access and refresh token is changed. |
@@ -42,3 +42,3 @@ export declare type Session = { | ||
}; | ||
export declare type SignInPasswordlessEmailParmas = { | ||
export declare type SignInPasswordlessEmailParams = { | ||
email: string; | ||
@@ -53,3 +53,3 @@ options?: { | ||
}; | ||
export declare type SignInPasswordlessSmsParmas = { | ||
export declare type SignInPasswordlessSmsParams = { | ||
phoneNumber: string; | ||
@@ -78,3 +78,33 @@ options?: { | ||
}; | ||
export declare type SignInParams = SignInEmailPasswordParams | SignInPasswordlessEmailParmas | SignInPasswordlessSmsParmas | SignInPasswordlessSmsOtpParams | SignInWithProviderOptions; | ||
export declare type SignInParams = SignInEmailPasswordParams | SignInPasswordlessEmailParams | SignInPasswordlessSmsParams | SignInPasswordlessSmsOtpParams | SignInWithProviderOptions; | ||
export declare type ResetPasswordParams = { | ||
email: string; | ||
options?: { | ||
redirectTo?: string; | ||
}; | ||
}; | ||
export declare type ChangePasswordParams = { | ||
oldPassword: string; | ||
newPassword: string; | ||
}; | ||
export declare type SendVerificationEmailParams = { | ||
email: string; | ||
options?: { | ||
redirectTo?: string; | ||
}; | ||
}; | ||
export declare type ChangeEmailParams = { | ||
newEmail: string; | ||
options?: { | ||
redirectTo?: string; | ||
}; | ||
}; | ||
export declare type DeanonymizeParams = { | ||
signInMethod: 'email-password' | 'passwordless'; | ||
email: string; | ||
password?: string; | ||
connection?: 'email' | 'sms'; | ||
defaultRole?: string; | ||
allowedRoles?: string[]; | ||
}; | ||
export declare type SignInReponse = { | ||
@@ -161,1 +191,16 @@ session: Session | null; | ||
}; | ||
export declare type ApiResetPasswordResponse = { | ||
error: null | Error; | ||
}; | ||
export declare type ApiChangePasswordResponse = { | ||
error: null | Error; | ||
}; | ||
export declare type ApiSendVerificationEmailResponse = { | ||
error: null | Error; | ||
}; | ||
export declare type ApiChangeEmailResponse = { | ||
error: null | Error; | ||
}; | ||
export declare type ApiDeanonymizeResponse = { | ||
error: null | Error; | ||
}; |
@@ -1,2 +0,2 @@ | ||
import { SignUpEmailPasswordParams, SignInEmailPasswordParams, SignInPasswordlessEmailParmas, SignInPasswordlessSmsParmas, SignInPasswordlessSmsOtpParams, ApiSignInResponse, ApiSignOutResponse, ApiRefreshTokenResponse } from './utils/types'; | ||
import { ResetPasswordParams, ChangePasswordParams, SendVerificationEmailParams, SignUpEmailPasswordParams, SignInEmailPasswordParams, SignInPasswordlessEmailParams, SignInPasswordlessSmsParams, SignInPasswordlessSmsOtpParams, ChangeEmailParams, DeanonymizeParams, ApiSignInResponse, ApiSignOutResponse, ApiRefreshTokenResponse, ApiResetPasswordResponse, ApiChangePasswordResponse, ApiSendVerificationEmailResponse, ApiChangeEmailResponse, ApiDeanonymizeResponse } from './utils/types'; | ||
export declare class HasuraAuthApi { | ||
@@ -13,4 +13,4 @@ private httpClient; | ||
signInEmailPassword(params: SignInEmailPasswordParams): Promise<ApiSignInResponse>; | ||
signInPasswordlessEmail(params: SignInPasswordlessEmailParmas): Promise<ApiSignInResponse>; | ||
signInPasswordlessSms(params: SignInPasswordlessSmsParmas): Promise<ApiSignInResponse>; | ||
signInPasswordlessEmail(params: SignInPasswordlessEmailParams): Promise<ApiSignInResponse>; | ||
signInPasswordlessSms(params: SignInPasswordlessSmsParams): Promise<ApiSignInResponse>; | ||
signInPasswordlessSmsOtp(params: SignInPasswordlessSmsOtpParams): Promise<ApiSignInResponse>; | ||
@@ -24,2 +24,7 @@ signOut(params: { | ||
}): Promise<ApiRefreshTokenResponse>; | ||
resetPassword(params: ResetPasswordParams): Promise<ApiResetPasswordResponse>; | ||
changePassword(params: ChangePasswordParams): Promise<ApiChangePasswordResponse>; | ||
sendVerificationEmail(params: SendVerificationEmailParams): Promise<ApiSendVerificationEmailResponse>; | ||
changeEmail(params: ChangeEmailParams): Promise<ApiChangeEmailResponse>; | ||
deanonymize(params: DeanonymizeParams): Promise<ApiDeanonymizeResponse>; | ||
verifyEmail(params: { | ||
@@ -26,0 +31,0 @@ email: string; |
@@ -183,10 +183,101 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}; | ||
// resetPassword | ||
// changePassword | ||
// sendVerificationEmail | ||
// changeEmail | ||
HasuraAuthApi.prototype.resetPassword = function (params) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var error_8; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, this.httpClient.post('/user/password/reset', params)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/, { error: null }]; | ||
case 2: | ||
error_8 = _a.sent(); | ||
return [2 /*return*/, { error: error_8 }]; | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
HasuraAuthApi.prototype.changePassword = function (params) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var error_9; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, this.httpClient.post('/user/password', params)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/, { error: null }]; | ||
case 2: | ||
error_9 = _a.sent(); | ||
return [2 /*return*/, { error: error_9 }]; | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
HasuraAuthApi.prototype.sendVerificationEmail = function (params) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var error_10; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, this.httpClient.post('/user/email/send-verification-email', params)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/, { error: null }]; | ||
case 2: | ||
error_10 = _a.sent(); | ||
return [2 /*return*/, { error: error_10 }]; | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
HasuraAuthApi.prototype.changeEmail = function (params) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var error_11; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, this.httpClient.post('/user/email/change', params)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/, { error: null }]; | ||
case 2: | ||
error_11 = _a.sent(); | ||
return [2 /*return*/, { error: error_11 }]; | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
HasuraAuthApi.prototype.deanonymize = function (params) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var error_12; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, this.httpClient.post('/user/deanonymize', params)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/, { error: null }]; | ||
case 2: | ||
error_12 = _a.sent(); | ||
return [2 /*return*/, { error: error_12 }]; | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
// deanonymize | ||
HasuraAuthApi.prototype.verifyEmail = function (params) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var res, error_8; | ||
var res, error_13; | ||
return __generator(this, function (_a) { | ||
@@ -201,4 +292,4 @@ switch (_a.label) { | ||
case 2: | ||
error_8 = _a.sent(); | ||
return [2 /*return*/, { data: null, error: error_8 }]; | ||
error_13 = _a.sent(); | ||
return [2 /*return*/, { data: null, error: error_13 }]; | ||
case 3: return [2 /*return*/]; | ||
@@ -205,0 +296,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { AuthChangedFunction, OnTokenChangedFunction, ClientStorage, ClientStorageType, Session, SignUpParams, SignInParams, SignUpResponse } from './utils/types'; | ||
import { AuthChangedFunction, OnTokenChangedFunction, ClientStorage, ClientStorageType, Session, SignUpParams, SignInParams, ResetPasswordParams, SendVerificationEmailParams, ChangePasswordParams, ChangeEmailParams, DeanonymizeParams, SignUpResponse, ApiResetPasswordResponse, ApiSendVerificationEmailResponse, ApiChangeEmailResponse, ApiChangePasswordResponse, ApiDeanonymizeResponse } from './utils/types'; | ||
export declare class HasuraAuthClient { | ||
@@ -85,2 +85,48 @@ private api; | ||
/** | ||
* Use `resetPassword` to reset a user's password. | ||
* | ||
* @example | ||
* auth.resetPassword({email}) | ||
* | ||
* @docs https://docs.nhost.io/TODO | ||
*/ | ||
resetPassword(params: ResetPasswordParams): Promise<ApiResetPasswordResponse>; | ||
/** | ||
* Use `changePassword` to change a user's password. | ||
* | ||
* @example | ||
* auth.changePassword({oldPassword, newPassword}) | ||
* | ||
* @docs https://docs.nhost.io/TODO | ||
*/ | ||
changePassword(params: ChangePasswordParams): Promise<ApiChangePasswordResponse>; | ||
/** | ||
* Use `sendVerificationEmail` to send a verification email | ||
* to the specified email. | ||
* | ||
* @example | ||
* auth.sendVerificationEmail({email}) | ||
* | ||
* @docs https://docs.nhost.io/TODO | ||
*/ | ||
sendVerificationEmail(params: SendVerificationEmailParams): Promise<ApiSendVerificationEmailResponse>; | ||
/** | ||
* Use `changeEmail` to change a user's email | ||
* | ||
* @example | ||
* auth.changeEmail({newEmail}) | ||
* | ||
* @docs https://docs.nhost.io/TODO | ||
*/ | ||
changeEmail(params: ChangeEmailParams): Promise<ApiChangeEmailResponse>; | ||
/** | ||
* Use `deanonymize` to deanonymize a user | ||
* | ||
* @example | ||
* auth.deanonymize({signInMethod: 'email-password', email}) | ||
* | ||
* @docs https://docs.nhost.io/TODO | ||
*/ | ||
deanonymize(params: DeanonymizeParams): Promise<ApiDeanonymizeResponse>; | ||
/** | ||
* Use `onTokenChanged` to add a custom function that will trigger whenever | ||
@@ -87,0 +133,0 @@ * the access and refresh token is changed. |
@@ -74,3 +74,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
// ex if the user came from a magic link | ||
if (autoLogin && isBrowser()) { | ||
if (autoLogin && isBrowser() && window.location) { | ||
// try { | ||
@@ -289,2 +289,108 @@ var urlParams = queryString.parse(window.location.toString().split('#')[1]); | ||
/** | ||
* Use `resetPassword` to reset a user's password. | ||
* | ||
* @example | ||
* auth.resetPassword({email}) | ||
* | ||
* @docs https://docs.nhost.io/TODO | ||
*/ | ||
HasuraAuthClient.prototype.resetPassword = function (params) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var error; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.api.resetPassword(params)]; | ||
case 1: | ||
error = (_a.sent()).error; | ||
return [2 /*return*/, { error: error }]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Use `changePassword` to change a user's password. | ||
* | ||
* @example | ||
* auth.changePassword({oldPassword, newPassword}) | ||
* | ||
* @docs https://docs.nhost.io/TODO | ||
*/ | ||
HasuraAuthClient.prototype.changePassword = function (params) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var error; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.api.changePassword(params)]; | ||
case 1: | ||
error = (_a.sent()).error; | ||
return [2 /*return*/, { error: error }]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Use `sendVerificationEmail` to send a verification email | ||
* to the specified email. | ||
* | ||
* @example | ||
* auth.sendVerificationEmail({email}) | ||
* | ||
* @docs https://docs.nhost.io/TODO | ||
*/ | ||
HasuraAuthClient.prototype.sendVerificationEmail = function (params) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var error; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.api.sendVerificationEmail(params)]; | ||
case 1: | ||
error = (_a.sent()).error; | ||
return [2 /*return*/, { error: error }]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Use `changeEmail` to change a user's email | ||
* | ||
* @example | ||
* auth.changeEmail({newEmail}) | ||
* | ||
* @docs https://docs.nhost.io/TODO | ||
*/ | ||
HasuraAuthClient.prototype.changeEmail = function (params) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var error; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.api.changeEmail(params)]; | ||
case 1: | ||
error = (_a.sent()).error; | ||
return [2 /*return*/, { error: error }]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Use `deanonymize` to deanonymize a user | ||
* | ||
* @example | ||
* auth.deanonymize({signInMethod: 'email-password', email}) | ||
* | ||
* @docs https://docs.nhost.io/TODO | ||
*/ | ||
HasuraAuthClient.prototype.deanonymize = function (params) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var error; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.api.deanonymize(params)]; | ||
case 1: | ||
error = (_a.sent()).error; | ||
return [2 /*return*/, { error: error }]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Use `onTokenChanged` to add a custom function that will trigger whenever | ||
@@ -291,0 +397,0 @@ * the access and refresh token is changed. |
@@ -42,3 +42,3 @@ export declare type Session = { | ||
}; | ||
export declare type SignInPasswordlessEmailParmas = { | ||
export declare type SignInPasswordlessEmailParams = { | ||
email: string; | ||
@@ -53,3 +53,3 @@ options?: { | ||
}; | ||
export declare type SignInPasswordlessSmsParmas = { | ||
export declare type SignInPasswordlessSmsParams = { | ||
phoneNumber: string; | ||
@@ -78,3 +78,33 @@ options?: { | ||
}; | ||
export declare type SignInParams = SignInEmailPasswordParams | SignInPasswordlessEmailParmas | SignInPasswordlessSmsParmas | SignInPasswordlessSmsOtpParams | SignInWithProviderOptions; | ||
export declare type SignInParams = SignInEmailPasswordParams | SignInPasswordlessEmailParams | SignInPasswordlessSmsParams | SignInPasswordlessSmsOtpParams | SignInWithProviderOptions; | ||
export declare type ResetPasswordParams = { | ||
email: string; | ||
options?: { | ||
redirectTo?: string; | ||
}; | ||
}; | ||
export declare type ChangePasswordParams = { | ||
oldPassword: string; | ||
newPassword: string; | ||
}; | ||
export declare type SendVerificationEmailParams = { | ||
email: string; | ||
options?: { | ||
redirectTo?: string; | ||
}; | ||
}; | ||
export declare type ChangeEmailParams = { | ||
newEmail: string; | ||
options?: { | ||
redirectTo?: string; | ||
}; | ||
}; | ||
export declare type DeanonymizeParams = { | ||
signInMethod: 'email-password' | 'passwordless'; | ||
email: string; | ||
password?: string; | ||
connection?: 'email' | 'sms'; | ||
defaultRole?: string; | ||
allowedRoles?: string[]; | ||
}; | ||
export declare type SignInReponse = { | ||
@@ -161,1 +191,16 @@ session: Session | null; | ||
}; | ||
export declare type ApiResetPasswordResponse = { | ||
error: null | Error; | ||
}; | ||
export declare type ApiChangePasswordResponse = { | ||
error: null | Error; | ||
}; | ||
export declare type ApiSendVerificationEmailResponse = { | ||
error: null | Error; | ||
}; | ||
export declare type ApiChangeEmailResponse = { | ||
error: null | Error; | ||
}; | ||
export declare type ApiDeanonymizeResponse = { | ||
error: null | Error; | ||
}; |
{ | ||
"name": "@nhost/hasura-auth-js", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Hasura Auth JS", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
146921
3564