@atproto/oauth-provider 0.15.15 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/dist/account/account-store.d.ts +1 -1
- package/dist/account/account-store.d.ts.map +1 -1
- package/dist/account/account-store.js.map +1 -1
- package/dist/customization/branding.d.ts +18 -1
- package/dist/customization/branding.d.ts.map +1 -1
- package/dist/customization/build-customization-css.d.ts.map +1 -1
- package/dist/customization/build-customization-css.js +16 -2
- package/dist/customization/build-customization-css.js.map +1 -1
- package/dist/customization/build-customization-data.d.ts +2 -2
- package/dist/customization/build-customization-data.d.ts.map +1 -1
- package/dist/customization/build-customization-data.js.map +1 -1
- package/dist/customization/colors.d.ts +11 -2
- package/dist/customization/colors.d.ts.map +1 -1
- package/dist/customization/colors.js +19 -1
- package/dist/customization/colors.js.map +1 -1
- package/dist/customization/customization.d.ts +26 -1
- package/dist/customization/customization.d.ts.map +1 -1
- package/dist/lib/http/router.d.ts +2 -1
- package/dist/lib/http/router.d.ts.map +1 -1
- package/dist/lib/http/router.js +1 -1
- package/dist/lib/http/router.js.map +1 -1
- package/dist/lib/util/color.d.ts +3 -0
- package/dist/lib/util/color.d.ts.map +1 -1
- package/dist/lib/util/color.js +33 -1
- package/dist/lib/util/color.js.map +1 -1
- package/dist/oauth-provider.d.ts.map +1 -1
- package/dist/oauth-provider.js +6 -11
- package/dist/oauth-provider.js.map +1 -1
- package/dist/result/authorization-result-authorize-page.d.ts +2 -1
- package/dist/result/authorization-result-authorize-page.d.ts.map +1 -1
- package/dist/result/authorization-result-authorize-page.js.map +1 -1
- package/dist/router/assets/assets.d.ts +1 -2
- package/dist/router/assets/assets.d.ts.map +1 -1
- package/dist/router/assets/assets.js +20 -12
- package/dist/router/assets/assets.js.map +1 -1
- package/dist/router/assets/send-authorization-page.d.ts.map +1 -1
- package/dist/router/assets/send-authorization-page.js +1 -0
- package/dist/router/assets/send-authorization-page.js.map +1 -1
- package/dist/router/create-api-middleware.d.ts.map +1 -1
- package/dist/router/create-api-middleware.js +5 -6
- package/dist/router/create-api-middleware.js.map +1 -1
- package/package.json +8 -9
- package/src/account/account-store.ts +1 -1
- package/src/customization/build-customization-css.ts +25 -3
- package/src/customization/build-customization-data.ts +2 -2
- package/src/customization/colors.ts +20 -1
- package/src/lib/http/router.ts +7 -3
- package/src/lib/util/color.ts +37 -1
- package/src/oauth-provider.ts +7 -13
- package/src/result/authorization-result-authorize-page.ts +2 -1
- package/src/router/assets/assets.ts +22 -17
- package/src/router/assets/send-authorization-page.ts +1 -0
- package/src/router/create-api-middleware.ts +10 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @atproto/oauth-provider
|
|
2
2
|
|
|
3
|
+
## 0.16.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#4820](https://github.com/bluesky-social/atproto/pull/4820) [`b3ce11a`](https://github.com/bluesky-social/atproto/commit/b3ce11ae2e965f239db6aec6054f069d557f4d55) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Unify account management and authorization pages into a signle package
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#4820](https://github.com/bluesky-social/atproto/pull/4820) [`b3ce11a`](https://github.com/bluesky-social/atproto/commit/b3ce11ae2e965f239db6aec6054f069d557f4d55) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Account management interface improvements
|
|
12
|
+
|
|
13
|
+
- [#4855](https://github.com/bluesky-social/atproto/pull/4855) [`0cfb16b`](https://github.com/bluesky-social/atproto/commit/0cfb16b2bfead81284317f2f893838384070d219) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Disable COEP headers when hCaptcha is enabled
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [[`26d793a`](https://github.com/bluesky-social/atproto/commit/26d793af95a6fb3a50f9b2a97187d8ac4fecf676), [`26d793a`](https://github.com/bluesky-social/atproto/commit/26d793af95a6fb3a50f9b2a97187d8ac4fecf676), [`b3ce11a`](https://github.com/bluesky-social/atproto/commit/b3ce11ae2e965f239db6aec6054f069d557f4d55), [`26d793a`](https://github.com/bluesky-social/atproto/commit/26d793af95a6fb3a50f9b2a97187d8ac4fecf676), [`b3ce11a`](https://github.com/bluesky-social/atproto/commit/b3ce11ae2e965f239db6aec6054f069d557f4d55), [`55d06de`](https://github.com/bluesky-social/atproto/commit/55d06de80a1506908a04ed5c0834986cb5783797), [`26d793a`](https://github.com/bluesky-social/atproto/commit/26d793af95a6fb3a50f9b2a97187d8ac4fecf676)]:
|
|
16
|
+
- @atproto/syntax@0.5.4
|
|
17
|
+
- @atproto/oauth-provider-api@0.4.0
|
|
18
|
+
- @atproto/oauth-provider-ui@0.5.0
|
|
19
|
+
- @atproto/lex-resolver@0.0.22
|
|
20
|
+
- @atproto/lex-document@0.0.20
|
|
21
|
+
|
|
22
|
+
## 0.15.16
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- Updated dependencies []:
|
|
27
|
+
- @atproto/common@0.5.16
|
|
28
|
+
- @atproto/lex-document@0.0.19
|
|
29
|
+
- @atproto/lex-resolver@0.0.21
|
|
30
|
+
|
|
3
31
|
## 0.15.15
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Account, ConfirmResetPasswordInput, InitiatePasswordResetInput } from '@atproto/oauth-provider-api';
|
|
1
|
+
import type { Account, ConfirmResetPasswordInput, InitiatePasswordResetInput } from '@atproto/oauth-provider-api';
|
|
2
2
|
import { OAuthScope } from '@atproto/oauth-types';
|
|
3
3
|
import { ClientId } from '../client/client-id.js';
|
|
4
4
|
import { DeviceId } from '../device/device-id.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-store.d.ts","sourceRoot":"","sources":["../../src/account/account-store.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"account-store.d.ts","sourceRoot":"","sources":["../../src/account/account-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,yBAAyB,EACzB,0BAA0B,EAC3B,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,EAAE,SAAS,EAAyB,MAAM,qBAAqB,CAAA;AACtE,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,uCAAuC,EACxC,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAIhD,cAAc,wBAAwB,CAAA;AACtC,cAAc,0BAA0B,CAAA;AACxC,cAAc,wBAAwB,CAAA;AACtC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,0BAA0B,CAAA;AAExC,YAAY,EACV,OAAO,EACP,oBAAoB,EACpB,UAAU,EACV,UAAU,EACV,WAAW,GACZ,CAAA;AAED,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,uCAAuC,GACxC,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG,0BAA0B,CAAA;AAClE,MAAM,MAAM,yBAAyB,GAAG,yBAAyB,CAAA;AAEjE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAA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,OAyBA;AACtB,oGAzBA,qCAAmB,OAyBA;AACnB,wHAzBA,yDAAuC,OAyBA;AAnBzC,kEAAkE;AAElE,yDAAsC;AACtC,2DAAwC;AACxC,yDAAsC;AACtC,iDAA8B;AAC9B,2DAAwC;AAiK3B,QAAA,cAAc,GAAG,IAAA,+BAAqB,EAAe;IAChE,eAAe;IACf,qBAAqB;IACrB,qBAAqB;IACrB,YAAY;IACZ,qBAAqB;IACrB,kBAAkB;IAClB,qBAAqB;IACrB,oBAAoB;IACpB,sBAAsB;IACtB,sBAAsB;IACtB,0BAA0B;CAC3B,CAAC,CAAA;AAEF,SAAgB,cAAc,CAAI,cAAiB;IACjD,IAAI,CAAC,cAAc,IAAI,CAAC,IAAA,sBAAc,EAAC,cAAc,CAAC,EAAE,CAAC;QACvD,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;IACxD,CAAC;IACD,OAAO,cAAc,CAAA;AACvB,CAAC","sourcesContent":["import {\n Account,\n ConfirmResetPasswordInput,\n InitiatePasswordResetInput,\n} from '@atproto/oauth-provider-api'\nimport { OAuthScope } from '@atproto/oauth-types'\nimport { ClientId } from '../client/client-id.js'\nimport { DeviceId } from '../device/device-id.js'\nimport { DeviceData } from '../device/device-store.js'\nimport { HcaptchaVerifyResult } from '../lib/hcaptcha.js'\nimport { Awaitable, buildInterfaceChecker } from '../lib/util/type.js'\nimport {\n HandleUnavailableError,\n InvalidRequestError,\n SecondAuthenticationFactorRequiredError,\n} from '../oauth-errors.js'\nimport { Sub } from '../oidc/sub.js'\nimport { InviteCode } from '../types/invite-code.js'\nimport { SignUpInput } from './sign-up-input.js'\n\n// Export all types needed to implement the AccountStore interface\n\nexport * from '../client/client-id.js'\nexport * from '../device/device-data.js'\nexport * from '../device/device-id.js'\nexport * from '../oidc/sub.js'\nexport * from '../request/request-id.js'\n\nexport type {\n Account,\n HcaptchaVerifyResult,\n InviteCode,\n OAuthScope,\n SignUpInput,\n}\n\nexport {\n HandleUnavailableError,\n InvalidRequestError,\n SecondAuthenticationFactorRequiredError,\n}\n\nexport type ResetPasswordRequestInput = InitiatePasswordResetInput\nexport type ResetPasswordConfirmInput = ConfirmResetPasswordInput\n\nexport type CreateAccountData = {\n locale: string\n email: string\n password: string\n handle: string\n inviteCode?: string | undefined\n}\n\nexport type AuthenticateAccountData = {\n locale: string\n password: string\n username: string\n emailOtp?: string | undefined\n}\n\nexport type AuthorizedClientData = { authorizedScopes: readonly string[] }\nexport type AuthorizedClients = Map<ClientId, AuthorizedClientData>\n\nexport type DeviceAccount = {\n deviceId: DeviceId\n\n /**\n * The data associated with the device, created through the\n * {@link DeviceStore}. This data is used to identify devices on which a user\n * has logged in.\n */\n deviceData: DeviceData\n\n /**\n * The account associated with the device account.\n */\n account: Account\n\n /**\n * The list of clients that are authorized by the account, as created through\n * the {@link AccountStore.setAuthorizedClient} method.\n */\n authorizedClients: AuthorizedClients\n\n /**\n * The date at which the device account was created. This value is currently\n * not used.\n */\n createdAt: Date\n\n /**\n * The date at which the device account was last updated. This value is used\n * to determine the date at which the user last authenticated on a device\n */\n updatedAt: Date\n}\n\nexport type SignUpData = SignUpInput & {\n hcaptchaResult?: HcaptchaVerifyResult\n inviteCode?: InviteCode\n}\n\nexport interface AccountStore {\n /**\n * @throws {HandleUnavailableError} - To indicate that the handle is already taken\n * @throws {InvalidRequestError} - To indicate that some data is invalid\n */\n createAccount(data: CreateAccountData): Awaitable<Account>\n\n /**\n * @throws {InvalidRequestError} - When the credentials are not valid\n * @throws {SecondAuthenticationFactorRequiredError} - To indicate that an {@link SecondAuthenticationFactorRequiredError.type} is required in the credentials\n */\n authenticateAccount(data: AuthenticateAccountData): Awaitable<Account>\n\n /**\n * Add a client & scopes to the list of authorized clients for the given account.\n */\n setAuthorizedClient(\n sub: Sub,\n clientId: ClientId,\n data: AuthorizedClientData,\n ): Awaitable<void>\n\n /**\n * @throws {InvalidRequestError} - When the credentials are not valid\n */\n getAccount(sub: Sub): Awaitable<{\n account: Account\n authorizedClients: AuthorizedClients\n }>\n\n /**\n * @param data.requestId - If provided, the inserted account must be bound to\n * that particular requestId.\n *\n * @note Whenever a particular device account is created, all **unbound**\n * device accounts for the same `deviceId` & `sub` should be deleted.\n *\n * @note When a particular request is deleted (through\n * {@link RequestStore.deleteRequest}), all accounts bound to that request\n * should be deleted as well.\n */\n upsertDeviceAccount(deviceId: DeviceId, sub: Sub): Awaitable<void>\n\n /**\n * @param requestId - If provided, the result must either have the same\n * requestId, or not be bound to a particular requestId. If `null`, the\n * result must not be bound to a particular requestId.\n * @throws {InvalidRequestError} - Instead of returning `null` in order to\n * provide a custom error message\n */\n getDeviceAccount(\n deviceId: DeviceId,\n sub: Sub,\n ): Awaitable<DeviceAccount | null>\n\n /**\n * Removes *all* the unbound device-accounts associated with the given device\n * & account.\n *\n * @note Noop if the device-account is not found.\n */\n removeDeviceAccount(deviceId: DeviceId, sub: Sub): Awaitable<void>\n\n /**\n * @returns **all** the device accounts that match the {@link requestId}\n * criteria and given {@link filter}.\n */\n listDeviceAccounts(\n filter: { sub: Sub } | { deviceId: DeviceId },\n ): Awaitable<DeviceAccount[]>\n\n resetPasswordRequest(\n data: ResetPasswordRequestInput,\n ): Awaitable<null | Account>\n\n resetPasswordConfirm(\n data: ResetPasswordConfirmInput,\n ): Awaitable<null | Account>\n\n /**\n * @throws {HandleUnavailableError} - To indicate that the handle is already taken\n */\n verifyHandleAvailability(handle: string): Awaitable<void>\n}\n\nexport const isAccountStore = buildInterfaceChecker<AccountStore>([\n 'createAccount',\n 'authenticateAccount',\n 'setAuthorizedClient',\n 'getAccount',\n 'upsertDeviceAccount',\n 'getDeviceAccount',\n 'removeDeviceAccount',\n 'listDeviceAccounts',\n 'resetPasswordRequest',\n 'resetPasswordConfirm',\n 'verifyHandleAvailability',\n])\n\nexport function asAccountStore<V>(implementation: V): V & AccountStore {\n if (!implementation || !isAccountStore(implementation)) {\n throw new Error('Invalid AccountStore implementation')\n }\n return implementation\n}\n"]}
|
|
1
|
+
{"version":3,"file":"account-store.js","sourceRoot":"","sources":["../../src/account/account-store.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAyMA,wCAKC;AApMD,iDAAsE;AACtE,wDAI2B;AAsBzB,uGAzBA,wCAAsB,OAyBA;AACtB,oGAzBA,qCAAmB,OAyBA;AACnB,wHAzBA,yDAAuC,OAyBA;AAnBzC,kEAAkE;AAElE,yDAAsC;AACtC,2DAAwC;AACxC,yDAAsC;AACtC,iDAA8B;AAC9B,2DAAwC;AAiK3B,QAAA,cAAc,GAAG,IAAA,+BAAqB,EAAe;IAChE,eAAe;IACf,qBAAqB;IACrB,qBAAqB;IACrB,YAAY;IACZ,qBAAqB;IACrB,kBAAkB;IAClB,qBAAqB;IACrB,oBAAoB;IACpB,sBAAsB;IACtB,sBAAsB;IACtB,0BAA0B;CAC3B,CAAC,CAAA;AAEF,SAAgB,cAAc,CAAI,cAAiB;IACjD,IAAI,CAAC,cAAc,IAAI,CAAC,IAAA,sBAAc,EAAC,cAAc,CAAC,EAAE,CAAC;QACvD,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;IACxD,CAAC;IACD,OAAO,cAAc,CAAA;AACvB,CAAC","sourcesContent":["import type {\n Account,\n ConfirmResetPasswordInput,\n InitiatePasswordResetInput,\n} from '@atproto/oauth-provider-api'\nimport { OAuthScope } from '@atproto/oauth-types'\nimport { ClientId } from '../client/client-id.js'\nimport { DeviceId } from '../device/device-id.js'\nimport { DeviceData } from '../device/device-store.js'\nimport { HcaptchaVerifyResult } from '../lib/hcaptcha.js'\nimport { Awaitable, buildInterfaceChecker } from '../lib/util/type.js'\nimport {\n HandleUnavailableError,\n InvalidRequestError,\n SecondAuthenticationFactorRequiredError,\n} from '../oauth-errors.js'\nimport { Sub } from '../oidc/sub.js'\nimport { InviteCode } from '../types/invite-code.js'\nimport { SignUpInput } from './sign-up-input.js'\n\n// Export all types needed to implement the AccountStore interface\n\nexport * from '../client/client-id.js'\nexport * from '../device/device-data.js'\nexport * from '../device/device-id.js'\nexport * from '../oidc/sub.js'\nexport * from '../request/request-id.js'\n\nexport type {\n Account,\n HcaptchaVerifyResult,\n InviteCode,\n OAuthScope,\n SignUpInput,\n}\n\nexport {\n HandleUnavailableError,\n InvalidRequestError,\n SecondAuthenticationFactorRequiredError,\n}\n\nexport type ResetPasswordRequestInput = InitiatePasswordResetInput\nexport type ResetPasswordConfirmInput = ConfirmResetPasswordInput\n\nexport type CreateAccountData = {\n locale: string\n email: string\n password: string\n handle: string\n inviteCode?: string | undefined\n}\n\nexport type AuthenticateAccountData = {\n locale: string\n password: string\n username: string\n emailOtp?: string | undefined\n}\n\nexport type AuthorizedClientData = { authorizedScopes: readonly string[] }\nexport type AuthorizedClients = Map<ClientId, AuthorizedClientData>\n\nexport type DeviceAccount = {\n deviceId: DeviceId\n\n /**\n * The data associated with the device, created through the\n * {@link DeviceStore}. This data is used to identify devices on which a user\n * has logged in.\n */\n deviceData: DeviceData\n\n /**\n * The account associated with the device account.\n */\n account: Account\n\n /**\n * The list of clients that are authorized by the account, as created through\n * the {@link AccountStore.setAuthorizedClient} method.\n */\n authorizedClients: AuthorizedClients\n\n /**\n * The date at which the device account was created. This value is currently\n * not used.\n */\n createdAt: Date\n\n /**\n * The date at which the device account was last updated. This value is used\n * to determine the date at which the user last authenticated on a device\n */\n updatedAt: Date\n}\n\nexport type SignUpData = SignUpInput & {\n hcaptchaResult?: HcaptchaVerifyResult\n inviteCode?: InviteCode\n}\n\nexport interface AccountStore {\n /**\n * @throws {HandleUnavailableError} - To indicate that the handle is already taken\n * @throws {InvalidRequestError} - To indicate that some data is invalid\n */\n createAccount(data: CreateAccountData): Awaitable<Account>\n\n /**\n * @throws {InvalidRequestError} - When the credentials are not valid\n * @throws {SecondAuthenticationFactorRequiredError} - To indicate that an {@link SecondAuthenticationFactorRequiredError.type} is required in the credentials\n */\n authenticateAccount(data: AuthenticateAccountData): Awaitable<Account>\n\n /**\n * Add a client & scopes to the list of authorized clients for the given account.\n */\n setAuthorizedClient(\n sub: Sub,\n clientId: ClientId,\n data: AuthorizedClientData,\n ): Awaitable<void>\n\n /**\n * @throws {InvalidRequestError} - When the credentials are not valid\n */\n getAccount(sub: Sub): Awaitable<{\n account: Account\n authorizedClients: AuthorizedClients\n }>\n\n /**\n * @param data.requestId - If provided, the inserted account must be bound to\n * that particular requestId.\n *\n * @note Whenever a particular device account is created, all **unbound**\n * device accounts for the same `deviceId` & `sub` should be deleted.\n *\n * @note When a particular request is deleted (through\n * {@link RequestStore.deleteRequest}), all accounts bound to that request\n * should be deleted as well.\n */\n upsertDeviceAccount(deviceId: DeviceId, sub: Sub): Awaitable<void>\n\n /**\n * @param requestId - If provided, the result must either have the same\n * requestId, or not be bound to a particular requestId. If `null`, the\n * result must not be bound to a particular requestId.\n * @throws {InvalidRequestError} - Instead of returning `null` in order to\n * provide a custom error message\n */\n getDeviceAccount(\n deviceId: DeviceId,\n sub: Sub,\n ): Awaitable<DeviceAccount | null>\n\n /**\n * Removes *all* the unbound device-accounts associated with the given device\n * & account.\n *\n * @note Noop if the device-account is not found.\n */\n removeDeviceAccount(deviceId: DeviceId, sub: Sub): Awaitable<void>\n\n /**\n * @returns **all** the device accounts that match the {@link requestId}\n * criteria and given {@link filter}.\n */\n listDeviceAccounts(\n filter: { sub: Sub } | { deviceId: DeviceId },\n ): Awaitable<DeviceAccount[]>\n\n resetPasswordRequest(\n data: ResetPasswordRequestInput,\n ): Awaitable<null | Account>\n\n resetPasswordConfirm(\n data: ResetPasswordConfirmInput,\n ): Awaitable<null | Account>\n\n /**\n * @throws {HandleUnavailableError} - To indicate that the handle is already taken\n */\n verifyHandleAvailability(handle: string): Awaitable<void>\n}\n\nexport const isAccountStore = buildInterfaceChecker<AccountStore>([\n 'createAccount',\n 'authenticateAccount',\n 'setAuthorizedClient',\n 'getAccount',\n 'upsertDeviceAccount',\n 'getDeviceAccount',\n 'removeDeviceAccount',\n 'listDeviceAccounts',\n 'resetPasswordRequest',\n 'resetPasswordConfirm',\n 'verifyHandleAvailability',\n])\n\nexport function asAccountStore<V>(implementation: V): V & AccountStore {\n if (!implementation || !isAccountStore(implementation)) {\n throw new Error('Invalid AccountStore implementation')\n }\n return implementation\n}\n"]}
|
|
@@ -5,36 +5,45 @@ export declare const brandingSchema: z.ZodObject<{
|
|
|
5
5
|
colors: z.ZodOptional<z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<z.objectUtil.extendShape<{
|
|
6
6
|
light: z.ZodOptional<z.ZodEffects<z.ZodString, import("../lib/util/color.js").RgbColor, string>>;
|
|
7
7
|
dark: z.ZodOptional<z.ZodEffects<z.ZodString, import("../lib/util/color.js").RgbColor, string>>;
|
|
8
|
-
|
|
8
|
+
contrastSaturation: z.ZodOptional<z.ZodNumber>;
|
|
9
|
+
}, Record<"error" | "success" | "warning" | "primary" | "info", z.ZodOptional<z.ZodEffects<z.ZodString, import("../lib/util/color.js").RgbColor, string>>>>, Record<"errorContrast" | "successContrast" | "warningContrast" | "primaryContrast" | "infoContrast", z.ZodOptional<z.ZodEffects<z.ZodString, import("../lib/util/color.js").RgbColor, string>>>>, Record<"errorHue" | "successHue" | "warningHue" | "primaryHue" | "infoHue", z.ZodOptional<z.ZodNumber>>>, "strip", z.ZodTypeAny, {
|
|
9
10
|
error?: import("../lib/util/color.js").RgbColor | undefined;
|
|
10
11
|
success?: import("../lib/util/color.js").RgbColor | undefined;
|
|
11
12
|
warning?: import("../lib/util/color.js").RgbColor | undefined;
|
|
12
13
|
light?: import("../lib/util/color.js").RgbColor | undefined;
|
|
13
14
|
dark?: import("../lib/util/color.js").RgbColor | undefined;
|
|
15
|
+
contrastSaturation?: number | undefined;
|
|
14
16
|
primary?: import("../lib/util/color.js").RgbColor | undefined;
|
|
17
|
+
info?: import("../lib/util/color.js").RgbColor | undefined;
|
|
15
18
|
errorContrast?: import("../lib/util/color.js").RgbColor | undefined;
|
|
16
19
|
successContrast?: import("../lib/util/color.js").RgbColor | undefined;
|
|
17
20
|
warningContrast?: import("../lib/util/color.js").RgbColor | undefined;
|
|
18
21
|
primaryContrast?: import("../lib/util/color.js").RgbColor | undefined;
|
|
22
|
+
infoContrast?: import("../lib/util/color.js").RgbColor | undefined;
|
|
19
23
|
errorHue?: number | undefined;
|
|
20
24
|
successHue?: number | undefined;
|
|
21
25
|
warningHue?: number | undefined;
|
|
22
26
|
primaryHue?: number | undefined;
|
|
27
|
+
infoHue?: number | undefined;
|
|
23
28
|
}, {
|
|
24
29
|
error?: string | undefined;
|
|
25
30
|
success?: string | undefined;
|
|
26
31
|
warning?: string | undefined;
|
|
27
32
|
light?: string | undefined;
|
|
28
33
|
dark?: string | undefined;
|
|
34
|
+
contrastSaturation?: number | undefined;
|
|
29
35
|
primary?: string | undefined;
|
|
36
|
+
info?: string | undefined;
|
|
30
37
|
errorContrast?: string | undefined;
|
|
31
38
|
successContrast?: string | undefined;
|
|
32
39
|
warningContrast?: string | undefined;
|
|
33
40
|
primaryContrast?: string | undefined;
|
|
41
|
+
infoContrast?: string | undefined;
|
|
34
42
|
errorHue?: number | undefined;
|
|
35
43
|
successHue?: number | undefined;
|
|
36
44
|
warningHue?: number | undefined;
|
|
37
45
|
primaryHue?: number | undefined;
|
|
46
|
+
infoHue?: number | undefined;
|
|
38
47
|
}>>;
|
|
39
48
|
links: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
40
49
|
title: z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodString>>]>;
|
|
@@ -58,15 +67,19 @@ export declare const brandingSchema: z.ZodObject<{
|
|
|
58
67
|
warning?: import("../lib/util/color.js").RgbColor | undefined;
|
|
59
68
|
light?: import("../lib/util/color.js").RgbColor | undefined;
|
|
60
69
|
dark?: import("../lib/util/color.js").RgbColor | undefined;
|
|
70
|
+
contrastSaturation?: number | undefined;
|
|
61
71
|
primary?: import("../lib/util/color.js").RgbColor | undefined;
|
|
72
|
+
info?: import("../lib/util/color.js").RgbColor | undefined;
|
|
62
73
|
errorContrast?: import("../lib/util/color.js").RgbColor | undefined;
|
|
63
74
|
successContrast?: import("../lib/util/color.js").RgbColor | undefined;
|
|
64
75
|
warningContrast?: import("../lib/util/color.js").RgbColor | undefined;
|
|
65
76
|
primaryContrast?: import("../lib/util/color.js").RgbColor | undefined;
|
|
77
|
+
infoContrast?: import("../lib/util/color.js").RgbColor | undefined;
|
|
66
78
|
errorHue?: number | undefined;
|
|
67
79
|
successHue?: number | undefined;
|
|
68
80
|
warningHue?: number | undefined;
|
|
69
81
|
primaryHue?: number | undefined;
|
|
82
|
+
infoHue?: number | undefined;
|
|
70
83
|
} | undefined;
|
|
71
84
|
links?: {
|
|
72
85
|
href: string;
|
|
@@ -82,15 +95,19 @@ export declare const brandingSchema: z.ZodObject<{
|
|
|
82
95
|
warning?: string | undefined;
|
|
83
96
|
light?: string | undefined;
|
|
84
97
|
dark?: string | undefined;
|
|
98
|
+
contrastSaturation?: number | undefined;
|
|
85
99
|
primary?: string | undefined;
|
|
100
|
+
info?: string | undefined;
|
|
86
101
|
errorContrast?: string | undefined;
|
|
87
102
|
successContrast?: string | undefined;
|
|
88
103
|
warningContrast?: string | undefined;
|
|
89
104
|
primaryContrast?: string | undefined;
|
|
105
|
+
infoContrast?: string | undefined;
|
|
90
106
|
errorHue?: number | undefined;
|
|
91
107
|
successHue?: number | undefined;
|
|
92
108
|
warningHue?: number | undefined;
|
|
93
109
|
primaryHue?: number | undefined;
|
|
110
|
+
infoHue?: number | undefined;
|
|
94
111
|
} | undefined;
|
|
95
112
|
links?: {
|
|
96
113
|
href: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"branding.d.ts","sourceRoot":"","sources":["../../src/customization/branding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,eAAO,MAAM,cAAc
|
|
1
|
+
{"version":3,"file":"branding.d.ts","sourceRoot":"","sources":["../../src/customization/branding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKzB,CAAA;AACF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAA;AAC1D,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-customization-css.d.ts","sourceRoot":"","sources":["../../src/customization/build-customization-css.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build-customization-css.d.ts","sourceRoot":"","sources":["../../src/customization/build-customization-css.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD,wBAAgB,qBAAqB,CAAC,EACpC,QAAQ,GACT,EAAE,aAAa,GAAG,SAAS,GAAG,MAAM,CAGpC"}
|
|
@@ -10,8 +10,22 @@ function buildCustomizationCss({ branding, }) {
|
|
|
10
10
|
}
|
|
11
11
|
function* buildCustomizationVars(branding) {
|
|
12
12
|
if (branding?.colors) {
|
|
13
|
-
const
|
|
14
|
-
|
|
13
|
+
const contrastSaturation = branding.colors.contrastSaturation ?? 30;
|
|
14
|
+
yield `--contrast-sat: ${contrastSaturation.toFixed(2)}%;`;
|
|
15
|
+
const contrastLight = branding.colors.light ??
|
|
16
|
+
// Corresponds to color-contrast-975
|
|
17
|
+
(0, color_js_1.hslToRgb)({
|
|
18
|
+
h: branding.colors.primaryHue ?? 0,
|
|
19
|
+
s: contrastSaturation / 100,
|
|
20
|
+
l: 0.07,
|
|
21
|
+
});
|
|
22
|
+
const contrastDark = branding.colors.dark ??
|
|
23
|
+
// Corresponds to color-contrast-25
|
|
24
|
+
(0, color_js_1.hslToRgb)({
|
|
25
|
+
h: branding.colors.primaryHue ?? 0,
|
|
26
|
+
s: contrastSaturation / 100,
|
|
27
|
+
l: 0.953,
|
|
28
|
+
});
|
|
15
29
|
for (const name of colors_js_1.COLOR_NAMES) {
|
|
16
30
|
const value = branding.colors[name];
|
|
17
31
|
if (!value)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-customization-css.js","sourceRoot":"","sources":["../../src/customization/build-customization-css.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"build-customization-css.js","sourceRoot":"","sources":["../../src/customization/build-customization-css.ts"],"names":[],"mappings":";;AAUA,sDAKC;AAfD,mDAK6B;AAE7B,2CAAyC;AAGzC,SAAgB,qBAAqB,CAAC,EACpC,QAAQ,GACM;IACd,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,CAAC,CAAA;IACzD,IAAI,IAAI,CAAC,MAAM;QAAE,OAAO,WAAW,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAA;AACvD,CAAC;AAED,QAAQ,CAAC,CAAC,sBAAsB,CAAC,QAAmB;IAClD,IAAI,QAAQ,EAAE,MAAM,EAAE,CAAC;QACrB,MAAM,kBAAkB,GAAG,QAAQ,CAAC,MAAM,CAAC,kBAAkB,IAAI,EAAE,CAAA;QACnE,MAAM,mBAAmB,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAA;QAE1D,MAAM,aAAa,GACjB,QAAQ,CAAC,MAAM,CAAC,KAAK;YACrB,oCAAoC;YACpC,IAAA,mBAAQ,EAAC;gBACP,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,IAAI,CAAC;gBAClC,CAAC,EAAE,kBAAkB,GAAG,GAAG;gBAC3B,CAAC,EAAE,IAAI;aACR,CAAC,CAAA;QACJ,MAAM,YAAY,GAChB,QAAQ,CAAC,MAAM,CAAC,IAAI;YACpB,mCAAmC;YACnC,IAAA,mBAAQ,EAAC;gBACP,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,IAAI,CAAC;gBAClC,CAAC,EAAE,kBAAkB,GAAG,GAAG;gBAC3B,CAAC,EAAE,KAAK;aACT,CAAC,CAAA;QAEJ,KAAK,MAAM,IAAI,IAAI,uBAAW,EAAE,CAAC;YAC/B,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;YACnC,IAAI,CAAC,KAAK;gBAAE,SAAQ,CAAC,sBAAsB;YAE3C,MAAM,QAAQ,GACZ,QAAQ,CAAC,MAAM,CAAC,GAAG,IAAI,UAAU,CAAC;gBAClC,IAAA,4BAAiB,EAAC,KAAK,EAAE,aAAa,EAAE,YAAY,CAAC,CAAA;YAEvD,MAAM,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,IAAI,KAAK,CAAC,IAAI,IAAA,qBAAU,EAAC,KAAK,CAAC,CAAA;YAE9D,MAAM,oBAAoB,IAAI,KAAK,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAA;YACnE,MAAM,oBAAoB,IAAI,cAAc,QAAQ,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,GAAG,CAAA;YACrF,MAAM,oBAAoB,IAAI,SAAS,GAAG,GAAG,CAAA;QAC/C,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import {\n RgbColor,\n extractHue,\n hslToRgb,\n pickContrastColor,\n} from '../lib/util/color.js'\nimport { Branding } from './branding.js'\nimport { COLOR_NAMES } from './colors.js'\nimport { Customization } from './customization.js'\n\nexport function buildCustomizationCss({\n branding,\n}: Customization): undefined | string {\n const vars = Array.from(buildCustomizationVars(branding))\n if (vars.length) return `:root { ${vars.join(' ')} }`\n}\n\nfunction* buildCustomizationVars(branding?: Branding): Generator<string> {\n if (branding?.colors) {\n const contrastSaturation = branding.colors.contrastSaturation ?? 30\n yield `--contrast-sat: ${contrastSaturation.toFixed(2)}%;`\n\n const contrastLight: RgbColor =\n branding.colors.light ??\n // Corresponds to color-contrast-975\n hslToRgb({\n h: branding.colors.primaryHue ?? 0,\n s: contrastSaturation / 100,\n l: 0.07,\n })\n const contrastDark: RgbColor =\n branding.colors.dark ??\n // Corresponds to color-contrast-25\n hslToRgb({\n h: branding.colors.primaryHue ?? 0,\n s: contrastSaturation / 100,\n l: 0.953,\n })\n\n for (const name of COLOR_NAMES) {\n const value = branding.colors[name]\n if (!value) continue // Skip missing colors\n\n const contrast =\n branding.colors[`${name}Contrast`] ??\n pickContrastColor(value, contrastLight, contrastDark)\n\n const hue = branding.colors[`${name}Hue`] ?? extractHue(value)\n\n yield `--branding-color-${name}: ${value.r} ${value.g} ${value.b};`\n yield `--branding-color-${name}-contrast: ${contrast.r} ${contrast.g} ${contrast.b};`\n yield `--branding-color-${name}-hue: ${hue};`\n }\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CustomizationData } from '@atproto/oauth-provider-api';
|
|
2
|
-
import { Customization } from './customization.js';
|
|
1
|
+
import type { CustomizationData } from '@atproto/oauth-provider-api';
|
|
2
|
+
import type { Customization } from './customization.js';
|
|
3
3
|
export declare function buildCustomizationData({ branding, availableUserDomains, inviteCodeRequired, hcaptcha, }: Customization): CustomizationData;
|
|
4
4
|
//# sourceMappingURL=build-customization-data.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-customization-data.d.ts","sourceRoot":"","sources":["../../src/customization/build-customization-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"build-customization-data.d.ts","sourceRoot":"","sources":["../../src/customization/build-customization-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD,wBAAgB,sBAAsB,CAAC,EACrC,QAAQ,EACR,oBAAoB,EACpB,kBAAkB,EAClB,QAAQ,GACT,EAAE,aAAa,GAAG,iBAAiB,CAanC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-customization-data.js","sourceRoot":"","sources":["../../src/customization/build-customization-data.ts"],"names":[],"mappings":";;AAGA,wDAkBC;AAlBD,SAAgB,sBAAsB,CAAC,EACrC,QAAQ,EACR,oBAAoB,EACpB,kBAAkB,EAClB,QAAQ,GACM;IACd,4EAA4E;IAC5E,iBAAiB;IACjB,6EAA6E;IAC7E,6DAA6D;IAC7D,OAAO;QACL,oBAAoB;QACpB,kBAAkB;QAClB,eAAe,EAAE,QAAQ,EAAE,OAAO;QAClC,IAAI,EAAE,QAAQ,EAAE,IAAI;QACpB,IAAI,EAAE,QAAQ,EAAE,IAAI;QACpB,KAAK,EAAE,QAAQ,EAAE,KAAK;KACvB,CAAA;AACH,CAAC","sourcesContent":["import { CustomizationData } from '@atproto/oauth-provider-api'\nimport { Customization } from './customization.js'\n\nexport function buildCustomizationData({\n branding,\n availableUserDomains,\n inviteCodeRequired,\n hcaptcha,\n}: Customization): CustomizationData {\n // @NOTE the front end does not need colors here as they will be injected as\n // CSS variables.\n // @NOTE We only copy the values explicitly needed to avoid leaking sensitive\n // data (in case the caller passed more than what we expect).\n return {\n availableUserDomains,\n inviteCodeRequired,\n hcaptchaSiteKey: hcaptcha?.siteKey,\n name: branding?.name,\n logo: branding?.logo,\n links: branding?.links,\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"build-customization-data.js","sourceRoot":"","sources":["../../src/customization/build-customization-data.ts"],"names":[],"mappings":";;AAGA,wDAkBC;AAlBD,SAAgB,sBAAsB,CAAC,EACrC,QAAQ,EACR,oBAAoB,EACpB,kBAAkB,EAClB,QAAQ,GACM;IACd,4EAA4E;IAC5E,iBAAiB;IACjB,6EAA6E;IAC7E,6DAA6D;IAC7D,OAAO;QACL,oBAAoB;QACpB,kBAAkB;QAClB,eAAe,EAAE,QAAQ,EAAE,OAAO;QAClC,IAAI,EAAE,QAAQ,EAAE,IAAI;QACpB,IAAI,EAAE,QAAQ,EAAE,IAAI;QACpB,KAAK,EAAE,QAAQ,EAAE,KAAK;KACvB,CAAA;AACH,CAAC","sourcesContent":["import type { CustomizationData } from '@atproto/oauth-provider-api'\nimport type { Customization } from './customization.js'\n\nexport function buildCustomizationData({\n branding,\n availableUserDomains,\n inviteCodeRequired,\n hcaptcha,\n}: Customization): CustomizationData {\n // @NOTE the front end does not need colors here as they will be injected as\n // CSS variables.\n // @NOTE We only copy the values explicitly needed to avoid leaking sensitive\n // data (in case the caller passed more than what we expect).\n return {\n availableUserDomains,\n inviteCodeRequired,\n hcaptchaSiteKey: hcaptcha?.siteKey,\n name: branding?.name,\n logo: branding?.logo,\n links: branding?.links,\n }\n}\n"]}
|
|
@@ -1,39 +1,48 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export declare const COLOR_NAMES: readonly ["primary", "error", "warning", "success"];
|
|
2
|
+
export declare const COLOR_NAMES: readonly ["primary", "error", "warning", "info", "success"];
|
|
3
3
|
export type ColorName = (typeof COLOR_NAMES)[number];
|
|
4
4
|
export declare const colorsSchema: z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<z.objectUtil.extendShape<{
|
|
5
5
|
light: z.ZodOptional<z.ZodEffects<z.ZodString, import("../lib/util/color.js").RgbColor, string>>;
|
|
6
6
|
dark: z.ZodOptional<z.ZodEffects<z.ZodString, import("../lib/util/color.js").RgbColor, string>>;
|
|
7
|
-
|
|
7
|
+
contrastSaturation: z.ZodOptional<z.ZodNumber>;
|
|
8
|
+
}, Record<"error" | "success" | "warning" | "primary" | "info", z.ZodOptional<z.ZodEffects<z.ZodString, import("../lib/util/color.js").RgbColor, string>>>>, Record<"errorContrast" | "successContrast" | "warningContrast" | "primaryContrast" | "infoContrast", z.ZodOptional<z.ZodEffects<z.ZodString, import("../lib/util/color.js").RgbColor, string>>>>, Record<"errorHue" | "successHue" | "warningHue" | "primaryHue" | "infoHue", z.ZodOptional<z.ZodNumber>>>, "strip", z.ZodTypeAny, {
|
|
8
9
|
error?: import("../lib/util/color.js").RgbColor | undefined;
|
|
9
10
|
success?: import("../lib/util/color.js").RgbColor | undefined;
|
|
10
11
|
warning?: import("../lib/util/color.js").RgbColor | undefined;
|
|
11
12
|
light?: import("../lib/util/color.js").RgbColor | undefined;
|
|
12
13
|
dark?: import("../lib/util/color.js").RgbColor | undefined;
|
|
14
|
+
contrastSaturation?: number | undefined;
|
|
13
15
|
primary?: import("../lib/util/color.js").RgbColor | undefined;
|
|
16
|
+
info?: import("../lib/util/color.js").RgbColor | undefined;
|
|
14
17
|
errorContrast?: import("../lib/util/color.js").RgbColor | undefined;
|
|
15
18
|
successContrast?: import("../lib/util/color.js").RgbColor | undefined;
|
|
16
19
|
warningContrast?: import("../lib/util/color.js").RgbColor | undefined;
|
|
17
20
|
primaryContrast?: import("../lib/util/color.js").RgbColor | undefined;
|
|
21
|
+
infoContrast?: import("../lib/util/color.js").RgbColor | undefined;
|
|
18
22
|
errorHue?: number | undefined;
|
|
19
23
|
successHue?: number | undefined;
|
|
20
24
|
warningHue?: number | undefined;
|
|
21
25
|
primaryHue?: number | undefined;
|
|
26
|
+
infoHue?: number | undefined;
|
|
22
27
|
}, {
|
|
23
28
|
error?: string | undefined;
|
|
24
29
|
success?: string | undefined;
|
|
25
30
|
warning?: string | undefined;
|
|
26
31
|
light?: string | undefined;
|
|
27
32
|
dark?: string | undefined;
|
|
33
|
+
contrastSaturation?: number | undefined;
|
|
28
34
|
primary?: string | undefined;
|
|
35
|
+
info?: string | undefined;
|
|
29
36
|
errorContrast?: string | undefined;
|
|
30
37
|
successContrast?: string | undefined;
|
|
31
38
|
warningContrast?: string | undefined;
|
|
32
39
|
primaryContrast?: string | undefined;
|
|
40
|
+
infoContrast?: string | undefined;
|
|
33
41
|
errorHue?: number | undefined;
|
|
34
42
|
successHue?: number | undefined;
|
|
35
43
|
warningHue?: number | undefined;
|
|
36
44
|
primaryHue?: number | undefined;
|
|
45
|
+
infoHue?: number | undefined;
|
|
37
46
|
}>;
|
|
38
47
|
export type Colors = z.infer<typeof colorsSchema>;
|
|
39
48
|
//# sourceMappingURL=colors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../src/customization/colors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../src/customization/colors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,eAAO,MAAM,WAAW,6DAMd,CAAA;AACV,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAA;AAEpD,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgCtB,CAAA;AAEH,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA"}
|
|
@@ -4,11 +4,29 @@ exports.colorsSchema = exports.COLOR_NAMES = void 0;
|
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const color_hue_js_1 = require("../types/color-hue.js");
|
|
6
6
|
const rgb_color_js_1 = require("../types/rgb-color.js");
|
|
7
|
-
exports.COLOR_NAMES = [
|
|
7
|
+
exports.COLOR_NAMES = [
|
|
8
|
+
'primary',
|
|
9
|
+
'error',
|
|
10
|
+
'warning',
|
|
11
|
+
'info',
|
|
12
|
+
'success',
|
|
13
|
+
];
|
|
8
14
|
exports.colorsSchema = zod_1.z
|
|
9
15
|
.object({
|
|
16
|
+
// The "light" and "dark" colors are used as default for unspecified
|
|
17
|
+
// contrast colors. The color that has the highest contrast ratio with the
|
|
18
|
+
// color base will be used. e.G. If "primary" is specified but
|
|
19
|
+
// "primaryContrast" is not, then the contrast color will be either "light"
|
|
20
|
+
// or "dark" depending on which one has the highest contrast ratio with
|
|
21
|
+
// "primary".
|
|
10
22
|
light: rgb_color_js_1.rgbColorSchema.optional(),
|
|
11
23
|
dark: rgb_color_js_1.rgbColorSchema.optional(),
|
|
24
|
+
// The "contrastSaturation" is used to compute the saturation of the
|
|
25
|
+
// "contrast" color. The "contrast" color is a (dynamic) color derived from
|
|
26
|
+
// the "primaryHue" color with the specified saturation and a variable
|
|
27
|
+
// lightness. "color-contrast-900" is used for default text, while
|
|
28
|
+
// "color-contrast-0" is used for the page background.
|
|
29
|
+
contrastSaturation: zod_1.z.number().min(0).max(100).optional(),
|
|
12
30
|
})
|
|
13
31
|
.extend(Object.fromEntries(exports.COLOR_NAMES.map((name) => [name, rgb_color_js_1.rgbColorSchema.optional()])))
|
|
14
32
|
.extend(Object.fromEntries(exports.COLOR_NAMES.map((name) => [`${name}Contrast`, rgb_color_js_1.rgbColorSchema.optional()])))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colors.js","sourceRoot":"","sources":["../../src/customization/colors.ts"],"names":[],"mappings":";;;AAAA,6BAAuB;AACvB,wDAAsD;AACtD,wDAAsD;AAEzC,QAAA,WAAW,GAAG,
|
|
1
|
+
{"version":3,"file":"colors.js","sourceRoot":"","sources":["../../src/customization/colors.ts"],"names":[],"mappings":";;;AAAA,6BAAuB;AACvB,wDAAsD;AACtD,wDAAsD;AAEzC,QAAA,WAAW,GAAG;IACzB,SAAS;IACT,OAAO;IACP,SAAS;IACT,MAAM;IACN,SAAS;CACD,CAAA;AAGG,QAAA,YAAY,GAAG,OAAC;KAC1B,MAAM,CAAC;IACN,oEAAoE;IACpE,0EAA0E;IAC1E,8DAA8D;IAC9D,2EAA2E;IAC3E,uEAAuE;IACvE,aAAa;IACb,KAAK,EAAE,6BAAc,CAAC,QAAQ,EAAE;IAChC,IAAI,EAAE,6BAAc,CAAC,QAAQ,EAAE;IAE/B,oEAAoE;IACpE,2EAA2E;IAC3E,sEAAsE;IACtE,kEAAkE;IAClE,sDAAsD;IACtD,kBAAkB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;CAC1D,CAAC;KACD,MAAM,CACL,MAAM,CAAC,WAAW,CAChB,mBAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,6BAAc,CAAC,QAAQ,EAAE,CAAC,CAAC,CACF,CAC7D;KACA,MAAM,CACL,MAAM,CAAC,WAAW,CAChB,mBAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,UAAU,EAAE,6BAAc,CAAC,QAAQ,EAAE,CAAC,CAAC,CACF,CAC1E;KACA,MAAM,CACL,MAAM,CAAC,WAAW,CAChB,mBAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,KAAK,EAAE,6BAAc,CAAC,QAAQ,EAAE,CAAC,CAAC,CACF,CACrE,CAAA","sourcesContent":["import { z } from 'zod'\nimport { colorHueSchema } from '../types/color-hue.js'\nimport { rgbColorSchema } from '../types/rgb-color.js'\n\nexport const COLOR_NAMES = [\n 'primary',\n 'error',\n 'warning',\n 'info',\n 'success',\n] as const\nexport type ColorName = (typeof COLOR_NAMES)[number]\n\nexport const colorsSchema = z\n .object({\n // The \"light\" and \"dark\" colors are used as default for unspecified\n // contrast colors. The color that has the highest contrast ratio with the\n // color base will be used. e.G. If \"primary\" is specified but\n // \"primaryContrast\" is not, then the contrast color will be either \"light\"\n // or \"dark\" depending on which one has the highest contrast ratio with\n // \"primary\".\n light: rgbColorSchema.optional(),\n dark: rgbColorSchema.optional(),\n\n // The \"contrastSaturation\" is used to compute the saturation of the\n // \"contrast\" color. The \"contrast\" color is a (dynamic) color derived from\n // the \"primaryHue\" color with the specified saturation and a variable\n // lightness. \"color-contrast-900\" is used for default text, while\n // \"color-contrast-0\" is used for the page background.\n contrastSaturation: z.number().min(0).max(100).optional(),\n })\n .extend(\n Object.fromEntries(\n COLOR_NAMES.map((name) => [name, rgbColorSchema.optional()]),\n ) as Record<ColorName, z.ZodOptional<typeof rgbColorSchema>>,\n )\n .extend(\n Object.fromEntries(\n COLOR_NAMES.map((name) => [`${name}Contrast`, rgbColorSchema.optional()]),\n ) as Record<`${ColorName}Contrast`, z.ZodOptional<typeof rgbColorSchema>>,\n )\n .extend(\n Object.fromEntries(\n COLOR_NAMES.map((name) => [`${name}Hue`, colorHueSchema.optional()]),\n ) as Record<`${ColorName}Hue`, z.ZodOptional<typeof colorHueSchema>>,\n )\n\nexport type Colors = z.infer<typeof colorsSchema>\n"]}
|
|
@@ -14,36 +14,45 @@ export declare const customizationSchema: z.ZodObject<{
|
|
|
14
14
|
colors: z.ZodOptional<z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<z.objectUtil.extendShape<{
|
|
15
15
|
light: z.ZodOptional<z.ZodEffects<z.ZodString, import("../lib/util/color.js").RgbColor, string>>;
|
|
16
16
|
dark: z.ZodOptional<z.ZodEffects<z.ZodString, import("../lib/util/color.js").RgbColor, string>>;
|
|
17
|
-
|
|
17
|
+
contrastSaturation: z.ZodOptional<z.ZodNumber>;
|
|
18
|
+
}, Record<"error" | "success" | "warning" | "primary" | "info", z.ZodOptional<z.ZodEffects<z.ZodString, import("../lib/util/color.js").RgbColor, string>>>>, Record<"errorContrast" | "successContrast" | "warningContrast" | "primaryContrast" | "infoContrast", z.ZodOptional<z.ZodEffects<z.ZodString, import("../lib/util/color.js").RgbColor, string>>>>, Record<"errorHue" | "successHue" | "warningHue" | "primaryHue" | "infoHue", z.ZodOptional<z.ZodNumber>>>, "strip", z.ZodTypeAny, {
|
|
18
19
|
error?: import("../lib/util/color.js").RgbColor | undefined;
|
|
19
20
|
success?: import("../lib/util/color.js").RgbColor | undefined;
|
|
20
21
|
warning?: import("../lib/util/color.js").RgbColor | undefined;
|
|
21
22
|
light?: import("../lib/util/color.js").RgbColor | undefined;
|
|
22
23
|
dark?: import("../lib/util/color.js").RgbColor | undefined;
|
|
24
|
+
contrastSaturation?: number | undefined;
|
|
23
25
|
primary?: import("../lib/util/color.js").RgbColor | undefined;
|
|
26
|
+
info?: import("../lib/util/color.js").RgbColor | undefined;
|
|
24
27
|
errorContrast?: import("../lib/util/color.js").RgbColor | undefined;
|
|
25
28
|
successContrast?: import("../lib/util/color.js").RgbColor | undefined;
|
|
26
29
|
warningContrast?: import("../lib/util/color.js").RgbColor | undefined;
|
|
27
30
|
primaryContrast?: import("../lib/util/color.js").RgbColor | undefined;
|
|
31
|
+
infoContrast?: import("../lib/util/color.js").RgbColor | undefined;
|
|
28
32
|
errorHue?: number | undefined;
|
|
29
33
|
successHue?: number | undefined;
|
|
30
34
|
warningHue?: number | undefined;
|
|
31
35
|
primaryHue?: number | undefined;
|
|
36
|
+
infoHue?: number | undefined;
|
|
32
37
|
}, {
|
|
33
38
|
error?: string | undefined;
|
|
34
39
|
success?: string | undefined;
|
|
35
40
|
warning?: string | undefined;
|
|
36
41
|
light?: string | undefined;
|
|
37
42
|
dark?: string | undefined;
|
|
43
|
+
contrastSaturation?: number | undefined;
|
|
38
44
|
primary?: string | undefined;
|
|
45
|
+
info?: string | undefined;
|
|
39
46
|
errorContrast?: string | undefined;
|
|
40
47
|
successContrast?: string | undefined;
|
|
41
48
|
warningContrast?: string | undefined;
|
|
42
49
|
primaryContrast?: string | undefined;
|
|
50
|
+
infoContrast?: string | undefined;
|
|
43
51
|
errorHue?: number | undefined;
|
|
44
52
|
successHue?: number | undefined;
|
|
45
53
|
warningHue?: number | undefined;
|
|
46
54
|
primaryHue?: number | undefined;
|
|
55
|
+
infoHue?: number | undefined;
|
|
47
56
|
}>>;
|
|
48
57
|
links: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
49
58
|
title: z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodString>>]>;
|
|
@@ -67,15 +76,19 @@ export declare const customizationSchema: z.ZodObject<{
|
|
|
67
76
|
warning?: import("../lib/util/color.js").RgbColor | undefined;
|
|
68
77
|
light?: import("../lib/util/color.js").RgbColor | undefined;
|
|
69
78
|
dark?: import("../lib/util/color.js").RgbColor | undefined;
|
|
79
|
+
contrastSaturation?: number | undefined;
|
|
70
80
|
primary?: import("../lib/util/color.js").RgbColor | undefined;
|
|
81
|
+
info?: import("../lib/util/color.js").RgbColor | undefined;
|
|
71
82
|
errorContrast?: import("../lib/util/color.js").RgbColor | undefined;
|
|
72
83
|
successContrast?: import("../lib/util/color.js").RgbColor | undefined;
|
|
73
84
|
warningContrast?: import("../lib/util/color.js").RgbColor | undefined;
|
|
74
85
|
primaryContrast?: import("../lib/util/color.js").RgbColor | undefined;
|
|
86
|
+
infoContrast?: import("../lib/util/color.js").RgbColor | undefined;
|
|
75
87
|
errorHue?: number | undefined;
|
|
76
88
|
successHue?: number | undefined;
|
|
77
89
|
warningHue?: number | undefined;
|
|
78
90
|
primaryHue?: number | undefined;
|
|
91
|
+
infoHue?: number | undefined;
|
|
79
92
|
} | undefined;
|
|
80
93
|
links?: {
|
|
81
94
|
href: string;
|
|
@@ -91,15 +104,19 @@ export declare const customizationSchema: z.ZodObject<{
|
|
|
91
104
|
warning?: string | undefined;
|
|
92
105
|
light?: string | undefined;
|
|
93
106
|
dark?: string | undefined;
|
|
107
|
+
contrastSaturation?: number | undefined;
|
|
94
108
|
primary?: string | undefined;
|
|
109
|
+
info?: string | undefined;
|
|
95
110
|
errorContrast?: string | undefined;
|
|
96
111
|
successContrast?: string | undefined;
|
|
97
112
|
warningContrast?: string | undefined;
|
|
98
113
|
primaryContrast?: string | undefined;
|
|
114
|
+
infoContrast?: string | undefined;
|
|
99
115
|
errorHue?: number | undefined;
|
|
100
116
|
successHue?: number | undefined;
|
|
101
117
|
warningHue?: number | undefined;
|
|
102
118
|
primaryHue?: number | undefined;
|
|
119
|
+
infoHue?: number | undefined;
|
|
103
120
|
} | undefined;
|
|
104
121
|
links?: {
|
|
105
122
|
href: string;
|
|
@@ -141,15 +158,19 @@ export declare const customizationSchema: z.ZodObject<{
|
|
|
141
158
|
warning?: import("../lib/util/color.js").RgbColor | undefined;
|
|
142
159
|
light?: import("../lib/util/color.js").RgbColor | undefined;
|
|
143
160
|
dark?: import("../lib/util/color.js").RgbColor | undefined;
|
|
161
|
+
contrastSaturation?: number | undefined;
|
|
144
162
|
primary?: import("../lib/util/color.js").RgbColor | undefined;
|
|
163
|
+
info?: import("../lib/util/color.js").RgbColor | undefined;
|
|
145
164
|
errorContrast?: import("../lib/util/color.js").RgbColor | undefined;
|
|
146
165
|
successContrast?: import("../lib/util/color.js").RgbColor | undefined;
|
|
147
166
|
warningContrast?: import("../lib/util/color.js").RgbColor | undefined;
|
|
148
167
|
primaryContrast?: import("../lib/util/color.js").RgbColor | undefined;
|
|
168
|
+
infoContrast?: import("../lib/util/color.js").RgbColor | undefined;
|
|
149
169
|
errorHue?: number | undefined;
|
|
150
170
|
successHue?: number | undefined;
|
|
151
171
|
warningHue?: number | undefined;
|
|
152
172
|
primaryHue?: number | undefined;
|
|
173
|
+
infoHue?: number | undefined;
|
|
153
174
|
} | undefined;
|
|
154
175
|
links?: {
|
|
155
176
|
href: string;
|
|
@@ -175,15 +196,19 @@ export declare const customizationSchema: z.ZodObject<{
|
|
|
175
196
|
warning?: string | undefined;
|
|
176
197
|
light?: string | undefined;
|
|
177
198
|
dark?: string | undefined;
|
|
199
|
+
contrastSaturation?: number | undefined;
|
|
178
200
|
primary?: string | undefined;
|
|
201
|
+
info?: string | undefined;
|
|
179
202
|
errorContrast?: string | undefined;
|
|
180
203
|
successContrast?: string | undefined;
|
|
181
204
|
warningContrast?: string | undefined;
|
|
182
205
|
primaryContrast?: string | undefined;
|
|
206
|
+
infoContrast?: string | undefined;
|
|
183
207
|
errorHue?: number | undefined;
|
|
184
208
|
successHue?: number | undefined;
|
|
185
209
|
warningHue?: number | undefined;
|
|
186
210
|
primaryHue?: number | undefined;
|
|
211
|
+
infoHue?: number | undefined;
|
|
187
212
|
} | undefined;
|
|
188
213
|
links?: {
|
|
189
214
|
href: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customization.d.ts","sourceRoot":"","sources":["../../src/customization/customization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,eAAO,MAAM,mBAAmB;IAC9B;;;OAGG;;IAEH;;OAEG
|
|
1
|
+
{"version":3,"file":"customization.d.ts","sourceRoot":"","sources":["../../src/customization/customization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,eAAO,MAAM,mBAAmB;IAC9B;;;OAGG;;IAEH;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEH;;OAEG;;IAEH;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEH,CAAA;AACF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AACpE,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
1
|
+
import type { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'node:http';
|
|
2
2
|
import { SubCtx } from './context.js';
|
|
3
3
|
import { MethodMatcherInput } from './method.js';
|
|
4
4
|
import { Params, Path } from './path.js';
|
|
@@ -6,6 +6,7 @@ import { RouteMiddleware } from './route.js';
|
|
|
6
6
|
import { Middleware } from './types.js';
|
|
7
7
|
export type RouterCtx<T extends object | void = void> = SubCtx<T, {
|
|
8
8
|
url: Readonly<URL>;
|
|
9
|
+
headers: IncomingHttpHeaders;
|
|
9
10
|
}>;
|
|
10
11
|
export type RouterMiddleware<T extends object | void = void, Req = IncomingMessage, Res = ServerResponse> = Middleware<RouterCtx<T>, Req, Res>;
|
|
11
12
|
export type RouterConfig = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../src/lib/http/router.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../src/lib/http/router.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,eAAe,EACf,cAAc,EACf,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,MAAM,EAAU,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAEhD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,eAAe,EAAe,MAAM,YAAY,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEvC,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,GAAG,IAAI,GAAG,IAAI,IAAI,MAAM,CAC5D,CAAC,EACD;IAAE,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;IAAC,OAAO,EAAE,mBAAmB,CAAA;CAAE,CACrD,CAAA;AAED,MAAM,MAAM,gBAAgB,CAC1B,CAAC,SAAS,MAAM,GAAG,IAAI,GAAG,IAAI,EAC9B,GAAG,GAAG,e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AAC,SAAS,MAAM,GAAG,MAAM,EAC/B,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EACb,GAAG,EAAE,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE;IAKrD,QAAQ,CAAC,CAAC,SAAS,MAAM,EACvB,MAAM,EAAE,kBAAkB,EAC1B,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EACb,GAAG,EAAE,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE;IAKrD;;OAEG;IACH,eAAe,IAAI,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC;CAoB3C"}
|
package/dist/lib/http/router.js
CHANGED
|
@@ -46,7 +46,7 @@ class Router {
|
|
|
46
46
|
return next(url);
|
|
47
47
|
// Any error thrown here will be uncaught/unhandled (a middleware should
|
|
48
48
|
// never throw)
|
|
49
|
-
const context = (0, context_js_1.subCtx)(this, { url });
|
|
49
|
+
const context = (0, context_js_1.subCtx)(this, { url, headers: req.headers });
|
|
50
50
|
middleware.call(context, req, res, next);
|
|
51
51
|
};
|
|
52
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../../src/lib/http/router.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../../src/lib/http/router.ts"],"names":[],"mappings":";;;AAKA,6CAA6C;AAE7C,mDAAoD;AAEpD,yCAAyD;AAqBzD,MAAa,MAAM;IAOY;IAFZ,WAAW,GAAoC,EAAE,CAAA;IAElE,YAA6B,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IAEtD,GAAG,CAAC,GAAG,WAA4C;QACjD,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAA;QACrC,OAAO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mBAAM,EAAC,IAAI,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAA;YAC3D,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAA;QAC1C,CAAC,CAAA;IACH,CAAC;CACF;AAzED,wBAyEC;AAED,SAAS,UAAU,CAAC,GAAoB,EAAE,MAAqB;IAC7D,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,EAAE,QAAQ,IAAI,QAAQ,CAAA;QAC7C,MAAM,IAAI,GAAG,MAAM,EAAE,IAAI,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,WAAW,CAAA;QAC5D,MAAM,QAAQ,GAAG,GAAG,CAAC,GAAG,IAAI,GAAG,CAAA;QAC/B,OAAO,IAAI,GAAG,CAAC,QAAQ,EAAE,GAAG,QAAQ,KAAK,IAAI,EAAE,CAAC,CAAA;IAClD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,KAAK,GACT,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,aAAa,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;QACtE,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,CAAA;IAC/D,CAAC;AACH,CAAC","sourcesContent":["import type {\n IncomingHttpHeaders,\n IncomingMessage,\n ServerResponse,\n} from 'node:http'\nimport { SubCtx, subCtx } from './context.js'\nimport { MethodMatcherInput } from './method.js'\nimport { combineMiddlewares } from './middleware.js'\nimport { Params, Path } from './path.js'\nimport { RouteMiddleware, createRoute } from './route.js'\nimport { Middleware } from './types.js'\n\nexport type RouterCtx<T extends object | void = void> = SubCtx<\n T,\n { url: Readonly<URL>; headers: IncomingHttpHeaders }\n>\n\nexport type RouterMiddleware<\n T extends object | void = void,\n Req = IncomingMessage,\n Res = ServerResponse,\n> = Middleware<RouterCtx<T>, Req, Res>\n\nexport type RouterConfig = {\n /** Used to build the origin of the {@link RouterCtx['url']} context property */\n protocol?: string\n /** Used to build the origin of the {@link RouterCtx['url']} context property */\n host?: string\n}\n\nexport class Router<\n T extends object | void = void,\n Req extends IncomingMessage = IncomingMessage,\n Res extends ServerResponse = ServerResponse,\n> {\n private readonly middlewares: RouterMiddleware<T, Req, Res>[] = []\n\n constructor(private readonly config?: RouterConfig) {}\n\n use(...middlewares: RouterMiddleware<T, Req, Res>[]) {\n this.middlewares.push(...middlewares)\n return this\n }\n\n all<P extends Params = Params>(\n path: Path<P>,\n ...mw: RouteMiddleware<RouterCtx<T>, P, Req, Res>[]\n ) {\n return this.addRoute<P>('*', path, ...mw)\n }\n\n get<P extends Params = Params>(\n path: Path<P>,\n ...mw: RouteMiddleware<RouterCtx<T>, P, Req, Res>[]\n ) {\n return this.addRoute<P>('GET', path, ...mw)\n }\n\n post<P extends Params = Params>(\n path: Path<P>,\n ...mw: RouteMiddleware<RouterCtx<T>, P, Req, Res>[]\n ) {\n return this.addRoute<P>('POST', path, ...mw)\n }\n\n options<P extends Params = Params>(\n path: Path<P>,\n ...mw: RouteMiddleware<RouterCtx<T>, P, Req, Res>[]\n ) {\n return this.addRoute<P>('OPTIONS', path, ...mw)\n }\n\n addRoute<P extends Params>(\n method: MethodMatcherInput,\n path: Path<P>,\n ...mw: RouteMiddleware<RouterCtx<T>, P, Req, Res>[]\n ) {\n return this.use(createRoute(method, path, ...mw))\n }\n\n /**\n * @returns router middleware which dispatches a route matching the request.\n */\n buildMiddleware(): Middleware<T, Req, Res> {\n const { config } = this\n\n // Calling next('router') from a middleware will skip all the remaining\n // middlewares in the stack.\n const middleware = combineMiddlewares(this.middlewares, {\n skipKeyword: 'router',\n })\n\n return function (this, req, res, next) {\n // Parse the URL using node's URL parser.\n const url = extractUrl(req, config)\n if (url instanceof Error) return next(url)\n\n // Any error thrown here will be uncaught/unhandled (a middleware should\n // never throw)\n const context = subCtx(this, { url, headers: req.headers })\n middleware.call(context, req, res, next)\n }\n }\n}\n\nfunction extractUrl(req: IncomingMessage, config?: RouterConfig): URL | Error {\n try {\n const protocol = config?.protocol || 'https:'\n const host = config?.host || req.headers.host || 'localhost'\n const pathname = req.url || '/'\n return new URL(pathname, `${protocol}//${host}`)\n } catch (cause) {\n const error =\n cause instanceof Error ? cause : new Error('Invalid URL', { cause })\n return Object.assign(error, { status: 400, statusCode: 400 })\n }\n}\n"]}
|
package/dist/lib/util/color.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export type HslaColor = {
|
|
|
20
20
|
l: number;
|
|
21
21
|
a: number;
|
|
22
22
|
};
|
|
23
|
+
export type Color = RgbColor | HslColor | RgbaColor | HslaColor;
|
|
23
24
|
export declare function parseColor(color: string): RgbColor | RgbaColor;
|
|
24
25
|
export declare function parseHexColor(v: string): RgbColor | RgbaColor;
|
|
25
26
|
export declare function parseRgbColor(v: string): RgbColor;
|
|
@@ -28,5 +29,7 @@ export declare function parseRgbaColor(v: string): RgbaColor;
|
|
|
28
29
|
* Return the color that has the best contrast with the reference color.
|
|
29
30
|
*/
|
|
30
31
|
export declare function pickContrastColor(ref: RgbColor, a: RgbColor, b: RgbColor): RgbColor;
|
|
32
|
+
export declare function hslToRgb({ h, s, l }: HslColor): RgbColor;
|
|
33
|
+
export declare function hslToRgb({ h, s, l, a }: HslaColor): RgbaColor;
|
|
31
34
|
export declare function extractHue(input: RgbColor): number;
|
|
32
35
|
//# sourceMappingURL=color.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../../src/lib/util/color.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,QAAQ,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAC1D,MAAM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