@nhost/hasura-auth-js
Advanced tools
Comparing version 0.1.2 to 0.1.5
@@ -63,2 +63,12 @@ "use strict"; | ||
}); | ||
// convert axios error to custom ApiError | ||
this.httpClient.interceptors.response.use(function (response) { return response; }, function (error) { | ||
var _a, _b; | ||
return Promise.reject({ | ||
message: ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data.message) || | ||
error.message || | ||
JSON.stringify(error), | ||
status: ((_b = error.response) === null || _b === void 0 ? void 0 : _b.status) || 500, | ||
}); | ||
}); | ||
} | ||
@@ -65,0 +75,0 @@ /** |
import { AuthChangedFunction, OnTokenChangedFunction, ClientStorage, ClientStorageType, Session, SignUpParams, SignInParams, ResetPasswordParams, SendVerificationEmailParams, ChangePasswordParams, ChangeEmailParams, DeanonymizeParams, SignUpResponse, ApiResetPasswordResponse, ApiSendVerificationEmailResponse, ApiChangeEmailResponse, ApiChangePasswordResponse, ApiDeanonymizeResponse } from './utils/types'; | ||
import { ApiError } from './utils/types'; | ||
export declare class HasuraAuthClient { | ||
@@ -57,3 +58,3 @@ private api; | ||
}; | ||
error: Error | null; | ||
error: null | ApiError; | ||
providerUrl?: string; | ||
@@ -98,3 +99,3 @@ provider?: string; | ||
* @example | ||
* auth.changePassword({oldPassword, newPassword}) | ||
* auth.changePassword({ newPassword }) | ||
* | ||
@@ -101,0 +102,0 @@ * @docs https://docs.nhost.io/TODO |
@@ -139,3 +139,6 @@ "use strict"; | ||
if (!data) { | ||
return [2 /*return*/, { session: null, error: new Error('Incorrect data') }]; | ||
return [2 /*return*/, { | ||
session: null, | ||
error: { message: 'An error occurred on sign up.', status: 500 }, | ||
}]; | ||
} | ||
@@ -149,3 +152,6 @@ session = data.session; | ||
case 3: return [2 /*return*/, { session: session, error: null }]; | ||
case 4: return [2 /*return*/, { session: null, error: new Error('incorrect parameters') }]; | ||
case 4: return [2 /*return*/, { | ||
session: null, | ||
error: { message: 'Incorrect parameters', status: 500 }, | ||
}]; | ||
} | ||
@@ -192,3 +198,7 @@ }); | ||
if (!data) { | ||
return [2 /*return*/, { session: null, mfa: null, error: new Error('Incorrect data') }]; | ||
return [2 /*return*/, { | ||
session: null, | ||
mfa: null, | ||
error: { message: 'Incorrect Data', status: 500 }, | ||
}]; | ||
} | ||
@@ -232,3 +242,3 @@ session = data.session, mfa = data.mfa; | ||
mfa: null, | ||
error: new Error('Incorrect data'), | ||
error: { message: 'Incorrect data', status: 500 }, | ||
}]; | ||
@@ -244,3 +254,3 @@ } | ||
mfa: null, | ||
error: new Error('incorrect parameters'), | ||
error: { message: 'Incorrect parameters', status: 500 }, | ||
}]; | ||
@@ -325,3 +335,3 @@ } | ||
* @example | ||
* auth.changePassword({oldPassword, newPassword}) | ||
* auth.changePassword({ newPassword }) | ||
* | ||
@@ -328,0 +338,0 @@ * @docs https://docs.nhost.io/TODO |
@@ -20,2 +20,6 @@ export declare type Session = { | ||
}; | ||
export declare type ApiError = { | ||
message: string; | ||
status: number; | ||
}; | ||
export declare type SignUpEmailPasswordParams = { | ||
@@ -26,5 +30,6 @@ email: string; | ||
locale?: string; | ||
allowedRoles?: string[]; | ||
defaultRole?: string; | ||
roles?: string[]; | ||
displayName?: string; | ||
redirectTo?: string; | ||
}; | ||
@@ -38,3 +43,3 @@ }; | ||
session: null; | ||
error: Error; | ||
error: ApiError; | ||
}; | ||
@@ -87,3 +92,2 @@ export declare type SignInEmailPasswordParams = { | ||
export declare type ChangePasswordParams = { | ||
oldPassword: string; | ||
newPassword: string; | ||
@@ -113,3 +117,3 @@ }; | ||
session: Session | null; | ||
error: Error | null; | ||
error: ApiError | null; | ||
mfa?: { | ||
@@ -171,3 +175,3 @@ enabled: boolean; | ||
session: null; | ||
error: Error; | ||
error: ApiError; | ||
}; | ||
@@ -182,3 +186,3 @@ export declare type ApiSignInResponse = { | ||
data: null; | ||
error: Error; | ||
error: ApiError; | ||
}; | ||
@@ -190,21 +194,21 @@ export declare type ApiRefreshTokenResponse = { | ||
session: null; | ||
error: Error; | ||
error: ApiError; | ||
}; | ||
export declare type ApiSignOutResponse = { | ||
error: null | Error; | ||
error: null | ApiError; | ||
}; | ||
export declare type ApiResetPasswordResponse = { | ||
error: null | Error; | ||
error: null | ApiError; | ||
}; | ||
export declare type ApiChangePasswordResponse = { | ||
error: null | Error; | ||
error: null | ApiError; | ||
}; | ||
export declare type ApiSendVerificationEmailResponse = { | ||
error: null | Error; | ||
error: null | ApiError; | ||
}; | ||
export declare type ApiChangeEmailResponse = { | ||
error: null | Error; | ||
error: null | ApiError; | ||
}; | ||
export declare type ApiDeanonymizeResponse = { | ||
error: null | Error; | ||
error: null | ApiError; | ||
}; |
@@ -57,2 +57,12 @@ var __assign = (this && this.__assign) || function () { | ||
}); | ||
// convert axios error to custom ApiError | ||
this.httpClient.interceptors.response.use(function (response) { return response; }, function (error) { | ||
var _a, _b; | ||
return Promise.reject({ | ||
message: ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data.message) || | ||
error.message || | ||
JSON.stringify(error), | ||
status: ((_b = error.response) === null || _b === void 0 ? void 0 : _b.status) || 500, | ||
}); | ||
}); | ||
} | ||
@@ -59,0 +69,0 @@ /** |
import { AuthChangedFunction, OnTokenChangedFunction, ClientStorage, ClientStorageType, Session, SignUpParams, SignInParams, ResetPasswordParams, SendVerificationEmailParams, ChangePasswordParams, ChangeEmailParams, DeanonymizeParams, SignUpResponse, ApiResetPasswordResponse, ApiSendVerificationEmailResponse, ApiChangeEmailResponse, ApiChangePasswordResponse, ApiDeanonymizeResponse } from './utils/types'; | ||
import { ApiError } from './utils/types'; | ||
export declare class HasuraAuthClient { | ||
@@ -57,3 +58,3 @@ private api; | ||
}; | ||
error: Error | null; | ||
error: null | ApiError; | ||
providerUrl?: string; | ||
@@ -98,3 +99,3 @@ provider?: string; | ||
* @example | ||
* auth.changePassword({oldPassword, newPassword}) | ||
* auth.changePassword({ newPassword }) | ||
* | ||
@@ -101,0 +102,0 @@ * @docs https://docs.nhost.io/TODO |
@@ -133,3 +133,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
if (!data) { | ||
return [2 /*return*/, { session: null, error: new Error('Incorrect data') }]; | ||
return [2 /*return*/, { | ||
session: null, | ||
error: { message: 'An error occurred on sign up.', status: 500 }, | ||
}]; | ||
} | ||
@@ -143,3 +146,6 @@ session = data.session; | ||
case 3: return [2 /*return*/, { session: session, error: null }]; | ||
case 4: return [2 /*return*/, { session: null, error: new Error('incorrect parameters') }]; | ||
case 4: return [2 /*return*/, { | ||
session: null, | ||
error: { message: 'Incorrect parameters', status: 500 }, | ||
}]; | ||
} | ||
@@ -186,3 +192,7 @@ }); | ||
if (!data) { | ||
return [2 /*return*/, { session: null, mfa: null, error: new Error('Incorrect data') }]; | ||
return [2 /*return*/, { | ||
session: null, | ||
mfa: null, | ||
error: { message: 'Incorrect Data', status: 500 }, | ||
}]; | ||
} | ||
@@ -226,3 +236,3 @@ session = data.session, mfa = data.mfa; | ||
mfa: null, | ||
error: new Error('Incorrect data'), | ||
error: { message: 'Incorrect data', status: 500 }, | ||
}]; | ||
@@ -238,3 +248,3 @@ } | ||
mfa: null, | ||
error: new Error('incorrect parameters'), | ||
error: { message: 'Incorrect parameters', status: 500 }, | ||
}]; | ||
@@ -319,3 +329,3 @@ } | ||
* @example | ||
* auth.changePassword({oldPassword, newPassword}) | ||
* auth.changePassword({ newPassword }) | ||
* | ||
@@ -322,0 +332,0 @@ * @docs https://docs.nhost.io/TODO |
@@ -20,2 +20,6 @@ export declare type Session = { | ||
}; | ||
export declare type ApiError = { | ||
message: string; | ||
status: number; | ||
}; | ||
export declare type SignUpEmailPasswordParams = { | ||
@@ -26,5 +30,6 @@ email: string; | ||
locale?: string; | ||
allowedRoles?: string[]; | ||
defaultRole?: string; | ||
roles?: string[]; | ||
displayName?: string; | ||
redirectTo?: string; | ||
}; | ||
@@ -38,3 +43,3 @@ }; | ||
session: null; | ||
error: Error; | ||
error: ApiError; | ||
}; | ||
@@ -87,3 +92,2 @@ export declare type SignInEmailPasswordParams = { | ||
export declare type ChangePasswordParams = { | ||
oldPassword: string; | ||
newPassword: string; | ||
@@ -113,3 +117,3 @@ }; | ||
session: Session | null; | ||
error: Error | null; | ||
error: ApiError | null; | ||
mfa?: { | ||
@@ -171,3 +175,3 @@ enabled: boolean; | ||
session: null; | ||
error: Error; | ||
error: ApiError; | ||
}; | ||
@@ -182,3 +186,3 @@ export declare type ApiSignInResponse = { | ||
data: null; | ||
error: Error; | ||
error: ApiError; | ||
}; | ||
@@ -190,21 +194,21 @@ export declare type ApiRefreshTokenResponse = { | ||
session: null; | ||
error: Error; | ||
error: ApiError; | ||
}; | ||
export declare type ApiSignOutResponse = { | ||
error: null | Error; | ||
error: null | ApiError; | ||
}; | ||
export declare type ApiResetPasswordResponse = { | ||
error: null | Error; | ||
error: null | ApiError; | ||
}; | ||
export declare type ApiChangePasswordResponse = { | ||
error: null | Error; | ||
error: null | ApiError; | ||
}; | ||
export declare type ApiSendVerificationEmailResponse = { | ||
error: null | Error; | ||
error: null | ApiError; | ||
}; | ||
export declare type ApiChangeEmailResponse = { | ||
error: null | Error; | ||
error: null | ApiError; | ||
}; | ||
export declare type ApiDeanonymizeResponse = { | ||
error: null | Error; | ||
error: null | ApiError; | ||
}; |
{ | ||
"name": "@nhost/hasura-auth-js", | ||
"version": "0.1.2", | ||
"version": "0.1.5", | ||
"description": "Hasura Auth JS", | ||
@@ -29,3 +29,4 @@ "keywords": [ | ||
"test:backend:start": "cd test/backend; nhost dev -d --no-browser", | ||
"test": "jest --runInBand --forceExit" | ||
"test": "jest --runInBand --forceExit", | ||
"semantic-release": "semantic-release" | ||
}, | ||
@@ -51,4 +52,9 @@ "dependencies": { | ||
"typedoc": "^0.22.6", | ||
"typescript": "^4.4.2" | ||
"typescript": "^4.4.2", | ||
"semantic-release": "^18.0.1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/nhost/hasura-auth-js.git" | ||
} | ||
} |
@@ -9,17 +9,5 @@ # Hasura Auth JS SDK | ||
or | ||
`$ yarn add hasura-auth-js` | ||
## Documentation | ||
[https://docs.nhost.io/libraries/nhost-js-sdk](https://docs.nhost.io/libraries/nhost-js-sdk) | ||
[https://docs.nhost.io/reference/sdk/authentication](https://docs.nhost.io/reference/sdk/authentication) | ||
``` | ||
type PaymentIntentResult = | ||
| {paymentIntent: PaymentIntent; error?: undefined} | ||
| {paymentIntent?: undefined; error: StripeError}; | ||
``` | ||
Tips: | ||
https://github.com/stripe/stripe-js/blob/9801d2c0ef0d255c005ee40c195e76f55af312f7/types/stripe-js/index.d.ts |
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
153713
3716
0
14
13