@rexezuge/identity 1.8.2 → 1.9.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResolvedAccount.d.ts","sourceRoot":"","sources":["../src/ResolvedAccount.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ResolvedAccount.d.ts","sourceRoot":"","sources":["../src/ResolvedAccount.ts"],"names":[],"mappings":"AAmBA;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,OAAO;IACtB,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED;;EAEE;AACF,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,eAAe,EAAE,IAAI,GAAG,OAAO,GAAG,UAAU,CAAC,CAAC;AAEhF;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,EAAE,IAAI,GAAG,OAAO,GAAG,eAAe,GAAG,UAAU,CAAC,GAAG,IAAI,CAAC;AAE9F;;EAEE;AACF,wBAAgB,SAAS,CAAC,GAAG,EAAE,WAAW,GAAG,eAAe,GAAG,IAAI,CAIlE;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAElC"}
|
package/dist/ResolvedAccount.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var l=Object.defineProperty;var n=(e,a)=>l(e,"name",{value:a,configurable:!0});const r=n(()=>crypto.randomUUID(),"randomUUID");function i(e){return e?.id?{id:e.id,email:(e.current_email??e.email).toLowerCase(),anchorEmail:e.email,username:e.username??null}:null}n(i,"summarize");function t(){return`usr_${r().replaceAll("-","")}`}n(t,"newAccountId");function c(){return`anchor-${r().replaceAll("-","")}@users.invalid`}n(c,"newAnchor");export{t as newAccountId,c as newAnchor,i as summarize};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/ResolvedAccount.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "+EAAA,
|
|
6
|
-
"names": ["randomUUID", "
|
|
4
|
+
"sourcesContent": ["/**\n * A v4 UUID.\n *\n * The global `crypto`, not `node:crypto`. Both APIs produce the same value, but\n * only one of them resolves everywhere this kit runs: `node:crypto`'s\n * *specifier* is a Node builtin, so a Worker needs either a compatibility date\n * of 2026-08-04 or later, or an explicit `nodejs_compat` flag, before the\n * module resolves at all. `globalThis.crypto.randomUUID` is a Web Crypto method,\n * natively implemented in the Workers runtime and in Node 19+, and needs\n * neither.\n *\n * This mattered because a consumer that adopted `@rexezuge/identity` without\n * knowing it inherited a `nodejs_compat` requirement. That failure is invisible\n * at build time and surfaces only on the account-creation path at runtime, in a\n * Worker deployed with `compatibility_flags: []` — which is exactly how two of\n * the family repos are configured.\n */\nconst randomUUID = (): string => crypto.randomUUID();\n\n/**\n * `users` rows — the stored form of an account.\n *\n * Converged from `backend-data/src/dao/UserDAO.ts` + its `UserRow` (identical in\n * six of the seven identity-carrying repos; AWS and ChordDHT keep only the\n * id/email core).\n *\n * `id` is the stable account key. `email` is the *anchor*: an immutable value\n * that legacy `*_email` foreign keys resolve against, so history stays\n * resolvable across an address change. `current_email` is the address the\n * account signs in with and the one APIs report.\n */\nexport interface UserRow {\n id?: string | null;\n /**\n * The frozen anchor address. Never updated — it is the foreign-key target\n * every legacy `*_email` value resolves against, and rewriting it would\n * cascade the rows that reference it. Read `current_email` for sign-in.\n */\n email: string;\n /**\n * Mutable sign-in address. Absent on a pre-identity database, where `email`\n * *is* the sign-in address; read it as `current_email ?? email`.\n */\n current_email?: string | null;\n created_at: number;\n username: string | null;\n updated_at: number | null;\n}\n\n/**\n * A resolved account.\n *\n * `id` is the only value that should be used as an identity. `email` is the\n * address the account currently signs in with; `anchorEmail` is the immutable\n * value legacy columns store, and is what a pre-identity row can still be\n * matched on.\n */\nexport interface ResolvedAccount {\n id: string;\n email: string;\n anchorEmail: string;\n username: string | null;\n}\n\n/**\nThe denormalized subset routes and the permission path use.\n*/\nexport type AccountSummary = Pick<ResolvedAccount, 'id' | 'email' | 'username'>;\n\n/**\n * Shape every `users` read has, whether or not the identity migration has run.\n *\n * `| null` for the absent row because that is what `UserDAO` returns now — the\n * DAO layer answers `null` for \"no row\", matching D1 and KV. The union is\n * widened into `summarize` rather than normalised there, so `summarize` accepts\n * either a row or the absence of one without a caller rewriting it first.\n */\nexport type UserRowLike = Pick<UserRow, 'id' | 'email' | 'current_email' | 'username'> | null;\n\n/**\nProject a `users` row onto a `ResolvedAccount`.\n*/\nexport function summarize(row: UserRowLike): ResolvedAccount | null {\n return row?.id\n ? { id: row.id, email: (row.current_email ?? row.email).toLowerCase(), anchorEmail: row.email, username: row.username ?? null }\n : null;\n}\n\n/**\n * The opaque account id.\n *\n * Prefixed so an id is never mistaken for an address in a log line or a URL,\n * and random at 128 bits so accounts are not enumerable.\n */\nexport function newAccountId(): string {\n return `usr_${randomUUID().replaceAll('-', '')}`;\n}\n\n/**\n * Opaque anchor for an account whose login address is already held as another\n * account's anchor.\n *\n * It must be globally unique and must never be a real address: `email` is the\n * anchor every legacy `*_email` foreign key resolves against, so an address\n * parked here could never be re-registered by a different person after its\n * original account moved off it. `.invalid` is reserved by RFC 2606 and can\n * never be delivered to, so it can never authenticate either.\n */\nexport function newAnchor(): string {\n return `anchor-${randomUUID().replaceAll('-', '')}@users.invalid`;\n}\n"],
|
|
5
|
+
"mappings": "+EAiBA,MAAMA,EAAaC,EAAA,IAAc,OAAO,WAAU,EAA/B,cAiEb,SAAUC,EAAUC,EAAgB,CACxC,OAAOA,GAAK,GACR,CAAE,GAAIA,EAAI,GAAI,OAAQA,EAAI,eAAiBA,EAAI,OAAO,YAAW,EAAI,YAAaA,EAAI,MAAO,SAAUA,EAAI,UAAY,IAAI,EAC3H,IACN,CAJgBF,EAAAC,EAAA,aAYV,SAAUE,GAAY,CAC1B,MAAO,OAAOJ,EAAU,EAAG,WAAW,IAAK,EAAE,CAAC,EAChD,CAFgBC,EAAAG,EAAA,gBAcV,SAAUC,GAAS,CACvB,MAAO,UAAUL,EAAU,EAAG,WAAW,IAAK,EAAE,CAAC,gBACnD,CAFgBC,EAAAI,EAAA",
|
|
6
|
+
"names": ["randomUUID", "__name", "summarize", "row", "newAccountId", "newAnchor"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rexezuge/identity",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@rexezuge/
|
|
29
|
-
"@rexezuge/
|
|
30
|
-
"@rexezuge/shared": "1.
|
|
28
|
+
"@rexezuge/d1": "1.9.0",
|
|
29
|
+
"@rexezuge/errors": "1.9.0",
|
|
30
|
+
"@rexezuge/shared": "1.9.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/node": "26.6.4",
|