@routr/common 2.0.8-alpha.9 → 2.0.13

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.
Files changed (103) hide show
  1. package/dist/assertions.js +2 -2
  2. package/dist/auth.d.ts +18 -11
  3. package/dist/auth.js +34 -12
  4. package/dist/connect/api/client.d.ts +3 -0
  5. package/dist/connect/api/client.js +158 -0
  6. package/dist/connect/api/index.d.ts +2 -0
  7. package/dist/connect/api/index.js +36 -0
  8. package/dist/connect/api/types.d.ts +51 -0
  9. package/dist/connect/api/types.js +2 -0
  10. package/dist/connect/assertions.d.ts +37 -0
  11. package/dist/connect/assertions.js +112 -0
  12. package/dist/connect/client.d.ts +8 -0
  13. package/dist/connect/client.js +94 -0
  14. package/dist/connect/config.d.ts +113 -0
  15. package/dist/connect/config.js +2 -0
  16. package/dist/connect/connect_error.d.ts +21 -0
  17. package/dist/connect/connect_error.js +44 -0
  18. package/dist/connect/index.d.ts +7 -2
  19. package/dist/connect/index.js +8 -3
  20. package/dist/connect/mappers/acl.d.ts +3 -0
  21. package/dist/connect/mappers/acl.js +19 -0
  22. package/dist/connect/mappers/agent.d.ts +3 -0
  23. package/dist/connect/mappers/agent.js +42 -0
  24. package/dist/connect/mappers/assertions.d.ts +3 -0
  25. package/dist/connect/mappers/assertions.js +43 -0
  26. package/dist/connect/mappers/credentials.d.ts +3 -0
  27. package/dist/connect/mappers/credentials.js +18 -0
  28. package/dist/connect/mappers/domain.d.ts +3 -0
  29. package/dist/connect/mappers/domain.js +19 -0
  30. package/dist/connect/mappers/index.d.ts +7 -0
  31. package/dist/connect/mappers/index.js +41 -0
  32. package/dist/connect/mappers/number.d.ts +3 -0
  33. package/dist/connect/mappers/number.js +26 -0
  34. package/dist/connect/mappers/peer.d.ts +3 -0
  35. package/dist/connect/mappers/peer.js +26 -0
  36. package/dist/connect/mappers/trunk.d.ts +3 -0
  37. package/dist/connect/mappers/trunk.js +34 -0
  38. package/dist/connect/protos/acl.proto +112 -0
  39. package/dist/connect/protos/agents.proto +153 -0
  40. package/dist/connect/protos/credentials.proto +114 -0
  41. package/dist/connect/protos/domains.proto +146 -0
  42. package/dist/connect/protos/numbers.proto +166 -0
  43. package/dist/connect/protos/peers.proto +174 -0
  44. package/dist/connect/protos/trunks.proto +178 -0
  45. package/dist/connect/schemas/acl.d.ts +66 -0
  46. package/dist/connect/schemas/acl.js +85 -0
  47. package/dist/connect/schemas/agent.d.ts +61 -0
  48. package/dist/connect/schemas/agent.js +80 -0
  49. package/dist/connect/schemas/crendentials.d.ts +59 -0
  50. package/dist/connect/schemas/crendentials.js +78 -0
  51. package/dist/connect/schemas/domain.d.ts +72 -0
  52. package/dist/connect/schemas/domain.js +91 -0
  53. package/dist/connect/schemas/index.d.ts +1 -0
  54. package/dist/connect/schemas/index.js +35 -0
  55. package/dist/connect/schemas/number.d.ts +81 -0
  56. package/dist/connect/schemas/number.js +100 -0
  57. package/dist/connect/schemas/peer.d.ts +84 -0
  58. package/dist/connect/schemas/peer.js +103 -0
  59. package/dist/connect/schemas/trunk.d.ts +125 -0
  60. package/dist/connect/schemas/trunk.js +157 -0
  61. package/dist/connect/schemas/validators.d.ts +2 -0
  62. package/dist/connect/schemas/validators.js +43 -0
  63. package/dist/connect/types.d.ts +89 -23
  64. package/dist/connect/types.js +7 -29
  65. package/dist/connect/validations.d.ts +43 -0
  66. package/dist/connect/validations.js +272 -0
  67. package/dist/envs.d.ts +2 -0
  68. package/dist/envs.js +23 -0
  69. package/dist/errors.d.ts +35 -1
  70. package/dist/errors.js +52 -6
  71. package/dist/healthcheck.d.ts +1 -0
  72. package/dist/healthcheck.js +24 -0
  73. package/dist/helper.d.ts +13 -0
  74. package/dist/helper.js +78 -4
  75. package/dist/index.d.ts +8 -4
  76. package/dist/index.js +9 -6
  77. package/dist/ip_utils.js +1 -1
  78. package/dist/protos/common.proto +2 -4
  79. package/dist/protos/location.proto +21 -8
  80. package/dist/protos/processor.proto +8 -6
  81. package/dist/protos/requester.proto +6 -6
  82. package/dist/protos/sipmessage.proto +9 -2
  83. package/dist/protos/verifier.proto +39 -0
  84. package/dist/requester/grpc_client.js +1 -1
  85. package/dist/requester/index.js +1 -1
  86. package/dist/service.d.ts +2 -2
  87. package/dist/service.js +27 -5
  88. package/dist/tracer.js +1 -1
  89. package/dist/types.d.ts +119 -87
  90. package/dist/types.js +79 -69
  91. package/dist/verifier/grpc_client.d.ts +1 -0
  92. package/dist/{connect → verifier}/grpc_client.js +4 -4
  93. package/dist/verifier/index.d.ts +2 -0
  94. package/dist/verifier/index.js +36 -0
  95. package/dist/verifier/types.d.ts +10 -0
  96. package/dist/verifier/types.js +2 -0
  97. package/dist/verifier/verifier.d.ts +3 -0
  98. package/dist/verifier/verifier.js +64 -0
  99. package/package.json +17 -7
  100. package/dist/connect/data_api.d.ts +0 -11
  101. package/dist/connect/data_api.js +0 -91
  102. package/dist/connect/grpc_client.d.ts +0 -1
  103. package/dist/protos/resources.proto +0 -108
