You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			45 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			TypeScript
		
	
			
		
		
	
	
			45 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			TypeScript
		
	
| import { ContentMessage } from './ContentMessage';
 | |
| import { SignalService } from '../../../../protobuf';
 | |
| import { MessageParams } from '../Message';
 | |
| 
 | |
| export interface PreKeyBundleType {
 | |
|   identityKey: Uint8Array;
 | |
|   deviceId: number;
 | |
|   preKeyId: number;
 | |
|   signedKeyId: number;
 | |
|   preKey: Uint8Array;
 | |
|   signedKey: Uint8Array;
 | |
|   signature: Uint8Array;
 | |
| }
 | |
| 
 | |
| interface SessionRequestParams extends MessageParams {
 | |
|   preKeyBundle: PreKeyBundleType;
 | |
| }
 | |
| 
 | |
| export class SessionRequestMessage extends ContentMessage {
 | |
|   private readonly preKeyBundle: PreKeyBundleType;
 | |
| 
 | |
|   constructor(params: SessionRequestParams) {
 | |
|     super({ timestamp: params.timestamp, identifier: params.identifier });
 | |
|     this.preKeyBundle = params.preKeyBundle;
 | |
|   }
 | |
| 
 | |
|   public ttl(): number {
 | |
|     return 4 * 24 * 60 * 60 * 1000; // 4 days
 | |
|   }
 | |
| 
 | |
|   protected getPreKeyBundleMessage(): SignalService.PreKeyBundleMessage {
 | |
|     return new SignalService.PreKeyBundleMessage(this.preKeyBundle);
 | |
|   }
 | |
| 
 | |
|   protected contentProto(): SignalService.Content {
 | |
|     const nullMessage = new SignalService.NullMessage({});
 | |
|     const preKeyBundleMessage = this.getPreKeyBundleMessage();
 | |
| 
 | |
|     return new SignalService.Content({
 | |
|       nullMessage,
 | |
|       preKeyBundleMessage,
 | |
|     });
 | |
|   }
 | |
| }
 |