@atproto/ozone 0.0.15 → 0.0.16

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/api/proxied.d.ts +3 -0
  3. package/dist/auth-verifier.d.ts +72 -0
  4. package/dist/config/config.d.ts +9 -2
  5. package/dist/config/env.d.ts +4 -0
  6. package/dist/context.d.ts +3 -90
  7. package/dist/db/index.js.map +2 -2
  8. package/dist/index.js +29669 -29467
  9. package/dist/index.js.map +3 -3
  10. package/dist/lexicon/lexicons.d.ts +5 -0
  11. package/dist/lexicon/types/app/bsky/actor/defs.d.ts +1 -1
  12. package/dist/lexicon/types/com/atproto/admin/defs.d.ts +1 -0
  13. package/dist/mod-service/index.d.ts +16 -7
  14. package/dist/mod-service/views.d.ts +3 -3
  15. package/package.json +5 -5
  16. package/src/api/admin/createCommunicationTemplate.ts +2 -2
  17. package/src/api/admin/deleteCommunicationTemplate.ts +2 -2
  18. package/src/api/admin/emitModerationEvent.ts +23 -4
  19. package/src/api/admin/getModerationEvent.ts +1 -1
  20. package/src/api/admin/getRecord.ts +2 -2
  21. package/src/api/admin/getRepo.ts +2 -2
  22. package/src/api/admin/listCommunicationTemplates.ts +2 -2
  23. package/src/api/admin/queryModerationEvents.ts +1 -1
  24. package/src/api/admin/queryModerationStatuses.ts +1 -1
  25. package/src/api/admin/searchRepos.ts +1 -1
  26. package/src/api/admin/updateCommunicationTemplate.ts +2 -2
  27. package/src/api/index.ts +2 -0
  28. package/src/api/moderation/createReport.ts +2 -2
  29. package/src/api/proxied.ts +116 -0
  30. package/src/api/temp/fetchLabels.ts +2 -2
  31. package/src/api/well-known.ts +3 -3
  32. package/src/auth-verifier.ts +218 -0
  33. package/src/config/config.ts +18 -2
  34. package/src/config/env.ts +9 -1
  35. package/src/context.ts +24 -38
  36. package/src/daemon/context.ts +10 -4
  37. package/src/daemon/event-pusher.ts +3 -3
  38. package/src/lexicon/lexicons.ts +5 -0
  39. package/src/lexicon/types/app/bsky/actor/defs.ts +1 -1
  40. package/src/lexicon/types/com/atproto/admin/defs.ts +2 -0
  41. package/src/mod-service/index.ts +64 -7
  42. package/src/mod-service/views.ts +22 -18
  43. package/tests/moderation-events.test.ts +49 -0
  44. package/dist/auth.d.ts +0 -81
  45. package/src/auth.ts +0 -147
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @atproto/ozone
2
2
 
