-
-
Notifications
You must be signed in to change notification settings - Fork 499
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(core,schemas): refactor the experience API
refactor the exerpience API structure
- Loading branch information
Showing
16 changed files
with
118 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const experienceApiRoutesPrefix = '/experience'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 2 additions & 7 deletions
9
.../routes/experience/verifications/utils.ts → packages/core/src/routes/experience/utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const experienceApiPrefix = 'experience'; | ||
export const experienceVerificationApiRoutesPrefix = `${experienceApiPrefix}/verification`; |
17 changes: 17 additions & 0 deletions
17
packages/integration-tests/src/api/experience-api/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { type PasswordSignInPayload } from '@logto/schemas'; | ||
|
||
import api from '../api.js'; | ||
|
||
import { experienceApiPrefix } from './const.js'; | ||
|
||
type RedirectResponse = { | ||
redirectTo: string; | ||
}; | ||
|
||
export const signInWithPassword = async (cookie: string, payload: PasswordSignInPayload) => | ||
api | ||
.post(`${experienceApiPrefix}/sign-in/password`, { headers: { cookie }, json: payload }) | ||
.json(); | ||
|
||
export const submit = async (cookie: string) => | ||
api.post(`${experienceApiPrefix}/submit`, { headers: { cookie } }).json<RedirectResponse>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
packages/integration-tests/src/helpers/experience/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* @fileoverview This file contains the successful interaction flow helper functions that use the experience APIs. | ||
*/ | ||
|
||
import { type InteractionIdentifier } from '@logto/schemas'; | ||
|
||
import { signInWithPassword as signInWithPasswordApi } from '#src/api/experience-api/index.js'; | ||
|
||
import { initClient, logoutClient, processSession } from '../client.js'; | ||
|
||
export const signInWithPassword = async ({ | ||
identifier, | ||
password, | ||
}: { | ||
identifier: InteractionIdentifier; | ||
password: string; | ||
}) => { | ||
const client = await initClient(); | ||
|
||
await client.successSend(signInWithPasswordApi, { | ||
identifier, | ||
password, | ||
}); | ||
|
||
const { redirectTo } = await client.submitInteraction('v2'); | ||
|
||
await processSession(client, redirectTo); | ||
await logoutClient(client); | ||
}; |
32 changes: 0 additions & 32 deletions
32
packages/integration-tests/src/helpers/interactions-using-experience-api.ts
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...-tests/src/tests/api/experience-api/sign-in-with-password-verification/happy-path.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.