@codemem/core 0.47.0-beta.4 → 0.47.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.
Files changed (101) hide show
  1. package/dist/account-owner-association-directory.d.ts +11 -0
  2. package/dist/account-owner-association-directory.d.ts.map +1 -1
  3. package/dist/account-owner-association.d.ts +5 -0
  4. package/dist/account-owner-association.d.ts.map +1 -1
  5. package/dist/better-sqlite-coordinator-store.d.ts +4 -0
  6. package/dist/better-sqlite-coordinator-store.d.ts.map +1 -1
  7. package/dist/coordinator-account-change.d.ts +0 -5
  8. package/dist/coordinator-account-change.d.ts.map +1 -1
  9. package/dist/coordinator-account-connection-link.d.ts +7 -1
  10. package/dist/coordinator-account-connection-link.d.ts.map +1 -1
  11. package/dist/coordinator-account-link-receiver.d.ts +19 -0
  12. package/dist/coordinator-account-link-receiver.d.ts.map +1 -1
  13. package/dist/coordinator-account-link-status.d.ts.map +1 -1
  14. package/dist/coordinator-actions.d.ts.map +1 -1
  15. package/dist/coordinator-api.d.ts.map +1 -1
  16. package/dist/coordinator-auth-browser-view.d.ts +6 -0
  17. package/dist/coordinator-auth-browser-view.d.ts.map +1 -1
  18. package/dist/coordinator-auth-controller-owner-review.d.ts +4 -1
  19. package/dist/coordinator-auth-controller-owner-review.d.ts.map +1 -1
  20. package/dist/coordinator-auth-device-claim-eligibility.d.ts +8 -3
  21. package/dist/coordinator-auth-device-claim-eligibility.d.ts.map +1 -1
  22. package/dist/coordinator-auth-historical-store-test-fixture.d.ts.map +1 -1
  23. package/dist/coordinator-auth-legacy-assignment.d.ts +1 -1
  24. package/dist/coordinator-auth-legacy-assignment.d.ts.map +1 -1
  25. package/dist/coordinator-auth-link-authority.d.ts +2 -1
  26. package/dist/coordinator-auth-link-authority.d.ts.map +1 -1
  27. package/dist/coordinator-browser-auth-app.d.ts.map +1 -1
  28. package/dist/coordinator-browser-auth-callback.d.ts +7 -1
  29. package/dist/coordinator-browser-auth-callback.d.ts.map +1 -1
  30. package/dist/coordinator-device-auth-link.d.ts +5 -1
  31. package/dist/coordinator-device-auth-link.d.ts.map +1 -1
  32. package/dist/coordinator-device-ownership-schema.d.ts +7 -1
  33. package/dist/coordinator-device-ownership-schema.d.ts.map +1 -1
  34. package/dist/coordinator-device-rebind-browser.d.ts +26 -0
  35. package/dist/coordinator-device-rebind-browser.d.ts.map +1 -0
  36. package/dist/coordinator-device-rebind-ceremony.d.ts +126 -0
  37. package/dist/coordinator-device-rebind-ceremony.d.ts.map +1 -0
  38. package/dist/coordinator-device-rebind-client.d.ts +82 -0
  39. package/dist/coordinator-device-rebind-client.d.ts.map +1 -0
  40. package/dist/coordinator-device-rebind-commit.d.ts +58 -0
  41. package/dist/coordinator-device-rebind-commit.d.ts.map +1 -0
  42. package/dist/coordinator-device-rebind-http.d.ts +11 -0
  43. package/dist/coordinator-device-rebind-http.d.ts.map +1 -0
  44. package/dist/coordinator-device-rebind-proof.d.ts +55 -0
  45. package/dist/coordinator-device-rebind-proof.d.ts.map +1 -0
  46. package/dist/coordinator-device-rebind-schema.d.ts +38 -0
  47. package/dist/coordinator-device-rebind-schema.d.ts.map +1 -0
  48. package/dist/coordinator-device-rebind-test-fixtures.d.ts +47 -0
  49. package/dist/coordinator-device-rebind-test-fixtures.d.ts.map +1 -0
  50. package/dist/coordinator-device-rebind-view.d.ts +37 -0
  51. package/dist/coordinator-device-rebind-view.d.ts.map +1 -0
  52. package/dist/coordinator-enrollment-ownership.d.ts +14 -0
  53. package/dist/coordinator-enrollment-ownership.d.ts.map +1 -0
  54. package/dist/coordinator-enrollment-reconciler.d.ts.map +1 -1
  55. package/dist/coordinator-history-sql-equivalence-test-fixtures.d.ts +1 -1
  56. package/dist/coordinator-history-sql-equivalence-test-fixtures.d.ts.map +1 -1
  57. package/dist/coordinator-legacy-completion-owner-proof.d.ts.map +1 -1
  58. package/dist/coordinator-legacy-owner-compatibility.d.ts +7 -5
  59. package/dist/coordinator-legacy-owner-compatibility.d.ts.map +1 -1
  60. package/dist/coordinator-legacy-team-completion.d.ts +17 -0
  61. package/dist/coordinator-legacy-team-completion.d.ts.map +1 -1
  62. package/dist/coordinator-resolved-account-owner-status-test-fixtures.d.ts +5 -0
  63. package/dist/coordinator-resolved-account-owner-status-test-fixtures.d.ts.map +1 -1
  64. package/dist/coordinator-resolved-account-owner-status.d.ts.map +1 -1
  65. package/dist/coordinator-store-contract.d.ts +2 -0
  66. package/dist/coordinator-store-contract.d.ts.map +1 -1
  67. package/dist/d1-coordinator-store.d.ts +5 -0
  68. package/dist/d1-coordinator-store.d.ts.map +1 -1
  69. package/dist/index.d.ts +10 -4
  70. package/dist/index.d.ts.map +1 -1
  71. package/dist/index.js +9807 -9173
  72. package/dist/index.js.map +1 -1
  73. package/dist/internal/cloudflare-coordinator.js +1523 -1219
  74. package/dist/internal/cloudflare-coordinator.js.map +1 -1
  75. package/dist/legacy-team-setup-completion-manifest.d.ts.map +1 -1
  76. package/dist/legacy-team-setup-draft.d.ts +7 -0
  77. package/dist/legacy-team-setup-draft.d.ts.map +1 -1
  78. package/dist/local-identity-generation.d.ts +14 -0
  79. package/dist/local-identity-generation.d.ts.map +1 -0
  80. package/dist/local-identity-switch.d.ts +82 -0
  81. package/dist/local-identity-switch.d.ts.map +1 -0
  82. package/dist/{owner-enrollment-start-BMkDi_Yz.js → owner-enrollment-start-XwN1p7du.js} +4750 -3756
  83. package/dist/owner-enrollment-start-XwN1p7du.js.map +1 -0
  84. package/dist/schema-bootstrap.d.ts.map +1 -1
  85. package/dist/schema.d.ts +38 -0
  86. package/dist/schema.d.ts.map +1 -1
  87. package/dist/semantic-worker-entry.js +1 -1
  88. package/dist/{semantic-worker-job-J6TKJeAe.js → semantic-worker-job-a7S-qbRH.js} +2 -2
  89. package/dist/{semantic-worker-job-J6TKJeAe.js.map → semantic-worker-job-a7S-qbRH.js.map} +1 -1
  90. package/dist/{semantic-worker-ranking-ByCOj--W.js → semantic-worker-ranking-hRyoWJtp.js} +2508 -2453
  91. package/dist/semantic-worker-ranking-hRyoWJtp.js.map +1 -0
  92. package/dist/store.d.ts +2 -0
  93. package/dist/store.d.ts.map +1 -1
  94. package/dist/test-schema.generated.d.ts +1 -1
  95. package/dist/test-schema.generated.d.ts.map +1 -1
  96. package/dist/{workspace-identity-CgbP3sJa.js → workspace-identity-C2g2-ZRR.js} +2246 -2123
  97. package/dist/workspace-identity-C2g2-ZRR.js.map +1 -0
  98. package/package.json +3 -3
  99. package/dist/owner-enrollment-start-BMkDi_Yz.js.map +0 -1
  100. package/dist/semantic-worker-ranking-ByCOj--W.js.map +0 -1
  101. package/dist/workspace-identity-CgbP3sJa.js.map +0 -1