package/dist/types.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MessageType = exports.ResponseType = exports.HeaderModifierAction = exports.Privacy = exports.ExtraHeader = exports.Transport = exports.Method = void 0;
3
+ exports.MessageType = exports.ResponseType = exports.HeaderModifierAction = exports.Privacy = exports.ExtraHeader = exports.LoadBalancingAlgorithm = exports.Transport = exports.Method = exports.ANONYMOUS = void 0;
4
+ exports.ANONYMOUS = "anonymous";
4
5
  var Method;
5
6
  (function (Method) {
6
7
  Method["UNKNOWN"] = "UNKNOWN";
@@ -17,90 +18,99 @@ var Method;
17
18
  })(Method = exports.Method || (exports.Method = {}));
18
19
  var Transport;
19
20
  (function (Transport) {
20
- Transport["TCP"] = "tcp";
21
- Transport["UDP"] = "udp";
22
- Transport["TLS"] = "tls";
23
- Transport["SCTP"] = "sctp";
24
- Transport["WS"] = "ws";
25
- Transport["WSS"] = "wss";
21
+ Transport["TCP"] = "TCP";
22
+ Transport["UDP"] = "UDP";
23
+ Transport["TLS"] = "TLS";
24
+ Transport["SCTP"] = "SCTP";
25
+ Transport["WS"] = "WS";
26
+ Transport["WSS"] = "WSS";
26
27
  })(Transport = exports.Transport || (exports.Transport = {}));
28
+ var LoadBalancingAlgorithm;
29
+ (function (LoadBalancingAlgorithm) {
30
+ LoadBalancingAlgorithm["UNSPECIFIED"] = "UNSPECIFIED";
31
+ LoadBalancingAlgorithm["ROUND_ROBIN"] = "ROUND_ROBIN";
32
+ LoadBalancingAlgorithm["LEAST_SESSIONS"] = "LEAST_SESSIONS";
33
+ })(LoadBalancingAlgorithm = exports.LoadBalancingAlgorithm || (exports.LoadBalancingAlgorithm = {}));
27
34
  var ExtraHeader;
28
35
  (function (ExtraHeader) {
29
36
  ExtraHeader["REQUEST_URI"] = "X-Request-Uri";
30
37
  ExtraHeader["GATEWAY_AUTH"] = "X-Gateway-Auth";
31
38
  ExtraHeader["EDGEPORT_REF"] = "X-Edgeport-Ref";
32
39
  ExtraHeader["SESSION_COUNT"] = "X-Session-Count";
40
+ ExtraHeader["DOD_NUMBER"] = "X-DOD-Number";
41
+ ExtraHeader["DOD_PRIVACY"] = "X-DOD-Privacy";
42
+ ExtraHeader["CONNECT_TOKEN"] = "X-Connect-Token";
33
43
  })(ExtraHeader = exports.ExtraHeader || (exports.ExtraHeader = {}));
34
44
  var Privacy;
