@openpeepshq/core 0.10.0 → 0.11.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.
@@ -4,4 +4,5 @@ export declare const profileFilters: {
4
4
  type: (type: string) => SqlFilter;
5
5
  notIdIn: (ids: string[]) => SqlFilter | undefined;
6
6
  activityScorePositive: (start?: Date, end?: Date) => SqlFilter;
7
+ discoverable: () => SqlFilter;
7
8
  };
@@ -1,4 +1,4 @@
1
- import { eq, gt, ne, notInArray } from 'drizzle-orm';
1
+ import { eq, gt, isNull, ne, notInArray, or, sql } from 'drizzle-orm';
2
2
  import { profiles } from '../schema/documents.js';
3
3
  import { profileActivityScoreExpr } from '../queries/activity.js';
4
4
  import { pgSql } from './types.js';
@@ -7,4 +7,10 @@ export const profileFilters = {
7
7
  type: (type) => pgSql(eq(profiles.type, type)),
8
8
  notIdIn: (ids) => ids.length ? pgSql(notInArray(profiles.id, ids)) : undefined,
9
9
  activityScorePositive: (start, end) => pgSql(gt(profileActivityScoreExpr(profiles, { start, end }), 0)),
10
+ // Writer contract: only body->>'discoverable' = 'false' hides a profile;
11
+ // an absent flag stays listed. That is the single canonical encoding — the
12
+ // profile screens persist it via PATCH /profiles/current, and
13
+ // loadLocalActor (federation/actors.ts) projects the same boolean onto the
14
+ // ActivityPub actor.
15
+ discoverable: () => pgSql(or(isNull(sql `${profiles.body}->>'discoverable'`), sql `${profiles.body}->>'discoverable' <> 'false'`)),
10
16
  };
@@ -3,7 +3,9 @@ export declare const findProfile: (profileId: string) => Promise<ProfileWithMeta
3
3
  export declare const findProfileByHandle: (handle: string) => Promise<ProfileWithMeta | undefined>;
4
4
  export { findProfileByHandleAndDomain, findProfileByUri, } from '../federation/profiles';
5
5
  export declare const existsProfileByHandle: (handle: string) => Promise<boolean>;
6
- export declare const listProfiles: (viewer?: ProfileWithMeta) => Promise<ProfileWithMeta[]>;
6
+ export declare const listProfiles: (viewer?: ProfileWithMeta, options?: {
7
+ directoryView?: boolean;
8
+ }) => Promise<ProfileWithMeta[]>;
7
9
  export declare const listProfilesByRole: (role: Role) => Promise<ProfileWithMeta[]>;
8
10
  export declare const listProfilesByAccount: (account: Account) => Promise<ProfileWithMeta[]>;
9
11
  export declare const listProfilesWithCapabilities: (capabilities: string[]) => Promise<ProfileWithMeta[]>;
@@ -1,7 +1,7 @@
1
1
  import { accountProfileRelation, baseProfilesMapping, membersRelation, profileRoleRelation, } from './mapping.js';
2
2
  import { allpeepDb } from '../db/index.js';
3
3
  import { profileFilters } from '../db/pg/filters/index.js';
4
- import { blockedPairIds, getUniqueBy } from '@openpeepshq/common/lib';
4
+ import { blockedPairIds, checkRoleCapabilities, getUniqueBy, } from '@openpeepshq/common/lib';
5
5
  import { rolesMapping } from '../roles/mapping.js';
6
6
  import { findRolesByCapabilities } from '../roles/finders.js';
7
7
  import { expandProfiles, followFinder } from './helpers.js';
@@ -13,10 +13,19 @@ export const findProfile = (profileId) => getProfile(profileId);
13
13
  export const findProfileByHandle = (handle) => getProfileByHandle(handle);
14
14
  export { findProfileByHandleAndDomain, findProfileByUri, } from '../federation/profiles.js';
15
15
  export const existsProfileByHandle = (handle) => getProfileByHandle(handle, true).then(Boolean);
16
- export const listProfiles = (viewer) => allpeepDb()
16
+ // Mirrors canSeeGroupFilter: member-directory viewers without
17
+ // core-profiles-read — including anonymous public-community visitors — only
18
+ // see profiles that have not opted out of the directory. It ands the same
19
+ // `profileFilters.discoverable()` SQL predicate defined in
20
+ // db/pg/filters/profiles.ts, so readers can jump straight to the predicate.
21
+ const directoryFilter = (viewer) => checkRoleCapabilities(viewer?.roles ?? [], ['core-profiles-read']).success
22
+ ? undefined
23
+ : profileFilters.discoverable();
24
+ export const listProfiles = (viewer, options = {}) => allpeepDb()
17
25
  .then(({ db }) => baseProfilesMapping
18
26
  .filter(profileFilters.notGuest())
19
27
  .filter(profileFilters.notIdIn(blockedPairIds(viewer)))
28
+ .filter(options.directoryView ? directoryFilter(viewer) : undefined)
20
29
  .all(db))
