@signalapp/libsignal-client 0.28.0 → 0.30.0
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/Native.d.ts +21 -19
- package/dist/Address.d.ts +10 -2
- package/dist/Address.js +31 -2
- package/dist/usernames.d.ts +5 -6
- package/dist/usernames.js +5 -11
- package/dist/zkgroup/auth/ClientZkAuthOperations.d.ts +12 -3
- package/dist/zkgroup/auth/ClientZkAuthOperations.js +15 -5
- package/dist/zkgroup/auth/ServerZkAuthOperations.d.ts +7 -5
- package/dist/zkgroup/auth/ServerZkAuthOperations.js +15 -9
- package/dist/zkgroup/calllinks/CallLinkAuthCredential.d.ts +3 -3
- package/dist/zkgroup/calllinks/CallLinkAuthCredential.js +1 -2
- package/dist/zkgroup/calllinks/CallLinkAuthCredentialResponse.d.ts +4 -4
- package/dist/zkgroup/calllinks/CallLinkAuthCredentialResponse.js +2 -3
- package/dist/zkgroup/calllinks/CallLinkSecretParams.d.ts +2 -2
- package/dist/zkgroup/calllinks/CallLinkSecretParams.js +2 -2
- package/dist/zkgroup/calllinks/CreateCallLinkCredential.d.ts +3 -3
- package/dist/zkgroup/calllinks/CreateCallLinkCredential.js +1 -2
- package/dist/zkgroup/calllinks/CreateCallLinkCredentialRequest.d.ts +3 -3
- package/dist/zkgroup/calllinks/CreateCallLinkCredentialRequest.js +1 -2
- package/dist/zkgroup/calllinks/CreateCallLinkCredentialRequestContext.d.ts +2 -2
- package/dist/zkgroup/calllinks/CreateCallLinkCredentialRequestContext.js +1 -2
- package/dist/zkgroup/groups/ClientZkGroupCipher.d.ts +5 -5
- package/dist/zkgroup/groups/ClientZkGroupCipher.js +9 -9
- package/dist/zkgroup/profiles/ClientZkProfileOperations.d.ts +3 -3
- package/dist/zkgroup/profiles/ClientZkProfileOperations.js +4 -5
- package/dist/zkgroup/profiles/ProfileKey.d.ts +3 -3
- package/dist/zkgroup/profiles/ProfileKey.js +4 -5
- package/dist/zkgroup/profiles/ServerZkProfileOperations.d.ts +3 -3
- package/dist/zkgroup/profiles/ServerZkProfileOperations.js +4 -5
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/node.napi.node +0 -0
- package/prebuilds/darwin-x64/node.napi.node +0 -0
- package/prebuilds/linux-arm64/node.napi.node +0 -0
- package/prebuilds/linux-x64/node.napi.node +0 -0
- package/prebuilds/win32-arm64/node.napi.node +0 -0
- package/prebuilds/win32-x64/node.napi.node +0 -0
- package/dist/zkgroup/internal/UUIDUtil.d.ts +0 -4
- package/dist/zkgroup/internal/UUIDUtil.js +0 -23
package/Native.d.ts
CHANGED
|
@@ -76,13 +76,13 @@ export function CallLinkAuthCredentialPresentation_CheckValidContents(presentati
|
|
|
76
76
|
export function CallLinkAuthCredentialPresentation_GetUserId(presentationBytes: Buffer): Serialized<UuidCiphertext>;
|
|
77
77
|
export function CallLinkAuthCredentialPresentation_Verify(presentationBytes: Buffer, now: Timestamp, serverParamsBytes: Buffer, callLinkParamsBytes: Buffer): void;
|
|
78
78
|
export function CallLinkAuthCredentialResponse_CheckValidContents(responseBytes: Buffer): void;
|
|
79
|
-
export function CallLinkAuthCredentialResponse_IssueDeterministic(userId:
|
|
80
|
-
export function CallLinkAuthCredentialResponse_Receive(responseBytes: Buffer, userId:
|
|
79
|
+
export function CallLinkAuthCredentialResponse_IssueDeterministic(userId: Buffer, redemptionTime: Timestamp, paramsBytes: Buffer, randomness: Buffer): Buffer;
|
|
80
|
+
export function CallLinkAuthCredentialResponse_Receive(responseBytes: Buffer, userId: Buffer, redemptionTime: Timestamp, paramsBytes: Buffer): Buffer;
|
|
81
81
|
export function CallLinkAuthCredential_CheckValidContents(credentialBytes: Buffer): void;
|
|
82
|
-
export function CallLinkAuthCredential_PresentDeterministic(credentialBytes: Buffer, userId:
|
|
82
|
+
export function CallLinkAuthCredential_PresentDeterministic(credentialBytes: Buffer, userId: Buffer, redemptionTime: Timestamp, serverParamsBytes: Buffer, callLinkParamsBytes: Buffer, randomness: Buffer): Buffer;
|
|
83
83
|
export function CallLinkPublicParams_CheckValidContents(paramsBytes: Buffer): void;
|
|
84
84
|
export function CallLinkSecretParams_CheckValidContents(paramsBytes: Buffer): void;
|
|
85
|
-
export function CallLinkSecretParams_DecryptUserId(paramsBytes: Buffer, userId: Serialized<UuidCiphertext>):
|
|
85
|
+
export function CallLinkSecretParams_DecryptUserId(paramsBytes: Buffer, userId: Serialized<UuidCiphertext>): Buffer;
|
|
86
86
|
export function CallLinkSecretParams_DeriveFromRootKey(rootKey: Buffer): Buffer;
|
|
87
87
|
export function CallLinkSecretParams_GetPublicParams(paramsBytes: Buffer): Buffer;
|
|
88
88
|
export function Cds2ClientState_New(mrenclave: Buffer, attestationMsg: Buffer, currentTimestamp: Timestamp): SgxClientState;
|
|
@@ -94,12 +94,12 @@ export function CreateCallLinkCredentialPresentation_Verify(presentationBytes: B
|
|
|
94
94
|
export function CreateCallLinkCredentialRequestContext_CheckValidContents(contextBytes: Buffer): void;
|
|
95
95
|
export function CreateCallLinkCredentialRequestContext_GetRequest(contextBytes: Buffer): Buffer;
|
|
96
96
|
export function CreateCallLinkCredentialRequestContext_NewDeterministic(roomId: Buffer, randomness: Buffer): Buffer;
|
|
97
|
-
export function CreateCallLinkCredentialRequestContext_ReceiveResponse(contextBytes: Buffer, responseBytes: Buffer, userId:
|
|
97
|
+
export function CreateCallLinkCredentialRequestContext_ReceiveResponse(contextBytes: Buffer, responseBytes: Buffer, userId: Buffer, paramsBytes: Buffer): Buffer;
|
|
98
98
|
export function CreateCallLinkCredentialRequest_CheckValidContents(requestBytes: Buffer): void;
|
|
99
|
-
export function CreateCallLinkCredentialRequest_IssueDeterministic(requestBytes: Buffer, userId:
|
|
99
|
+
export function CreateCallLinkCredentialRequest_IssueDeterministic(requestBytes: Buffer, userId: Buffer, timestamp: Timestamp, paramsBytes: Buffer, randomness: Buffer): Buffer;
|
|
100
100
|
export function CreateCallLinkCredentialResponse_CheckValidContents(responseBytes: Buffer): void;
|
|
101
101
|
export function CreateCallLinkCredential_CheckValidContents(paramsBytes: Buffer): void;
|
|
102
|
-
export function CreateCallLinkCredential_PresentDeterministic(credentialBytes: Buffer, roomId: Buffer, userId:
|
|
102
|
+
export function CreateCallLinkCredential_PresentDeterministic(credentialBytes: Buffer, roomId: Buffer, userId: Buffer, serverParamsBytes: Buffer, callLinkParamsBytes: Buffer, randomness: Buffer): Buffer;
|
|
103
103
|
export function DecryptionErrorMessage_Deserialize(data: Buffer): DecryptionErrorMessage;
|
|
104
104
|
export function DecryptionErrorMessage_ExtractFromSerializedContent(bytes: Buffer): DecryptionErrorMessage;
|
|
105
105
|
export function DecryptionErrorMessage_ForOriginalMessage(originalBytes: Buffer, originalType: number, originalTimestamp: Timestamp, originalSenderDeviceId: number): DecryptionErrorMessage;
|
|
@@ -124,12 +124,12 @@ export function GroupPublicParams_CheckValidContents(buffer: Buffer): void;
|
|
|
124
124
|
export function GroupPublicParams_GetGroupIdentifier(groupPublicParams: Serialized<GroupPublicParams>): Buffer;
|
|
125
125
|
export function GroupSecretParams_CheckValidContents(buffer: Buffer): void;
|
|
126
126
|
export function GroupSecretParams_DecryptBlobWithPadding(params: Serialized<GroupSecretParams>, ciphertext: Buffer): Buffer;
|
|
127
|
-
export function GroupSecretParams_DecryptProfileKey(params: Serialized<GroupSecretParams>, profileKey: Serialized<ProfileKeyCiphertext>,
|
|
128
|
-
export function
|
|
127
|
+
export function GroupSecretParams_DecryptProfileKey(params: Serialized<GroupSecretParams>, profileKey: Serialized<ProfileKeyCiphertext>, userId: Buffer): Serialized<ProfileKey>;
|
|
128
|
+
export function GroupSecretParams_DecryptServiceId(params: Serialized<GroupSecretParams>, ciphertext: Serialized<UuidCiphertext>): Buffer;
|
|
129
129
|
export function GroupSecretParams_DeriveFromMasterKey(masterKey: Serialized<GroupMasterKey>): Serialized<GroupSecretParams>;
|
|
130
130
|
export function GroupSecretParams_EncryptBlobWithPaddingDeterministic(params: Serialized<GroupSecretParams>, randomness: Buffer, plaintext: Buffer, paddingLen: number): Buffer;
|
|
131
|
-
export function GroupSecretParams_EncryptProfileKey(params: Serialized<GroupSecretParams>, profileKey: Serialized<ProfileKey>,
|
|
132
|
-
export function
|
|
131
|
+
export function GroupSecretParams_EncryptProfileKey(params: Serialized<GroupSecretParams>, profileKey: Serialized<ProfileKey>, userId: Buffer): Serialized<ProfileKeyCiphertext>;
|
|
132
|
+
export function GroupSecretParams_EncryptServiceId(params: Serialized<GroupSecretParams>, serviceId: Buffer): Serialized<UuidCiphertext>;
|
|
133
133
|
export function GroupSecretParams_GenerateDeterministic(randomness: Buffer): Serialized<GroupSecretParams>;
|
|
134
134
|
export function GroupSecretParams_GetMasterKey(params: Serialized<GroupSecretParams>): Serialized<GroupMasterKey>;
|
|
135
135
|
export function GroupSecretParams_GetPublicParams(params: Serialized<GroupSecretParams>): Serialized<GroupPublicParams>;
|
|
@@ -210,8 +210,8 @@ export function ProfileKeyCredentialRequestContext_GetRequest(context: Serialize
|
|
|
210
210
|
export function ProfileKeyCredentialRequest_CheckValidContents(buffer: Buffer): void;
|
|
211
211
|
export function ProfileKey_CheckValidContents(buffer: Buffer): void;
|
|
212
212
|
export function ProfileKey_DeriveAccessKey(profileKey: Serialized<ProfileKey>): Buffer;
|
|
213
|
-
export function ProfileKey_GetCommitment(profileKey: Serialized<ProfileKey>,
|
|
214
|
-
export function ProfileKey_GetProfileKeyVersion(profileKey: Serialized<ProfileKey>,
|
|
213
|
+
export function ProfileKey_GetCommitment(profileKey: Serialized<ProfileKey>, userId: Buffer): Serialized<ProfileKeyCommitment>;
|
|
214
|
+
export function ProfileKey_GetProfileKeyVersion(profileKey: Serialized<ProfileKey>, userId: Buffer): Buffer;
|
|
215
215
|
export function ProtocolAddress_DeviceId(obj: Wrapper<ProtocolAddress>): number;
|
|
216
216
|
export function ProtocolAddress_Name(obj: Wrapper<ProtocolAddress>): string;
|
|
217
217
|
export function ProtocolAddress_New(name: string, deviceId: number): ProtocolAddress;
|
|
@@ -287,20 +287,22 @@ export function ServerPublicParams_CheckValidContents(buffer: Buffer): void;
|
|
|
287
287
|
export function ServerPublicParams_CreateAuthCredentialPresentationDeterministic(serverPublicParams: Serialized<ServerPublicParams>, randomness: Buffer, groupSecretParams: Serialized<GroupSecretParams>, authCredential: Serialized<AuthCredential>): Buffer;
|
|
288
288
|
export function ServerPublicParams_CreateAuthCredentialWithPniPresentationDeterministic(serverPublicParams: Serialized<ServerPublicParams>, randomness: Buffer, groupSecretParams: Serialized<GroupSecretParams>, authCredential: Serialized<AuthCredentialWithPni>): Buffer;
|
|
289
289
|
export function ServerPublicParams_CreateExpiringProfileKeyCredentialPresentationDeterministic(serverPublicParams: Serialized<ServerPublicParams>, randomness: Buffer, groupSecretParams: Serialized<GroupSecretParams>, profileKeyCredential: Serialized<ExpiringProfileKeyCredential>): Buffer;
|
|
290
|
-
export function ServerPublicParams_CreateProfileKeyCredentialRequestContextDeterministic(serverPublicParams: Serialized<ServerPublicParams>, randomness: Buffer,
|
|
290
|
+
export function ServerPublicParams_CreateProfileKeyCredentialRequestContextDeterministic(serverPublicParams: Serialized<ServerPublicParams>, randomness: Buffer, userId: Buffer, profileKey: Serialized<ProfileKey>): Serialized<ProfileKeyCredentialRequestContext>;
|
|
291
291
|
export function ServerPublicParams_CreateReceiptCredentialPresentationDeterministic(serverPublicParams: Serialized<ServerPublicParams>, randomness: Buffer, receiptCredential: Serialized<ReceiptCredential>): Serialized<ReceiptCredentialPresentation>;
|
|
292
292
|
export function ServerPublicParams_CreateReceiptCredentialRequestContextDeterministic(serverPublicParams: Serialized<ServerPublicParams>, randomness: Buffer, receiptSerial: Buffer): Serialized<ReceiptCredentialRequestContext>;
|
|
293
|
-
export function ServerPublicParams_ReceiveAuthCredential(params: Serialized<ServerPublicParams>,
|
|
294
|
-
export function
|
|
293
|
+
export function ServerPublicParams_ReceiveAuthCredential(params: Serialized<ServerPublicParams>, aci: Buffer, redemptionTime: number, response: Serialized<AuthCredentialResponse>): Serialized<AuthCredential>;
|
|
294
|
+
export function ServerPublicParams_ReceiveAuthCredentialWithPniAsAci(params: Serialized<ServerPublicParams>, aci: Buffer, pni: Buffer, redemptionTime: Timestamp, response: Serialized<AuthCredentialWithPniResponse>): Serialized<AuthCredentialWithPni>;
|
|
295
|
+
export function ServerPublicParams_ReceiveAuthCredentialWithPniAsServiceId(params: Serialized<ServerPublicParams>, aci: Buffer, pni: Buffer, redemptionTime: Timestamp, response: Serialized<AuthCredentialWithPniResponse>): Serialized<AuthCredentialWithPni>;
|
|
295
296
|
export function ServerPublicParams_ReceiveExpiringProfileKeyCredential(serverPublicParams: Serialized<ServerPublicParams>, requestContext: Serialized<ProfileKeyCredentialRequestContext>, response: Serialized<ExpiringProfileKeyCredentialResponse>, currentTimeInSeconds: Timestamp): Serialized<ExpiringProfileKeyCredential>;
|
|
296
297
|
export function ServerPublicParams_ReceiveReceiptCredential(serverPublicParams: Serialized<ServerPublicParams>, requestContext: Serialized<ReceiptCredentialRequestContext>, response: Serialized<ReceiptCredentialResponse>): Serialized<ReceiptCredential>;
|
|
297
298
|
export function ServerPublicParams_VerifySignature(serverPublicParams: Serialized<ServerPublicParams>, message: Buffer, notarySignature: Buffer): void;
|
|
298
299
|
export function ServerSecretParams_CheckValidContents(buffer: Buffer): void;
|
|
299
300
|
export function ServerSecretParams_GenerateDeterministic(randomness: Buffer): Serialized<ServerSecretParams>;
|
|
300
301
|
export function ServerSecretParams_GetPublicParams(params: Serialized<ServerSecretParams>): Serialized<ServerPublicParams>;
|
|
301
|
-
export function ServerSecretParams_IssueAuthCredentialDeterministic(serverSecretParams: Serialized<ServerSecretParams>, randomness: Buffer,
|
|
302
|
-
export function
|
|
303
|
-
export function
|
|
302
|
+
export function ServerSecretParams_IssueAuthCredentialDeterministic(serverSecretParams: Serialized<ServerSecretParams>, randomness: Buffer, aci: Buffer, redemptionTime: number): Serialized<AuthCredentialResponse>;
|
|
303
|
+
export function ServerSecretParams_IssueAuthCredentialWithPniAsAciDeterministic(serverSecretParams: Serialized<ServerSecretParams>, randomness: Buffer, aci: Buffer, pni: Buffer, redemptionTime: Timestamp): Serialized<AuthCredentialWithPniResponse>;
|
|
304
|
+
export function ServerSecretParams_IssueAuthCredentialWithPniAsServiceIdDeterministic(serverSecretParams: Serialized<ServerSecretParams>, randomness: Buffer, aci: Buffer, pni: Buffer, redemptionTime: Timestamp): Serialized<AuthCredentialWithPniResponse>;
|
|
305
|
+
export function ServerSecretParams_IssueExpiringProfileKeyCredentialDeterministic(serverSecretParams: Serialized<ServerSecretParams>, randomness: Buffer, request: Serialized<ProfileKeyCredentialRequest>, userId: Buffer, commitment: Serialized<ProfileKeyCommitment>, expirationInSeconds: Timestamp): Serialized<ExpiringProfileKeyCredentialResponse>;
|
|
304
306
|
export function ServerSecretParams_IssueReceiptCredentialDeterministic(serverSecretParams: Serialized<ServerSecretParams>, randomness: Buffer, request: Serialized<ReceiptCredentialRequest>, receiptExpirationTime: Timestamp, receiptLevel: Buffer): Serialized<ReceiptCredentialResponse>;
|
|
305
307
|
export function ServerSecretParams_SignDeterministic(params: Serialized<ServerSecretParams>, randomness: Buffer, message: Buffer): Buffer;
|
|
306
308
|
export function ServerSecretParams_VerifyAuthCredentialPresentation(serverSecretParams: Serialized<ServerSecretParams>, groupPublicParams: Serialized<GroupPublicParams>, presentationBytes: Buffer, currentTimeInSeconds: Timestamp): void;
|
package/dist/Address.d.ts
CHANGED
|
@@ -12,9 +12,10 @@ export declare class ServiceId extends Object {
|
|
|
12
12
|
protected constructor(serviceIdFixedWidthBinary: Buffer);
|
|
13
13
|
protected static fromUuidBytesAndKind<T extends typeof ServiceId>(this: T, uuidBytes: ArrayLike<number>, kind: ServiceIdKind): ThisType<T>;
|
|
14
14
|
getServiceIdBinary(): Buffer;
|
|
15
|
+
getServiceIdFixedWidthBinary(): Buffer;
|
|
15
16
|
getServiceIdString(): string;
|
|
16
17
|
toString(): string;
|
|
17
|
-
|
|
18
|
+
static parseFromServiceIdFixedWidthBinary<T extends typeof ServiceId>(this: T, serviceIdFixedWidthBinary: Buffer): ThisType<T>;
|
|
18
19
|
static parseFromServiceIdBinary(serviceIdBinary: Buffer): ServiceId;
|
|
19
20
|
static parseFromServiceIdString(serviceIdString: string): ServiceId;
|
|
20
21
|
getRawUuid(): string;
|
|
@@ -35,8 +36,15 @@ export declare class ProtocolAddress {
|
|
|
35
36
|
readonly _nativeHandle: Native.ProtocolAddress;
|
|
36
37
|
private constructor();
|
|
37
38
|
static _fromNativeHandle(handle: Native.ProtocolAddress): ProtocolAddress;
|
|
38
|
-
static new(name: string, deviceId: number): ProtocolAddress;
|
|
39
|
+
static new(name: string | ServiceId, deviceId: number): ProtocolAddress;
|
|
39
40
|
name(): string;
|
|
41
|
+
/**
|
|
42
|
+
* Returns a ServiceId if this address contains a valid ServiceId, `null` otherwise.
|
|
43
|
+
*
|
|
44
|
+
* In a future release ProtocolAddresses will *only* support ServiceIds.
|
|
45
|
+
*/
|
|
46
|
+
serviceId(): ServiceId | null;
|
|
40
47
|
deviceId(): number;
|
|
48
|
+
toString(): string;
|
|
41
49
|
}
|
|
42
50
|
export {};
|
package/dist/Address.js
CHANGED
|
@@ -30,6 +30,9 @@ class ServiceId extends Object {
|
|
|
30
30
|
getServiceIdBinary() {
|
|
31
31
|
return Native.ServiceId_ServiceIdBinary(this.serviceIdFixedWidthBinary);
|
|
32
32
|
}
|
|
33
|
+
getServiceIdFixedWidthBinary() {
|
|
34
|
+
return Buffer.from(this.serviceIdFixedWidthBinary);
|
|
35
|
+
}
|
|
33
36
|
getServiceIdString() {
|
|
34
37
|
return Native.ServiceId_ServiceIdString(this.serviceIdFixedWidthBinary);
|
|
35
38
|
}
|
|
@@ -37,14 +40,21 @@ class ServiceId extends Object {
|
|
|
37
40
|
return Native.ServiceId_ServiceIdLog(this.serviceIdFixedWidthBinary);
|
|
38
41
|
}
|
|
39
42
|
static parseFromServiceIdFixedWidthBinary(serviceIdFixedWidthBinary) {
|
|
43
|
+
let result;
|
|
40
44
|
switch (serviceIdFixedWidthBinary[0]) {
|
|
41
45
|
case ServiceIdKind.Aci:
|
|
42
|
-
|
|
46
|
+
result = new Aci(serviceIdFixedWidthBinary);
|
|
47
|
+
break;
|
|
43
48
|
case ServiceIdKind.Pni:
|
|
44
|
-
|
|
49
|
+
result = new Pni(serviceIdFixedWidthBinary);
|
|
50
|
+
break;
|
|
45
51
|
default:
|
|
46
52
|
throw new TypeError('unknown type in Service-Id-FixedWidthBinary');
|
|
47
53
|
}
|
|
54
|
+
if (result instanceof this) {
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
throw new TypeError(`expected ${this.name}, got ${result.constructor.name}`);
|
|
48
58
|
}
|
|
49
59
|
static parseFromServiceIdBinary(serviceIdBinary) {
|
|
50
60
|
return ServiceId.parseFromServiceIdFixedWidthBinary(Native.ServiceId_ParseFromServiceIdBinary(serviceIdBinary));
|
|
@@ -89,14 +99,33 @@ class ProtocolAddress {
|
|
|
89
99
|
return new ProtocolAddress(handle);
|
|
90
100
|
}
|
|
91
101
|
static new(name, deviceId) {
|
|
102
|
+
if (typeof name !== 'string') {
|
|
103
|
+
name = name.getServiceIdString();
|
|
104
|
+
}
|
|
92
105
|
return new ProtocolAddress(Native.ProtocolAddress_New(name, deviceId));
|
|
93
106
|
}
|
|
94
107
|
name() {
|
|
95
108
|
return Native.ProtocolAddress_Name(this);
|
|
96
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Returns a ServiceId if this address contains a valid ServiceId, `null` otherwise.
|
|
112
|
+
*
|
|
113
|
+
* In a future release ProtocolAddresses will *only* support ServiceIds.
|
|
114
|
+
*/
|
|
115
|
+
serviceId() {
|
|
116
|
+
try {
|
|
117
|
+
return ServiceId.parseFromServiceIdString(this.name());
|
|
118
|
+
}
|
|
119
|
+
catch (_a) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
97
123
|
deviceId() {
|
|
98
124
|
return Native.ProtocolAddress_DeviceId(this);
|
|
99
125
|
}
|
|
126
|
+
toString() {
|
|
127
|
+
return `${this.name()}.${this.deviceId()}`;
|
|
128
|
+
}
|
|
100
129
|
}
|
|
101
130
|
exports.ProtocolAddress = ProtocolAddress;
|
|
102
131
|
//# sourceMappingURL=Address.js.map
|
package/dist/usernames.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
export type UsernameLink = {
|
|
3
|
+
entropy: Buffer;
|
|
4
|
+
encryptedUsername: Buffer;
|
|
5
|
+
};
|
|
2
6
|
export declare function generateCandidates(nickname: string, minNicknameLength: number, maxNicknameLength: number): string[];
|
|
3
7
|
export declare function hash(username: string): Buffer;
|
|
4
8
|
export declare function generateProof(username: string): Buffer;
|
|
5
9
|
export declare function generateProofWithRandom(username: string, random: Buffer): Buffer;
|
|
6
|
-
export declare
|
|
7
|
-
readonly entropy: Buffer;
|
|
8
|
-
readonly encryptedUsername: Buffer;
|
|
9
|
-
constructor(entropy: Buffer, encryptedUsername: Buffer);
|
|
10
|
-
decryptUsername(): string;
|
|
11
|
-
}
|
|
10
|
+
export declare function decryptUsernameLink(usernameLink: UsernameLink): string;
|
|
12
11
|
export declare function createUsernameLink(username: string): UsernameLink;
|
|
13
12
|
export declare function verifyProof(proof: Buffer, hash: Buffer): void;
|
package/dist/usernames.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
5
5
|
//
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.verifyProof = exports.createUsernameLink = exports.
|
|
7
|
+
exports.verifyProof = exports.createUsernameLink = exports.decryptUsernameLink = exports.generateProofWithRandom = exports.generateProof = exports.hash = exports.generateCandidates = void 0;
|
|
8
8
|
/* eslint @typescript-eslint/no-shadow: ["error", { "allow": ["hash"] }] */
|
|
9
9
|
const crypto_1 = require("crypto");
|
|
10
10
|
const Constants_1 = require("./zkgroup/internal/Constants");
|
|
@@ -26,21 +26,15 @@ function generateProofWithRandom(username, random) {
|
|
|
26
26
|
return Native.Username_Proof(username, random);
|
|
27
27
|
}
|
|
28
28
|
exports.generateProofWithRandom = generateProofWithRandom;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
this.entropy = entropy;
|
|
32
|
-
this.encryptedUsername = encryptedUsername;
|
|
33
|
-
}
|
|
34
|
-
decryptUsername() {
|
|
35
|
-
return Native.UsernameLink_DecryptUsername(this.entropy, this.encryptedUsername);
|
|
36
|
-
}
|
|
29
|
+
function decryptUsernameLink(usernameLink) {
|
|
30
|
+
return Native.UsernameLink_DecryptUsername(usernameLink.entropy, usernameLink.encryptedUsername);
|
|
37
31
|
}
|
|
38
|
-
exports.
|
|
32
|
+
exports.decryptUsernameLink = decryptUsernameLink;
|
|
39
33
|
function createUsernameLink(username) {
|
|
40
34
|
const usernameLinkData = Native.UsernameLink_Create(username);
|
|
41
35
|
const entropy = usernameLinkData.slice(0, 32);
|
|
42
36
|
const encryptedUsername = usernameLinkData.slice(32);
|
|
43
|
-
return
|
|
37
|
+
return { entropy, encryptedUsername };
|
|
44
38
|
}
|
|
45
39
|
exports.createUsernameLink = createUsernameLink;
|
|
46
40
|
// Only for testing. Will throw on failure.
|
|
@@ -6,17 +6,26 @@ import AuthCredentialResponse from './AuthCredentialResponse';
|
|
|
6
6
|
import AuthCredentialWithPni from './AuthCredentialWithPni';
|
|
7
7
|
import AuthCredentialWithPniResponse from './AuthCredentialWithPniResponse';
|
|
8
8
|
import GroupSecretParams from '../groups/GroupSecretParams';
|
|
9
|
-
import {
|
|
9
|
+
import { Aci, Pni } from '../../Address';
|
|
10
10
|
export default class ClientZkAuthOperations {
|
|
11
11
|
serverPublicParams: ServerPublicParams;
|
|
12
12
|
constructor(serverPublicParams: ServerPublicParams);
|
|
13
|
-
receiveAuthCredential(
|
|
13
|
+
receiveAuthCredential(aci: Aci, redemptionTime: number, authCredentialResponse: AuthCredentialResponse): AuthCredential;
|
|
14
14
|
/**
|
|
15
15
|
* Produces the AuthCredentialWithPni from a server-generated AuthCredentialWithPniResponse.
|
|
16
16
|
*
|
|
17
17
|
* @param redemptionTime - This is provided by the server as an integer, and should be passed through directly.
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
receiveAuthCredentialWithPniAsServiceId(aci: Aci, pni: Pni, redemptionTime: number, authCredentialResponse: AuthCredentialWithPniResponse): AuthCredentialWithPni;
|
|
20
|
+
/**
|
|
21
|
+
* Produces the AuthCredentialWithPni from a server-generated AuthCredentialWithPniResponse.
|
|
22
|
+
*
|
|
23
|
+
* This older style of AuthCredentialWithPni will not actually have a usable PNI field,
|
|
24
|
+
* but can still be used for authenticating with an ACI.
|
|
25
|
+
*
|
|
26
|
+
* @param redemptionTime - This is provided by the server as an integer, and should be passed through directly.
|
|
27
|
+
*/
|
|
28
|
+
receiveAuthCredentialWithPniAsAci(aci: Aci, pni: Pni, redemptionTime: number, authCredentialResponse: AuthCredentialWithPniResponse): AuthCredentialWithPni;
|
|
20
29
|
createAuthCredentialPresentation(groupSecretParams: GroupSecretParams, authCredential: AuthCredential): AuthCredentialPresentation;
|
|
21
30
|
createAuthCredentialPresentationWithRandom(random: Buffer, groupSecretParams: GroupSecretParams, authCredential: AuthCredential): AuthCredentialPresentation;
|
|
22
31
|
createAuthCredentialWithPniPresentation(groupSecretParams: GroupSecretParams, authCredential: AuthCredentialWithPni): AuthCredentialPresentation;
|
|
@@ -10,21 +10,31 @@ const Constants_1 = require("../internal/Constants");
|
|
|
10
10
|
const AuthCredential_1 = require("./AuthCredential");
|
|
11
11
|
const AuthCredentialPresentation_1 = require("./AuthCredentialPresentation");
|
|
12
12
|
const AuthCredentialWithPni_1 = require("./AuthCredentialWithPni");
|
|
13
|
-
const UUIDUtil_1 = require("../internal/UUIDUtil");
|
|
14
13
|
class ClientZkAuthOperations {
|
|
15
14
|
constructor(serverPublicParams) {
|
|
16
15
|
this.serverPublicParams = serverPublicParams;
|
|
17
16
|
}
|
|
18
|
-
receiveAuthCredential(
|
|
19
|
-
return new AuthCredential_1.default(Native.ServerPublicParams_ReceiveAuthCredential(this.serverPublicParams.getContents(),
|
|
17
|
+
receiveAuthCredential(aci, redemptionTime, authCredentialResponse) {
|
|
18
|
+
return new AuthCredential_1.default(Native.ServerPublicParams_ReceiveAuthCredential(this.serverPublicParams.getContents(), aci.getServiceIdFixedWidthBinary(), redemptionTime, authCredentialResponse.getContents()));
|
|
20
19
|
}
|
|
21
20
|
/**
|
|
22
21
|
* Produces the AuthCredentialWithPni from a server-generated AuthCredentialWithPniResponse.
|
|
23
22
|
*
|
|
24
23
|
* @param redemptionTime - This is provided by the server as an integer, and should be passed through directly.
|
|
25
24
|
*/
|
|
26
|
-
|
|
27
|
-
return new AuthCredentialWithPni_1.default(Native.
|
|
25
|
+
receiveAuthCredentialWithPniAsServiceId(aci, pni, redemptionTime, authCredentialResponse) {
|
|
26
|
+
return new AuthCredentialWithPni_1.default(Native.ServerPublicParams_ReceiveAuthCredentialWithPniAsServiceId(this.serverPublicParams.getContents(), aci.getServiceIdFixedWidthBinary(), pni.getServiceIdFixedWidthBinary(), redemptionTime, authCredentialResponse.getContents()));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Produces the AuthCredentialWithPni from a server-generated AuthCredentialWithPniResponse.
|
|
30
|
+
*
|
|
31
|
+
* This older style of AuthCredentialWithPni will not actually have a usable PNI field,
|
|
32
|
+
* but can still be used for authenticating with an ACI.
|
|
33
|
+
*
|
|
34
|
+
* @param redemptionTime - This is provided by the server as an integer, and should be passed through directly.
|
|
35
|
+
*/
|
|
36
|
+
receiveAuthCredentialWithPniAsAci(aci, pni, redemptionTime, authCredentialResponse) {
|
|
37
|
+
return new AuthCredentialWithPni_1.default(Native.ServerPublicParams_ReceiveAuthCredentialWithPniAsAci(this.serverPublicParams.getContents(), aci.getServiceIdFixedWidthBinary(), pni.getServiceIdFixedWidthBinary(), redemptionTime, authCredentialResponse.getContents()));
|
|
28
38
|
}
|
|
29
39
|
createAuthCredentialPresentation(groupSecretParams, authCredential) {
|
|
30
40
|
const random = (0, crypto_1.randomBytes)(Constants_1.RANDOM_LENGTH);
|
|
@@ -4,13 +4,15 @@ import AuthCredentialResponse from './AuthCredentialResponse';
|
|
|
4
4
|
import AuthCredentialPresentation from './AuthCredentialPresentation';
|
|
5
5
|
import AuthCredentialWithPniResponse from './AuthCredentialWithPniResponse';
|
|
6
6
|
import GroupPublicParams from '../groups/GroupPublicParams';
|
|
7
|
-
import {
|
|
7
|
+
import { Aci, Pni } from '../../Address';
|
|
8
8
|
export default class ServerZkAuthOperations {
|
|
9
9
|
serverSecretParams: ServerSecretParams;
|
|
10
10
|
constructor(serverSecretParams: ServerSecretParams);
|
|
11
|
-
issueAuthCredential(
|
|
12
|
-
issueAuthCredentialWithRandom(random: Buffer,
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
issueAuthCredential(aci: Aci, redemptionTime: number): AuthCredentialResponse;
|
|
12
|
+
issueAuthCredentialWithRandom(random: Buffer, aci: Aci, redemptionTime: number): AuthCredentialResponse;
|
|
13
|
+
issueAuthCredentialWithPniAsServiceId(aci: Aci, pni: Pni, redemptionTime: number): AuthCredentialWithPniResponse;
|
|
14
|
+
issueAuthCredentialWithPniAsServiceIdWithRandom(random: Buffer, aci: Aci, pni: Pni, redemptionTime: number): AuthCredentialWithPniResponse;
|
|
15
|
+
issueAuthCredentialWithPniAsAci(aci: Aci, pni: Pni, redemptionTime: number): AuthCredentialWithPniResponse;
|
|
16
|
+
issueAuthCredentialWithPniAsAciWithRandom(random: Buffer, aci: Aci, pni: Pni, redemptionTime: number): AuthCredentialWithPniResponse;
|
|
15
17
|
verifyAuthCredentialPresentation(groupPublicParams: GroupPublicParams, authCredentialPresentation: AuthCredentialPresentation, now?: Date): void;
|
|
16
18
|
}
|
|
@@ -9,24 +9,30 @@ const Constants_1 = require("../internal/Constants");
|
|
|
9
9
|
const Native = require("../../../Native");
|
|
10
10
|
const AuthCredentialResponse_1 = require("./AuthCredentialResponse");
|
|
11
11
|
const AuthCredentialWithPniResponse_1 = require("./AuthCredentialWithPniResponse");
|
|
12
|
-
const UUIDUtil_1 = require("../internal/UUIDUtil");
|
|
13
12
|
class ServerZkAuthOperations {
|
|
14
13
|
constructor(serverSecretParams) {
|
|
15
14
|
this.serverSecretParams = serverSecretParams;
|
|
16
15
|
}
|
|
17
|
-
issueAuthCredential(
|
|
16
|
+
issueAuthCredential(aci, redemptionTime) {
|
|
18
17
|
const random = (0, crypto_1.randomBytes)(Constants_1.RANDOM_LENGTH);
|
|
19
|
-
return this.issueAuthCredentialWithRandom(random,
|
|
18
|
+
return this.issueAuthCredentialWithRandom(random, aci, redemptionTime);
|
|
20
19
|
}
|
|
21
|
-
issueAuthCredentialWithRandom(random,
|
|
22
|
-
return new AuthCredentialResponse_1.default(Native.ServerSecretParams_IssueAuthCredentialDeterministic(this.serverSecretParams.getContents(), random,
|
|
20
|
+
issueAuthCredentialWithRandom(random, aci, redemptionTime) {
|
|
21
|
+
return new AuthCredentialResponse_1.default(Native.ServerSecretParams_IssueAuthCredentialDeterministic(this.serverSecretParams.getContents(), random, aci.getServiceIdFixedWidthBinary(), redemptionTime));
|
|
23
22
|
}
|
|
24
|
-
|
|
23
|
+
issueAuthCredentialWithPniAsServiceId(aci, pni, redemptionTime) {
|
|
25
24
|
const random = (0, crypto_1.randomBytes)(Constants_1.RANDOM_LENGTH);
|
|
26
|
-
return this.
|
|
25
|
+
return this.issueAuthCredentialWithPniAsServiceIdWithRandom(random, aci, pni, redemptionTime);
|
|
27
26
|
}
|
|
28
|
-
|
|
29
|
-
return new AuthCredentialWithPniResponse_1.default(Native.
|
|
27
|
+
issueAuthCredentialWithPniAsServiceIdWithRandom(random, aci, pni, redemptionTime) {
|
|
28
|
+
return new AuthCredentialWithPniResponse_1.default(Native.ServerSecretParams_IssueAuthCredentialWithPniAsServiceIdDeterministic(this.serverSecretParams.getContents(), random, aci.getServiceIdFixedWidthBinary(), pni.getServiceIdFixedWidthBinary(), redemptionTime));
|
|
29
|
+
}
|
|
30
|
+
issueAuthCredentialWithPniAsAci(aci, pni, redemptionTime) {
|
|
31
|
+
const random = (0, crypto_1.randomBytes)(Constants_1.RANDOM_LENGTH);
|
|
32
|
+
return this.issueAuthCredentialWithPniAsAciWithRandom(random, aci, pni, redemptionTime);
|
|
33
|
+
}
|
|
34
|
+
issueAuthCredentialWithPniAsAciWithRandom(random, aci, pni, redemptionTime) {
|
|
35
|
+
return new AuthCredentialWithPniResponse_1.default(Native.ServerSecretParams_IssueAuthCredentialWithPniAsAciDeterministic(this.serverSecretParams.getContents(), random, aci.getServiceIdFixedWidthBinary(), pni.getServiceIdFixedWidthBinary(), redemptionTime));
|
|
30
36
|
}
|
|
31
37
|
verifyAuthCredentialPresentation(groupPublicParams, authCredentialPresentation, now = new Date()) {
|
|
32
38
|
Native.ServerSecretParams_VerifyAuthCredentialPresentation(this.serverSecretParams.getContents(), groupPublicParams.getContents(), authCredentialPresentation.getContents(), Math.floor(now.getTime() / 1000));
|
|
@@ -3,10 +3,10 @@ import ByteArray from '../internal/ByteArray';
|
|
|
3
3
|
import CallLinkSecretParams from './CallLinkSecretParams';
|
|
4
4
|
import CallLinkAuthCredentialPresentation from './CallLinkAuthCredentialPresentation';
|
|
5
5
|
import GenericServerPublicParams from '../GenericServerPublicParams';
|
|
6
|
-
import {
|
|
6
|
+
import { Aci } from '../../Address';
|
|
7
7
|
export default class CallLinkAuthCredential extends ByteArray {
|
|
8
8
|
private readonly __type?;
|
|
9
9
|
constructor(contents: Buffer);
|
|
10
|
-
present(userId:
|
|
11
|
-
presentWithRandom(userId:
|
|
10
|
+
present(userId: Aci, redemptionTime: number, serverParams: GenericServerPublicParams, callLinkParams: CallLinkSecretParams): CallLinkAuthCredentialPresentation;
|
|
11
|
+
presentWithRandom(userId: Aci, redemptionTime: number, serverParams: GenericServerPublicParams, callLinkParams: CallLinkSecretParams, random: Buffer): CallLinkAuthCredentialPresentation;
|
|
12
12
|
}
|
|
@@ -9,7 +9,6 @@ const ByteArray_1 = require("../internal/ByteArray");
|
|
|
9
9
|
const Constants_1 = require("../internal/Constants");
|
|
10
10
|
const Native = require("../../../Native");
|
|
11
11
|
const CallLinkAuthCredentialPresentation_1 = require("./CallLinkAuthCredentialPresentation");
|
|
12
|
-
const UUIDUtil_1 = require("../internal/UUIDUtil");
|
|
13
12
|
class CallLinkAuthCredential extends ByteArray_1.default {
|
|
14
13
|
constructor(contents) {
|
|
15
14
|
super(contents, Native.CallLinkAuthCredential_CheckValidContents);
|
|
@@ -19,7 +18,7 @@ class CallLinkAuthCredential extends ByteArray_1.default {
|
|
|
19
18
|
return this.presentWithRandom(userId, redemptionTime, serverParams, callLinkParams, random);
|
|
20
19
|
}
|
|
21
20
|
presentWithRandom(userId, redemptionTime, serverParams, callLinkParams, random) {
|
|
22
|
-
return new CallLinkAuthCredentialPresentation_1.default(Native.CallLinkAuthCredential_PresentDeterministic(this.contents,
|
|
21
|
+
return new CallLinkAuthCredentialPresentation_1.default(Native.CallLinkAuthCredential_PresentDeterministic(this.contents, userId.getServiceIdFixedWidthBinary(), redemptionTime, serverParams.contents, callLinkParams.contents, random));
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
24
|
exports.default = CallLinkAuthCredential;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import ByteArray from '../internal/ByteArray';
|
|
3
|
-
import { UUIDType } from '../internal/UUIDUtil';
|
|
4
3
|
import GenericServerSecretParams from '../GenericServerSecretParams';
|
|
5
4
|
import GenericServerPublicParams from '../GenericServerPublicParams';
|
|
6
5
|
import CallLinkAuthCredential from './CallLinkAuthCredential';
|
|
6
|
+
import { Aci } from '../../Address';
|
|
7
7
|
export default class CallLinkAuthCredentialResponse extends ByteArray {
|
|
8
8
|
private readonly __type?;
|
|
9
9
|
constructor(contents: Buffer);
|
|
10
|
-
static issueCredential(userId:
|
|
11
|
-
static issueCredentialWithRandom(userId:
|
|
12
|
-
receive(userId:
|
|
10
|
+
static issueCredential(userId: Aci, redemptionTime: number, params: GenericServerSecretParams): CallLinkAuthCredentialResponse;
|
|
11
|
+
static issueCredentialWithRandom(userId: Aci, redemptionTime: number, params: GenericServerSecretParams, random: Buffer): CallLinkAuthCredentialResponse;
|
|
12
|
+
receive(userId: Aci, redemptionTime: number, params: GenericServerPublicParams): CallLinkAuthCredential;
|
|
13
13
|
}
|
|
@@ -8,7 +8,6 @@ const crypto_1 = require("crypto");
|
|
|
8
8
|
const ByteArray_1 = require("../internal/ByteArray");
|
|
9
9
|
const Native = require("../../../Native");
|
|
10
10
|
const Constants_1 = require("../internal/Constants");
|
|
11
|
-
const UUIDUtil_1 = require("../internal/UUIDUtil");
|
|
12
11
|
const CallLinkAuthCredential_1 = require("./CallLinkAuthCredential");
|
|
13
12
|
class CallLinkAuthCredentialResponse extends ByteArray_1.default {
|
|
14
13
|
constructor(contents) {
|
|
@@ -19,10 +18,10 @@ class CallLinkAuthCredentialResponse extends ByteArray_1.default {
|
|
|
19
18
|
return this.issueCredentialWithRandom(userId, redemptionTime, params, random);
|
|
20
19
|
}
|
|
21
20
|
static issueCredentialWithRandom(userId, redemptionTime, params, random) {
|
|
22
|
-
return new CallLinkAuthCredentialResponse(Native.CallLinkAuthCredentialResponse_IssueDeterministic(
|
|
21
|
+
return new CallLinkAuthCredentialResponse(Native.CallLinkAuthCredentialResponse_IssueDeterministic(userId.getServiceIdFixedWidthBinary(), redemptionTime, params.contents, random));
|
|
23
22
|
}
|
|
24
23
|
receive(userId, redemptionTime, params) {
|
|
25
|
-
return new CallLinkAuthCredential_1.default(Native.CallLinkAuthCredentialResponse_Receive(this.contents,
|
|
24
|
+
return new CallLinkAuthCredential_1.default(Native.CallLinkAuthCredentialResponse_Receive(this.contents, userId.getServiceIdFixedWidthBinary(), redemptionTime, params.contents));
|
|
26
25
|
}
|
|
27
26
|
}
|
|
28
27
|
exports.default = CallLinkAuthCredentialResponse;
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
import ByteArray from '../internal/ByteArray';
|
|
3
3
|
import CallLinkPublicParams from './CallLinkPublicParams';
|
|
4
4
|
import UuidCiphertext from '../groups/UuidCiphertext';
|
|
5
|
-
import {
|
|
5
|
+
import { Aci } from '../../Address';
|
|
6
6
|
export default class CallLinkSecretParams extends ByteArray {
|
|
7
7
|
private readonly __type?;
|
|
8
8
|
static deriveFromRootKey(callLinkRootKey: Buffer): CallLinkSecretParams;
|
|
9
9
|
constructor(contents: Buffer);
|
|
10
10
|
getPublicParams(): CallLinkPublicParams;
|
|
11
|
-
decryptUserId(userId: UuidCiphertext):
|
|
11
|
+
decryptUserId(userId: UuidCiphertext): Aci;
|
|
12
12
|
}
|
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
const ByteArray_1 = require("../internal/ByteArray");
|
|
8
8
|
const Native = require("../../../Native");
|
|
9
9
|
const CallLinkPublicParams_1 = require("./CallLinkPublicParams");
|
|
10
|
-
const
|
|
10
|
+
const Address_1 = require("../../Address");
|
|
11
11
|
class CallLinkSecretParams extends ByteArray_1.default {
|
|
12
12
|
static deriveFromRootKey(callLinkRootKey) {
|
|
13
13
|
return new CallLinkSecretParams(Native.CallLinkSecretParams_DeriveFromRootKey(callLinkRootKey));
|
|
@@ -19,7 +19,7 @@ class CallLinkSecretParams extends ByteArray_1.default {
|
|
|
19
19
|
return new CallLinkPublicParams_1.default(Native.CallLinkSecretParams_GetPublicParams(this.contents));
|
|
20
20
|
}
|
|
21
21
|
decryptUserId(userId) {
|
|
22
|
-
return
|
|
22
|
+
return Address_1.Aci.parseFromServiceIdFixedWidthBinary(Native.CallLinkSecretParams_DecryptUserId(this.contents, userId.contents));
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
exports.default = CallLinkSecretParams;
|
|
@@ -3,10 +3,10 @@ import ByteArray from '../internal/ByteArray';
|
|
|
3
3
|
import CallLinkSecretParams from './CallLinkSecretParams';
|
|
4
4
|
import CreateCallLinkCredentialPresentation from './CreateCallLinkCredentialPresentation';
|
|
5
5
|
import GenericServerPublicParams from '../GenericServerPublicParams';
|
|
6
|
-
import {
|
|
6
|
+
import { Aci } from '../../Address';
|
|
7
7
|
export default class CreateCallLinkCredential extends ByteArray {
|
|
8
8
|
private readonly __type?;
|
|
9
9
|
constructor(contents: Buffer);
|
|
10
|
-
present(roomId: Buffer, userId:
|
|
11
|
-
presentWithRandom(roomId: Buffer, userId:
|
|
10
|
+
present(roomId: Buffer, userId: Aci, serverParams: GenericServerPublicParams, callLinkParams: CallLinkSecretParams): CreateCallLinkCredentialPresentation;
|
|
11
|
+
presentWithRandom(roomId: Buffer, userId: Aci, serverParams: GenericServerPublicParams, callLinkParams: CallLinkSecretParams, random: Buffer): CreateCallLinkCredentialPresentation;
|
|
12
12
|
}
|
|
@@ -9,7 +9,6 @@ const ByteArray_1 = require("../internal/ByteArray");
|
|
|
9
9
|
const Constants_1 = require("../internal/Constants");
|
|
10
10
|
const Native = require("../../../Native");
|
|
11
11
|
const CreateCallLinkCredentialPresentation_1 = require("./CreateCallLinkCredentialPresentation");
|
|
12
|
-
const UUIDUtil_1 = require("../internal/UUIDUtil");
|
|
13
12
|
class CreateCallLinkCredential extends ByteArray_1.default {
|
|
14
13
|
constructor(contents) {
|
|
15
14
|
super(contents, Native.CreateCallLinkCredential_CheckValidContents);
|
|
@@ -19,7 +18,7 @@ class CreateCallLinkCredential extends ByteArray_1.default {
|
|
|
19
18
|
return this.presentWithRandom(roomId, userId, serverParams, callLinkParams, random);
|
|
20
19
|
}
|
|
21
20
|
presentWithRandom(roomId, userId, serverParams, callLinkParams, random) {
|
|
22
|
-
return new CreateCallLinkCredentialPresentation_1.default(Native.CreateCallLinkCredential_PresentDeterministic(this.contents, roomId,
|
|
21
|
+
return new CreateCallLinkCredentialPresentation_1.default(Native.CreateCallLinkCredential_PresentDeterministic(this.contents, roomId, userId.getServiceIdFixedWidthBinary(), serverParams.contents, callLinkParams.contents, random));
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
24
|
exports.default = CreateCallLinkCredential;
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import ByteArray from '../internal/ByteArray';
|
|
3
3
|
import CreateCallLinkCredentialResponse from './CreateCallLinkCredentialResponse';
|
|
4
4
|
import GenericServerSecretParams from '../GenericServerSecretParams';
|
|
5
|
-
import {
|
|
5
|
+
import { Aci } from '../../Address';
|
|
6
6
|
export default class CreateCallLinkCredentialRequest extends ByteArray {
|
|
7
7
|
private readonly __type?;
|
|
8
8
|
constructor(contents: Buffer);
|
|
9
|
-
issueCredential(userId:
|
|
10
|
-
issueCredentialWithRandom(userId:
|
|
9
|
+
issueCredential(userId: Aci, timestamp: number, params: GenericServerSecretParams): CreateCallLinkCredentialResponse;
|
|
10
|
+
issueCredentialWithRandom(userId: Aci, timestamp: number, params: GenericServerSecretParams, random: Buffer): CreateCallLinkCredentialResponse;
|
|
11
11
|
}
|
|
@@ -9,7 +9,6 @@ const ByteArray_1 = require("../internal/ByteArray");
|
|
|
9
9
|
const Constants_1 = require("../internal/Constants");
|
|
10
10
|
const Native = require("../../../Native");
|
|
11
11
|
const CreateCallLinkCredentialResponse_1 = require("./CreateCallLinkCredentialResponse");
|
|
12
|
-
const UUIDUtil_1 = require("../internal/UUIDUtil");
|
|
13
12
|
class CreateCallLinkCredentialRequest extends ByteArray_1.default {
|
|
14
13
|
constructor(contents) {
|
|
15
14
|
super(contents, Native.CreateCallLinkCredentialRequest_CheckValidContents);
|
|
@@ -19,7 +18,7 @@ class CreateCallLinkCredentialRequest extends ByteArray_1.default {
|
|
|
19
18
|
return this.issueCredentialWithRandom(userId, timestamp, params, random);
|
|
20
19
|
}
|
|
21
20
|
issueCredentialWithRandom(userId, timestamp, params, random) {
|
|
22
|
-
return new CreateCallLinkCredentialResponse_1.default(Native.CreateCallLinkCredentialRequest_IssueDeterministic(this.contents,
|
|
21
|
+
return new CreateCallLinkCredentialResponse_1.default(Native.CreateCallLinkCredentialRequest_IssueDeterministic(this.contents, userId.getServiceIdFixedWidthBinary(), timestamp, params.contents, random));
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
24
|
exports.default = CreateCallLinkCredentialRequest;
|
|
@@ -4,12 +4,12 @@ import CreateCallLinkCredentialRequest from './CreateCallLinkCredentialRequest';
|
|
|
4
4
|
import CreateCallLinkCredentialResponse from './CreateCallLinkCredentialResponse';
|
|
5
5
|
import CreateCallLinkCredential from './CreateCallLinkCredential';
|
|
6
6
|
import GenericServerPublicParams from '../GenericServerPublicParams';
|
|
7
|
-
import {
|
|
7
|
+
import { Aci } from '../../Address';
|
|
8
8
|
export default class CreateCallLinkCredentialRequestContext extends ByteArray {
|
|
9
9
|
private readonly __type?;
|
|
10
10
|
constructor(contents: Buffer);
|
|
11
11
|
static forRoomId(roomId: Buffer): CreateCallLinkCredentialRequestContext;
|
|
12
12
|
static forRoomIdWithRandom(roomId: Buffer, random: Buffer): CreateCallLinkCredentialRequestContext;
|
|
13
13
|
getRequest(): CreateCallLinkCredentialRequest;
|
|
14
|
-
receive(response: CreateCallLinkCredentialResponse, userId:
|
|
14
|
+
receive(response: CreateCallLinkCredentialResponse, userId: Aci, params: GenericServerPublicParams): CreateCallLinkCredential;
|
|
15
15
|
}
|
|
@@ -10,7 +10,6 @@ const Constants_1 = require("../internal/Constants");
|
|
|
10
10
|
const Native = require("../../../Native");
|
|
11
11
|
const CreateCallLinkCredentialRequest_1 = require("./CreateCallLinkCredentialRequest");
|
|
12
12
|
const CreateCallLinkCredential_1 = require("./CreateCallLinkCredential");
|
|
13
|
-
const UUIDUtil_1 = require("../internal/UUIDUtil");
|
|
14
13
|
class CreateCallLinkCredentialRequestContext extends ByteArray_1.default {
|
|
15
14
|
constructor(contents) {
|
|
16
15
|
super(contents, Native.CreateCallLinkCredentialRequestContext_CheckValidContents);
|
|
@@ -26,7 +25,7 @@ class CreateCallLinkCredentialRequestContext extends ByteArray_1.default {
|
|
|
26
25
|
return new CreateCallLinkCredentialRequest_1.default(Native.CreateCallLinkCredentialRequestContext_GetRequest(this.contents));
|
|
27
26
|
}
|
|
28
27
|
receive(response, userId, params) {
|
|
29
|
-
return new CreateCallLinkCredential_1.default(Native.CreateCallLinkCredentialRequestContext_ReceiveResponse(this.contents, response.contents,
|
|
28
|
+
return new CreateCallLinkCredential_1.default(Native.CreateCallLinkCredentialRequestContext_ReceiveResponse(this.contents, response.contents, userId.getServiceIdFixedWidthBinary(), params.contents));
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
31
|
exports.default = CreateCallLinkCredentialRequestContext;
|
|
@@ -3,14 +3,14 @@ import UuidCiphertext from './UuidCiphertext';
|
|
|
3
3
|
import ProfileKeyCiphertext from './ProfileKeyCiphertext';
|
|
4
4
|
import ProfileKey from '../profiles/ProfileKey';
|
|
5
5
|
import GroupSecretParams from './GroupSecretParams';
|
|
6
|
-
import {
|
|
6
|
+
import { Aci, ServiceId } from '../../Address';
|
|
7
7
|
export default class ClientZkGroupCipher {
|
|
8
8
|
groupSecretParams: GroupSecretParams;
|
|
9
9
|
constructor(groupSecretParams: GroupSecretParams);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
encryptProfileKey(profileKey: ProfileKey,
|
|
13
|
-
decryptProfileKey(profileKeyCiphertext: ProfileKeyCiphertext,
|
|
10
|
+
encryptServiceId(serviceId: ServiceId): UuidCiphertext;
|
|
11
|
+
decryptServiceId(ciphertext: UuidCiphertext): ServiceId;
|
|
12
|
+
encryptProfileKey(profileKey: ProfileKey, userId: Aci): ProfileKeyCiphertext;
|
|
13
|
+
decryptProfileKey(profileKeyCiphertext: ProfileKeyCiphertext, userId: Aci): ProfileKey;
|
|
14
14
|
encryptBlob(plaintext: Buffer): Buffer;
|
|
15
15
|
encryptBlobWithRandom(random: Buffer, plaintext: Buffer): Buffer;
|
|
16
16
|
decryptBlob(blobCiphertext: Buffer): Buffer;
|
|
@@ -10,22 +10,22 @@ const Native = require("../../../Native");
|
|
|
10
10
|
const UuidCiphertext_1 = require("./UuidCiphertext");
|
|
11
11
|
const ProfileKeyCiphertext_1 = require("./ProfileKeyCiphertext");
|
|
12
12
|
const ProfileKey_1 = require("../profiles/ProfileKey");
|
|
13
|
-
const
|
|
13
|
+
const Address_1 = require("../../Address");
|
|
14
14
|
class ClientZkGroupCipher {
|
|
15
15
|
constructor(groupSecretParams) {
|
|
16
16
|
this.groupSecretParams = groupSecretParams;
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
return new UuidCiphertext_1.default(Native.
|
|
18
|
+
encryptServiceId(serviceId) {
|
|
19
|
+
return new UuidCiphertext_1.default(Native.GroupSecretParams_EncryptServiceId(this.groupSecretParams.getContents(), serviceId.getServiceIdFixedWidthBinary()));
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
return
|
|
21
|
+
decryptServiceId(ciphertext) {
|
|
22
|
+
return Address_1.ServiceId.parseFromServiceIdFixedWidthBinary(Native.GroupSecretParams_DecryptServiceId(this.groupSecretParams.getContents(), ciphertext.getContents()));
|
|
23
23
|
}
|
|
24
|
-
encryptProfileKey(profileKey,
|
|
25
|
-
return new ProfileKeyCiphertext_1.default(Native.GroupSecretParams_EncryptProfileKey(this.groupSecretParams.getContents(), profileKey.getContents(),
|
|
24
|
+
encryptProfileKey(profileKey, userId) {
|
|
25
|
+
return new ProfileKeyCiphertext_1.default(Native.GroupSecretParams_EncryptProfileKey(this.groupSecretParams.getContents(), profileKey.getContents(), userId.getServiceIdFixedWidthBinary()));
|
|
26
26
|
}
|
|
27
|
-
decryptProfileKey(profileKeyCiphertext,
|
|
28
|
-
return new ProfileKey_1.default(Native.GroupSecretParams_DecryptProfileKey(this.groupSecretParams.getContents(), profileKeyCiphertext.getContents(),
|
|
27
|
+
decryptProfileKey(profileKeyCiphertext, userId) {
|
|
28
|
+
return new ProfileKey_1.default(Native.GroupSecretParams_DecryptProfileKey(this.groupSecretParams.getContents(), profileKeyCiphertext.getContents(), userId.getServiceIdFixedWidthBinary()));
|
|
29
29
|
}
|
|
30
30
|
encryptBlob(plaintext) {
|
|
31
31
|
const random = (0, crypto_1.randomBytes)(Constants_1.RANDOM_LENGTH);
|
|
@@ -6,12 +6,12 @@ import ExpiringProfileKeyCredentialResponse from './ExpiringProfileKeyCredential
|
|
|
6
6
|
import ProfileKey from './ProfileKey';
|
|
7
7
|
import ProfileKeyCredentialPresentation from './ProfileKeyCredentialPresentation';
|
|
8
8
|
import ProfileKeyCredentialRequestContext from './ProfileKeyCredentialRequestContext';
|
|
9
|
-
import {
|
|
9
|
+
import { Aci } from '../../Address';
|
|
10
10
|
export default class ClientZkProfileOperations {
|
|
11
11
|
serverPublicParams: ServerPublicParams;
|
|
12
12
|
constructor(serverPublicParams: ServerPublicParams);
|
|
13
|
-
createProfileKeyCredentialRequestContext(
|
|
14
|
-
createProfileKeyCredentialRequestContextWithRandom(random: Buffer,
|
|
13
|
+
createProfileKeyCredentialRequestContext(userId: Aci, profileKey: ProfileKey): ProfileKeyCredentialRequestContext;
|
|
14
|
+
createProfileKeyCredentialRequestContextWithRandom(random: Buffer, userId: Aci, profileKey: ProfileKey): ProfileKeyCredentialRequestContext;
|
|
15
15
|
receiveExpiringProfileKeyCredential(profileKeyCredentialRequestContext: ProfileKeyCredentialRequestContext, profileKeyCredentialResponse: ExpiringProfileKeyCredentialResponse, now?: Date): ExpiringProfileKeyCredential;
|
|
16
16
|
createExpiringProfileKeyCredentialPresentation(groupSecretParams: GroupSecretParams, profileKeyCredential: ExpiringProfileKeyCredential): ProfileKeyCredentialPresentation;
|
|
17
17
|
createExpiringProfileKeyCredentialPresentationWithRandom(random: Buffer, groupSecretParams: GroupSecretParams, profileKeyCredential: ExpiringProfileKeyCredential): ProfileKeyCredentialPresentation;
|
|
@@ -10,17 +10,16 @@ const Native = require("../../../Native");
|
|
|
10
10
|
const ExpiringProfileKeyCredential_1 = require("./ExpiringProfileKeyCredential");
|
|
11
11
|
const ProfileKeyCredentialPresentation_1 = require("./ProfileKeyCredentialPresentation");
|
|
12
12
|
const ProfileKeyCredentialRequestContext_1 = require("./ProfileKeyCredentialRequestContext");
|
|
13
|
-
const UUIDUtil_1 = require("../internal/UUIDUtil");
|
|
14
13
|
class ClientZkProfileOperations {
|
|
15
14
|
constructor(serverPublicParams) {
|
|
16
15
|
this.serverPublicParams = serverPublicParams;
|
|
17
16
|
}
|
|
18
|
-
createProfileKeyCredentialRequestContext(
|
|
17
|
+
createProfileKeyCredentialRequestContext(userId, profileKey) {
|
|
19
18
|
const random = (0, crypto_1.randomBytes)(Constants_1.RANDOM_LENGTH);
|
|
20
|
-
return this.createProfileKeyCredentialRequestContextWithRandom(random,
|
|
19
|
+
return this.createProfileKeyCredentialRequestContextWithRandom(random, userId, profileKey);
|
|
21
20
|
}
|
|
22
|
-
createProfileKeyCredentialRequestContextWithRandom(random,
|
|
23
|
-
return new ProfileKeyCredentialRequestContext_1.default(Native.ServerPublicParams_CreateProfileKeyCredentialRequestContextDeterministic(this.serverPublicParams.getContents(), random,
|
|
21
|
+
createProfileKeyCredentialRequestContextWithRandom(random, userId, profileKey) {
|
|
22
|
+
return new ProfileKeyCredentialRequestContext_1.default(Native.ServerPublicParams_CreateProfileKeyCredentialRequestContextDeterministic(this.serverPublicParams.getContents(), random, userId.getServiceIdFixedWidthBinary(), profileKey.getContents()));
|
|
24
23
|
}
|
|
25
24
|
receiveExpiringProfileKeyCredential(profileKeyCredentialRequestContext, profileKeyCredentialResponse, now = new Date()) {
|
|
26
25
|
return new ExpiringProfileKeyCredential_1.default(Native.ServerPublicParams_ReceiveExpiringProfileKeyCredential(this.serverPublicParams.getContents(), profileKeyCredentialRequestContext.getContents(), profileKeyCredentialResponse.getContents(), Math.floor(now.getTime() / 1000)));
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
import ByteArray from '../internal/ByteArray';
|
|
3
3
|
import ProfileKeyCommitment from './ProfileKeyCommitment';
|
|
4
4
|
import ProfileKeyVersion from './ProfileKeyVersion';
|
|
5
|
-
import {
|
|
5
|
+
import { Aci } from '../../Address';
|
|
6
6
|
export default class ProfileKey extends ByteArray {
|
|
7
7
|
private readonly __type?;
|
|
8
8
|
static SIZE: number;
|
|
9
9
|
constructor(contents: Buffer);
|
|
10
|
-
getCommitment(
|
|
11
|
-
getProfileKeyVersion(
|
|
10
|
+
getCommitment(userId: Aci): ProfileKeyCommitment;
|
|
11
|
+
getProfileKeyVersion(userId: Aci): ProfileKeyVersion;
|
|
12
12
|
deriveAccessKey(): Buffer;
|
|
13
13
|
}
|
|
@@ -8,16 +8,15 @@ const ByteArray_1 = require("../internal/ByteArray");
|
|
|
8
8
|
const Native = require("../../../Native");
|
|
9
9
|
const ProfileKeyCommitment_1 = require("./ProfileKeyCommitment");
|
|
10
10
|
const ProfileKeyVersion_1 = require("./ProfileKeyVersion");
|
|
11
|
-
const UUIDUtil_1 = require("../internal/UUIDUtil");
|
|
12
11
|
class ProfileKey extends ByteArray_1.default {
|
|
13
12
|
constructor(contents) {
|
|
14
13
|
super(contents, ProfileKey.checkLength(ProfileKey.SIZE));
|
|
15
14
|
}
|
|
16
|
-
getCommitment(
|
|
17
|
-
return new ProfileKeyCommitment_1.default(Native.ProfileKey_GetCommitment(this.contents,
|
|
15
|
+
getCommitment(userId) {
|
|
16
|
+
return new ProfileKeyCommitment_1.default(Native.ProfileKey_GetCommitment(this.contents, userId.getServiceIdFixedWidthBinary()));
|
|
18
17
|
}
|
|
19
|
-
getProfileKeyVersion(
|
|
20
|
-
return new ProfileKeyVersion_1.default(Native.ProfileKey_GetProfileKeyVersion(this.contents,
|
|
18
|
+
getProfileKeyVersion(userId) {
|
|
19
|
+
return new ProfileKeyVersion_1.default(Native.ProfileKey_GetProfileKeyVersion(this.contents, userId.getServiceIdFixedWidthBinary()));
|
|
21
20
|
}
|
|
22
21
|
deriveAccessKey() {
|
|
23
22
|
return Native.ProfileKey_DeriveAccessKey(this.contents);
|
|
@@ -5,11 +5,11 @@ import ExpiringProfileKeyCredentialResponse from './ExpiringProfileKeyCredential
|
|
|
5
5
|
import ProfileKeyCommitment from './ProfileKeyCommitment';
|
|
6
6
|
import ProfileKeyCredentialPresentation from './ProfileKeyCredentialPresentation';
|
|
7
7
|
import ProfileKeyCredentialRequest from './ProfileKeyCredentialRequest';
|
|
8
|
-
import {
|
|
8
|
+
import { Aci } from '../../Address';
|
|
9
9
|
export default class ServerZkProfileOperations {
|
|
10
10
|
serverSecretParams: ServerSecretParams;
|
|
11
11
|
constructor(serverSecretParams: ServerSecretParams);
|
|
12
|
-
issueExpiringProfileKeyCredential(profileKeyCredentialRequest: ProfileKeyCredentialRequest,
|
|
13
|
-
issueExpiringProfileKeyCredentialWithRandom(random: Buffer, profileKeyCredentialRequest: ProfileKeyCredentialRequest,
|
|
12
|
+
issueExpiringProfileKeyCredential(profileKeyCredentialRequest: ProfileKeyCredentialRequest, userId: Aci, profileKeyCommitment: ProfileKeyCommitment, expirationInSeconds: number): ExpiringProfileKeyCredentialResponse;
|
|
13
|
+
issueExpiringProfileKeyCredentialWithRandom(random: Buffer, profileKeyCredentialRequest: ProfileKeyCredentialRequest, userId: Aci, profileKeyCommitment: ProfileKeyCommitment, expirationInSeconds: number): ExpiringProfileKeyCredentialResponse;
|
|
14
14
|
verifyProfileKeyCredentialPresentation(groupPublicParams: GroupPublicParams, profileKeyCredentialPresentation: ProfileKeyCredentialPresentation, now?: Date): void;
|
|
15
15
|
}
|
|
@@ -8,17 +8,16 @@ const crypto_1 = require("crypto");
|
|
|
8
8
|
const Native = require("../../../Native");
|
|
9
9
|
const Constants_1 = require("../internal/Constants");
|
|
10
10
|
const ExpiringProfileKeyCredentialResponse_1 = require("./ExpiringProfileKeyCredentialResponse");
|
|
11
|
-
const UUIDUtil_1 = require("../internal/UUIDUtil");
|
|
12
11
|
class ServerZkProfileOperations {
|
|
13
12
|
constructor(serverSecretParams) {
|
|
14
13
|
this.serverSecretParams = serverSecretParams;
|
|
15
14
|
}
|
|
16
|
-
issueExpiringProfileKeyCredential(profileKeyCredentialRequest,
|
|
15
|
+
issueExpiringProfileKeyCredential(profileKeyCredentialRequest, userId, profileKeyCommitment, expirationInSeconds) {
|
|
17
16
|
const random = (0, crypto_1.randomBytes)(Constants_1.RANDOM_LENGTH);
|
|
18
|
-
return this.issueExpiringProfileKeyCredentialWithRandom(random, profileKeyCredentialRequest,
|
|
17
|
+
return this.issueExpiringProfileKeyCredentialWithRandom(random, profileKeyCredentialRequest, userId, profileKeyCommitment, expirationInSeconds);
|
|
19
18
|
}
|
|
20
|
-
issueExpiringProfileKeyCredentialWithRandom(random, profileKeyCredentialRequest,
|
|
21
|
-
return new ExpiringProfileKeyCredentialResponse_1.default(Native.ServerSecretParams_IssueExpiringProfileKeyCredentialDeterministic(this.serverSecretParams.getContents(), random, profileKeyCredentialRequest.getContents(),
|
|
19
|
+
issueExpiringProfileKeyCredentialWithRandom(random, profileKeyCredentialRequest, userId, profileKeyCommitment, expirationInSeconds) {
|
|
20
|
+
return new ExpiringProfileKeyCredentialResponse_1.default(Native.ServerSecretParams_IssueExpiringProfileKeyCredentialDeterministic(this.serverSecretParams.getContents(), random, profileKeyCredentialRequest.getContents(), userId.getServiceIdFixedWidthBinary(), profileKeyCommitment.getContents(), expirationInSeconds));
|
|
22
21
|
}
|
|
23
22
|
verifyProfileKeyCredentialPresentation(groupPublicParams, profileKeyCredentialPresentation, now = new Date()) {
|
|
24
23
|
Native.ServerSecretParams_VerifyProfileKeyCredentialPresentation(this.serverSecretParams.getContents(), groupPublicParams.getContents(), profileKeyCredentialPresentation.getContents(), Math.floor(now.getTime() / 1000));
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
//
|
|
3
|
-
// Copyright 2020-2021 Signal Messenger, LLC.
|
|
4
|
-
// SPDX-License-Identifier: AGPL-3.0-only
|
|
5
|
-
//
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.fromUUID = exports.toUUID = void 0;
|
|
8
|
-
function toUUID(array) {
|
|
9
|
-
const hex = array.toString('hex');
|
|
10
|
-
return `${hex.substring(0, 8)}-${hex.substring(8, 12)}-${hex.substring(12, 16)}-${hex.substring(16, 20)}-${hex.substring(20)}`;
|
|
11
|
-
}
|
|
12
|
-
exports.toUUID = toUUID;
|
|
13
|
-
function fromUUID(uuid) {
|
|
14
|
-
let i = 0;
|
|
15
|
-
const array = Buffer.alloc(16);
|
|
16
|
-
uuid.replace(/[0-9A-F]{2}/gi, (oct) => {
|
|
17
|
-
array[i++] = parseInt(oct, 16);
|
|
18
|
-
return '';
|
|
19
|
-
});
|
|
20
|
-
return array;
|
|
21
|
-
}
|
|
22
|
-
exports.fromUUID = fromUUID;
|
|
23
|
-
//# sourceMappingURL=UUIDUtil.js.map
|