@signalapp/mock-server
Advanced tools
Comparing version 5.0.1 to 5.1.0
'use strict'; | ||
const fs = require('fs'); | ||
const { ServerSecretParams } = require('@signalapp/libsignal-client/zkgroup'); | ||
const { GenericServerSecretParams, ServerSecretParams } = require('@signalapp/libsignal-client/zkgroup'); | ||
const secretParams = ServerSecretParams.generate(); | ||
const publicParams = secretParams.getPublicParams(); | ||
const genericSecretParams = GenericServerSecretParams.generate(); | ||
const genericPublicParams = genericSecretParams.getPublicParams(); | ||
@@ -12,2 +14,4 @@ fs.writeFileSync(process.argv[2], JSON.stringify({ | ||
publicParams: publicParams.serialize().toString('base64'), | ||
genericSecretParams: genericSecretParams.serialize().toString('base64'), | ||
genericPublicParams: genericPublicParams.serialize().toString('base64'), | ||
}, null, 2)); |
{ | ||
"secretParams": "AAq67tSKii/IIxqln0Np0FcBtAeRpqXZoduStPtZxx4BiYFKtTTOADG/17Z70C06dRvrqdv2LojL8Mm3z0AiQw4OAYlwhrN8oVHAWbzWOvWt/jykpL7t15xM1TEVhlFrXMpl7ObeHiO4VVQfabxG9xq00+DIR9kzPPE55QzTUb8OpaPzQ0S6d1pCDkZYtT64RnOC2APM1NuCoBGcTk+BJA2ItU9eaWTFstAvLOQxicWB7Lge6epDNh37BORqV0PcBU/+EmqHh7a/scW9ugdfDl0nSbGseg+x4UXGi+6RB/ABN9WZI7ceqkrtwhzSNA8FfUiqE5MnzIQkvcQ1QIm6VQq72RplYNq8qis3+Sutu3S2hgcHrHbDCeSYIESmHqu2CuSxRzRT1PJQyyheqbANW5d12WbqByrbGmpr8PDe7W0F/F0cJjEZ5kpF6+S4ckD9xFgpgiuS0IxukeIm0Ym3CC2BIP0SjUeRZCOQulGhlV547LDAu2QQnyYKGWiwddBxBVCw/e/IVOaUolBTwBIlgm1axcrfIehm4nUQiPhQkDgHrCjJhoqlK1Wyo5NE3XbpngpTpbxfGYwWJPzOTW1PHHBTnJuK9l/PmkJ8qn4K1hSBINamzPhJpt4vFmFGumiBAJbX0tFWudwLR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wjSKfCVCaYyAXJoOwoGqk0Ue0+XyidUaEgbiJYP+1KJn6QS3OVd5YVeSnyqeWMIg/n7pO6q836AVpWn/GsSy1Vsxrt5f2ISL5tx4UsMD2ExuRELY0duT8y1hOhSC9FhIYKjq02Mib45rtf/VBhG2hgSWwgmZ11B" | ||
} |
{ | ||
"name": "@signalapp/mock-server", | ||
"version": "5.0.1", | ||
"version": "5.1.0", | ||
"description": "Mock Signal Server for writing tests", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -20,2 +20,4 @@ /// <reference types="node" /> | ||
publicParams: string; | ||
genericSecretParams: string; | ||
genericPublicParams: string; | ||
}>; | ||
@@ -22,0 +24,0 @@ export type Config = Readonly<{ |
@@ -68,2 +68,4 @@ "use strict"; | ||
this.zkSecret = new zkgroup_1.ServerSecretParams(zkSecret); | ||
const genericSecret = Buffer.from(this.config.zkParams.genericSecretParams, 'base64'); | ||
this.genericServerSecret = new zkgroup_1.GenericServerSecretParams(genericSecret); | ||
this.certificate = (0, crypto_1.generateServerCertificate)(this.trustRoot); | ||
@@ -70,0 +72,0 @@ this.provisionQueue = this.createQueue(); |
export type Certificates = Readonly<{ | ||
certificateAuthority: string; | ||
genericServerPublicParams: string; | ||
serverPublicParams: string; | ||
@@ -4,0 +5,0 @@ serverTrustRoot: string; |
@@ -25,4 +25,5 @@ "use strict"; | ||
async function load() { | ||
const [certificateAuthority, serverPublicParams, serverTrustRoot,] = await Promise.all([ | ||
const [certificateAuthority, genericServerPublicParams, serverPublicParams, serverTrustRoot,] = await Promise.all([ | ||
loadString('ca-cert.pem'), | ||
loadJSONProperty('zk-params.json', 'genericPublicParams'), | ||
loadJSONProperty('zk-params.json', 'publicParams'), | ||
@@ -33,2 +34,3 @@ loadJSONProperty('trust-root.json', 'publicKey'), | ||
certificateAuthority, | ||
genericServerPublicParams, | ||
serverPublicParams, | ||
@@ -35,0 +37,0 @@ serverTrustRoot, |
/// <reference types="node" /> | ||
import Long from 'long'; | ||
import { SenderCertificate } from '@signalapp/libsignal-client'; | ||
import { AuthCredentialPresentation, ProfileKeyCredentialRequest, ServerSecretParams } from '@signalapp/libsignal-client/zkgroup'; | ||
import { AuthCredentialPresentation, GenericServerSecretParams, ProfileKeyCredentialRequest, ServerSecretParams } from '@signalapp/libsignal-client/zkgroup'; | ||
import { signalservice as Proto } from '../../protos/compiled'; | ||
@@ -128,2 +128,3 @@ import { ServerCertificate } from '../crypto'; | ||
protected privZKSecret: ServerSecretParams | undefined; | ||
protected privGenericServerSecret: GenericServerSecretParams | undefined; | ||
generateAci(): Promise<AciString>; | ||
@@ -180,2 +181,3 @@ generatePni(): Promise<PniString>; | ||
verifyGroupCredentials(publicParams: Buffer, credential: Buffer): Promise<AuthCredentialPresentation>; | ||
getCallLinkAuthCredentials({ aci }: Device, { from, to }: GroupCredentialsRange): Promise<GroupCredentials>; | ||
issueExpiringProfileKeyCredential({ aci, profileKeyCommitment }: Device, request: ProfileKeyCredentialRequest): Promise<Buffer | undefined>; | ||
@@ -186,2 +188,4 @@ abstract isUnregistered(serviceId: ServiceIdString): boolean; | ||
protected get certificate(): ServerCertificate; | ||
protected set genericServerSecret(value: GenericServerSecretParams); | ||
protected get genericServerSecret(): GenericServerSecretParams; | ||
protected set zkSecret(value: ServerSecretParams); | ||
@@ -188,0 +192,0 @@ protected get zkSecret(): ServerSecretParams; |
@@ -55,2 +55,3 @@ "use strict"; | ||
privZKSecret; | ||
privGenericServerSecret; | ||
// | ||
@@ -671,2 +672,19 @@ // Service Ids | ||
} | ||
async getCallLinkAuthCredentials({ aci }, { from, to }) { | ||
const today = (0, util_1.getTodayInSeconds)(); | ||
if (from > to || | ||
from < today || | ||
to > today + constants_1.DAY_IN_SECONDS * constants_1.MAX_GROUP_CREDENTIALS_DAYS) { | ||
throw new Error('Invalid redemption range'); | ||
} | ||
const result = []; | ||
for (let redemptionTime = from; redemptionTime <= to; redemptionTime += constants_1.DAY_IN_SECONDS) { | ||
result.push({ | ||
credential: zkgroup_1.CallLinkAuthCredentialResponse.issueCredential(libsignal_client_1.Aci.parseFromServiceIdString(aci), redemptionTime, this.genericServerSecret) | ||
.serialize().toString('base64'), | ||
redemptionTime, | ||
}); | ||
} | ||
return result; | ||
} | ||
async issueExpiringProfileKeyCredential({ aci, profileKeyCommitment }, request) { | ||
@@ -695,2 +713,14 @@ if (!profileKeyCommitment) { | ||
} | ||
set genericServerSecret(value) { | ||
if (this.privGenericServerSecret) { | ||
throw new Error('zkgroup generic secret already set'); | ||
} | ||
this.privGenericServerSecret = value; | ||
} | ||
get genericServerSecret() { | ||
if (!this.privGenericServerSecret) { | ||
throw new Error('zkgroup generic secret not set'); | ||
} | ||
return this.privGenericServerSecret; | ||
} | ||
set zkSecret(value) { | ||
@@ -697,0 +727,0 @@ if (this.privZKSecret) { |
@@ -290,2 +290,6 @@ "use strict"; | ||
}), | ||
callLinkAuthCredentials: await this.server.getCallLinkAuthCredentials(device, { | ||
from: parseInt(from, 10), | ||
to: parseInt(to, 10), | ||
}), | ||
pni: (0, types_1.untagPni)(device.pni), | ||
@@ -292,0 +296,0 @@ }, |
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
3588295
66366
2