@orbit-work/oem-sdk 0.1.7 → 0.1.8
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/audit-brand.js +47 -37
- package/dist/audit-brand.js.map +1 -1
- package/dist/audit.d.ts +3 -0
- package/dist/audit.js +47 -37
- package/dist/audit.js.map +1 -1
- package/dist/{chunk-YMKYAM23.js → chunk-C4G3TUO6.js} +2 -2
- package/dist/{chunk-YMKYAM23.js.map → chunk-C4G3TUO6.js.map} +1 -1
- package/dist/{chunk-ZOURSTKZ.js → chunk-KFDD7FES.js} +38 -33
- package/dist/chunk-KFDD7FES.js.map +1 -0
- package/dist/index.js +2 -2
- package/dist/manifest.d.ts +7 -0
- package/dist/manifest.js +1 -1
- package/dist/runtime.js +2 -2
- package/package.json +2 -2
- package/schema/orbit-brand.schema.json +12 -2
- package/dist/chunk-ZOURSTKZ.js.map +0 -1
package/dist/audit.js
CHANGED
|
@@ -21,6 +21,7 @@ var ROOT_KEYS = /* @__PURE__ */ new Set([
|
|
|
21
21
|
"tokens",
|
|
22
22
|
"typography",
|
|
23
23
|
"fontScale",
|
|
24
|
+
"appearance",
|
|
24
25
|
"assets",
|
|
25
26
|
"branding",
|
|
26
27
|
"locales",
|
|
@@ -34,6 +35,7 @@ var CONTRIBUTES_KEYS = /* @__PURE__ */ new Set(["slots"]);
|
|
|
34
35
|
var NETWORK_KEYS = /* @__PURE__ */ new Set(["allowedOrigins"]);
|
|
35
36
|
var PERMISSIONS_KEYS = /* @__PURE__ */ new Set(["microphoneUsage"]);
|
|
36
37
|
var TYPOGRAPHY_KEYS = /* @__PURE__ */ new Set(["fontSans", "fontMono"]);
|
|
38
|
+
var APPEARANCE_KEYS = /* @__PURE__ */ new Set(["homeBackdrop"]);
|
|
37
39
|
var BRANDING_KEYS = /* @__PURE__ */ new Set(["productName", "companyName", "claim", "claimNote", "slogan"]);
|
|
38
40
|
var SLOT_COMMON_KEYS = /* @__PURE__ */ new Set(["name"]);
|
|
39
41
|
var BRAND_TOKEN_NAMES = /* @__PURE__ */ new Set([...UNIFIED_NEUTRAL_TOKENS, ...BRAND_ACTION_TOKENS]);
|
|
@@ -46,16 +48,7 @@ var SOURCE_ENTRY = /^\.\/src\/.+\.(?:[cm]?js|[jt]sx?)$/;
|
|
|
46
48
|
var WINDOWS_DEVICE_NAME = /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\..*)?$/i;
|
|
47
49
|
var OFFICIAL_APP_ID = "ai.orbit.desktop";
|
|
48
50
|
var OFFICIAL_PRODUCT_NAMES = /* @__PURE__ */ new Set(["orbitwork"]);
|
|
49
|
-
var RESERVED_VERSION_CHANNELS = /* @__PURE__ */ new Set([
|
|
50
|
-
"stable",
|
|
51
|
-
"preview",
|
|
52
|
-
"uat",
|
|
53
|
-
"latest",
|
|
54
|
-
"desktop",
|
|
55
|
-
"macos",
|
|
56
|
-
"windows",
|
|
57
|
-
"linux"
|
|
58
|
-
]);
|
|
51
|
+
var RESERVED_VERSION_CHANNELS = /* @__PURE__ */ new Set(["stable", "debug", "latest", "desktop", "macos", "windows", "linux"]);
|
|
59
52
|
var RESERVED_PROTOCOL_SCHEMES = /* @__PURE__ */ new Set([
|
|
60
53
|
"about",
|
|
61
54
|
"blob",
|
|
@@ -118,32 +111,30 @@ function relativePath(value, path) {
|
|
|
118
111
|
}
|
|
119
112
|
function parseIdentity(value, id, platform) {
|
|
120
113
|
if (!isRecord(value)) throw new Error("identity must be an object");
|
|
121
|
-
assertKnownKeys(value, IDENTITY_KEYS, "identity");
|
|
114
|
+
assertKnownKeys(value, platform ? /* @__PURE__ */ new Set([...IDENTITY_KEYS, "userDataNamespace"]) : IDENTITY_KEYS, "identity");
|
|
122
115
|
const productName = text(value.productName, "identity.productName", 64);
|
|
123
|
-
const appId = text(value.appId, "identity.appId", 160);
|
|
116
|
+
const appId = text(value.appId, "identity.appId", platform ? 200 : 160);
|
|
124
117
|
const versionChannel = text(value.versionChannel, "identity.versionChannel", 64);
|
|
125
118
|
const protocolScheme = text(value.protocolScheme, "identity.protocolScheme", 64);
|
|
126
|
-
if (
|
|
127
|
-
throw new Error("identity.
|
|
128
|
-
}
|
|
129
|
-
if (!APP_ID.test(appId)) throw new Error("identity.appId must be a reverse-DNS identifier");
|
|
119
|
+
if (!(platform ? /^[a-z][a-z0-9-]*(\.[a-z][a-z0-9-]*)+$/ : APP_ID).test(appId))
|
|
120
|
+
throw new Error("identity.appId must be a reverse-DNS identifier");
|
|
130
121
|
if (!KEBAB_ID.test(versionChannel)) throw new Error("identity.versionChannel must be kebab-case");
|
|
131
122
|
if (!platform && RESERVED_VERSION_CHANNELS.has(versionChannel)) {
|
|
132
123
|
throw new Error(`identity.versionChannel is reserved: ${versionChannel}`);
|
|
133
124
|
}
|
|
134
|
-
if (!PROTOCOL_SCHEME.test(protocolScheme)) {
|
|
125
|
+
if (!(platform ? /^[a-z][a-z0-9+.-]{1,62}$/ : PROTOCOL_SCHEME).test(protocolScheme)) {
|
|
135
126
|
throw new Error("identity.protocolScheme must be a lowercase URI scheme beginning with a letter");
|
|
136
127
|
}
|
|
137
|
-
if (RESERVED_PROTOCOL_SCHEMES.has(protocolScheme)) {
|
|
128
|
+
if (RESERVED_PROTOCOL_SCHEMES.has(protocolScheme) && !(platform && protocolScheme === "orbit")) {
|
|
138
129
|
throw new Error(`identity.protocolScheme is reserved: ${protocolScheme}`);
|
|
139
130
|
}
|
|
140
131
|
if (hasUnsafeProductNameCharacter(productName) || /[. ]$/.test(productName) || productName === "." || productName === ".." || WINDOWS_DEVICE_NAME.test(productName)) {
|
|
141
132
|
throw new Error("identity.productName must be safe for macOS, Windows, Linux, and release artifact paths");
|
|
142
133
|
}
|
|
143
|
-
if (OFFICIAL_PRODUCT_NAMES.has(productName.toLowerCase())) {
|
|
134
|
+
if (!platform && OFFICIAL_PRODUCT_NAMES.has(productName.toLowerCase())) {
|
|
144
135
|
throw new Error(`identity.productName is reserved for the official application: ${productName}`);
|
|
145
136
|
}
|
|
146
|
-
if (appId === OFFICIAL_APP_ID) {
|
|
137
|
+
if (!platform && appId === OFFICIAL_APP_ID) {
|
|
147
138
|
throw new Error(`identity.appId is reserved for the official application: ${appId}`);
|
|
148
139
|
}
|
|
149
140
|
if (!platform && productNameNamespace(productName) !== id) {
|
|
@@ -158,13 +149,15 @@ function parseIdentity(value, id, platform) {
|
|
|
158
149
|
if (!platform && !appId.endsWith(`.oem.${id}`)) {
|
|
159
150
|
throw new Error("identity.appId must end with .oem.<manifest id> to isolate installation and user data");
|
|
160
151
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
152
|
+
if (!platform && value.userDataNamespace !== void 0 && !KEBAB_ID.test(text(value.userDataNamespace, "identity.userDataNamespace", 64))) {
|
|
153
|
+
throw new Error("identity.userDataNamespace must be lowercase kebab-case");
|
|
154
|
+
}
|
|
155
|
+
const userDataNamespace = value.userDataNamespace === void 0 ? void 0 : text(value.userDataNamespace, "identity.userDataNamespace", 200);
|
|
156
|
+
if (userDataNamespace && (!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(userDataNamespace) || userDataNamespace.includes("..")))
|
|
157
|
+
throw new Error("identity.userDataNamespace must be a safe directory name");
|
|
158
|
+
if (platform && versionChannel !== id && !["stable", "debug", "oem-dev"].includes(versionChannel))
|
|
159
|
+
throw new Error("Platform environment must be stable, debug, or oem-dev");
|
|
160
|
+
return { productName, appId, versionChannel, protocolScheme, ...userDataNamespace ? { userDataNamespace } : {} };
|
|
168
161
|
}
|
|
169
162
|
function parseAssets(value) {
|
|
170
163
|
if (!isRecord(value)) throw new Error("assets must be an object");
|
|
@@ -178,6 +171,14 @@ function parseAssets(value) {
|
|
|
178
171
|
...loginKV ? { loginKV } : {}
|
|
179
172
|
};
|
|
180
173
|
}
|
|
174
|
+
function parseAppearance(value) {
|
|
175
|
+
if (value === void 0) return void 0;
|
|
176
|
+
if (!isRecord(value)) throw new Error("appearance must be an object");
|
|
177
|
+
assertKnownKeys(value, APPEARANCE_KEYS, "appearance");
|
|
178
|
+
if (value.homeBackdrop !== void 0 && typeof value.homeBackdrop !== "boolean")
|
|
179
|
+
throw new Error("appearance.homeBackdrop must be a boolean");
|
|
180
|
+
return value.homeBackdrop === void 0 ? {} : { homeBackdrop: value.homeBackdrop };
|
|
181
|
+
}
|
|
181
182
|
function parseBrandCopy(value, path) {
|
|
182
183
|
if (!isRecord(value)) throw new Error(`${path} must be an object`);
|
|
183
184
|
assertKnownKeys(value, BRANDING_KEYS, path);
|
|
@@ -230,7 +231,7 @@ function isDevelopmentHostname(hostname) {
|
|
|
230
231
|
}
|
|
231
232
|
return lower.split(/[.-]/).some((label) => ["dev", "development", "test", "testing", "stage", "staging", "uat"].includes(label));
|
|
232
233
|
}
|
|
233
|
-
function parseNetwork(value) {
|
|
234
|
+
function parseNetwork(value, platform = false) {
|
|
234
235
|
if (value === void 0) return void 0;
|
|
235
236
|
if (!isRecord(value)) throw new Error("network must be an object");
|
|
236
237
|
assertKnownKeys(value, NETWORK_KEYS, "network");
|
|
@@ -249,7 +250,7 @@ function parseNetwork(value) {
|
|
|
249
250
|
if (parsed.protocol !== "https:" || parsed.username || parsed.password || parsed.pathname !== "/" || parsed.search || parsed.hash || parsed.origin !== origin) {
|
|
250
251
|
throw new Error(`${path} must be a canonical exact HTTPS origin without credentials, path, query, or fragment`);
|
|
251
252
|
}
|
|
252
|
-
if (isDevelopmentHostname(parsed.hostname)) {
|
|
253
|
+
if (!platform && isDevelopmentHostname(parsed.hostname)) {
|
|
253
254
|
throw new Error(`${path} must be a production origin, not localhost, private network, dev, test, staging, or UAT`);
|
|
254
255
|
}
|
|
255
256
|
return origin;
|
|
@@ -394,7 +395,8 @@ function parseBrandManifest(input, options) {
|
|
|
394
395
|
assertKnownKeys(input, ROOT_KEYS, "manifest");
|
|
395
396
|
if (input.$schema !== BRAND_MANIFEST_SCHEMA) throw new Error(`$schema must equal ${BRAND_MANIFEST_SCHEMA}`);
|
|
396
397
|
const id = text(input.id, "id", 64);
|
|
397
|
-
if (!KEBAB_ID.test(id))
|
|
398
|
+
if (!(platform ? /^[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?$/ : KEBAB_ID).test(id))
|
|
399
|
+
throw new Error("id must be lowercase kebab-case");
|
|
398
400
|
const entry = input.entry === void 0 ? void 0 : relativePath(input.entry, "entry");
|
|
399
401
|
if (entry && !SOURCE_ENTRY.test(entry)) {
|
|
400
402
|
throw new Error("entry must point to reviewed source under ./src using .js, .mjs, .jsx, .ts, or .tsx");
|
|
@@ -405,8 +407,9 @@ function parseBrandManifest(input, options) {
|
|
|
405
407
|
const tokens = parseTokens(input.tokens);
|
|
406
408
|
const typography = parseTypography(input.typography);
|
|
407
409
|
const fontScale = parseFontScale(input.fontScale);
|
|
410
|
+
const appearance = parseAppearance(input.appearance);
|
|
408
411
|
const locales = parseLocales(input.locales);
|
|
409
|
-
const network = parseNetwork(input.network);
|
|
412
|
+
const network = parseNetwork(input.network, platform);
|
|
410
413
|
const identity = parseIdentity(input.identity, id, platform);
|
|
411
414
|
if (!platform && productNameNamespace(identity.productName) !== id) {
|
|
412
415
|
throw new Error("identity.productName must normalize to manifest id so installation names cannot collide");
|
|
@@ -434,6 +437,7 @@ function parseBrandManifest(input, options) {
|
|
|
434
437
|
...tokens ? { tokens } : {},
|
|
435
438
|
...typography ? { typography } : {},
|
|
436
439
|
...fontScale ? { fontScale } : {},
|
|
440
|
+
...appearance ? { appearance } : {},
|
|
437
441
|
assets: parseAssets(input.assets),
|
|
438
442
|
branding: parseBranding(input.branding),
|
|
439
443
|
...locales ? { locales } : {},
|
|
@@ -541,8 +545,8 @@ async function assertAsset(packageRoot, relative, kind) {
|
|
|
541
545
|
const { width, height } = dimensions;
|
|
542
546
|
if (kind === "appIcon") {
|
|
543
547
|
if (width !== height || width < 1024) throw new Error("assets.appIcon must be square and at least 1024x1024");
|
|
544
|
-
} else if (width !== height
|
|
545
|
-
throw new Error("assets.tray must be a square image
|
|
548
|
+
} else if (width !== height) {
|
|
549
|
+
throw new Error("assets.tray must be a square image");
|
|
546
550
|
}
|
|
547
551
|
}
|
|
548
552
|
return file;
|
|
@@ -556,13 +560,19 @@ function jpegDimensions(bytes) {
|
|
|
556
560
|
let offset = 2;
|
|
557
561
|
while (offset + 9 < bytes.length) {
|
|
558
562
|
if (bytes[offset] !== 255) return null;
|
|
559
|
-
|
|
563
|
+
let markerOffset = offset;
|
|
564
|
+
while (bytes[markerOffset] === 255) markerOffset += 1;
|
|
565
|
+
const marker = bytes[markerOffset];
|
|
560
566
|
if (marker >= 192 && marker <= 207 && ![196, 200, 204].includes(marker)) {
|
|
561
|
-
return { height: bytes.readUInt16BE(
|
|
567
|
+
return { height: bytes.readUInt16BE(markerOffset + 4), width: bytes.readUInt16BE(markerOffset + 6) };
|
|
568
|
+
}
|
|
569
|
+
if (marker === 1 || marker >= 208 && marker <= 215) {
|
|
570
|
+
offset = markerOffset + 1;
|
|
571
|
+
continue;
|
|
562
572
|
}
|
|
563
|
-
const length = bytes.readUInt16BE(
|
|
573
|
+
const length = bytes.readUInt16BE(markerOffset + 1);
|
|
564
574
|
if (length < 2) return null;
|
|
565
|
-
offset
|
|
575
|
+
offset = markerOffset + 1 + length;
|
|
566
576
|
}
|
|
567
577
|
return null;
|
|
568
578
|
}
|