@tomorrowos/sdk 0.5.9 → 0.6.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 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/pairing-code.d.ts +6 -0
- package/dist/pairing-code.d.ts.map +1 -1
- package/dist/pairing-code.js +19 -1
- package/dist/store/postgres-store.js +253 -253
- package/dist/store/sqlite-store.js +249 -249
- package/dist/tomorrowos.d.ts +14 -0
- package/dist/tomorrowos.d.ts.map +1 -1
- package/dist/tomorrowos.js +114 -2
- package/package.json +1 -1
- package/templates/cms-starter/.env.example +12 -8
- package/templates/cms-starter/package.json +2 -2
- package/templates/cms-starter/public/index.html +12 -0
- package/templates/cms-starter/public/methods.js +65 -0
- package/templates/cms-starter/public/panel.css +14 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { TomorrowOS } from "./tomorrowos.js";
|
|
2
|
-
export type { DeviceListItem, ListenOptions, TomorrowOSBrand, TomorrowOSOptions } from "./tomorrowos.js";
|
|
2
|
+
export type { DeviceListItem, DeviceScreenshotInfo, ListenOptions, TomorrowOSBrand, TomorrowOSOptions } from "./tomorrowos.js";
|
|
3
3
|
export type { DevicePlaylistAssignment, DeviceRegistryRecord, PairedDeviceRecord, PendingCodeEntry, PendingCodeRecord, DeviceRegistryEntry, PlaylistItemRecord, PlaylistSchedule, PublishedPlaylistSnapshot, StoredPlaylist, TomorrowOSDataSnapshot, TomorrowOSMigratableStore, TomorrowOSStore } from "./store/types.js";
|
|
4
4
|
export { PlaylistCatalog } from "./playlist-catalog.js";
|
|
5
5
|
export type { BuiltDevicePolicy, SavePlaylistInput } from "./playlist-catalog.js";
|
|
6
|
-
export { generateRandomPairingCode, isValidPairingCodeFormat, normalizePairingCode, PAIRING_CODE_ALPHABET, PAIRING_CODE_LENGTH } from "./pairing-code.js";
|
|
6
|
+
export { DEFAULT_PAIRING_CODE_SECRET, generateDeterministicPairingCode, generateRandomPairingCode, isValidPairingCodeFormat, normalizePairingCode, PAIRING_CODE_ALPHABET, PAIRING_CODE_LENGTH, resolvePairingCodeSecret } from "./pairing-code.js";
|
|
7
7
|
export { MemoryStore } from "./store/memory-store.js";
|
|
8
8
|
export { PostgresStore } from "./store/postgres-store.js";
|
|
9
9
|
export type { PostgresStoreOptions } from "./store/postgres-store.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,YAAY,EACV,cAAc,EACd,aAAa,EACb,eAAe,EACf,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EACV,wBAAwB,EACxB,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,yBAAyB,EACzB,cAAc,EACd,sBAAsB,EACtB,yBAAyB,EACzB,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,YAAY,EACV,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,eAAe,EACf,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EACV,wBAAwB,EACxB,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,yBAAyB,EACzB,cAAc,EACd,sBAAsB,EACtB,yBAAyB,EACzB,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,EACL,2BAA2B,EAC3B,gCAAgC,EAChC,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,wBAAwB,EACzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,YAAY,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,4BAA4B,EAC5B,qBAAqB,EACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { TomorrowOS } from "./tomorrowos.js";
|
|
2
2
|
export { PlaylistCatalog } from "./playlist-catalog.js";
|
|
3
|
-
export { generateRandomPairingCode, isValidPairingCodeFormat, normalizePairingCode, PAIRING_CODE_ALPHABET, PAIRING_CODE_LENGTH } from "./pairing-code.js";
|
|
3
|
+
export { DEFAULT_PAIRING_CODE_SECRET, generateDeterministicPairingCode, generateRandomPairingCode, isValidPairingCodeFormat, normalizePairingCode, PAIRING_CODE_ALPHABET, PAIRING_CODE_LENGTH, resolvePairingCodeSecret } from "./pairing-code.js";
|
|
4
4
|
export { MemoryStore } from "./store/memory-store.js";
|
|
5
5
|
export { PostgresStore } from "./store/postgres-store.js";
|
|
6
6
|
export { SQLiteStore } from "./store/sqlite-store.js";
|
package/dist/pairing-code.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
/** 0-9 and A-Z — 36 characters per digit position. */
|
|
2
2
|
export declare const PAIRING_CODE_ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
3
3
|
export declare const PAIRING_CODE_LENGTH = 6;
|
|
4
|
+
export declare const DEFAULT_PAIRING_CODE_SECRET = "TomorrowOSDefaultPairingV1";
|
|
4
5
|
export declare function normalizePairingCode(raw: string): string;
|
|
5
6
|
export declare function isValidPairingCodeFormat(code: string): boolean;
|
|
6
7
|
/** Random 6-character code; each position is digit or uppercase letter. */
|
|
7
8
|
export declare function generateRandomPairingCode(): string;
|
|
9
|
+
export declare function resolvePairingCodeSecret(env?: NodeJS.ProcessEnv): string;
|
|
10
|
+
export declare function generateDeterministicPairingCode(identity: string, options?: {
|
|
11
|
+
secret?: string;
|
|
12
|
+
attempt?: number;
|
|
13
|
+
}): string;
|
|
8
14
|
//# sourceMappingURL=pairing-code.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pairing-code.d.ts","sourceRoot":"","sources":["../src/pairing-code.ts"],"names":[],"mappings":"AAEA,sDAAsD;AACtD,eAAO,MAAM,qBAAqB,yCAAyC,CAAC;AAE5E,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAKxD;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAK9D;AAED,2EAA2E;AAC3E,wBAAgB,yBAAyB,IAAI,MAAM,CAOlD"}
|
|
1
|
+
{"version":3,"file":"pairing-code.d.ts","sourceRoot":"","sources":["../src/pairing-code.ts"],"names":[],"mappings":"AAEA,sDAAsD;AACtD,eAAO,MAAM,qBAAqB,yCAAyC,CAAC;AAE5E,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC,eAAO,MAAM,2BAA2B,+BAA+B,CAAC;AAExE,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAKxD;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAK9D;AAED,2EAA2E;AAC3E,wBAAgB,yBAAyB,IAAI,MAAM,CAOlD;AAED,wBAAgB,wBAAwB,CACtC,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,MAAM,CAGR;AAED,wBAAgB,gCAAgC,CAC9C,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE;IACP,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CACb,GACL,MAAM,CAaR"}
|
package/dist/pairing-code.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { randomBytes } from "crypto";
|
|
1
|
+
import { createHmac, randomBytes } from "crypto";
|
|
2
2
|
/** 0-9 and A-Z — 36 characters per digit position. */
|
|
3
3
|
export const PAIRING_CODE_ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
4
4
|
export const PAIRING_CODE_LENGTH = 6;
|
|
5
|
+
export const DEFAULT_PAIRING_CODE_SECRET = "TomorrowOSDefaultPairingV1";
|
|
5
6
|
export function normalizePairingCode(raw) {
|
|
6
7
|
return String(raw || "")
|
|
7
8
|
.trim()
|
|
@@ -21,3 +22,20 @@ export function generateRandomPairingCode() {
|
|
|
21
22
|
}
|
|
22
23
|
return out;
|
|
23
24
|
}
|
|
25
|
+
export function resolvePairingCodeSecret(env = process.env) {
|
|
26
|
+
const configured = String(env.PAIRING_CODE_SECRET || "").trim();
|
|
27
|
+
return configured || DEFAULT_PAIRING_CODE_SECRET;
|
|
28
|
+
}
|
|
29
|
+
export function generateDeterministicPairingCode(identity, options = {}) {
|
|
30
|
+
const normalizedIdentity = String(identity || "").trim().toUpperCase();
|
|
31
|
+
const secret = options.secret || DEFAULT_PAIRING_CODE_SECRET;
|
|
32
|
+
const attempt = Number.isInteger(options.attempt) ? options.attempt : 0;
|
|
33
|
+
const digest = createHmac("sha256", secret)
|
|
34
|
+
.update(`${normalizedIdentity}:${attempt}`)
|
|
35
|
+
.digest();
|
|
36
|
+
let out = "";
|
|
37
|
+
for (let i = 0; i < PAIRING_CODE_LENGTH; i += 1) {
|
|
38
|
+
out += PAIRING_CODE_ALPHABET[digest[i] % PAIRING_CODE_ALPHABET.length];
|
|
39
|
+
}
|
|
40
|
+
return out;
|
|
41
|
+
}
|