21
30
  .then(expandProfiles);
22
31
  export const listProfilesByRole = (role) => allpeepDb()
@@ -24,6 +24,45 @@ export declare const getSentryService: () => SentryService | undefined;
24
24
  * — never fall back to `NODE_ENV` (Docker images always set that to production).
25
25
  */
26
26
  export declare const resolveSentryEnvironment: (explicit?: string) => string;
27
+ /**
28
+ * Integration names of `@sentry/node@10.x`'s vendored DB instrumentations
29
+ * (the SDK vendors its own copies; 9.x's standalone
30
+ * `@opentelemetry/instrumentation-*` packages left the tree). They emit the
31
+ * `db.user` span attribute unconditionally — GHSA-qqmp-wf37-98f9's behavior,
32
+ * invisible to `pnpm audit` because the copies live inside the audited-clean
33
+ * package. The only one that can ever match a module in this repo is
34
+ * Postgres (drizzle/pg); the rest are inert here, but they are dropped
35
+ * together so this list stays the complete set of vendored `db.user`
36
+ * emitters.
37
+ *
38
+ * Trade-off (documented decision): the filter matches on the integration
39
+ * `name`, and the SDK's `filterDuplicates` resolves duplicate integrations by
40
+ * name too. A future *user-supplied* integration that happens to be named
41
+ * exactly `Postgres`/`Mysql`/`Mysql2`/`Tedious`/`Knex` would therefore also
42
+ * be dropped from the final set. That is accepted: the five names are the
43
+ * SDK's own vendored names, so a user integration carrying one would collide
44
+ * with the vendored copy anyway, and dropping both is the safe outcome.
45
+ *
46
+ * Layout provenance: this list is pinned by the canary in
47
+ * `sentry.test.ts`, which resolves the vendored-instrumentation path from the
48
+ * installed `@sentry/node` package — that resolved path, not any directory
49
+ * names quoted in comments, is the source of truth for the layout.
50
+ */
51
+ export declare const VENDORED_DB_INTEGRATION_NAMES: readonly ["Postgres", "Mysql", "Mysql2", "Tedious", "Knex"];
52
+ /**
53
+ * The callable shape `initSentry` passes to `Sentry.init`'s `integrations`
54
+ * option: a function that maps the SDK's own auto-detected default list to a
55
+ * filtered subset. The function form is load-bearing — a callable *replaces*
56
+ * the default set entirely, whereas the array form *keeps* the defaults and
57
+ * overlays by name (which would re-admit the five DB integrations).
58
+ */
59
+ export type SentryDefaultIntegrations = (integrations: ReturnType<typeof Sentry.getAutoPerformanceIntegrations>) => ReturnType<typeof Sentry.getAutoPerformanceIntegrations>;
60
+ /**
61
+ * Removes the vendored DB integrations (see
62
+ * `VENDORED_DB_INTEGRATION_NAMES`) from the SDK default set so no `db.user`
63
+ * attribute is emitted. Wired into `Sentry.init` below as the callable form.
64
+ */
65
+ export declare const withoutVendoredDbIntegrations: SentryDefaultIntegrations;
27
66
  /** Re-apply community tags on the current isolation scope (per-request). */
28
67
  export declare const applyCommunitySentryTags: () => void;
29
68
  /**
@@ -40,6 +40,43 @@ export const resolveSentryEnvironment = (explicit) => {
40
40
  return fromEnvironment;
41
41
  return 'local';
42
42
  };
43
+ /**
44
+ * Integration names of `@sentry/node@10.x`'s vendored DB instrumentations
45
+ * (the SDK vendors its own copies; 9.x's standalone
46
+ * `@opentelemetry/instrumentation-*` packages left the tree). They emit the
47
+ * `db.user` span attribute unconditionally — GHSA-qqmp-wf37-98f9's behavior,
48
+ * invisible to `pnpm audit` because the copies live inside the audited-clean
49
+ * package. The only one that can ever match a module in this repo is
50
+ * Postgres (drizzle/pg); the rest are inert here, but they are dropped
51
+ * together so this list stays the complete set of vendored `db.user`
52
+ * emitters.
53
+ *
54
+ * Trade-off (documented decision): the filter matches on the integration
55
+ * `name`, and the SDK's `filterDuplicates` resolves duplicate integrations by
56
+ * name too. A future *user-supplied* integration that happens to be named
57
+ * exactly `Postgres`/`Mysql`/`Mysql2`/`Tedious`/`Knex` would therefore also
58
+ * be dropped from the final set. That is accepted: the five names are the
59
+ * SDK's own vendored names, so a user integration carrying one would collide
60
+ * with the vendored copy anyway, and dropping both is the safe outcome.
61
+ *
62
+ * Layout provenance: this list is pinned by the canary in
63
+ * `sentry.test.ts`, which resolves the vendored-instrumentation path from the
64
+ * installed `@sentry/node` package — that resolved path, not any directory
65
+ * names quoted in comments, is the source of truth for the layout.
66
+ */
67
+ export const VENDORED_DB_INTEGRATION_NAMES = [
68
+ 'Postgres',
69
+ 'Mysql',
70
+ 'Mysql2',
71
+ 'Tedious',
72
+ 'Knex',
73
+ ];
74
+ /**
75
+ * Removes the vendored DB integrations (see
76
+ * `VENDORED_DB_INTEGRATION_NAMES`) from the SDK default set so no `db.user`
77
+ * attribute is emitted. Wired into `Sentry.init` below as the callable form.
78
+ */
79
+ export const withoutVendoredDbIntegrations = (integrations) => integrations.filter((i) => !VENDORED_DB_INTEGRATION_NAMES.some((n) => i.name === n));
43
80
  /** Re-apply community tags on the current isolation scope (per-request). */
