Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions .github/node-persist-ignore.js

This file was deleted.

10 changes: 0 additions & 10 deletions __mocks__/node-persist.ts

This file was deleted.

1 change: 1 addition & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Config } from "jest";
const config: Config = {
"preset": "ts-jest",
"testEnvironment": "node",
"setupFilesAfterEnv": ["<rootDir>/jest.setup.ts"],
"transform": {
"^.+\\.tsx?$": ["ts-jest", {
"tsconfig": "tsconfig.spec.json",
Expand Down
14 changes: 14 additions & 0 deletions jest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { HAPStorage } from "./src/lib/model/HAPStorage";

// Redirect the HAPStorage singleton into a fresh temporary directory for every test file,
// so suites which exercise persistence (e.g. through Accessory.publish()) never touch
// a real "persist" directory inside the repository.
const storageDir = fs.mkdtempSync(path.join(os.tmpdir(), "hap-nodejs-jest-"));
HAPStorage.setCustomStoragePath(storageDir);

afterAll(() => {
fs.rmSync(storageDir, { recursive: true, force: true });
});
34 changes: 0 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"check": "npm install && npm outdated",
"clean": "rimraf dist && rimraf coverage",
"lint": "eslint 'src/**/*.{js,ts,json}'",
"build": "rimraf dist && tsc && node .github/node-persist-ignore.js",
"build": "rimraf dist && tsc",
"generate-definitions": "ts-node src/lib/definitions/generate-definitions.ts",
"prepublishOnly": "npm run build",
"postpublish": "npm run clean",
Expand Down Expand Up @@ -58,7 +58,6 @@
"debug": "^4.4.3",
"fast-srp-hap": "^2.0.4",
"futoin-hkdf": "^1.5.3",
"node-persist": "^0.0.12",
"source-map-support": "^0.5.21",
"tslib": "^2.8.1",
"tweetnacl": "^1.0.3"
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { readFileSync } from "node:fs";
* @group Utils
*/
export * as uuid from "./lib/util/uuid";
export * from "./lib/model/HAPFileStorage";
export * from "./lib/model/HAPStorage";
export * from "./lib/Accessory";
export * from "./lib/Bridge";
Expand Down
6 changes: 3 additions & 3 deletions src/lib/model/AccessoryInfo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { AssertionError } from "assert";
describe("AccessoryInfo", () => {
describe("#load()", () => {
it("should default category to Categories.OTHER when missing", () => {
const mockStorage = HAPStorage.storage();
(mockStorage.getItem as jest.Mock).mockReturnValueOnce({
const username = "0E:AE:FC:45:7B:91";
HAPStorage.storage().setItemSync(AccessoryInfo.persistKey(username), {
displayName: "Test",
pincode: "123-45-678",
signSk: "aa".repeat(64),
Expand All @@ -16,7 +16,7 @@ describe("AccessoryInfo", () => {
// category intentionally omitted
});

const info = AccessoryInfo.load("0E:AE:FC:45:7B:91");
const info = AccessoryInfo.load(username);
expect(info).not.toBeNull();
expect(info!.category).toBe(Categories.OTHER);
expect(typeof info!.category).toBe("number");
Expand Down
2 changes: 1 addition & 1 deletion src/lib/model/AccessoryInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export class AccessoryInfo {
signPk: this.signPk.toString("hex"),
pairedClients: {},
// moving permissions into an extra object, so there is nothing to migrate from old files.
// if the legacy node-persist storage should be upgraded some time, it would be reasonable to combine the storage
// if the legacy storage format should be upgraded some time, it would be reasonable to combine the storage
// of public keys (pairedClients object) and permissions.
pairedClientsPermission: {},
configVersion: this.configVersion,
Expand Down
Loading
Loading