@voltro/plugin-sanctions 0.0.0-stage → 0.88.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 +24492 -0
- package/LICENSE +61 -0
- package/README.md +198 -2
- package/SECURITY.md +56 -0
- package/THIRD-PARTY-NOTICES.md +8333 -0
- package/dist/admission.server.js +96 -0
- package/dist/components.js +282 -0
- package/dist/contract.js +88 -0
- package/dist/entities.js +101 -0
- package/dist/errors.d.ts +13 -0
- package/dist/errors.js +14 -0
- package/dist/eventProducer.d.ts +8 -0
- package/dist/eventProducer.js +19 -0
- package/dist/events.d.ts +14 -0
- package/dist/events.js +10 -0
- package/dist/guard.d.ts +83 -0
- package/dist/guard.js +16 -0
- package/dist/index.d.ts +585 -0
- package/dist/index.js +179 -0
- package/dist/inspect.js +23 -0
- package/dist/port.d.ts +82 -0
- package/dist/port.js +4 -0
- package/dist/rpc.d.ts +165 -0
- package/dist/rpc.js +146 -0
- package/dist/rpcRoutes.js +49 -0
- package/dist/sanctions-app/events/sanctions.changed.event.ts +1 -0
- package/dist/sanctions-app/subscribers/sanctions.actions.subscribe.ts +3 -0
- package/dist/server.d.ts +363 -0
- package/dist/server.js +1 -0
- package/dist/service.js +708 -0
- package/dist/strategies.d.ts +154 -0
- package/dist/strategies.js +72 -0
- package/dist/testing.d.ts +211 -0
- package/dist/testing.js +120 -0
- package/dist/web.d.ts +239 -0
- package/dist/web.js +7 -0
- package/package.json +99 -4
package/dist/guard.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { AuthSubjectGuard } from '@voltro/protocol';
|
|
2
|
+
import { Effect } from 'effect';
|
|
3
|
+
import { Schema } from 'effect';
|
|
4
|
+
import { Subject } from '@voltro/protocol';
|
|
5
|
+
import { SubjectGuard } from '@voltro/plugin-auth';
|
|
6
|
+
import { YieldableError } from 'effect/Cause';
|
|
7
|
+
|
|
8
|
+
declare const CATEGORIES: readonly ["cheating", "abuse", "name", "spam", "griefing", "rmt"];
|
|
9
|
+
|
|
10
|
+
declare const DecisionSchema: Schema.Struct<{
|
|
11
|
+
readonly allowed: Schema.Boolean;
|
|
12
|
+
readonly actionIds: Schema.$Array<Schema.String>;
|
|
13
|
+
readonly shadow: Schema.Boolean;
|
|
14
|
+
}>;
|
|
15
|
+
|
|
16
|
+
declare const POINTS: readonly ["chat", "matchmaking", "trade", "ranked", "login"];
|
|
17
|
+
|
|
18
|
+
declare type ReportContext = typeof ReportContextSchema.Type;
|
|
19
|
+
|
|
20
|
+
declare const ReportContextSchema: Schema.Struct<{
|
|
21
|
+
readonly channelId: Schema.optional<Schema.String>;
|
|
22
|
+
readonly messageIds: Schema.optional<Schema.$Array<Schema.String>>;
|
|
23
|
+
readonly roomId: Schema.optional<Schema.String>;
|
|
24
|
+
readonly matchId: Schema.optional<Schema.String>;
|
|
25
|
+
readonly replayRef: Schema.optional<Schema.String>;
|
|
26
|
+
}>;
|
|
27
|
+
|
|
28
|
+
declare type Sanction = typeof SanctionSchema.Type;
|
|
29
|
+
|
|
30
|
+
declare type SanctionCategory = typeof CATEGORIES[number];
|
|
31
|
+
|
|
32
|
+
declare interface SanctionCheckContext {
|
|
33
|
+
readonly channelId?: string;
|
|
34
|
+
readonly queueId?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
declare type SanctionDecision = typeof DecisionSchema.Type;
|
|
38
|
+
|
|
39
|
+
declare type SanctionPoint = typeof POINTS[number];
|
|
40
|
+
|
|
41
|
+
declare const SanctionSchema: Schema.Struct<{
|
|
42
|
+
readonly id: Schema.String;
|
|
43
|
+
readonly kind: Schema.Literals<readonly ["warn", "mute", "chatBan", "matchmakingBan", "rankedBan", "tradeBan", "ban", "shadowBan", "nameReset", "rollback"]>;
|
|
44
|
+
readonly scope: Schema.Struct<{
|
|
45
|
+
readonly channels: Schema.$Array<Schema.String>;
|
|
46
|
+
readonly queues: Schema.$Array<Schema.String>;
|
|
47
|
+
}>;
|
|
48
|
+
readonly from: Schema.Number;
|
|
49
|
+
readonly until: Schema.NullOr<Schema.Number>;
|
|
50
|
+
readonly publicReason: Schema.String;
|
|
51
|
+
readonly appealable: Schema.Boolean;
|
|
52
|
+
}>;
|
|
53
|
+
|
|
54
|
+
declare class SanctionsError extends SanctionsError_base {
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
declare const SanctionsError_base: Schema.Class<SanctionsError, Schema.TaggedStruct<"SanctionsError", {
|
|
58
|
+
readonly code: Schema.Literals<readonly ["identity_required", "invalid_input", "forbidden", "not_found", "conflict", "rate_limited", "sanctioned", "unavailable", "export_limit"]>;
|
|
59
|
+
}>, YieldableError>;
|
|
60
|
+
|
|
61
|
+
/** Opt-in; the caller supplies the actual service. No auth default or boot path is changed. */
|
|
62
|
+
export declare const sanctionsLoginGuard: (service: Pick<SanctionsService, "check">) => SubjectGuard;
|
|
63
|
+
|
|
64
|
+
declare interface SanctionsService {
|
|
65
|
+
readonly check: (subject: Subject, point: SanctionPoint, context?: SanctionCheckContext) => Effect.Effect<SanctionDecision, SanctionsError>;
|
|
66
|
+
readonly active: (subject: Subject) => Effect.Effect<ReadonlyArray<Sanction>, SanctionsError>;
|
|
67
|
+
readonly trust: (subject: Subject) => Effect.Effect<number, SanctionsError>;
|
|
68
|
+
readonly recordSignal: (subject: Subject, input: TrustedSanctionSignal) => Effect.Effect<void, SanctionsError>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Request-side opt-in. Existing scope caches need explicit invalidation by the host app. */
|
|
72
|
+
export declare const sanctionsSubjectGuard: (service: Pick<SanctionsService, "check">) => AuthSubjectGuard;
|
|
73
|
+
|
|
74
|
+
declare interface TrustedSanctionSignal {
|
|
75
|
+
readonly tenantId: string;
|
|
76
|
+
readonly targetId: string;
|
|
77
|
+
readonly requestId: string;
|
|
78
|
+
readonly category: SanctionCategory;
|
|
79
|
+
readonly confidence: number;
|
|
80
|
+
readonly context?: ReportContext;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export { }
|
package/dist/guard.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Effect as e } from "effect";
|
|
2
|
+
// src/guard.ts
|
|
3
|
+
var t = {
|
|
4
|
+
ok: !1,
|
|
5
|
+
code: "sanctions_check_unavailable",
|
|
6
|
+
message: "Account policy could not be checked"
|
|
7
|
+
}, n = {
|
|
8
|
+
ok: !1,
|
|
9
|
+
code: "account_sanctioned",
|
|
10
|
+
message: "Account policy prevents login"
|
|
11
|
+
}, r = (r) => (i) => e.suspend(() => r.check({
|
|
12
|
+
type: "user",
|
|
13
|
+
id: i.id,
|
|
14
|
+
tenantId: i.tenantId
|
|
15
|
+
}, "login")).pipe(e.map((e) => e.allowed ? { ok: !0 } : n), e.catch(() => e.succeed(t)), e.catchDefect(() => e.succeed(t))), i = (r) => async (i) => i.type === "user" ? e.runPromise(e.suspend(() => r.check(i, "login")).pipe(e.map((e) => e.allowed ? { ok: !0 } : n), e.catch(() => e.succeed(t)), e.catchDefect(() => e.succeed(t)))) : { ok: !0 };
|
|
16
|
+
export { r as sanctionsLoginGuard, i as sanctionsSubjectGuard };
|