44
81
  export const applyCommunitySentryTags = () => {
45
82
  if (communityHostname) {
@@ -92,6 +129,7 @@ export const initSentry = (options = {}) => {
92
129
  tracesSampleRate: Number.isFinite(tracesSampleRate)
93
130
  ? tracesSampleRate
94
131
  : 0.1,
132
+ integrations: withoutVendoredDbIntegrations,
95
133
  });
96
134
  if (communityHostname) {
97
135
  Sentry.setTag(COMMUNITY_HOSTNAME_TAG, communityHostname);
@@ -28,9 +28,10 @@ export { seoRoute, type SeoRoute, type SeoRouteKind } from './route';
28
28
  * their own, so they are covered by the post paths.
29
29
  *
30
30
  * Profiles are opt-in: a crawled profile page is cached by search engines long
31
- * after the member leaves. `listProfiles` applies no privacy filter — it is the
32
- * same list `/members` shows — so enabling this exposes exactly the profiles an
33
- * anonymous visitor can already browse.
31
+ * after the member leaves. The sitemap uses the same directory view
32
+ * (`directoryView`) as the anonymous `/members` list, so enabling this exposes
33
+ * exactly the profiles an anonymous visitor can already browse — never ones
34
+ * that opted out of the directory.
34
35
  */
35
36
  export declare const crawlableEntries: ({ indexProfiles, }: {
36
37
  indexProfiles: boolean;
package/dist/seo/index.js CHANGED
@@ -38,15 +38,18 @@ const excerpt = (value, fallback) => {
38
38
  * their own, so they are covered by the post paths.
39
39
  *
40
40
  * Profiles are opt-in: a crawled profile page is cached by search engines long
41
- * after the member leaves. `listProfiles` applies no privacy filter — it is the
42
- * same list `/members` shows — so enabling this exposes exactly the profiles an
43
- * anonymous visitor can already browse.
41
+ * after the member leaves. The sitemap uses the same directory view
42
+ * (`directoryView`) as the anonymous `/members` list, so enabling this exposes
43
+ * exactly the profiles an anonymous visitor can already browse — never ones
44
+ * that opted out of the directory.
44
45
  */
45
46
  export const crawlableEntries = async ({ indexProfiles, }) => {
46
47
  const [posts, groups, profiles] = await Promise.all([
47
48
  listPosts(ANONYMOUS, { limit: PER_KIND_LIMIT }),
48
49
  listGroups(ANONYMOUS),
49
- indexProfiles ? listProfiles() : Promise.resolve([]),
50
+ indexProfiles
51
+ ? listProfiles(undefined, { directoryView: true })
52
+ : Promise.resolve([]),
50
53
  ]);
51
54
  const entities = [
52
55
  ...posts.map((post) => ({
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@openpeepshq/core",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "type": "module",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "dependencies": {
7
7
  "@asteasolutions/zod-to-openapi": "^8.5.0",
8
8
  "@keyv/redis": "^5.1.4",
9
- "@sentry/node": "^9.13.0",
9
+ "@sentry/node": "^10.78.0",
10
10
  "apns2": "^12.2.0",
11
11
  "archiver": "^7.0.1",
12
12
  "bcrypt": "^5.1.1",
@@ -38,9 +38,9 @@
38
38
  "uuidv7": "^1.0.2",
39
39
  "web-push": "^3.6.7",
40
40
  "@openpeepshq/common": "0.12.0",
41
- "@openpeepshq/geocoder": "^0.1.2",
41
+ "@openpeepshq/i18n": "^0.13.0",
42
42
  "@openpeepshq/fetch-client": "^0.2.1",
43
- "@openpeepshq/i18n": "^0.12.0"
43
+ "@openpeepshq/geocoder": "^0.1.2"
44
44
  },
45
45
  "main": "dist/index.js",
46
46
  "types": "dist/index.d.ts",