@fonoster/common 0.27.0 → 0.30.0

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 (176) hide show
  1. package/dist/assistants/index.d.ts +2 -6
  2. package/dist/assistants/index.js +2 -6
  3. package/dist/assistants/sessionAssistantSchema.d.ts +741 -0
  4. package/dist/assistants/sessionAssistantSchema.js +112 -0
  5. package/dist/assistants/testCasesSchema.d.ts +4 -4
  6. package/dist/{voice/Dial.d.ts → calls/index.d.ts} +16 -13
  7. package/dist/calls/index.js +44 -0
  8. package/dist/cellsecrets/index.d.ts +91 -0
  9. package/dist/cellsecrets/index.js +299 -0
  10. package/dist/config/cli/check.d.ts +6 -0
  11. package/dist/config/cli/check.js +202 -0
  12. package/dist/config/cli/envFile.d.ts +23 -0
  13. package/dist/config/cli/envFile.js +81 -0
  14. package/dist/config/cli/exposure.d.ts +10 -0
  15. package/dist/config/cli/exposure.js +93 -0
  16. package/dist/config/cli/index.d.ts +2 -0
  17. package/dist/{identity/tokenHasAccessKeyId.js → config/cli/index.js} +7 -8
  18. package/dist/config/cli/info.d.ts +6 -0
  19. package/dist/config/cli/info.js +62 -0
  20. package/dist/config/cli/init.d.ts +9 -0
  21. package/dist/config/cli/init.js +152 -0
  22. package/dist/config/cli/main.d.ts +11 -0
  23. package/dist/config/cli/main.js +155 -0
  24. package/dist/config/cli/render.d.ts +44 -0
  25. package/dist/config/cli/render.js +129 -0
  26. package/dist/config/cli/secrets.d.ts +21 -0
  27. package/dist/config/cli/secrets.js +117 -0
  28. package/dist/{utils/findIntegrationsCredentials.d.ts → config/cli/types.d.ts} +6 -5
  29. package/dist/config/cli/types.js +7 -0
  30. package/dist/config/configHints.d.ts +39 -0
  31. package/dist/config/configHints.js +61 -0
  32. package/dist/{voice → config}/index.d.ts +12 -13
  33. package/dist/config/index.js +46 -0
  34. package/dist/config/integrationsSchema.d.ts +32 -0
  35. package/dist/config/integrationsSchema.js +56 -0
  36. package/dist/config/interpolateEnv.d.ts +34 -0
  37. package/dist/config/interpolateEnv.js +70 -0
  38. package/dist/config/loadServiceConfig.d.ts +33 -0
  39. package/dist/config/loadServiceConfig.js +121 -0
  40. package/dist/config/logsSchema.d.ts +76 -0
  41. package/dist/config/logsSchema.js +49 -0
  42. package/dist/config/natsConnection.d.ts +53 -0
  43. package/dist/config/natsConnection.js +58 -0
  44. package/dist/config/parseConfigFile.d.ts +7 -0
  45. package/dist/config/parseConfigFile.js +60 -0
  46. package/dist/config/resolveConfigFile.d.ts +17 -0
  47. package/dist/config/resolveConfigFile.js +54 -0
  48. package/dist/config/resolveSecretRefs.d.ts +35 -0
  49. package/dist/config/resolveSecretRefs.js +129 -0
  50. package/dist/{assistants/audioFiltersSchema.d.ts → config/strictDeep.d.ts} +9 -12
  51. package/dist/config/strictDeep.js +58 -0
  52. package/dist/config/telemetrySchema.d.ts +39 -0
  53. package/dist/config/telemetrySchema.js +44 -0
  54. package/dist/config/toJsonSchema.d.ts +30 -0
  55. package/dist/config/toJsonSchema.js +161 -0
  56. package/dist/constants.d.ts +1 -4
  57. package/dist/constants.js +4 -5
  58. package/dist/envs.d.ts +2 -1
  59. package/dist/envs.js +13 -11
  60. package/dist/identity/createAuthInterceptor.d.ts +9 -2
  61. package/dist/identity/createAuthInterceptor.js +36 -30
  62. package/dist/identity/hasAccess.d.ts +9 -3
  63. package/dist/identity/hasAccess.js +32 -8
  64. package/dist/identity/index.d.ts +1 -0
  65. package/dist/identity/index.js +1 -0
  66. package/dist/identity/isValidToken.d.ts +12 -2
  67. package/dist/identity/isValidToken.js +25 -9
  68. package/dist/identity/roles.js +22 -6
  69. package/dist/identity/types.d.ts +6 -1
  70. package/dist/identity/types.js +1 -0
  71. package/dist/{assistants/LanguageModelProvider.js → identity/verifyAccessToken.d.ts} +10 -11
  72. package/dist/identity/verifyAccessToken.js +44 -0
  73. package/dist/index.d.ts +11 -1
  74. package/dist/index.js +14 -2
  75. package/dist/net/assertPublicDestination.d.ts +52 -0
  76. package/dist/net/assertPublicDestination.js +342 -0
  77. package/dist/{voice/PlayDtmf.d.ts → net/index.d.ts} +1 -5
  78. package/dist/{voice → net}/index.js +1 -13
  79. package/dist/notifications/createSendEmail.js +3 -1
  80. package/dist/protos/applications.proto +124 -3
  81. package/dist/protos/authz.proto +23 -4
  82. package/dist/protos/capabilities.proto +94 -0
  83. package/dist/protos/identity.proto +26 -1
  84. package/dist/protos/providers.proto +135 -0
  85. package/dist/protos/webhooks.proto +140 -0
  86. package/dist/{voice/StopSay.d.ts → regions/hub/index.d.ts} +1 -6
  87. package/dist/regions/hub/index.js +35 -0
  88. package/dist/regions/hub/natsJwt.d.ts +63 -0
  89. package/dist/regions/hub/natsJwt.js +195 -0
  90. package/dist/registry/Registry.d.ts +79 -0
  91. package/dist/registry/Registry.js +418 -0
  92. package/dist/registry/cli.d.ts +20 -0
  93. package/dist/registry/cli.js +424 -0
  94. package/dist/{assistants/audioFiltersSchema.js → registry/features.d.ts} +13 -14
  95. package/dist/registry/features.js +36 -0
  96. package/dist/{assistants/LanguageModelProvider.d.ts → registry/index.d.ts} +6 -8
  97. package/dist/registry/index.js +40 -0
  98. package/dist/registry/prisma.d.ts +67 -0
  99. package/dist/registry/prisma.js +391 -0
  100. package/dist/registry/stores.d.ts +21 -0
  101. package/dist/{assistants/eventsHookSchema.js → registry/stores.js} +55 -18
  102. package/dist/registry/types.d.ts +98 -0
  103. package/dist/{voice/Say.d.ts → registry/types.js} +4 -10
  104. package/dist/registry/workspaceKeys.d.ts +41 -0
  105. package/dist/registry/workspaceKeys.js +64 -0
  106. package/dist/session/index.d.ts +19 -0
  107. package/dist/session/index.js +35 -0
  108. package/dist/session/schema.d.ts +1951 -0
  109. package/dist/session/schema.js +397 -0
  110. package/dist/sessions/index.d.ts +93 -0
  111. package/dist/sessions/index.js +194 -0
  112. package/dist/telemetry.d.ts +76 -0
  113. package/dist/telemetry.js +360 -0
  114. package/dist/types.d.ts +3 -5
  115. package/dist/utils/{findIntegrationsCredentials.js → WriteBehind.d.ts} +13 -10
  116. package/dist/utils/WriteBehind.js +64 -0
  117. package/dist/utils/index.d.ts +1 -1
  118. package/dist/utils/index.js +1 -1
  119. package/dist/{voice/Play.d.ts → utils/logUnhandledRejections.d.ts} +8 -12
  120. package/dist/utils/logUnhandledRejections.js +37 -0
  121. package/dist/validators/calls.d.ts +2 -2
  122. package/dist/validators/calls.js +5 -2
  123. package/dist/validators/identity.d.ts +37 -8
  124. package/dist/validators/identity.js +22 -3
  125. package/dist/validators/index.d.ts +1 -0
  126. package/dist/validators/index.js +1 -0
  127. package/dist/validators/sip.d.ts +40 -0
  128. package/dist/validators/sip.js +99 -0
  129. package/dist/validators/sipnet/credentials.d.ts +2 -2
  130. package/dist/validators/sipnet/domains.js +7 -7
  131. package/dist/validators/sipnet/trunks.d.ts +14 -14
  132. package/dist/validators/sipnet/trunks.js +4 -2
  133. package/dist/webhooks/Dispatcher.d.ts +87 -0
  134. package/dist/webhooks/Dispatcher.js +225 -0
  135. package/dist/webhooks/bus.d.ts +49 -0
  136. package/dist/webhooks/bus.js +170 -0
  137. package/dist/webhooks/events.d.ts +66 -0
  138. package/dist/webhooks/events.js +62 -0
  139. package/dist/webhooks/index.d.ts +23 -0
  140. package/dist/webhooks/index.js +39 -0
  141. package/dist/webhooks/prisma.d.ts +55 -0
  142. package/dist/webhooks/prisma.js +242 -0
  143. package/dist/webhooks/signing.d.ts +8 -0
  144. package/dist/webhooks/signing.js +53 -0
  145. package/package.json +25 -12
  146. package/schema/session.v1.json +791 -0
  147. package/dist/assistants/assistantSchema.d.ts +0 -739
  148. package/dist/assistants/assistantSchema.js +0 -37
  149. package/dist/assistants/conversationSettingsSchema.d.ts +0 -122
  150. package/dist/assistants/conversationSettingsSchema.js +0 -133
  151. package/dist/assistants/eventsHookSchema.d.ts +0 -38
  152. package/dist/assistants/languageModelConfigSchema.d.ts +0 -206
  153. package/dist/assistants/languageModelConfigSchema.js +0 -91
  154. package/dist/identity/tokenHasAccessKeyId.d.ts +0 -2
  155. package/dist/protos/voice.proto +0 -557
  156. package/dist/voice/Dial.js +0 -20
  157. package/dist/voice/Gather.d.ts +0 -37
  158. package/dist/voice/Gather.js +0 -9
  159. package/dist/voice/Mute.d.ts +0 -31
  160. package/dist/voice/Mute.js +0 -9
  161. package/dist/voice/Play.js +0 -2
  162. package/dist/voice/PlayDtmf.js +0 -2
  163. package/dist/voice/PlaybackControl.d.ts +0 -31
  164. package/dist/voice/PlaybackControl.js +0 -11
  165. package/dist/voice/Record.d.ts +0 -36
  166. package/dist/voice/Record.js +0 -7
  167. package/dist/voice/Say.js +0 -2
  168. package/dist/voice/StopSay.js +0 -2
  169. package/dist/voice/Stream.d.ts +0 -53
  170. package/dist/voice/Stream.js +0 -19
  171. package/dist/voice/StreamGather.d.ts +0 -34
  172. package/dist/voice/StreamGather.js +0 -9
  173. package/dist/voice/Verb.d.ts +0 -27
  174. package/dist/voice/Verb.js +0 -2
  175. package/dist/voice/voice.d.ts +0 -171
  176. package/dist/voice/voice.js +0 -65
