@ssoeasy-dev/proto 1.1.0-dev-develop.5304bf2 → 1.1.0-dev-feat-auth.1

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.

Potentially problematic release.


This version of @ssoeasy-dev/proto might be problematic. Click here for more details.

@@ -7,6 +7,7 @@
7
7
  /* eslint-disable */
8
8
  import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
9
9
  import type { CallContext, CallOptions } from "nice-grpc-common";
10
+ import { StatusResponse } from "./common";
10
11
 
11
12
  export enum VerificationType {
12
13
  email_code = "email_code",
@@ -53,51 +54,50 @@ export function verificationTypeToNumber(object: VerificationType): number {
53
54
  }
54
55
  }
55
56
 
57
+ export interface Verification {
58
+ $type: "auth.v1.Verification";
59
+ id: string;
60
+ value: string;
61
+ expiresAt: number;
62
+ }
63
+
56
64
  export interface VerificateRequest {
57
65
  $type: "auth.v1.VerificateRequest";
58
66
  id: string;
59
67
  value: string;
60
- type: string;
61
- companyId: string;
62
- serviceId: string;
68
+ code: string;
63
69
  }
64
70
 
65
- export interface VerificateResponse {
66
- $type: "auth.v1.VerificateResponse";
67
- access: string;
68
- refresh: string;
71
+ export interface RefreshRequest {
72
+ $type: "auth.v1.RefreshRequest";
73
+ userId: string;
74
+ type: VerificationType;
69
75
  }
70
76
 
71
- function createBaseVerificateRequest(): VerificateRequest {
72
- return { $type: "auth.v1.VerificateRequest", id: "", value: "", type: "", companyId: "", serviceId: "" };
77
+ function createBaseVerification(): Verification {
78
+ return { $type: "auth.v1.Verification", id: "", value: "", expiresAt: 0 };
73
79
  }
74
80
 
75
- export const VerificateRequest: MessageFns<VerificateRequest, "auth.v1.VerificateRequest"> = {
76
- $type: "auth.v1.VerificateRequest" as const,
81
+ export const Verification: MessageFns<Verification, "auth.v1.Verification"> = {
82
+ $type: "auth.v1.Verification" as const,
77
83
 
78
- encode(message: VerificateRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
84
+ encode(message: Verification, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
79
85
  if (message.id !== "") {
80
86
  writer.uint32(10).string(message.id);
81
87
  }
82
88
  if (message.value !== "") {
83
89
  writer.uint32(18).string(message.value);
84
90
  }
85
- if (message.type !== "") {
86
- writer.uint32(26).string(message.type);
87
- }
88
- if (message.companyId !== "") {
89
- writer.uint32(34).string(message.companyId);
90
- }
91
- if (message.serviceId !== "") {
92
- writer.uint32(42).string(message.serviceId);
91
+ if (message.expiresAt !== 0) {
92
+ writer.uint32(24).int64(message.expiresAt);
93
93
  }
94
94
  return writer;
95
95
  },
96
96
 
97
- decode(input: BinaryReader | Uint8Array, length?: number): VerificateRequest {
97
+ decode(input: BinaryReader | Uint8Array, length?: number): Verification {
98
98
  const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
99
99
  const end = length === undefined ? reader.len : reader.pos + length;
100
- const message = createBaseVerificateRequest();
100
+ const message = createBaseVerification();
101
101
  while (reader.pos < end) {
102
102
  const tag = reader.uint32();
103
103
  switch (tag >>> 3) {
@@ -118,27 +118,110 @@ export const VerificateRequest: MessageFns<VerificateRequest, "auth.v1.Verificat
118
118
  continue;
119
119
  }
120
120
  case 3: {
121
- if (tag !== 26) {
121
+ if (tag !== 24) {
122
122
  break;
123
123
  }
124
124
 
125
- message.type = reader.string();
125
+ message.expiresAt = longToNumber(reader.int64());
126
126
  continue;
127
127
  }
128
- case 4: {
129
- if (tag !== 34) {
128
+ }
129
+ if ((tag & 7) === 4 || tag === 0) {
130
+ break;
131
+ }
132
+ reader.skip(tag & 7);
133
+ }
134
+ return message;
135
+ },
136
+
137
+ fromJSON(object: any): Verification {
138
+ return {
139
+ $type: Verification.$type,
140
+ id: isSet(object.id) ? globalThis.String(object.id) : "",
141
+ value: isSet(object.value) ? globalThis.String(object.value) : "",
142
+ expiresAt: isSet(object.expiresAt)
143
+ ? globalThis.Number(object.expiresAt)
144
+ : isSet(object.expires_at)
145
+ ? globalThis.Number(object.expires_at)
146
+ : 0,
147
+ };
148
+ },
149
+
150
+ toJSON(message: Verification): unknown {
151
+ const obj: any = {};
152
+ if (message.id !== "") {
153
+ obj.id = message.id;
154
+ }
155
+ if (message.value !== "") {
156
+ obj.value = message.value;
157
+ }
158
+ if (message.expiresAt !== 0) {
159
+ obj.expiresAt = Math.round(message.expiresAt);
160
+ }
161
+ return obj;
162
+ },
163
+
164
+ create<I extends Exact<DeepPartial<Verification>, I>>(base?: I): Verification {
165
+ return Verification.fromPartial(base ?? ({} as any));
166
+ },
167
+ fromPartial<I extends Exact<DeepPartial<Verification>, I>>(object: I): Verification {
168
+ const message = createBaseVerification();
169
+ message.id = object.id ?? "";
170
+ message.value = object.value ?? "";
171
+ message.expiresAt = object.expiresAt ?? 0;
172
+ return message;
173
+ },
174
+ };
175
+
176
+ function createBaseVerificateRequest(): VerificateRequest {
177
+ return { $type: "auth.v1.VerificateRequest", id: "", value: "", code: "" };
178
+ }
179
+
180
+ export const VerificateRequest: MessageFns<VerificateRequest, "auth.v1.VerificateRequest"> = {
181
+ $type: "auth.v1.VerificateRequest" as const,
182
+
183
+ encode(message: VerificateRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
184
+ if (message.id !== "") {
185
+ writer.uint32(10).string(message.id);
186
+ }
187
+ if (message.value !== "") {
188
+ writer.uint32(18).string(message.value);
189
+ }
190
+ if (message.code !== "") {
191
+ writer.uint32(26).string(message.code);
192
+ }
193
+ return writer;
194
+ },
195
+
196
+ decode(input: BinaryReader | Uint8Array, length?: number): VerificateRequest {
197
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
198
+ const end = length === undefined ? reader.len : reader.pos + length;
199
+ const message = createBaseVerificateRequest();
200
+ while (reader.pos < end) {
201
+ const tag = reader.uint32();
202
+ switch (tag >>> 3) {
203
+ case 1: {
204
+ if (tag !== 10) {
205
+ break;
206
+ }
207
+
208
+ message.id = reader.string();
209
+ continue;
210
+ }
211
+ case 2: {
212
+ if (tag !== 18) {
130
213
  break;
131
214
  }
132
215
 
133
- message.companyId = reader.string();
216
+ message.value = reader.string();
134
217
  continue;
135
218
  }
136
- case 5: {
137
- if (tag !== 42) {
219
+ case 3: {
220
+ if (tag !== 26) {
138
221
  break;
139
222
  }
140
223
 
141
- message.serviceId = reader.string();
224
+ message.code = reader.string();
142
225
  continue;
143
226
  }
144
227
  }
@@ -155,17 +238,7 @@ export const VerificateRequest: MessageFns<VerificateRequest, "auth.v1.Verificat
155
238
  $type: VerificateRequest.$type,
156
239
  id: isSet(object.id) ? globalThis.String(object.id) : "",
157
240
  value: isSet(object.value) ? globalThis.String(object.value) : "",
158
- type: isSet(object.type) ? globalThis.String(object.type) : "",
159
- companyId: isSet(object.companyId)
160
- ? globalThis.String(object.companyId)
161
- : isSet(object.company_id)
162
- ? globalThis.String(object.company_id)
163
- : "",
164
- serviceId: isSet(object.serviceId)
165
- ? globalThis.String(object.serviceId)
166
- : isSet(object.service_id)
167
- ? globalThis.String(object.service_id)
168
- : "",
241
+ code: isSet(object.code) ? globalThis.String(object.code) : "",
169
242
  };
170
243
  },
171
244
 
@@ -177,14 +250,8 @@ export const VerificateRequest: MessageFns<VerificateRequest, "auth.v1.Verificat
177
250
  if (message.value !== "") {
178
251
  obj.value = message.value;
179
252
  }
180
- if (message.type !== "") {
181
- obj.type = message.type;
182
- }
183
- if (message.companyId !== "") {
184
- obj.companyId = message.companyId;
185
- }
186
- if (message.serviceId !== "") {
187
- obj.serviceId = message.serviceId;
253
+ if (message.code !== "") {
254
+ obj.code = message.code;
188
255
  }
189
256
  return obj;
190
257
  },
@@ -196,34 +263,32 @@ export const VerificateRequest: MessageFns<VerificateRequest, "auth.v1.Verificat
196
263
  const message = createBaseVerificateRequest();
197
264
  message.id = object.id ?? "";
198
265
  message.value = object.value ?? "";
199
- message.type = object.type ?? "";
200
- message.companyId = object.companyId ?? "";
201
- message.serviceId = object.serviceId ?? "";
266
+ message.code = object.code ?? "";
202
267
  return message;
203
268
  },
204
269
  };
205
270
 
206
- function createBaseVerificateResponse(): VerificateResponse {
207
- return { $type: "auth.v1.VerificateResponse", access: "", refresh: "" };
271
+ function createBaseRefreshRequest(): RefreshRequest {
272
+ return { $type: "auth.v1.RefreshRequest", userId: "", type: VerificationType.email_code };
208
273
  }
209
274
 
210
- export const VerificateResponse: MessageFns<VerificateResponse, "auth.v1.VerificateResponse"> = {
211
- $type: "auth.v1.VerificateResponse" as const,
275
+ export const RefreshRequest: MessageFns<RefreshRequest, "auth.v1.RefreshRequest"> = {
276
+ $type: "auth.v1.RefreshRequest" as const,
212
277
 
213
- encode(message: VerificateResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
214
- if (message.access !== "") {
215
- writer.uint32(10).string(message.access);
278
+ encode(message: RefreshRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
279
+ if (message.userId !== "") {
280
+ writer.uint32(10).string(message.userId);
216
281
  }
217
- if (message.refresh !== "") {
218
- writer.uint32(18).string(message.refresh);
282
+ if (message.type !== VerificationType.email_code) {
283
+ writer.uint32(16).int32(verificationTypeToNumber(message.type));
219
284
  }
220
285
  return writer;
221
286
  },
222
287
 
223
- decode(input: BinaryReader | Uint8Array, length?: number): VerificateResponse {
288
+ decode(input: BinaryReader | Uint8Array, length?: number): RefreshRequest {
224
289
  const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
225
290
  const end = length === undefined ? reader.len : reader.pos + length;
226
- const message = createBaseVerificateResponse();
291
+ const message = createBaseRefreshRequest();
227
292
  while (reader.pos < end) {
228
293
  const tag = reader.uint32();
229
294
  switch (tag >>> 3) {
@@ -232,15 +297,15 @@ export const VerificateResponse: MessageFns<VerificateResponse, "auth.v1.Verific
232
297
  break;
233
298
  }
234
299
 
235
- message.access = reader.string();
300
+ message.userId = reader.string();
236
301
  continue;
237
302
  }
238
303
  case 2: {
239
- if (tag !== 18) {
304
+ if (tag !== 16) {
240
305
  break;
241
306
  }
242
307
 
243
- message.refresh = reader.string();
308
+ message.type = verificationTypeFromJSON(reader.int32());
244
309
  continue;
245
310
  }
246
311
  }
@@ -252,32 +317,36 @@ export const VerificateResponse: MessageFns<VerificateResponse, "auth.v1.Verific
252
317
  return message;
253
318
  },
254
319
 
255
- fromJSON(object: any): VerificateResponse {
320
+ fromJSON(object: any): RefreshRequest {
256
321
  return {
257
- $type: VerificateResponse.$type,
258
- access: isSet(object.access) ? globalThis.String(object.access) : "",
259
- refresh: isSet(object.refresh) ? globalThis.String(object.refresh) : "",
322
+ $type: RefreshRequest.$type,
323
+ userId: isSet(object.userId)
324
+ ? globalThis.String(object.userId)
325
+ : isSet(object.user_id)
326
+ ? globalThis.String(object.user_id)
327
+ : "",
328
+ type: isSet(object.type) ? verificationTypeFromJSON(object.type) : VerificationType.email_code,
260
329
  };
261
330
  },
262
331
 
263
- toJSON(message: VerificateResponse): unknown {
332
+ toJSON(message: RefreshRequest): unknown {
264
333
  const obj: any = {};
265
- if (message.access !== "") {
266
- obj.access = message.access;
334
+ if (message.userId !== "") {
335
+ obj.userId = message.userId;
267
336
  }
268
- if (message.refresh !== "") {
269
- obj.refresh = message.refresh;
337
+ if (message.type !== VerificationType.email_code) {
338
+ obj.type = verificationTypeToJSON(message.type);
270
339
  }
271
340
  return obj;
272
341
  },
273
342
 
274
- create<I extends Exact<DeepPartial<VerificateResponse>, I>>(base?: I): VerificateResponse {
275
- return VerificateResponse.fromPartial(base ?? ({} as any));
343
+ create<I extends Exact<DeepPartial<RefreshRequest>, I>>(base?: I): RefreshRequest {
344
+ return RefreshRequest.fromPartial(base ?? ({} as any));
276
345
  },
277
- fromPartial<I extends Exact<DeepPartial<VerificateResponse>, I>>(object: I): VerificateResponse {
278
- const message = createBaseVerificateResponse();
279
- message.access = object.access ?? "";
280
- message.refresh = object.refresh ?? "";
346
+ fromPartial<I extends Exact<DeepPartial<RefreshRequest>, I>>(object: I): RefreshRequest {
347
+ const message = createBaseRefreshRequest();
348
+ message.userId = object.userId ?? "";
349
+ message.type = object.type ?? VerificationType.email_code;
281
350
  return message;
282
351
  },
283
352
  };
@@ -291,7 +360,15 @@ export const VerificationServiceDefinition = {
291
360
  name: "Verificate",
292
361
  requestType: VerificateRequest,
293
362
  requestStream: false,
294
- responseType: VerificateResponse,
363
+ responseType: StatusResponse,
364
+ responseStream: false,
365
+ options: {},
366
+ },
367
+ refresh: {
368
+ name: "Refresh",
369
+ requestType: RefreshRequest,
370
+ requestStream: false,
371
+ responseType: Verification,
295
372
  responseStream: false,
296
373
  options: {},
297
374
  },
@@ -299,17 +376,13 @@ export const VerificationServiceDefinition = {
299
376
  } as const;
300
377
 
301
378
  export interface VerificationServiceImplementation<CallContextExt = {}> {
302
- verificate(
303
- request: VerificateRequest,
304
- context: CallContext & CallContextExt,
305
- ): Promise<DeepPartial<VerificateResponse>>;
379
+ verificate(request: VerificateRequest, context: CallContext & CallContextExt): Promise<DeepPartial<StatusResponse>>;
380
+ refresh(request: RefreshRequest, context: CallContext & CallContextExt): Promise<DeepPartial<Verification>>;
306
381
  }
307
382
 
308
383
  export interface VerificationServiceClient<CallOptionsExt = {}> {
309
- verificate(
310
- request: DeepPartial<VerificateRequest>,
311
- options?: CallOptions & CallOptionsExt,
312
- ): Promise<VerificateResponse>;
384
+ verificate(request: DeepPartial<VerificateRequest>, options?: CallOptions & CallOptionsExt): Promise<StatusResponse>;
385
+ refresh(request: DeepPartial<RefreshRequest>, options?: CallOptions & CallOptionsExt): Promise<Verification>;
313
386
  }
314
387
 
315
388
  type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
@@ -325,6 +398,17 @@ type KeysOfUnion<T> = T extends T ? keyof T : never;
325
398
  type Exact<P, I extends P> = P extends Builtin ? P
326
399
  : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P> | "$type">]: never };
327
400
 
401
+ function longToNumber(int64: { toString(): string }): number {
402
+ const num = globalThis.Number(int64.toString());
403
+ if (num > globalThis.Number.MAX_SAFE_INTEGER) {
404
+ throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
405
+ }
406
+ if (num < globalThis.Number.MIN_SAFE_INTEGER) {
407
+ throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
408
+ }
409
+ return num;
410
+ }
411
+
328
412
  function isSet(value: any): boolean {
329
413
  return value !== null && value !== undefined;
330
414
  }
@@ -5,5 +5,7 @@
5
5
 
6
6
  /* eslint-disable */
7
7
 
8
+ export * from "./auth/v1/common";
8
9
  export * from "./auth/v1/verification";
10
+ export * from "./auth/v1/user_policy";
9
11
  export * from "./auth/v1/auth";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssoeasy-dev/proto",
3
- "version": "1.1.0-dev-develop.5304bf2",
3
+ "version": "1.1.0-dev-feat-auth.1",
4
4
  "description": "gRPC proto contracts and generated TypeScript clients for SSOEasy",
5
5
  "main": "gen/ts/index.ts",
6
6
  "types": "gen/ts/index.ts",
@@ -3,37 +3,64 @@ syntax = "proto3";
3
3
  package auth.v1;
4
4
 
5
5
  import "auth/v1/verification.proto";
6
+ import "auth/v1/user_policy.proto";
7
+ import "auth/v1/common.proto";
6
8
 
7
9
  service AuthService {
8
10
  rpc Registration(RegistrationRequest) returns (RegistrationResponse);
9
- rpc RegistrationCompensate(RegistrationCompensateRequest) returns (StatusResponse);
11
+ rpc RegistrationCompensate(RegistrationCompensateRequest) returns (auth.v1.StatusResponse);
12
+ rpc Login(LoginRequest) returns (LoginResponse);
13
+ rpc Authtorize(AuthtorizeRequest) returns (auth.v1.Tokens);
14
+ rpc Logout(Tokens) returns (auth.v1.StatusResponse);
15
+ }
16
+
17
+ message AuthCode {
18
+ string id = 1;
19
+ string value = 2;
20
+ int64 expires_at = 3;
10
21
  }
11
22
 
12
23
  message RegistrationRequest {
13
- string user_id = 1;
14
- string service_id = 2;
15
- string company_id = 3;
16
- string attribute_name = 4;
17
- string attribute_value = 5;
18
- string contact = 6;
19
- auth.v1.VerificationType verification_type = 7;
20
- string password = 8;
24
+ string login = 1;
25
+ string password = 2;
26
+ optional auth.v1.VerificationType verification_type = 3;
27
+ repeated auth.v1.UserPolicyRequest policies = 4;
21
28
  }
22
29
 
23
30
  message RegistrationResponse {
24
- string credential_id = 1;
25
- string attribute_id = 2;
26
- string verification_id = 3;
27
- string value = 4;
28
- int64 expires_at = 5;
31
+ string user_id = 1;
32
+ string credential_id = 2;
33
+ repeated auth.v1.UserPolicyResponse policies = 3;
34
+ optional auth.v1.Verification verification = 4;
29
35
  }
30
36
 
31
37
  message RegistrationCompensateRequest {
32
- string credential_id = 1;
33
- string verification_id = 2;
34
- string user_attribute_id = 3;
38
+ string user_id = 1;
39
+ string credential_id = 2;
40
+ optional string verification_id = 3;
41
+ repeated string policy_ids = 4;
42
+ }
43
+
44
+ message LoginRequest {
45
+ string login = 1;
46
+ string password = 2;
47
+ string code_challenge = 3;
48
+ string service_id = 4;
49
+ optional auth.v1.VerificationType verification_type = 5;
50
+ }
51
+
52
+ message LoginResponse {
53
+ optional AuthCode code = 1;
54
+ optional auth.v1.Verification verification = 2;
55
+ }
56
+
57
+ message CodeVerifier {
58
+ string code = 1;
59
+ string verifier = 2;
35
60
  }
36
61
 
37
- message StatusResponse {
38
- bool success = 1;
62
+ message AuthtorizeRequest {
63
+ string service_id = 1;
64
+ optional auth.v1.Tokens tokens = 2;
65
+ optional CodeVerifier code = 3;
39
66
  }
@@ -0,0 +1,12 @@
1
+ syntax = "proto3";
2
+
3
+ package auth.v1;
4
+
5
+ message StatusResponse {
6
+ bool success = 1;
7
+ }
8
+
9
+ message Tokens {
10
+ string access = 1;
11
+ string refresh = 2;
12
+ }
@@ -0,0 +1,29 @@
1
+ syntax = "proto3";
2
+
3
+ package auth.v1;
4
+
5
+ enum AttributeType {
6
+ boolean = 0;
7
+ string = 1;
8
+ number = 2;
9
+ }
10
+
11
+ message Attribute {
12
+ string name = 1;
13
+ string operator = 2;
14
+ string value = 3;
15
+ }
16
+
17
+ message UserPolicyRequest {
18
+ string name = 1;
19
+ string service_id = 2;
20
+ optional string company_id = 3;
21
+ }
22
+
23
+ message UserPolicyResponse {
24
+ string id = 1;
25
+ string name = 2;
26
+ string service_id = 3;
27
+ optional string company_id = 4;
28
+ repeated Attribute attributes = 5;
29
+ }
@@ -2,8 +2,11 @@ syntax = "proto3";
2
2
 
3
3
  package auth.v1;
4
4
 
5
+ import "auth/v1/common.proto";
6
+
5
7
  service VerificationService {
6
- rpc Verificate(VerificateRequest) returns (VerificateResponse);
8
+ rpc Verificate(VerificateRequest) returns (auth.v1.StatusResponse);
9
+ rpc Refresh(RefreshRequest) returns (Verification);
7
10
  }
8
11
 
9
12
  enum VerificationType {
@@ -11,15 +14,19 @@ enum VerificationType {
11
14
  email_link = 1;
12
15
  }
13
16
 
17
+ message Verification {
18
+ string id = 1;
19
+ string value = 2;
20
+ int64 expires_at = 3;
21
+ }
22
+
14
23
  message VerificateRequest {
15
24
  string id = 1;
16
25
  string value = 2;
17
- string type = 3;
18
- string company_id = 4;
19
- string service_id = 5;
26
+ string code = 3;
20
27
  }
21
28
 
22
- message VerificateResponse {
23
- string access = 1;
24
- string refresh = 2;
29
+ message RefreshRequest {
30
+ string user_id = 1;
31
+ VerificationType type = 2;
25
32
  }