@fatehan/tsrp 1.2.1 → 1.3.2

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/dist/api.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type HeaderProvider = () => Promise<HeadersInit> | HeadersInit;
1
+ import { HeaderProvider } from ".";
2
2
  export declare class ApiService {
3
3
  private readonly url;
4
4
  private readonly namespace;
package/dist/api.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC;AAEtE,qBAAa,UAAU;IACnB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA6C;IACvE,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAiB;gBAEvC,GAAG,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc;YAKzC,KAAK;IA+BN,OAAO,CAAC,OAAO,EAAE,OAAO,wBAAwB,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,wBAAwB,EAAE,UAAU,CAAC;IAKlH,WAAW,CAAC,OAAO,EAAE,OAAO,wBAAwB,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,wBAAwB,EAAE,cAAc,CAAC;IAK9H,SAAS,CAAC,OAAO,EAAE,OAAO,wBAAwB,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,wBAAwB,EAAE,iBAAiB,CAAC;IAKlI,WAAW,CAAC,OAAO,EAAE,OAAO,wBAAwB,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,wBAAwB,EAAE,cAAc,CAAC;IAK9H,SAAS,CAAC,OAAO,EAAE,OAAO,wBAAwB,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,wBAAwB,EAAE,YAAY,CAAC;CAIxI"}
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,GAAG,CAAC;AAEnC,qBAAa,UAAU;IACnB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA6C;IACvE,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAiB;gBAEvC,GAAG,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc;YAKzC,KAAK;IA+BN,OAAO,CAAC,OAAO,EAAE,OAAO,wBAAwB,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,wBAAwB,EAAE,UAAU,CAAC;IAKlH,WAAW,CAAC,OAAO,EAAE,OAAO,wBAAwB,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,wBAAwB,EAAE,cAAc,CAAC;IAK9H,SAAS,CAAC,OAAO,EAAE,OAAO,wBAAwB,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,wBAAwB,EAAE,iBAAiB,CAAC;IAKlI,WAAW,CAAC,OAAO,EAAE,OAAO,wBAAwB,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,wBAAwB,EAAE,cAAc,CAAC;IAK9H,SAAS,CAAC,OAAO,EAAE,OAAO,wBAAwB,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,wBAAwB,EAAE,YAAY,CAAC;CAIxI"}
package/dist/auth.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { HeaderProvider } from ".";
2
+ export declare class AuthService {
3
+ private readonly url;
4
+ private readonly namespace;
5
+ private readonly getDynamicHeaders;
6
+ constructor(url: string, headerProvider: HeaderProvider);
7
+ private _call;
8
+ AuthRequest(request: import("./fatehan/identities/authentication").AuthRequest): Promise<import("./fatehan/identities/authentication").AuthResponse>;
9
+ OtpCode(request: import("./fatehan/identities/authentication").OtpCodeRequest): Promise<import("./fatehan/identities/authentication").OtpCodeResponse>;
10
+ }
11
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,GAAG,CAAC;AAEnC,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAgD;IAC1E,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAiB;gBAEvC,GAAG,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc;YAKzC,KAAK;IAgCN,WAAW,CACtB,OAAO,EAAE,OAAO,qCAAqC,EAAE,WAAW,GACjE,OAAO,CAAC,OAAO,qCAAqC,EAAE,YAAY,CAAC;IAOzD,OAAO,CAClB,OAAO,EAAE,OAAO,qCAAqC,EAAE,cAAc,GACpE,OAAO,CAAC,OAAO,qCAAqC,EAAE,eAAe,CAAC;CAM1E"}
package/dist/auth.js ADDED
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.AuthService = void 0;
37
+ class AuthService {
38
+ constructor(url, headerProvider) {
39
+ this.namespace = "com.fatehan.identities.AuthService";
40
+ this.url = url;
41
+ this.getDynamicHeaders = headerProvider;
42
+ }
43
+ async _call(methodName, request, encoder, decoder) {
44
+ const dynamicHeaders = await this.getDynamicHeaders();
45
+ const headers = {
46
+ "Content-Type": "application/octet-stream",
47
+ Accept: "application/octet-stream",
48
+ ...dynamicHeaders,
49
+ };
50
+ const response = await fetch(`${this.url}/${this.namespace}/${methodName}`, {
51
+ method: "POST",
52
+ headers: headers,
53
+ body: new Uint8Array(encoder.encode(request).finish()),
54
+ });
55
+ if (response.ok) {
56
+ const buffer = await response.arrayBuffer();
57
+ return decoder.decode(new Uint8Array(buffer));
58
+ }
59
+ else {
60
+ const errorText = await response.text();
61
+ throw new Error(`API Error (${response.status}): ${errorText}`);
62
+ }
63
+ }
64
+ async AuthRequest(request) {
65
+ const { AuthRequest, AuthResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/identities/authentication")));
66
+ return this._call("MeIndex", request, AuthRequest, AuthResponse);
67
+ }
68
+ async OtpCode(request) {
69
+ const { OtpCodeRequest, OtpCodeResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/identities/authentication")));
70
+ return this._call("MeIndex", request, OtpCodeRequest, OtpCodeResponse);
71
+ }
72
+ }
73
+ exports.AuthService = AuthService;
@@ -1,6 +1,5 @@
1
1
  import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
2
2
  import Long from "long";
3
- import { User } from "./identities";
4
3
  export declare const protobufPackage = "com.fatehan.identities";
5
4
  export interface OtpCodeRequest {
6
5
  phone: Long;
@@ -8,9 +7,10 @@ export interface OtpCodeRequest {
8
7
  export interface OtpCodeResponse {
9
8
  message: string;
10
9
  passwordRequired: boolean;
10
+ status: number;
11
11
  }
12
12
  export interface AuthResponse {
13
- user?: User | undefined;
13
+ identity?: Identity | undefined;
14
14
  token: string;
15
15
  }
16
16
  export interface AuthRequest {
@@ -31,11 +31,49 @@ export interface OtpAuth {
31
31
  phone: Long;
32
32
  code: number;
33
33
  password?: string | undefined;
34
+ deviceType: string;
34
35
  }
35
36
  export interface GoogleAuth {
36
37
  }
37
38
  export interface TelegramAuth {
38
39
  }
40
+ export interface Identity {
41
+ id: Long;
42
+ phone: Long;
43
+ createdAt?: Date | undefined;
44
+ updatedAt?: Date | undefined;
45
+ encryptedPhone: Uint8Array;
46
+ phoneHash: Uint8Array;
47
+ }
48
+ export interface AccessToken {
49
+ id: Long;
50
+ identityId: Long;
51
+ domain: string;
52
+ token: Long;
53
+ phoneHash: Uint8Array;
54
+ ipAddress: string;
55
+ userAgent: string;
56
+ deviceType: string;
57
+ expiresAt?: Date | undefined;
58
+ createdAt?: Date | undefined;
59
+ }
60
+ export interface OtpRequest {
61
+ id: Long;
62
+ phoneHash: Uint8Array;
63
+ ipAddress: string;
64
+ domain: string;
65
+ token: Uint8Array;
66
+ expiresAt?: Date | undefined;
67
+ createdAt?: Date | undefined;
68
+ }
69
+ export interface Credential {
70
+ id: Long;
71
+ identityId: Long;
72
+ expires: Long;
73
+ created: Long;
74
+ token: Long;
75
+ domain: string;
76
+ }
39
77
  export declare const OtpCodeRequest: MessageFns<OtpCodeRequest>;
40
78
  export declare const OtpCodeResponse: MessageFns<OtpCodeResponse>;
41
79
  export declare const AuthResponse: MessageFns<AuthResponse>;
@@ -45,6 +83,10 @@ export declare const QrCodeAuth: MessageFns<QrCodeAuth>;
45
83
  export declare const OtpAuth: MessageFns<OtpAuth>;
46
84
  export declare const GoogleAuth: MessageFns<GoogleAuth>;
47
85
  export declare const TelegramAuth: MessageFns<TelegramAuth>;
86
+ export declare const Identity: MessageFns<Identity>;
87
+ export declare const AccessToken: MessageFns<AccessToken>;
88
+ export declare const OtpRequest: MessageFns<OtpRequest>;
89
+ export declare const Credential: MessageFns<Credential>;
48
90
  type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
49
91
  export type DeepPartial<T> = T extends Builtin ? T : T extends Long ? string | number | Long : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
50
92
  [K in keyof T]?: DeepPartial<T[K]>;
@@ -1 +1 @@
1
- {"version":3,"file":"authentication.d.ts","sourceRoot":"","sources":["../../../src/fatehan/identities/authentication.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,eAAO,MAAM,eAAe,2BAA2B,CAAC;AAExD,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,IAAI,CAAC;CACb;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAC1B,YAAY,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IACxC,UAAU,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IACpC,UAAU,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IACpC,YAAY,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IACxC,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;C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
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.TelegramAuth = exports.GoogleAuth = exports.OtpAuth = exports.QrCodeAuth = exports.PasswordAuth = exports.AuthRequest = exports.AuthResponse = exports.OtpCodeResponse = exports.OtpCodeRequest = exports.protobufPackage = void 0;
11
+ exports.Credential = exports.OtpRequest = exports.AccessToken = exports.Identity = exports.TelegramAuth = exports.GoogleAuth = exports.OtpAuth = exports.QrCodeAuth = exports.PasswordAuth = exports.AuthRequest = exports.AuthResponse = exports.OtpCodeResponse = exports.OtpCodeRequest = exports.protobufPackage = void 0;
12
12
  /* eslint-disable */
13
13
  const wire_1 = require("@bufbuild/protobuf/wire");
14
14
  const long_1 = __importDefault(require("long"));
15
- const identities_1 = require("./identities");
15
+ const timestamp_1 = require("../google/protobuf/timestamp");
16
16
  exports.protobufPackage = "com.fatehan.identities";
17
17
  function createBaseOtpCodeRequest() {
18
18
  return { phone: long_1.default.UZERO };
@@ -66,7 +66,7 @@ exports.OtpCodeRequest = {
66
66
  },
67
67
  };
68
68
  function createBaseOtpCodeResponse() {
69
- return { message: "", passwordRequired: false };
69
+ return { message: "", passwordRequired: false, status: 0 };
70
70
  }
71
71
  exports.OtpCodeResponse = {
72
72
  encode(message, writer = new wire_1.BinaryWriter()) {
@@ -76,6 +76,9 @@ exports.OtpCodeResponse = {
76
76
  if (message.passwordRequired !== false) {
77
77
  writer.uint32(16).bool(message.passwordRequired);
78
78
  }
79
+ if (message.status !== 0) {
80
+ writer.uint32(24).uint32(message.status);
81
+ }
79
82
  return writer;
80
83
  },
81
84
  decode(input, length) {
@@ -99,6 +102,13 @@ exports.OtpCodeResponse = {
99
102
  message.passwordRequired = reader.bool();
100
103
  continue;
101
104
  }
105
+ case 3: {
106
+ if (tag !== 24) {
107
+ break;
108
+ }
109
+ message.status = reader.uint32();
110
+ continue;
111
+ }
102
112
  }
103
113
  if ((tag & 7) === 4 || tag === 0) {
104
114
  break;
@@ -111,6 +121,7 @@ exports.OtpCodeResponse = {
111
121
  return {
112
122
  message: isSet(object.message) ? globalThis.String(object.message) : "",
113
123
  passwordRequired: isSet(object.password_required) ? globalThis.Boolean(object.password_required) : false,
124
+ status: isSet(object.status) ? globalThis.Number(object.status) : 0,
114
125
  };
115
126
  },
116
127
  toJSON(message) {
@@ -121,26 +132,30 @@ exports.OtpCodeResponse = {
121
132
  if (message.passwordRequired !== false) {
122
133
  obj.password_required = message.passwordRequired;
123
134
  }
135
+ if (message.status !== 0) {
136
+ obj.status = Math.round(message.status);
137
+ }
124
138
  return obj;
125
139
  },
126
140
  create(base) {
127
141
  return exports.OtpCodeResponse.fromPartial(base !== null && base !== void 0 ? base : {});
128
142
  },
129
143
  fromPartial(object) {
130
- var _a, _b;
144
+ var _a, _b, _c;
131
145
  const message = createBaseOtpCodeResponse();
132
146
  message.message = (_a = object.message) !== null && _a !== void 0 ? _a : "";
133
147
  message.passwordRequired = (_b = object.passwordRequired) !== null && _b !== void 0 ? _b : false;
148
+ message.status = (_c = object.status) !== null && _c !== void 0 ? _c : 0;
134
149
  return message;
135
150
  },
136
151
  };
137
152
  function createBaseAuthResponse() {
138
- return { user: undefined, token: "" };
153
+ return { identity: undefined, token: "" };
139
154
  }
140
155
  exports.AuthResponse = {
141
156
  encode(message, writer = new wire_1.BinaryWriter()) {
142
- if (message.user !== undefined) {
143
- identities_1.User.encode(message.user, writer.uint32(10).fork()).join();
157
+ if (message.identity !== undefined) {
158
+ exports.Identity.encode(message.identity, writer.uint32(10).fork()).join();
144
159
  }
145
160
  if (message.token !== "") {
146
161
  writer.uint32(18).string(message.token);
@@ -158,7 +173,7 @@ exports.AuthResponse = {
158
173
  if (tag !== 10) {
159
174
  break;
160
175
  }
161
- message.user = identities_1.User.decode(reader, reader.uint32());
176
+ message.identity = exports.Identity.decode(reader, reader.uint32());
162
177
  continue;
163
178
  }
164
179
  case 2: {
@@ -178,14 +193,14 @@ exports.AuthResponse = {
178
193
  },
179
194
  fromJSON(object) {
180
195
  return {
181
- user: isSet(object.user) ? identities_1.User.fromJSON(object.user) : undefined,
196
+ identity: isSet(object.identity) ? exports.Identity.fromJSON(object.identity) : undefined,
182
197
  token: isSet(object.token) ? globalThis.String(object.token) : "",
183
198
  };
184
199
  },
185
200
  toJSON(message) {
186
201
  const obj = {};
187
- if (message.user !== undefined) {
188
- obj.user = identities_1.User.toJSON(message.user);
202
+ if (message.identity !== undefined) {
203
+ obj.identity = exports.Identity.toJSON(message.identity);
189
204
  }
190
205
  if (message.token !== "") {
191
206
  obj.token = message.token;
@@ -198,7 +213,9 @@ exports.AuthResponse = {
198
213
  fromPartial(object) {
199
214
  var _a;
200
215
  const message = createBaseAuthResponse();
201
- message.user = (object.user !== undefined && object.user !== null) ? identities_1.User.fromPartial(object.user) : undefined;
216
+ message.identity = (object.identity !== undefined && object.identity !== null)
217
+ ? exports.Identity.fromPartial(object.identity)
218
+ : undefined;
202
219
  message.token = (_a = object.token) !== null && _a !== void 0 ? _a : "";
203
220
  return message;
204
221
  },
@@ -454,7 +471,7 @@ exports.QrCodeAuth = {
454
471
  },
455
472
  };
456
473
  function createBaseOtpAuth() {
457
- return { phone: long_1.default.UZERO, code: 0, password: undefined };
474
+ return { phone: long_1.default.UZERO, code: 0, password: undefined, deviceType: "" };
458
475
  }
459
476
  exports.OtpAuth = {
460
477
  encode(message, writer = new wire_1.BinaryWriter()) {
@@ -467,6 +484,9 @@ exports.OtpAuth = {
467
484
  if (message.password !== undefined) {
468
485
  writer.uint32(26).string(message.password);
469
486
  }
487
+ if (message.deviceType !== "") {
488
+ writer.uint32(34).string(message.deviceType);
489
+ }
470
490
  return writer;
471
491
  },
472
492
  decode(input, length) {
@@ -497,6 +517,13 @@ exports.OtpAuth = {
497
517
  message.password = reader.string();
498
518
  continue;
499
519
  }
520
+ case 4: {
521
+ if (tag !== 34) {
522
+ break;
523
+ }
524
+ message.deviceType = reader.string();
525
+ continue;
526
+ }
500
527
  }
501
528
  if ((tag & 7) === 4 || tag === 0) {
502
529
  break;
@@ -510,6 +537,7 @@ exports.OtpAuth = {
510
537
  phone: isSet(object.phone) ? long_1.default.fromValue(object.phone) : long_1.default.UZERO,
511
538
  code: isSet(object.code) ? globalThis.Number(object.code) : 0,
512
539
  password: isSet(object.password) ? globalThis.String(object.password) : undefined,
540
+ deviceType: isSet(object.device_type) ? globalThis.String(object.device_type) : "",
513
541
  };
514
542
  },
515
543
  toJSON(message) {
@@ -523,17 +551,21 @@ exports.OtpAuth = {
523
551
  if (message.password !== undefined) {
524
552
  obj.password = message.password;
525
553
  }
554
+ if (message.deviceType !== "") {
555
+ obj.device_type = message.deviceType;
556
+ }
526
557
  return obj;
527
558
  },
528
559
  create(base) {
529
560
  return exports.OtpAuth.fromPartial(base !== null && base !== void 0 ? base : {});
530
561
  },
531
562
  fromPartial(object) {
532
- var _a, _b;
563
+ var _a, _b, _c;
533
564
  const message = createBaseOtpAuth();
534
565
  message.phone = (object.phone !== undefined && object.phone !== null) ? long_1.default.fromValue(object.phone) : long_1.default.UZERO;
535
566
  message.code = (_a = object.code) !== null && _a !== void 0 ? _a : 0;
536
567
  message.password = (_b = object.password) !== null && _b !== void 0 ? _b : undefined;
568
+ message.deviceType = (_c = object.deviceType) !== null && _c !== void 0 ? _c : "";
537
569
  return message;
538
570
  },
539
571
  };
@@ -611,6 +643,687 @@ exports.TelegramAuth = {
611
643
  return message;
612
644
  },
613
645
  };
646
+ function createBaseIdentity() {
647
+ return {
648
+ id: long_1.default.UZERO,
649
+ phone: long_1.default.UZERO,
650
+ createdAt: undefined,
651
+ updatedAt: undefined,
652
+ encryptedPhone: new Uint8Array(0),
653
+ phoneHash: new Uint8Array(0),
654
+ };
655
+ }
656
+ exports.Identity = {
657
+ encode(message, writer = new wire_1.BinaryWriter()) {
658
+ if (!message.id.equals(long_1.default.UZERO)) {
659
+ writer.uint32(8).uint64(message.id.toString());
660
+ }
661
+ if (!message.phone.equals(long_1.default.UZERO)) {
662
+ writer.uint32(16).uint64(message.phone.toString());
663
+ }
664
+ if (message.createdAt !== undefined) {
665
+ timestamp_1.Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(26).fork()).join();
666
+ }
667
+ if (message.updatedAt !== undefined) {
668
+ timestamp_1.Timestamp.encode(toTimestamp(message.updatedAt), writer.uint32(34).fork()).join();
669
+ }
670
+ if (message.encryptedPhone.length !== 0) {
671
+ writer.uint32(42).bytes(message.encryptedPhone);
672
+ }
673
+ if (message.phoneHash.length !== 0) {
674
+ writer.uint32(50).bytes(message.phoneHash);
675
+ }
676
+ return writer;
677
+ },
678
+ decode(input, length) {
679
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
680
+ const end = length === undefined ? reader.len : reader.pos + length;
681
+ const message = createBaseIdentity();
682
+ while (reader.pos < end) {
683
+ const tag = reader.uint32();
684
+ switch (tag >>> 3) {
685
+ case 1: {
686
+ if (tag !== 8) {
687
+ break;
688
+ }
689
+ message.id = long_1.default.fromString(reader.uint64().toString(), true);
690
+ continue;
691
+ }
692
+ case 2: {
693
+ if (tag !== 16) {
694
+ break;
695
+ }
696
+ message.phone = long_1.default.fromString(reader.uint64().toString(), true);
697
+ continue;
698
+ }
699
+ case 3: {
700
+ if (tag !== 26) {
701
+ break;
702
+ }
703
+ message.createdAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
704
+ continue;
705
+ }
706
+ case 4: {
707
+ if (tag !== 34) {
708
+ break;
709
+ }
710
+ message.updatedAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
711
+ continue;
712
+ }
713
+ case 5: {
714
+ if (tag !== 42) {
715
+ break;
716
+ }
717
+ message.encryptedPhone = reader.bytes();
718
+ continue;
719
+ }
720
+ case 6: {
721
+ if (tag !== 50) {
722
+ break;
723
+ }
724
+ message.phoneHash = reader.bytes();
725
+ continue;
726
+ }
727
+ }
728
+ if ((tag & 7) === 4 || tag === 0) {
729
+ break;
730
+ }
731
+ reader.skip(tag & 7);
732
+ }
733
+ return message;
734
+ },
735
+ fromJSON(object) {
736
+ return {
737
+ id: isSet(object.id) ? long_1.default.fromValue(object.id) : long_1.default.UZERO,
738
+ phone: isSet(object.phone) ? long_1.default.fromValue(object.phone) : long_1.default.UZERO,
739
+ createdAt: isSet(object.created_at) ? fromJsonTimestamp(object.created_at) : undefined,
740
+ updatedAt: isSet(object.updated_at) ? fromJsonTimestamp(object.updated_at) : undefined,
741
+ encryptedPhone: isSet(object.encrypted_phone) ? bytesFromBase64(object.encrypted_phone) : new Uint8Array(0),
742
+ phoneHash: isSet(object.phone_hash) ? bytesFromBase64(object.phone_hash) : new Uint8Array(0),
743
+ };
744
+ },
745
+ toJSON(message) {
746
+ const obj = {};
747
+ if (!message.id.equals(long_1.default.UZERO)) {
748
+ obj.id = (message.id || long_1.default.UZERO).toString();
749
+ }
750
+ if (!message.phone.equals(long_1.default.UZERO)) {
751
+ obj.phone = (message.phone || long_1.default.UZERO).toString();
752
+ }
753
+ if (message.createdAt !== undefined) {
754
+ obj.created_at = message.createdAt.toISOString();
755
+ }
756
+ if (message.updatedAt !== undefined) {
757
+ obj.updated_at = message.updatedAt.toISOString();
758
+ }
759
+ if (message.encryptedPhone.length !== 0) {
760
+ obj.encrypted_phone = base64FromBytes(message.encryptedPhone);
761
+ }
762
+ if (message.phoneHash.length !== 0) {
763
+ obj.phone_hash = base64FromBytes(message.phoneHash);
764
+ }
765
+ return obj;
766
+ },
767
+ create(base) {
768
+ return exports.Identity.fromPartial(base !== null && base !== void 0 ? base : {});
769
+ },
770
+ fromPartial(object) {
771
+ var _a, _b, _c, _d;
772
+ const message = createBaseIdentity();
773
+ message.id = (object.id !== undefined && object.id !== null) ? long_1.default.fromValue(object.id) : long_1.default.UZERO;
774
+ message.phone = (object.phone !== undefined && object.phone !== null) ? long_1.default.fromValue(object.phone) : long_1.default.UZERO;
775
+ message.createdAt = (_a = object.createdAt) !== null && _a !== void 0 ? _a : undefined;
776
+ message.updatedAt = (_b = object.updatedAt) !== null && _b !== void 0 ? _b : undefined;
777
+ message.encryptedPhone = (_c = object.encryptedPhone) !== null && _c !== void 0 ? _c : new Uint8Array(0);
778
+ message.phoneHash = (_d = object.phoneHash) !== null && _d !== void 0 ? _d : new Uint8Array(0);
779
+ return message;
780
+ },
781
+ };
782
+ function createBaseAccessToken() {
783
+ return {
784
+ id: long_1.default.UZERO,
785
+ identityId: long_1.default.UZERO,
786
+ domain: "",
787
+ token: long_1.default.UZERO,
788
+ phoneHash: new Uint8Array(0),
789
+ ipAddress: "",
790
+ userAgent: "",
791
+ deviceType: "",
792
+ expiresAt: undefined,
793
+ createdAt: undefined,
794
+ };
795
+ }
796
+ exports.AccessToken = {
797
+ encode(message, writer = new wire_1.BinaryWriter()) {
798
+ if (!message.id.equals(long_1.default.UZERO)) {
799
+ writer.uint32(8).uint64(message.id.toString());
800
+ }
801
+ if (!message.identityId.equals(long_1.default.UZERO)) {
802
+ writer.uint32(16).uint64(message.identityId.toString());
803
+ }
804
+ if (message.domain !== "") {
805
+ writer.uint32(26).string(message.domain);
806
+ }
807
+ if (!message.token.equals(long_1.default.UZERO)) {
808
+ writer.uint32(32).uint64(message.token.toString());
809
+ }
810
+ if (message.phoneHash.length !== 0) {
811
+ writer.uint32(42).bytes(message.phoneHash);
812
+ }
813
+ if (message.ipAddress !== "") {
814
+ writer.uint32(50).string(message.ipAddress);
815
+ }
816
+ if (message.userAgent !== "") {
817
+ writer.uint32(58).string(message.userAgent);
818
+ }
819
+ if (message.deviceType !== "") {
820
+ writer.uint32(66).string(message.deviceType);
821
+ }
822
+ if (message.expiresAt !== undefined) {
823
+ timestamp_1.Timestamp.encode(toTimestamp(message.expiresAt), writer.uint32(74).fork()).join();
824
+ }
825
+ if (message.createdAt !== undefined) {
826
+ timestamp_1.Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(82).fork()).join();
827
+ }
828
+ return writer;
829
+ },
830
+ decode(input, length) {
831
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
832
+ const end = length === undefined ? reader.len : reader.pos + length;
833
+ const message = createBaseAccessToken();
834
+ while (reader.pos < end) {
835
+ const tag = reader.uint32();
836
+ switch (tag >>> 3) {
837
+ case 1: {
838
+ if (tag !== 8) {
839
+ break;
840
+ }
841
+ message.id = long_1.default.fromString(reader.uint64().toString(), true);
842
+ continue;
843
+ }
844
+ case 2: {
845
+ if (tag !== 16) {
846
+ break;
847
+ }
848
+ message.identityId = long_1.default.fromString(reader.uint64().toString(), true);
849
+ continue;
850
+ }
851
+ case 3: {
852
+ if (tag !== 26) {
853
+ break;
854
+ }
855
+ message.domain = reader.string();
856
+ continue;
857
+ }
858
+ case 4: {
859
+ if (tag !== 32) {
860
+ break;
861
+ }
862
+ message.token = long_1.default.fromString(reader.uint64().toString(), true);
863
+ continue;
864
+ }
865
+ case 5: {
866
+ if (tag !== 42) {
867
+ break;
868
+ }
869
+ message.phoneHash = reader.bytes();
870
+ continue;
871
+ }
872
+ case 6: {
873
+ if (tag !== 50) {
874
+ break;
875
+ }
876
+ message.ipAddress = reader.string();
877
+ continue;
878
+ }
879
+ case 7: {
880
+ if (tag !== 58) {
881
+ break;
882
+ }
883
+ message.userAgent = reader.string();
884
+ continue;
885
+ }
886
+ case 8: {
887
+ if (tag !== 66) {
888
+ break;
889
+ }
890
+ message.deviceType = reader.string();
891
+ continue;
892
+ }
893
+ case 9: {
894
+ if (tag !== 74) {
895
+ break;
896
+ }
897
+ message.expiresAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
898
+ continue;
899
+ }
900
+ case 10: {
901
+ if (tag !== 82) {
902
+ break;
903
+ }
904
+ message.createdAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
905
+ continue;
906
+ }
907
+ }
908
+ if ((tag & 7) === 4 || tag === 0) {
909
+ break;
910
+ }
911
+ reader.skip(tag & 7);
912
+ }
913
+ return message;
914
+ },
915
+ fromJSON(object) {
916
+ return {
917
+ id: isSet(object.id) ? long_1.default.fromValue(object.id) : long_1.default.UZERO,
918
+ identityId: isSet(object.identity_id) ? long_1.default.fromValue(object.identity_id) : long_1.default.UZERO,
919
+ domain: isSet(object.domain) ? globalThis.String(object.domain) : "",
920
+ token: isSet(object.token) ? long_1.default.fromValue(object.token) : long_1.default.UZERO,
921
+ phoneHash: isSet(object.phone) ? bytesFromBase64(object.phone) : new Uint8Array(0),
922
+ ipAddress: isSet(object.ip) ? globalThis.String(object.ip) : "",
923
+ userAgent: isSet(object.user_agent) ? globalThis.String(object.user_agent) : "",
924
+ deviceType: isSet(object.device_type) ? globalThis.String(object.device_type) : "",
925
+ expiresAt: isSet(object.expires_at) ? fromJsonTimestamp(object.expires_at) : undefined,
926
+ createdAt: isSet(object.created_at) ? fromJsonTimestamp(object.created_at) : undefined,
927
+ };
928
+ },
929
+ toJSON(message) {
930
+ const obj = {};
931
+ if (!message.id.equals(long_1.default.UZERO)) {
932
+ obj.id = (message.id || long_1.default.UZERO).toString();
933
+ }
934
+ if (!message.identityId.equals(long_1.default.UZERO)) {
935
+ obj.identity_id = (message.identityId || long_1.default.UZERO).toString();
936
+ }
937
+ if (message.domain !== "") {
938
+ obj.domain = message.domain;
939
+ }
940
+ if (!message.token.equals(long_1.default.UZERO)) {
941
+ obj.token = (message.token || long_1.default.UZERO).toString();
942
+ }
943
+ if (message.phoneHash.length !== 0) {
944
+ obj.phone = base64FromBytes(message.phoneHash);
945
+ }
946
+ if (message.ipAddress !== "") {
947
+ obj.ip = message.ipAddress;
948
+ }
949
+ if (message.userAgent !== "") {
950
+ obj.user_agent = message.userAgent;
951
+ }
952
+ if (message.deviceType !== "") {
953
+ obj.device_type = message.deviceType;
954
+ }
955
+ if (message.expiresAt !== undefined) {
956
+ obj.expires_at = message.expiresAt.toISOString();
957
+ }
958
+ if (message.createdAt !== undefined) {
959
+ obj.created_at = message.createdAt.toISOString();
960
+ }
961
+ return obj;
962
+ },
963
+ create(base) {
964
+ return exports.AccessToken.fromPartial(base !== null && base !== void 0 ? base : {});
965
+ },
966
+ fromPartial(object) {
967
+ var _a, _b, _c, _d, _e, _f, _g;
968
+ const message = createBaseAccessToken();
969
+ message.id = (object.id !== undefined && object.id !== null) ? long_1.default.fromValue(object.id) : long_1.default.UZERO;
970
+ message.identityId = (object.identityId !== undefined && object.identityId !== null)
971
+ ? long_1.default.fromValue(object.identityId)
972
+ : long_1.default.UZERO;
973
+ message.domain = (_a = object.domain) !== null && _a !== void 0 ? _a : "";
974
+ message.token = (object.token !== undefined && object.token !== null) ? long_1.default.fromValue(object.token) : long_1.default.UZERO;
975
+ message.phoneHash = (_b = object.phoneHash) !== null && _b !== void 0 ? _b : new Uint8Array(0);
976
+ message.ipAddress = (_c = object.ipAddress) !== null && _c !== void 0 ? _c : "";
977
+ message.userAgent = (_d = object.userAgent) !== null && _d !== void 0 ? _d : "";
978
+ message.deviceType = (_e = object.deviceType) !== null && _e !== void 0 ? _e : "";
979
+ message.expiresAt = (_f = object.expiresAt) !== null && _f !== void 0 ? _f : undefined;
980
+ message.createdAt = (_g = object.createdAt) !== null && _g !== void 0 ? _g : undefined;
981
+ return message;
982
+ },
983
+ };
984
+ function createBaseOtpRequest() {
985
+ return {
986
+ id: long_1.default.UZERO,
987
+ phoneHash: new Uint8Array(0),
988
+ ipAddress: "",
989
+ domain: "",
990
+ token: new Uint8Array(0),
991
+ expiresAt: undefined,
992
+ createdAt: undefined,
993
+ };
994
+ }
995
+ exports.OtpRequest = {
996
+ encode(message, writer = new wire_1.BinaryWriter()) {
997
+ if (!message.id.equals(long_1.default.UZERO)) {
998
+ writer.uint32(8).uint64(message.id.toString());
999
+ }
1000
+ if (message.phoneHash.length !== 0) {
1001
+ writer.uint32(18).bytes(message.phoneHash);
1002
+ }
1003
+ if (message.ipAddress !== "") {
1004
+ writer.uint32(26).string(message.ipAddress);
1005
+ }
1006
+ if (message.domain !== "") {
1007
+ writer.uint32(34).string(message.domain);
1008
+ }
1009
+ if (message.token.length !== 0) {
1010
+ writer.uint32(42).bytes(message.token);
1011
+ }
1012
+ if (message.expiresAt !== undefined) {
1013
+ timestamp_1.Timestamp.encode(toTimestamp(message.expiresAt), writer.uint32(50).fork()).join();
1014
+ }
1015
+ if (message.createdAt !== undefined) {
1016
+ timestamp_1.Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(58).fork()).join();
1017
+ }
1018
+ return writer;
1019
+ },
1020
+ decode(input, length) {
1021
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1022
+ const end = length === undefined ? reader.len : reader.pos + length;
1023
+ const message = createBaseOtpRequest();
1024
+ while (reader.pos < end) {
1025
+ const tag = reader.uint32();
1026
+ switch (tag >>> 3) {
1027
+ case 1: {
1028
+ if (tag !== 8) {
1029
+ break;
1030
+ }
1031
+ message.id = long_1.default.fromString(reader.uint64().toString(), true);
1032
+ continue;
1033
+ }
1034
+ case 2: {
1035
+ if (tag !== 18) {
1036
+ break;
1037
+ }
1038
+ message.phoneHash = reader.bytes();
1039
+ continue;
1040
+ }
1041
+ case 3: {
1042
+ if (tag !== 26) {
1043
+ break;
1044
+ }
1045
+ message.ipAddress = reader.string();
1046
+ continue;
1047
+ }
1048
+ case 4: {
1049
+ if (tag !== 34) {
1050
+ break;
1051
+ }
1052
+ message.domain = reader.string();
1053
+ continue;
1054
+ }
1055
+ case 5: {
1056
+ if (tag !== 42) {
1057
+ break;
1058
+ }
1059
+ message.token = reader.bytes();
1060
+ continue;
1061
+ }
1062
+ case 6: {
1063
+ if (tag !== 50) {
1064
+ break;
1065
+ }
1066
+ message.expiresAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
1067
+ continue;
1068
+ }
1069
+ case 7: {
1070
+ if (tag !== 58) {
1071
+ break;
1072
+ }
1073
+ message.createdAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
1074
+ continue;
1075
+ }
1076
+ }
1077
+ if ((tag & 7) === 4 || tag === 0) {
1078
+ break;
1079
+ }
1080
+ reader.skip(tag & 7);
1081
+ }
1082
+ return message;
1083
+ },
1084
+ fromJSON(object) {
1085
+ return {
1086
+ id: isSet(object.id) ? long_1.default.fromValue(object.id) : long_1.default.UZERO,
1087
+ phoneHash: isSet(object.phone_hash) ? bytesFromBase64(object.phone_hash) : new Uint8Array(0),
1088
+ ipAddress: isSet(object.ip) ? globalThis.String(object.ip) : "",
1089
+ domain: isSet(object.domain) ? globalThis.String(object.domain) : "",
1090
+ token: isSet(object.token) ? bytesFromBase64(object.token) : new Uint8Array(0),
1091
+ expiresAt: isSet(object.expires_at) ? fromJsonTimestamp(object.expires_at) : undefined,
1092
+ createdAt: isSet(object.created_at) ? fromJsonTimestamp(object.created_at) : undefined,
1093
+ };
1094
+ },
1095
+ toJSON(message) {
1096
+ const obj = {};
1097
+ if (!message.id.equals(long_1.default.UZERO)) {
1098
+ obj.id = (message.id || long_1.default.UZERO).toString();
1099
+ }
1100
+ if (message.phoneHash.length !== 0) {
1101
+ obj.phone_hash = base64FromBytes(message.phoneHash);
1102
+ }
1103
+ if (message.ipAddress !== "") {
1104
+ obj.ip = message.ipAddress;
1105
+ }
1106
+ if (message.domain !== "") {
1107
+ obj.domain = message.domain;
1108
+ }
1109
+ if (message.token.length !== 0) {
1110
+ obj.token = base64FromBytes(message.token);
1111
+ }
1112
+ if (message.expiresAt !== undefined) {
1113
+ obj.expires_at = message.expiresAt.toISOString();
1114
+ }
1115
+ if (message.createdAt !== undefined) {
1116
+ obj.created_at = message.createdAt.toISOString();
1117
+ }
1118
+ return obj;
1119
+ },
1120
+ create(base) {
1121
+ return exports.OtpRequest.fromPartial(base !== null && base !== void 0 ? base : {});
1122
+ },
1123
+ fromPartial(object) {
1124
+ var _a, _b, _c, _d, _e, _f;
1125
+ const message = createBaseOtpRequest();
1126
+ message.id = (object.id !== undefined && object.id !== null) ? long_1.default.fromValue(object.id) : long_1.default.UZERO;
1127
+ message.phoneHash = (_a = object.phoneHash) !== null && _a !== void 0 ? _a : new Uint8Array(0);
1128
+ message.ipAddress = (_b = object.ipAddress) !== null && _b !== void 0 ? _b : "";
1129
+ message.domain = (_c = object.domain) !== null && _c !== void 0 ? _c : "";
1130
+ message.token = (_d = object.token) !== null && _d !== void 0 ? _d : new Uint8Array(0);
1131
+ message.expiresAt = (_e = object.expiresAt) !== null && _e !== void 0 ? _e : undefined;
1132
+ message.createdAt = (_f = object.createdAt) !== null && _f !== void 0 ? _f : undefined;
1133
+ return message;
1134
+ },
1135
+ };
1136
+ function createBaseCredential() {
1137
+ return {
1138
+ id: long_1.default.UZERO,
1139
+ identityId: long_1.default.UZERO,
1140
+ expires: long_1.default.ZERO,
1141
+ created: long_1.default.ZERO,
1142
+ token: long_1.default.UZERO,
1143
+ domain: "",
1144
+ };
1145
+ }
1146
+ exports.Credential = {
1147
+ encode(message, writer = new wire_1.BinaryWriter()) {
1148
+ if (!message.id.equals(long_1.default.UZERO)) {
1149
+ writer.uint32(8).uint64(message.id.toString());
1150
+ }
1151
+ if (!message.identityId.equals(long_1.default.UZERO)) {
1152
+ writer.uint32(16).uint64(message.identityId.toString());
1153
+ }
1154
+ if (!message.expires.equals(long_1.default.ZERO)) {
1155
+ writer.uint32(24).sint64(message.expires.toString());
1156
+ }
1157
+ if (!message.created.equals(long_1.default.ZERO)) {
1158
+ writer.uint32(32).sint64(message.created.toString());
1159
+ }
1160
+ if (!message.token.equals(long_1.default.UZERO)) {
1161
+ writer.uint32(48).uint64(message.token.toString());
1162
+ }
1163
+ if (message.domain !== "") {
1164
+ writer.uint32(42).string(message.domain);
1165
+ }
1166
+ return writer;
1167
+ },
1168
+ decode(input, length) {
1169
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1170
+ const end = length === undefined ? reader.len : reader.pos + length;
1171
+ const message = createBaseCredential();
1172
+ while (reader.pos < end) {
1173
+ const tag = reader.uint32();
1174
+ switch (tag >>> 3) {
1175
+ case 1: {
1176
+ if (tag !== 8) {
1177
+ break;
1178
+ }
1179
+ message.id = long_1.default.fromString(reader.uint64().toString(), true);
1180
+ continue;
1181
+ }
1182
+ case 2: {
1183
+ if (tag !== 16) {
1184
+ break;
1185
+ }
1186
+ message.identityId = long_1.default.fromString(reader.uint64().toString(), true);
1187
+ continue;
1188
+ }
1189
+ case 3: {
1190
+ if (tag !== 24) {
1191
+ break;
1192
+ }
1193
+ message.expires = long_1.default.fromString(reader.sint64().toString());
1194
+ continue;
1195
+ }
1196
+ case 4: {
1197
+ if (tag !== 32) {
1198
+ break;
1199
+ }
1200
+ message.created = long_1.default.fromString(reader.sint64().toString());
1201
+ continue;
1202
+ }
1203
+ case 6: {
1204
+ if (tag !== 48) {
1205
+ break;
1206
+ }
1207
+ message.token = long_1.default.fromString(reader.uint64().toString(), true);
1208
+ continue;
1209
+ }
1210
+ case 5: {
1211
+ if (tag !== 42) {
1212
+ break;
1213
+ }
1214
+ message.domain = reader.string();
1215
+ continue;
1216
+ }
1217
+ }
1218
+ if ((tag & 7) === 4 || tag === 0) {
1219
+ break;
1220
+ }
1221
+ reader.skip(tag & 7);
1222
+ }
1223
+ return message;
1224
+ },
1225
+ fromJSON(object) {
1226
+ return {
1227
+ id: isSet(object.id) ? long_1.default.fromValue(object.id) : long_1.default.UZERO,
1228
+ identityId: isSet(object.identity_id) ? long_1.default.fromValue(object.identity_id) : long_1.default.UZERO,
1229
+ expires: isSet(object.expires) ? long_1.default.fromValue(object.expires) : long_1.default.ZERO,
1230
+ created: isSet(object.created) ? long_1.default.fromValue(object.created) : long_1.default.ZERO,
1231
+ token: isSet(object.token) ? long_1.default.fromValue(object.token) : long_1.default.UZERO,
1232
+ domain: isSet(object.domain) ? globalThis.String(object.domain) : "",
1233
+ };
1234
+ },
1235
+ toJSON(message) {
1236
+ const obj = {};
1237
+ if (!message.id.equals(long_1.default.UZERO)) {
1238
+ obj.id = (message.id || long_1.default.UZERO).toString();
1239
+ }
1240
+ if (!message.identityId.equals(long_1.default.UZERO)) {
1241
+ obj.identity_id = (message.identityId || long_1.default.UZERO).toString();
1242
+ }
1243
+ if (!message.expires.equals(long_1.default.ZERO)) {
1244
+ obj.expires = (message.expires || long_1.default.ZERO).toString();
1245
+ }
1246
+ if (!message.created.equals(long_1.default.ZERO)) {
1247
+ obj.created = (message.created || long_1.default.ZERO).toString();
1248
+ }
1249
+ if (!message.token.equals(long_1.default.UZERO)) {
1250
+ obj.token = (message.token || long_1.default.UZERO).toString();
1251
+ }
1252
+ if (message.domain !== "") {
1253
+ obj.domain = message.domain;
1254
+ }
1255
+ return obj;
1256
+ },
1257
+ create(base) {
1258
+ return exports.Credential.fromPartial(base !== null && base !== void 0 ? base : {});
1259
+ },
1260
+ fromPartial(object) {
1261
+ var _a;
1262
+ const message = createBaseCredential();
1263
+ message.id = (object.id !== undefined && object.id !== null) ? long_1.default.fromValue(object.id) : long_1.default.UZERO;
1264
+ message.identityId = (object.identityId !== undefined && object.identityId !== null)
1265
+ ? long_1.default.fromValue(object.identityId)
1266
+ : long_1.default.UZERO;
1267
+ message.expires = (object.expires !== undefined && object.expires !== null)
1268
+ ? long_1.default.fromValue(object.expires)
1269
+ : long_1.default.ZERO;
1270
+ message.created = (object.created !== undefined && object.created !== null)
1271
+ ? long_1.default.fromValue(object.created)
1272
+ : long_1.default.ZERO;
1273
+ message.token = (object.token !== undefined && object.token !== null) ? long_1.default.fromValue(object.token) : long_1.default.UZERO;
1274
+ message.domain = (_a = object.domain) !== null && _a !== void 0 ? _a : "";
1275
+ return message;
1276
+ },
1277
+ };
1278
+ function bytesFromBase64(b64) {
1279
+ if (globalThis.Buffer) {
1280
+ return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
1281
+ }
1282
+ else {
1283
+ const bin = globalThis.atob(b64);
1284
+ const arr = new Uint8Array(bin.length);
1285
+ for (let i = 0; i < bin.length; ++i) {
1286
+ arr[i] = bin.charCodeAt(i);
1287
+ }
1288
+ return arr;
1289
+ }
1290
+ }
1291
+ function base64FromBytes(arr) {
1292
+ if (globalThis.Buffer) {
1293
+ return globalThis.Buffer.from(arr).toString("base64");
1294
+ }
1295
+ else {
1296
+ const bin = [];
1297
+ arr.forEach((byte) => {
1298
+ bin.push(globalThis.String.fromCharCode(byte));
1299
+ });
1300
+ return globalThis.btoa(bin.join(""));
1301
+ }
1302
+ }
1303
+ function toTimestamp(date) {
1304
+ const seconds = numberToLong(Math.trunc(date.getTime() / 1000));
1305
+ const nanos = (date.getTime() % 1000) * 1000000;
1306
+ return { seconds, nanos };
1307
+ }
1308
+ function fromTimestamp(t) {
1309
+ let millis = (t.seconds.toNumber() || 0) * 1000;
1310
+ millis += (t.nanos || 0) / 1000000;
1311
+ return new globalThis.Date(millis);
1312
+ }
1313
+ function fromJsonTimestamp(o) {
1314
+ if (o instanceof globalThis.Date) {
1315
+ return o;
1316
+ }
1317
+ else if (typeof o === "string") {
1318
+ return new globalThis.Date(o);
1319
+ }
1320
+ else {
1321
+ return fromTimestamp(timestamp_1.Timestamp.fromJSON(o));
1322
+ }
1323
+ }
1324
+ function numberToLong(number) {
1325
+ return long_1.default.fromNumber(number);
1326
+ }
614
1327
  function isSet(value) {
615
1328
  return value !== null && value !== undefined;
616
1329
  }
@@ -0,0 +1,2 @@
1
+ export type HeaderProvider = () => Promise<HeadersInit> | HeadersInit;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/report.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { ShownIo, SystemIo } from "./fatehan/devices/devices";
2
2
  import type { Data } from "./fatehan/packets/dataModel";
3
- export type HeaderProvider = () => Promise<HeadersInit> | HeadersInit;
3
+ import { HeaderProvider } from ".";
4
4
  export declare class ReportService {
5
5
  private readonly url;
6
6
  private readonly namespace;
@@ -1 +1 @@
1
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AqB,GAChE,OAAO,CAAC,OAAO,0BAA0B,EAAE,sBAAsB,CAAC;IAYxD,cAAc,CACzB,OAAO,EAAE,OAAO,0BAA0B,EAAE,eAAe,GAC1D,OAAO,CAAC,OAAO,0BAA0B,EAAE,gBAAgB,CAAC;IAYlD,WAAW,CACtB,OAAO,EAAE,OAAO,0BAA0B,EAAE,YAAY,EACxD,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,0BAA0B,EAAE,aAAa,KAAK,IAAI;IA8CjE,cAAc,CACzB,OAAO,EAAE,OAAO,0BAA0B,EAAE,eAAe,GAC1D,OAAO,CAAC,OAAO,0BAA0B,EAAE,gBAAgB,CAAC;IAoBlD,YAAY,CACvB,QAAQ,EAAE,QAAQ,EAAE,GAAG,IAAI,EAC3B,QAAQ,EAAE,QAAQ,EAAE,EACpB,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,OAAO,EAAE,CAAC;CActB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=api.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.test.d.ts","sourceRoot":"","sources":["../../src/tests/api.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const vitest_1 = require("vitest");
4
+ const api_1 = require("../api");
5
+ global.fetch = vitest_1.vi.fn();
6
+ (0, vitest_1.describe)("ApiService", () => {
7
+ const url = "http://fake-api-server.com/gapi";
8
+ let service;
9
+ let mockHeaderProvider;
10
+ (0, vitest_1.beforeEach)(() => {
11
+ vitest_1.vi.clearAllMocks();
12
+ mockHeaderProvider = vitest_1.vi.fn(() => ({
13
+ authorization: "Bearer test-token-from-mock",
14
+ "organization-id": "test-org-from-mock",
15
+ }));
16
+ service = new api_1.ApiService(url, mockHeaderProvider);
17
+ });
18
+ const setupMockSuccessResponse = (data = {}) => {
19
+ global.fetch.mockResolvedValue({
20
+ ok: true,
21
+ arrayBuffer: () => Promise.resolve(new Uint8Array()),
22
+ text: () => Promise.resolve("Success"),
23
+ });
24
+ };
25
+ (0, vitest_1.it)("should call MeIndex with correct headers and URL", async () => {
26
+ setupMockSuccessResponse();
27
+ await service.MeIndex({});
28
+ (0, vitest_1.expect)(mockHeaderProvider).toHaveBeenCalledOnce();
29
+ (0, vitest_1.expect)(global.fetch).toHaveBeenCalledWith(`${url}/com.fatehan.services.ApiService/MeIndex`, vitest_1.expect.objectContaining({
30
+ method: "POST",
31
+ headers: vitest_1.expect.objectContaining({
32
+ authorization: "Bearer test-token-from-mock",
33
+ }),
34
+ }));
35
+ });
36
+ (0, vitest_1.it)("should call ConfigIndex with correct headers and URL", async () => {
37
+ setupMockSuccessResponse();
38
+ await service.ConfigIndex({
39
+ domain: "api.myavl.ir",
40
+ });
41
+ (0, vitest_1.expect)(mockHeaderProvider).toHaveBeenCalledOnce();
42
+ (0, vitest_1.expect)(global.fetch).toHaveBeenCalledWith(`${url}/com.fatehan.services.ApiService/ConfigIndex`, vitest_1.expect.any(Object));
43
+ });
44
+ (0, vitest_1.it)("should call DeviceIndex with correct headers and URL", async () => {
45
+ setupMockSuccessResponse();
46
+ await service.DeviceIndex({
47
+ includeDeviceStatus: false,
48
+ organizationId: undefined,
49
+ queryFilter: {},
50
+ order: undefined,
51
+ sort: undefined,
52
+ search: undefined,
53
+ trackerId: undefined,
54
+ disablePagination: false,
55
+ page: 1,
56
+ pageSize: 15,
57
+ });
58
+ (0, vitest_1.expect)(mockHeaderProvider).toHaveBeenCalledOnce();
59
+ (0, vitest_1.expect)(global.fetch).toHaveBeenCalledWith(`${url}/com.fatehan.services.ApiService/DeviceIndex`, vitest_1.expect.any(Object));
60
+ });
61
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=report.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report.test.d.ts","sourceRoot":"","sources":["../../src/tests/report.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ const vitest_1 = require("vitest");
40
+ const report_1 = require("../report");
41
+ const long_1 = __importDefault(require("long"));
42
+ const system_io_1 = __importDefault(require("../system.io"));
43
+ const report_2 = require("../fatehan/reports/report");
44
+ global.fetch = vitest_1.vi.fn();
45
+ vitest_1.vi.mock("./system.io", () => ({
46
+ default: vitest_1.vi.fn(() => [{ name: "Mocked IO Result", value: 42 }]),
47
+ }));
48
+ vitest_1.vi.mock("./store/system.io", () => ({
49
+ getSystemIoCache: vitest_1.vi.fn(() => null),
50
+ setSystemIoCache: vitest_1.vi.fn(),
51
+ }));
52
+ (0, vitest_1.describe)("ReportService", () => {
53
+ const url = "http://fake-report-server.com";
54
+ let service;
55
+ let mockHeaderProvider;
56
+ (0, vitest_1.beforeEach)(() => {
57
+ vitest_1.vi.clearAllMocks();
58
+ mockHeaderProvider = vitest_1.vi.fn(() => ({
59
+ authorization: "Bearer test-token-12345",
60
+ "organization-id": "org-test-1000001",
61
+ }));
62
+ service = new report_1.ReportService(url, mockHeaderProvider);
63
+ });
64
+ const setupMockSuccessResponse = (data = {}) => {
65
+ global.fetch.mockResolvedValue({
66
+ ok: true,
67
+ arrayBuffer: () => Promise.resolve(new Uint8Array()),
68
+ text: () => Promise.resolve("Success"),
69
+ });
70
+ };
71
+ (0, vitest_1.it)("should call TripPerformanceReport with correct headers and URL", async () => {
72
+ setupMockSuccessResponse();
73
+ await service.TripPerformanceReport({
74
+ groupByDatetime: report_2.TripPerformanceRequest_GroupBy.All,
75
+ hourly: false,
76
+ deviceId: [long_1.default.fromInt(10168)],
77
+ startedAt: new Date(),
78
+ finishedAt: new Date(),
79
+ groupByDevice: true,
80
+ });
81
+ (0, vitest_1.expect)(mockHeaderProvider).toHaveBeenCalledOnce();
82
+ (0, vitest_1.expect)(global.fetch).toHaveBeenCalledWith(`${url}/com.fatehan.reports.ReportService/TripPerformanceReport`, vitest_1.expect.objectContaining({
83
+ method: "POST",
84
+ headers: vitest_1.expect.objectContaining({
85
+ authorization: "Bearer test-token-12345",
86
+ "organization-id": "org-test-1000001",
87
+ }),
88
+ }));
89
+ });
90
+ (0, vitest_1.it)("should call TripReport with correct headers and URL", async () => {
91
+ setupMockSuccessResponse();
92
+ await service.TripReport({ deviceIds: [long_1.default.fromInt(124251414)] });
93
+ (0, vitest_1.expect)(global.fetch).toHaveBeenCalledWith(`${url}/com.fatehan.reports.ReportService/TripReport`, vitest_1.expect.any(Object));
94
+ });
95
+ (0, vitest_1.it)("should call SystemIoReport and then set the cache on success", async () => {
96
+ const { setSystemIoCache } = await Promise.resolve().then(() => __importStar(require("../store/system.io")));
97
+ setupMockSuccessResponse({ ios: [{ id: 1, name: "TestIO" }] });
98
+ await service.SystemIoReport({});
99
+ (0, vitest_1.expect)(global.fetch).toHaveBeenCalledWith(`${url}/com.fatehan.reports.ReportService/SystemIoReport`, vitest_1.expect.any(Object));
100
+ });
101
+ (0, vitest_1.it)("should handle streaming ChartReport fetch call", async () => {
102
+ const mockStreamReader = {
103
+ read: vitest_1.vi
104
+ .fn()
105
+ .mockResolvedValueOnce({
106
+ done: false,
107
+ value: new Uint8Array([1, 2, 3]),
108
+ })
109
+ .mockResolvedValueOnce({ done: true, value: undefined }),
110
+ };
111
+ global.fetch.mockResolvedValue({
112
+ ok: true,
113
+ body: {
114
+ getReader: () => mockStreamReader,
115
+ },
116
+ });
117
+ const onChunkCallback = vitest_1.vi.fn();
118
+ await service.ChartReport({
119
+ finishedAt: undefined,
120
+ ios: [],
121
+ startedAt: undefined,
122
+ deviceIds: [long_1.default.fromInt(119926)],
123
+ }, onChunkCallback);
124
+ (0, vitest_1.expect)(global.fetch).toHaveBeenCalledWith(`${url}/com.fatehan.reports.ReportService/ChartReport`, vitest_1.expect.any(Object));
125
+ });
126
+ (0, vitest_1.it)("SystemIoCast should trigger SystemIoReport when cache is empty", async () => {
127
+ setupMockSuccessResponse();
128
+ await service.SystemIoCast(null, [], { deviceId: long_1.default.ZERO });
129
+ (0, vitest_1.expect)(global.fetch).toHaveBeenCalledWith(`${url}/com.fatehan.reports.ReportService/SystemIoReport`, vitest_1.expect.any(Object));
130
+ (0, vitest_1.expect)(system_io_1.default).toHaveBeenCalled();
131
+ });
132
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fatehan/tsrp",
3
- "version": "1.2.1",
3
+ "version": "1.3.2",
4
4
  "description": "fatehan main models",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",