@signalapp/mock-server
Advanced tools
Comparing version 4.1.1 to 4.1.2
{ | ||
"name": "@signalapp/mock-server", | ||
"version": "4.1.1", | ||
"version": "4.1.2", | ||
"description": "Mock Signal Server for writing tests", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -5,3 +5,3 @@ /// <reference types="node" /> | ||
import { signalservice as Proto } from '../../protos/compiled'; | ||
import { AciString, DeviceId, PniString, ServiceIdKind, ServiceIdString } from '../types'; | ||
import { AciString, DeviceId, PniString, ServiceIdKind, ServiceIdString, UntaggedPniString } from '../types'; | ||
import { Contact } from '../data/contacts'; | ||
@@ -40,3 +40,3 @@ import { Group as GroupData } from '../data/group'; | ||
serviceIdKind?: ServiceIdKind; | ||
updatedPni?: PniString; | ||
updatedPni?: UntaggedPniString; | ||
distributionId?: string; | ||
@@ -43,0 +43,0 @@ group?: Group; |
@@ -753,3 +753,3 @@ "use strict"; | ||
timestamp, | ||
updatedPni: this.device.pni, | ||
updatedPni: (0, types_1.untagPni)(this.device.pni), | ||
}); | ||
@@ -756,0 +756,0 @@ return { device, envelope }; |
@@ -55,8 +55,11 @@ "use strict"; | ||
} | ||
const serviceId = serviceIdKind === types_1.ServiceIdKind.ACI ? | ||
this.record?.contact?.aci : this.record?.contact?.pni; | ||
if (!serviceId) { | ||
if (serviceIdKind === types_1.ServiceIdKind.ACI) { | ||
return this.record?.contact?.aci === device.aci; | ||
} | ||
const untaggedPni = this.record?.contact?.pni; | ||
if (!untaggedPni) { | ||
return false; | ||
} | ||
return serviceId === device.getServiceIdByKind(serviceIdKind); | ||
const pni = (0, types_1.tagPni)(untaggedPni); | ||
return pni === device.pni; | ||
} | ||
@@ -172,5 +175,5 @@ inspect() { | ||
aci: serviceIdKind === types_1.ServiceIdKind.ACI ? | ||
device.getServiceIdByKind(serviceIdKind) : undefined, | ||
device.aci : undefined, | ||
pni: serviceIdKind === types_1.ServiceIdKind.PNI ? | ||
device.getServiceIdByKind(serviceIdKind) : undefined, | ||
(0, types_1.untagPni)(device.pni) : undefined, | ||
serviceE164: device.number, | ||
@@ -208,3 +211,3 @@ ...diff, | ||
.addContact(primary, { | ||
pni: device.getServiceIdByKind(types_1.ServiceIdKind.PNI), | ||
pni: (0, types_1.untagPni)(device.pni), | ||
...diff, | ||
@@ -211,0 +214,0 @@ }) |
@@ -12,7 +12,7 @@ import z from 'zod'; | ||
}, "strip", z.ZodTypeAny, { | ||
publicKey: string; | ||
keyId: number; | ||
}, { | ||
publicKey: string; | ||
}, { | ||
keyId: number; | ||
publicKey: string; | ||
}>; | ||
@@ -25,8 +25,8 @@ export type ServerPreKey = z.infer<typeof PreKeySchema>; | ||
}, "strip", z.ZodTypeAny, { | ||
publicKey: string; | ||
keyId: number; | ||
publicKey: string; | ||
signature: string; | ||
}, { | ||
publicKey: string; | ||
keyId: number; | ||
publicKey: string; | ||
signature: string; | ||
@@ -41,7 +41,7 @@ }>; | ||
}, "strip", z.ZodTypeAny, { | ||
publicKey: string; | ||
keyId: number; | ||
}, { | ||
publicKey: string; | ||
}, { | ||
keyId: number; | ||
publicKey: string; | ||
}>, "many">; | ||
@@ -53,8 +53,8 @@ pqPreKeys: z.ZodOptional<z.ZodArray<z.ZodObject<{ | ||
}, "strip", z.ZodTypeAny, { | ||
publicKey: string; | ||
keyId: number; | ||
publicKey: string; | ||
signature: string; | ||
}, { | ||
publicKey: string; | ||
keyId: number; | ||
publicKey: string; | ||
signature: string; | ||
@@ -67,8 +67,8 @@ }>, "many">>; | ||
}, "strip", z.ZodTypeAny, { | ||
publicKey: string; | ||
keyId: number; | ||
publicKey: string; | ||
signature: string; | ||
}, { | ||
publicKey: string; | ||
keyId: number; | ||
publicKey: string; | ||
signature: string; | ||
@@ -81,24 +81,24 @@ }>>; | ||
}, "strip", z.ZodTypeAny, { | ||
publicKey: string; | ||
keyId: number; | ||
publicKey: string; | ||
signature: string; | ||
}, { | ||
publicKey: string; | ||
keyId: number; | ||
publicKey: string; | ||
signature: string; | ||
}>>; | ||
}, "strip", z.ZodTypeAny, { | ||
signedPreKey?: { | ||
publicKey: string; | ||
keyId: number; | ||
signature: string; | ||
} | undefined; | ||
pqPreKeys?: { | ||
publicKey: string; | ||
keyId: number; | ||
publicKey: string; | ||
signature: string; | ||
}[] | undefined; | ||
pqLastResortPreKey?: { | ||
keyId: number; | ||
publicKey: string; | ||
signature: string; | ||
} | undefined; | ||
signedPreKey?: { | ||
keyId: number; | ||
publicKey: string; | ||
signature: string; | ||
@@ -108,19 +108,19 @@ } | undefined; | ||
preKeys: { | ||
publicKey: string; | ||
keyId: number; | ||
publicKey: string; | ||
}[]; | ||
}, { | ||
signedPreKey?: { | ||
publicKey: string; | ||
keyId: number; | ||
signature: string; | ||
} | undefined; | ||
pqPreKeys?: { | ||
publicKey: string; | ||
keyId: number; | ||
publicKey: string; | ||
signature: string; | ||
}[] | undefined; | ||
pqLastResortPreKey?: { | ||
keyId: number; | ||
publicKey: string; | ||
signature: string; | ||
} | undefined; | ||
signedPreKey?: { | ||
keyId: number; | ||
publicKey: string; | ||
signature: string; | ||
@@ -130,4 +130,4 @@ } | undefined; | ||
preKeys: { | ||
publicKey: string; | ||
keyId: number; | ||
publicKey: string; | ||
}[]; | ||
@@ -142,11 +142,11 @@ }>; | ||
}, "strip", z.ZodTypeAny, { | ||
content: string; | ||
type: number; | ||
destinationDeviceId: DeviceId; | ||
destinationRegistrationId: RegistrationId; | ||
}, { | ||
content: string; | ||
}, { | ||
type: number; | ||
destinationDeviceId: number; | ||
destinationRegistrationId: number; | ||
content: string; | ||
}>; | ||
@@ -161,11 +161,11 @@ export type Message = z.infer<typeof MessageSchema>; | ||
}, "strip", z.ZodTypeAny, { | ||
content: string; | ||
type: number; | ||
destinationDeviceId: DeviceId; | ||
destinationRegistrationId: RegistrationId; | ||
}, { | ||
content: string; | ||
}, { | ||
type: number; | ||
destinationDeviceId: number; | ||
destinationRegistrationId: number; | ||
content: string; | ||
}>, "many">; | ||
@@ -175,6 +175,6 @@ timestamp: z.ZodNumber; | ||
messages: { | ||
content: string; | ||
type: number; | ||
destinationDeviceId: DeviceId; | ||
destinationRegistrationId: RegistrationId; | ||
content: string; | ||
}[]; | ||
@@ -184,6 +184,6 @@ timestamp: number; | ||
messages: { | ||
content: string; | ||
type: number; | ||
destinationDeviceId: number; | ||
destinationRegistrationId: number; | ||
content: string; | ||
}[]; | ||
@@ -201,11 +201,11 @@ timestamp: number; | ||
}, "strip", z.ZodTypeAny, { | ||
fetchesMessages: boolean; | ||
registrationId: RegistrationId; | ||
pniRegistrationId: RegistrationId; | ||
name: string; | ||
fetchesMessages: boolean; | ||
}, { | ||
fetchesMessages: boolean; | ||
registrationId: number; | ||
pniRegistrationId: number; | ||
name: string; | ||
fetchesMessages: boolean; | ||
}>; | ||
@@ -217,8 +217,8 @@ aciSignedPreKey: z.ZodObject<{ | ||
}, "strip", z.ZodTypeAny, { | ||
publicKey: string; | ||
keyId: number; | ||
publicKey: string; | ||
signature: string; | ||
}, { | ||
publicKey: string; | ||
keyId: number; | ||
publicKey: string; | ||
signature: string; | ||
@@ -231,8 +231,8 @@ }>; | ||
}, "strip", z.ZodTypeAny, { | ||
publicKey: string; | ||
keyId: number; | ||
publicKey: string; | ||
signature: string; | ||
}, { | ||
publicKey: string; | ||
keyId: number; | ||
publicKey: string; | ||
signature: string; | ||
@@ -245,8 +245,8 @@ }>; | ||
}, "strip", z.ZodTypeAny, { | ||
publicKey: string; | ||
keyId: number; | ||
publicKey: string; | ||
signature: string; | ||
}, { | ||
publicKey: string; | ||
keyId: number; | ||
publicKey: string; | ||
signature: string; | ||
@@ -259,8 +259,8 @@ }>; | ||
}, "strip", z.ZodTypeAny, { | ||
publicKey: string; | ||
keyId: number; | ||
publicKey: string; | ||
signature: string; | ||
}, { | ||
publicKey: string; | ||
keyId: number; | ||
publicKey: string; | ||
signature: string; | ||
@@ -271,25 +271,25 @@ }>; | ||
accountAttributes: { | ||
fetchesMessages: boolean; | ||
registrationId: RegistrationId; | ||
pniRegistrationId: RegistrationId; | ||
name: string; | ||
fetchesMessages: boolean; | ||
}; | ||
aciSignedPreKey: { | ||
publicKey: string; | ||
keyId: number; | ||
publicKey: string; | ||
signature: string; | ||
}; | ||
pniSignedPreKey: { | ||
publicKey: string; | ||
keyId: number; | ||
publicKey: string; | ||
signature: string; | ||
}; | ||
aciPqLastResortPreKey: { | ||
publicKey: string; | ||
keyId: number; | ||
publicKey: string; | ||
signature: string; | ||
}; | ||
pniPqLastResortPreKey: { | ||
publicKey: string; | ||
keyId: number; | ||
publicKey: string; | ||
signature: string; | ||
@@ -300,25 +300,25 @@ }; | ||
accountAttributes: { | ||
fetchesMessages: boolean; | ||
registrationId: number; | ||
pniRegistrationId: number; | ||
name: string; | ||
fetchesMessages: boolean; | ||
}; | ||
aciSignedPreKey: { | ||
publicKey: string; | ||
keyId: number; | ||
publicKey: string; | ||
signature: string; | ||
}; | ||
pniSignedPreKey: { | ||
publicKey: string; | ||
keyId: number; | ||
publicKey: string; | ||
signature: string; | ||
}; | ||
aciPqLastResortPreKey: { | ||
publicKey: string; | ||
keyId: number; | ||
publicKey: string; | ||
signature: string; | ||
}; | ||
pniPqLastResortPreKey: { | ||
publicKey: string; | ||
keyId: number; | ||
publicKey: string; | ||
signature: string; | ||
@@ -335,8 +335,8 @@ }; | ||
}, "strip", z.ZodTypeAny, { | ||
members: number; | ||
attributes: number; | ||
members: number; | ||
addFromInviteLink: number; | ||
}, { | ||
members: number; | ||
attributes: number; | ||
members: number; | ||
addFromInviteLink: number; | ||
@@ -347,17 +347,17 @@ }>; | ||
publicKey: Uint8Array; | ||
version: 0; | ||
accessControl: { | ||
members: number; | ||
attributes: number; | ||
members: number; | ||
addFromInviteLink: number; | ||
}; | ||
version: 0; | ||
members: unknown[]; | ||
}, { | ||
publicKey: Uint8Array; | ||
version: 0; | ||
accessControl: { | ||
members: number; | ||
attributes: number; | ||
members: number; | ||
addFromInviteLink: number; | ||
}; | ||
version: 0; | ||
members: unknown[]; | ||
@@ -364,0 +364,0 @@ }>; |
@@ -9,2 +9,5 @@ /// <reference types="node" /> | ||
}; | ||
export type UntaggedPniString = string & { | ||
__untagged_pni: never; | ||
}; | ||
export type ServiceIdString = AciString | PniString; | ||
@@ -44,2 +47,3 @@ export type ProvisionIdString = string & { | ||
}>; | ||
export declare function untagPni(pni: PniString): string; | ||
export declare function untagPni(pni: PniString): UntaggedPniString; | ||
export declare function tagPni(pni: UntaggedPniString): PniString; |
@@ -5,3 +5,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.untagPni = exports.ServiceIdKind = void 0; | ||
exports.tagPni = exports.untagPni = exports.ServiceIdKind = void 0; | ||
var ServiceIdKind; | ||
@@ -16,1 +16,5 @@ (function (ServiceIdKind) { | ||
exports.untagPni = untagPni; | ||
function tagPni(pni) { | ||
return `PNI:${pni}`; | ||
} | ||
exports.tagPni = tagPni; |
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
3595305
66529