Compare commits

..

11 Commits

Author SHA1 Message Date
Szilárd Dóró
11b4d12f12 Merge pull request #1794 from nhost/changeset-release/main
chore: update versions
2023-03-30 19:56:33 +02:00
Szilárd Dóró
12301e6551 fix: use correct @nhost/apollo version 2023-03-30 15:57:43 +02:00
github-actions[bot]
74e52cac2d chore: update versions 2023-03-30 09:07:41 +00:00
Szilárd Dóró
f17823760a Merge pull request #1795 from nhost/fix/presigned-urls
fix: don't alter URLs when no transformation parameters are available
2023-03-30 11:06:32 +02:00
Szilárd Dóró
bb8803a1e3 fix: don't alter URLs 2023-03-30 10:41:57 +02:00
Szilárd Dóró
b846291331 Merge pull request #1793 from nhost/fix/export-issue
fix: don't use conflicting names
2023-03-30 10:07:24 +02:00
Szilárd Dóró
2b2fb94f00 chore: add type checking step 2023-03-30 09:42:23 +02:00
Szilárd Dóró
551760c4f0 fix: don't break builds 2023-03-30 09:37:39 +02:00
Szilárd Dóró
5ae5a8e77d fix: don't break builds 2023-03-30 09:31:54 +02:00
Szilárd Dóró
56aae0c964 fix: don't break builds 2023-03-30 09:28:34 +02:00
Szilárd Dóró
a0e093d77b fix: don't use conflicting names 2023-03-30 09:16:30 +02:00
61 changed files with 282 additions and 167 deletions

View File