@@ -0,0 +1,26 @@
1
+ import type { AuthLinkBackend } from "./coordinator-auth-link.js";
2
+ import { type BrowserCsrfKey } from "./coordinator-browser-csrf.js";
3
+ import { type CoordinatorOidcOptions } from "./coordinator-oidc.js";
4
+ import type { InMemoryRequestRateLimiter } from "./request-rate-limit.js";
5
+ export interface DeviceRebindBrowserInput {
6
+ config: unknown;
7
+ csrfKey: BrowserCsrfKey;
8
+ limiter: InMemoryRequestRateLimiter;
9
+ /** Must already have the rebind tables; see readDeviceRebindBackend. */
10
+ backend: AuthLinkBackend;
11
+ oidcOptions?: CoordinatorOidcOptions;
12
+ now?: () => number;
13
+ }
14
+ export declare function createDeviceRebindBrowser(input: DeviceRebindBrowserInput): Promise<{
15
+ ok: false;
16
+ handlers?: undefined;
17
+ } | {
18
+ ok: true;
19
+ handlers: Readonly<{
20
+ startPage: (request: Request, clientKey: string) => Promise<Response>;
21
+ start: (request: Request, clientKey: string) => Promise<Response>;
22
+ confirm: (request: Request, clientKey: string) => Promise<Response>;
23
+ callback: (request: Request) => Promise<Response | null>;
24
+ }>;
25
+ }>;
26
+ //# sourceMappingURL=coordinator-device-rebind-browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coordinator-device-rebind-browser.d.ts","sourceRoot":"","sources":["../src/coordinator-device-rebind-browser.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAQlE,OAAO,EAAE,KAAK,cAAc,EAAyB,MAAM,+BAA+B,CAAC;AAiB3F,OAAO,EAEN,KAAK,sBAAsB,EAE3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAE1E,MAAM,WAAW,wBAAwB;IACxC,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,cAAc,CAAC;IACxB,OAAO,EAAE,0BAA0B,CAAC;IACpC,wEAAwE;IACxE,OAAO,EAAE,eAAe,CAAC;IACzB,WAAW,CAAC,EAAE,sBAAsB,CAAC;IACrC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACnB;AAmKD,wBAAsB,yBAAyB,CAAC,KAAK,EAAE,wBAAwB;;;;;;4DATnD,OAAO,CAAC,QAAQ,CAAC;wDAAjB,OAAO,CAAC,QAAQ,CAAC;0DAAjB,OAAO,CAAC,QAAQ,CAAC;4BAiDhB,OAAO,KAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;;GAS9D"}
@@ -0,0 +1,126 @@
1
+ import type { CoordinatorAuthBrowserConfig } from "./coordinator-auth-browser-transaction-contract.js";
2
+ import type { AuthLinkBackend } from "./coordinator-auth-link.js";
3
+ import { type BrowserCsrfKey } from "./coordinator-browser-csrf.js";
4
+ import { type DeviceRebindReceipt } from "./coordinator-device-rebind-commit.js";
5
+ import type { CoordinatorOidcClient } from "./coordinator-oidc.js";
6
+ import type { InMemoryRequestRateLimiter } from "./request-rate-limit.js";
7
+ /** The signed device request's verified enrollment; the route authenticates it. */
8
+ export interface DeviceRebindSigner {
9
+ groupId: string;
10
+ deviceId: string;
11
+ publicKey: string;
12
+ fingerprint: string;
13
+ }
14
+ export interface DeviceRebindStart {
15
+ attemptId: string;
16
+ signer: DeviceRebindSigner;
17
+ /** The device's current Identity (its local actor), checked against its enrollments. */
18
+ currentIdentityId: string;
19
+ loopbackRedirect: string;
20
+ /** SHA-256 hex of the browser start code; the device keeps the code itself. */
21
+ browserStartHash: string;
22
+ /** SHA-256 hex of the device's local review; any local change aborts the switch. */
23
+ reviewDigest: string;
24
+ }
25
+ /** Why a step refused; the Viewer turns these into the next action for the person. */
26
+ export type DeviceRebindRefusal = "unavailable" | "current_identity_linked" | "device_already_bound" | "account_not_linked" | "already_this_identity" | "daily_limit" | "retry";
27
+ export interface DeviceRebindConfirmation {
28
+ attemptId: string;
29
+ deviceId: string;
30
+ fingerprint: string;
31
+ issuer: string;
32
+ subject: string;
33
+ currentIdentityId: string;
34
+ targetIdentityId: string;
35
+ /** Groups where the device stays enrolled but the target Identity has no access yet. */
36
+ groupsWithoutAccess: readonly string[];
37
+ confirmationHash: string;
38
+ }
39
+ export type DeviceRebindResult = {
40
+ kind: "refused";
41
+ reason: DeviceRebindRefusal;
42
+ /** This step burned the browser's transaction; its cookie can be cleared. */
43
+ retired?: true;
44
+ /** Where the browser tells the device the attempt ended, so it stops waiting. */
45
+ returnTo?: {
46
+ loopbackRedirect: string;
47
+ attemptId: string;
48
+ };
49
+ } | {
50
+ kind: "unknown";
51
+ } | {
52
+ kind: "started";
53
+ attemptId: string;
54
+ expiresAtMs: number;
55
+ } | {
56
+ kind: "browser_claimed";
57
+ authorizationUrl: string;
58
+ setCookies: string[];
59
+ } | {
60
+ kind: "verified";
61
+ confirmation: DeviceRebindConfirmation;
62
+ csrf: string;
63
+ } | {
64
+ kind: "confirmed";
65
+ completionSecret: string;
66
+ loopbackRedirect: string;
67
+ } | {
68
+ kind: "finalized" | "prior_commit";
69
+ receipt: DeviceRebindReceipt;
70
+ } | {
71
+ kind: "status";
72
+ state: string;
73
+ expiresAtMs: number;
74
+ /** Shown once the person confirmed; the device signs it at finalize. */
75
+ targetIdentityId: string | null;
76
+ receipt: DeviceRebindReceipt | null;
77
+ };
78
+ /** What the signed device steps need: no OIDC client or browser CSRF key. */
79
+ export interface DeviceRebindDeviceDependencies {
80
+ backend: AuthLinkBackend;
81
+ /** Store settings of the enabled browser-auth configuration. */
82
+ config: CoordinatorAuthBrowserConfig;
83
+ publicOrigin: string;
84
+ limiter: InMemoryRequestRateLimiter;
85
+ now(): number;
86
+ }
87
+ export interface DeviceRebindDependencies extends DeviceRebindDeviceDependencies {
88
+ csrfKey: BrowserCsrfKey;
89
+ client: Pick<CoordinatorOidcClient, "createAuthorizationRequest" | "verifyCallback">;
90
+ }
91
+ /**
92
+ * The browser and device ceremony for ADR 0005 Section 8 rebinding. Every
93
+ * step re-checks live authority in its winning statement; pre-reads only pick
94
+ * the refusal reason shown to the person.
95
+ */
96
+ export declare function createDeviceRebindCeremony(deps: DeviceRebindDependencies): Readonly<{
97
+ claimBrowser: (request: Request, clientKey: string) => Promise<DeviceRebindResult | null>;
98
+ verifyCallback: (request: Request) => Promise<DeviceRebindResult | null>;
99
+ confirm: (request: Request, clientKey: string, commitment: string) => Promise<DeviceRebindResult | null>;
100
+ start: (input: DeviceRebindStart, clientKey: string) => Promise<DeviceRebindResult | null>;
101
+ finalize: (input: {
102
+ attemptId: string;
103
+ signer: DeviceRebindSigner;
104
+ completionSecret: string;
105
+ signature: string;
106
+ }) => Promise<DeviceRebindResult | null>;
107
+ status: (input: {
108
+ attemptId: string;
109
+ signer: DeviceRebindSigner;
110
+ }) => Promise<DeviceRebindResult | null>;
111
+ }>;
112
+ /** The steps a signed device request drives: start, status, and finalize. */
113
+ export declare function createDeviceRebindDeviceSteps(deps: DeviceRebindDeviceDependencies): Readonly<{
114
+ start: (input: DeviceRebindStart, clientKey: string) => Promise<DeviceRebindResult | null>;
115
+ finalize: (input: {
116
+ attemptId: string;
117
+ signer: DeviceRebindSigner;
118
+ completionSecret: string;
119
+ signature: string;
120
+ }) => Promise<DeviceRebindResult | null>;
121
+ status: (input: {
122
+ attemptId: string;
123
+ signer: DeviceRebindSigner;
124
+ }) => Promise<DeviceRebindResult | null>;
125
+ }>;
126
+ //# sourceMappingURL=coordinator-device-rebind-ceremony.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coordinator-device-rebind-ceremony.d.ts","sourceRoot":"","sources":["../src/coordinator-device-rebind-ceremony.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oDAAoD,CAAC;AAEvG,OAAO,KAAK,EAAE,eAAe,EAAqB,MAAM,4BAA4B,CAAC;AAgBrF,OAAO,EACN,KAAK,cAAc,EAGnB,MAAM,+BAA+B,CAAC;AAIvC,OAAO,EAGN,KAAK,mBAAmB,EAGxB,MAAM,uCAAuC,CAAC;AAO/C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAE1E,mFAAmF;AACnF,MAAM,WAAW,kBAAkB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,wFAAwF;IACxF,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,+EAA+E;IAC/E,gBAAgB,EAAE,MAAM,CAAC;IACzB,oFAAoF;IACpF,YAAY,EAAE,MAAM,CAAC;CACrB;AAED,sFAAsF;AACtF,MAAM,MAAM,mBAAmB,GAC5B,aAAa,GACb,yBAAyB,GACzB,sBAAsB,GACtB,oBAAoB,GACpB,uBAAuB,GACvB,aAAa,GACb,OAAO,CAAC;AAEX,MAAM,WAAW,wBAAwB;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EA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7E,MAAM,WAAW,8BAA8B;IAC9C,OAAO,EAAE,eAAe,CAAC;IACzB,gEAAgE;IAChE,MAAM,EAAE,4BAA4B,CAAC;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,0BAA0B,CAAC;IACpC,GAAG,IAAI,MAAM,CAAC;CACd;AAED,MAAM,WAAW,wBAAyB,SAAQ,8BAA8B;IAC/E,OAAO,EAAE,cAAc,CAAC;IACxB,MAAM,EAAE,IAAI,CAAC,qBAAqB,EAAE,4BAA4B,GAAG,gBAAgB,CAAC,CAAC;CACrF;AAuGD;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,wBAAwB;2DAd7C,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;8BAmBlC,OAAO;0EAnBP,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;4DAAlC,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;;mBAghBjD,MAAM;gBACT,kBAAkB;0BACR,MAAM;mBACb,MAAM;UAnhBS,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;;mBAulBJ,MAAM;gBAAU,kBAAkB;UAvlBhE,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;GAsB7D;AAED,6EAA6E;AAC7E,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,8BAA8B;4DAzBtD,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;;mBAghBjD,MAAM;gBACT,kBAAkB;0BACR,MAAM;mBACb,MAAM;UAnhBS,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;;mBAulBJ,MAAM;gBAAU,kBAAkB;UAvlBhE,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;GA2B7D"}
@@ -0,0 +1,82 @@
1
+ declare const REFUSALS: readonly ["unavailable", "current_identity_linked", "device_already_bound", "account_not_linked", "already_this_identity", "daily_limit", "retry"];
2
+ export type DeviceRebindClientRefusal = (typeof REFUSALS)[number];
3
+ export interface DeviceRebindReceiptV1 {
4
+ attemptId: string;
5
+ bindingId: string;
6
+ deviceId: string;
7
+ previousIdentityId: string;
8
+ targetIdentityId: string;
9
+ enrollmentCount: number;
10
+ finalizedAtMs: number;
11
+ }
12
+ /** What the caller must store durably before finalize, to resume by status. */
13
+ export interface DeviceRebindPending {
14
+ attemptId: string;
15
+ coordinatorOrigin: string;
16
+ groupId: string;
17
+ deviceId: string;
18
+ previousIdentityId: string;
19
+ targetIdentityId: string;
20
+ reviewDigest: string;
21
+ expiresAtMs: number;
22
+ }
23
+ export type DeviceRebindOutcome = {
24
+ kind: "finalized";
25
+ receipt: DeviceRebindReceiptV1;
26
+ }
27
+ /** `beforeBrowser`: the coordinator refused the start, so no Google trip happened. */
28
+ | {
29
+ kind: "refused";
30
+ reason: DeviceRebindClientRefusal;
31
+ beforeBrowser?: true;
32
+ }
33
+ /** Nothing was committed; the person may start again. */
34
+ | {
35
+ kind: "failed";
36
+ error: "device_unavailable" | "request_failed" | "browser_stopped";
37
+ }
38
+ /** Finalize may have committed; resolve with resumeDeviceRebind. */
39
+ | {
40
+ kind: "unknown";
41
+ pending: DeviceRebindPending;
42
+ };
43
+ export interface DeviceRebindOptions {
44
+ dbPath: string;
45
+ keysDir?: string;
46
+ coordinatorUrl: string;
47
+ groupId: string;
48
+ /** The device's current Identity, which the coordinator checks against its enrollments. */
49
+ currentIdentityId: string;
50
+ /** SHA-256 hex of the device's local review; it is pinned and signed. */
51
+ reviewDigest: string;
52
+ openBrowser(url: string): void | Promise<void>;
53
+ /** Must persist durably; a throw stops the rebind before finalize. */
54
+ recordPending(pending: DeviceRebindPending): void | Promise<void>;
55
+ fetch?: typeof globalThis.fetch;
56
+ signal?: AbortSignal;
57
+ }
58
+ export declare function runDeviceRebind(options: DeviceRebindOptions): Promise<DeviceRebindOutcome>;
59
+ export interface ResumeOptions {
60
+ dbPath: string;
61
+ keysDir?: string;
62
+ coordinatorUrl: string;
63
+ groupId: string;
64
+ pending: DeviceRebindPending;
65
+ fetch?: typeof globalThis.fetch;
66
+ signal?: AbortSignal;
67
+ now?: () => number;
68
+ }
69
+ /**
70
+ * Reads the recorded attempt. `not_committed` only once the attempt can no
71
+ * longer finalize; otherwise an unclear answer stays `unknown`.
72
+ */
73
+ export declare function resumeDeviceRebind(options: ResumeOptions): Promise<{
74
+ kind: "finalized";
75
+ receipt: DeviceRebindReceiptV1;
76
+ } | {
77
+ kind: "not_committed";
78
+ } | {
79
+ kind: "unknown";
80
+ }>;
81
+ export {};
82
+ //# sourceMappingURL=coordinator-device-rebind-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coordinator-device-rebind-client.d.ts","sourceRoot":"","sources":["../src/coordinator-device-rebind-client.ts"],"names":[],"mappings":"AAuCA,QAAA,MAAM,QAAQ,YACb,aAAa,EACb,yBAAyB,EACzB,sBAAsB,EACtB,oBAAoB,EACpB,uBAAuB,EACvB,aAAa,EACb,OAAO,CACE,CAAC;AACX,MAAM,MAAM,yBAAyB,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;AAElE,MAAM,WAAW,qBAAqB;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;CACtB;AAED,+EAA+E;AAC/E,MAAM,WAAW,mBAAmB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM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KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CACvC,OAAO,EAAE,aAAa,GACpB,OAAO,CACP;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,qBAAqB,CAAA;CAAE,GACrD;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,GACzB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CACrB,CAwBA"}
@@ -0,0 +1,58 @@
1
+ import type { AuthLinkBackend } from "./coordinator-auth-link.js";
2
+ /** Finalized rebinds allowed per target Identity in any 24 hours (ADR 0005 Section 8). */
3
+ export declare const DEVICE_REBIND_DAILY_LIMIT = 3;
4
+ export type DeviceRebindReceipt = {
5
+ kind: "finalized";
6
+ attemptId: string;
7
+ bindingId: string;
8
+ deviceId: string;
9
+ previousIdentityId: string;
10
+ targetIdentityId: string;
11
+ enrollmentCount: number;
12
+ finalizedAtMs: number;
13
+ };
14
+ export type DeviceRebindCommitResult = {
15
+ kind: "committed";
16
+ receipt: DeviceRebindReceipt;
17
+ } | {
18
+ kind: "prior_commit";
19
+ receipt: DeviceRebindReceipt;
20
+ } | {
21
+ kind: "refused";
22
+ };
23
+ /**
24
+ * This device has no proof of its own for its current Identity, as account
25
+ * changes select it: no claim for this device and key in a live Team, and no
26
+ * active attestation for this key in a live Team it is still enrolled in (a binding
27
+ * already blocks every attempt). Only such a device may self-bind, getting a
28
+ * binding for the Identity it already uses.
29
+ */
30
+ export declare const NO_OWN_PROOF_SQL = "NOT EXISTS (SELECT 1 FROM coordinator_auth_device_claims d\n WHERE d.coordinator_id = a.coordinator_id AND d.identity_id = a.current_identity_id\n AND d.device_id = a.device_id AND d.key_id = a.key_id\n AND EXISTS (SELECT 1 FROM groups g WHERE g.group_id = d.group_id AND g.archived_at IS NULL))\n AND NOT EXISTS (SELECT 1 FROM coordinator_auth_controller_attestations t\n JOIN enrolled_devices e ON e.group_id = t.group_id AND e.device_id = t.device_id\n AND e.public_key = t.public_key AND e.fingerprint = t.fingerprint AND e.enabled = 1\n AND (e.identity_id IS NULL OR e.identity_id = t.identity_id)\n JOIN groups g ON g.group_id = t.group_id AND g.archived_at IS NULL\n WHERE t.coordinator_id = a.coordinator_id AND t.identity_id = a.current_identity_id\n AND t.device_id = a.device_id AND t.public_key = a.public_key AND t.fingerprint = a.fingerprint\n AND t.revoked_at IS NULL)";
31
+ /**
32
+ * Reads a finalized rebind from records that never change: the finalized
33
+ * attempt, its binding, and its audit event. Enrollments are not consulted,
34
+ * because an admin may change them after the commit. Resolves an unknown commit outcome
35
+ * without retrying the write. Null means "not committed as recorded".
36
+ */
37
+ export declare function readDeviceRebindReceipt(backend: AuthLinkBackend, coordinatorId: string, attemptId: string): Promise<DeviceRebindReceipt | null>;
38
+ interface DeviceRebindCommitInput {
39
+ backend: AuthLinkBackend;
40
+ coordinatorId: string;
41
+ attemptId: string;
42
+ /** Trusted current auth config revision, never a client value. */
43
+ revision: string;
44
+ now: number;
45
+ completionSecret: string;
46
+ signature: string;
47
+ }
48
+ /**
49
+ * One atomic commit: finalize the attempt, write the immutable ownership
50
+ * binding, move every enrollment of the device key to the target Identity, and
51
+ * record the audit event. Team memberships and grants are untouched. An exact
52
+ * retry of an already finalized attempt returns its receipt; anything else
53
+ * writes nothing. SQL errors propagate so an unknown outcome is never reported
54
+ * as a refusal; callers resolve it with readDeviceRebindReceipt.
55
+ */
56
+ export declare function commitDeviceRebind(input: DeviceRebindCommitInput): Promise<DeviceRebindCommitResult>;
57
+ export {};
58
+ //# sourceMappingURL=coordinator-device-rebind-commit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coordinator-device-rebind-commit.d.ts","sourceRoot":"","sources":["../src/coordinator-device-rebind-commit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAqB,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rebinding: start, status, finalize. */
2
+ import type { Hono } from "hono";
3
+ import type { registerCoordinatorDeviceAuthLinkRoutes } from "./coordinator-device-auth-link.js";
4
+ type LinkDeps = Parameters<typeof registerCoordinatorDeviceAuthLinkRoutes>[1];
5
+ export declare const DEVICE_REBIND_ATTEMPTS_PATH = "/v1/auth/rebind-attempts";
6
+ /** Signed admission runs before any rebind storage is touched. */
7
+ export declare function registerCoordinatorDeviceRebindRoutes(app: Hono, deps: LinkDeps & {
8
+ now?: () => number;
9
+ }): void;
10
+ export {};
11
+ //# sourceMappingURL=coordinator-device-rebind-http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coordinator-device-rebind-http.d.ts","sourceRoot":"","sources":["../src/coordinator-device-rebind-http.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,MAAM,CAAC;AAG1C,OAAO,KAAK,EAAE,uCAAuC,EAAE,MAAM,mCAAmC,CAAC;AAYjG,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,uCAAuC,CAAC,CAAC,CAAC,CAAC,CAAC;AAM9E,eAAO,MAAM,2BAA2B,6BAA6B,CAAC;AA2MtE,kEAAkE;AAClE,wBAAgB,qCAAqC,CACpD,GAAG,EAAE,IAAI,EACT,IAAI,EAAE,QAAQ,GAAG;IAAE,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CAAE,GACrC,IAAI,CASN"}
@@ -0,0 +1,55 @@
1
+ /** One stored rebinding attempt. Private ceremony state, never current authority. */
2
+ export interface DeviceRebindAttempt {
3
+ coordinator_id: string;
4
+ attempt_id: string;
5
+ origin: string;
6
+ device_id: string;
7
+ public_key: string;
8
+ key_id: string;
9
+ fingerprint: string;
10
+ current_identity_id: string;
11
+ issuer: string;
12
+ auth_config_revision: string;
13
+ loopback_redirect: string | null;
14
+ browser_start_hash: string;
15
+ browser_transaction_hash: string | null;
16
+ browser_binder_hash: string | null;
17
+ account_subject: string | null;
18
+ target_identity_id: string | null;
19
+ link_id: string | null;
20
+ link_authority_kind: "controller_attestation" | "device_claim" | null;
21
+ review_digest: string | null;
22
+ team_effects_json: string | null;
23
+ enrollment_count: number | null;
24
+ confirmation_hash: string | null;
25
+ completion_secret_hash: string | null;
26
+ final_key_proof_hash: string | null;
27
+ state: string;
28
+ created_at_ms: number;
29
+ expires_at_ms: number;
30
+ finalized_at_ms: number | null;
31
+ binding_id: string | null;
32
+ audit_event_id: string | null;
33
+ final_outcome_json: string | null;
34
+ }
35
+ /**
36
+ * What the browser confirms: the Google account, both Identities, the device,
37
+ * the local review digest, and the Team effects shown to the person.
38
+ */
39
+ export declare function deviceRebindConfirmationHash(a: DeviceRebindAttempt): Promise<string>;
40
+ /** What the device key signs after the loopback delivers the completion secret. */
41
+ export declare function deviceRebindFinalMessage(a: DeviceRebindAttempt, completionSecret: string): string;
42
+ /**
43
+ * Checks the three proofs this attempt binds: the confirmed browser commitment,
44
+ * the completion secret delivered to this device, and its enrolled key's
45
+ * signature. It does not check current authority; the commit SQL does that.
46
+ */
47
+ export declare function verifyDeviceRebindCompletion(a: DeviceRebindAttempt, input: {
48
+ revision: string;
49
+ now: number;
50
+ completionSecret: string;
51
+ signature: string;
52
+ }): Promise<{
53
+ keyProofHash: string;
54
+ } | null>;
55
+ //# sourceMappingURL=coordinator-device-rebind-proof.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coordinator-device-rebind-proof.d.ts","sourceRoot":"","sources":["../src/coordinator-device-rebind-proof.ts"],"names":[],"mappings":"AAOA,qFAAqF;AACrF,MAAM,WAAW,mBAAmB;IACnC,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB,EAAE,MAAM,CAA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,EACtB,KAAK,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACnF,OAAO,CAAC;IAAE,YAAY,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CAW1C"}
@@ -0,0 +1,38 @@
1
+ import type { AuthLinkBackend } from "./coordinator-auth-link.js";
2
+ /**
3
+ * Storage for ADR 0005 Section 8 rebinding: an enrolled device whose current
4
+ * Identity has no account link of its own moves to the Identity linked to the
5
+ * Google account it signs in with. A self-bind keeps the device's Identity
6
+ * (target = current) and gives a device without its own proof a binding. Both tables are additive. They never change
7
+ * the owner-enrollment tables, whose schema readiness checks compare exact DDL.
8
+ *
9
+ * Mirror: packages/cloudflare-coordinator-worker/migrations/0038_add_device_rebind.sql
10
+ */
11
+ export declare const COORDINATOR_DEVICE_REBIND_SCHEMA_SQL = "\nCREATE TABLE IF NOT EXISTS coordinator_device_rebind_attempts (\n coordinator_id TEXT NOT NULL,\n attempt_id TEXT NOT NULL,\n origin TEXT NOT NULL,\n device_id TEXT NOT NULL,\n public_key TEXT NOT NULL,\n key_id TEXT NOT NULL CHECK (length(key_id) = 64 AND key_id NOT GLOB '*[^0-9a-f]*'),\n fingerprint TEXT NOT NULL,\n current_identity_id TEXT NOT NULL CHECK (length(current_identity_id) BETWEEN 1 AND 256),\n issuer TEXT NOT NULL,\n auth_config_revision TEXT NOT NULL,\n loopback_redirect TEXT,\n browser_start_hash TEXT NOT NULL UNIQUE,\n browser_transaction_hash TEXT UNIQUE,\n browser_binder_hash TEXT,\n account_subject TEXT,\n target_identity_id TEXT,\n link_id TEXT,\n link_authority_kind TEXT CHECK (link_authority_kind IS NULL\n OR link_authority_kind IN ('controller_attestation', 'device_claim')),\n review_digest TEXT CHECK (review_digest IS NULL\n OR (length(review_digest) = 64 AND review_digest NOT GLOB '*[^0-9a-f]*')),\n team_effects_json TEXT CHECK (team_effects_json IS NULL OR json_valid(team_effects_json)),\n enrollment_count INTEGER CHECK (enrollment_count IS NULL OR enrollment_count BETWEEN 1 AND 50),\n confirmation_hash TEXT,\n completion_secret_hash TEXT UNIQUE,\n final_key_proof_hash TEXT,\n state TEXT NOT NULL CHECK (state IN\n ('pending', 'browser_claimed', 'oidc_verified', 'confirmed', 'finalized', 'expired', 'failed')),\n created_at_ms INTEGER NOT NULL,\n expires_at_ms INTEGER NOT NULL CHECK (expires_at_ms = created_at_ms + 600000),\n finalized_at_ms INTEGER,\n binding_id TEXT UNIQUE,\n audit_event_id TEXT UNIQUE,\n final_outcome_json TEXT CHECK (final_outcome_json IS NULL OR json_valid(final_outcome_json)),\n PRIMARY KEY (coordinator_id, attempt_id),\n CHECK (state NOT IN ('confirmed', 'finalized') OR (account_subject IS NOT NULL\n AND target_identity_id IS NOT NULL AND link_id IS NOT NULL AND link_authority_kind IS NOT NULL\n AND review_digest IS NOT NULL AND team_effects_json IS NOT NULL AND enrollment_count IS NOT NULL\n AND confirmation_hash IS NOT NULL AND completion_secret_hash IS NOT NULL)),\n CHECK (state <> 'finalized' OR (finalized_at_ms IS NOT NULL AND binding_id IS NOT NULL\n AND audit_event_id IS NOT NULL AND final_key_proof_hash IS NOT NULL\n AND final_outcome_json IS NOT NULL AND loopback_redirect IS NULL)),\n CHECK (state = 'finalized' OR (finalized_at_ms IS NULL AND binding_id IS NULL\n AND audit_event_id IS NULL AND final_key_proof_hash IS NULL AND final_outcome_json IS NULL)),\n CHECK (state NOT IN ('pending', 'browser_claimed', 'oidc_verified')\n OR (confirmation_hash IS NULL AND completion_secret_hash IS NULL)),\n CHECK (state NOT IN ('pending', 'browser_claimed') OR (account_subject IS NULL\n AND target_identity_id IS NULL AND link_id IS NULL AND link_authority_kind IS NULL\n AND team_effects_json IS NULL AND enrollment_count IS NULL)),\n CHECK (review_digest IS NOT NULL),\n CHECK (state <> 'pending' OR (browser_transaction_hash IS NULL AND browser_binder_hash IS NULL))\n);\n\nCREATE INDEX IF NOT EXISTS idx_coordinator_device_rebind_attempts_device\n ON coordinator_device_rebind_attempts (coordinator_id, device_id, state);\n\n-- Birth facts never change; proofs are set once; only forward transitions are allowed.\n-- The EXISTS clause stops UPDATE OR REPLACE from deleting another row through a unique key.\nCREATE TRIGGER IF NOT EXISTS coordinator_device_rebind_attempt_pins\nBEFORE UPDATE ON coordinator_device_rebind_attempts\nWHEN OLD.state IN ('finalized', 'expired', 'failed') OR NEW.rowid IS NOT OLD.rowid\n OR EXISTS (SELECT 1 FROM coordinator_device_rebind_attempts o\n WHERE NOT (o.coordinator_id = OLD.coordinator_id AND o.attempt_id = OLD.attempt_id)\n AND (o.browser_transaction_hash = NEW.browser_transaction_hash\n OR o.completion_secret_hash = NEW.completion_secret_hash\n OR o.binding_id = NEW.binding_id OR o.audit_event_id = NEW.audit_event_id))\n OR NEW.coordinator_id IS NOT OLD.coordinator_id OR NEW.attempt_id IS NOT OLD.attempt_id\n OR NEW.origin IS NOT OLD.origin OR NEW.device_id IS NOT OLD.device_id\n OR NEW.public_key IS NOT OLD.public_key OR NEW.key_id IS NOT OLD.key_id\n OR NEW.fingerprint IS NOT OLD.fingerprint OR NEW.current_identity_id IS NOT OLD.current_identity_id\n OR NEW.issuer IS NOT OLD.issuer OR NEW.auth_config_revision IS NOT OLD.auth_config_revision\n OR NEW.browser_start_hash IS NOT OLD.browser_start_hash\n OR NEW.created_at_ms IS NOT OLD.created_at_ms OR NEW.expires_at_ms IS NOT OLD.expires_at_ms\n OR (OLD.browser_transaction_hash IS NOT NULL AND NEW.browser_transaction_hash IS NOT OLD.browser_transaction_hash)\n OR (OLD.browser_binder_hash IS NOT NULL AND NEW.browser_binder_hash IS NOT OLD.browser_binder_hash)\n OR (OLD.account_subject IS NOT NULL AND NEW.account_subject IS NOT OLD.account_subject)\n OR (OLD.target_identity_id IS NOT NULL AND NEW.target_identity_id IS NOT OLD.target_identity_id)\n OR (OLD.link_id IS NOT NULL AND NEW.link_id IS NOT OLD.link_id)\n OR (OLD.review_digest IS NOT NULL AND NEW.review_digest IS NOT OLD.review_digest)\n OR (OLD.team_effects_json IS NOT NULL AND NEW.team_effects_json IS NOT OLD.team_effects_json)\n OR (OLD.enrollment_count IS NOT NULL AND NEW.enrollment_count IS NOT OLD.enrollment_count)\n OR (OLD.confirmation_hash IS NOT NULL AND NEW.confirmation_hash IS NOT OLD.confirmation_hash)\n OR (OLD.completion_secret_hash IS NOT NULL AND NEW.completion_secret_hash IS NOT OLD.completion_secret_hash)\n OR (NEW.loopback_redirect IS NOT OLD.loopback_redirect\n AND NOT (NEW.loopback_redirect IS NULL AND NEW.state IN ('finalized', 'expired', 'failed')))\n OR NOT ((OLD.state = NEW.state)\n OR (OLD.state = 'pending' AND NEW.state IN ('browser_claimed', 'expired', 'failed'))\n OR (OLD.state = 'browser_claimed' AND NEW.state IN ('oidc_verified', 'expired', 'failed'))\n OR (OLD.state = 'oidc_verified' AND NEW.state IN ('confirmed', 'expired', 'failed'))\n OR (OLD.state = 'confirmed' AND NEW.state IN ('finalized', 'expired', 'failed')))\nBEGIN\n SELECT RAISE(ABORT, 'device_rebind_attempt_immutable');\nEND;\n\n-- REPLACE's implicit deletes may skip DELETE triggers when recursive triggers are off.\nCREATE TRIGGER IF NOT EXISTS coordinator_device_rebind_attempt_insert_collision\nBEFORE INSERT ON coordinator_device_rebind_attempts\nWHEN EXISTS (SELECT 1 FROM coordinator_device_rebind_attempts\n WHERE rowid = NEW.rowid OR (coordinator_id = NEW.coordinator_id AND attempt_id = NEW.attempt_id)\n OR browser_start_hash = NEW.browser_start_hash\n OR browser_transaction_hash = NEW.browser_transaction_hash\n OR completion_secret_hash = NEW.completion_secret_hash\n OR binding_id = NEW.binding_id OR audit_event_id = NEW.audit_event_id)\nBEGIN\n SELECT RAISE(ABORT, 'device_rebind_attempt_collision');\nEND;\n\n-- An automatic rowid reads as -1 before insert; positive rowids keep that from matching a row.\nCREATE TRIGGER IF NOT EXISTS coordinator_device_rebind_attempt_rowid\nAFTER INSERT ON coordinator_device_rebind_attempts\nWHEN NEW.rowid < 1\nBEGIN\n SELECT RAISE(ABORT, 'device_rebind_attempt_rowid');\nEND;\n\nCREATE TRIGGER IF NOT EXISTS coordinator_device_rebind_attempt_retained\nBEFORE DELETE ON coordinator_device_rebind_attempts\nWHEN OLD.state = 'finalized'\nBEGIN\n SELECT RAISE(ABORT, 'device_rebind_attempt_immutable');\nEND;\n\nCREATE TABLE IF NOT EXISTS coordinator_device_rebind_audit_log (\n coordinator_id TEXT NOT NULL,\n event_id TEXT NOT NULL,\n attempt_id TEXT NOT NULL,\n action TEXT NOT NULL CHECK (action = 'owner_device_rebound'),\n binding_id TEXT NOT NULL,\n device_id TEXT NOT NULL,\n previous_identity_id TEXT NOT NULL,\n target_identity_id TEXT NOT NULL,\n enrollment_count INTEGER NOT NULL CHECK (enrollment_count BETWEEN 1 AND 50),\n created_at_ms INTEGER NOT NULL,\n PRIMARY KEY (coordinator_id, event_id),\n UNIQUE (coordinator_id, attempt_id)\n);\n\nCREATE INDEX IF NOT EXISTS idx_coordinator_device_rebind_audit_target\n ON coordinator_device_rebind_audit_log (coordinator_id, target_identity_id, created_at_ms);\n\nCREATE TRIGGER IF NOT EXISTS coordinator_device_rebind_audit_insert_collision\nBEFORE INSERT ON coordinator_device_rebind_audit_log\nWHEN EXISTS (SELECT 1 FROM coordinator_device_rebind_audit_log\n WHERE rowid = NEW.rowid\n OR (coordinator_id = NEW.coordinator_id AND (event_id = NEW.event_id OR attempt_id = NEW.attempt_id)))\nBEGIN\n SELECT RAISE(ABORT, 'device_rebind_audit_collision');\nEND;\n\nCREATE TRIGGER IF NOT EXISTS coordinator_device_rebind_audit_rowid\nAFTER INSERT ON coordinator_device_rebind_audit_log\nWHEN NEW.rowid < 1\nBEGIN\n SELECT RAISE(ABORT, 'device_rebind_audit_rowid');\nEND;\n\nCREATE TRIGGER IF NOT EXISTS coordinator_device_rebind_audit_immutable_update\nBEFORE UPDATE ON coordinator_device_rebind_audit_log\nBEGIN\n SELECT RAISE(ABORT, 'device_rebind_audit_immutable');\nEND;\n\nCREATE TRIGGER IF NOT EXISTS coordinator_device_rebind_audit_immutable_delete\nBEFORE DELETE ON coordinator_device_rebind_audit_log\nBEGIN\n SELECT RAISE(ABORT, 'device_rebind_audit_immutable');\nEND;\n";
12
+ /**
13
+ * The first pre-release attempts table forbade a review digest before OIDC,
14
+ * but the ceremony pins it at start. A coordinator that opened that build has
15
+ * the old table; recreate it while it is still empty (nothing wrote attempts
16
+ * before the routes shipped). With rows present it is left as is and starts
17
+ * fail closed.
18
+ */
19
+ export declare function upgradePreReleaseRebindAttemptsSql(existingTableSql: string | null, rows: number): string | null;
20
+ /**
21
+ * The backend, only when this database has the current rebind tables. Without
22
+ * them (a D1 database before migration 0038) rebind routes report not found
23
+ * and the shared OIDC callback skips the rebind hook.
24
+ */
25
+ export declare function readDeviceRebindBackend(backend: AuthLinkBackend): Promise<AuthLinkBackend | null>;
26
+ /**
27
+ * Rebuilds the attempts table without the first release's "target differs
28
+ * from current" CHECK, which self-binds need. Rows, the index and every
29
+ * trigger are kept. Mirror: migrations/0040_allow_device_self_bind.sql.
30
+ */
31
+ export declare function rebuildRebindAttemptsForSelfBindSql(): string;
32
+ /**
33
+ * True when an existing attempts table still forbids a self-bind. A
34
+ * pre-release table that kept rows (no review-digest CHECK) is left alone: its
35
+ * rows can't satisfy the current table, and it already fails closed.
36
+ */
37
+ export declare function rebindAttemptsNeedSelfBindRebuild(existingTableSql: string | null): boolean;
38
+ //# sourceMappingURL=coordinator-device-rebind-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coordinator-device-rebind-schema.d.ts","sourceRoot":"","sources":["../src/coordinator-device-rebind-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE;;;;;;;;GAQG;AACH,eAAO,MAAM,oCAAoC,qyRAyKhD,CAAC;AAWF;;;;;;GAMG;AACH,wBAAgB,kCAAkC,CACjD,gBAAgB,EAAE,MAAM,GAAG,IAAI,EAC/B,IAAI,EAAE,MAAM,GACV,MAAM,GAAG,IAAI,CAUf;AAQD;;;;GAIG;AACH,wBAAsB,uBAAuB,CAC5C,OAAO,EAAE,eAAe,GACtB,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAMjC;AAoBD;;;;GAIG;AACH,wBAAgB,mCAAmC,IAAI,MAAM,CAa5D;AAED;;;;GAIG;AACH,wBAAgB,iCAAiC,CAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAM1F"}
@@ -0,0 +1,47 @@
1
+ import type Database from "better-sqlite3";
2
+ import type { AuthLinkBackend } from "./coordinator-auth-link.js";
3
+ import { type Backend } from "./coordinator-auth-store-test-fixtures.js";
4
+ import { type DeviceRebindAttempt } from "./coordinator-device-rebind-proof.js";
5
+ import type { CoordinatorStore } from "./coordinator-store-contract.js";
6
+ export declare const NOW = 1791028800000;
7
+ export declare const COORDINATOR = "coordinator-a";
8
+ export declare const CURRENT = "local:device-work";
9
+ export declare const TARGET = "identity-target";
10
+ export declare const REVISION: string;
11
+ export declare const GROUPS: readonly ["group-a", "group-b"];
12
+ /** Every table a rebind may touch, for all-or-nothing assertions. */
13
+ export declare const EFFECT_TABLES: readonly ["coordinator_device_rebind_attempts", "coordinator_device_ownership_bindings", "enrolled_devices", "coordinator_device_rebind_audit_log", "coordinator_identity_group_grants", "coordinator_auth_account_links"];
14
+ export interface RebindFixture {
15
+ db: Database.Database;
16
+ store: CoordinatorStore;
17
+ backend: AuthLinkBackend;
18
+ attempt: DeviceRebindAttempt;
19
+ secret: string;
20
+ sign(message: string): string;
21
+ input(patch?: {
22
+ now?: number;
23
+ completionSecret?: string;
24
+ signature?: string;
25
+ }): {
26
+ backend: AuthLinkBackend;
27
+ coordinatorId: string;
28
+ attemptId: string;
29
+ revision: string;
30
+ now: number;
31
+ completionSecret: string;
32
+ signature: string;
33
+ };
34
+ effects(): unknown[][];
35
+ close(): Promise<void>;
36
+ }
37
+ /** A migrated device enrolled in two groups, confirmed to rebind to TARGET. */
38
+ export declare function rebindFixture(kind: Backend): Promise<RebindFixture>;
39
+ /** Gives the enrolled device its own claim for `identityId`, so it has proof and can't self-bind. */
40
+ export declare function insertOwnDeviceClaim(db: Database.Database, input: {
41
+ coordinatorId: string;
42
+ issuer: string;
43
+ revision: string;
44
+ identityId: string;
45
+ deviceId: string;
46
+ }): Promise<void>;
47
+ //# sourceMappingURL=coordinator-device-rebind-test-fixtures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coordinator-device-rebind-test-fixtures.d.ts","sourceRoot":"","sources":["../src/coordinator-device-rebind-test-fixtures.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAAE,KAAK,OAAO,EAAwB,MAAM,2CAA2C,CAAC;AAC/F,OAAO,EACN,KAAK,mBAAmB,EAGxB,MAAM,sCAAsC,CAAC;AAI9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAGxE,eAAO,MAAM,GAAG,gBAAoB,CAAC;AACrC,eAAO,MAAM,WAAW,kBAAkB,CAAC;AAC3C,eAAO,MAAM,OAAO,sBAAsB,CAAC;AAC3C,eAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,eAAO,MAAM,QAAQ,QAAiB,CAAC;AACvC,eAAO,MAAM,MAAM,YAAI,SAAS,EAAE,SAAS,CAAU,CAAC;AAEtD,qEAAqE;AACrE,eAAO,MAAM,aAAa,YACzB,oCAAoC,EACpC,uCAAuC,EACvC,kBAAkB,EAClB,qCAAqC,EACrC,mCAAmC,EACnC,gCAAgC,CACvB,CAAC;AAEX,MAAM,WAAW,aAAa;IAC7B,EAAE,EAAE,QAAQ,CAAC,QAAQ,CAAC;IACtB,KAAK,EAAE,gBAAgB,CAAC;IACxB,OAAO,EAAE,eAAe,CAAC;IACzB,OAAO,EAAE,mBAAmB,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B,KAAK,CAAC,KAAK,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG;QAC/E,OAAO,EAAE,eAAe,CAAC;QACzB,aAAa,EAAE,MAAM,CAAC;QACtB,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,GAAG,EAAE,MAAM,CAAC;QACZ,gBAAgB,EAAE,MAAM,CAAC;QACzB,SAAS,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,OAAO,IAAI,OAAO,EAAE,EAAE,CAAC;IACvB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB;AAuFD,+EAA+E;AAC/E,wBAAsB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAmCzE;AAED,qGAAqG;AACrG,wBAAsB,oBAAoB,CACzC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,KAAK,EAAE;IACN,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CACjB,GACC,OAAO,CAAC,IAAI,CAAC,CAkBf"}
@@ -0,0 +1,37 @@
1
+ /** Browser pages for ADR 0005 Section 8 rebinding. Presentation only; the ceremony decides. */
2
+ import { type CoordinatorAuthBrowserPage } from "./coordinator-auth-browser-view.js";
3
+ import type { DeviceRebindConfirmation, DeviceRebindRefusal } from "./coordinator-device-rebind-ceremony.js";
4
+ export declare const DEVICE_REBIND_BROWSER_PATHS: Readonly<{
5
+ start: "/auth/rebind/start";
6
+ confirm: "/auth/rebind/confirm";
7
+ }>;
8
+ /** Private start code stays in hidden form data; the page submits itself. */
9
+ export declare function renderDeviceRebindStartPage(input: {
10
+ attemptId: string;
11
+ startCode: string;
12
+ csrf: string;
13
+ }): Promise<CoordinatorAuthBrowserPage>;
14
+ export declare function renderDeviceRebindConfirmPage(input: {
15
+ confirmation: DeviceRebindConfirmation;
16
+ csrf: string;
17
+ }): Promise<CoordinatorAuthBrowserPage>;
18
+ /** Caller releases this secret-bearing page only after confirmation commits. */
19
+ export declare function renderDeviceRebindHopPage(input: {
20
+ loopbackRedirect: string;
21
+ attemptId: string;
22
+ completionSecret: string;
23
+ confirmationHash: string;
24
+ }): Promise<CoordinatorAuthBrowserPage>;
25
+ /** Browser-only states on top of the ceremony's refusals. */
26
+ export type DeviceRebindNotice = DeviceRebindRefusal | "unknown" | "rate_limited" | "busy";
27
+ /**
28
+ * A refusal at the Google callback: explain it here and send the browser back
29
+ * to the device, which stops waiting and shows the next step.
30
+ */
31
+ export declare function renderDeviceRebindReturnPage(input: {
32
+ reason: DeviceRebindRefusal;
33
+ loopbackRedirect: string;
34
+ attemptId: string;
35
+ }): Promise<CoordinatorAuthBrowserPage>;
36
+ export declare function renderDeviceRebindNotice(reason: DeviceRebindNotice): Promise<CoordinatorAuthBrowserPage>;
37
+ //# sourceMappingURL=coordinator-device-rebind-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coordinator-device-rebind-view.d.ts","sourceRoot":"","sources":["../src/coordinator-device-rebind-view.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,OAAO,EAEN,KAAK,0BAA0B,EAE/B,MAAM,oCAAoC,CAAC;AAE5C,OAAO,KAAK,EACX,wBAAwB,EACxB,mBAAmB,EACnB,MAAM,yCAAyC,CAAC;AAEjD,eAAO,MAAM,2BAA2B;;;EAGtC,CAAC;AAeH,6EAA6E;AAC7E,wBAAgB,2BAA2B,CAAC,KAAK,EAAE;IAClD,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACb,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAQtC;AA6BD,wBAAgB,6BAA6B,CAAC,KAAK,EAAE;IACpD,YAAY,EAAE,wBAAwB,CAAC;IACvC,IAAI,EAAE,MAAM,CAAC;CACb,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAqBtC;AAED,gFAAgF;AAChF,wBAAgB,yBAAyB,CAAC,KAAK,EAAE;IAChD,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;CACzB,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAgBtC;AAED,6DAA6D;AAC7D,MAAM,MAAM,kBAAkB,GAAG,mBAAmB,GAAG,SAAS,GAAG,cAAc,GAAG,MAAM,CAAC;AAiC3F;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE;IACnD,MAAM,EAAE,mBAAmB,CAAC;IAC5B,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAWtC;AAED,wBAAgB,wBAAwB,CACvC,MAAM,EAAE,kBAAkB,GACxB,OAAO,CAAC,0BAA0B,CAAC,CAGrC"}
@@ -0,0 +1,14 @@
1
+ import type { CoordinatorEnrollment } from "./coordinator-store-contract.js";
2
+ /**
3
+ * The device's ownership binding, if it has exactly one. A rebind (ADR 0005
4
+ * Section 8) writes one, so admins can tell a rebound device from a conflict.
5
+ */
6
+ export declare const ENROLLMENT_OWNERSHIP_COLUMNS = "(SELECT CASE WHEN count(*) = 1 THEN max(b.identity_id) END\n\t FROM coordinator_device_ownership_bindings b\n\t WHERE b.device_id = enrolled_devices.device_id) AS ownership_identity_id,\n\t(SELECT CASE WHEN count(*) = 1 THEN max(b.key_id) END\n\t FROM coordinator_device_ownership_bindings b\n\t WHERE b.device_id = enrolled_devices.device_id) AS ownership_key_id";
7
+ /**
8
+ * Keeps `ownership_identity_id` only when the binding names this enrollment's
9
+ * exact key; a binding for another key says nothing about this enrollment.
10
+ */
11
+ export declare function withEnrollmentOwnership(rows: ReadonlyArray<CoordinatorEnrollment & {
12
+ ownership_key_id?: unknown;
13
+ }>): Promise<CoordinatorEnrollment[]>;
14
+ //# sourceMappingURL=coordinator-enrollment-ownership.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coordinator-enrollment-ownership.d.ts","sourceRoot":"","sources":["../src/coordinator-enrollment-ownership.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAE7E;;;GAGG;AACH,eAAO,MAAM,4BAA4B,gXAK6B,CAAC;AAEvE;;;GAGG;AACH,wBAAsB,uBAAuB,CAC5C,IAAI,EAAE,aAAa,CAAC,qBAAqB,GAAG;IAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,GACzE,OAAO,CAAC,qBAAqB,EAAE,CAAC,CASlC"}
@@ -1 +1 @@
1
- {"version":3,"file":"coordinator-enrollment-reconciler.d.ts","sourceRoot":"","sources":["../src/coordinator-enrollment-reconciler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AAE9E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAexC,MAAM,WAAW,mCAAmC;IACnD,IAAI,EAAE,QAAQ,GAAG,iBAAiB,CAAC;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,oCAAoC;IACpD,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,mCAAmC,EAAE,CAAC;CAC9C;AAED,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAShF;AA6ED,wBAAsB,sCAAsC,CAC3D,EAAE,EAAE,QAAQ,EACZ,KAAK,EAAE;IACN,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,qBAAqB,EAAE,CAAC;IACrC,mBAAmB,EAAE,6BAA6B,EAAE,CAAC;IACrD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;CACb,GACC,OAAO,CAAC,oCAAoC,CAAC,CA0b/C"}
1
+ {"version":3,"file":"coordinator-enrollment-reconciler.d.ts","sourceRoot":"","sources":["../src/coordinator-enrollment-reconciler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AAE9E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAexC,MAAM,WAAW,mCAAmC;IACnD,IAAI,EAAE,QAAQ,GAAG,iBAAiB,CAAC;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,oCAAoC;IACpD,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,mCAAmC,EAAE,CAAC;CAC9C;AAED,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAShF;AAwLD,wBAAsB,sCAAsC,CAC3D,EAAE,EAAE,QAAQ,EACZ,KAAK,EAAE;IACN,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,qBAAqB,EAAE,CAAC;IACrC,mBAAmB,EAAE,6BAA6B,EAAE,CAAC;IACrD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;CACb,GACC,OAAO,CAAC,oCAAoC,CAAC,CAia/C"}
@@ -23,10 +23,10 @@ export declare function historyCases(statement: AuthLinkStatement): {
23
23
  selected: boolean;
24
24
  }[];
25
25
  export declare function compareHistorySql(backend: Backend, statement: AuthLinkStatement): Promise<{
26
+ error?: undefined;
26
27
  rows: {
27
28
  row: string;
28
29
  }[];
29
- error?: undefined;
30
30
  } | {
31
31
  rows?: undefined;
32
32
  error: string;
@@ -1 +1 @@
1
- {"version":3,"file":"coordinator-history-sql-equivalence-test-fixtures.d.ts","sourceRoot":"","sources":["../src/coordinator-history-sql-equivalence-test-fixtures.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAOpE,KAAK,OAAO,GAAG;IACd,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,iBAAiB,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;IACnD,KAAK,CAAC,CAAC,EAAE,SAAS,EAAE,iBAAiB,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;CAC1D,CAAC;AAoBF,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAsBvD;AAED,wBAAsB,iBAAiB,CACtC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE;;;sBAyB7C;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE;iBAGb,MAAM;;GAMxC;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,iBAAiB;UAYpC,MAAM;SAAO,MAAM;cAAY,OAAO;IA0B1D;AAuDD,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,iBAAiB;;aAG3C,MAAM;;;;;;GAShD"}
1
+ {"version":3,"file":"coordinator-history-sql-equivalence-test-fixtures.d.ts","sourceRoot":"","sources":["../src/coordinator-history-sql-equivalence-test-fixtures.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAOpE,KAAK,OAAO,GAAG;IACd,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,iBAAiB,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;IACnD,KAAK,CAAC,CAAC,EAAE,SAAS,EAAE,iBAAiB,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;CAC1D,CAAC;AAoBF,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAsBvD;AAED,wBAAsB,iBAAiB,CACtC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE;;;sBAyB7C;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE;iBAGb,MAAM;;GAMxC;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,iBAAiB;UAYpC,MAAM;SAAO,MAAM;cAAY,OAAO;IA0B1D;AAuDD,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,iBAAiB;;;aAG3C,MAAM;;;;;GAShD"}
@@ -1 +1 @@
1
- {"version":3,"file":"coordinator-legacy-completion-owner-proof.d.ts","sourceRoot":"","sources":["../src/coordin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AC,EACzB,QAAQ,EAAE,UAAU,CAAC,OAAO,wBAAwB,CAAC,GACnD,yBAAyB,CA8C3B;AAgPD;;GAEG;AACH,wBAAsB,iCAAiC,CAAC,KAAK,EAAE;IAC9D,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAyBtC;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,0BAA0B,GAAG,QAAQ,CAEzF"}
1
+ {"version":3,"file":"coordinator-legacy-completion-owner-proof.d.ts","sourceRoot":"","sources":["../src/coordinator-legacy-completion-owner-proof.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,uBAAuB,EAC5B,KAAK,yBAAyB,EAG9B,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAEN,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,eAAe,EAGpB,MAAM,qDAAqD,CAAC;AAoB7D,UAAU,OAAO;IAChB,KAAK,CAAC,CAAC,EAAE,SAAS,EAAE,iBAAiB,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAC1D,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,iBAAiB,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;CACnD;AAED,qEAAqE;AACrE,MAAM,WAAW,0BAA0B;IAC1C,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;CACpB;AAED,UAAU,OAAQ,SAAQ,eAAe;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,EAAE,MAAM,EAAE,CAAC;CACvB;AAcD,UAAU,QAAQ;IACjB,sEAAsE;IACtE,QAAQ,CAAC,IAAI,EAAE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