Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/kratos-admin-sdk #256

Merged
merged 5 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require('@rushstack/eslint-patch/modern-module-resolution')

module.exports = {
extends: [
'./.yarn/unplugged/@atls-config-eslint-npm-0.0.10-fcb02bb484/node_modules/@atls/config-eslint/dist/.eslintrc.js',
],
parserOptions: {
project: './tsconfig.json',
},
ignorePatterns: ['.eslintrc.js'],
}
2,316 changes: 2,256 additions & 60 deletions .pnp.cjs

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added .yarn/cache/fsevents-patch-19706e7e35-9.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1,756 changes: 786 additions & 970 deletions .yarn/releases/yarn-remote.cjs

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
},
"devDependencies": {
"@atls/code-service": "0.0.23",
"@atls/config-eslint": "0.0.10",
"@atls/config-jest": "0.0.6",
"@atls/schematics": "0.0.18",
"@jest/core": "28.1.2",
"@rushstack/eslint-patch": "1.6.1",
"@types/eslint": "8.4.5",
"@types/jest": "28.1.4",
"@types/node": "18.0.3",
Expand All @@ -24,7 +26,12 @@
"husky": "8.0.1",
"typescript": "4.6.2"
},
"packageManager": "[email protected]",
"dependenciesMeta": {
"@atls/[email protected]": {
"unplugged": true
}
},
"packageManager": "[email protected]",
"tools": {
"schematic": {
"collection": "@atls/schematics",
Expand Down
3 changes: 1 addition & 2 deletions packages/identity-integration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
## BREAKING CHANGE 0.0.16

- Необходим глобальный провайдер `KratosClientProvider`. По умолчанию он предоставляет
стандартный клиент `kratos`, однако его можно будет изменять/расширять по потребности в
проекте, а также URL редиректа для некоторых ошибок.
стандартный клиент `kratos`, однако его можно изменять/расширять в случае необходимости как и URL редиректа для некоторых ошибок.
- Добавлена кастомизация URL для редиректа в случае ошибок, например пользователь уже авторизован.
- Расширен конструктов класса `KratosClient`

Expand Down
1 change: 1 addition & 0 deletions packages/identity-integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@ory/client": "1.2.11",
"@ory/integrations": "1.1.5",
"@ory/kratos-client": "1.0.0",
"@types/tldjs": "2.3.4",
"tldjs": "2.3.1"
},
"devDependencies": {
Expand Down
2 changes: 2 additions & 0 deletions packages/identity-integration/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ export * from './flows'
export * from './ui'
export * from './messages'
export * from './sdk'
export { Session } from '@ory/kratos-client'
export { Configuration } from '@ory/kratos-client'
28 changes: 2 additions & 26 deletions packages/identity-integration/src/sdk/index.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,2 @@
import { Configuration } from '@ory/kratos-client'
import { FrontendApi } from '@ory/kratos-client'

import { getDomain } from 'tldjs'

export class KratosClient extends FrontendApi {
constructor({ basePath, ...props }: Partial<Configuration>) {
if (!basePath && typeof window !== 'undefined') {
const { hostname, protocol } = window.location

if (hostname === 'localhost') {
basePath = 'http://localhost:4433' // eslint-disable-line no-param-reassign
} else if (hostname === '127.0.0.1') {
basePath = 'http://127.0.0.1:4433' // eslint-disable-line no-param-reassign
} else if (hostname.startsWith('accounts.')) {
basePath = origin.replace('accounts.', 'identity.') // eslint-disable-line no-param-reassign
} else {
basePath = `${protocol}//identity.${getDomain(hostname)}` // eslint-disable-line no-param-reassign
}
}

super(new Configuration({ basePath, ...props }))
}
}

export const kratos = new KratosClient({})
export * from './kratos-admin.client'
export * from './kratos.client'
26 changes: 26 additions & 0 deletions packages/identity-integration/src/sdk/kratos-admin.client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Configuration } from '@ory/kratos-client'
import { IdentityApi } from '@ory/kratos-client'

import { getDomain } from 'tldjs'

export class KratosAdminClient extends IdentityApi {
constructor({ basePath, ...props }: Partial<Configuration>) {
if (!basePath && typeof window !== 'undefined') {
const { hostname, protocol } = window.location

if (hostname === 'localhost') {
basePath = 'http://localhost:4434' // eslint-disable-line no-param-reassign
} else if (hostname === '127.0.0.1') {
basePath = 'http://127.0.0.1:4434' // eslint-disable-line no-param-reassign
} else if (hostname.startsWith('accounts.')) {
basePath = origin.replace('accounts.', 'identity-admin.') // eslint-disable-line no-param-reassign
} else {
basePath = `${protocol}//identity-admin.${getDomain(hostname)}` // eslint-disable-line no-param-reassign
}
}

super(new Configuration({ basePath, ...props }))
}
}

export const kratosAdmin = new KratosAdminClient({})
26 changes: 26 additions & 0 deletions packages/identity-integration/src/sdk/kratos.client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Configuration } from '@ory/kratos-client'
import { FrontendApi } from '@ory/kratos-client'

import { getDomain } from 'tldjs'

export class KratosClient extends FrontendApi {
constructor({ basePath, ...props }: Partial<Configuration>) {
if (!basePath && typeof window !== 'undefined') {
const { hostname, protocol } = window.location

if (hostname === 'localhost') {
basePath = 'http://localhost:4433' // eslint-disable-line no-param-reassign
} else if (hostname === '127.0.0.1') {
basePath = 'http://127.0.0.1:4433' // eslint-disable-line no-param-reassign
} else if (hostname.startsWith('accounts.')) {
basePath = origin.replace('accounts.', 'identity.') // eslint-disable-line no-param-reassign
} else {
basePath = `${protocol}//identity.${getDomain(hostname)}` // eslint-disable-line no-param-reassign
}
}

super(new Configuration({ basePath, ...props }))
}
}

export const kratos = new KratosClient({})
Loading
Loading