35
45
  (function (Privacy) {
36
- Privacy["NONE"] = "none";
37
- Privacy["PRIVATE"] = "id";
46
+ Privacy["NONE"] = "NONE";
47
+ Privacy["PRIVATE"] = "ID";
38
48
  })(Privacy = exports.Privacy || (exports.Privacy = {}));
39
49
  var HeaderModifierAction;
40
50
  (function (HeaderModifierAction) {
41
- HeaderModifierAction["ADD"] = "add";
42
- HeaderModifierAction["REMOVE"] = "remove";
51
+ HeaderModifierAction[HeaderModifierAction["ADD"] = 0] = "ADD";
52
+ HeaderModifierAction[HeaderModifierAction["REMOVE"] = 1] = "REMOVE";
43
53
  })(HeaderModifierAction = exports.HeaderModifierAction || (exports.HeaderModifierAction = {}));
44
54
  var ResponseType;
45
55
  (function (ResponseType) {
46
- ResponseType[ResponseType["UNKNOWN"] = 0] = "UNKNOWN";
47
- ResponseType[ResponseType["TRYING"] = 1] = "TRYING";
48
- ResponseType[ResponseType["RINGING"] = 2] = "RINGING";
49
- ResponseType[ResponseType["CALL_IS_BEING_FORWARDED"] = 3] = "CALL_IS_BEING_FORWARDED";
50
- ResponseType[ResponseType["QUEUED"] = 4] = "QUEUED";
51
- ResponseType[ResponseType["SESSION_PROGRESS"] = 5] = "SESSION_PROGRESS";
52
- ResponseType[ResponseType["SUCCESS"] = 6] = "SUCCESS";
53
- ResponseType[ResponseType["OK"] = 7] = "OK";
54
- ResponseType[ResponseType["ACCEPTED"] = 8] = "ACCEPTED";
55
- ResponseType[ResponseType["REDIRECTION"] = 9] = "REDIRECTION";
56
- ResponseType[ResponseType["MULTIPLE_CHOICES"] = 10] = "MULTIPLE_CHOICES";
57
- ResponseType[ResponseType["MOVED_PERMANENTLY"] = 11] = "MOVED_PERMANENTLY";
58
- ResponseType[ResponseType["MOVED_TEMPORARILY"] = 12] = "MOVED_TEMPORARILY";
59
- ResponseType[ResponseType["USE_PROXY"] = 13] = "USE_PROXY";
60
- ResponseType[ResponseType["ALTERNATIVE_SERVICE"] = 14] = "ALTERNATIVE_SERVICE";
61
- ResponseType[ResponseType["CLIENT_ERROR"] = 15] = "CLIENT_ERROR";
62
- ResponseType[ResponseType["BAD_REQUEST"] = 16] = "BAD_REQUEST";
63
- ResponseType[ResponseType["UNAUTHORIZED"] = 17] = "UNAUTHORIZED";
64
- ResponseType[ResponseType["PAYMENT_REQUIRED"] = 18] = "PAYMENT_REQUIRED";
65
- ResponseType[ResponseType["FORBIDDEN"] = 19] = "FORBIDDEN";
66
- ResponseType[ResponseType["NOT_FOUND"] = 20] = "NOT_FOUND";
67
- ResponseType[ResponseType["METHOD_NOT_ALLOWED"] = 21] = "METHOD_NOT_ALLOWED";
68
- ResponseType[ResponseType["NOT_ACCEPTABLE"] = 22] = "NOT_ACCEPTABLE";
69
- ResponseType[ResponseType["PROXY_AUTHENTICATION_REQUIRED"] = 23] = "PROXY_AUTHENTICATION_REQUIRED";
70
- ResponseType[ResponseType["REQUEST_TIMEOUT"] = 24] = "REQUEST_TIMEOUT";
71
- ResponseType[ResponseType["GONE"] = 25] = "GONE";
72
- ResponseType[ResponseType["REQUEST_ENTITY_TOO_LARGE"] = 26] = "REQUEST_ENTITY_TOO_LARGE";
73
- ResponseType[ResponseType["REQUEST_URI_TOO_LONG"] = 27] = "REQUEST_URI_TOO_LONG";
74
- ResponseType[ResponseType["UNSUPPORTED_MEDIA_TYPE"] = 28] = "UNSUPPORTED_MEDIA_TYPE";
75
- ResponseType[ResponseType["UNSUPPORTED_URI_SCHEME"] = 29] = "UNSUPPORTED_URI_SCHEME";
76
- ResponseType[ResponseType["BAD_EXTENSION"] = 30] = "BAD_EXTENSION";
77
- ResponseType[ResponseType["EXTENSION_REQUIRED"] = 31] = "EXTENSION_REQUIRED";
78
- ResponseType[ResponseType["INTERVAL_TOO_BRIEF"] = 32] = "INTERVAL_TOO_BRIEF";
79
- ResponseType[ResponseType["TEMPORARILY_UNAVAILABLE"] = 33] = "TEMPORARILY_UNAVAILABLE";
80
- ResponseType[ResponseType["CALL_OR_TRANSACTION_DOES_NOT_EXIST"] = 34] = "CALL_OR_TRANSACTION_DOES_NOT_EXIST";
81
- ResponseType[ResponseType["LOOP_DETECTED"] = 35] = "LOOP_DETECTED";
82
- ResponseType[ResponseType["TOO_MANY_HOPS"] = 36] = "TOO_MANY_HOPS";
83
- ResponseType[ResponseType["ADDRESS_INCOMPLETE"] = 37] = "ADDRESS_INCOMPLETE";
84
- ResponseType[ResponseType["AMBIGUOUS"] = 38] = "AMBIGUOUS";
85
- ResponseType[ResponseType["BUSY_HERE"] = 39] = "BUSY_HERE";
86
- ResponseType[ResponseType["REQUEST_TERMINATED"] = 40] = "REQUEST_TERMINATED";
87
- ResponseType[ResponseType["NOT_ACCEPTABLE_HERE"] = 41] = "NOT_ACCEPTABLE_HERE";
88
- ResponseType[ResponseType["BAD_EVENT"] = 42] = "BAD_EVENT";
89
- ResponseType[ResponseType["REQUEST_PENDING"] = 43] = "REQUEST_PENDING";
90
- ResponseType[ResponseType["UNDECIPHERABLE"] = 44] = "UNDECIPHERABLE";
91
- ResponseType[ResponseType["SERVER_ERROR"] = 45] = "SERVER_ERROR";
92
- ResponseType[ResponseType["SERVER_INTERNAL_ERROR"] = 46] = "SERVER_INTERNAL_ERROR";
93
- ResponseType[ResponseType["NOT_IMPLEMENTED"] = 47] = "NOT_IMPLEMENTED";
94
- ResponseType[ResponseType["BAD_GATEWAY"] = 48] = "BAD_GATEWAY";
95
- ResponseType[ResponseType["SERVICE_UNAVAILABLE"] = 49] = "SERVICE_UNAVAILABLE";
96
- ResponseType[ResponseType["SERVER_TIMEOUT"] = 50] = "SERVER_TIMEOUT";
97
- ResponseType[ResponseType["VERSION_NOT_SUPPORTED"] = 51] = "VERSION_NOT_SUPPORTED";
98
- ResponseType[ResponseType["MESSAGE_TOO_LARGE"] = 52] = "MESSAGE_TOO_LARGE";
99
- ResponseType[ResponseType["GLOBAL_ERROR"] = 53] = "GLOBAL_ERROR";
100
- ResponseType[ResponseType["BUSY_EVERYWHERE"] = 54] = "BUSY_EVERYWHERE";
101
- ResponseType[ResponseType["DECLINE"] = 55] = "DECLINE";
102
- ResponseType[ResponseType["DOES_NOT_EXIST_ANYWHERE"] = 56] = "DOES_NOT_EXIST_ANYWHERE";
103
- ResponseType[ResponseType["SESSION_NOT_ACCEPTABLE"] = 57] = "SESSION_NOT_ACCEPTABLE";
56
+ ResponseType["UNKNOWN"] = "UNKNOWN";
57
+ ResponseType["TRYING"] = "TRYING";
58
+ ResponseType["RINGING"] = "RINGING";
59
+ ResponseType["CALL_IS_BEING_FORWARDED"] = "CALL_IS_BEING_FORWARDED";
60
+ ResponseType["QUEUED"] = "QUEUED";
61
+ ResponseType["SESSION_PROGRESS"] = "SESSION_PROGRESS";
62
+ ResponseType["SUCCESS"] = "SUCCESS";
63
+ ResponseType["OK"] = "OK";
64
+ ResponseType["ACCEPTED"] = "ACCEPTED";
65
+ ResponseType["REDIRECTION"] = "REDIRECTION";
66
+ ResponseType["MULTIPLE_CHOICES"] = "MULTIPLE_CHOICES";
67
+ ResponseType["MOVED_PERMANENTLY"] = "MOVED_PERMANENTLY";
68
+ ResponseType["MOVED_TEMPORARILY"] = "MOVED_TEMPORARILY";
69
+ ResponseType["USE_PROXY"] = "USE_PROXY";
70
+ ResponseType["ALTERNATIVE_SERVICE"] = "ALTERNATIVE_SERVICE";
71
+ ResponseType["CLIENT_ERROR"] = "CLIENT_ERROR";
72
+ ResponseType["BAD_REQUEST"] = "BAD_REQUEST";
73
+ ResponseType["UNAUTHORIZED"] = "UNAUTHORIZED";
74
+ ResponseType["PAYMENT_REQUIRED"] = "PAYMENT_REQUIRED";
75
+ ResponseType["FORBIDDEN"] = "FORBIDDEN";
76
+ ResponseType["NOT_FOUND"] = "NOT_FOUND";
77
+ ResponseType["METHOD_NOT_ALLOWED"] = "METHOD_NOT_ALLOWED";
78
+ ResponseType["NOT_ACCEPTABLE"] = "NOT_ACCEPTABLE";
79
+ ResponseType["PROXY_AUTHENTICATION_REQUIRED"] = "PROXY_AUTHENTICATION_REQUIRED";
80
+ ResponseType["REQUEST_TIMEOUT"] = "REQUEST_TIMEOUT";
81
+ ResponseType["GONE"] = "GONE";
82
+ ResponseType["REQUEST_ENTITY_TOO_LARGE"] = "REQUEST_ENTITY_TOO_LARGE";
83
+ ResponseType["REQUEST_URI_TOO_LONG"] = "REQUEST_URI_TOO_LONG";
84
+ ResponseType["UNSUPPORTED_MEDIA_TYPE"] = "UNSUPPORTED_MEDIA_TYPE";
85
+ ResponseType["UNSUPPORTED_URI_SCHEME"] = "UNSUPPORTED_URI_SCHEME";
86
+ ResponseType["BAD_EXTENSION"] = "BAD_EXTENSION";
87
+ ResponseType["EXTENSION_REQUIRED"] = "EXTENSION_REQUIRED";
88
+ ResponseType["INTERVAL_TOO_BRIEF"] = "INTERVAL_TOO_BRIEF";
89
+ ResponseType["TEMPORARILY_UNAVAILABLE"] = "TEMPORARILY_UNAVAILABLE";
90
+ ResponseType["CALL_OR_TRANSACTION_DOES_NOT_EXIST"] = "CALL_OR_TRANSACTION_DOES_NOT_EXIST";
91
+ ResponseType["LOOP_DETECTED"] = "LOOP_DETECTED";
92
+ ResponseType["TOO_MANY_HOPS"] = "TOO_MANY_HOPS";
93
+ ResponseType["ADDRESS_INCOMPLETE"] = "ADDRESS_INCOMPLETE";
94
+ ResponseType["AMBIGUOUS"] = "AMBIGUOUS";
95
+ ResponseType["BUSY_HERE"] = "BUSY_HERE";
96
+ ResponseType["REQUEST_TERMINATED"] = "REQUEST_TERMINATED";
97
+ ResponseType["NOT_ACCEPTABLE_HERE"] = "NOT_ACCEPTABLE_HERE";
98
+ ResponseType["BAD_EVENT"] = "BAD_EVENT";
99
+ ResponseType["REQUEST_PENDING"] = "REQUEST_PENDING";
100
+ ResponseType["UNDECIPHERABLE"] = "UNDECIPHERABLE";
101
+ ResponseType["SERVER_ERROR"] = "SERVER_ERROR";
102
+ ResponseType["SERVER_INTERNAL_ERROR"] = "SERVER_INTERNAL_ERROR";
103
+ ResponseType["NOT_IMPLEMENTED"] = "NOT_IMPLEMENTED";
104
+ ResponseType["BAD_GATEWAY"] = "BAD_GATEWAY";
105
+ ResponseType["SERVICE_UNAVAILABLE"] = "SERVICE_UNAVAILABLE";
106
+ ResponseType["SERVER_TIMEOUT"] = "SERVER_TIMEOUT";
107
+ ResponseType["VERSION_NOT_SUPPORTED"] = "VERSION_NOT_SUPPORTED";
108
+ ResponseType["MESSAGE_TOO_LARGE"] = "MESSAGE_TOO_LARGE";
109
+ ResponseType["GLOBAL_ERROR"] = "GLOBAL_ERROR";
110
+ ResponseType["BUSY_EVERYWHERE"] = "BUSY_EVERYWHERE";
111
+ ResponseType["DECLINE"] = "DECLINE";
112
+ ResponseType["DOES_NOT_EXIST_ANYWHERE"] = "DOES_NOT_EXIST_ANYWHERE";
113
+ ResponseType["SESSION_NOT_ACCEPTABLE"] = "SESSION_NOT_ACCEPTABLE";
104
114
  })(ResponseType = exports.ResponseType || (exports.ResponseType = {}));
