diff --git a/.changeset/plenty-readers-guess.md b/.changeset/plenty-readers-guess.md
new file mode 100644
index 0000000000..55c959b250
--- /dev/null
+++ b/.changeset/plenty-readers-guess.md
@@ -0,0 +1,6 @@
+---
+'demo-parse-server-auth-server': minor
+'@moralisweb3/auth': minor
+---
+
+Update endpoints for evm Authentication in Moralis.Auth to reflect api changes
diff --git a/demos/demo-parse-server-auth/public/index.html b/demos/demo-parse-server-auth/public/index.html
index baf0027000..ba03b98d72 100644
--- a/demos/demo-parse-server-auth/public/index.html
+++ b/demos/demo-parse-server-auth/public/index.html
@@ -14,6 +14,7 @@
Demo Auth parse-server
+
diff --git a/demos/demo-parse-server-auth/public/script.js b/demos/demo-parse-server-auth/public/script.js
index 894189e5b8..c22559aa98 100644
--- a/demos/demo-parse-server-auth/public/script.js
+++ b/demos/demo-parse-server-auth/public/script.js
@@ -1,5 +1,9 @@
const AUTH_API_URL = 'http://localhost:1337/api/auth';
+const elError = document.getElementById('error');
+const elUser = document.getElementById('user');
+const elBtnMetamask = document.getElementById('auth-metamask');
+
const handleApiPost = async (endpoint, params) => {
const result = await axios.post(`${AUTH_API_URL}/${endpoint}`, params, {
headers: {
@@ -57,12 +61,16 @@ const handleAuth = async () => {
};
const renderUser = (user) => {
- document.getElementById('user').innerHTML = user ? JSON.stringify(user, null, 2) : '';
+ elUser.innerHTML = user ? JSON.stringify(user, null, 2) : '';
+};
+
+const renderError = (error) => {
+ elError.innerHTML = error ? JSON.stringify(error.message, null, 2) : '';
};
function init() {
- document.getElementById('auth-metamask').addEventListener('click', async () => {
- handleAuth();
+ elBtnMetamask.addEventListener('click', async () => {
+ handleAuth().catch((error) => renderError(error));
});
}
diff --git a/demos/demo-parse-server-auth/public/styles.css b/demos/demo-parse-server-auth/public/styles.css
index 435d6a035f..e98fe46adf 100644
--- a/demos/demo-parse-server-auth/public/styles.css
+++ b/demos/demo-parse-server-auth/public/styles.css
@@ -29,3 +29,10 @@ h1 {
font-size: 1rem;
color: rgb(4, 24, 54);
}
+
+#error {
+ margin-bottom: 1rem;
+ line-height: 1.2;
+ font-size: 1rem;
+ color: rgb(200, 31, 31);
+}
diff --git a/packages/auth/src/generated/types.ts b/packages/auth/src/generated/types.ts
index 8bfa307e31..6ab5da532b 100644
--- a/packages/auth/src/generated/types.ts
+++ b/packages/auth/src/generated/types.ts
@@ -4,11 +4,11 @@
*/
export interface paths {
- "/challenge": {
- post: operations["initializeChallenge"];
+ "/challenge/request/evm": {
+ post: operations["Request Challenge (EVM)"];
};
- "/challenge/complete": {
- post: operations["completeChallenge"];
+ "/challenge/verify/evm": {
+ post: operations["Verify Challenge (EVM)"];
};
"/health": {
get: operations["HealthController_check"];
@@ -175,7 +175,7 @@ export interface components {
}
export interface operations {
- initializeChallenge: {
+ "Request Challenge (EVM)": {
parameters: {};
responses: {
/** The back channel challenge containing the id to store on the api and the message to be signed by the user */
@@ -191,7 +191,7 @@ export interface operations {
};
};
};
- completeChallenge: {
+ "Verify Challenge (EVM)": {
parameters: {};
responses: {
/** The token to be used to call the third party API from the client */
diff --git a/packages/auth/src/methods/requestMessage.ts b/packages/auth/src/methods/requestMessage.ts
index 10f5a1b8c5..71c319d45d 100644
--- a/packages/auth/src/methods/requestMessage.ts
+++ b/packages/auth/src/methods/requestMessage.ts
@@ -1,6 +1,6 @@
import { AuthErrorCode, MoralisAuthError } from '@moralisweb3/core';
import { EvmAddress, EvmAddressish, EvmChain, EvmChainish } from '@moralisweb3/evm-utils';
-import { initializeChallengeResolver } from '../resolvers/initializeChallenge';
+import { initializeChallengeResolver } from '../resolvers/evmRequestChallenge';
export enum AuthNetwork {
EVM = 'evm',
diff --git a/packages/auth/src/methods/verify.ts b/packages/auth/src/methods/verify.ts
index 8f80ddafad..92eef20656 100644
--- a/packages/auth/src/methods/verify.ts
+++ b/packages/auth/src/methods/verify.ts
@@ -1,5 +1,5 @@
import { assertUnreachable } from '@moralisweb3/core';
-import { completeChallengeResolver } from '../resolvers/completeChallenge';
+import { completeChallengeResolver } from '../resolvers/evmVerifyChallenge';
export interface VerifyEvmOptions {
message: string;
diff --git a/packages/auth/src/resolvers/initializeChallenge.ts b/packages/auth/src/resolvers/evmRequestChallenge.ts
similarity index 87%
rename from packages/auth/src/resolvers/initializeChallenge.ts
rename to packages/auth/src/resolvers/evmRequestChallenge.ts
index 51f6bca992..2c3719e626 100644
--- a/packages/auth/src/resolvers/initializeChallenge.ts
+++ b/packages/auth/src/resolvers/evmRequestChallenge.ts
@@ -3,7 +3,7 @@ import { toCamelCase } from '@moralisweb3/core';
import { operations } from '../generated/types';
import { BASE_URL } from '../MoralisAuth';
-type name = 'initializeChallenge';
+type name = 'Request Challenge (EVM)';
type BodyParams = operations[name]['requestBody']['content']['application/json'];
type ApiParams = BodyParams;
const method = 'post';
@@ -31,8 +31,8 @@ const apiToResult = (apiData: ApiResult, params: Params) => {
};
export const initializeChallengeResolver = new ApiResolver({
- name: 'initializeChallenge',
- getUrl: (params: Params) => `${BASE_URL}/challenge/`,
+ name: 'Request Challenge (EVM)',
+ getUrl: (params: Params) => `${BASE_URL}/challenge/request/evm`,
apiToResult: apiToResult,
resultToJson: (data) => ({
...data,
diff --git a/packages/auth/src/resolvers/completeChallenge.ts b/packages/auth/src/resolvers/evmVerifyChallenge.ts
similarity index 89%
rename from packages/auth/src/resolvers/completeChallenge.ts
rename to packages/auth/src/resolvers/evmVerifyChallenge.ts
index 171ee40c56..30ad17bdd8 100644
--- a/packages/auth/src/resolvers/completeChallenge.ts
+++ b/packages/auth/src/resolvers/evmVerifyChallenge.ts
@@ -4,7 +4,7 @@ import { ApiResolver } from '@moralisweb3/api-utils';
import { operations } from '../generated/types';
import { BASE_URL } from '../MoralisAuth';
-type name = 'completeChallenge';
+type name = 'Verify Challenge (EVM)';
type BodyParams = operations[name]['requestBody']['content']['application/json'];
type ApiParams = BodyParams;
type Params = ApiParams;
@@ -14,8 +14,8 @@ const bodyParams = ['message', 'signature'] as const;
type ApiResult = operations[name]['responses']['201']['content']['application/json'];
export const completeChallengeResolver = new ApiResolver({
- name: 'completeChallenge',
- getUrl: (params: Params) => `${BASE_URL}/challenge/complete`,
+ name: 'Verify Challenge (EVM)',
+ getUrl: (params: Params) => `${BASE_URL}/challenge/verify/evm`,
apiToResult: ({ chainId, ...data }: ApiResult) => ({
...data,
// TODO: revisit EVM logic once we know how authentication in other networks work