@signalapp/mock-server
Advanced tools
Comparing version 7.0.1 to 7.0.2
{ | ||
"name": "@signalapp/mock-server", | ||
"version": "7.0.1", | ||
"version": "7.0.2", | ||
"description": "Mock Signal Server for writing tests", | ||
@@ -24,3 +24,3 @@ "main": "src/index.js", | ||
"test": "npm run mocha && npm run lint", | ||
"prepublish": "npm run build" | ||
"prepare": "npm run build" | ||
}, | ||
@@ -51,2 +51,3 @@ "repository": { | ||
"debug": "^4.3.2", | ||
"is-plain-obj": "3.0.0", | ||
"long": "^4.0.0", | ||
@@ -57,2 +58,3 @@ "micro": "^9.3.4", | ||
"protobufjs": "^7.2.4", | ||
"type-fest": "^4.26.1", | ||
"url-pattern": "^1.0.3", | ||
@@ -59,0 +61,0 @@ "uuid": "^8.3.2", |
@@ -0,1 +1,2 @@ | ||
/// <reference types="node" /> | ||
import z from 'zod'; | ||
@@ -13,7 +14,7 @@ import { AciString, DeviceId, PniString, RegistrationId } from '../types'; | ||
}, "strip", z.ZodTypeAny, { | ||
keyId: number; | ||
publicKey: string; | ||
}, { | ||
keyId: number; | ||
}, { | ||
publicKey: string; | ||
keyId: number; | ||
}>; | ||
@@ -26,8 +27,8 @@ export type ServerPreKey = z.infer<typeof PreKeySchema>; | ||
}, "strip", z.ZodTypeAny, { | ||
keyId: number; | ||
publicKey: string; | ||
keyId: number; | ||
signature: string; | ||
}, { | ||
keyId: number; | ||
publicKey: string; | ||
keyId: number; | ||
signature: string; | ||
@@ -41,7 +42,7 @@ }>; | ||
}, "strip", z.ZodTypeAny, { | ||
keyId: number; | ||
publicKey: string; | ||
}, { | ||
keyId: number; | ||
}, { | ||
publicKey: string; | ||
keyId: number; | ||
}>, "many">; | ||
@@ -53,8 +54,8 @@ pqPreKeys: z.ZodOptional<z.ZodArray<z.ZodObject<{ | ||
}, "strip", z.ZodTypeAny, { | ||
keyId: number; | ||
publicKey: string; | ||
keyId: number; | ||
signature: string; | ||
}, { | ||
keyId: number; | ||
publicKey: string; | ||
keyId: number; | ||
signature: string; | ||
@@ -67,8 +68,8 @@ }>, "many">>; | ||
}, "strip", z.ZodTypeAny, { | ||
keyId: number; | ||
publicKey: string; | ||
keyId: number; | ||
signature: string; | ||
}, { | ||
keyId: number; | ||
publicKey: string; | ||
keyId: number; | ||
signature: string; | ||
@@ -81,8 +82,8 @@ }>>; | ||
}, "strip", z.ZodTypeAny, { | ||
keyId: number; | ||
publicKey: string; | ||
keyId: number; | ||
signature: string; | ||
}, { | ||
keyId: number; | ||
publicKey: string; | ||
keyId: number; | ||
signature: string; | ||
@@ -92,18 +93,18 @@ }>>; | ||
preKeys: { | ||
keyId: number; | ||
publicKey: string; | ||
keyId: number; | ||
}[]; | ||
pqPreKeys?: { | ||
keyId: number; | ||
publicKey: string; | ||
keyId: number; | ||
signature: string; | ||
}[] | undefined; | ||
pqLastResortPreKey?: { | ||
keyId: number; | ||
publicKey: string; | ||
keyId: number; | ||
signature: string; | ||
} | undefined; | ||
signedPreKey?: { | ||
keyId: number; | ||
publicKey: string; | ||
keyId: number; | ||
signature: string; | ||
@@ -113,18 +114,18 @@ } | undefined; | ||
preKeys: { | ||
keyId: number; | ||
publicKey: string; | ||
keyId: number; | ||
}[]; | ||
pqPreKeys?: { | ||
keyId: number; | ||
publicKey: string; | ||
keyId: number; | ||
signature: string; | ||
}[] | undefined; | ||
pqLastResortPreKey?: { | ||
keyId: number; | ||
publicKey: string; | ||
keyId: number; | ||
signature: string; | ||
} | undefined; | ||
signedPreKey?: { | ||
keyId: number; | ||
publicKey: string; | ||
keyId: number; | ||
signature: string; | ||
@@ -207,2 +208,3 @@ } | undefined; | ||
}, "strip", z.ZodTypeAny, { | ||
fetchesMessages: boolean; | ||
registrationId: number & { | ||
@@ -215,8 +217,7 @@ __reg_id: never; | ||
name: string; | ||
}, { | ||
fetchesMessages: boolean; | ||
}, { | ||
registrationId: number; | ||
pniRegistrationId: number; | ||
name: string; | ||
fetchesMessages: boolean; | ||
}>; | ||
@@ -228,8 +229,8 @@ aciSignedPreKey: z.ZodObject<{ | ||
}, "strip", z.ZodTypeAny, { | ||
keyId: number; | ||
publicKey: string; | ||
keyId: number; | ||
signature: string; | ||
}, { | ||
keyId: number; | ||
publicKey: string; | ||
keyId: number; | ||
signature: string; | ||
@@ -242,8 +243,8 @@ }>; | ||
}, "strip", z.ZodTypeAny, { | ||
keyId: number; | ||
publicKey: string; | ||
keyId: number; | ||
signature: string; | ||
}, { | ||
keyId: number; | ||
publicKey: string; | ||
keyId: number; | ||
signature: string; | ||
@@ -256,8 +257,8 @@ }>; | ||
}, "strip", z.ZodTypeAny, { | ||
keyId: number; | ||
publicKey: string; | ||
keyId: number; | ||
signature: string; | ||
}, { | ||
keyId: number; | ||
publicKey: string; | ||
keyId: number; | ||
signature: string; | ||
@@ -270,8 +271,8 @@ }>; | ||
}, "strip", z.ZodTypeAny, { | ||
keyId: number; | ||
publicKey: string; | ||
keyId: number; | ||
signature: string; | ||
}, { | ||
keyId: number; | ||
publicKey: string; | ||
keyId: number; | ||
signature: string; | ||
@@ -282,2 +283,3 @@ }>; | ||
accountAttributes: { | ||
fetchesMessages: boolean; | ||
registrationId: number & { | ||
@@ -290,22 +292,21 @@ __reg_id: never; | ||
name: string; | ||
fetchesMessages: boolean; | ||
}; | ||
aciSignedPreKey: { | ||
keyId: number; | ||
publicKey: string; | ||
keyId: number; | ||
signature: string; | ||
}; | ||
pniSignedPreKey: { | ||
keyId: number; | ||
publicKey: string; | ||
keyId: number; | ||
signature: string; | ||
}; | ||
aciPqLastResortPreKey: { | ||
keyId: number; | ||
publicKey: string; | ||
keyId: number; | ||
signature: string; | ||
}; | ||
pniPqLastResortPreKey: { | ||
keyId: number; | ||
publicKey: string; | ||
keyId: number; | ||
signature: string; | ||
@@ -316,25 +317,25 @@ }; | ||
accountAttributes: { | ||
fetchesMessages: boolean; | ||
registrationId: number; | ||
pniRegistrationId: number; | ||
name: string; | ||
fetchesMessages: boolean; | ||
}; | ||
aciSignedPreKey: { | ||
keyId: number; | ||
publicKey: string; | ||
keyId: number; | ||
signature: string; | ||
}; | ||
pniSignedPreKey: { | ||
keyId: number; | ||
publicKey: string; | ||
keyId: number; | ||
signature: string; | ||
}; | ||
aciPqLastResortPreKey: { | ||
keyId: number; | ||
publicKey: string; | ||
keyId: number; | ||
signature: string; | ||
}; | ||
pniPqLastResortPreKey: { | ||
keyId: number; | ||
publicKey: string; | ||
keyId: number; | ||
signature: string; | ||
@@ -351,8 +352,8 @@ }; | ||
}, "strip", z.ZodTypeAny, { | ||
attributes: number; | ||
members: number; | ||
attributes: number; | ||
addFromInviteLink: number; | ||
}, { | ||
attributes: number; | ||
members: number; | ||
attributes: number; | ||
addFromInviteLink: number; | ||
@@ -363,17 +364,17 @@ }>; | ||
publicKey: Uint8Array; | ||
version: 0; | ||
accessControl: { | ||
attributes: number; | ||
members: number; | ||
attributes: number; | ||
addFromInviteLink: number; | ||
}; | ||
version: 0; | ||
members: unknown[]; | ||
}, { | ||
publicKey: Uint8Array; | ||
version: 0; | ||
accessControl: { | ||
attributes: number; | ||
members: number; | ||
attributes: number; | ||
addFromInviteLink: number; | ||
}; | ||
version: 0; | ||
members: unknown[]; | ||
@@ -380,0 +381,0 @@ }>; |
@@ -61,7 +61,7 @@ "use strict"; | ||
{ | ||
name: target.profileName, | ||
name: target.profileName?.toString('base64'), | ||
identityKey: identityKey.serialize().toString('base64'), | ||
unrestrictedUnidentifiedAccess: false, | ||
unidentifiedAccess: target.accessKey | ||
? (0, crypto_2.generateAccessKeyVerifier)(target.accessKey) | ||
? (0, crypto_2.generateAccessKeyVerifier)(target.accessKey).toString('base64') | ||
: undefined, | ||
@@ -68,0 +68,0 @@ capabilities: target.capabilities, |
/// <reference types="node" /> | ||
import { ParsedUrlQuery } from 'querystring'; | ||
import { WSRequest, WSResponse } from './service'; | ||
export type AbbreviatedResponse = Readonly<[number, unknown]>; | ||
import { JsonValue, PartialDeep } from 'type-fest'; | ||
export type AbbreviatedResponse = Readonly<[number, PartialDeep<JsonValue>]>; | ||
export type Handler = (params: Record<string, string>, body: Uint8Array | undefined, headers: Record<string, string>, query?: ParsedUrlQuery) => Promise<AbbreviatedResponse>; | ||
@@ -6,0 +7,0 @@ export declare class Router { |
@@ -13,2 +13,3 @@ "use strict"; | ||
const url_pattern_1 = __importDefault(require("url-pattern")); | ||
const util_1 = require("../../util"); | ||
const debug = (0, debug_1.default)('mock:ws:router'); | ||
@@ -66,2 +67,3 @@ class Router { | ||
} | ||
(0, util_1.assertJsonValue)(json); | ||
return { | ||
@@ -68,0 +70,0 @@ status, |
/// <reference types="node" /> | ||
import { ProtocolAddress } from '@signalapp/libsignal-client'; | ||
import type { JsonValue } from 'type-fest'; | ||
import type { RegistrationId } from './types'; | ||
@@ -38,1 +39,2 @@ export type PromiseQueueConfig = Readonly<{ | ||
export declare function fromURLSafeBase64(base64: string): Buffer; | ||
export declare function assertJsonValue(root: unknown): asserts root is JsonValue; |
@@ -8,4 +8,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.fromURLSafeBase64 = exports.fromBase64 = exports.toURLSafeBase64 = exports.toBase64 = exports.generateRegistrationId = exports.daysToSeconds = exports.getTodayInSeconds = exports.addressToString = exports.PromiseQueue = exports.parseAuthHeader = exports.generateRandomE164 = void 0; | ||
exports.assertJsonValue = exports.fromURLSafeBase64 = exports.fromBase64 = exports.toURLSafeBase64 = exports.toBase64 = exports.generateRegistrationId = exports.daysToSeconds = exports.getTodayInSeconds = exports.addressToString = exports.PromiseQueue = exports.parseAuthHeader = exports.generateRandomE164 = void 0; | ||
const assert_1 = __importDefault(require("assert")); | ||
const is_plain_obj_1 = __importDefault(require("is-plain-obj")); | ||
const node_util_1 = __importDefault(require("node:util")); | ||
const constants_1 = require("./constants"); | ||
@@ -174,1 +176,34 @@ function generateRandomE164() { | ||
exports.fromURLSafeBase64 = fromURLSafeBase64; | ||
function assertJsonValue(root) { | ||
const issues = []; | ||
function visit(node, path) { | ||
if (node === null || | ||
typeof node === 'boolean' || | ||
(typeof node === 'number' && Number.isFinite(node)) || | ||
typeof node === 'string') { | ||
return; | ||
} | ||
else if (Array.isArray(node)) { | ||
node.forEach((item, index) => { | ||
visit(item, path.concat(index)); | ||
}); | ||
return; | ||
} | ||
else if ((0, is_plain_obj_1.default)(node)) { | ||
Object.entries(node).forEach(([key, item]) => { | ||
// ignore undefined properties | ||
if (typeof item !== 'undefined') { | ||
visit(item, path.concat(key)); | ||
} | ||
}); | ||
} | ||
else { | ||
issues.push(`${path.join('.')}: ${node_util_1.default.inspect(node)}`); | ||
} | ||
} | ||
visit(root, ['value']); | ||
if (issues.length > 0) { | ||
throw new TypeError(`Invalid JsonValue:\n${issues.join('\n')}`); | ||
} | ||
} | ||
exports.assertJsonValue = assertJsonValue; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3859733
71062
16
+ Addedis-plain-obj@3.0.0
+ Addedtype-fest@^4.26.1
+ Addedis-plain-obj@3.0.0(transitive)
+ Addedtype-fest@4.30.2(transitive)