DeriveClaimCode produces the 6-digit code for the given (user, workspace) at the given wall-clock time. Exported so the Phase E "Connect project" modal handler can render the same code the claim path will verify. secret must be at least 16 bytes of cryptographically-strong material — production wir
(secret []byte, userID, workspaceID string, at time.Time)
| 76 | // Returns "000000"–"999999" zero-padded so the wire format is uniform |
| 77 | // (avoids an agent stripping leading zeros when echoing the code back). |
| 78 | func DeriveClaimCode(secret []byte, userID, workspaceID string, at time.Time) string { |
| 79 | bucket := at.UTC().Unix() / claimBucketSeconds |
| 80 | return deriveClaimCodeForBucket(secret, userID, workspaceID, bucket) |
| 81 | } |
| 82 | |
| 83 | // deriveClaimCodeForBucket is the inner derive — split out so |
| 84 | // VerifyClaimCode can derive both the current and previous bucket |