Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions apps/activitypub/src/api/activitypub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,13 @@ export interface GetBlockedDomainsResponse {
next: string | null;
}

export enum PostType {
Note = 0,
Article = 1,
Tombstone = 2
}
export const PostType = {
Note: 0,
Article: 1,
Tombstone: 2
} as const;

export type PostType = (typeof PostType)[keyof typeof PostType];

export interface Post {
id: string;
Expand Down Expand Up @@ -242,12 +244,22 @@ export const isApiError = (error: unknown): error is ApiError => {
};

export class ActivityPubAPI {
private readonly apiUrl: URL;
private readonly authApiUrl: URL;
private readonly handle: string;
private readonly fetch: (resource: URL, init?: RequestInit) => Promise<Response>;

constructor(
private readonly apiUrl: URL,
private readonly authApiUrl: URL,
private readonly handle: string,
private readonly fetch: (resource: URL, init?: RequestInit) => Promise<Response> = window.fetch.bind(window)
) {}
apiUrl: URL,
authApiUrl: URL,
handle: string,
fetch: (resource: URL, init?: RequestInit) => Promise<Response> = window.fetch.bind(window)
) {
this.apiUrl = apiUrl;
this.authApiUrl = authApiUrl;
this.handle = handle;
this.fetch = fetch;
}

private async getToken(): Promise<string | null> {
try {
Expand Down
1 change: 1 addition & 0 deletions apps/activitypub/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true,

/* Path aliases */
Expand Down
1 change: 1 addition & 0 deletions apps/admin-x-design-system/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"],
Expand Down
14 changes: 11 additions & 3 deletions apps/admin-x-framework/src/utils/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ export interface ErrorResponse {
}

export class APIError extends Error {
public readonly response?: Response;
public readonly data?: unknown;

constructor(
public readonly response?: Response,
public readonly data?: unknown,
response?: Response,
data?: unknown,
message?: string,
errorOptions?: ErrorOptions
) {
Expand All @@ -26,17 +29,22 @@ export class APIError extends Error {
}

super(message || 'Something went wrong, please try again.', errorOptions);
this.response = response;
this.data = data;
}
}

export class JSONError extends APIError {
public readonly data?: ErrorResponse;

constructor(
response: Response,
public readonly data?: ErrorResponse,
data?: ErrorResponse,
message?: string,
errorOptions?: ErrorOptions
) {
super(response, data, message, errorOptions);
this.data = data;
}
}

Expand Down
1 change: 1 addition & 0 deletions apps/admin-x-framework/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src", "test"],
Expand Down
2 changes: 1 addition & 1 deletion apps/comments-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tryghost/comments-ui",
"version": "1.4.0",
"version": "1.4.1",
"license": "MIT",
"repository": "https://github.com/TryGhost/Ghost",
"author": "Ghost Foundation",
Expand Down
1 change: 1 addition & 0 deletions apps/comments-ui/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true,

/* Vitest */
Expand Down
2 changes: 1 addition & 1 deletion apps/portal/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tryghost/portal",
"version": "2.67.0",
"version": "2.67.1",
"license": "MIT",
"repository": "https://github.com/TryGhost/Ghost",
"author": "Ghost Foundation",
Expand Down
2 changes: 1 addition & 1 deletion apps/portal/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
// "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
// "erasableSyntaxOnly": true, /* Do not allow runtime constructs that are not part of ECMAScript. */
"erasableSyntaxOnly": true, /* Do not allow runtime constructs that are not part of ECMAScript. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
Expand Down
1 change: 1 addition & 0 deletions apps/posts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true,

/* Path aliases */
Expand Down
2 changes: 1 addition & 1 deletion apps/signup-form/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tryghost/signup-form",
"version": "0.3.8",
"version": "0.3.9",
"license": "MIT",
"repository": "https://github.com/TryGhost/Ghost",
"author": "Ghost Foundation",
Expand Down
1 change: 1 addition & 0 deletions apps/signup-form/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"],
Expand Down
1 change: 1 addition & 0 deletions apps/stats/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true,

/* Path aliases */
Expand Down
8 changes: 5 additions & 3 deletions e2e/data-factory/persistence/adapters/knex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
* Knex-based persistence adapter for direct database access
*/
export class KnexPersistenceAdapter implements PersistenceAdapter {
constructor(
private db: Knex
) {}
private db: Knex;

Check warning on line 8 in e2e/data-factory/persistence/adapters/knex.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Member 'db' is never reassigned; mark it as `readonly`.

See more on https://sonarcloud.io/project/issues?id=TryGhost_Ghost&issues=AZ0qnYQqlpSFCu4-jzCp&open=AZ0qnYQqlpSFCu4-jzCp&pullRequest=26915

constructor(db: Knex) {
this.db = db;
}

async insert<T>(entityType: string, data: T): Promise<T> {
// entityType is the table name for Knex
Expand Down
4 changes: 3 additions & 1 deletion e2e/helpers/pages/admin/posts/post/post-preview-frames.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import {FrameLocator, Locator, Page} from '@playwright/test';

class PreviewFrame {
constructor(protected readonly page: Page) {
protected readonly page: Page;

constructor(page: Page) {
this.page = page;
}

Expand Down
1 change: 1 addition & 0 deletions e2e/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
/* Interop Constraints */
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
"erasableSyntaxOnly": true, /* Do not allow runtime constructs that are not part of ECMAScript. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,22 @@
}

export class ActivityPubService {
private knex: Knex;

Check warning on line 20 in ghost/core/core/server/services/activitypub/activity-pub-service.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Member 'knex' is never reassigned; mark it as `readonly`.

See more on https://sonarcloud.io/project/issues?id=TryGhost_Ghost&issues=AZ0qnYP0lpSFCu4-jzCl&open=AZ0qnYP0lpSFCu4-jzCl&pullRequest=26915
private siteUrl: URL;

Check warning on line 21 in ghost/core/core/server/services/activitypub/activity-pub-service.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Member 'siteUrl' is never reassigned; mark it as `readonly`.

See more on https://sonarcloud.io/project/issues?id=TryGhost_Ghost&issues=AZ0qnYP0lpSFCu4-jzCm&open=AZ0qnYP0lpSFCu4-jzCm&pullRequest=26915
private logging: Logger;

Check warning on line 22 in ghost/core/core/server/services/activitypub/activity-pub-service.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Member 'logging' is never reassigned; mark it as `readonly`.

See more on https://sonarcloud.io/project/issues?id=TryGhost_Ghost&issues=AZ0qnYP0lpSFCu4-jzCn&open=AZ0qnYP0lpSFCu4-jzCn&pullRequest=26915
private identityTokenService: IdentityTokenService;

Check warning on line 23 in ghost/core/core/server/services/activitypub/activity-pub-service.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Member 'identityTokenService' is never reassigned; mark it as `readonly`.

See more on https://sonarcloud.io/project/issues?id=TryGhost_Ghost&issues=AZ0qnYP0lpSFCu4-jzCo&open=AZ0qnYP0lpSFCu4-jzCo&pullRequest=26915

constructor(
private knex: Knex,
private siteUrl: URL,
private logging: Logger,
private identityTokenService: IdentityTokenService
) {}
knex: Knex,
siteUrl: URL,
logging: Logger,
identityTokenService: IdentityTokenService
) {
this.knex = knex;
this.siteUrl = siteUrl;
this.logging = logging;
this.identityTokenService = identityTokenService;
}

getExpectedWebhooks(secret: string): ExpectedWebhook[] {
return [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import {sign} from 'jsonwebtoken';

export class IdentityTokenService {
private privateKey: string;

Check warning on line 4 in ghost/core/core/server/services/identity-tokens/identity-token-service.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Member 'privateKey' is never reassigned; mark it as `readonly`.

See more on https://sonarcloud.io/project/issues?id=TryGhost_Ghost&issues=AZ0qnYMylpSFCu4-jzCi&open=AZ0qnYMylpSFCu4-jzCi&pullRequest=26915
private issuer: string;

Check warning on line 5 in ghost/core/core/server/services/identity-tokens/identity-token-service.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Member 'issuer' is never reassigned; mark it as `readonly`.

See more on https://sonarcloud.io/project/issues?id=TryGhost_Ghost&issues=AZ0qnYMylpSFCu4-jzCj&open=AZ0qnYMylpSFCu4-jzCj&pullRequest=26915
private keyId: string;

Check warning on line 6 in ghost/core/core/server/services/identity-tokens/identity-token-service.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Member 'keyId' is never reassigned; mark it as `readonly`.

See more on https://sonarcloud.io/project/issues?id=TryGhost_Ghost&issues=AZ0qnYMylpSFCu4-jzCk&open=AZ0qnYMylpSFCu4-jzCk&pullRequest=26915

constructor(
private privateKey: string,
private issuer: string,
private keyId: string
) {}
privateKey: string,
issuer: string,
keyId: string
) {
this.privateKey = privateKey;
this.issuer = issuer;
this.keyId = keyId;
}

async getTokenForUser(email: string, role?: string) {
const claims: Record<string, string> = {
Expand Down
1 change: 1 addition & 0 deletions ghost/core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
/* Interop Constraints */
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
"erasableSyntaxOnly": true, /* Do not allow runtime constructs that are not part of ECMAScript. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
Expand Down
Loading