@7365admin1/layer-common 3.1.4-staging.53 → 3.2.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.
- package/CHANGELOG.md +6 -0
- package/components/CreateSubsciptionPlan.vue +376 -0
- package/components/DashboardMain.vue +16 -38
- package/components/EntryPassInformation.vue +4 -4
- package/components/HidAccessLogDashboard.vue +8 -53
- package/components/HidIdentityMapping.vue +975 -0
- package/components/HidIntercomManagement.vue +174 -621
- package/components/HidQrCodeConfiguration.vue +94 -742
- package/components/HidServiceSettingsPanel.vue +1 -20
- package/components/HidUserEnrollment.vue +0 -2
- package/components/Nfc/NFCPatrolRouteMain.vue +7 -52
- package/components/PlanActionsMenu.vue +33 -0
- package/components/PlanStatusBadge.vue +26 -0
- package/components/QrTemplate/CreditCardLandscape.vue +12 -19
- package/components/QrTemplate/PrintDialog.vue +196 -209
- package/components/SubscriptionPlanTable.vue +362 -0
- package/components/VisitorForm.vue +78 -201
- package/components/VisitorManagement.vue +1 -0
- package/composables/useEquipmentManagementPermission.ts +1 -1
- package/composables/useEquipmentPermission.ts +1 -1
- package/composables/useHidAmico.ts +0 -66
- package/composables/useHidNavigation.ts +7 -0
- package/composables/useWebUsb.ts +37 -127
- package/package.json +1 -2
- package/pages/[org]/[site]/access-mgmt/identity-mapping/index.vue +23 -0
- package/plugins/secure-member.client.ts +56 -21
- package/types/site.d.ts +0 -65
- package/types/subscription.ts +51 -0
- package/composables/useSipWebPhone.ts +0 -236
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
import { computed, onScopeDispose, readonly, ref, shallowRef } from "vue";
|
|
2
|
-
import type { SimpleUser, SimpleUserDelegate, SimpleUserOptions } from "sip.js/lib/platform/web";
|
|
3
|
-
|
|
4
|
-
export type SipWebPhoneConfig = {
|
|
5
|
-
webSocketServer: string;
|
|
6
|
-
aor: string;
|
|
7
|
-
authorizationUsername: string;
|
|
8
|
-
authorizationPassword: string;
|
|
9
|
-
displayName?: string;
|
|
10
|
-
video?: boolean;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export type SipWebPhoneMedia = {
|
|
14
|
-
localVideo?: HTMLVideoElement | null;
|
|
15
|
-
remoteAudio?: HTMLAudioElement | null;
|
|
16
|
-
remoteVideo?: HTMLVideoElement | null;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
type ConnectionState = "disconnected" | "connecting" | "registered" | "error";
|
|
20
|
-
type CallState = "idle" | "calling" | "incoming" | "active" | "ending";
|
|
21
|
-
|
|
22
|
-
export default function useSipWebPhone() {
|
|
23
|
-
const simpleUser = shallowRef<SimpleUser>();
|
|
24
|
-
const connectionState = ref<ConnectionState>("disconnected");
|
|
25
|
-
const callState = ref<CallState>("idle");
|
|
26
|
-
const errorMessage = ref("");
|
|
27
|
-
const muted = ref(false);
|
|
28
|
-
const currentTarget = ref("");
|
|
29
|
-
const activeConfig = shallowRef<SipWebPhoneConfig>();
|
|
30
|
-
|
|
31
|
-
const isRegistered = computed(() => connectionState.value === "registered");
|
|
32
|
-
const hasCall = computed(() => callState.value !== "idle");
|
|
33
|
-
|
|
34
|
-
async function connect(config: SipWebPhoneConfig, media: SipWebPhoneMedia) {
|
|
35
|
-
validateConfig(config);
|
|
36
|
-
await disconnect();
|
|
37
|
-
|
|
38
|
-
connectionState.value = "connecting";
|
|
39
|
-
errorMessage.value = "";
|
|
40
|
-
activeConfig.value = { ...config };
|
|
41
|
-
|
|
42
|
-
try {
|
|
43
|
-
const { SimpleUser: SimpleUserConstructor } = await import("sip.js/lib/platform/web");
|
|
44
|
-
const delegate: SimpleUserDelegate = {
|
|
45
|
-
onCallCreated: () => {
|
|
46
|
-
if (callState.value !== "incoming") callState.value = "calling";
|
|
47
|
-
},
|
|
48
|
-
onCallReceived: () => {
|
|
49
|
-
callState.value = "incoming";
|
|
50
|
-
currentTarget.value = "Incoming call";
|
|
51
|
-
},
|
|
52
|
-
onCallAnswered: () => {
|
|
53
|
-
callState.value = "active";
|
|
54
|
-
},
|
|
55
|
-
onCallHangup: () => resetCall(),
|
|
56
|
-
onRegistered: () => {
|
|
57
|
-
connectionState.value = "registered";
|
|
58
|
-
},
|
|
59
|
-
onUnregistered: () => {
|
|
60
|
-
connectionState.value = "disconnected";
|
|
61
|
-
},
|
|
62
|
-
onServerDisconnect: (error) => {
|
|
63
|
-
connectionState.value = error ? "error" : "disconnected";
|
|
64
|
-
if (error) errorMessage.value = error.message;
|
|
65
|
-
resetCall();
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
const options: SimpleUserOptions = {
|
|
69
|
-
aor: normalizeSipUri(config.aor),
|
|
70
|
-
delegate,
|
|
71
|
-
media: {
|
|
72
|
-
constraints: { audio: true, video: Boolean(config.video) },
|
|
73
|
-
local: { video: media.localVideo || undefined },
|
|
74
|
-
remote: {
|
|
75
|
-
audio: media.remoteAudio || undefined,
|
|
76
|
-
video: media.remoteVideo || undefined,
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
userAgentOptions: {
|
|
80
|
-
authorizationUsername: config.authorizationUsername,
|
|
81
|
-
authorizationPassword: config.authorizationPassword,
|
|
82
|
-
displayName: config.displayName || config.authorizationUsername,
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const user = new SimpleUserConstructor(config.webSocketServer.trim(), options);
|
|
87
|
-
simpleUser.value = user;
|
|
88
|
-
await user.connect();
|
|
89
|
-
await user.register();
|
|
90
|
-
} catch (error) {
|
|
91
|
-
await disconnect(false);
|
|
92
|
-
connectionState.value = "error";
|
|
93
|
-
errorMessage.value = getErrorMessage(error);
|
|
94
|
-
throw error;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
async function disconnect(clearError = true) {
|
|
99
|
-
const user = simpleUser.value;
|
|
100
|
-
simpleUser.value = undefined;
|
|
101
|
-
|
|
102
|
-
if (user) {
|
|
103
|
-
try {
|
|
104
|
-
if (hasCall.value) await user.hangup();
|
|
105
|
-
} catch {
|
|
106
|
-
// The session may already have ended remotely.
|
|
107
|
-
}
|
|
108
|
-
try {
|
|
109
|
-
await user.unregister();
|
|
110
|
-
} catch {
|
|
111
|
-
// Registration may not have completed.
|
|
112
|
-
}
|
|
113
|
-
try {
|
|
114
|
-
await user.disconnect();
|
|
115
|
-
} catch {
|
|
116
|
-
// The WebSocket may already be closed.
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
connectionState.value = "disconnected";
|
|
121
|
-
activeConfig.value = undefined;
|
|
122
|
-
resetCall();
|
|
123
|
-
if (clearError) errorMessage.value = "";
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
async function call(target: string) {
|
|
127
|
-
const user = requireRegisteredUser();
|
|
128
|
-
const destination = normalizeDestination(target, activeConfig.value?.aor || "");
|
|
129
|
-
errorMessage.value = "";
|
|
130
|
-
currentTarget.value = destination;
|
|
131
|
-
callState.value = "calling";
|
|
132
|
-
try {
|
|
133
|
-
await user.call(destination);
|
|
134
|
-
} catch (error) {
|
|
135
|
-
resetCall();
|
|
136
|
-
errorMessage.value = getErrorMessage(error);
|
|
137
|
-
throw error;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
async function answer() {
|
|
142
|
-
const user = requireRegisteredUser();
|
|
143
|
-
await user.answer();
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
async function decline() {
|
|
147
|
-
const user = requireUser();
|
|
148
|
-
callState.value = "ending";
|
|
149
|
-
await user.decline();
|
|
150
|
-
resetCall();
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
async function hangup() {
|
|
154
|
-
const user = requireUser();
|
|
155
|
-
callState.value = "ending";
|
|
156
|
-
await user.hangup();
|
|
157
|
-
resetCall();
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function toggleMute() {
|
|
161
|
-
const user = requireUser();
|
|
162
|
-
if (muted.value) {
|
|
163
|
-
user.unmute();
|
|
164
|
-
} else {
|
|
165
|
-
user.mute();
|
|
166
|
-
}
|
|
167
|
-
muted.value = user.isMuted();
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function resetCall() {
|
|
171
|
-
callState.value = "idle";
|
|
172
|
-
currentTarget.value = "";
|
|
173
|
-
muted.value = false;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
function requireRegisteredUser() {
|
|
177
|
-
const user = requireUser();
|
|
178
|
-
if (!isRegistered.value) throw new Error("Connect the web phone before making a call.");
|
|
179
|
-
return user;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
function requireUser() {
|
|
183
|
-
if (!simpleUser.value) throw new Error("Web phone is not connected.");
|
|
184
|
-
return simpleUser.value;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
onScopeDispose(() => {
|
|
188
|
-
void disconnect();
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
return {
|
|
192
|
-
connectionState: readonly(connectionState),
|
|
193
|
-
callState: readonly(callState),
|
|
194
|
-
errorMessage: readonly(errorMessage),
|
|
195
|
-
muted: readonly(muted),
|
|
196
|
-
currentTarget: readonly(currentTarget),
|
|
197
|
-
isRegistered,
|
|
198
|
-
hasCall,
|
|
199
|
-
connect,
|
|
200
|
-
disconnect,
|
|
201
|
-
call,
|
|
202
|
-
answer,
|
|
203
|
-
decline,
|
|
204
|
-
hangup,
|
|
205
|
-
toggleMute,
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
function validateConfig(config: SipWebPhoneConfig) {
|
|
210
|
-
if (!/^wss:\/\//i.test(config.webSocketServer.trim())) {
|
|
211
|
-
throw new Error("SIP WebSocket URL must use WSS.");
|
|
212
|
-
}
|
|
213
|
-
if (!config.aor.trim() || !config.authorizationUsername.trim() || !config.authorizationPassword) {
|
|
214
|
-
throw new Error("SIP address, username, and password are required.");
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
function normalizeSipUri(value: string) {
|
|
219
|
-
const trimmed = value.trim();
|
|
220
|
-
return trimmed.toLowerCase().startsWith("sip:") ? trimmed : `sip:${trimmed}`;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
function normalizeDestination(target: string, aor: string) {
|
|
224
|
-
const trimmed = target.trim();
|
|
225
|
-
if (!trimmed) throw new Error("Enter an extension or SIP address to call.");
|
|
226
|
-
if (trimmed.toLowerCase().startsWith("sip:")) return trimmed;
|
|
227
|
-
if (trimmed.includes("@")) return `sip:${trimmed}`;
|
|
228
|
-
|
|
229
|
-
const domain = normalizeSipUri(aor).split("@")[1];
|
|
230
|
-
if (!domain) throw new Error("Enter a full SIP address for the destination.");
|
|
231
|
-
return `sip:${trimmed}@${domain}`;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
function getErrorMessage(error: unknown) {
|
|
235
|
-
return error instanceof Error ? error.message : "SIP connection failed.";
|
|
236
|
-
}
|