@forklaunch/core 1.6.7 → 2.0.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.
@@ -48,26 +48,29 @@ import type { EntityManager } from '@mikro-orm/core';
48
48
  * }
49
49
  * ```
50
50
  *
51
- * # The empty tenant is a tenant
51
+ * # The empty tenant is not a tenant
52
52
  *
53
- * Global rows (a billing plan, a trial, a template) are encrypted under the
54
- * empty tenant `''`. A caller that passes `''` means "bind the no-tenant
55
- * key", and gets a Proxy that runs every EM call inside
56
- * `withEncryptionContext('', …)`. Only `undefined` means "do not wrap": the
57
- * EM is returned as is and inherits whatever context is already bound,
58
- * which is right for a super-admin lookup that has not resolved a tenant
59
- * yet, and wrong for anything that writes.
53
+ * `''` is rejected: it throws `EmptyTenantError`. It used to mean "bind the
54
+ * no-tenant key", which is how global rows (a billing plan, a trial, a
55
+ * template) were encrypted — and it made a deliberate global row and a tenant
56
+ * nobody resolved the same key. A path that forgot to bind wrote perfectly
57
+ * readable rows under `''`, and the mistake surfaced later, somewhere else, as
58
+ * the owning tenant's "Failed to decrypt encrypted column value".
60
59
  *
61
- * Earlier versions treated `''` like `undefined` and also seeded the ALS
62
- * with `enterWith`, which mutates the *calling* async resource. Together
63
- * those meant: after one org-scoped EM was created on a request, a later
64
- * "no-tenant" EM on the same resource silently read and wrote under that
65
- * org's key. Global rows then came out unreadable ("Failed to decrypt
66
- * encrypted column value") depending on what had run before on the worker.
60
+ * Global rows need an id you can name and search for. Pick a constant no
61
+ * organization can collide with — the platform uses `'_internal'` — and bind
62
+ * it like any other tenant.
63
+ *
64
+ * `undefined` still means "do not wrap": the EM is returned as is and inherits
65
+ * whatever context is already bound. That is right only for a lookup that has
66
+ * not resolved a tenant yet and reads no encrypted column; anything that
67
+ * touches one now fails with `UnboundTenantError` rather than quietly using
68
+ * the empty key.
67
69
  *
68
70
  * @param em a freshly forked `EntityManager` from `orm.em.fork(...)`
69
- * @param tenantId the org/tenant id to bind; `''` binds the no-tenant key;
71
+ * @param tenantId the org/tenant id to bind; `''` throws;
70
72
  * `undefined` skips wrapping entirely
73
+ * @throws EmptyTenantError when `tenantId` is `''`
71
74
  */
72
75
  export declare function wrapEmWithTenantContext(em: EntityManager, tenantId: string | undefined): EntityManager;
73
76
  //# sourceMappingURL=tenantEm.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tenantEm.d.ts","sourceRoot":"","sources":["../../src/persistence/tenantEm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AACH,wBAAgB,uBAAuB,CACrC,EAAE,EAAE,aAAa,EACjB,QAAQ,EAAE,MAAM,GAAG,SAAS,GAC3B,aAAa,CA8Bf"}
1
+ {"version":3,"file":"tenantEm.d.ts","sourceRoot":"","sources":["../../src/persistence/tenantEm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AACH,wBAAgB,uBAAuB,CACrC,EAAE,EAAE,aAAa,EACjB,QAAQ,EAAE,MAAM,GAAG,SAAS,GAC3B,aAAa,CA4Bf"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forklaunch/core",
3
- "version": "1.6.7",
3
+ "version": "2.0.0",
4
4
  "description": "forklaunch-js core package. Contains useful building blocks.",
5
5
  "homepage": "https://github.com/forklaunch/forklaunch-js#readme",
6
6
  "bugs": {