@vantageos/cloud-identity 0.2.0 → 0.4.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,82 @@
3
3
  All notable changes to `@vantageos/cloud-identity` are documented here.
4
4
  This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5
5
 
6
+ ## [0.4.0]
7
+
8
+ **Additive.** Two new primitives so one identity layer covers both deployment
9
+ shapes and the human sign-in path — no separate self-host layer, no change to
10
+ the Cloud/machine path. Serves Tau's `vantage-starter` self-host install and
11
+ the Hephaistos human-path onboarding, both stalled on this surface.
12
+
13
+ ### Added
14
+
15
+ - **Named deployment mode** — `DeploymentMode` (`"cloud" | "self-host"`) and a
16
+ `{ kind: "self-host"; tenantId }` branch on `TenantSource` / `requireTenantId`
17
+ (`src/org-guard.ts`). `cloud` keeps the existing fail-closed behaviour
18
+ unchanged (org/workspace required on every request — invariant #1123 holds,
19
+ 0.4.0 reopens nothing). `self-host` is single-tenant: `requireTenantId`
20
+ returns the configured `tenantId` only when it is a non-empty string, and
21
+ **throws** otherwise — the tenant is presented explicitly by configuration,
22
+ never inferred from the absence of an organization.
23
+ - **Human-path resolver** — `normalizeVerifiedHumanSession()` (`src/human-path.ts`,
24
+ new `./human-path` subpath export) maps an already-*verified*, framework-agnostic
25
+ Clerk-shaped session (`{ orgId, userId, orgRole }`) to
26
+ `{ tenant, subject, role }`. `role` is a new union `HumanAccountRole`
27
+ (`owner | admin | member | client`), distinct from `workspaceRoleSchema`
28
+ (`Admin | Editor | Viewer`) and never conflated. No Clerk SDK is imported.
29
+ Refuses (throws) on no session, no org, no user id, or an unrecognized/absent
30
+ org role — presented, never inferred. **Naming fix, still pre-publish:** this
31
+ function was originally named `resolveHumanIdentity`, which invited passing
32
+ in an unverified, client-supplied object (e.g. `req.body`) and would make
33
+ that object the trusted source of tenant/subject/role — a
34
+ privilege-escalation risk. Renamed to `normalizeVerifiedHumanSession` before
35
+ 0.4.0 reaches npm (current published latest is 0.3.0) to make the
36
+ already-verified precondition explicit at the call-site, mirroring
37
+ `decodeUnverifiedBearer`'s rename from `resolveBearer` in 0.2.0. Not a
38
+ breaking change — 0.4.0 has no npm consumer yet.
39
+
40
+ ### Notes
41
+
42
+ - Purely additive: every 0.3.0 export (`passesScopeFilter`, `scopeFilterList`,
43
+ `scopeFilterGet`, `validateMasterBearer`, `getEffectiveTenantId`,
44
+ `decodeUnverifiedBearer`, `requireTenantId`'s `session`/`bearer` branches, …)
45
+ is behaviorally unchanged. Full suite 87/87, `tsc --noEmit` 0.
46
+
47
+ ## [Unreleased] - 0.3.0
48
+
49
+ **BREAKING.** Closes two measured 0.2.0 defects — a right must never be
50
+ granted by absence.
51
+
52
+ ### Changed (breaking)
53
+
54
+ - `passesScopeFilter`, `scopeFilterList`, `scopeFilterGet`, `isMasterScope`,
55
+ `isWildcardScope`: `oauthCtx` is now **mandatory** (`OAuthCtx`, no longer
56
+ `OAuthCtx | undefined`). The 0.2.0 behaviour of an omitted `oauthCtx`
57
+ silently passing every row (wildcard, as if master-scoped) is removed.
58
+ Omitting the argument now breaks the caller's build; at runtime (for
59
+ callers that bypass TypeScript) it throws instead of granting access.
60
+ Callers that deliberately want the old legacy-bearer wildcard behaviour
61
+ must import and pass the new `LEGACY_WILDCARD_CTX` sentinel explicitly.
62
+
63
+ ### Added
64
+
65
+ - `LEGACY_WILDCARD_CTX` — explicit, by-name opt-in for the pre-0.3.0
66
+ legacy-bearer wildcard behaviour (`src/scope-filter.ts`).
67
+ - `requireTenantId(source: TenantSource): string` — organization/workspace
68
+ membership guard, unifying the human (session) and machine (bearer) entry
69
+ paths behind one contract. Refuses on missing session, missing/empty `orgId`, and
70
+ missing/empty bearer-resolved `workspaceId` (`src/org-guard.ts`).
71
+ - `SessionIdentity`, `TenantSource` types.
72
+
73
+ ### Scope note
74
+
75
+ The package now exposes, behind one contract, all four primitives an
76
+ application needs and should never reimplement: tenant resolution
77
+ (`getEffectiveTenantId`), membership requirement (`requireTenantId`), row
78
+ filtering (`passesScopeFilter` / `scopeFilterList` / `scopeFilterGet`), and
79
+ identifier validation (`validateMasterBearer`). Framework adapters (Convex,
80
+ Hono, etc.) wrap these; they must not reimplement the checks.
81
+
6
82
  ## [0.2.0] - 2026-06-13