105
115
  var MessageType;
106
116
  (function (MessageType) {
@@ -0,0 +1 @@
1
+ export declare const VERIFIER_PROTO: any;
@@ -23,9 +23,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.RESOURCES_PROTO = void 0;
26
+ exports.VERIFIER_PROTO = void 0;
27
27
  /*
28
- * Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
28
+ * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
29
29
  * http://github.com/fonoster/routr
30
30
  *
31
31
  * This file is part of Routr
@@ -44,7 +44,7 @@ exports.RESOURCES_PROTO = void 0;
44
44
  */
45
45
  const grpc = __importStar(require("@grpc/grpc-js"));
46
46
  const protoLoader = require("@grpc/proto-loader");
47
- const packageDefinition = protoLoader.loadSync(__dirname + "/../protos/resources.proto", {
47
+ const packageDefinition = protoLoader.loadSync(__dirname + "/../protos/verifier.proto", {
48
48
  keepCase: false,
49
49
  longs: String,
50
50
  enums: String,
@@ -53,4 +53,4 @@ const packageDefinition = protoLoader.loadSync(__dirname + "/../protos/resources
53
53
  });
54
54
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
55
55
  const protoDescriptor = grpc.loadPackageDefinition(packageDefinition);
56
- exports.RESOURCES_PROTO = protoDescriptor.fonoster.routr.resources;
56
+ exports.VERIFIER_PROTO = protoDescriptor.fonoster.verifier;
@@ -0,0 +1,2 @@
1
+ export * from "./verifier";
2
+ export * from "./types";
@@ -0,0 +1,36 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ /*
18
+ * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
19
+ * http://github.com/fonoster
20
+ *
21
+ * This file is part of Routr.
22
+ *
23
+ * Licensed under the MIT License (the "License");
24
+ * you may not use this file except in compliance with
25
+ * the License. You may obtain a copy of the License at
26
+ *
27
+ * https://opensource.org/licenses/MIT
28
+ *
29
+ * Unless required by applicable law or agreed to in writing, software
30
+ * distributed under the License is distributed on an "AS IS" BASIS,
31
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32
+ * See the License for the specific language governing permissions and
33
+ * limitations under the License.
34
+ */
35
+ __exportStar(require("./verifier"), exports);
36
+ __exportStar(require("./types"), exports);
@@ -0,0 +1,10 @@
1
+ import { Method } from "../types";
2
+ export interface VerifyResponse {
3
+ ref: string;
4
+ domain: string;
5
+ domainRef: string;
6
+ aor: string;
7
+ aorLink: string;
8
+ username: string;
9
+ allowedMethods: Method[];
10
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ import { ServiceUnavailableError } from "../errors";
2
+ import { VerifyResponse } from "./types";
3
+ export declare const verifier: (verifierAddr: string) => (token: string) => Promise<ServiceUnavailableError | VerifyResponse>;
@@ -0,0 +1,64 @@
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 (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.verifier = void 0;
27
+ /*
28
+ * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
29
+ * http://github.com/fonoster/routr
30
+ *
31
+ * This file is part of Routr
32
+ *
33
+ * Licensed under the MIT License (the "License");
34
+ * you may not use this file except in compliance with
35
+ * the License. You may obtain a copy of the License at
36
+ *
37
+ * https://opensource.org/licenses/MIT
38
+ *
39
+ * Unless required by applicable law or agreed to in writing, software
40
+ * distributed under the License is distributed on an "AS IS" BASIS,
41
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
42
+ * See the License for the specific language governing permissions and
43
+ * limitations under the License.
44
+ */
45
+ const grpc = __importStar(require("@grpc/grpc-js"));
46
+ const errors_1 = require("../errors");
47
+ const grpc_client_1 = require("./grpc_client");
48
+ const verifier = (verifierAddr) => {
49
+ return (token) => {
50
+ const client = new grpc_client_1.VERIFIER_PROTO.Verifier(verifierAddr, grpc.credentials.createInsecure());
51
+ return new Promise((resolve, reject) => {
52
+ client.sendMessage({ token }, (err, response) => {
53
+ if ((err === null || err === void 0 ? void 0 : err.code) === 14) {
54
+ return reject(new errors_1.ServiceUnavailableError(verifierAddr));
55
+ }
56
+ else if (err) {
57
+ return reject(err);
58
+ }
59
+ resolve(response);
60
+ });
61
+ });
62
+ };
63
+ };
64
+ exports.verifier = verifier;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@routr/common",
3
- "version": "2.0.8-alpha.9",
3
+ "version": "2.0.13",
4
4
  "description": "Common package",
5
5
  "author": "Pedro Sanders <psanders@fonoster.com>",
6
6
  "homepage": "https://github.com/fonoster/routr#readme",
@@ -10,12 +10,13 @@
10
10
  "scripts": {
11
11
  "prebuild": "rimraf ./dist tsconfig.tsbuildinfo",
12
12
  "build": "tsc -b tsconfig.json",
13
- "postbuild": "mkdir -p dist/protos && cp src/protos/* dist/protos"
13
+ "postbuild": "cp -a src/protos dist/protos && cp -a src/connect/protos dist/connect/protos"
14
14
  },
15
15
  "dependencies": {
16
- "@fonoster/logger": "0.3.18",
17
- "@grpc/grpc-js": "^1.5.9",
18
- "@grpc/proto-loader": "^0.6.9",
16
+ "@fonoster/grpc-health-check": "^3.1.2",
17
+ "@fonoster/logger": "0.3.20",
18
+ "@grpc/grpc-js": "^1.8.4",
19
+ "@grpc/proto-loader": "^0.7.2",
19
20
  "@opentelemetry/api": "^1.0.4",
20
21
  "@opentelemetry/exporter-jaeger": "^1.0.4",
21
22
  "@opentelemetry/instrumentation": "^0.27.0",
@@ -24,9 +25,15 @@
24
25
  "@opentelemetry/sdk-trace-base": "^1.0.4",
25
26
  "@opentelemetry/sdk-trace-node": "^1.0.4",
26
27
  "@opentelemetry/semantic-conventions": "^1.0.4",
28
+ "ajv": "^6.12.6",
27
29
  "fp-ts": "^2.11.8",
30
+ "grpc-interceptors": "github:fonoster/node-grpc-interceptors",
28
31
  "ip-utils": "^2.4.0",
29
- "pb-util": "^1.0.3"
32
+ "js-yaml": "^4.1.0",
33
+ "pb-util": "^1.0.3",
34
+ "phone": "^3.1.32",
35
+ "toml": "^3.0.0",
36
+ "validator": "^13.7.0"
30
37
  },
31
38
  "directories": {
32
39
  "src": "src",
@@ -45,5 +52,8 @@
45
52
  "bugs": {
46
53
  "url": "https://github.com/fonoster/routr/issues"
47
54
  },
48
- "gitHead": "9ebb361db74fad2b3891fc9add683ddfde2efdff"
55
+ "devDependencies": {
56
+ "@types/js-yaml": "^4.0.5"
57
+ },
58
+ "gitHead": "476d11cfb4fd3dc9847a0829cae6fece84d048df"
49
59
  }
@@ -1,11 +0,0 @@
1
- import { FindParameters, Resource } from "./types";
2
- /**
3
- * Data API for the Connect module.
4
- *
5
- * @param {string} apiAddr - The address of the API server
6
- * @return {Promise<Resource[]>}
7
- */
8
- export declare function dataAPI(apiAddr: string): {
9
- get: (ref: string) => Promise<Resource>;
10
- findBy: (request: FindParameters) => Promise<Resource[]>;
11
- };
@@ -1,91 +0,0 @@
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 (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.dataAPI = void 0;
27
- /*
28
- * Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
29
- * http://github.com/fonoster/routr
30
- *
31
- * This file is part of Routr
32
- *
33
- * Licensed under the MIT License (the "License");
34
- * you may not use this file except in compliance with
35
- * the License. You may obtain a copy of the License at
36
- *
37
- * https://opensource.org/licenses/MIT
38
- *
39
- * Unless required by applicable law or agreed to in writing, software
40
- * distributed under the License is distributed on an "AS IS" BASIS,
41
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
42
- * See the License for the specific language governing permissions and
43
- * limitations under the License.
44
- */
45
- const grpc = __importStar(require("@grpc/grpc-js"));
46
- const protobufUtil = __importStar(require("pb-util"));
47
- const errors_1 = require("../errors");
48
- const grpc_client_1 = require("./grpc_client");
49
- const jsonToStruct = protobufUtil.struct.encode;
50
- const jsonFromStruct = protobufUtil.struct.decode;
51
- /**
52
- * Data API for the Connect module.
53
- *
54
- * @param {string} apiAddr - The address of the API server
55
- * @return {Promise<Resource[]>}
56
- */
57
- function dataAPI(apiAddr) {
58
- const client = new grpc_client_1.RESOURCES_PROTO.v2draft1.Resources(apiAddr, grpc.credentials.createInsecure());
59
- return {
60
- get: (ref) => new Promise((resolve, reject) => {
61
- client.get({ ref }, (err, response) => {
62
- if (err) {
63
- return (err === null || err === void 0 ? void 0 : err.code) === grpc.status.UNAVAILABLE
64
- ? reject(new errors_1.ServiceUnavailableError(`api server at ${apiAddr} is unavailable`))
65
- : reject(err);
66
- }
67
- // Convert back to Json
68
- response.spec = jsonFromStruct(response.spec);
69
- resolve(response);
70
- });
71
- }),
72
- findBy: (request) => new Promise((resolve, reject) => {
73
- request.parameters = jsonToStruct(request.parameters);
74
- client.findBy(request, (err, response) => {
75
- var _a;
76
- if (err) {
77
- return (err === null || err === void 0 ? void 0 : err.code) === grpc.status.UNAVAILABLE
78
- ? reject(new errors_1.ServiceUnavailableError(`api server at ${apiAddr} is unavailable`))
79
- : reject(err);
80
- }
81
- const res = (_a = response === null || response === void 0 ? void 0 : response.resources) === null || _a === void 0 ? void 0 : _a.map((resource) => {
82
- // Convert back to Json
83
- resource.spec = jsonFromStruct(resource.spec);
84
- return resource;
85
- });
86
- resolve(res);
87
- });
88
- })
89
- };
90
- }
91
- exports.dataAPI = dataAPI;
@@ -1 +0,0 @@
1
- export declare const RESOURCES_PROTO: any;
@@ -1,108 +0,0 @@
1
- // TODO: Show a link to were this proto was downloaded from
2
- syntax = "proto3";
3
-
4
- package fonoster.routr.resources.v2draft1;
5
-
6
- import "google/protobuf/struct.proto";
7
-
8
- // Resources service
9
- service Resources {
10
- rpc Create (CreateRequest) returns (Resource) {}
11
- rpc Update (UpdateRequest) returns (Resource) {}
12
- rpc Get (GetRequest) returns (Resource) {}
13
- rpc Delete (DeleteRequest) returns (Empty) {}
14
- rpc List (ListRequest) returns (ListResponse) {}
15
- rpc FindBy (FindByRequest) returns (FindByResponse) {}
16
- }
17
-
18
- message Metadata {
19
- // The resource's name
20
- string name = 1;
21
- // Created at
22
- int32 create_time = 2;
23
- // Updated at
24
- int32 update_time = 3;
25
- }
26
-
27
- message Resource {
28
- // The resource's api version
29
- string apiVersion = 1;
30
- // The resource's kind
31
- string kind = 2;
32
- // The resource's unique identifier
33
- string ref = 3;
34
- // The resource's metadata
35
- Metadata metadata = 4;
36
- // The resource's data
37
- .google.protobuf.Struct spec = 5;
38
- }
39
-
40
- message CreateRequest {
41
- Metadata metadata = 1;
42
- .google.protobuf.Struct spec = 2;
43
- }
44
-
45
- message UpdateRequest {
46
- Metadata metadata = 1;
47
- .google.protobuf.Struct spec = 2;
48
- }
49
-
50
- message DeleteRequest {
51
- string ref = 1;
52
- }
53
-
54
- message GetRequest {
55
- string ref = 1;
56
- }
57
-
58
- message ListRequest {
59
- // The maximum number of items in the list
60
- int32 page_size = 1;
61
-
62
- // The next_page_token value returned from the previous request, if any
63
- string page_token = 2;
64
-
65
- // The filter to apply to the list
66
- string filter = 3;
67
-
68
- // The type of resource to list
69
- string kind = 4;
70
-
71
- // Level of detail of the individual entities (reserved)
72
- View view = 5;
73
- }
74
-
75
- message ListResponse {
76
- // List of Resources
77
- repeated Resource resources = 1;
78
-
79
- // Token to retrieve the next page of results, or empty if there are no more results in the list
80
- string next_page_token = 2;
81
- }
82
-
83
- message FindByRequest {
84
- // The type of resource to find
85
- string kind = 1;
86
-
87
- // Search criteria for the request
88
- string criteria = 2;
89
-
90
- // Parameters to apply in combination with the search criteria
91
- .google.protobuf.Struct parameters = 3;
92
-
93
- // Level of detail of the individual entities (reserved)
94
- View view = 4;
95
- }
96
-
97
- message FindByResponse {
98
- // List of Resources
99
- repeated Resource resources = 1;
100
- }
101
-
102
- enum View {
103
- BASIC = 0;
104
- STANDARD = 1;
105
- FULL = 2;
106
- }
107
-
108
- message Empty {}