Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add request client #342

Merged
merged 11 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/status-js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,10 @@ export { createClient } from './client/client'
export type { Community } from './client/community/community'
export type { Reaction, Reactions } from './client/community/get-reactions'
export type { Member } from './client/member'
export type { ChannelInfo } from './request-client/map-channel'
export type { CommunityInfo } from './request-client/map-community'
export type { UserInfo } from './request-client/map-user'
export type { RequestClient } from './request-client/request-client'
export { createRequestClient } from './request-client/request-client'
export { deserializePublicKey } from './utils/deserialize-public-key'
export { publicKeyToEmojiHash } from './utils/public-key-to-emoji-hash'
11 changes: 10 additions & 1 deletion packages/status-js/src/protos/protocol-message.proto
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,16 @@ message HRHeader {
// Community message number for this key_id
uint32 seq_no = 2;
// Community ID
string group_id = 3;
bytes group_id = 3;
}

message HRKeys {
repeated HRKey keys = 1;
}

message HRKey {
uint32 key_id = 1;
bytes key = 2;
}

// Direct message value
Expand Down
86 changes: 83 additions & 3 deletions packages/status-js/src/protos/protocol-message_pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,9 @@ export class HRHeader extends Message<HRHeader> {
/**
* Community ID
*
* @generated from field: string group_id = 3;
* @generated from field: bytes group_id = 3;
*/
groupId = "";
groupId = new Uint8Array(0);

constructor(data?: PartialMessage<HRHeader>) {
super();
Expand All @@ -353,7 +353,7 @@ export class HRHeader extends Message<HRHeader> {
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "key_id", kind: "scalar", T: 13 /* ScalarType.UINT32 */ },
{ no: 2, name: "seq_no", kind: "scalar", T: 13 /* ScalarType.UINT32 */ },
{ no: 3, name: "group_id", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 3, name: "group_id", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
]);

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): HRHeader {
Expand All @@ -373,6 +373,86 @@ export class HRHeader extends Message<HRHeader> {
}
}

/**
* @generated from message HRKeys
*/
export class HRKeys extends Message<HRKeys> {
/**
* @generated from field: repeated HRKey keys = 1;
*/
keys: HRKey[] = [];

constructor(data?: PartialMessage<HRKeys>) {
super();
proto3.util.initPartial(data, this);
}

static readonly runtime = proto3;
static readonly typeName = "HRKeys";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "keys", kind: "message", T: HRKey, repeated: true },
]);

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): HRKeys {
return new HRKeys().fromBinary(bytes, options);
}

static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): HRKeys {
return new HRKeys().fromJson(jsonValue, options);
}

static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): HRKeys {
return new HRKeys().fromJsonString(jsonString, options);
}

static equals(a: HRKeys | PlainMessage<HRKeys> | undefined, b: HRKeys | PlainMessage<HRKeys> | undefined): boolean {
return proto3.util.equals(HRKeys, a, b);
}
}

/**
* @generated from message HRKey
*/
export class HRKey extends Message<HRKey> {
/**
* @generated from field: uint32 key_id = 1;
*/
keyId = 0;

/**
* @generated from field: bytes key = 2;
*/
key = new Uint8Array(0);

constructor(data?: PartialMessage<HRKey>) {
super();
proto3.util.initPartial(data, this);
}

static readonly runtime = proto3;
static readonly typeName = "HRKey";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "key_id", kind: "scalar", T: 13 /* ScalarType.UINT32 */ },
{ no: 2, name: "key", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
]);

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): HRKey {
return new HRKey().fromBinary(bytes, options);
}

static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): HRKey {
return new HRKey().fromJson(jsonValue, options);
}

static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): HRKey {
return new HRKey().fromJsonString(jsonString, options);
}

static equals(a: HRKey | PlainMessage<HRKey> | undefined, b: HRKey | PlainMessage<HRKey> | undefined): boolean {
return proto3.util.equals(HRKey, a, b);
}
}

/**
* Direct message value
*
Expand Down
103 changes: 103 additions & 0 deletions packages/status-js/src/protos/push-notifications.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
syntax = "proto3";

import "chat-identity.proto";

message PushNotificationRegistration {
enum TokenType {
UNKNOWN_TOKEN_TYPE = 0;
APN_TOKEN = 1;
FIREBASE_TOKEN = 2;
}
TokenType token_type = 1;
string device_token = 2;
string installation_id = 3;
string access_token = 4;
bool enabled = 5;
uint64 version = 6;
repeated bytes allowed_key_list = 7;
repeated bytes blocked_chat_list = 8;
bool unregister = 9;
bytes grant = 10;
bool allow_from_contacts_only = 11;
string apn_topic = 12;
bool block_mentions = 13;
repeated bytes allowed_mentions_chat_list = 14;
}

message PushNotificationRegistrationResponse {
bool success = 1;
ErrorType error = 2;
bytes request_id = 3;

enum ErrorType {
UNKNOWN_ERROR_TYPE = 0;
MALFORMED_MESSAGE = 1;
VERSION_MISMATCH = 2;
UNSUPPORTED_TOKEN_TYPE = 3;
INTERNAL_ERROR = 4;
}
}

message ContactCodeAdvertisement {
repeated PushNotificationQueryInfo push_notification_info = 1;
ChatIdentity chat_identity = 2;
}

message PushNotificationQuery {
repeated bytes public_keys = 1;
}

message PushNotificationQueryInfo {
string access_token = 1;
string installation_id = 2;
bytes public_key = 3;
repeated bytes allowed_key_list = 4;
bytes grant = 5;
uint64 version = 6;
bytes server_public_key = 7;
}

message PushNotificationQueryResponse {
repeated PushNotificationQueryInfo info = 1;
bytes message_id = 2;
bool success = 3;
}

message PushNotification {
string access_token = 1;
bytes chat_id = 2;
bytes public_key = 3;
string installation_id = 4;
bytes message = 5;
PushNotificationType type = 6;
enum PushNotificationType {
UNKNOWN_PUSH_NOTIFICATION_TYPE = 0;
MESSAGE = 1;
MENTION = 2;
REQUEST_TO_JOIN_COMMUNITY = 3;
}
bytes author = 7;
}

message PushNotificationRequest {
repeated PushNotification requests = 1;
bytes message_id = 2;
}

message PushNotificationReport {
bool success = 1;
ErrorType error = 2;
enum ErrorType {
UNKNOWN_ERROR_TYPE = 0;
WRONG_TOKEN = 1;
INTERNAL_ERROR = 2;
NOT_REGISTERED = 3;
}
bytes public_key = 3;
string installation_id = 4;
}

message PushNotificationResponse {
bytes message_id = 1;
repeated PushNotificationReport reports = 2;
}
Loading