You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(encryption): an encrypted object shaped like the Date marker is revived as a Date whatever its value #52
EncryptionModifier stores a Date inside an encrypted value as { "type": "Date", "value": "<toUTCString>" } and date_decoder (src/modifiers/encryption.ts) turns every object with exactly the keys type and value, type === "Date", back into new Date(value.value) without checking what value.value is. A caller who stores such an object themselves gets a different value back.
Reproduction (built package, 0.1.11):
constlib=require("./dist/index.js");classTextendslib.Table.with(lib.EncryptionModifier){}lib.Encrypted({secretKey: "0123456789abcdef0123456789abcdef"})(T.prototype,"card");constrow=newT();row.card={type: "Date",value: 123};console.log(row.cardinstanceofDate,row.card);// true, 1970-01-01T00:00:00.123Z: the stored object is not returned
Expected: only the marker date_encoder writes (value a string toUTCString can have produced) is revived, and any other object comes back as stored. Fixing it is a behaviour change, so the 0.2.17 burn-down left it (six rows of encryption.ts:37-43 stay under the ratchet).
Fixed by #57 (revive only the date marker the encoder writes), landed on main (921bf9d, the landed campaign/integration PR #87). Checked on main with the issue's repro: row.card = { type: 'Date', value: 123 } now reads back as the plain object, not a Date.
Activity
Upd4ting commentedon Nov 4, 2026
Fixed by #57 (revive only the date marker the encoder writes), landed on main (921bf9d, the landed campaign/integration PR #87). Checked on main with the issue's repro: row.card = { type: 'Date', value: 123 } now reads back as the plain object, not a Date.