3
+ ## 0.0.16
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2279](https://github.com/bluesky-social/atproto/pull/2279) [`192223f12`](https://github.com/bluesky-social/atproto/commit/192223f127c0b226287df1ecfcd953636db08655) Thanks [@gaearon](https://github.com/gaearon)! - Change Following feed prefs to only show replies from people you follow by default
8
+
9
+ - Updated dependencies [[`192223f12`](https://github.com/bluesky-social/atproto/commit/192223f127c0b226287df1ecfcd953636db08655)]:
10
+ - @atproto/api@0.10.5
11
+
3
12
  ## 0.0.15
4
13
 
5
14
  ### Patch Changes
@@ -0,0 +1,3 @@
1
+ import { Server } from '../lexicon';
2
+ import AppContext from '../context';
3
+ export default function (server: Server, ctx: AppContext): void;
@@ -0,0 +1,72 @@
1
+ import express from 'express';
2
+ import { IdResolver } from '@atproto/identity';
3
+ type ReqCtx = {
4
+ req: express.Request;
5
+ };
6
+ type RoleOutput = {
7
+ credentials: {
8
+ type: 'role';
9
+ isAdmin: boolean;
10
+ isModerator: boolean;
11
+ isTriage: true;
12
+ };
13
+ };
14
+ type ModeratorOutput = {
15
+ credentials: {
16
+ type: 'moderator';
17
+ aud: string;
18
+ iss: string;
19
+ isAdmin: boolean;
20
+ isModerator: boolean;
21
+ isTriage: true;
22
+ };
23
+ };
24
+ type StandardOutput = {
25
+ credentials: {
26
+ type: 'standard';
27
+ aud: string;
28
+ iss: string;
29
+ isAdmin: boolean;
30
+ isModerator: boolean;
31
+ isTriage: boolean;
32
+ };
33
+ };
34
+ type NullOutput = {
35
+ credentials: {
36
+ type: 'none';
37
+ iss: null;
38
+ };
39
+ };
40
+ export type AuthVerifierOpts = {
41
+ serviceDid: string;
42
+ admins: string[];
43
+ moderators: string[];
44
+ triage: string[];
45
+ adminPassword: string;
46
+ moderatorPassword: string;
47
+ triagePassword: string;
48
+ };
49
+ export declare class AuthVerifier {
50
+ idResolver: IdResolver;
51
+ serviceDid: string;
52
+ admins: string[];
53
+ moderators: string[];
54
+ triage: string[];
55
+ private adminPassword;
56
+ private moderatorPassword;
57
+ private triagePassword;
58
+ constructor(idResolver: IdResolver, opts: AuthVerifierOpts);
59
+ modOrRole: (reqCtx: ReqCtx) => Promise<ModeratorOutput | RoleOutput>;
60
+ moderator: (reqCtx: ReqCtx) => Promise<ModeratorOutput>;
61
+ standard: (reqCtx: ReqCtx) => Promise<StandardOutput>;
62
+ standardOptional: (reqCtx: ReqCtx) => Promise<StandardOutput | NullOutput>;
63
+ standardOptionalOrRole: (reqCtx: ReqCtx) => Promise<StandardOutput | RoleOutput | NullOutput>;
64
+ role: (reqCtx: ReqCtx) => Promise<RoleOutput>;
65
+ nullCreds(): NullOutput;
66
+ }
67
+ export declare const getJwtStrFromReq: (req: express.Request) => string | null;
68
+ export declare const parseBasicAuth: (token: string) => {
69
+ username: string;
70
+ password: string;
71
+ } | null;
72
+ export {};
@@ -7,12 +7,14 @@ export type OzoneConfig = {
7
7
  pds: PdsConfig | null;
8
8
  cdn: CdnConfig;
9
9
  identity: IdentityConfig;
10
+ access: AccessConfig;
10
11
  };
11
12
  export type ServiceConfig = {
12
13
  port: number;
13
14
  publicUrl: string;
14
15
  did: string;
15
16
  version?: string;
17
+ devMode?: boolean;
16
18
  };
17
19
  export type DatabaseConfig = {
18
20
  postgresUrl: string;
@@ -29,9 +31,14 @@ export type PdsConfig = {
29
31
  url: string;
30
32
  did: string;
31
33
  };
34
+ export type CdnConfig = {
35
+ paths?: string[];
36
+ };
32
37
  export type IdentityConfig = {
33
38
  plcUrl: string;
34
39
  };
35
- export type CdnConfig = {
36
- paths?: string[];
40
+ export type AccessConfig = {
41
+ admins: string[];
42
+ moderators: string[];
43
+ triage: string[];
37
44
  };
@@ -1,6 +1,7 @@
1
1
  export declare const readEnv: () => OzoneEnvironment;
2
2
  export type OzoneEnvironment = {
3
3
  nodeEnv?: string;
4
+ devMode?: boolean;
4
5
  version?: string;
5
6
  port?: number;
6
7
  publicUrl?: string;
@@ -16,6 +17,9 @@ export type OzoneEnvironment = {
16
17
  dbPoolIdleTimeoutMs?: number;
17
18
  didPlcUrl?: string;
18
19
  cdnPaths?: string[];
20
+ adminDids: string[];
21
+ moderatorDids: string[];
22
+ triageDids: string[];
19
23
  adminPassword?: string;
20
24
  moderatorPassword?: string;
21
25
  triagePassword?: string;
package/dist/context.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- /// <reference types="qs" />
2
- /// <reference types="express" />
3
1
  import * as plc from '@did-plc/lib';
4
2
  import { IdResolver } from '@atproto/identity';
5
3
  import { AtpAgent } from '@atproto/api';
@@ -10,6 +8,7 @@ import { ModerationServiceCreator } from './mod-service';
10
8
  import { BackgroundQueue } from './background';
11
9
  import Sequencer from './sequencer/sequencer';
12
10
  import { CommunicationTemplateServiceCreator } from './communication-service/template';
11
+ import { AuthVerifier } from './auth-verifier';
13
12
  import { ImageInvalidator } from './image-invalidator';
14
13
  export type AppContextOptions = {
15
14
  db: Database;
@@ -23,6 +22,7 @@ export type AppContextOptions = {
23
22
  imgInvalidator?: ImageInvalidator;
24
23
  backgroundQueue: BackgroundQueue;
25
24
  sequencer: Sequencer;
25
+ authVerifier: AuthVerifier;
26
26
  };
27
27
  export declare class AppContext {
28
28
  private opts;
@@ -41,94 +41,7 @@ export declare class AppContext {
41
41
  get idResolver(): IdResolver;
42
42
  get backgroundQueue(): BackgroundQueue;
43
43
  get sequencer(): Sequencer;
44
- get authVerifier(): (reqCtx: {
45
- req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
46
- res: import("express").Response<any, Record<string, any>>;
47
- }) => Promise<{
48
- credentials: {
49
- did: string;
50
- };
51
- artifacts: {
52
- aud: string | null;
53
- };
54
- }>;
55
- get authVerifierAnyAudience(): (reqCtx: {
56
- req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
57
- res: import("express").Response<any, Record<string, any>>;
58
- }) => Promise<{
59
- credentials: {
60
- did: string;
61
- };
62
- artifacts: {
63
- aud: string | null;
64
- };
65
- }>;
66
- get authOptionalVerifierAnyAudience(): (reqCtx: {
67
- req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
68
- res: import("express").Response<any, Record<string, any>>;
69
- }) => Promise<{
70
- credentials: {
71
- did: string;
72
- };
73
- artifacts: {
74
- aud: string | null;
75
- };
76
- } | {
77
- credentials: {
78
- did: null;
79
- };
80
- }>;
81
- get authOptionalVerifier(): (reqCtx: {
82
- req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
83
- res: import("express").Response<any, Record<string, any>>;
84
- }) => Promise<{
85
- credentials: {
86
- did: string;
87
- };
88
- artifacts: {
89
- aud: string | null;
90
- };
91
- } | {
92
- credentials: {
93
- did: null;
94
- };
95
- }>;
96
- get authOptionalAccessOrRoleVerifier(): (ctx: {
97
- req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
98
- res: import("express").Response<any, Record<string, any>>;
99
- }) => Promise<{
100
- credentials: {
101
- did: null;
102
- type: "unauthed";
103
- };
104
- } | {
105
- credentials: {
106
- valid: boolean;
107
- admin: boolean;
108
- moderator: boolean;
109
- triage: boolean;
110
- type: "role";
111
- };
112
- } | {
113
- credentials: {
114
- did: string;
115
- type: "access";
116
- };
117
- artifacts: {
118
- aud: string | null;
119
- };
120
- }>;
121
- get roleVerifier(): (reqCtx: {
122
- req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
123
- res: import("express").Response<any, Record<string, any>>;
124
- }) => Promise<{
125
- credentials: {
126
- valid: boolean;
127
- admin: boolean;
128
- moderator: boolean;
129
- triage: boolean;
130
- };
131
- }>;
44
+ get authVerifier(): AuthVerifier;
132
45
  serviceAuthHeaders(aud: string): Promise<{
133
46
  headers: {
134
47
  authorization: string;