Skip to content

Commit

Permalink
Merge pull request #256 from atls/feat/kratos-admin-sdk
Browse files Browse the repository at this point in the history
feat/kratos-admin-sdk
  • Loading branch information
TorinAsakura authored Jan 8, 2024
2 parents c66165c + 9059c48 commit b5ac768
Show file tree
Hide file tree
Showing 188 changed files with 5,043 additions and 1,087 deletions.
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

0 comments on commit b5ac768

Please sign in to comment.