@@ -20,10 +20,14 @@ import { Role } from "@fonoster/types";
20
20
  import { z } from "zod";
21
21
  declare const createWorkspaceRequestSchema: z.ZodObject<{
22
22
  name: z.ZodString;
23
+ /** An offered public region id, or one of the caller's private regions (id or rg_ ref). */
24
+ region: z.ZodOptional<z.ZodString>;
23
25
  }, "strip", z.ZodTypeAny, {
24
26
  name?: string;
27
+ region?: string;
25
28
  }, {
26
29
  name?: string;
30
+ region?: string;
27
31
  }>;
28
32
  declare const createApiKeyRequestSchema: z.ZodObject<{
29
33
  role: z.ZodEnum<[Role.WORKSPACE_ADMIN]>;
@@ -50,12 +54,12 @@ declare const exchangeCredentialsRequestSchema: z.ZodObject<{
50
54
  password: z.ZodString;
51
55
  twoFactorCode: z.ZodOptional<z.ZodString>;
52
56
  }, "strip", z.ZodTypeAny, {
53
- username?: string;
54
57
  password?: string;
58
+ username?: string;
55
59
  twoFactorCode?: string;
56
60
  }, {
57
- username?: string;
58
61
  password?: string;
62
+ username?: string;
59
63
  twoFactorCode?: string;
60
64
  }>;
61
65
  declare const exchangeOauth2RequestSchema: z.ZodObject<{
@@ -68,6 +72,16 @@ declare const exchangeOauth2RequestSchema: z.ZodObject<{
68
72
  code?: string;
69
73
  provider?: "GITHUB";
70
74
  }>;
75
+ declare const exchangeVerificationCodeRequestSchema: z.ZodObject<{
76
+ email: z.ZodString;
77
+ code: z.ZodString;
78
+ }, "strip", z.ZodTypeAny, {
79
+ code?: string;
80
+ email?: string;
81
+ }, {
82
+ code?: string;
83
+ email?: string;
84
+ }>;
71
85
  declare const exchangeRefreshTokenRequestSchema: z.ZodObject<{
72
86
  refreshToken: z.ZodString;
73
87
  }, "strip", z.ZodTypeAny, {
@@ -75,6 +89,13 @@ declare const exchangeRefreshTokenRequestSchema: z.ZodObject<{
75
89
  }, {
76
90
  refreshToken?: string;
77
91
  }>;
92
+ declare const revokeTokenRequestSchema: z.ZodObject<{
93
+ token: z.ZodString;
94
+ }, "strip", z.ZodTypeAny, {
95
+ token?: string;
96
+ }, {
97
+ token?: string;
98
+ }>;
78
99
  declare const createUserRequestSchema: z.ZodObject<{
79
100
  name: z.ZodString;
80
101
  email: z.ZodString;
@@ -106,6 +127,7 @@ declare const updateUserRequestSchema: z.ZodObject<{
106
127
  name: z.ZodUnion<[z.ZodString, z.ZodOptional<z.ZodString>]>;
107
128
  phone: z.ZodOptional<z.ZodString>;
108
129
  password: z.ZodUnion<[z.ZodString, z.ZodOptional<z.ZodString>]>;
130
+ currentPassword: z.ZodOptional<z.ZodString>;
109
131
  avatar: z.ZodUnion<[z.ZodString, z.ZodOptional<z.ZodString>]>;
110
132
  }, "strip", z.ZodTypeAny, {
111
133
  name?: string;
@@ -113,12 +135,14 @@ declare const updateUserRequestSchema: z.ZodObject<{
113
135
  password?: string;
114
136
  phone?: string;
115
137
  avatar?: string;
138
+ currentPassword?: string;
116
139
  }, {
117
140
  name?: string;
118
141
  ref?: string;
119
142
  password?: string;
120
143
  phone?: string;
121
144
  avatar?: string;
145
+ currentPassword?: string;
122
146
  }>;
123
147
  declare const inviteUserToWorkspaceRequestSchema: z.ZodObject<{
124
148
  email: z.ZodString;
@@ -128,13 +152,13 @@ declare const inviteUserToWorkspaceRequestSchema: z.ZodObject<{
128
152
  }, "strip", z.ZodTypeAny, {
129
153
  name?: string;
130
154
  email?: string;
131
- role?: Role.WORKSPACE_ADMIN | Role.WORKSPACE_MEMBER;
132
155
  password?: string;
156
+ role?: Role.WORKSPACE_ADMIN | Role.WORKSPACE_MEMBER;
133
157
  }, {
134
158
  name?: string;
135
159
  email?: string;
136
- role?: Role.WORKSPACE_ADMIN | Role.WORKSPACE_MEMBER;
137
160
  password?: string;
161
+ role?: Role.WORKSPACE_ADMIN | Role.WORKSPACE_MEMBER;
138
162
  }>;
139
163
  declare const resendWorkspaceMembershipInvitationRequestSchema: z.ZodObject<{
140
164
  userRef: z.ZodString;
@@ -145,13 +169,17 @@ declare const resendWorkspaceMembershipInvitationRequestSchema: z.ZodObject<{
145
169
  }>;
146
170
  declare const updateWorkspaceRequestSchema: z.ZodObject<{
147
171
  ref: z.ZodString;
172
+ /** Only accepted when unchanged: the region is immutable (region_immutable). */
173
+ region: z.ZodOptional<z.ZodString>;
148
174
  name: z.ZodUnion<[z.ZodString, z.ZodOptional<z.ZodString>]>;
149
175
  }, "strip", z.ZodTypeAny, {
150
176
  name?: string;
151
177
  ref?: string;
178
+ region?: string;
152
179
  }, {
153
180
  name?: string;
154
181
  ref?: string;
182
+ region?: string;
155
183
  }>;
156
184
  declare const removeUserFromWorkspaceRequestSchema: z.ZodObject<{
157
185
  userRef: z.ZodString;
@@ -188,7 +216,8 @@ declare const verifyCodeRequestSchema: z.ZodObject<{
188
216
  }>;
189
217
  declare const sendResetPasswordCodeRequestSchema: z.ZodObject<{
190
218
  username: z.ZodString;
191
- resetPasswordUrl: z.ZodString;
219
+ /** Ignored: the link is built from Identity's configured reset URL. */
220
+ resetPasswordUrl: z.ZodOptional<z.ZodString>;
192
221
  }, "strip", z.ZodTypeAny, {
193
222
  username?: string;
194
223
  resetPasswordUrl?: string;
@@ -201,12 +230,12 @@ declare const resetPasswordRequestSchema: z.ZodObject<{
201
230
  password: z.ZodString;
202
231
  verificationCode: z.ZodString;
203
232
  }, "strip", z.ZodTypeAny, {
204
- username?: string;
205
233
  password?: string;
234
+ username?: string;
206
235
  verificationCode?: string;
207
236
  }, {
208
- username?: string;
209
237
  password?: string;
238
+ username?: string;
210
239
  verificationCode?: string;
211
240
  }>;
212
- export { createApiKeyRequestSchema, createUserRequestSchema, createWorkspaceRequestSchema, exchangeApiKeysRequestSchema, exchangeCredentialsRequestSchema, exchangeOauth2RequestSchema, exchangeRefreshTokenRequestSchema, inviteUserToWorkspaceRequestSchema, removeUserFromWorkspaceRequestSchema, resendWorkspaceMembershipInvitationRequestSchema, sendVerificationCodeRequestSchema, updateUserRequestSchema, updateWorkspaceRequestSchema, verifyCodeRequestSchema, sendResetPasswordCodeRequestSchema, resetPasswordRequestSchema, createUserWithOauth2CodeRequestSchema };
241
+ export { createApiKeyRequestSchema, createUserRequestSchema, createWorkspaceRequestSchema, exchangeApiKeysRequestSchema, exchangeCredentialsRequestSchema, exchangeOauth2RequestSchema, exchangeRefreshTokenRequestSchema, exchangeVerificationCodeRequestSchema, inviteUserToWorkspaceRequestSchema, removeUserFromWorkspaceRequestSchema, resendWorkspaceMembershipInvitationRequestSchema, revokeTokenRequestSchema, sendVerificationCodeRequestSchema, updateUserRequestSchema, updateWorkspaceRequestSchema, verifyCodeRequestSchema, sendResetPasswordCodeRequestSchema, resetPasswordRequestSchema, createUserWithOauth2CodeRequestSchema };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createUserWithOauth2CodeRequestSchema = exports.resetPasswordRequestSchema = exports.sendResetPasswordCodeRequestSchema = exports.verifyCodeRequestSchema = exports.updateWorkspaceRequestSchema = exports.updateUserRequestSchema = exports.sendVerificationCodeRequestSchema = exports.resendWorkspaceMembershipInvitationRequestSchema = exports.removeUserFromWorkspaceRequestSchema = exports.inviteUserToWorkspaceRequestSchema = exports.exchangeRefreshTokenRequestSchema = exports.exchangeOauth2RequestSchema = exports.exchangeCredentialsRequestSchema = exports.exchangeApiKeysRequestSchema = exports.createWorkspaceRequestSchema = exports.createUserRequestSchema = exports.createApiKeyRequestSchema = void 0;
3
+ exports.createUserWithOauth2CodeRequestSchema = exports.resetPasswordRequestSchema = exports.sendResetPasswordCodeRequestSchema = exports.verifyCodeRequestSchema = exports.updateWorkspaceRequestSchema = exports.updateUserRequestSchema = exports.sendVerificationCodeRequestSchema = exports.revokeTokenRequestSchema = exports.resendWorkspaceMembershipInvitationRequestSchema = exports.removeUserFromWorkspaceRequestSchema = exports.inviteUserToWorkspaceRequestSchema = exports.exchangeVerificationCodeRequestSchema = exports.exchangeRefreshTokenRequestSchema = exports.exchangeOauth2RequestSchema = exports.exchangeCredentialsRequestSchema = exports.exchangeApiKeysRequestSchema = exports.createWorkspaceRequestSchema = exports.createUserRequestSchema = exports.createApiKeyRequestSchema = void 0;
4
4
  /**
5
5
  * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
6
6
  * http://github.com/fonoster/fonoster
@@ -32,7 +32,13 @@ const createWorkspaceRequestSchema = zod_1.z.object({
32
32
  name: zod_1.z
33
33
  .string()
34
34
  .min(1, { message: MIN_NAME_MESSAGE })
35
- .max(50, { message: MAX_NAME_MESSAGE })
35
+ .max(50, { message: MAX_NAME_MESSAGE }),
36
+ /** An offered public region id, or one of the caller's private regions (id or rg_ ref). */
37
+ region: zod_1.z
38
+ .string()
39
+ .max(64)
40
+ .regex(/^[a-z0-9_-]*$/, { message: "Invalid region" })
41
+ .optional()
36
42
  });
37
43
  exports.createWorkspaceRequestSchema = createWorkspaceRequestSchema;
38
44
  const createApiKeyRequestSchema = zod_1.z.object({
@@ -62,10 +68,19 @@ const exchangeOauth2RequestSchema = zod_1.z.object({
62
68
  code: zod_1.z.string()
63
69
  });
64
70
  exports.exchangeOauth2RequestSchema = exchangeOauth2RequestSchema;
71
+ const exchangeVerificationCodeRequestSchema = zod_1.z.object({
72
+ email: zod_1.z.string().email({ message: EMAIL_MESSAGE }),
73
+ code: zod_1.z.string().regex(/^\d{6}$/, { message: "Must be a 6-digit code" })
74
+ });
75
+ exports.exchangeVerificationCodeRequestSchema = exchangeVerificationCodeRequestSchema;
65
76
  const exchangeRefreshTokenRequestSchema = zod_1.z.object({
66
77
  refreshToken: zod_1.z.string()
67
78
  });
68
79
  exports.exchangeRefreshTokenRequestSchema = exchangeRefreshTokenRequestSchema;
80
+ const revokeTokenRequestSchema = zod_1.z.object({
81
+ token: zod_1.z.string()
82
+ });
83
+ exports.revokeTokenRequestSchema = revokeTokenRequestSchema;
69
84
  const createUserRequestSchema = zod_1.z.object({
70
85
  name: zod_1.z.string().max(50, { message: MAX_NAME_MESSAGE }),
71
86
  email: zod_1.z.string().email({ message: EMAIL_MESSAGE }),
@@ -93,6 +108,7 @@ const updateUserRequestSchema = zod_1.z.object({
93
108
  .string()
94
109
  .min(8, { message: PASSWORD_MESSAGE })
95
110
  .or(zod_1.z.string().optional()),
111
+ currentPassword: zod_1.z.string().max(1024).optional(),
96
112
  avatar: zod_1.z.string().url().or(zod_1.z.string().optional())
97
113
  });
98
114
  exports.updateUserRequestSchema = updateUserRequestSchema;
@@ -109,6 +125,8 @@ const resendWorkspaceMembershipInvitationRequestSchema = zod_1.z.object({
109
125
  exports.resendWorkspaceMembershipInvitationRequestSchema = resendWorkspaceMembershipInvitationRequestSchema;
110
126
  const updateWorkspaceRequestSchema = zod_1.z.object({
111
127
  ref: zod_1.z.string().uuid({ message: WORKSPACE_REF_MESSAGE }),
128
+ /** Only accepted when unchanged: the region is immutable (region_immutable). */
129
+ region: zod_1.z.string().max(64).optional(),
112
130
  name: zod_1.z
113
131
  .string()
114
132
  .min(1, { message: MIN_NAME_MESSAGE })
@@ -136,7 +154,8 @@ const sendResetPasswordCodeRequestSchema = zod_1.z.object({
136
154
  username: zod_1.z
137
155
  .string()
138
156
  .email({ message: "Invalid username. Must be an email address" }),
139
- resetPasswordUrl: zod_1.z.string()
157
+ /** Ignored: the link is built from Identity's configured reset URL. */
158
+ resetPasswordUrl: zod_1.z.string().optional()
140
159
  });
141
160
  exports.sendResetPasswordCodeRequestSchema = sendResetPasswordCodeRequestSchema;
142
161
  const resetPasswordRequestSchema = zod_1.z.object({
@@ -22,3 +22,4 @@ export * from "./hostOrHostPortSchema";
22
22
  export * from "./identity";
23
23
  export * from "./secrets";
24
24
  export * from "./sipnet";
25
+ export * from "./sip";
@@ -38,3 +38,4 @@ __exportStar(require("./hostOrHostPortSchema"), exports);
38
38
  __exportStar(require("./identity"), exports);
39
39
  __exportStar(require("./secrets"), exports);
40
40
  __exportStar(require("./sipnet"), exports);
41
+ __exportStar(require("./sip"), exports);
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
3
+ * http://github.com/fonoster/fonoster
4
+ *
5
+ * This file is part of Fonoster
6
+ *
7
+ * Licensed under the MIT License (the "License");
8
+ * you may not use this file except in compliance with
9
+ * the License. You may obtain a copy of the License at
10
+ *
11
+ * https://opensource.org/licenses/MIT
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ import { z } from "zod";
20
+ /**
21
+ * Headers the platform (Routr, the media node, the gateway, the apiserver) sets and trusts: they
22
+ * pick the app, the call, the workspace and the trunk. Callers and apps may never set them.
23
+ */
24
+ export declare const RESERVED_SIP_HEADERS: ReadonlySet<string>;
25
+ /** Custom headers only: `X-` (any case) and up to 64 letters, digits or dashes. */
26
+ export declare const SIP_HEADER_NAME: RegExp;
27
+ export declare const SIP_HEADER_VALUE_MAX = 256;
28
+ export declare const SIP_HEADERS_MAX = 16;
29
+ /** E.164: a leading `+` is optional, up to 15 digits, no leading zero. */
30
+ export declare const E164: RegExp;
31
+ /** A dial target: an E.164 number, a SIP user, or `sip:`/`sips:user@host[:port]`. */
32
+ export declare const SIP_TARGET: RegExp;
33
+ /** Why a custom SIP header may not be sent (undefined: it may). */
34
+ export declare function sipHeaderProblem(name: string, value: unknown): string | undefined;
35
+ /** Why a set of custom SIP headers may not be sent (undefined: they may). */
36
+ export declare function sipHeadersProblem(headers: unknown): string | undefined;
37
+ /** Whether `to` is a target the media node may dial or refer to. */
38
+ export declare function isSipTarget(to: unknown): to is string;
39
+ export declare const e164Schema: z.ZodString;
40
+ export declare const sipTargetSchema: z.ZodString;
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sipTargetSchema = exports.e164Schema = exports.SIP_TARGET = exports.E164 = exports.SIP_HEADERS_MAX = exports.SIP_HEADER_VALUE_MAX = exports.SIP_HEADER_NAME = exports.RESERVED_SIP_HEADERS = void 0;
4
+ exports.sipHeaderProblem = sipHeaderProblem;
5
+ exports.sipHeadersProblem = sipHeadersProblem;
6
+ exports.isSipTarget = isSipTarget;
7
+ /**
8
+ * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
9
+ * http://github.com/fonoster/fonoster
10
+ *
11
+ * This file is part of Fonoster
12
+ *
13
+ * Licensed under the MIT License (the "License");
14
+ * you may not use this file except in compliance with
15
+ * the License. You may obtain a copy of the License at
16
+ *
17
+ * https://opensource.org/licenses/MIT
18
+ *
19
+ * Unless required by applicable law or agreed to in writing, software
20
+ * distributed under the License is distributed on an "AS IS" BASIS,
21
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
+ * See the License for the specific language governing permissions and
23
+ * limitations under the License.
24
+ */
25
+ const zod_1 = require("zod");
26
+ // What apps and API callers may put into a SIP request the platform sends (CreateCall's
27
+ // from/to, the `transfer` command's target and headers). sipgo does not escape header values or
28
+ // URI users, so anything that reaches an INVITE or REFER must be safe as-is.
29
+ /**
30
+ * Headers the platform (Routr, the media node, the gateway, the apiserver) sets and trusts: they
31
+ * pick the app, the call, the workspace and the trunk. Callers and apps may never set them.
32
+ */
33
+ exports.RESERVED_SIP_HEADERS = new Set([
34
+ "X-App-Ref",
35
+ "X-Call-Ref",
36
+ "X-Call-Direction",
37
+ "X-Dod-Number",
38
+ "X-Dod-Privacy",
39
+ "X-Access-Key-Id",
40
+ "X-Is-Api-Originated-Type",
41
+ "X-Connect-Token",
42
+ "X-Edgeport-Ref",
43
+ "X-Gateway-Auth",
44
+ "X-Request-Uri",
45
+ "X-Session-Count"
46
+ ].map((h) => h.toLowerCase()));
47
+ /** Custom headers only: `X-` (any case) and up to 64 letters, digits or dashes. */
48
+ exports.SIP_HEADER_NAME = /^X-[A-Za-z0-9-]{1,64}$/i;
49
+ exports.SIP_HEADER_VALUE_MAX = 256;
50
+ exports.SIP_HEADERS_MAX = 16;
51
+ /** E.164: a leading `+` is optional, up to 15 digits, no leading zero. */
52
+ exports.E164 = /^\+?[1-9][0-9]{1,14}$/;
53
+ // The user part of a SIP URI as the node dials it (a number, an extension or an agent name).
54
+ const SIP_USER = "[A-Za-z0-9+*#._~-]{1,64}";
55
+ const SIP_HOST = "[A-Za-z0-9](?:[A-Za-z0-9.-]{0,251}[A-Za-z0-9])?(?::[0-9]{1,5})?";
56
+ /** A dial target: an E.164 number, a SIP user, or `sip:`/`sips:user@host[:port]`. */
57
+ exports.SIP_TARGET = new RegExp(`^(?:${SIP_USER}|sips?:${SIP_USER}@${SIP_HOST}|tel:\\+?[0-9*#-]{1,32})$`);
58
+ /** Why a custom SIP header may not be sent (undefined: it may). */
59
+ function sipHeaderProblem(name, value) {
60
+ if (!exports.SIP_HEADER_NAME.test(name))
61
+ return `header ${JSON.stringify(name)} is not an X- header name`;
62
+ if (exports.RESERVED_SIP_HEADERS.has(name.toLowerCase()))
63
+ return `header ${name} is reserved for the platform`;
64
+ if (typeof value !== "string")
65
+ return `header ${name} must be a string`;
66
+ if (value.length > exports.SIP_HEADER_VALUE_MAX)
67
+ return `header ${name} is longer than ${exports.SIP_HEADER_VALUE_MAX} characters`;
68
+ // CR, LF and every other control character (a tab is allowed).
69
+ // eslint-disable-next-line no-control-regex
70
+ if (/[\u0000-\u0008\u000a-\u001f\u007f]/.test(value))
71
+ return `header ${name} has control characters`;
72
+ return undefined;
73
+ }
74
+ /** Why a set of custom SIP headers may not be sent (undefined: they may). */
75
+ function sipHeadersProblem(headers) {
76
+ if (headers === undefined || headers === null)
77
+ return undefined;
78
+ if (typeof headers !== "object" || Array.isArray(headers))
79
+ return "headers must be an object";
80
+ const entries = Object.entries(headers);
81
+ if (entries.length > exports.SIP_HEADERS_MAX)
82
+ return `at most ${exports.SIP_HEADERS_MAX} headers`;
83
+ for (const [name, value] of entries) {
84
+ const problem = sipHeaderProblem(name, value);
85
+ if (problem)
86
+ return problem;
87
+ }
88
+ return undefined;
89
+ }
90
+ /** Whether `to` is a target the media node may dial or refer to. */
91
+ function isSipTarget(to) {
92
+ return typeof to === "string" && exports.SIP_TARGET.test(to);
93
+ }
94
+ exports.e164Schema = zod_1.z
95
+ .string()
96
+ .regex(exports.E164, { message: "Must be an E.164 number (e.g. +17853178070)" });
97
+ exports.sipTargetSchema = zod_1.z.string().regex(exports.SIP_TARGET, {
98
+ message: "Must be an E.164 number, a SIP user or a sip: URI"
99
+ });
@@ -23,12 +23,12 @@ declare const createCredentialsRequestSchema: z.ZodObject<{
23
23
  password: z.ZodString;
24
24
  }, "strip", z.ZodTypeAny, {
25
25
  name?: string;
26
- username?: string;
27
26
  password?: string;
27
+ username?: string;
28
28
  }, {
29
29
  name?: string;
30
- username?: string;
31
30
  password?: string;
31
+ username?: string;
32
32
  }>;
33
33
  declare const updateCredentialsRequestSchema: z.ZodObject<{
34
34
  name: z.ZodString;
@@ -27,14 +27,14 @@ const domainSchema = zod_1.z
27
27
  .refine((domain) => {
28
28
  const domainRegex = /^[a-zA-Z0-9-]+(\.[a-zA-Z]{2,})+$/;
29
29
  return domainRegex.test(domain);
30
- }, {
31
- message: `Invalid domain format. Should be like: "acme.${envs_1.ROOT_DOMAIN}"`
32
- })
30
+ }, () => ({
31
+ message: `Invalid domain format. Should be like: "acme.${(0, envs_1.getRootDomain)()}"`
32
+ }))
33
33
  .refine((domain) => {
34
- return domain.endsWith(envs_1.ROOT_DOMAIN);
35
- }, {
36
- message: `Domain must end with "${envs_1.ROOT_DOMAIN}"`
37
- });
34
+ return domain.endsWith((0, envs_1.getRootDomain)());
35
+ }, () => ({
36
+ message: `Domain must end with "${(0, envs_1.getRootDomain)()}"`
37
+ }));
38
38
  const createDomainRequestSchema = zod_1.z.object({
39
39
  name: common_1.nameSchema,
40
40
  domainUri: domainSchema,
@@ -20,7 +20,7 @@ import { Transport } from "@fonoster/types";
20
20
  import { z } from "zod";
21
21
  declare const createTrunkRequestSchema: z.ZodObject<{
22
22
  name: z.ZodString;
23
- sendRegister: z.ZodBoolean;
23
+ sendRegister: z.ZodOptional<z.ZodBoolean>;
24
24
  inboundUri: z.ZodEffects<z.ZodString, string, string>;
25
25
  uris: z.ZodArray<z.ZodObject<{
26
26
  host: z.ZodEffects<z.ZodString, string, string>;
@@ -29,49 +29,49 @@ declare const createTrunkRequestSchema: z.ZodObject<{
29
29
  user: z.ZodOptional<z.ZodString>;
30
30
  weight: z.ZodNumber;
31
31
  priority: z.ZodNumber;
32
- enabled: z.ZodBoolean;
32
+ enabled: z.ZodOptional<z.ZodBoolean>;
33
33
  }, "strip", z.ZodTypeAny, {
34
+ transport?: Transport;
34
35
  host?: string;
35
36
  port?: number;
36
- priority?: number;
37
- enabled?: boolean;
38
- transport?: Transport;
39
37
  user?: string;
38
+ enabled?: boolean;
40
39
  weight?: number;
40
+ priority?: number;
41
41
  }, {
42
+ transport?: Transport;
42
43
  host?: string;
43
44
  port?: number;
44
- priority?: number;
45
- enabled?: boolean;
46
- transport?: Transport;
47
45
  user?: string;
46
+ enabled?: boolean;
48
47
  weight?: number;
48
+ priority?: number;
49
49
  }>, "many">;
50
50
  }, "strip", z.ZodTypeAny, {
51
51
  name?: string;
52
52
  sendRegister?: boolean;
53
53
  inboundUri?: string;
54
54
  uris?: {
55
+ transport?: Transport;
55
56
  host?: string;
56
57
  port?: number;
57
- priority?: number;
58
- enabled?: boolean;
59
- transport?: Transport;
60
58
  user?: string;
59
+ enabled?: boolean;
61
60
  weight?: number;
61
+ priority?: number;
62
62
  }[];
63
63
  }, {
64
64
  name?: string;
65
65
  sendRegister?: boolean;
66
66
  inboundUri?: string;
67
67
  uris?: {
68
+ transport?: Transport;
68
69
  host?: string;
69
70
  port?: number;
70
- priority?: number;
71
- enabled?: boolean;
72
- transport?: Transport;
73
71
  user?: string;
72
+ enabled?: boolean;
74
73
  weight?: number;
74
+ priority?: number;
75
75
  }[];
76
76
  }>;
77
77
  declare const updateTrunkRequestSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
@@ -61,9 +61,11 @@ const hostOrIPSchema = zod_1.z
61
61
  .refine((host) => Validator.isIP(host, 4) || Validator.isFQDN(host), {
62
62
  message: "Must be a valid IP or FQDN"
63
63
  });
64
+ // Booleans are optional: the gRPC loader drops proto3 defaults, so `false`
65
+ // arrives as a missing field.
64
66
  const createTrunkRequestSchema = zod_1.z.object({
65
67
  name: common_1.nameSchema,
66
- sendRegister: zod_1.z.boolean(),
68
+ sendRegister: zod_1.z.boolean().optional(),
67
69
  inboundUri: hostOrIPSchema,
68
70
  uris: zod_1.z.array(zod_1.z.object({
69
71
  host: hostOrIPSchema,
@@ -72,7 +74,7 @@ const createTrunkRequestSchema = zod_1.z.object({
72
74
  user: zod_1.z.string().optional(),
73
75
  weight: zod_1.z.number(),
74
76
  priority: zod_1.z.number(),
75
- enabled: zod_1.z.boolean()
77
+ enabled: zod_1.z.boolean().optional()
76
78
  }))
77
79
  });
78
80
  exports.createTrunkRequestSchema = createTrunkRequestSchema;
@@ -0,0 +1,87 @@
1
+ import { WebhookEvent, WebhookEventType } from "./events";
2
+ export type WebhookEndpoint = {
3
+ id: string;
4
+ workspaceRef: string;
5
+ url: string;
6
+ events: WebhookEventType[];
7
+ secret: string;
8
+ /** The previous secret stays valid until `previousUntil` (rotation window). */
9
+ previousSecret?: string;
10
+ previousUntil?: number;
11
+ };
12
+ export type Delivery = {
13
+ id: string;
14
+ endpointId: string;
15
+ event: WebhookEvent;
16
+ status: "pending" | "succeeded" | "failed";
17
+ attempts: number;
18
+ firstAttemptAt?: number;
19
+ lastAttemptAt?: number;
20
+ lastStatus?: number;
21
+ nextAttemptAt: number;
22
+ };
23
+ export interface WebhookStore {
24
+ endpoints(workspaceRef?: string): WebhookEndpoint[];
25
+ putEndpoint(e: WebhookEndpoint): void;
26
+ deleteEndpoint(id: string): void;
27
+ deliveries(endpointId?: string): Delivery[];
28
+ putDelivery(d: Delivery): void;
29
+ }
30
+ export declare class MemoryWebhookStore implements WebhookStore {
31
+ private e;
32
+ private d;
33
+ endpoints(workspaceRef?: string): WebhookEndpoint[];
34
+ putEndpoint(x: WebhookEndpoint): void;
35
+ deleteEndpoint(id: string): void;
36
+ deliveries(endpointId?: string): Delivery[];
37
+ putDelivery(x: Delivery): void;
38
+ }
39
+ export declare class WebhookError extends Error {
40
+ }
41
+ /**
42
+ * The id of an event's delivery to one endpoint. It depends only on the two, so the same event
43
+ * fanned out again (a bus message redelivered after a replica died, or published twice) finds
44
+ * the delivery it already made instead of making a second one (ST-2).
45
+ */
46
+ export declare function deliveryId(eventId: string, endpointId: string): string;
47
+ export type DispatcherOptions = {
48
+ store: WebhookStore;
49
+ /** Per-attempt timeout (design OQ3 proposal: 10 s). */
50
+ attemptTimeoutMs?: number;
51
+ /** First retry delay; each next one doubles, capped at maxDelayMs (OQ2: from 10 s). */
52
+ firstDelayMs?: number;
53
+ maxDelayMs?: number;
54
+ /** Retries stop this long after the first attempt (OQ2: 24 h). */
55
+ retryPeriodMs?: number;
56
+ /** Lets tests use plain http:// receivers. Never in production. */
57
+ allowInsecureUrls?: boolean;
58
+ /**
59
+ * Private destinations (host names, IPs, CIDRs) endpoints may use; defaults to
60
+ * FONOSTER_ALLOWED_DESTINATIONS. Everything else must be public (RV-B2).
61
+ */
62
+ allowedDestinations?: string[];
63
+ now?: () => number;
64
+ };
65
+ export declare class WebhookDispatcher {
66
+ private readonly options;
67
+ constructor(options: DispatcherOptions);
68
+ private policy;
69
+ private now;
70
+ /** Registers an endpoint; the returned secret is the only time it is shown. */
71
+ createEndpoint(input: {
72
+ workspaceRef: string;
73
+ url: string;
74
+ events: WebhookEventType[];
75
+ }): WebhookEndpoint;
76
+ /** New secret; the old one keeps verifying for `windowMs`. Returns the new secret. */
77
+ rotateSecret(endpointId: string, windowMs?: number): string;
78
+ /** The deliveries an event makes, one per subscribed endpoint of its workspace (not stored). */
79
+ plan(event: WebhookEvent): Delivery[];
80
+ /** Fans an event out to every endpoint of its workspace subscribed to its type. */
81
+ publish(event: WebhookEvent): Delivery[];
82
+ /** Attempts every pending delivery that is due; returns how many were attempted. */
83
+ runDue(): Promise<number>;
84
+ /** Sends a delivery again now, with the original event id and a fresh signature. */
85
+ resend(deliveryId: string): Promise<Delivery>;
86
+ private attempt;
87
+ }