7
83
 
8
84
  Additive release — domain-tenancy layer. No breaking changes. All 0.1.0 exports unchanged.
@@ -38,5 +114,5 @@ Initial release.
38
114
  - Public type surface: `OAuthCtx`, `ScopeProfile`, `NamespacePrefix`, `FromAllowListEntry`, `ValidateMasterBearerResult`.
39
115
 
40
116
  ### Notes
41
- - `getEffectiveWorkspaceId` deferred to 0.2.0 (depends on `vantageos-crm` workspace helper, owned by Theta).
117
+ - `getEffectiveWorkspaceId` deferred to 0.2.0.
42
118
  - No `provenance: true` in `publishConfig` — provenance only from CI per fleet friction lesson `npm-publish-provenance-only-from-ci-not-local-host`.
package/LICENSE CHANGED
@@ -1,21 +1,110 @@
1
- MIT License
1
+ Functional Source License, Version 1.1, Apache 2.0 Future License
2
2
 
3
- Copyright (c) 2026 VantagePeers Cloud
3
+ Abbreviation
4
4
 
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
5
+ FSL-1.1-Apache-2.0
11
6
 
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
7
+ Notice
8
+
9
+ Copyright 2026 VantageOS (ElPi Corp)
10
+
11
+ Terms and Conditions
12
+
13
+ Licensor: VantageOS (ElPi Corp)
14
+
15
+ Licensed Work: VantagePeers
16
+ The Licensed Work is (c) 2026 VantageOS (ElPi Corp)
17
+
18
+ Additional Use Grant: You may make production use of the Licensed Work,
19
+ provided Your use does not include offering the Licensed
20
+ Work to third parties as a hosted or managed service
21
+ where the service provides users with access to any
22
+ substantial set of the features or functionality of the
23
+ Licensed Work.
24
+
25
+ Change Date: 2028-04-03 (two years from publication)
26
+
27
+ Change License: Apache License, Version 2.0
28
+
29
+ For information about alternative licensing arrangements for the Licensed Work,
30
+ please contact: contact@vantageos.com
31
+
32
+ License text below is provided for informational purposes only.
33
+
34
+ ---
35
+
36
+ Functional Source License, Version 1.1, Apache 2.0 Future License
37
+
38
+ 1. Purpose
39
+
40
+ This license gives you broad permission to use, modify, and share this
41
+ software, with one important condition: you may not use it to compete with us.
42
+
43
+ 2. Acceptance
44
+
45
+ To use the software, you must agree to these terms. If you do not agree, you
46
+ may not use the software.
47
+
48
+ 3. Copyright License
49
+
50
+ The licensor grants you a non-exclusive, royalty-free, worldwide, non-
51
+ sublicensable, non-transferable license to use, copy, distribute, make
52
+ available, and prepare derivative works of the software, in each case subject
53
+ to the limitations below.
54
+
55
+ 4. Limitations
56
+
57
+ You may not make the functionality of the software available to third parties
58
+ as a service, or otherwise use the software to provide a service to third
59
+ parties that competes with the licensor.
60
+
61
+ 5. Patents
62
+
63
+ The licensor grants you a license, under any patent claims the licensor can
64
+ license or becomes able to license, to make, have made, use, sell, offer for
65
+ sale, import, and have imported the software, in each case subject to the
66
+ limitations and conditions in this license.
67
+
68
+ 6. Fair Use
69
+
70
+ This license is not intended to limit any rights you may have under applicable
71
+ fair use or other laws.
72
+
73
+ 7. No Other Rights
74
+
75
+ These terms do not grant any other rights. The licensor reserves all rights not
76
+ expressly granted.
77
+
78
+ 8. Termination
79
+
80
+ Your license is automatically terminated if you violate the terms. However, if
81
+ you cure the violation within 30 days of discovering it, your license is
82
+ reinstated retroactively.
83
+
84
+ 9. Disclaimer
14
85
 
15
86
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
87
+ IMPLIED.
88
+
89
+ 10. Limitation of Liability
90
+
91
+ TO THE EXTENT PERMITTED BY LAW, THE LICENSOR IS NOT LIABLE FOR ANY DAMAGES
92
+ ARISING FROM THE USE OF THE SOFTWARE.
93
+
94
+ 11. Change Date and License
95
+
96
+ After the Change Date, the licensor grants you the rights under the Change
97
+ License.
98
+
99
+ 12. Definitions
100
+
101
+ "Compete" means providing a product or service that is substantially similar
102
+ to, or a replacement for, all or a significant portion of the Licensed Work.
103
+
104
+ ---
105
+
106
+ Apache License, Version 2.0
107
+
108
+ After the Change Date (2028-04-03), this software will be available under the
109
+ Apache License, Version 2.0. See https://www.apache.org/licenses/LICENSE-2.0
110
+ for full text.