@@ -1,5 +1,12 @@
# @nhost/dashboard
## 0.14.1
### Patch Changes
- @nhost/react-apollo@5.0.15
- @nhost/nextjs@1.13.19
## 0.14.0
### Minor Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/dashboard",
"version": "0.14.0",
"version": "0.14.1",
"private": true,
"scripts": {
"preinstall": "npx only-allow pnpm",

View File

@@ -1,5 +1,12 @@
# @nhost/apollo
## 5.2.0
### Patch Changes
- Updated dependencies [a0e093d7]
- @nhost/nhost-js@2.2.0
## 5.1.3
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/apollo",
"version": "5.1.3",
"version": "5.2.0",
"description": "Nhost Apollo Client library",
"license": "MIT",
"keywords": [

View File

@@ -1,5 +1,12 @@
# @nhost/react-apollo
## 5.0.15
### Patch Changes
- @nhost/apollo@5.2.0
- @nhost/react@2.0.13
## 5.0.14
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/react-apollo",
"version": "5.0.14",
"version": "5.0.15",
"description": "Nhost React Apollo client",
"license": "MIT",
"keywords": [

View File

@@ -1,5 +1,11 @@
# @nhost/react-urql
## 2.0.13
### Patch Changes
- @nhost/react@2.0.13
## 2.0.12
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/react-urql",
"version": "2.0.12",
"version": "2.0.13",
"description": "Nhost React URQL client",
"license": "MIT",
"keywords": [

View File

@@ -1,5 +1,11 @@
# @nhost/hasura-auth-js
## 2.1.0
### Minor Changes
- a0e093d7: fix(exports): don't use conflicting names in exports
## 2.0.2
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/hasura-auth-js",
"version": "2.0.2",
"version": "2.1.0",
"description": "Hasura-auth client",
"license": "MIT",
"keywords": [
@@ -43,7 +43,8 @@
},
"scripts": {
"dev": "vite build --config ./vite.dev.config.js",
"build": "run-p build:lib build:umd",
"build": "run-p typecheck build:lib build:umd",
"typecheck": "tsc --noEmit",
"build:lib": "vite build",
"build:umd": "vite build --config ../../config/vite.lib.umd.config.js",
"test": "vitest run",

View File

@@ -1,4 +1,4 @@
import { ErrorPayload } from './types'
import { AuthErrorPayload } from './types'
export const NETWORK_ERROR_CODE = 0
export const OTHER_ERROR_CODE = 1
@@ -12,8 +12,8 @@ export const STATE_ERROR_CODE = 20
* See https://github.com/statelyai/xstate/issues/3037
*/
export class CodifiedError extends Error {
error: ErrorPayload
constructor(original: Error | ErrorPayload) {
error: AuthErrorPayload
constructor(original: Error | AuthErrorPayload) {
super(original.message)
Error.captureStackTrace(this, this.constructor)
if (original instanceof Error) {
@@ -30,95 +30,95 @@ export class CodifiedError extends Error {
}
}
export type ValidationErrorPayload = ErrorPayload & { status: typeof VALIDATION_ERROR_CODE }
export type ValidationAuthErrorPayload = AuthErrorPayload & { status: typeof VALIDATION_ERROR_CODE }
// TODO share with hasura-auth
export const INVALID_EMAIL_ERROR: ValidationErrorPayload = {
export const INVALID_EMAIL_ERROR: ValidationAuthErrorPayload = {
status: VALIDATION_ERROR_CODE,
error: 'invalid-email',
message: 'Email is incorrectly formatted'
}
export const INVALID_MFA_TYPE_ERROR: ValidationErrorPayload = {
export const INVALID_MFA_TYPE_ERROR: ValidationAuthErrorPayload = {
status: VALIDATION_ERROR_CODE,
error: 'invalid-mfa-type',
message: 'MFA type is invalid'
}
export const INVALID_MFA_CODE_ERROR: ValidationErrorPayload = {
export const INVALID_MFA_CODE_ERROR: ValidationAuthErrorPayload = {
status: VALIDATION_ERROR_CODE,
error: 'invalid-mfa-code',
message: 'MFA code is invalid'
}
export const INVALID_PASSWORD_ERROR: ValidationErrorPayload = {
export const INVALID_PASSWORD_ERROR: ValidationAuthErrorPayload = {
status: VALIDATION_ERROR_CODE,
error: 'invalid-password',
message: 'Password is incorrectly formatted'
}
export const INVALID_PHONE_NUMBER_ERROR: ValidationErrorPayload = {
export const INVALID_PHONE_NUMBER_ERROR: ValidationAuthErrorPayload = {
status: VALIDATION_ERROR_CODE,
error: 'invalid-phone-number',
message: 'Phone number is incorrectly formatted'
}
export const INVALID_MFA_TICKET_ERROR: ValidationErrorPayload = {
export const INVALID_MFA_TICKET_ERROR: ValidationAuthErrorPayload = {
status: VALIDATION_ERROR_CODE,
error: 'invalid-mfa-ticket',
message: 'MFA ticket is invalid'
}
export const NO_MFA_TICKET_ERROR: ValidationErrorPayload = {
export const NO_MFA_TICKET_ERROR: ValidationAuthErrorPayload = {
status: VALIDATION_ERROR_CODE,
error: 'no-mfa-ticket',
message: 'No MFA ticket has been provided'
}
export const NO_REFRESH_TOKEN: ValidationErrorPayload = {
export const NO_REFRESH_TOKEN: ValidationAuthErrorPayload = {
status: VALIDATION_ERROR_CODE,
error: 'no-refresh-token',
message: 'No refresh token has been provided'
}
export const TOKEN_REFRESHER_RUNNING_ERROR: ErrorPayload = {
export const TOKEN_REFRESHER_RUNNING_ERROR: AuthErrorPayload = {
status: STATE_ERROR_CODE,
error: 'refresher-already-running',
message:
'The token refresher is already running. You must wait until is has finished before submitting a new token.'
}
export const USER_ALREADY_SIGNED_IN: ErrorPayload = {
export const USER_ALREADY_SIGNED_IN: AuthErrorPayload = {
status: STATE_ERROR_CODE,
error: 'already-signed-in',
message: 'User is already signed in'
}
export const USER_UNAUTHENTICATED: ErrorPayload = {
export const USER_UNAUTHENTICATED: AuthErrorPayload = {
status: STATE_ERROR_CODE,
error: 'unauthenticated-user',
message: 'User is not authenticated'
}
export const USER_NOT_ANONYMOUS: ErrorPayload = {
export const USER_NOT_ANONYMOUS: AuthErrorPayload = {
status: STATE_ERROR_CODE,
error: 'user-not-anonymous',
message: 'User is not anonymous'
}
export const EMAIL_NEEDS_VERIFICATION: ErrorPayload = {
export const EMAIL_NEEDS_VERIFICATION: AuthErrorPayload = {
status: STATE_ERROR_CODE,
error: 'unverified-user',
message: 'Email needs verification'
}
export const INVALID_REFRESH_TOKEN = {
export const INVALID_REFRESH_TOKEN: AuthErrorPayload = {
status: VALIDATION_ERROR_CODE,
error: 'invalid-refresh-token',
message: 'Invalid or expired refresh token'
}
export const INVALID_SIGN_IN_METHOD = {
export const INVALID_SIGN_IN_METHOD: AuthErrorPayload = {
status: OTHER_ERROR_CODE,
error: 'invalid-sign-in-method',
message: 'Invalid sign-in method'

View File

@@ -34,13 +34,13 @@ import {
} from './promises'
import {
AuthChangedFunction,
AuthErrorPayload,
ChangeEmailParams,
ChangeEmailResponse,
ChangePasswordParams,
ChangePasswordResponse,
DeanonymizeParams,
DeanonymizeResponse,
ErrorPayload,
JWTClaims,
JWTHasuraClaims,
NhostAuthConstructorParams,
@@ -411,7 +411,7 @@ export class HasuraAuthClient {
*/
async addSecurityKey(
nickname?: string
): Promise<{ error: ErrorPayload | null; key?: SecurityKey }> {
): Promise<{ error: AuthErrorPayload | null; key?: SecurityKey }> {
const { error, key } = await addSecurityKeyPromise(this._client, nickname)
return { error, key }
}

View File

@@ -1,4 +1,4 @@
import { ErrorPayload, User } from '../../types'
import { AuthErrorPayload, User } from '../../types'
export type StateErrorTypes = 'registration' | 'authentication' | 'signout'
@@ -21,7 +21,7 @@ export type AuthContext = {
}
/** Number of times the user tried to get an access token from a refresh token but got a network error */
importTokenAttempts: number
errors: Partial<Record<StateErrorTypes, ErrorPayload>>
errors: Partial<Record<StateErrorTypes, AuthErrorPayload>>
}
export const INITIAL_MACHINE_CONTEXT: AuthContext = {

View File

@@ -24,9 +24,9 @@ import {
} from '../../errors'
import { localStorageGetter, localStorageSetter } from '../../local-storage'
import {
AuthErrorPayload,
AuthOptions,
DeanonymizeResponse,
ErrorPayload,
NhostSession,
NhostSessionResponse,
PasswordlessEmailResponse,
@@ -856,7 +856,7 @@ export const createAuthMachine = ({
error: null
}
}
let error: ErrorPayload | null = null
let error: AuthErrorPayload | null = null
if (autoSignIn) {
const urlToken = getParameterByName('refreshToken') || null
if (urlToken) {
@@ -866,7 +866,7 @@ export const createAuthMachine = ({
})
return { session, error: null }
} catch (exception) {
error = (exception as { error: ErrorPayload }).error
error = (exception as { error: AuthErrorPayload }).error
}
} else {
const error = getParameterByName('error')
@@ -890,7 +890,7 @@ export const createAuthMachine = ({
})
return { session, error: null }
} catch (exception) {
error = (exception as { error: ErrorPayload }).error
error = (exception as { error: AuthErrorPayload }).error
}
}
if (error) {

View File

@@ -1,12 +1,12 @@
import { assign, createMachine, send } from 'xstate'
import { INVALID_EMAIL_ERROR } from '../errors'
import { AuthClient } from '../internal-client'
import { ChangeEmailOptions, ChangeEmailResponse, ErrorPayload } from '../types'
import { AuthErrorPayload, ChangeEmailOptions, ChangeEmailResponse } from '../types'
import { postFetch, rewriteRedirectTo } from '../utils'
import { isValidEmail } from '../utils/validators'
export type ChangeEmailContext = {
error: ErrorPayload | null
error: AuthErrorPayload | null
}
export type ChangeEmailEvents =
@@ -16,7 +16,7 @@ export type ChangeEmailEvents =
options?: ChangeEmailOptions
}
| { type: 'SUCCESS' }
| { type: 'ERROR'; error: ErrorPayload | null }
| { type: 'ERROR'; error: AuthErrorPayload | null }
export type ChangeEmailServices = {
request: { data: ChangeEmailResponse }

View File

@@ -16,9 +16,9 @@ export interface Typegen0 {
}
missingImplementations: {
actions: never
services: never
guards: never
delays: never
guards: never
services: never
}
eventsCausingActions: {
reportError: 'error.platform.requestChange'
@@ -26,13 +26,13 @@ export interface Typegen0 {
saveInvalidEmailError: 'REQUEST'
saveRequestError: 'error.platform.requestChange'
}
eventsCausingServices: {
requestChange: 'REQUEST'
}
eventsCausingDelays: {}
eventsCausingGuards: {
invalidEmail: 'REQUEST'
}
eventsCausingDelays: {}
eventsCausingServices: {
requestChange: 'REQUEST'
}
matchesStates:
| 'idle'
| 'idle.error'

View File

@@ -1,12 +1,12 @@
import { assign, createMachine, send } from 'xstate'
import { INVALID_PASSWORD_ERROR } from '../errors'
import { AuthClient } from '../internal-client'
import { ChangePasswordResponse, ErrorPayload } from '../types'
import { AuthErrorPayload, ChangePasswordResponse } from '../types'
import { postFetch } from '../utils'
import { isValidPassword } from '../utils/validators'
export type ChangePasswordContext = {
error: ErrorPayload | null
error: AuthErrorPayload | null
}
export type ChangePasswordEvents =
| {
@@ -15,7 +15,7 @@ export type ChangePasswordEvents =
ticket?: string
}
| { type: 'SUCCESS' }
| { type: 'ERROR'; error: ErrorPayload | null }
| { type: 'ERROR'; error: AuthErrorPayload | null }
export type ChangePasswordServices = {
requestChange: { data: ChangePasswordResponse }

View File

@@ -16,9 +16,9 @@ export interface Typegen0 {
}
missingImplementations: {
actions: never
services: never
guards: never
delays: never
guards: never
services: never
}
eventsCausingActions: {
reportError: 'error.platform.requestChange'
@@ -26,13 +26,13 @@ export interface Typegen0 {
saveInvalidPasswordError: 'REQUEST'
saveRequestError: 'error.platform.requestChange'
}
eventsCausingServices: {
requestChange: 'REQUEST'
}
eventsCausingDelays: {}
eventsCausingGuards: {
invalidPassword: 'REQUEST'
}
eventsCausingDelays: {}
eventsCausingServices: {
requestChange: 'REQUEST'
}
matchesStates:
| 'idle'
| 'idle.error'

View File

@@ -1,11 +1,11 @@
import { assign, createMachine, send } from 'xstate'
import { INVALID_MFA_CODE_ERROR, INVALID_MFA_TYPE_ERROR } from '../errors'
import { AuthClient } from '../internal-client'
import { ErrorPayload } from '../types'
import { AuthErrorPayload } from '../types'
import { getFetch, postFetch } from '../utils'
export type EnableMfaContext = {
error: ErrorPayload | null
error: AuthErrorPayload | null
imageUrl: string | null
secret: string | null
}
@@ -20,9 +20,9 @@ export type EnableMfaEvents =
activeMfaType: 'totp'
}
| { type: 'GENERATED' }
| { type: 'GENERATED_ERROR'; error: ErrorPayload | null }
| { type: 'GENERATED_ERROR'; error: AuthErrorPayload | null }
| { type: 'SUCCESS' }
| { type: 'ERROR'; error: ErrorPayload | null }
| { type: 'ERROR'; error: AuthErrorPayload | null }
export type EnableMfadMachine = ReturnType<typeof createEnableMfaMachine>

View File

@@ -23,9 +23,9 @@ export interface Typegen0 {
}
missingImplementations: {
actions: never
services: never
guards: never
delays: never
guards: never
services: never
}
eventsCausingActions: {
reportError: 'error.platform.activate'
@@ -37,15 +37,15 @@ export interface Typegen0 {
saveInvalidMfaCodeError: 'ACTIVATE'
saveInvalidMfaTypeError: 'ACTIVATE'
}
eventsCausingServices: {
activate: 'ACTIVATE'
generate: 'GENERATE'
}
eventsCausingDelays: {}
eventsCausingGuards: {
invalidMfaCode: 'ACTIVATE'
invalidMfaType: 'ACTIVATE'
}
eventsCausingDelays: {}
eventsCausingServices: {
activate: 'ACTIVATE'
generate: 'GENERATE'
}
matchesStates:
| 'generated'
| 'generated.activated'

View File

@@ -1,12 +1,12 @@
import { assign, createMachine, send } from 'xstate'
import { INVALID_EMAIL_ERROR } from '../errors'
import { AuthClient } from '../internal-client'
import { ErrorPayload, ResetPasswordOptions, ResetPasswordResponse } from '../types'
import { AuthErrorPayload, ResetPasswordOptions, ResetPasswordResponse } from '../types'
import { postFetch, rewriteRedirectTo } from '../utils'
import { isValidEmail } from '../utils/validators'
export type ResetPasswordContext = {
error: ErrorPayload | null
error: AuthErrorPayload | null
}
export type ResetPasswordEvents =
| {
@@ -15,7 +15,7 @@ export type ResetPasswordEvents =
options?: ResetPasswordOptions
}
| { type: 'SUCCESS' }
| { type: 'ERROR'; error: ErrorPayload | null }
| { type: 'ERROR'; error: AuthErrorPayload | null }
export type ResetPasswordServices = {
requestChange: { data: ResetPasswordResponse }

View File

@@ -16,9 +16,9 @@ export interface Typegen0 {
}
missingImplementations: {
actions: never
services: never
guards: never
delays: never
guards: never
services: never
}
eventsCausingActions: {
reportError: 'error.platform.requestChange'
@@ -26,13 +26,13 @@ export interface Typegen0 {
saveInvalidEmailError: 'REQUEST'
saveRequestError: 'error.platform.requestChange'
}
eventsCausingServices: {
requestChange: 'REQUEST'
}
eventsCausingDelays: {}
eventsCausingGuards: {
invalidEmail: 'REQUEST'
}
eventsCausingDelays: {}
eventsCausingServices: {
requestChange: 'REQUEST'
}
matchesStates:
| 'idle'
| 'idle.error'

View File

@@ -1,12 +1,16 @@
import { assign, createMachine, send } from 'xstate'
import { INVALID_EMAIL_ERROR } from '../errors'
import { AuthClient } from '../internal-client'
import { ErrorPayload, SendVerificationEmailOptions, SendVerificationEmailResponse } from '../types'
import {
AuthErrorPayload,
SendVerificationEmailOptions,
SendVerificationEmailResponse
} from '../types'
import { postFetch, rewriteRedirectTo } from '../utils'
import { isValidEmail } from '../utils/validators'
export type SendVerificationEmailContext = {
error: ErrorPayload | null
error: AuthErrorPayload | null
}
export type SendVerificationEmailEvents =
@@ -16,7 +20,7 @@ export type SendVerificationEmailEvents =
options?: SendVerificationEmailOptions
}
| { type: 'SUCCESS' }
| { type: 'ERROR'; error: ErrorPayload | null }
| { type: 'ERROR'; error: AuthErrorPayload | null }
export type SendVerificationEmailServices = {
request: { data: SendVerificationEmailResponse }

View File

@@ -16,9 +16,9 @@ export interface Typegen0 {
}
missingImplementations: {
actions: never
services: never
guards: never
delays: never
guards: never
services: never
}
eventsCausingActions: {
reportError: 'error.platform.request'
@@ -26,13 +26,13 @@ export interface Typegen0 {
saveInvalidEmailError: 'REQUEST'
saveRequestError: 'error.platform.request'
}
eventsCausingServices: {
request: 'REQUEST'
}
eventsCausingDelays: {}
eventsCausingGuards: {
invalidEmail: 'REQUEST'
}
eventsCausingDelays: {}
eventsCausingServices: {
request: 'REQUEST'
}
matchesStates:
| 'idle'
| 'idle.error'

View File

@@ -6,14 +6,14 @@ import {
import { postFetch } from '..'
import { CodifiedError } from '../errors'
import { AuthClient } from '../internal-client'
import { ErrorPayload, SecurityKey } from '../types'
import { ActionErrorState, ActionLoadingState, ActionSuccessState } from './types'
import { AuthErrorPayload, SecurityKey } from '../types'
import { AuthActionErrorState, AuthActionLoadingState, AuthActionSuccessState } from './types'
export interface AddSecurityKeyHandlerResult extends ActionErrorState, ActionSuccessState {
export interface AddSecurityKeyHandlerResult extends AuthActionErrorState, AuthActionSuccessState {
key?: SecurityKey
}
export interface AddSecurityKeyState extends AddSecurityKeyHandlerResult, ActionLoadingState {}
export interface AddSecurityKeyState extends AddSecurityKeyHandlerResult, AuthActionLoadingState {}
export const addSecurityKeyPromise = async (
{ backendUrl, interpreter }: AuthClient,
@@ -38,7 +38,7 @@ export const addSecurityKeyPromise = async (
)
return { key, isError: false, error: null, isSuccess: true }
} catch (e) {
const { error } = e as { error: ErrorPayload }
const { error } = e as { error: AuthErrorPayload }
return { isError: true, error, isSuccess: false }
}
}

View File

@@ -3,10 +3,12 @@ import { InterpreterFrom } from 'xstate'
import { ChangeEmailMachine } from '../machines'
import { ChangeEmailOptions } from '../types'
import { ActionErrorState, ActionLoadingState, NeedsEmailVerificationState } from './types'
export interface ChangeEmailHandlerResult extends ActionErrorState, NeedsEmailVerificationState {}
import { AuthActionErrorState, AuthActionLoadingState, NeedsEmailVerificationState } from './types'
export interface ChangeEmailHandlerResult
extends AuthActionErrorState,
NeedsEmailVerificationState {}
export interface ChangeEmailState extends ChangeEmailHandlerResult, ActionLoadingState {}
export interface ChangeEmailState extends ChangeEmailHandlerResult, AuthActionLoadingState {}
export const changeEmailPromise = async (
interpreter: InterpreterFrom<ChangeEmailMachine>,

View File

@@ -2,11 +2,11 @@ import { InterpreterFrom } from 'xstate'
import { ChangePasswordMachine } from '../machines'
import { ActionErrorState, ActionLoadingState, ActionSuccessState } from './types'
import { AuthActionErrorState, AuthActionLoadingState, AuthActionSuccessState } from './types'
export interface ChangePasswordState extends ChangePasswordHandlerResult, ActionLoadingState {}
export interface ChangePasswordState extends ChangePasswordHandlerResult, AuthActionLoadingState {}
export interface ChangePasswordHandlerResult extends ActionErrorState, ActionSuccessState {}
export interface ChangePasswordHandlerResult extends AuthActionErrorState, AuthActionSuccessState {}
export const changePasswordPromise = async (
interpreter: InterpreterFrom<ChangePasswordMachine>,

View File

@@ -2,9 +2,9 @@ import { InterpreterFrom } from 'xstate'
import { EnableMfadMachine } from '../machines'
import { ActionErrorState } from './types'
import { AuthActionErrorState } from './types'
export interface GenerateQrCodeHandlerResult extends ActionErrorState {
export interface GenerateQrCodeHandlerResult extends AuthActionErrorState {
qrCodeDataUrl: string
isGenerated: boolean
}
@@ -12,7 +12,7 @@ export interface GenerateQrCodeHandlerResult extends ActionErrorState {
export interface GenerateQrCodeState extends GenerateQrCodeHandlerResult {
isGenerating: boolean
}
export interface ActivateMfaHandlerResult extends ActionErrorState {
export interface ActivateMfaHandlerResult extends AuthActionErrorState {
isActivated: boolean
}

View File

@@ -3,14 +3,14 @@ import { InterpreterFrom } from 'xstate'
import { ResetPasswordMachine } from '../machines'
import { ResetPasswordOptions } from '../types'
import { ActionErrorState, ActionLoadingState } from './types'
import { AuthActionErrorState, AuthActionLoadingState } from './types'
export interface ResetPasswordHandlerResult extends ActionErrorState {
export interface ResetPasswordHandlerResult extends AuthActionErrorState {
/** Returns `true` when an email to reset the password has been sent */
isSent: boolean
}
export interface ResetPasswordState extends ResetPasswordHandlerResult, ActionLoadingState {}
export interface ResetPasswordState extends ResetPasswordHandlerResult, AuthActionLoadingState {}
export const resetPasswordPromise = async (
interpreter: InterpreterFrom<ResetPasswordMachine>,

View File

@@ -3,15 +3,15 @@ import { InterpreterFrom } from 'xstate'
import { SendVerificationEmailMachine } from '../machines'
import { SendVerificationEmailOptions } from '../types'
import { ActionErrorState, ActionLoadingState } from './types'
import { AuthActionErrorState, AuthActionLoadingState } from './types'
export interface SendVerificationEmailHandlerResult extends ActionErrorState {
export interface SendVerificationEmailHandlerResult extends AuthActionErrorState {
/** Returns `true` when a new verification email has been sent */
isSent: boolean
}
export interface SendVerificationEmailState
extends ActionLoadingState,
extends AuthActionLoadingState,
SendVerificationEmailHandlerResult {}
export const sendVerificationEmailPromise = (

View File

@@ -1,10 +1,12 @@
import { USER_ALREADY_SIGNED_IN } from '../errors'
import { AuthInterpreter } from '../machines'
import { ActionLoadingState, SessionActionHandlerResult } from './types'
import { AuthActionLoadingState, SessionActionHandlerResult } from './types'
export interface SignInAnonymousHandlerResult extends SessionActionHandlerResult {}
export interface SignInAnonymousState extends SignInAnonymousHandlerResult, ActionLoadingState {}
export interface SignInAnonymousState
extends SignInAnonymousHandlerResult,
AuthActionLoadingState {}
export const signInAnonymousPromise = (
interpreter: AuthInterpreter

View File

@@ -2,7 +2,7 @@ import { USER_ALREADY_SIGNED_IN } from '../errors'
import { AuthInterpreter } from '../machines'
import {
ActionLoadingState,
AuthActionLoadingState,
NeedsEmailVerificationState,
SessionActionHandlerResult
} from './types'
@@ -18,7 +18,7 @@ export interface SignInEmailPasswordHandlerResult
export interface SignInEmailPasswordState
extends SignInEmailPasswordHandlerResult,
ActionLoadingState {}
AuthActionLoadingState {}
export const signInEmailPasswordPromise = (
interpreter: AuthInterpreter,

View File

@@ -2,13 +2,13 @@ import { USER_ALREADY_SIGNED_IN } from '../errors'
import { AuthInterpreter } from '../machines'
import { PasswordlessOptions } from '../types'
import { ActionErrorState, ActionLoadingState, ActionSuccessState } from './types'
import { AuthActionErrorState, AuthActionLoadingState, AuthActionSuccessState } from './types'
export interface SignInEmailPasswordlessHandlerResult
extends ActionErrorState,
ActionSuccessState {}
extends AuthActionErrorState,
AuthActionSuccessState {}
export interface SignInEmailPasswordlessState
extends SignInEmailPasswordlessHandlerResult,
ActionLoadingState {}
AuthActionLoadingState {}
export const signInEmailPasswordlessPromise = (
interpreter: AuthInterpreter,

View File

@@ -2,7 +2,7 @@ import { USER_ALREADY_SIGNED_IN } from '../errors'
import { AuthInterpreter } from '../machines'
import {
ActionLoadingState,
AuthActionLoadingState,
NeedsEmailVerificationState,
SessionActionHandlerResult
} from './types'
@@ -13,7 +13,7 @@ export interface SignInSecurityKeyPasswordlessHandlerResult
export interface SignInSecurityKeyPasswordlessState
extends SignInSecurityKeyPasswordlessHandlerResult,
ActionLoadingState {}
AuthActionLoadingState {}
export const signInEmailSecurityKeyPromise = (interpreter: AuthInterpreter, email: string) =>
new Promise<SignInSecurityKeyPasswordlessHandlerResult>((resolve) => {

View File

@@ -1,11 +1,11 @@
import { USER_ALREADY_SIGNED_IN } from '../errors'
import { AuthInterpreter } from '../machines'
import { ActionLoadingState, SessionActionHandlerResult } from './types'
import { AuthActionLoadingState, SessionActionHandlerResult } from './types'
export interface SignInMfaTotpHandlerResult extends SessionActionHandlerResult {}
export interface SignInMfaTotpState extends SignInMfaTotpHandlerResult, ActionLoadingState {}
export interface SignInMfaTotpState extends SignInMfaTotpHandlerResult, AuthActionLoadingState {}
export const signInMfaTotpPromise = (interpreter: AuthInterpreter, otp: string, ticket?: string) =>
new Promise<SignInMfaTotpHandlerResult>((resolve) => {

View File

@@ -2,13 +2,15 @@ import { USER_ALREADY_SIGNED_IN } from '../errors'
import { AuthInterpreter } from '../machines'
import { PasswordlessOptions } from '../types'
import { ActionErrorState, ActionLoadingState, ActionSuccessState } from './types'
import { AuthActionErrorState, AuthActionLoadingState, AuthActionSuccessState } from './types'
export interface SignInSmsPasswordlessState
extends SignInSmsPasswordlessHandlerResult,
ActionLoadingState {}
AuthActionLoadingState {}
export interface SignInSmsPasswordlessHandlerResult extends ActionErrorState, ActionSuccessState {
export interface SignInSmsPasswordlessHandlerResult
extends AuthActionErrorState,
AuthActionSuccessState {
/**
* Returns true when the one-time password has been sent over by SMS, and the user needs to send it back to complete sign-in.
*/

View File

@@ -1,12 +1,12 @@
import { USER_ALREADY_SIGNED_IN } from '../errors'
import { AuthInterpreter } from '../machines'
import { ActionLoadingState, SessionActionHandlerResult } from './types'
import { AuthActionLoadingState, SessionActionHandlerResult } from './types'
export interface SignInSmsPasswordlessOtpHandlerResult extends SessionActionHandlerResult {}
export interface SignInSmsPasswordlessOtpState
extends SignInSmsPasswordlessOtpHandlerResult,
ActionLoadingState {}
AuthActionLoadingState {}
export const signInSmsPasswordlessOtpPromise = (
interpreter: AuthInterpreter,

View File

@@ -1,10 +1,10 @@
import { USER_UNAUTHENTICATED } from '../errors'
import { AuthInterpreter } from '../machines'
import { ActionErrorState, ActionLoadingState, ActionSuccessState } from './types'
import { AuthActionErrorState, AuthActionLoadingState, AuthActionSuccessState } from './types'
export interface SignOutlessHandlerResult extends ActionErrorState, ActionSuccessState {}
export interface SignOutlessState extends SignOutlessHandlerResult, ActionLoadingState {}
export interface SignOutlessHandlerResult extends AuthActionErrorState, AuthActionSuccessState {}
export interface SignOutlessState extends SignOutlessHandlerResult, AuthActionLoadingState {}
export const signOutPromise = async (
interpreter: AuthInterpreter,

View File

@@ -3,7 +3,7 @@ import { AuthInterpreter } from '../machines'
import { SignUpOptions } from '../types'
import {
ActionLoadingState,
AuthActionLoadingState,
NeedsEmailVerificationState,
SessionActionHandlerResult
} from './types'
@@ -14,7 +14,7 @@ export interface SignUpEmailPasswordHandlerResult
export interface SignUpEmailPasswordState
extends SignUpEmailPasswordHandlerResult,
ActionLoadingState {}
AuthActionLoadingState {}
export const signUpEmailPasswordPromise = (
interpreter: AuthInterpreter,

View File

@@ -3,7 +3,7 @@ import { AuthInterpreter } from '../machines'
import { SignUpSecurityKeyOptions } from '../types'
import {
ActionLoadingState,
AuthActionLoadingState,
NeedsEmailVerificationState,
SessionActionHandlerResult
} from './types'
@@ -14,7 +14,7 @@ export interface SignUpSecurityKeyHandlerResult
export interface SignUpSecurityKeyState
extends SignUpSecurityKeyHandlerResult,
ActionLoadingState {}
AuthActionLoadingState {}
export const signUpEmailSecurityKeyPromise = (
interpreter: AuthInterpreter,

View File

@@ -1,28 +1,28 @@
import { ErrorPayload, User } from '../types'
import { AuthErrorPayload, User } from '../types'
export interface ActionErrorState {
export interface AuthActionErrorState {
/**
* @return `true` if an error occurred
* @depreacted use `!isSuccess` or `!!error` instead
* */
isError: boolean
/** Provides details about the error */
error: ErrorPayload | null
error: AuthErrorPayload | null
}
export interface ActionLoadingState {
export interface AuthActionLoadingState {
/**
* @return `true` when the action is executing, `false` when it finished its execution.
*/
isLoading: boolean
}
export interface ActionSuccessState {
export interface AuthActionSuccessState {
/** Returns `true` if the action is successful. */
isSuccess: boolean
}
export interface SessionActionHandlerResult extends ActionSuccessState, ActionErrorState {
export interface SessionActionHandlerResult extends AuthActionSuccessState, AuthActionErrorState {
/** User information */
user: User | null
/** Access token (JWT) */

View File

@@ -1,5 +1,5 @@
// TODO shared with other packages
export type ErrorPayload = {
export type AuthErrorPayload = {
error: string
status: number
message: string

View File

@@ -1,13 +1,13 @@
import { ErrorPayload, NhostSession } from './common'
import { AuthErrorPayload, NhostSession } from './common'
// Hasura-auth API response types
export interface NullableErrorResponse {
error: ErrorPayload | null
error: AuthErrorPayload | null
}
/** session payload from common hasura-auth responses */
export type NhostSessionResponse =
| { session: null; error: ErrorPayload }
| { session: null; error: AuthErrorPayload }
| { session: NhostSession | null; error: null }
/** payload from hasura-auth endpoint /signin/email-password */
@@ -16,7 +16,7 @@ export interface SignInResponse {
mfa: {
ticket: string
} | null
error: ErrorPayload | null
error: AuthErrorPayload | null
}
/** payload from hasura-auth endpoint /signup/email-password */

View File

@@ -1,5 +1,15 @@
# @nhost/hasura-storage-js
## 2.1.0
### Minor Changes
- a0e093d7: fix(exports): don't use conflicting names in exports
### Patch Changes
- bb8803a1: fix(presigned-url): don't alter URL when no transformation params were provided
## 2.0.5
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/hasura-storage-js",
"version": "2.0.5",
"version": "2.1.0",
"description": "Hasura-storage client",
"license": "MIT",
"keywords": [
@@ -41,7 +41,8 @@
},
"scripts": {
"dev": "vite build --config ../../config/vite.lib.dev.config.js",
"build": "run-p build:lib build:umd",
"build": "run-p typecheck build:lib build:umd",
"typecheck": "tsc --noEmit",
"build:lib": "vite build",
"build:umd": "vite build --config ../../config/vite.lib.umd.config.js",
"e2e": "start-test e2e:backend http-get://localhost:9695 ci:test",

View File

@@ -1,12 +1,12 @@
import FormData from 'form-data'
import { assign, createMachine } from 'xstate'
import { ErrorPayload, FileUploadConfig } from '../utils'
import { FileUploadConfig, StorageErrorPayload } from '../utils'
import { fetchUpload } from '../utils/upload'
export type FileUploadContext = {
progress: number | null
loaded: number
error: ErrorPayload | null
error: StorageErrorPayload | null
id?: string
bucketId?: string
file?: File
@@ -24,7 +24,7 @@ export type FileUploadEvents =
} & FileUploadConfig)
| { type: 'UPLOAD_PROGRESS'; progress: number; loaded: number; additions: number }
| { type: 'UPLOAD_DONE'; id: string; bucketId: string }
| { type: 'UPLOAD_ERROR'; error: ErrorPayload }
| { type: 'UPLOAD_ERROR'; error: StorageErrorPayload }
| { type: 'CANCEL' }
| { type: 'DESTROY' }

View File

@@ -1,7 +1,7 @@
import { InterpreterFrom } from 'xstate'
import { FileItemRef, FileUploadMachine } from '../machines'
import { ActionErrorState, FileUploadConfig, StorageUploadFileParams } from '../utils'
import { FileUploadConfig, StorageActionErrorState, StorageUploadFileParams } from '../utils'
export interface UploadProgressState {
/**
@@ -14,7 +14,7 @@ export interface UploadProgressState {
progress: number | null
}
export interface UploadFileHandlerResult extends ActionErrorState {
export interface UploadFileHandlerResult extends StorageActionErrorState {
/**
* Returns `true` when the file has been successfully uploaded.
*/

View File

@@ -3,7 +3,7 @@ import appendImageTransformationParameters from './appendImageTransformationPara
test('should append image transformation parameters to a simple URL', () => {
expect(
appendImageTransformationParameters('https://example.com/', {
appendImageTransformationParameters('https://example.com', {
width: 100,
height: 100,
blur: 50,
@@ -25,7 +25,7 @@ test('should append image transformation parameters to a URL with existing query
test('should not append falsy values', () => {
expect(
appendImageTransformationParameters('https://example.com/', {
appendImageTransformationParameters('https://example.com', {
width: undefined,
height: 100,
blur: undefined,
@@ -35,7 +35,9 @@ test('should not append falsy values', () => {
})
test('should keep the original URL if no transformation parameters are provided', () => {
expect(appendImageTransformationParameters('https://example.com/', {})).toBe(
'https://example.com/'
)
expect(appendImageTransformationParameters('https://example.com')).toBe('https://example.com')
expect(
appendImageTransformationParameters('https://example.com/?param1=test_data&param2=test_data')
).toBe('https://example.com/?param1=test_data&param2=test_data')
expect(appendImageTransformationParameters('https://example.com/')).toBe('https://example.com/')
})

View File

@@ -12,8 +12,12 @@ import { StorageImageTransformationParams } from '../types'
*/
export default function appendImageTransformationParameters(
url: string,
params: StorageImageTransformationParams
params?: StorageImageTransformationParams
): string {
if (!params || Object.keys(params).length === 0) {
return url
}
const urlObject = new URL(url)
// create an object with the transformation parameters by using the first

View File

@@ -1,21 +1,21 @@
import FormData from 'form-data'
// TODO shared with other packages
export type ErrorPayload = {
export type StorageErrorPayload = {
error: string
status: number
message: string
}
// TODO shared with other packages
export interface ActionErrorState {
export interface StorageActionErrorState {
/**
* @return `true` if an error occurred
* @depreacted use `!isSuccess` or `!!error` instead
* */
isError: boolean
/** Provides details about the error */
error: ErrorPayload | null
error: StorageErrorPayload | null
}
// * Avoid circular references and broken links in docusaurus generated docs
@@ -46,7 +46,7 @@ export type StorageUploadParams = StorageUploadFileParams | StorageUploadFormDat
export type StorageUploadResponse =
| { fileMetadata: FileResponse; error: null }
| { fileMetadata: null; error: ErrorPayload }
| { fileMetadata: null; error: StorageErrorPayload }
export interface StorageImageTransformationParams {
/** Image width, in pixels */

View File

@@ -1,6 +1,6 @@
import FormData from 'form-data'
import fetch from 'isomorphic-unfetch'
import { ErrorPayload, StorageUploadResponse } from './types'
import { StorageErrorPayload, StorageUploadResponse } from './types'
/** Convert any string into ISO-8859-1 */
export const toIso88591 = (fileName: string) => {
@@ -59,7 +59,7 @@ export const fetchUpload = async (
})
if (!response.ok) {
const error: ErrorPayload = {
const error: StorageErrorPayload = {
status: response.status,
message: await response.text(),
// * errors from hasura-storage are not codified
@@ -70,7 +70,7 @@ export const fetchUpload = async (
const fileMetadata = await response.json()
return { fileMetadata, error: null }
} catch (e) {
const error: ErrorPayload = {
const error: StorageErrorPayload = {
status: 0,
message: (e as Error).message,
error: (e as Error).message

View File

@@ -1,5 +1,11 @@
# @nhost/nextjs
## 1.13.19
### Patch Changes
- @nhost/react@2.0.13
## 1.13.18
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/nextjs",
"version": "1.13.18",
"version": "1.13.19",
"description": "Nhost NextJS library",
"license": "MIT",
"keywords": [

View File

@@ -1,5 +1,18 @@
# @nhost/nhost-js
## 2.2.0
### Minor Changes
- a0e093d7: fix(exports): don't use conflicting names in exports
### Patch Changes
- Updated dependencies [bb8803a1]
- Updated dependencies [a0e093d7]
- @nhost/hasura-storage-js@2.1.0
- @nhost/hasura-auth-js@2.1.0
## 2.1.2
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/nhost-js",
"version": "2.1.2",
"version": "2.2.0",
"description": "Nhost JavaScript SDK",
"license": "MIT",
"keywords": [
@@ -44,7 +44,8 @@
},
"scripts": {
"dev": "vite build --config ../../config/vite.lib.dev.config.js",
"build": "run-p build:lib build:umd",
"build": "run-p typecheck build:lib build:umd",
"typecheck": "tsc --noEmit",
"build:lib": "vite build",
"build:umd": "vite build --config ../../config/vite.lib.umd.config.js",
"test": "vitest run",

View File

@@ -1,10 +1,4 @@
export * from '@nhost/hasura-auth-js'
// ErrorPayload and ActionErrorState are two conflicting types, but these are
// the same in both packages, so this error is ignored for now.
// @ts-ignore
export * from '@nhost/hasura-storage-js'
export * from './clients'
// ErrorPayload is conflicting types, but it is the same in both packages,
// so this error is ignored for now.
// @ts-ignore
export * from './utils/types'

View File

@@ -1,11 +1,37 @@
import { NhostAuthConstructorParams } from '@nhost/hasura-auth-js'
// TODO shared with other packages
export type ErrorPayload = {
export interface ErrorPayload {
error: string
status: number
message: string
}
// TODO shared with other packages
export interface ActionErrorState {
/**
* @return `true` if an error occurred
* @depreacted use `!isSuccess` or `!!error` instead
* */
isError: boolean
/** Provides details about the error */
error: ErrorPayload | null
}
// TODO shared with other packages
export interface ActionLoadingState {
/**
* @return `true` when the action is executing, `false` when it finished its execution.
*/
isLoading: boolean
}
// TODO shared with other packages
export interface ActionSuccessState {
/** Returns `true` if the action is successful. */
isSuccess: boolean
}
export type BackendUrl = {
/**
* Nhost backend URL

View File

@@ -1,5 +1,12 @@
# @nhost/react
## 2.0.13
### Patch Changes
- Updated dependencies [a0e093d7]
- @nhost/nhost-js@2.2.0
## 2.0.12
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/react",
"version": "2.0.12",
"version": "2.0.13",
"description": "Nhost React library",
"license": "MIT",
"keywords": [

View File

@@ -1,5 +1,12 @@
# @nhost/vue
## 1.13.19
### Patch Changes
- Updated dependencies [a0e093d7]
- @nhost/nhost-js@2.2.0
## 1.13.18
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/vue",
"version": "1.13.18",
"version": "1.13.19",
"description": "Nhost Vue library",
"license": "MIT",
"keywords": [