diff --git a/src/common/rest/check-challenge-signature/index.ts b/src/common/rest/check-challenge-signature/index.ts new file mode 100644 index 00000000..f7e08c2c --- /dev/null +++ b/src/common/rest/check-challenge-signature/index.ts @@ -0,0 +1,56 @@ +import { MethodMetadata, Parameter } from '..'; +import { useMasaMutation, useRestCall } from '../../helpers/rest-calls'; + +const path = 'session/check-signature'; + +export function useMethod({ body }: any) { + const { data, error, loading, getData } = useRestCall({ + headers: Headers, + metadata, + body, + }); + + return { data, error, loading, getData }; +} + +export function useSimpleMethod({ pathParameters, body, settings }: any) { + const masaQuery = useMasaMutation( + 'check-challenge-signature', + { + pathParameters, + headers: Headers, + body, + metadata, + }, + settings + ); + return masaQuery; +} + +const parameters: Parameter[] = [ + { + key: 1, + name: 'signature', + description: 'Challenge signature', + required: 'yes', + default: '', + dataType: 'string', + }, + { + key: 2, + name: 'address', + description: 'User address', + required: 'yes', + default: '', + dataType: 'string', + }, +]; + +export const metadata: MethodMetadata = { + author: 'Hide on bush', + authorPicture: '', + description: 'Send signed challenge to backend for authentication', + name: path, + method: 'POST', + parameters: parameters, +}; diff --git a/src/common/rest/get-challenge/index.ts b/src/common/rest/get-challenge/index.ts new file mode 100644 index 00000000..bc49a431 --- /dev/null +++ b/src/common/rest/get-challenge/index.ts @@ -0,0 +1,36 @@ +import { MethodMetadata } from '..'; +import { Headers } from '../../helpers/axios'; +import { useMasaQuery, useRestCall } from '../../helpers/rest-calls'; + +const path = 'session/get-challenge'; + +export function useMethod() { + const { data, error, loading, getData } = useRestCall({ + headers: Headers, + metadata, + }); + return { data, error, loading, getData }; +} + +export function useSimpleMethod({ pathParameters, body, settings }: any) { + const masaQuery = useMasaQuery( + 'get-challenge', + { + pathParameters, + headers: Headers, + body, + metadata, + }, + settings + ); + return masaQuery; +} + +export const metadata: MethodMetadata = { + author: 'Hide on bush', + authorPicture: '', + description: 'Get challenge', + name: path, + method: 'GET', + parameters: [], +}; diff --git a/src/common/rest/get-session/index.ts b/src/common/rest/get-session/index.ts new file mode 100644 index 00000000..6d80ccb7 --- /dev/null +++ b/src/common/rest/get-session/index.ts @@ -0,0 +1,36 @@ +import { MethodMetadata } from '..'; +import { Headers } from '../../helpers/axios'; +import { useMasaQuery, useRestCall } from '../../helpers/rest-calls'; + +const path = 'session/check'; + +export function useMethod() { + const { data, error, loading, getData } = useRestCall({ + headers: Headers, + metadata, + }); + return { data, error, loading, getData }; +} + +export function useSimpleMethod({ pathParameters, body, settings }: any) { + const masaQuery = useMasaQuery( + 'get-session', + { + pathParameters, + headers: Headers, + body, + metadata, + }, + settings + ); + return masaQuery; +} + +export const metadata: MethodMetadata = { + author: 'Hide on bush', + authorPicture: '', + description: 'Get session', + name: path, + method: 'GET', + parameters: [], +}; diff --git a/src/common/rest/index.ts b/src/common/rest/index.ts index 404318b6..bf5d2001 100644 --- a/src/common/rest/index.ts +++ b/src/common/rest/index.ts @@ -12,7 +12,6 @@ import * as contractsMint from './contracts-mint'; import * as mintCreditScore from './mint-credit-score'; import * as getCreditScore from './get-credit-score'; - import * as getVezgoLink from './vezgo/get-link'; import * as listVezgoProviders from './vezgo/list-providers'; import * as listVezgoAccounts from './vezgo/list-accounts'; @@ -36,6 +35,11 @@ import * as balances from './balances'; import * as getIdentity from './get-identity'; +import * as getChallenge from './get-challenge'; +import * as getSession from './get-session'; +import * as checkSignatureChallenge from './check-challenge-signature'; +import * as sessionLogout from './session-logout'; + export interface Parameter { key: number; name: string; @@ -84,4 +88,8 @@ export const masaRestClient = { getNodeOperators, postNodeOperators, getIdentity, + getChallenge, + checkSignatureChallenge, + getSession, + sessionLogout, }; diff --git a/src/common/rest/session-logout/index.ts b/src/common/rest/session-logout/index.ts new file mode 100644 index 00000000..13a00eb9 --- /dev/null +++ b/src/common/rest/session-logout/index.ts @@ -0,0 +1,39 @@ +import { MethodMetadata, Parameter } from '..'; +import { useMasaMutation, useRestCall } from '../../helpers/rest-calls'; + +const path = 'session/logout'; + +export function useMethod({ body }: any) { + const { data, error, loading, getData } = useRestCall({ + headers: Headers, + metadata, + body, + }); + + return { data, error, loading, getData }; +} + +export function useSimpleMethod({ pathParameters, body, settings }: any) { + const masaQuery = useMasaMutation( + 'logout', + { + pathParameters, + headers: Headers, + body, + metadata, + }, + settings + ); + return masaQuery; +} + +const parameters: Parameter[] = []; + +export const metadata: MethodMetadata = { + author: 'Hide on bush', + authorPicture: '', + description: 'Logout and remove user sesison from backend', + name: path, + method: 'POST', + parameters: parameters, +};