@tryvitris/website-admin-contracts 1.1.0 → 1.3.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/LICENSE +21 -21
- package/README.md +3 -3
- package/dist/index.d.ts +4 -0
- package/dist/index.js +28 -1
- package/dist/pairing.d.ts +94 -0
- package/dist/pairing.js +19 -0
- package/dist/signon.d.ts +51 -0
- package/dist/signon.js +9 -0
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Vitris contributors
|
|
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:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
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.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vitris contributors
|
|
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:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
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.
|
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
# Website Admin Contracts
|
|
2
|
-
|
|
3
|
-
Validated installation manifests, roles, permissions and module contracts for `@tryvitris/website-admin-harness`. Node.js 24+. MIT licensed.
|
|
1
|
+
# Website Admin Contracts
|
|
2
|
+
|
|
3
|
+
Validated installation manifests, roles, permissions and module contracts for `@tryvitris/website-admin-harness`. Node.js 24+. MIT licensed.
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export * from './client-portfolio.js';
|
|
|
4
4
|
export * from './client-onboarding.js';
|
|
5
5
|
export * from './scheduling.js';
|
|
6
6
|
export * from './webmaster.js';
|
|
7
|
+
export * from './pairing.js';
|
|
8
|
+
export * from './signon.js';
|
|
7
9
|
export declare const contractVersion = 1;
|
|
8
10
|
export declare const coreSections: readonly ["overview", "leads", "analytics", "settings", "access", "activity"];
|
|
9
11
|
export declare const permissions: readonly ["leads:read", "leads:write", "analytics:read", "settings:write", "access:read", "access:write", "activity:read", "tasks:read", "tasks:write", "appointments:read", "appointments:write", "availability:write", "scheduling:configure", "calendar-connections:manage", "clients:read", "client-changes:request", "client-releases:publish", "prospects:read", "prospects:write", "billing:read", "billing:customers:write", "billing:catalog:read", "billing:subscriptions:write", "billing:invoices:write", "billing:collect", "billing:connection:manage", "account-billing:read", "account-billing:manage"];
|
|
@@ -12,6 +14,8 @@ export type Role = 'owner' | 'administrator' | 'editor' | 'analyst';
|
|
|
12
14
|
export declare const roles: Record<Role, readonly Permission[]>;
|
|
13
15
|
export declare function can(role: Role, permission: Permission): boolean;
|
|
14
16
|
export interface AdminManifest {
|
|
17
|
+
webmasterSignOn?: import('./signon.js').SignOnConfiguration;
|
|
18
|
+
reportingPairing?: import('./pairing.js').PairingConfiguration;
|
|
15
19
|
schemaVersion: 1;
|
|
16
20
|
installationId: string;
|
|
17
21
|
business: {
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,8 @@ export * from "./client-portfolio.js";
|
|
|
8
8
|
export * from "./client-onboarding.js";
|
|
9
9
|
export * from "./scheduling.js";
|
|
10
10
|
export * from "./webmaster.js";
|
|
11
|
+
export * from "./pairing.js";
|
|
12
|
+
export * from "./signon.js";
|
|
11
13
|
const contractVersion = 1;
|
|
12
14
|
const coreSections = ["overview", "leads", "analytics", "settings", "access", "activity"];
|
|
13
15
|
const permissions = ["leads:read", "leads:write", "analytics:read", "settings:write", "access:read", "access:write", "activity:read", "tasks:read", "tasks:write", ...schedulingPermissions, ...clientPortfolioPermissions, ...clientOnboardingPermissions, ...billingPermissions];
|
|
@@ -118,6 +120,29 @@ function parseManifest(value) {
|
|
|
118
120
|
backend = { provider: "vitris-harness", origin: origin(b.origin, "backend origin"), tenantId };
|
|
119
121
|
if (isLoopback(backend.origin) && !isLoopback(String(v.adminOrigin))) throw new Error("Production admin cannot connect to a local backend");
|
|
120
122
|
}
|
|
123
|
+
let reportingPairing;
|
|
124
|
+
if (v.reportingPairing !== void 0) {
|
|
125
|
+
const config = object(v.reportingPairing);
|
|
126
|
+
if (!Array.isArray(config.trustedWebmasters) || config.trustedWebmasters.length < 1 || config.trustedWebmasters.length > 10) throw new Error("Configure trusted webmaster installations explicitly");
|
|
127
|
+
const trustedWebmasters = config.trustedWebmasters.map((raw) => {
|
|
128
|
+
const p = object(raw), adminOrigin = origin(p.adminOrigin, "trusted webmaster origin");
|
|
129
|
+
if (isLoopback(adminOrigin) && !isLoopback(String(v.adminOrigin))) throw new Error("A production issuer cannot trust a local webmaster");
|
|
130
|
+
return { installationId: id(p.installationId, "webmaster installation ID"), siteId: id(p.siteId, "webmaster site ID"), adminOrigin, organizationId: id(p.organizationId, "webmaster organization ID"), organizationName: text(p.organizationName, "webmaster organization name") };
|
|
131
|
+
});
|
|
132
|
+
if (new Set(trustedWebmasters.map((p) => p.adminOrigin)).size !== trustedWebmasters.length) throw new Error("Duplicate trusted webmaster origin");
|
|
133
|
+
reportingPairing = { trustedWebmasters };
|
|
134
|
+
}
|
|
135
|
+
let webmasterSignOn;
|
|
136
|
+
if (v.webmasterSignOn !== void 0) {
|
|
137
|
+
const c = object(v.webmasterSignOn);
|
|
138
|
+
if (c.mode === "broker") webmasterSignOn = { mode: "broker" };
|
|
139
|
+
else if (c.mode === "client") {
|
|
140
|
+
const b = object(c.broker), k = object(c.publicKey), adminOrigin = origin(b.adminOrigin, "sign-on broker origin");
|
|
141
|
+
if (isLoopback(adminOrigin) && !isLoopback(String(v.adminOrigin))) throw Error("A production client cannot trust a local sign-on broker");
|
|
142
|
+
if (k.kty !== "EC" || k.crv !== "P-256" || typeof k.x !== "string" || typeof k.y !== "string" || !/^[-\w]{43}$/.test(k.x) || !/^[-\w]{43}$/.test(k.y) || k.d !== void 0) throw Error("Pin the broker public P-256 key");
|
|
143
|
+
webmasterSignOn = { mode: "client", broker: { installationId: id(b.installationId, "broker installation ID"), siteId: id(b.siteId, "broker site ID"), adminOrigin }, subjectId: text(c.subjectId, "approved broker subject", 100), organizationId: id(c.organizationId, "webmaster organization ID"), publicKey: { kty: "EC", crv: "P-256", x: k.x, y: k.y } };
|
|
144
|
+
} else throw Error("Unsupported webmaster sign-on mode");
|
|
145
|
+
}
|
|
121
146
|
return {
|
|
122
147
|
schemaVersion: 1,
|
|
123
148
|
installationId: id(v.installationId, "installation ID"),
|
|
@@ -126,7 +151,9 @@ function parseManifest(value) {
|
|
|
126
151
|
adminOrigin: origin(v.adminOrigin, "admin origin"),
|
|
127
152
|
modules,
|
|
128
153
|
...backend ? { backend } : {},
|
|
129
|
-
...v.theme ? { theme: v.theme } : {}
|
|
154
|
+
...v.theme ? { theme: v.theme } : {},
|
|
155
|
+
...reportingPairing ? { reportingPairing } : {},
|
|
156
|
+
...webmasterSignOn ? { webmasterSignOn } : {}
|
|
130
157
|
};
|
|
131
158
|
}
|
|
132
159
|
function validateModules(manifest, modules) {
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export declare const reportingPairingVersion = 1;
|
|
2
|
+
export declare const pairingBase = "/api/webmaster-reporting/v1";
|
|
3
|
+
export declare const pairingMachineActions: readonly ["request", "poll", "exchange", "report", "rotate", "revoke"];
|
|
4
|
+
export type PairingMachineAction = typeof pairingMachineActions[number];
|
|
5
|
+
export declare const pairingPaths: Record<"capabilities" | "approval" | "approve" | "reject" | "grants" | "revoke-grant" | PairingMachineAction, string>;
|
|
6
|
+
export declare const pairingPolicy: {
|
|
7
|
+
requestLifetimeSeconds: number;
|
|
8
|
+
receiptLifetimeSeconds: number;
|
|
9
|
+
signatureSkewSeconds: number;
|
|
10
|
+
analyticsDays: readonly [14, 30];
|
|
11
|
+
};
|
|
12
|
+
export interface PairingStart {
|
|
13
|
+
requestId: string;
|
|
14
|
+
challenge: string;
|
|
15
|
+
}
|
|
16
|
+
export interface PairingExchange {
|
|
17
|
+
requestId: string;
|
|
18
|
+
code: string;
|
|
19
|
+
verifier: string;
|
|
20
|
+
}
|
|
21
|
+
export interface PairingReportRequest {
|
|
22
|
+
grantId: string;
|
|
23
|
+
operation: 'status' | 'analytics';
|
|
24
|
+
days?: 14 | 30;
|
|
25
|
+
}
|
|
26
|
+
export interface PairingMutation {
|
|
27
|
+
grantId: string;
|
|
28
|
+
operationId: string;
|
|
29
|
+
}
|
|
30
|
+
export declare const reportingOperations: readonly ["status", "analytics"];
|
|
31
|
+
export interface PairingIdentity {
|
|
32
|
+
installationId: string;
|
|
33
|
+
siteId: string;
|
|
34
|
+
adminOrigin: string;
|
|
35
|
+
}
|
|
36
|
+
export interface PairingPeer extends PairingIdentity {
|
|
37
|
+
organizationId: string;
|
|
38
|
+
organizationName: string;
|
|
39
|
+
}
|
|
40
|
+
export interface PairingConfiguration {
|
|
41
|
+
trustedWebmasters: PairingPeer[];
|
|
42
|
+
}
|
|
43
|
+
export interface PairingCapabilities {
|
|
44
|
+
version: 1;
|
|
45
|
+
issuer: PairingIdentity;
|
|
46
|
+
siteOrigin: string;
|
|
47
|
+
operations: readonly ['status', 'analytics'];
|
|
48
|
+
scope: 'analytics:read';
|
|
49
|
+
requestPath: string;
|
|
50
|
+
approvalPath: string;
|
|
51
|
+
}
|
|
52
|
+
export interface PairingEnvelope {
|
|
53
|
+
version: 1;
|
|
54
|
+
identity: PairingIdentity;
|
|
55
|
+
target: string;
|
|
56
|
+
path: string;
|
|
57
|
+
time: number;
|
|
58
|
+
nonce: string;
|
|
59
|
+
tokenHash: string;
|
|
60
|
+
request: Record<string, unknown>;
|
|
61
|
+
}
|
|
62
|
+
export interface PairingCredential {
|
|
63
|
+
version: 1;
|
|
64
|
+
issuer: PairingIdentity;
|
|
65
|
+
consumer: PairingIdentity;
|
|
66
|
+
siteOrigin: string;
|
|
67
|
+
grantId: string;
|
|
68
|
+
token: string;
|
|
69
|
+
keyId: string;
|
|
70
|
+
scope: 'analytics:read';
|
|
71
|
+
operations: readonly ['status', 'analytics'];
|
|
72
|
+
}
|
|
73
|
+
export interface PairingGrantView {
|
|
74
|
+
id: string;
|
|
75
|
+
organizationId: string;
|
|
76
|
+
organizationName: string;
|
|
77
|
+
consumer: PairingIdentity;
|
|
78
|
+
createdAt: number;
|
|
79
|
+
lastUsedAt: number | null;
|
|
80
|
+
revokedAt: number | null;
|
|
81
|
+
revision: number;
|
|
82
|
+
}
|
|
83
|
+
export interface PairingRequestView {
|
|
84
|
+
id: string;
|
|
85
|
+
organizationName: string;
|
|
86
|
+
consumer: PairingIdentity;
|
|
87
|
+
issuer: PairingIdentity;
|
|
88
|
+
expiresAt: number;
|
|
89
|
+
status: 'pending' | 'approved' | 'revoked' | 'expired';
|
|
90
|
+
scope: 'analytics:read';
|
|
91
|
+
createsRelationship: boolean;
|
|
92
|
+
}
|
|
93
|
+
export type PairingErrorCode = 'invalid_request' | 'unauthorized' | 'forbidden' | 'expired' | 'replay' | 'conflict' | 'unavailable' | 'unsupported';
|
|
94
|
+
export declare function samePairingIdentity(a: PairingIdentity, b: PairingIdentity): boolean;
|
package/dist/pairing.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// packages/contracts/src/pairing.ts
|
|
2
|
+
var reportingPairingVersion = 1;
|
|
3
|
+
var pairingBase = "/api/webmaster-reporting/v1";
|
|
4
|
+
var pairingMachineActions = ["request", "poll", "exchange", "report", "rotate", "revoke"];
|
|
5
|
+
var pairingPaths = Object.fromEntries(["capabilities", "approval", "approve", "reject", "grants", "revoke-grant", ...pairingMachineActions].map((action) => [action, pairingBase + "/" + action]));
|
|
6
|
+
var pairingPolicy = { requestLifetimeSeconds: 600, receiptLifetimeSeconds: 600, signatureSkewSeconds: 90, analyticsDays: [14, 30] };
|
|
7
|
+
var reportingOperations = ["status", "analytics"];
|
|
8
|
+
function samePairingIdentity(a, b) {
|
|
9
|
+
return a.installationId === b.installationId && a.siteId === b.siteId && a.adminOrigin === b.adminOrigin;
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
pairingBase,
|
|
13
|
+
pairingMachineActions,
|
|
14
|
+
pairingPaths,
|
|
15
|
+
pairingPolicy,
|
|
16
|
+
reportingOperations,
|
|
17
|
+
reportingPairingVersion,
|
|
18
|
+
samePairingIdentity
|
|
19
|
+
};
|
package/dist/signon.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { PairingIdentity } from './pairing.js';
|
|
2
|
+
export declare const signOnVersion = 1;
|
|
3
|
+
export declare const signOnBase = "/api/webmaster-sso/v1";
|
|
4
|
+
export declare const signOnPolicy: {
|
|
5
|
+
flowSeconds: number;
|
|
6
|
+
codeSeconds: number;
|
|
7
|
+
approvalSeconds: number;
|
|
8
|
+
sessionSeconds: number;
|
|
9
|
+
uiCheckMilliseconds: number;
|
|
10
|
+
};
|
|
11
|
+
export type SignOnConfiguration = {
|
|
12
|
+
mode: 'broker';
|
|
13
|
+
} | {
|
|
14
|
+
mode: 'client';
|
|
15
|
+
broker: PairingIdentity;
|
|
16
|
+
subjectId: string;
|
|
17
|
+
organizationId: string;
|
|
18
|
+
publicKey: {
|
|
19
|
+
kty: 'EC';
|
|
20
|
+
crv: 'P-256';
|
|
21
|
+
x: string;
|
|
22
|
+
y: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export interface SignOnAssertion {
|
|
26
|
+
version: 1;
|
|
27
|
+
issuer: PairingIdentity;
|
|
28
|
+
audience: PairingIdentity;
|
|
29
|
+
subject: {
|
|
30
|
+
id: string;
|
|
31
|
+
email: string;
|
|
32
|
+
};
|
|
33
|
+
lease: string;
|
|
34
|
+
expiresAt: number;
|
|
35
|
+
flowId: string;
|
|
36
|
+
}
|
|
37
|
+
export interface SignOnStatus {
|
|
38
|
+
version: 1;
|
|
39
|
+
issuer: PairingIdentity;
|
|
40
|
+
audience: PairingIdentity;
|
|
41
|
+
nonce: string;
|
|
42
|
+
leaseHash: string;
|
|
43
|
+
subjectId: string;
|
|
44
|
+
active: boolean;
|
|
45
|
+
expiresAt: number;
|
|
46
|
+
time: number;
|
|
47
|
+
}
|
|
48
|
+
export interface SignedSignOn {
|
|
49
|
+
payload: string;
|
|
50
|
+
signature: string;
|
|
51
|
+
}
|
package/dist/signon.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// packages/contracts/src/signon.ts
|
|
2
|
+
var signOnVersion = 1;
|
|
3
|
+
var signOnBase = "/api/webmaster-sso/v1";
|
|
4
|
+
var signOnPolicy = { flowSeconds: 300, codeSeconds: 60, approvalSeconds: 600, sessionSeconds: 28800, uiCheckMilliseconds: 5e3 };
|
|
5
|
+
export {
|
|
6
|
+
signOnBase,
|
|
7
|
+
signOnPolicy,
|
|
8
|
+
signOnVersion
|
|
9
|
+
};
|