Skip to content

Commit 64f5140

Browse files
authored
Merge pull request #273 from atls/feat/identity-integration-pages-router
feat(identity-integration): app and pages router
2 parents 3354983 + ec161d8 commit 64f5140

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1723
-1081
lines changed

.pnp.cjs

Lines changed: 264 additions & 447 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.yarnrc.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@ enableGlobalCache: true
55
globalFolder: ../.yarn/berry
66

77
yarnPath: .yarn/releases/yarn.cjs
8+
9+
preferReuse: true
10+
11+
defaultSemverRangePrefix: ''
12+
13+
pnpEnableEsmLoader: true

packages/identity-integration/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Identity Integration
22

3+
## BREAKING CHANGE 1.0.0
4+
5+
- Flow экспортируются:
6+
- `@atls/next-identity-integration/app-router` - для `app` роутера
7+
- `@atls/next-identity-integration/page-router` - для `pages` роутера
8+
39
## BREAKING CHANGE 0.2.0
410

511
- Переход на `App Router` для `Next.JS@14`

packages/identity-integration/package.json

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
{
22
"name": "@atls/next-identity-integration",
3-
"version": "0.2.4",
3+
"version": "1.0.0",
44
"license": "BSD-3-Clause",
5+
"type": "module",
6+
"exports": {
7+
".": "./src/index.ts",
8+
"./package.json": "./package.json",
9+
"./app-router": "./src/app-router.ts",
10+
"./page-router": "./src/page-router.ts"
11+
},
512
"main": "src/index.ts",
613
"files": [
714
"dist"
@@ -12,26 +19,44 @@
1219
"postpack": "rm -rf dist"
1320
},
1421
"dependencies": {
15-
"@ory/client": "1.2.11",
16-
"@ory/integrations": "1.1.5",
17-
"@ory/kratos-client": "1.0.0",
18-
"@types/tldjs": "2.3.4",
22+
"@ory/client": "1.14.5",
23+
"@ory/integrations": "1.2.1",
24+
"@ory/kratos-client": "1.2.1",
1925
"tldjs": "2.3.1"
2026
},
2127
"devDependencies": {
2228
"@types/react": "18.2.40",
2329
"@types/react-dom": "18.2.10",
24-
"axios": "1.5.1",
25-
"next": "14.1.0",
26-
"react": "18.2.0",
27-
"react-dom": "18.2.0"
30+
"@types/tldjs": "2.3.4",
31+
"axios": "1.7.7",
32+
"next": "14.2.9",
33+
"react": "18.3.1",
34+
"react-dom": "18.3.1"
2835
},
2936
"peerDependencies": {
3037
"next": "^14.1.0",
3138
"react": "^18.2.0"
3239
},
3340
"publishConfig": {
3441
"access": "public",
42+
"exports": {
43+
"./package.json": "./package.json",
44+
".": {
45+
"import": "./dist/index.js",
46+
"types": "./dist/index.d.ts",
47+
"default": "./dist/index.js"
48+
},
49+
"./app-router": {
50+
"import": "./dist/app-router.js",
51+
"types": "./dist/app-router.d.ts",
52+
"default": "./dist/app-router.js"
53+
},
54+
"./page-router": {
55+
"import": "./dist/page-router.js",
56+
"types": "./dist/page-router.d.ts",
57+
"default": "./dist/page-router.js"
58+
}
59+
},
3560
"main": "dist/index.js",
3661
"typings": "dist/index.d.ts"
3762
},
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './flows-app-router/index.js'

packages/identity-integration/src/flows/error.flow.tsx renamed to packages/identity-integration/src/flows-app-router/error.flow.tsx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
import { FlowError } from '@ory/kratos-client'
2-
import { AxiosError } from 'axios'
3-
import { PropsWithChildren } from 'react'
4-
import { FC } from 'react'
5-
import { useRouter } from 'next/navigation'
6-
import { useSearchParams } from 'next/navigation'
7-
import { useState } from 'react'
8-
import { useEffect } from 'react'
9-
import React from 'react'
10-
11-
import { ErrorProvider } from '../providers'
12-
import { useKratosClient } from '../providers'
1+
import type { FlowError } from '@ory/kratos-client'
2+
import type { AxiosError } from 'axios'
3+
import type { PropsWithChildren } from 'react'
4+
import type { FC } from 'react'
5+
6+
import { useRouter } from 'next/navigation.js'
7+
import { useSearchParams } from 'next/navigation.js'
8+
import { useState } from 'react'
9+
import { useEffect } from 'react'
10+
import React from 'react'
11+
12+
import { ErrorProvider } from '../providers/index.js'
13+
import { useKratosClient } from '../providers/index.js'
1314

1415
export interface ErrorErrorProps {
1516
returnToUrl?: string

packages/identity-integration/src/flows/handle-errors.util.ts renamed to packages/identity-integration/src/flows-app-router/handle-errors.util.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
/* eslint-disable prefer-template */
33
/* eslint-disable default-case */
44

5-
import { AxiosError } from 'axios'
6-
import { AppRouterInstance } from 'next/dist/shared/lib/app-router-context.shared-runtime'
7-
import { Dispatch } from 'react'
8-
import { SetStateAction } from 'react'
5+
import type { AxiosError } from 'axios'
6+
import type { AppRouterInstance } from 'next/dist/shared/lib/app-router-context.shared-runtime.js'
7+
import type { Dispatch } from 'react'
8+
import type { SetStateAction } from 'react'
99

1010
export const handleFlowError = <S>(
1111
router: AppRouterInstance,
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export * from './verification.flow.js'
2+
export * from './registration.flow.js'
3+
export * from './recovery.flow.js'
4+
export * from './settings.flow.js'
5+
export * from './login.flow.js'
6+
export * from './error.flow.js'
7+
export * from './logout.flow.js'

packages/identity-integration/src/flows/login.flow.tsx renamed to packages/identity-integration/src/flows-app-router/login.flow.tsx

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
import { UpdateLoginFlowBody } from '@ory/kratos-client'
2-
import { LoginFlow as KratosLoginFlow } from '@ory/kratos-client'
3-
import { AxiosError } from 'axios'
4-
import { PropsWithChildren } from 'react'
5-
import { FC } from 'react'
6-
import { useSearchParams } from 'next/navigation'
7-
import { useRouter } from 'next/navigation'
8-
import { useState } from 'react'
9-
import { useEffect } from 'react'
10-
import { useMemo } from 'react'
11-
import { useCallback } from 'react'
12-
import React from 'react'
13-
14-
import { FlowProvider } from '../providers'
15-
import { ValuesProvider } from '../providers'
16-
import { ValuesStore } from '../providers'
17-
import { SubmitProvider } from '../providers'
18-
import { useKratosClient } from '../providers'
19-
import { handleFlowError } from './handle-errors.util'
1+
import type { UpdateLoginFlowBody } from '@ory/kratos-client'
2+
import type { LoginFlow as KratosLoginFlow } from '@ory/kratos-client'
3+
import type { AxiosError } from 'axios'
4+
import type { PropsWithChildren } from 'react'
5+
import type { FC } from 'react'
6+
7+
import { useSearchParams } from 'next/navigation.js'
8+
import { useRouter } from 'next/navigation.js'
9+
import { useState } from 'react'
10+
import { useEffect } from 'react'
11+
import { useMemo } from 'react'
12+
import { useCallback } from 'react'
13+
import React from 'react'
14+
15+
import { FlowProvider } from '../providers/index.js'
16+
import { ValuesProvider } from '../providers/index.js'
17+
import { ValuesStore } from '../providers/index.js'
18+
import { SubmitProvider } from '../providers/index.js'
19+
import { useKratosClient } from '../providers/index.js'
20+
import { handleFlowError } from './handle-errors.util.js'
2021

2122
export interface LoginFlowProps {
2223
onError?: (error: { id: string }) => void
@@ -92,6 +93,7 @@ export const LoginFlow: FC<PropsWithChildren<LoginFlowProps>> = ({
9293

9394
kratosClient
9495
.updateLoginFlow(
96+
// @ts-ignore
9597
{ flow: String(flow?.id), updateLoginFlowBody: body },
9698
{ withCredentials: true }
9799
)
@@ -122,6 +124,7 @@ export const LoginFlow: FC<PropsWithChildren<LoginFlowProps>> = ({
122124
return (
123125
<FlowProvider value={{ flow, loading }}>
124126
<ValuesProvider value={values}>
127+
{/* @ts-ignore */}
125128
<SubmitProvider value={{ submitting, onSubmit }}>{children}</SubmitProvider>
126129
</ValuesProvider>
127130
</FlowProvider>

packages/identity-integration/src/flows/logout.flow.tsx renamed to packages/identity-integration/src/flows-app-router/logout.flow.tsx

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
import { LogoutFlow as KratosLogoutFlow } from '@ory/kratos-client'
2-
import { AxiosError } from 'axios'
3-
import { PropsWithChildren } from 'react'
4-
import { FC } from 'react'
5-
import { useSearchParams } from 'next/navigation'
6-
import { useRouter } from 'next/navigation'
7-
import { useState } from 'react'
8-
import { useEffect } from 'react'
9-
import React from 'react'
10-
11-
import { useKratosClient } from '../providers'
1+
import type { LogoutFlow as KratosLogoutFlow } from '@ory/kratos-client'
2+
import type { AxiosError } from 'axios'
3+
import type { PropsWithChildren } from 'react'
4+
import type { FC } from 'react'
5+
6+
import { useSearchParams } from 'next/navigation.js'
7+
import { useRouter } from 'next/navigation.js'
8+
import { useState } from 'react'
9+
import { useEffect } from 'react'
10+
import React from 'react'
11+
12+
import { useKratosClient } from '../providers/index.js'
1213

1314
interface LogoutFlowProps {
1415
returnToUrl?: string

0 commit comments

Comments
 (0)