From ec789709fc41fa47a4becd5faef90058f2fd2461 Mon Sep 17 00:00:00 2001 From: Eugeny Koshaev Date: Wed, 28 Oct 2026 00:42:09 +0300 Subject: [PATCH 01/12] feat(auth): add mcp authorization endpoint types --- index.ts | 1 + src/auth/mcp/authorizationEndpoint.ts | 35 +++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/auth/mcp/authorizationEndpoint.ts diff --git a/index.ts b/index.ts index c11e6e3..8263de1 100644 --- a/index.ts +++ b/index.ts @@ -1,6 +1,7 @@ export * from './src/ai/stream'; export * from './src/auth/tokensPair'; +export * from './src/auth/mcp/authorizationEndpoint'; export * from './src/base/businessOperation/businessOperation'; diff --git a/src/auth/mcp/authorizationEndpoint.ts b/src/auth/mcp/authorizationEndpoint.ts new file mode 100644 index 0000000..409f49f --- /dev/null +++ b/src/auth/mcp/authorizationEndpoint.ts @@ -0,0 +1,35 @@ +/** + * MCP Authorization Endpoint request body interface + */ +export interface AuthorizationEndpointRequest { + /** + * MCP Client Identifier + */ + client_id: string; + + /** + * Indicates the URL to return the user to after authorization is complete + */ + redirect_uri: string; + + /** + * Opaque value used by the client to maintain state between the request and callback + */ + state: string; + + /** + * Base64-URL-encoded string of the SHA256 hash of the code verifier + */ + code_challenge: string; +}; + +/** + * MCP Authorization Endpoint response body interface + */ +export interface AuthorizationEndpointResponse { + /** + * Indicates the URL to return the user to after authorization is complete. + * Populated with additional parameters + */ + redirect_uri: string; +}; From 479c0c144b080b6fa6123c6d4fa3925bb629d0d1 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 27 Oct 2026 21:52:18 +0000 Subject: [PATCH 02/12] Lint and build --- build/index.d.ts | 1 + build/index.js | 1 + build/src/auth/mcp/authorizationEndpoint.d.ts | 31 +++++++++++++++++++ build/src/auth/mcp/authorizationEndpoint.js | 4 +++ 4 files changed, 37 insertions(+) create mode 100644 build/src/auth/mcp/authorizationEndpoint.d.ts create mode 100644 build/src/auth/mcp/authorizationEndpoint.js diff --git a/build/index.d.ts b/build/index.d.ts index 033c402..d5601d7 100644 --- a/build/index.d.ts +++ b/build/index.d.ts @@ -1,5 +1,6 @@ export * from './src/ai/stream'; export * from './src/auth/tokensPair'; +export * from './src/auth/mcp/authorizationEndpoint'; export * from './src/base/businessOperation/businessOperation'; export * from './src/billing/planProlongrationPayload'; export * from './src/base/event/affectedUser'; diff --git a/build/index.js b/build/index.js index cc6ddf2..ee6a2e2 100644 --- a/build/index.js +++ b/build/index.js @@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) { Object.defineProperty(exports, "__esModule", { value: true }); __exportStar(require("./src/ai/stream"), exports); __exportStar(require("./src/auth/tokensPair"), exports); +__exportStar(require("./src/auth/mcp/authorizationEndpoint"), exports); __exportStar(require("./src/base/businessOperation/businessOperation"), exports); __exportStar(require("./src/billing/planProlongrationPayload"), exports); __exportStar(require("./src/base/event/affectedUser"), exports); diff --git a/build/src/auth/mcp/authorizationEndpoint.d.ts b/build/src/auth/mcp/authorizationEndpoint.d.ts new file mode 100644 index 0000000..e0879e7 --- /dev/null +++ b/build/src/auth/mcp/authorizationEndpoint.d.ts @@ -0,0 +1,31 @@ +/** + * MCP Authorization Endpoint request body interface + */ +export interface AuthorizationEndpointRequest { + /** + * MCP Client Identifier + */ + client_id: string; + /** + * Indicates the URL to return the user to after authorization is complete + */ + redirect_uri: string; + /** + * Opaque value used by the client to maintain state between the request and callback + */ + state: string; + /** + * Base64-URL-encoded string of the SHA256 hash of the code verifier + */ + code_challenge: string; +} +/** + * MCP Authorization Endpoint response body interface + */ +export interface AuthorizationEndpointResponse { + /** + * Indicates the URL to return the user to after authorization is complete. + * Populated with additional parameters + */ + redirect_uri: string; +} diff --git a/build/src/auth/mcp/authorizationEndpoint.js b/build/src/auth/mcp/authorizationEndpoint.js new file mode 100644 index 0000000..89f6374 --- /dev/null +++ b/build/src/auth/mcp/authorizationEndpoint.js @@ -0,0 +1,4 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +; +; From 74216d71756eec5f0967655be4ba380c1e85ba49 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 27 Oct 2026 21:52:21 +0000 Subject: [PATCH 03/12] Bump version up to 0.9.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4768fa1..3300df1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hawk.so/types", - "version": "0.9.0", + "version": "0.9.1", "description": "TypeScript definitions for Hawk", "types": "build/index.d.ts", "main": "build/index.js", From 65857f2e2db374b7c44e42e72730069a33d80892 Mon Sep 17 00:00:00 2001 From: Eugeny Koshaev Date: Wed, 11 Nov 2026 00:59:13 +0300 Subject: [PATCH 04/12] feat(jwtIdDBScheme): add DB scheme for jwts issued to third-party --- src/dbScheme/jwtId.ts | 56 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/dbScheme/jwtId.ts diff --git a/src/dbScheme/jwtId.ts b/src/dbScheme/jwtId.ts new file mode 100644 index 0000000..3cace16 --- /dev/null +++ b/src/dbScheme/jwtId.ts @@ -0,0 +1,56 @@ +import type { ObjectId, Timestamp } from "bson"; + +/** + * Permissions granted to token + */ +export type TokenPermissions = 'read' | 'write'; + +/** + * Database representation of JSON Web Token issued to third-party clients + */ +export interface JWTIdDBScheme { + /** + * External token identifier + */ + _id: ObjectId, + + /** + * Token owner id + */ + userId: string, + + /** + * Unique JSON Web Token Identifier + */ + jti: string, + + /** + * Last characters of the token, used to tell tokens apart in user settings + */ + preview: string, + + /** + * What token can be used for + */ + permissions: TokenPermissions[], + + /** + * Label set by user + */ + lable: string, + + /** + * Last time token was used + */ + lastUsedAt: Timestamp | null, + + /** + * Usage count + */ + requestCount: number, + + /** + * Creation date + */ + createdAt: Timestamp +} From 306ef797e57e17378ded802fa57c626c7c263660 Mon Sep 17 00:00:00 2001 From: Eugeny Koshaev Date: Wed, 11 Nov 2026 02:08:27 +0300 Subject: [PATCH 05/12] chore(thirdparty): rename jwtid to thirdparty --- src/dbScheme/{jwtId.ts => thirdparty.ts} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename src/dbScheme/{jwtId.ts => thirdparty.ts} (87%) diff --git a/src/dbScheme/jwtId.ts b/src/dbScheme/thirdparty.ts similarity index 87% rename from src/dbScheme/jwtId.ts rename to src/dbScheme/thirdparty.ts index 3cace16..658c6f9 100644 --- a/src/dbScheme/jwtId.ts +++ b/src/dbScheme/thirdparty.ts @@ -6,9 +6,9 @@ import type { ObjectId, Timestamp } from "bson"; export type TokenPermissions = 'read' | 'write'; /** - * Database representation of JSON Web Token issued to third-party clients + * Database representation of active to third-party clients */ -export interface JWTIdDBScheme { +export interface ThirdpartyDBScheme { /** * External token identifier */ From 85132be22eb48f9f19a33e46aca33d7c8dbf6b1c Mon Sep 17 00:00:00 2001 From: Eugeny Koshaev Date: Wed, 11 Nov 2026 02:27:27 +0300 Subject: [PATCH 06/12] chore(authEndpoint): rename to OAuth, add additional parameters, add error respones --- index.ts | 3 +- src/auth/OAuth.ts | 64 +++++++++++++++++++++++++++ src/auth/mcp/authorizationEndpoint.ts | 35 --------------- 3 files changed, 66 insertions(+), 36 deletions(-) create mode 100644 src/auth/OAuth.ts delete mode 100644 src/auth/mcp/authorizationEndpoint.ts diff --git a/index.ts b/index.ts index 8263de1..b312522 100644 --- a/index.ts +++ b/index.ts @@ -1,7 +1,7 @@ export * from './src/ai/stream'; export * from './src/auth/tokensPair'; -export * from './src/auth/mcp/authorizationEndpoint'; +export * from './src/auth/OAuth'; export * from './src/base/businessOperation/businessOperation'; @@ -41,6 +41,7 @@ export * from './src/dbScheme/workspace'; export * from './src/dbScheme/bankCard'; export * from './src/dbScheme/sso'; export * from './src/dbScheme/projectEventGroupingPattern'; +export * from './src/dbScheme/thirdparty'; export * from './src/notifications/createProjectNotifications'; export * from './src/notifications/receiveTypes'; diff --git a/src/auth/OAuth.ts b/src/auth/OAuth.ts new file mode 100644 index 0000000..ee14443 --- /dev/null +++ b/src/auth/OAuth.ts @@ -0,0 +1,64 @@ +/** + * Authorization request + */ +export interface OAuthRequest { + /** + * Client Identifier + */ + client_id: string; + + /** + * Indicates the URL to return the user to after authorization is complete + */ + redirect_uri: string; + + /** + * Opaque value used by the client to maintain state between the request and callback + */ + state?: string; + + /** + * Base64-URL-encoded string of the SHA256 hash of the code verifier + */ + code_challenge: string; + + /** + * The code challenge transformation method + */ + code_challenge_method: 'S256'; + + /** + * Target service or resource to which access is being requested. + * MUST be an absolute URI + */ + resource?: string; + + /** + * Additional access requested by the application + */ + scope?: string; + + /** + * URL string that references a logo for the client + */ + logoUrl?: string; +}; + +/** + * Authorization response + */ +export interface OAuthResponse { + /** + * Indicates the URL to return the user to after authorization is complete. + * Populated with additional parameters + */ + redirect_uri: string; +}; + +/** + * Authorization error + */ +export interface OAuthError { + error: string; + error_description?: string; +} diff --git a/src/auth/mcp/authorizationEndpoint.ts b/src/auth/mcp/authorizationEndpoint.ts deleted file mode 100644 index 409f49f..0000000 --- a/src/auth/mcp/authorizationEndpoint.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * MCP Authorization Endpoint request body interface - */ -export interface AuthorizationEndpointRequest { - /** - * MCP Client Identifier - */ - client_id: string; - - /** - * Indicates the URL to return the user to after authorization is complete - */ - redirect_uri: string; - - /** - * Opaque value used by the client to maintain state between the request and callback - */ - state: string; - - /** - * Base64-URL-encoded string of the SHA256 hash of the code verifier - */ - code_challenge: string; -}; - -/** - * MCP Authorization Endpoint response body interface - */ -export interface AuthorizationEndpointResponse { - /** - * Indicates the URL to return the user to after authorization is complete. - * Populated with additional parameters - */ - redirect_uri: string; -}; From 3f55efba9738facca3ff9483cfdbb36d4032cc74 Mon Sep 17 00:00:00 2001 From: Eugeny Koshaev Date: Wed, 11 Nov 2026 02:45:25 +0300 Subject: [PATCH 07/12] fix lint --- src/auth/OAuth.ts | 50 +++++++++++++++++++++++++++++++++++++- src/dbScheme/thirdparty.ts | 20 +++++++-------- 2 files changed, 59 insertions(+), 11 deletions(-) diff --git a/src/auth/OAuth.ts b/src/auth/OAuth.ts index ee14443..e33efa2 100644 --- a/src/auth/OAuth.ts +++ b/src/auth/OAuth.ts @@ -1,3 +1,44 @@ +/** + * Possible {@link https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-17#section-3.2.4 | OAuth error codes} + */ +export declare enum OAuthErrorCode { + /** + * The request is missing a required parameter, includes an unsupported parameter value + * (other than grant type), repeats a parameter, includes multiple credentials, utilizes + * more than one mechanism for authenticating the client, contains a code_verifier + * although no code_challenge was sent in the authorization request, or is otherwise malformed + */ + invalidRequest = 'invalid_request', + + /** + * Client authentication failed (e.g., unknown client, no client authentication included, + * or unsupported authentication method). + */ + invalidClient = 'invalid_client', + + /** + * The provided authorization grant (e.g., authorization code, resource owner credentials) + * or refresh token is invalid, expired, revoked, does not match the redirect URI used in + * the authorization request, or was issued to another client. + */ + invalidGrant = 'invalid_grant', + + /** + * The authenticated client is not authorized to use this authorization grant type + */ + unauthorizedClient = 'unauthorized_client', + + /** + * The authorization grant type is not supported by the authorization server + */ + unsupportedGrantType = 'unsupported_grant_type', + + /** + * requested scope is invalid, unknown, malformed, or exceeds the scope granted by the resource owner + */ + invalidScope = 'invalid_scope' +} + /** * Authorization request */ @@ -59,6 +100,13 @@ export interface OAuthResponse { * Authorization error */ export interface OAuthError { - error: string; + /** + * Error code + */ + error: OAuthErrorCode; + + /** + * Optional text providing additional information + */ error_description?: string; } diff --git a/src/dbScheme/thirdparty.ts b/src/dbScheme/thirdparty.ts index 658c6f9..8ebba05 100644 --- a/src/dbScheme/thirdparty.ts +++ b/src/dbScheme/thirdparty.ts @@ -1,4 +1,4 @@ -import type { ObjectId, Timestamp } from "bson"; +import type { ObjectId, Timestamp } from 'bson'; /** * Permissions granted to token @@ -12,45 +12,45 @@ export interface ThirdpartyDBScheme { /** * External token identifier */ - _id: ObjectId, + _id: ObjectId; /** * Token owner id */ - userId: string, + userId: string; /** * Unique JSON Web Token Identifier */ - jti: string, + jti: string; /** * Last characters of the token, used to tell tokens apart in user settings */ - preview: string, + preview: string; /** * What token can be used for */ - permissions: TokenPermissions[], + permissions: TokenPermissions[]; /** * Label set by user */ - lable: string, + lable: string; /** * Last time token was used */ - lastUsedAt: Timestamp | null, + lastUsedAt: Timestamp | null; /** * Usage count */ - requestCount: number, + requestCount: number; /** * Creation date */ - createdAt: Timestamp + createdAt: Timestamp; } From 6ce66c3c9f02046fd08effa61e0b1243b661ba96 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 10 Nov 2026 23:45:58 +0000 Subject: [PATCH 08/12] Lint and build --- build/index.d.ts | 3 +- build/index.js | 3 +- build/src/auth/OAuth.d.ts | 96 ++++++++++++++++++++++++++++++ build/src/auth/OAuth.js | 4 ++ build/src/dbScheme/thirdparty.d.ts | 46 ++++++++++++++ build/src/dbScheme/thirdparty.js | 2 + 6 files changed, 152 insertions(+), 2 deletions(-) create mode 100644 build/src/auth/OAuth.d.ts create mode 100644 build/src/auth/OAuth.js create mode 100644 build/src/dbScheme/thirdparty.d.ts create mode 100644 build/src/dbScheme/thirdparty.js diff --git a/build/index.d.ts b/build/index.d.ts index d5601d7..7f65c09 100644 --- a/build/index.d.ts +++ b/build/index.d.ts @@ -1,6 +1,6 @@ export * from './src/ai/stream'; export * from './src/auth/tokensPair'; -export * from './src/auth/mcp/authorizationEndpoint'; +export * from './src/auth/OAuth'; export * from './src/base/businessOperation/businessOperation'; export * from './src/billing/planProlongrationPayload'; export * from './src/base/event/affectedUser'; @@ -35,6 +35,7 @@ export * from './src/dbScheme/workspace'; export * from './src/dbScheme/bankCard'; export * from './src/dbScheme/sso'; export * from './src/dbScheme/projectEventGroupingPattern'; +export * from './src/dbScheme/thirdparty'; export * from './src/notifications/createProjectNotifications'; export * from './src/notifications/receiveTypes'; export * from './src/notifications/updateProjectNotifications'; diff --git a/build/index.js b/build/index.js index ee6a2e2..e3ec34a 100644 --- a/build/index.js +++ b/build/index.js @@ -16,7 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) { Object.defineProperty(exports, "__esModule", { value: true }); __exportStar(require("./src/ai/stream"), exports); __exportStar(require("./src/auth/tokensPair"), exports); -__exportStar(require("./src/auth/mcp/authorizationEndpoint"), exports); +__exportStar(require("./src/auth/OAuth"), exports); __exportStar(require("./src/base/businessOperation/businessOperation"), exports); __exportStar(require("./src/billing/planProlongrationPayload"), exports); __exportStar(require("./src/base/event/affectedUser"), exports); @@ -51,6 +51,7 @@ __exportStar(require("./src/dbScheme/workspace"), exports); __exportStar(require("./src/dbScheme/bankCard"), exports); __exportStar(require("./src/dbScheme/sso"), exports); __exportStar(require("./src/dbScheme/projectEventGroupingPattern"), exports); +__exportStar(require("./src/dbScheme/thirdparty"), exports); __exportStar(require("./src/notifications/createProjectNotifications"), exports); __exportStar(require("./src/notifications/receiveTypes"), exports); __exportStar(require("./src/notifications/updateProjectNotifications"), exports); diff --git a/build/src/auth/OAuth.d.ts b/build/src/auth/OAuth.d.ts new file mode 100644 index 0000000..78a642f --- /dev/null +++ b/build/src/auth/OAuth.d.ts @@ -0,0 +1,96 @@ +/** + * Possible {@link https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-17#section-3.2.4 | OAuth error codes} + */ +export declare enum OAuthErrorCode { + /** + * The request is missing a required parameter, includes an unsupported parameter value + * (other than grant type), repeats a parameter, includes multiple credentials, utilizes + * more than one mechanism for authenticating the client, contains a code_verifier + * although no code_challenge was sent in the authorization request, or is otherwise malformed + */ + invalidRequest = "invalid_request", + /** + * Client authentication failed (e.g., unknown client, no client authentication included, + * or unsupported authentication method). + */ + invalidClient = "invalid_client", + /** + * The provided authorization grant (e.g., authorization code, resource owner credentials) + * or refresh token is invalid, expired, revoked, does not match the redirect URI used in + * the authorization request, or was issued to another client. + */ + invalidGrant = "invalid_grant", + /** + * The authenticated client is not authorized to use this authorization grant type + */ + unauthorizedClient = "unauthorized_client", + /** + * The authorization grant type is not supported by the authorization server + */ + unsupportedGrantType = "unsupported_grant_type", + /** + * requested scope is invalid, unknown, malformed, or exceeds the scope granted by the resource owner + */ + invalidScope = "invalid_scope" +} +/** + * Authorization request + */ +export interface OAuthRequest { + /** + * Client Identifier + */ + client_id: string; + /** + * Indicates the URL to return the user to after authorization is complete + */ + redirect_uri: string; + /** + * Opaque value used by the client to maintain state between the request and callback + */ + state?: string; + /** + * Base64-URL-encoded string of the SHA256 hash of the code verifier + */ + code_challenge: string; + /** + * The code challenge transformation method + */ + code_challenge_method: 'S256'; + /** + * Target service or resource to which access is being requested. + * MUST be an absolute URI + */ + resource?: string; + /** + * Additional access requested by the application + */ + scope?: string; + /** + * URL string that references a logo for the client + */ + logoUrl?: string; +} +/** + * Authorization response + */ +export interface OAuthResponse { + /** + * Indicates the URL to return the user to after authorization is complete. + * Populated with additional parameters + */ + redirect_uri: string; +} +/** + * Authorization error + */ +export interface OAuthError { + /** + * Error code + */ + error: OAuthErrorCode; + /** + * Optional text providing additional information + */ + error_description?: string; +} diff --git a/build/src/auth/OAuth.js b/build/src/auth/OAuth.js new file mode 100644 index 0000000..89f6374 --- /dev/null +++ b/build/src/auth/OAuth.js @@ -0,0 +1,4 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +; +; diff --git a/build/src/dbScheme/thirdparty.d.ts b/build/src/dbScheme/thirdparty.d.ts new file mode 100644 index 0000000..c0c97e0 --- /dev/null +++ b/build/src/dbScheme/thirdparty.d.ts @@ -0,0 +1,46 @@ +import type { ObjectId, Timestamp } from 'bson'; +/** + * Permissions granted to token + */ +export type TokenPermissions = 'read' | 'write'; +/** + * Database representation of active to third-party clients + */ +export interface ThirdpartyDBScheme { + /** + * External token identifier + */ + _id: ObjectId; + /** + * Token owner id + */ + userId: string; + /** + * Unique JSON Web Token Identifier + */ + jti: string; + /** + * Last characters of the token, used to tell tokens apart in user settings + */ + preview: string; + /** + * What token can be used for + */ + permissions: TokenPermissions[]; + /** + * Label set by user + */ + lable: string; + /** + * Last time token was used + */ + lastUsedAt: Timestamp | null; + /** + * Usage count + */ + requestCount: number; + /** + * Creation date + */ + createdAt: Timestamp; +} diff --git a/build/src/dbScheme/thirdparty.js b/build/src/dbScheme/thirdparty.js new file mode 100644 index 0000000..c8ad2e5 --- /dev/null +++ b/build/src/dbScheme/thirdparty.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); From 14c0e90fa2874e3fa67e842ab29f6a1c602bd6ed Mon Sep 17 00:00:00 2001 From: Eugeny Koshaev Date: Thu, 12 Nov 2026 18:34:53 +0300 Subject: [PATCH 09/12] chore(dbScheme): rename thirdparty to oauthClient --- index.ts | 4 ++-- src/auth/{OAuth.ts => oauth.ts} | 0 src/dbScheme/{thirdparty.ts => oauthClient.ts} | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename src/auth/{OAuth.ts => oauth.ts} (100%) rename src/dbScheme/{thirdparty.ts => oauthClient.ts} (95%) diff --git a/index.ts b/index.ts index b312522..0af41f9 100644 --- a/index.ts +++ b/index.ts @@ -1,7 +1,7 @@ export * from './src/ai/stream'; export * from './src/auth/tokensPair'; -export * from './src/auth/OAuth'; +export * from './src/auth/oauth'; export * from './src/base/businessOperation/businessOperation'; @@ -41,7 +41,7 @@ export * from './src/dbScheme/workspace'; export * from './src/dbScheme/bankCard'; export * from './src/dbScheme/sso'; export * from './src/dbScheme/projectEventGroupingPattern'; -export * from './src/dbScheme/thirdparty'; +export * from './src/dbScheme/oauthClient'; export * from './src/notifications/createProjectNotifications'; export * from './src/notifications/receiveTypes'; diff --git a/src/auth/OAuth.ts b/src/auth/oauth.ts similarity index 100% rename from src/auth/OAuth.ts rename to src/auth/oauth.ts diff --git a/src/dbScheme/thirdparty.ts b/src/dbScheme/oauthClient.ts similarity index 95% rename from src/dbScheme/thirdparty.ts rename to src/dbScheme/oauthClient.ts index 8ebba05..409321b 100644 --- a/src/dbScheme/thirdparty.ts +++ b/src/dbScheme/oauthClient.ts @@ -8,7 +8,7 @@ export type TokenPermissions = 'read' | 'write'; /** * Database representation of active to third-party clients */ -export interface ThirdpartyDBScheme { +export interface OAuthClientDBScheme { /** * External token identifier */ From 35324c30686a1fd89fbfb14fec2750ed7f04de06 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 12 Nov 2026 15:36:37 +0000 Subject: [PATCH 10/12] Lint and build --- build/index.d.ts | 4 +- build/index.js | 4 +- build/src/auth/oauth.d.ts | 96 +++++++++++++++++++++++++++++ build/src/auth/oauth.js | 4 ++ build/src/dbScheme/oauthClient.d.ts | 46 ++++++++++++++ build/src/dbScheme/oauthClient.js | 2 + 6 files changed, 152 insertions(+), 4 deletions(-) create mode 100644 build/src/auth/oauth.d.ts create mode 100644 build/src/auth/oauth.js create mode 100644 build/src/dbScheme/oauthClient.d.ts create mode 100644 build/src/dbScheme/oauthClient.js diff --git a/build/index.d.ts b/build/index.d.ts index 7f65c09..49c0af5 100644 --- a/build/index.d.ts +++ b/build/index.d.ts @@ -1,6 +1,6 @@ export * from './src/ai/stream'; export * from './src/auth/tokensPair'; -export * from './src/auth/OAuth'; +export * from './src/auth/oauth'; export * from './src/base/businessOperation/businessOperation'; export * from './src/billing/planProlongrationPayload'; export * from './src/base/event/affectedUser'; @@ -35,7 +35,7 @@ export * from './src/dbScheme/workspace'; export * from './src/dbScheme/bankCard'; export * from './src/dbScheme/sso'; export * from './src/dbScheme/projectEventGroupingPattern'; -export * from './src/dbScheme/thirdparty'; +export * from './src/dbScheme/oauthClient'; export * from './src/notifications/createProjectNotifications'; export * from './src/notifications/receiveTypes'; export * from './src/notifications/updateProjectNotifications'; diff --git a/build/index.js b/build/index.js index e3ec34a..b56051b 100644 --- a/build/index.js +++ b/build/index.js @@ -16,7 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) { Object.defineProperty(exports, "__esModule", { value: true }); __exportStar(require("./src/ai/stream"), exports); __exportStar(require("./src/auth/tokensPair"), exports); -__exportStar(require("./src/auth/OAuth"), exports); +__exportStar(require("./src/auth/oauth"), exports); __exportStar(require("./src/base/businessOperation/businessOperation"), exports); __exportStar(require("./src/billing/planProlongrationPayload"), exports); __exportStar(require("./src/base/event/affectedUser"), exports); @@ -51,7 +51,7 @@ __exportStar(require("./src/dbScheme/workspace"), exports); __exportStar(require("./src/dbScheme/bankCard"), exports); __exportStar(require("./src/dbScheme/sso"), exports); __exportStar(require("./src/dbScheme/projectEventGroupingPattern"), exports); -__exportStar(require("./src/dbScheme/thirdparty"), exports); +__exportStar(require("./src/dbScheme/oauthClient"), exports); __exportStar(require("./src/notifications/createProjectNotifications"), exports); __exportStar(require("./src/notifications/receiveTypes"), exports); __exportStar(require("./src/notifications/updateProjectNotifications"), exports); diff --git a/build/src/auth/oauth.d.ts b/build/src/auth/oauth.d.ts new file mode 100644 index 0000000..78a642f --- /dev/null +++ b/build/src/auth/oauth.d.ts @@ -0,0 +1,96 @@ +/** + * Possible {@link https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-17#section-3.2.4 | OAuth error codes} + */ +export declare enum OAuthErrorCode { + /** + * The request is missing a required parameter, includes an unsupported parameter value + * (other than grant type), repeats a parameter, includes multiple credentials, utilizes + * more than one mechanism for authenticating the client, contains a code_verifier + * although no code_challenge was sent in the authorization request, or is otherwise malformed + */ + invalidRequest = "invalid_request", + /** + * Client authentication failed (e.g., unknown client, no client authentication included, + * or unsupported authentication method). + */ + invalidClient = "invalid_client", + /** + * The provided authorization grant (e.g., authorization code, resource owner credentials) + * or refresh token is invalid, expired, revoked, does not match the redirect URI used in + * the authorization request, or was issued to another client. + */ + invalidGrant = "invalid_grant", + /** + * The authenticated client is not authorized to use this authorization grant type + */ + unauthorizedClient = "unauthorized_client", + /** + * The authorization grant type is not supported by the authorization server + */ + unsupportedGrantType = "unsupported_grant_type", + /** + * requested scope is invalid, unknown, malformed, or exceeds the scope granted by the resource owner + */ + invalidScope = "invalid_scope" +} +/** + * Authorization request + */ +export interface OAuthRequest { + /** + * Client Identifier + */ + client_id: string; + /** + * Indicates the URL to return the user to after authorization is complete + */ + redirect_uri: string; + /** + * Opaque value used by the client to maintain state between the request and callback + */ + state?: string; + /** + * Base64-URL-encoded string of the SHA256 hash of the code verifier + */ + code_challenge: string; + /** + * The code challenge transformation method + */ + code_challenge_method: 'S256'; + /** + * Target service or resource to which access is being requested. + * MUST be an absolute URI + */ + resource?: string; + /** + * Additional access requested by the application + */ + scope?: string; + /** + * URL string that references a logo for the client + */ + logoUrl?: string; +} +/** + * Authorization response + */ +export interface OAuthResponse { + /** + * Indicates the URL to return the user to after authorization is complete. + * Populated with additional parameters + */ + redirect_uri: string; +} +/** + * Authorization error + */ +export interface OAuthError { + /** + * Error code + */ + error: OAuthErrorCode; + /** + * Optional text providing additional information + */ + error_description?: string; +} diff --git a/build/src/auth/oauth.js b/build/src/auth/oauth.js new file mode 100644 index 0000000..89f6374 --- /dev/null +++ b/build/src/auth/oauth.js @@ -0,0 +1,4 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +; +; diff --git a/build/src/dbScheme/oauthClient.d.ts b/build/src/dbScheme/oauthClient.d.ts new file mode 100644 index 0000000..ed63dde --- /dev/null +++ b/build/src/dbScheme/oauthClient.d.ts @@ -0,0 +1,46 @@ +import type { ObjectId, Timestamp } from 'bson'; +/** + * Permissions granted to token + */ +export type TokenPermissions = 'read' | 'write'; +/** + * Database representation of active to third-party clients + */ +export interface OAuthClientDBScheme { + /** + * External token identifier + */ + _id: ObjectId; + /** + * Token owner id + */ + userId: string; + /** + * Unique JSON Web Token Identifier + */ + jti: string; + /** + * Last characters of the token, used to tell tokens apart in user settings + */ + preview: string; + /** + * What token can be used for + */ + permissions: TokenPermissions[]; + /** + * Label set by user + */ + lable: string; + /** + * Last time token was used + */ + lastUsedAt: Timestamp | null; + /** + * Usage count + */ + requestCount: number; + /** + * Creation date + */ + createdAt: Timestamp; +} diff --git a/build/src/dbScheme/oauthClient.js b/build/src/dbScheme/oauthClient.js new file mode 100644 index 0000000..c8ad2e5 --- /dev/null +++ b/build/src/dbScheme/oauthClient.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); From bde3082955202a9e29e75d2d54d966ae3da79290 Mon Sep 17 00:00:00 2001 From: Eugeny Koshaev Date: Fri, 13 Nov 2026 01:55:15 +0300 Subject: [PATCH 11/12] chore(oauthClient): add clientId parameter, remove preview parameter, fix JSDoc --- src/dbScheme/oauthClient.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/dbScheme/oauthClient.ts b/src/dbScheme/oauthClient.ts index 409321b..cc2a7b9 100644 --- a/src/dbScheme/oauthClient.ts +++ b/src/dbScheme/oauthClient.ts @@ -6,11 +6,11 @@ import type { ObjectId, Timestamp } from 'bson'; export type TokenPermissions = 'read' | 'write'; /** - * Database representation of active to third-party clients + * Database representation of active to oauth client */ export interface OAuthClientDBScheme { /** - * External token identifier + * External client identifier */ _id: ObjectId; @@ -20,17 +20,17 @@ export interface OAuthClientDBScheme { userId: string; /** - * Unique JSON Web Token Identifier + * User agent id */ - jti: string; + clientId: string; /** - * Last characters of the token, used to tell tokens apart in user settings + * Unique JSON Web Token Identifier */ - preview: string; + jti: string; /** - * What token can be used for + * What client is allowed to do */ permissions: TokenPermissions[]; @@ -40,7 +40,7 @@ export interface OAuthClientDBScheme { lable: string; /** - * Last time token was used + * Last time the client interacted with hawk api */ lastUsedAt: Timestamp | null; From 6da5a686986bfa37ac4be49ef6675113f91c8662 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 12 Nov 2026 22:55:49 +0000 Subject: [PATCH 12/12] Lint and build --- build/src/dbScheme/oauthClient.d.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/build/src/dbScheme/oauthClient.d.ts b/build/src/dbScheme/oauthClient.d.ts index ed63dde..59da10b 100644 --- a/build/src/dbScheme/oauthClient.d.ts +++ b/build/src/dbScheme/oauthClient.d.ts @@ -4,11 +4,11 @@ import type { ObjectId, Timestamp } from 'bson'; */ export type TokenPermissions = 'read' | 'write'; /** - * Database representation of active to third-party clients + * Database representation of active to oauth client */ export interface OAuthClientDBScheme { /** - * External token identifier + * External client identifier */ _id: ObjectId; /** @@ -16,15 +16,15 @@ export interface OAuthClientDBScheme { */ userId: string; /** - * Unique JSON Web Token Identifier + * User agent id */ - jti: string; + clientId: string; /** - * Last characters of the token, used to tell tokens apart in user settings + * Unique JSON Web Token Identifier */ - preview: string; + jti: string; /** - * What token can be used for + * What client is allowed to do */ permissions: TokenPermissions[]; /** @@ -32,7 +32,7 @@ export interface OAuthClientDBScheme { */ lable: string; /** - * Last time token was used + * Last time the client interacted with hawk api */ lastUsedAt: Timestamp | null; /**