@grubbylee/aiba 0.1.1

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.
@@ -0,0 +1,78 @@
1
+ apiVersion: aiba.dev/v0alpha1
2
+ kind: CapabilityRecipe
3
+ metadata:
4
+ id: typescript-reference
5
+ version: 0.1.0
6
+ title: TypeScript Review Access
7
+ description: >-
8
+ Semantic implementation guidance for a server-authoritative review access
9
+ boundary in TypeScript projects.
10
+ spec:
11
+ capability:
12
+ id: review-access
13
+ version: 0.1.0
14
+ compatibility:
15
+ languages: [TypeScript]
16
+ frameworks: []
17
+ writeScope:
18
+ allowedPatterns:
19
+ - src/**
20
+ - server/**
21
+ - test/**
22
+ - tests/**
23
+ - miniprogram/**
24
+ - cloudfunctions/**
25
+ operations:
26
+ - id: establish-reviewer-boundary
27
+ intent: Implement a reviewer principal that cannot impersonate normal or administrative users.
28
+ requiredInterfaces: [identity.principal, authorization.decision]
29
+ invariants: [reviewer-is-distinct-principal, client-cannot-self-assert-reviewer]
30
+ guidance:
31
+ - Derive reviewer identity, permissions, and enablement only from trusted server configuration.
32
+ - Reject client-provided role, scope, data-mode, or reviewer identity assertions.
33
+ - id: constrain-review-session
34
+ intent: Bind review access to an enabled release, a short lifetime, and explicit revocation.
35
+ requiredInterfaces: [identity.principal, authorization.decision]
36
+ invariants: [server-authoritative-enable, access-expires, access-is-revocable]
37
+ guidance:
38
+ - Enforce enablement and expiry on every authentication and authorization boundary.
39
+ - Store revocation state in a server-authoritative component.
40
+ - id: isolate-review-data
41
+ intent: Restrict reviewers to explicit read-only scopes and isolated or sanitized data.
42
+ requiredInterfaces: [authorization.decision]
43
+ invariants: [scope-is-least-privilege, production-data-is-isolated]
44
+ guidance:
45
+ - Use an allowlist of review-only actions and datasets.
46
+ - Never make unrestricted production records reachable through a review session.
47
+ - id: defend-and-audit
48
+ intent: Rate-limit authentication attempts and emit attributable audit events.
49
+ requiredInterfaces: [audit.event]
50
+ invariants: [attempts-are-rate-limited, actions-are-audited]
51
+ guidance:
52
+ - Apply rate limits in trusted server state rather than client storage.
53
+ - Audit authentication, denial, session creation, authorization, expiry, and revocation.
54
+ evidence:
55
+ - invariant: reviewer-is-distinct-principal
56
+ suggestions: &sourceTestSuggestions
57
+ - type: source
58
+ pathPattern: src/**/*.ts
59
+ description: Server-side review access implementation.
60
+ - type: test
61
+ pathPattern: src/**/*.test.ts
62
+ description: Security-focused review access tests.
63
+ - invariant: server-authoritative-enable
64
+ suggestions: *sourceTestSuggestions
65
+ - invariant: scope-is-least-privilege
66
+ suggestions: *sourceTestSuggestions
67
+ - invariant: access-expires
68
+ suggestions: *sourceTestSuggestions
69
+ - invariant: access-is-revocable
70
+ suggestions: *sourceTestSuggestions
71
+ - invariant: production-data-is-isolated
72
+ suggestions: *sourceTestSuggestions
73
+ - invariant: attempts-are-rate-limited
74
+ suggestions: *sourceTestSuggestions
75
+ - invariant: actions-are-audited
76
+ suggestions: *sourceTestSuggestions
77
+ - invariant: client-cannot-self-assert-reviewer
78
+ suggestions: *sourceTestSuggestions
@@ -0,0 +1,73 @@
1
+ apiVersion: aiba.dev/v0alpha1
2
+ kind: CapabilityRecipe
3
+ metadata:
4
+ id: wechat-native
5
+ version: 0.1.0
6
+ title: Native WeChat Mini Program Review Access
7
+ description: >-
8
+ Semantic guidance for a native WeChat Mini Program review entry backed by
9
+ a server-authoritative TypeScript security boundary.
10
+ spec:
11
+ capability:
12
+ id: review-access
13
+ version: 0.1.0
14
+ compatibility:
15
+ languages: [JavaScript, TypeScript]
16
+ frameworks: [WeChat Mini Program]
17
+ writeScope:
18
+ allowedPatterns:
19
+ - miniprogram/**
20
+ - src/**
21
+ operations:
22
+ - id: add-review-entry
23
+ intent: Add a reviewer-facing Mini Program entry that submits only credential and release identity.
24
+ requiredInterfaces: [identity.principal]
25
+ invariants: [client-cannot-self-assert-reviewer, reviewer-is-distinct-principal]
26
+ guidance:
27
+ - Do not place enablement, reviewer roles, scopes, secrets, or production data rules in Mini Program code.
28
+ - Keep reviewer session tokens in memory and use a dedicated reviewer principal returned by the server.
29
+ - id: enforce-server-policy
30
+ intent: Enforce release binding, enablement, expiration, revocation, and rate limits in trusted server state.
31
+ requiredInterfaces: [identity.principal, authorization.decision]
32
+ invariants: [server-authoritative-enable, access-expires, access-is-revocable, attempts-are-rate-limited]
33
+ guidance:
34
+ - Derive the rate-limit key from trusted transport metadata rather than request body fields.
35
+ - Re-evaluate policy while authorizing an existing review session.
36
+ - id: isolate-review-capabilities
37
+ intent: Expose only fixed review operations backed by isolated or sanitized data.
38
+ requiredInterfaces: [authorization.decision]
39
+ invariants: [scope-is-least-privilege, production-data-is-isolated]
40
+ guidance:
41
+ - Map each endpoint to a server-owned scope instead of accepting arbitrary scope input.
42
+ - Inject an isolated review dataset without a production-data fallback.
43
+ - id: audit-review-boundary
44
+ intent: Emit attributable audit events for authentication, authorization, denial, and revocation.
45
+ requiredInterfaces: [audit.event]
46
+ invariants: [actions-are-audited]
47
+ guidance:
48
+ - Record outcomes and reason codes without logging raw credentials or session tokens.
49
+ evidence:
50
+ - invariant: reviewer-is-distinct-principal
51
+ suggestions: &wechatEvidence
52
+ - type: source
53
+ pathPattern: src/server/**/*.ts
54
+ description: Server-authoritative review access implementation.
55
+ - type: test
56
+ pathPattern: src/**/*.test.ts
57
+ description: Black-box review access attack tests.
58
+ - invariant: server-authoritative-enable
59
+ suggestions: *wechatEvidence
60
+ - invariant: scope-is-least-privilege
61
+ suggestions: *wechatEvidence
62
+ - invariant: access-expires
63
+ suggestions: *wechatEvidence
64
+ - invariant: access-is-revocable
65
+ suggestions: *wechatEvidence
66
+ - invariant: production-data-is-isolated
67
+ suggestions: *wechatEvidence
68
+ - invariant: attempts-are-rate-limited
69
+ suggestions: *wechatEvidence
70
+ - invariant: actions-are-audited
71
+ suggestions: *wechatEvidence
72
+ - invariant: client-cannot-self-assert-reviewer
73
+ suggestions: *wechatEvidence
@@ -0,0 +1,8 @@
1
+ # Users Capability
2
+
3
+ `users` defines tenant-scoped user lifecycle management over trusted identity,
4
+ authorization, and audit boundaries. It separates profile data from roles and
5
+ credentials, uses explicit states, and coordinates disable/delete with session
6
+ revocation.
7
+
8
+ It does not prescribe a user table, directory provider, permission model, or UI.
@@ -0,0 +1,76 @@
1
+ apiVersion: aiba.dev/v0alpha1
2
+ kind: Capability
3
+ metadata:
4
+ id: users
5
+ version: 0.1.0
6
+ title: Users
7
+ description: >-
8
+ Authorized, tenant-scoped user lifecycle management with server-derived
9
+ identity, explicit states, session revocation, and attributable changes.
10
+ spec:
11
+ interfaces:
12
+ - identity.principal
13
+ - identity.session
14
+ - authorization.decision
15
+ - audit.event
16
+ - users.lifecycle
17
+ dependencies:
18
+ - id: identity
19
+ version: ^0.1.0
20
+ optional: false
21
+ - id: authorization
22
+ version: ^0.1.0
23
+ optional: false
24
+ - id: audit
25
+ version: ^0.1.0
26
+ optional: false
27
+ invariants:
28
+ - id: tenant-and-id-are-server-derived
29
+ title: Tenant and ID are server derived
30
+ description: User identifiers and tenant ownership cannot be selected through lifecycle request fields.
31
+ severity: critical
32
+ evidence: &sourceAndTest
33
+ acceptedTypes: [source, test, config, document]
34
+ requiredTypes: [source, test]
35
+ minimum: 2
36
+ requireHash: true
37
+ - id: every-operation-is-authorized
38
+ title: Every operation is authorized
39
+ description: Read and mutation operations require an explicit authorization decision over the target user.
40
+ severity: critical
41
+ evidence: *sourceAndTest
42
+ - id: tenant-boundaries-hide-records
43
+ title: Tenant boundaries hide records
44
+ description: Cross-tenant records are neither returned nor distinguishable from missing records.
45
+ severity: critical
46
+ evidence: *sourceAndTest
47
+ - id: roles-and-credentials-are-separate
48
+ title: Roles and credentials are separate
49
+ description: Profile and lifecycle inputs cannot assign roles, permissions, passwords, or credential material.
50
+ severity: critical
51
+ evidence: *sourceAndTest
52
+ - id: lifecycle-transitions-are-explicit
53
+ title: Lifecycle transitions are explicit
54
+ description: Pending, active, disabled, and deleted states follow a bounded transition graph and deleted users cannot be revived.
55
+ severity: critical
56
+ evidence: *sourceAndTest
57
+ - id: identifiers-are-unique-per-tenant
58
+ title: Identifiers are unique per tenant
59
+ description: Normalized login identifiers cannot create duplicate active user identity inside one tenant.
60
+ severity: critical
61
+ evidence: *sourceAndTest
62
+ - id: disable-and-delete-revoke-sessions
63
+ title: Disable and delete revoke sessions
64
+ description: Disabling or deleting a user triggers trusted revocation of all reusable sessions.
65
+ severity: critical
66
+ evidence: *sourceAndTest
67
+ - id: mutations-and-audit-commit-together
68
+ title: Mutations and audit commit together
69
+ description: User state and its audit outbox record are committed atomically or the mutation fails visibly.
70
+ severity: critical
71
+ evidence: *sourceAndTest
72
+ - id: returned-profile-is-minimized
73
+ title: Returned profile is minimized
74
+ description: Lifecycle responses exclude credential material, roles, permissions, and unnecessary identifiers.
75
+ severity: error
76
+ evidence: *sourceAndTest
@@ -0,0 +1,75 @@
1
+ apiVersion: aiba.dev/v0alpha1
2
+ kind: CapabilityRecipe
3
+ metadata:
4
+ id: typescript-reference
5
+ version: 0.1.0
6
+ title: TypeScript Users Lifecycle
7
+ description: Semantic guidance for a tenant-safe, authorized TypeScript user directory.
8
+ spec:
9
+ capability:
10
+ id: users
11
+ version: 0.1.0
12
+ compatibility:
13
+ languages: [TypeScript]
14
+ frameworks: []
15
+ writeScope:
16
+ allowedPatterns:
17
+ - src/**
18
+ - server/**
19
+ - test/**
20
+ - tests/**
21
+ - cloudfunctions/**
22
+ operations:
23
+ - id: establish-user-record-boundary
24
+ intent: Derive user identity and tenant ownership on the server while keeping roles and credentials separate.
25
+ requiredInterfaces: [identity.principal, users.lifecycle]
26
+ invariants: [tenant-and-id-are-server-derived, roles-and-credentials-are-separate, identifiers-are-unique-per-tenant, returned-profile-is-minimized]
27
+ guidance:
28
+ - Take tenant ownership from trusted principal context and generate opaque user IDs inside the service.
29
+ - Reject role, permission, status, tenant, ID, password, and credential fields in create/profile inputs.
30
+ - id: authorize-user-operations
31
+ intent: Evaluate an explicit user resource decision for every read and mutation.
32
+ requiredInterfaces: [authorization.decision]
33
+ invariants: [every-operation-is-authorized, tenant-boundaries-hide-records]
34
+ guidance:
35
+ - Bind object-level checks to the actual record tenant and user ID before returning data.
36
+ - Return the same public not-found result for missing and cross-tenant records.
37
+ - id: enforce-user-lifecycle
38
+ intent: Apply a bounded state graph and revoke sessions for disabled or deleted users.
39
+ requiredInterfaces: [identity.session, users.lifecycle]
40
+ invariants: [lifecycle-transitions-are-explicit, disable-and-delete-revoke-sessions]
41
+ guidance:
42
+ - Keep deleted users terminal and represent deletion without silently reusing identity.
43
+ - Coordinate disable/delete with a session-revocation command through trusted infrastructure.
44
+ - id: commit-user-audit
45
+ intent: Commit each user mutation with an audit outbox event and optimistic version check.
46
+ requiredInterfaces: [audit.event]
47
+ invariants: [mutations-and-audit-commit-together]
48
+ guidance:
49
+ - Use a database transaction or equivalent outbox boundary for the user state and audit event.
50
+ - Reject concurrent stale writes instead of overwriting a newer lifecycle state.
51
+ evidence:
52
+ - invariant: tenant-and-id-are-server-derived
53
+ suggestions: &usersEvidence
54
+ - type: source
55
+ pathPattern: src/**/*.ts
56
+ description: Authorized user lifecycle implementation.
57
+ - type: test
58
+ pathPattern: src/**/*.test.ts
59
+ description: Tenant, lifecycle, and mutation tests.
60
+ - invariant: every-operation-is-authorized
61
+ suggestions: *usersEvidence
62
+ - invariant: tenant-boundaries-hide-records
63
+ suggestions: *usersEvidence
64
+ - invariant: roles-and-credentials-are-separate
65
+ suggestions: *usersEvidence
66
+ - invariant: lifecycle-transitions-are-explicit
67
+ suggestions: *usersEvidence
68
+ - invariant: identifiers-are-unique-per-tenant
69
+ suggestions: *usersEvidence
70
+ - invariant: disable-and-delete-revoke-sessions
71
+ suggestions: *usersEvidence
72
+ - invariant: mutations-and-audit-commit-together
73
+ suggestions: *usersEvidence
74
+ - invariant: returned-profile-is-minimized
75
+ suggestions: *usersEvidence
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};