@tryvitris/website-admin-contracts 1.2.0 → 1.3.1
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/dist/index.d.ts +2 -0
- package/dist/index.js +14 -1
- package/dist/signon.d.ts +51 -0
- package/dist/signon.js +9 -0
- package/package.json +36 -36
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from './client-onboarding.js';
|
|
|
5
5
|
export * from './scheduling.js';
|
|
6
6
|
export * from './webmaster.js';
|
|
7
7
|
export * from './pairing.js';
|
|
8
|
+
export * from './signon.js';
|
|
8
9
|
export declare const contractVersion = 1;
|
|
9
10
|
export declare const coreSections: readonly ["overview", "leads", "analytics", "settings", "access", "activity"];
|
|
10
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"];
|
|
@@ -13,6 +14,7 @@ export type Role = 'owner' | 'administrator' | 'editor' | 'analyst';
|
|
|
13
14
|
export declare const roles: Record<Role, readonly Permission[]>;
|
|
14
15
|
export declare function can(role: Role, permission: Permission): boolean;
|
|
15
16
|
export interface AdminManifest {
|
|
17
|
+
webmasterSignOn?: import('./signon.js').SignOnConfiguration;
|
|
16
18
|
reportingPairing?: import('./pairing.js').PairingConfiguration;
|
|
17
19
|
schemaVersion: 1;
|
|
18
20
|
installationId: string;
|
package/dist/index.js
CHANGED
|
@@ -9,6 +9,7 @@ export * from "./client-onboarding.js";
|
|
|
9
9
|
export * from "./scheduling.js";
|
|
10
10
|
export * from "./webmaster.js";
|
|
11
11
|
export * from "./pairing.js";
|
|
12
|
+
export * from "./signon.js";
|
|
12
13
|
const contractVersion = 1;
|
|
13
14
|
const coreSections = ["overview", "leads", "analytics", "settings", "access", "activity"];
|
|
14
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];
|
|
@@ -131,6 +132,17 @@ function parseManifest(value) {
|
|
|
131
132
|
if (new Set(trustedWebmasters.map((p) => p.adminOrigin)).size !== trustedWebmasters.length) throw new Error("Duplicate trusted webmaster origin");
|
|
132
133
|
reportingPairing = { trustedWebmasters };
|
|
133
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
|
+
}
|
|
134
146
|
return {
|
|
135
147
|
schemaVersion: 1,
|
|
136
148
|
installationId: id(v.installationId, "installation ID"),
|
|
@@ -140,7 +152,8 @@ function parseManifest(value) {
|
|
|
140
152
|
modules,
|
|
141
153
|
...backend ? { backend } : {},
|
|
142
154
|
...v.theme ? { theme: v.theme } : {},
|
|
143
|
-
...reportingPairing ? { reportingPairing } : {}
|
|
155
|
+
...reportingPairing ? { reportingPairing } : {},
|
|
156
|
+
...webmasterSignOn ? { webmasterSignOn } : {}
|
|
144
157
|
};
|
|
145
158
|
}
|
|
146
159
|
function validateModules(manifest, modules) {
|
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
|
+
};
|
package/package.json
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@tryvitris/website-admin-contracts",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"description": "Validated installation and module contracts for Cloudflare business admin apps",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": {
|
|
9
|
-
"types": "./dist/index.d.ts",
|
|
10
|
-
"default": "./dist/index.js"
|
|
11
|
-
},
|
|
12
|
-
"./scheduling": {
|
|
13
|
-
"types": "./dist/scheduling.d.ts",
|
|
14
|
-
"default": "./dist/scheduling.js"
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
"files": [
|
|
18
|
-
"dist"
|
|
19
|
-
],
|
|
20
|
-
"publishConfig": {
|
|
21
|
-
"access": "public",
|
|
22
|
-
"tag": "latest"
|
|
23
|
-
},
|
|
24
|
-
"engines": {
|
|
25
|
-
"node": ">=24"
|
|
26
|
-
},
|
|
27
|
-
"repository": {
|
|
28
|
-
"type": "git",
|
|
29
|
-
"url": "git+https://github.com/jackperrotta/website-admin-harness.git",
|
|
30
|
-
"directory": "packages/contracts"
|
|
31
|
-
},
|
|
32
|
-
"homepage": "https://github.com/jackperrotta/website-admin-harness#readme",
|
|
33
|
-
"bugs": {
|
|
34
|
-
"url": "https://github.com/jackperrotta/website-admin-harness/issues"
|
|
35
|
-
}
|
|
36
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@tryvitris/website-admin-contracts",
|
|
3
|
+
"version": "1.3.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"description": "Validated installation and module contracts for Cloudflare business admin apps",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./scheduling": {
|
|
13
|
+
"types": "./dist/scheduling.d.ts",
|
|
14
|
+
"default": "./dist/scheduling.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public",
|
|
22
|
+
"tag": "latest"
|
|
23
|
+
},
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=24"
|
|
26
|
+
},
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/jackperrotta/website-admin-harness.git",
|
|
30
|
+
"directory": "packages/contracts"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/jackperrotta/website-admin-harness#readme",
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/jackperrotta/website-admin-harness/issues"
|
|
35
|
+
}
|
|
36
|
+
}
|