@passflow/core 0.0.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.
- package/README.md +1087 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2149 -0
- package/dist/index.mjs.map +1 -0
- package/dist/lib/api/app.d.ts +8 -0
- package/dist/lib/api/app.d.ts.map +1 -0
- package/dist/lib/api/auth.d.ts +23 -0
- package/dist/lib/api/auth.d.ts.map +1 -0
- package/dist/lib/api/axios-client.d.ts +36 -0
- package/dist/lib/api/axios-client.d.ts.map +1 -0
- package/dist/lib/api/index.d.ts +8 -0
- package/dist/lib/api/index.d.ts.map +1 -0
- package/dist/lib/api/invitation.d.ts +77 -0
- package/dist/lib/api/invitation.d.ts.map +1 -0
- package/dist/lib/api/model.d.ts +459 -0
- package/dist/lib/api/model.d.ts.map +1 -0
- package/dist/lib/api/setting.d.ts +10 -0
- package/dist/lib/api/setting.d.ts.map +1 -0
- package/dist/lib/api/tenant.d.ts +213 -0
- package/dist/lib/api/tenant.d.ts.map +1 -0
- package/dist/lib/api/user.d.ts +19 -0
- package/dist/lib/api/user.d.ts.map +1 -0
- package/dist/lib/constants/index.d.ts +8 -0
- package/dist/lib/constants/index.d.ts.map +1 -0
- package/dist/lib/device-service/index.d.ts +7 -0
- package/dist/lib/device-service/index.d.ts.map +1 -0
- package/dist/lib/index.d.ts +8 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/passflow.d.ts +115 -0
- package/dist/lib/passflow.d.ts.map +1 -0
- package/dist/lib/services/auth-service.d.ts +67 -0
- package/dist/lib/services/auth-service.d.ts.map +1 -0
- package/dist/lib/services/index.d.ts +7 -0
- package/dist/lib/services/index.d.ts.map +1 -0
- package/dist/lib/services/invitation-service.d.ts +44 -0
- package/dist/lib/services/invitation-service.d.ts.map +1 -0
- package/dist/lib/services/logger.d.ts +24 -0
- package/dist/lib/services/logger.d.ts.map +1 -0
- package/dist/lib/services/tenant-service.d.ts +200 -0
- package/dist/lib/services/tenant-service.d.ts.map +1 -0
- package/dist/lib/services/tenant-user-membership.d.ts +76 -0
- package/dist/lib/services/tenant-user-membership.d.ts.map +1 -0
- package/dist/lib/services/token-cache-service.d.ts +26 -0
- package/dist/lib/services/token-cache-service.d.ts.map +1 -0
- package/dist/lib/services/user-service.d.ts +39 -0
- package/dist/lib/services/user-service.d.ts.map +1 -0
- package/dist/lib/storage-manager/index.d.ts +37 -0
- package/dist/lib/storage-manager/index.d.ts.map +1 -0
- package/dist/lib/store.d.ts +89 -0
- package/dist/lib/store.d.ts.map +1 -0
- package/dist/lib/token-service/index.d.ts +4 -0
- package/dist/lib/token-service/index.d.ts.map +1 -0
- package/dist/lib/token-service/membership.d.ts +37 -0
- package/dist/lib/token-service/membership.d.ts.map +1 -0
- package/dist/lib/token-service/service.d.ts +35 -0
- package/dist/lib/token-service/service.d.ts.map +1 -0
- package/dist/lib/token-service/token.d.ts +34 -0
- package/dist/lib/token-service/token.d.ts.map +1 -0
- package/dist/lib/types/index.d.ts +22 -0
- package/dist/lib/types/index.d.ts.map +1 -0
- package/dist/tests/storage-manager/fake-storage.d.ts +7 -0
- package/dist/tests/storage-manager/fake-storage.d.ts.map +1 -0
- package/dist/tests/storage-manager/storage-manager.test.d.ts +2 -0
- package/dist/tests/storage-manager/storage-manager.test.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +81 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2149 @@
|
|
|
1
|
+
import T from "axios";
|
|
2
|
+
import { v4 as R } from "uuid";
|
|
3
|
+
import { startRegistration as _, startAuthentication as U } from "@simplewebauthn/browser";
|
|
4
|
+
const P = "X-Passflow-Clientid", m = "Authorization", D = "X-Passflow-DeviceId", x = "X-Passflow-DeviceType", F = ["id", "offline", "tenant", "email", "oidc", "openid", "access:tenant:all"], A = "https://auth.passflow.cloud", re = "default", M = (i) => {
|
|
5
|
+
const e = [];
|
|
6
|
+
let t;
|
|
7
|
+
for (t in i) {
|
|
8
|
+
const s = i[t];
|
|
9
|
+
if (s === void 0)
|
|
10
|
+
continue;
|
|
11
|
+
const r = { tenant: { id: s.tenant_id, name: s.tenant_name } };
|
|
12
|
+
r.groups = s.groups ? Object.keys(s.groups).map((o) => {
|
|
13
|
+
const n = s.groups[o] || [];
|
|
14
|
+
return { group: { id: o, name: s.group_names?.[o] ?? "unknown" }, roles: n };
|
|
15
|
+
}) : [], r.tenantRoles = r.groups?.find((o) => o.group.id === s.root_group_id), e.push(r);
|
|
16
|
+
}
|
|
17
|
+
return { raw: i, tenants: e };
|
|
18
|
+
};
|
|
19
|
+
class G {
|
|
20
|
+
constructor() {
|
|
21
|
+
this.storageManager = new b();
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Checks if a token is not exists or expired.
|
|
25
|
+
*
|
|
26
|
+
* @param {TokenType} ttype - The token type to check.
|
|
27
|
+
* @returns {boolean} Returns true if the token is expired or not exists, false otherwise.
|
|
28
|
+
*/
|
|
29
|
+
isTokenTypeExpired(e) {
|
|
30
|
+
const t = this.storageManager.getToken(e);
|
|
31
|
+
if (!t) return !0;
|
|
32
|
+
const s = d(t);
|
|
33
|
+
return s ? f(s) : !0;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Parse token from storage by type.
|
|
37
|
+
* Please be aware that this method does not check if the token signature and if the token is valid.
|
|
38
|
+
*
|
|
39
|
+
* @param {TokenType} tokenType - The token type to check.
|
|
40
|
+
* @returns {Token | undefined} Returns token with parsed user membership or undefined.
|
|
41
|
+
*/
|
|
42
|
+
parseTokenType(e) {
|
|
43
|
+
const t = this.storageManager.getToken(e);
|
|
44
|
+
if (t)
|
|
45
|
+
return d(t);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function f(i) {
|
|
49
|
+
return Math.floor(Date.now() / 1e3) > i.exp;
|
|
50
|
+
}
|
|
51
|
+
function d(i) {
|
|
52
|
+
const e = i.split(".")[1];
|
|
53
|
+
if (!e) throw new Error("Invalid token string");
|
|
54
|
+
const t = e.replace(/-/g, "+").replace(/_/g, "/"), s = decodeURIComponent(
|
|
55
|
+
window.atob(t).split("").map((o) => "%" + ("00" + o.charCodeAt(0).toString(16)).slice(-2)).join("")
|
|
56
|
+
), r = JSON.parse(s);
|
|
57
|
+
return r.membership = r.passflow_tm && r.type !== "invite" ? M(r.passflow_tm) : void 0, r;
|
|
58
|
+
}
|
|
59
|
+
var g = /* @__PURE__ */ ((i) => (i.id_token = "id_token", i.access_token = "access", i.refresh_token = "refresh", i.invite_token = "invite", i.reset_token = "reset", i.web_cookie = "web-cookie", i.management = "management", i.signin = "signin", i.actor = "actor", i))(g || {});
|
|
60
|
+
class b {
|
|
61
|
+
constructor({ storage: e, prefix: t } = {}) {
|
|
62
|
+
this.keyStoragePrefix = "", this.scopes = `${this.keyStoragePrefix}tokens_scopes`, this.deviceId = `${this.keyStoragePrefix}passflowDeviceId`, this.invitationToken = `${this.keyStoragePrefix}passflowInvitationToken`, this.previousRedirectUrl = `${this.keyStoragePrefix}passflowPreviousRedirectUrl`, this.storage = e ?? localStorage, this.keyStoragePrefix = t ? `${t}_` : "";
|
|
63
|
+
}
|
|
64
|
+
saveTokens(e) {
|
|
65
|
+
const { id_token: t, access_token: s, refresh_token: r, scopes: o } = e;
|
|
66
|
+
t && this.storage.setItem(this.getKeyForTokenType(g.id_token), t), s && this.storage.setItem(this.getKeyForTokenType(g.access_token), s), r && this.storage.setItem(this.getKeyForTokenType(g.refresh_token), r), o && this.storage.setItem(this.scopes, o.join(","));
|
|
67
|
+
}
|
|
68
|
+
getToken(e) {
|
|
69
|
+
const t = this.getKeyForTokenType(e);
|
|
70
|
+
return this.storage.getItem(t) ?? void 0;
|
|
71
|
+
}
|
|
72
|
+
getTokens() {
|
|
73
|
+
const e = this.storage.getItem(this.getKeyForTokenType(g.access_token));
|
|
74
|
+
if (e)
|
|
75
|
+
return {
|
|
76
|
+
access_token: e,
|
|
77
|
+
id_token: this.storage.getItem(this.getKeyForTokenType(g.id_token)) ?? void 0,
|
|
78
|
+
refresh_token: this.storage.getItem(this.getKeyForTokenType(g.refresh_token)) ?? void 0,
|
|
79
|
+
scopes: this.storage.getItem(this.scopes)?.split(",") ?? void 0
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
getScopes() {
|
|
83
|
+
return this.storage.getItem(this.scopes)?.split(",") ?? void 0;
|
|
84
|
+
}
|
|
85
|
+
deleteToken(e) {
|
|
86
|
+
const t = this.getKeyForTokenType(e);
|
|
87
|
+
this.storage.removeItem(t);
|
|
88
|
+
}
|
|
89
|
+
deleteTokens() {
|
|
90
|
+
this.storage.removeItem(this.getKeyForTokenType(g.id_token)), this.storage.removeItem(this.getKeyForTokenType(g.access_token)), this.storage.removeItem(this.getKeyForTokenType(g.refresh_token)), this.storage.removeItem(this.scopes);
|
|
91
|
+
}
|
|
92
|
+
getDeviceId() {
|
|
93
|
+
return this.storage.getItem(this.deviceId) ?? void 0;
|
|
94
|
+
}
|
|
95
|
+
setDeviceId(e) {
|
|
96
|
+
this.storage.setItem(this.deviceId, e);
|
|
97
|
+
}
|
|
98
|
+
deleteDeviceId() {
|
|
99
|
+
this.storage.removeItem(this.deviceId);
|
|
100
|
+
}
|
|
101
|
+
setInvitationToken(e) {
|
|
102
|
+
this.storage.setItem(this.invitationToken, e);
|
|
103
|
+
}
|
|
104
|
+
getInvitationToken() {
|
|
105
|
+
return this.storage.getItem(this.invitationToken) ?? void 0;
|
|
106
|
+
}
|
|
107
|
+
deleteInvitationToken() {
|
|
108
|
+
this.storage.removeItem(this.invitationToken);
|
|
109
|
+
}
|
|
110
|
+
setPreviousRedirectUrl(e) {
|
|
111
|
+
this.storage.setItem(this.previousRedirectUrl, e);
|
|
112
|
+
}
|
|
113
|
+
getPreviousRedirectUrl() {
|
|
114
|
+
return this.storage.getItem(this.previousRedirectUrl) ?? void 0;
|
|
115
|
+
}
|
|
116
|
+
deletePreviousRedirectUrl() {
|
|
117
|
+
this.storage.removeItem(this.previousRedirectUrl);
|
|
118
|
+
}
|
|
119
|
+
getKeyForTokenType(e) {
|
|
120
|
+
return `${this.keyStoragePrefix}${e}`;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
class $ {
|
|
124
|
+
constructor() {
|
|
125
|
+
this.storageManager = new b();
|
|
126
|
+
}
|
|
127
|
+
getDeviceId() {
|
|
128
|
+
const e = this.storageManager.getDeviceId();
|
|
129
|
+
if (!e) {
|
|
130
|
+
const t = this.generateUniqueDeviceId();
|
|
131
|
+
return this.storageManager.setDeviceId(t), t;
|
|
132
|
+
}
|
|
133
|
+
return e;
|
|
134
|
+
}
|
|
135
|
+
generateUniqueDeviceId() {
|
|
136
|
+
return R();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
var S = /* @__PURE__ */ ((i) => (i.GET = "get", i.POST = "post", i.PUT = "put", i.PATCH = "patch", i.DELETE = "delete", i))(S || {}), c = /* @__PURE__ */ ((i) => (i.signin = "/auth/login", i.signup = "/auth/register", i.signInWithProvider = "/auth/federated/start/", i.passwordless = "/auth/passwordless/start", i.passwordlessComplete = "/auth/passwordless/complete", i.logout = "/user/logout", i.refresh = "/auth/refresh", i.sendPasswordResetEmail = "/auth/password/reset", i.resetPassword = "/auth/password/change", i.appSettings = "/app/settings", i.passkeyRegisterStart = "/auth/passkey/register/start", i.passkeyRegisterComplete = "/auth/passkey/register/complete", i.passkeyAuthenticateStart = "/auth/passkey/authenticate/start", i.passkeyAuthenticateComplete = "/auth/passkey/authenticate/complete", i.passkeyValidate = "/auth/validate", i.settingsAll = "/settings", i.settingsPasswordPolicy = "/settings/password", i.settingsPasskey = "/settings/passkey", i.userPasskey = "/user/passkey", i.addUserPasskey = "/user/passkey/add/start", i.completeAddUserPasskey = "/user/passkey/add/complete", i.joinInvitation = "/user/tenant/join", i.tenantPath = "/user/tenant", i.invitationsPath = "/user/tenant/:tenantID/invitations", i.requestInvitation = "/user/invite", i.invitationDelete = "/user/invite/:invitationID", i.invitationResend = "/user/invite/:invitationID/resend", i.invitationGetLink = "/user/invite/:invitationID/link", i))(c || {}), y = /* @__PURE__ */ ((i) => (i.passkeyRegisterStart = "/admin/auth/passkey/register/start", i.passkeyRegisterComplete = "/admin/auth/passkey/register/complete", i.passkeyAuthenticateStart = "/admin/auth/passkey/authenticate/start", i.passkeyAuthenticateComplete = "/admin/auth/passkey/authenticate/complete", i.passkeyValidate = "/admin/auth/validate", i.logout = "/admin/auth/logout", i))(y || {});
|
|
140
|
+
class u extends Error {
|
|
141
|
+
constructor(e) {
|
|
142
|
+
super(), this.id = e?.id ?? "unknown", this.message = e?.message ?? e ?? "Something went wrong", this.status = e?.status ?? 500, this.location = e?.location ?? "unknown", this.time = e?.time ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
var L = /* @__PURE__ */ ((i) => (i.google = "google", i.facebook = "facebook", i))(L || {}), w = /* @__PURE__ */ ((i) => (i.web = "web", i))(w || {});
|
|
146
|
+
function C(i, e) {
|
|
147
|
+
let t = i;
|
|
148
|
+
return Object.entries(e).forEach(([s, r]) => {
|
|
149
|
+
t = t.replace(`:${s}`, r);
|
|
150
|
+
}), t;
|
|
151
|
+
}
|
|
152
|
+
class I {
|
|
153
|
+
constructor(e) {
|
|
154
|
+
this.refreshPromise = null, this.origin = window.location.origin, this.defaultHeaders = {
|
|
155
|
+
Accept: "application/json",
|
|
156
|
+
"Content-Type": "application/json"
|
|
157
|
+
}, this.nonAccessTokenEndpoints = ["/auth/", "/settings", "/settings/"], this.protectedEndpoints = ["logout", "refresh"];
|
|
158
|
+
const { url: t, appId: s, keyStoragePrefix: r } = e;
|
|
159
|
+
this.url = t || A, this.storageManager = new b({
|
|
160
|
+
prefix: r ?? ""
|
|
161
|
+
}), this.deviceService = new $(), this.tokenService = new G(), s && (this.appId = s, this.defaultHeaders = {
|
|
162
|
+
...this.defaultHeaders,
|
|
163
|
+
[P]: s
|
|
164
|
+
});
|
|
165
|
+
const o = this.deviceService.getDeviceId();
|
|
166
|
+
this.defaultHeaders = {
|
|
167
|
+
...this.defaultHeaders,
|
|
168
|
+
[D]: o,
|
|
169
|
+
[x]: "web"
|
|
170
|
+
}, this.instance = T.create({
|
|
171
|
+
baseURL: this.url,
|
|
172
|
+
headers: { ...this.defaultHeaders }
|
|
173
|
+
}), this.instance.interceptors.request.use(async (n) => {
|
|
174
|
+
if (this.isNonAuthEndpoint(n.url))
|
|
175
|
+
return n;
|
|
176
|
+
if (n.url?.includes("refresh")) {
|
|
177
|
+
if (this.refreshPromise) {
|
|
178
|
+
const p = new AbortController();
|
|
179
|
+
return p.abort(), n.signal = p.signal, n;
|
|
180
|
+
}
|
|
181
|
+
return n;
|
|
182
|
+
}
|
|
183
|
+
const h = this.storageManager.getTokens(), l = this.storageManager.getScopes();
|
|
184
|
+
if (h?.access_token) {
|
|
185
|
+
const p = d(h.access_token);
|
|
186
|
+
if (f(p) && h.refresh_token)
|
|
187
|
+
try {
|
|
188
|
+
if (this.refreshPromise) {
|
|
189
|
+
const E = await this.refreshPromise;
|
|
190
|
+
return E.data && (n.headers[m] = `Bearer ${E.data.access_token}`), n;
|
|
191
|
+
}
|
|
192
|
+
const v = {
|
|
193
|
+
refresh_token: h.refresh_token,
|
|
194
|
+
scopes: l
|
|
195
|
+
};
|
|
196
|
+
this.refreshPromise = this.instance.post(c.refresh, v, {
|
|
197
|
+
headers: {
|
|
198
|
+
[m]: `Bearer ${h.refresh_token}`
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
const k = await this.refreshPromise;
|
|
202
|
+
return k.data && (this.storageManager.saveTokens(k.data), n.headers[m] = `Bearer ${k.data.access_token}`), n;
|
|
203
|
+
} catch (v) {
|
|
204
|
+
return this.refreshPromise = null, Promise.reject(v);
|
|
205
|
+
} finally {
|
|
206
|
+
this.refreshPromise = null;
|
|
207
|
+
}
|
|
208
|
+
return n.headers[m] = `Bearer ${h.access_token}`, n;
|
|
209
|
+
}
|
|
210
|
+
return n;
|
|
211
|
+
}), this.instance.interceptors.response.use(
|
|
212
|
+
(n) => n,
|
|
213
|
+
(n) => this.handleAxiosError(n)
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
isProtectedEndpoint(e) {
|
|
217
|
+
return this.protectedEndpoints.some((t) => e?.includes(t));
|
|
218
|
+
}
|
|
219
|
+
isNonAuthEndpoint(e) {
|
|
220
|
+
return this.nonAccessTokenEndpoints.some((t) => e?.includes(t)) && !this.isProtectedEndpoint(e);
|
|
221
|
+
}
|
|
222
|
+
// eslint-disable-next-line complexity
|
|
223
|
+
// biome-ignore lint/suspicious/useAwait: <explanation>
|
|
224
|
+
async handleAxiosError(e) {
|
|
225
|
+
if (!e.response)
|
|
226
|
+
return Promise.reject(e);
|
|
227
|
+
const t = e.response.status, s = e.response.data;
|
|
228
|
+
if ("error" in s && typeof s.error == "object" && s.error !== null) {
|
|
229
|
+
const { error: r } = s;
|
|
230
|
+
return Promise.reject(new u(r));
|
|
231
|
+
}
|
|
232
|
+
return Promise.reject(
|
|
233
|
+
new u({
|
|
234
|
+
id: `error.http.${t}`,
|
|
235
|
+
message: e.message || "An error occurred",
|
|
236
|
+
status: t,
|
|
237
|
+
location: e.config?.url || "unknown",
|
|
238
|
+
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
239
|
+
})
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
async send(e, t, s) {
|
|
243
|
+
return (await this.instance.request({
|
|
244
|
+
method: e,
|
|
245
|
+
url: t,
|
|
246
|
+
...s
|
|
247
|
+
})).data;
|
|
248
|
+
}
|
|
249
|
+
get(e, t) {
|
|
250
|
+
return this.send(S.GET, e, t);
|
|
251
|
+
}
|
|
252
|
+
post(e, t, s) {
|
|
253
|
+
return this.send(S.POST, e, { data: t, ...s });
|
|
254
|
+
}
|
|
255
|
+
put(e, t, s) {
|
|
256
|
+
return this.send(S.PUT, e, { data: t, ...s });
|
|
257
|
+
}
|
|
258
|
+
patch(e, t, s) {
|
|
259
|
+
return this.send(S.PATCH, e, { data: t, ...s });
|
|
260
|
+
}
|
|
261
|
+
delete(e, t) {
|
|
262
|
+
return this.send(S.DELETE, e, t);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
class O {
|
|
266
|
+
constructor(e) {
|
|
267
|
+
this.storageManager = new b(), this.axiosClient = new I(e);
|
|
268
|
+
}
|
|
269
|
+
refreshToken(e, t, s) {
|
|
270
|
+
const r = {
|
|
271
|
+
access: s,
|
|
272
|
+
scopes: t
|
|
273
|
+
};
|
|
274
|
+
return this.axiosClient.post(c.refresh, r, {
|
|
275
|
+
headers: {
|
|
276
|
+
[m]: `Bearer ${e}`
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
signIn(e, t, s) {
|
|
281
|
+
const r = {
|
|
282
|
+
...e,
|
|
283
|
+
device: t,
|
|
284
|
+
os: s
|
|
285
|
+
};
|
|
286
|
+
return this.axiosClient.post(
|
|
287
|
+
c.signin,
|
|
288
|
+
r
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
signUp(e) {
|
|
292
|
+
const { create_tenant: t, anonymous: s } = e, r = {
|
|
293
|
+
...e,
|
|
294
|
+
create_tenant: t ?? !1,
|
|
295
|
+
anonymous: s ?? !1
|
|
296
|
+
};
|
|
297
|
+
return this.axiosClient.post(
|
|
298
|
+
c.signup,
|
|
299
|
+
r
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
passwordlessSignIn(e, t, s) {
|
|
303
|
+
const { create_tenant: r } = e, o = {
|
|
304
|
+
...e,
|
|
305
|
+
create_tenant: r ?? !1,
|
|
306
|
+
device: t,
|
|
307
|
+
os: s
|
|
308
|
+
};
|
|
309
|
+
return this.axiosClient.post(
|
|
310
|
+
c.passwordless,
|
|
311
|
+
o
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
passwordlessSignInComplete(e) {
|
|
315
|
+
return this.axiosClient.post(
|
|
316
|
+
c.passwordlessComplete,
|
|
317
|
+
e
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
logOut(e, t, s = !1) {
|
|
321
|
+
const r = s ? void 0 : { refresh_token: t, device: e }, o = s ? y.logout : c.logout;
|
|
322
|
+
return this.axiosClient.post(o, r);
|
|
323
|
+
}
|
|
324
|
+
sendPasswordResetEmail(e) {
|
|
325
|
+
return this.axiosClient.post(
|
|
326
|
+
c.sendPasswordResetEmail,
|
|
327
|
+
e
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
resetPassword(e, t, s) {
|
|
331
|
+
const r = {
|
|
332
|
+
password: e,
|
|
333
|
+
scopes: t
|
|
334
|
+
};
|
|
335
|
+
return this.axiosClient.post(c.resetPassword, r, {
|
|
336
|
+
headers: {
|
|
337
|
+
[m]: `Bearer ${s}`,
|
|
338
|
+
[P]: void 0
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
passkeyRegisterStart(e, t, s, r = !1) {
|
|
343
|
+
const { create_tenant: o } = e, n = {
|
|
344
|
+
...e,
|
|
345
|
+
create_tenant: o ?? !1,
|
|
346
|
+
device: t,
|
|
347
|
+
os: s
|
|
348
|
+
}, h = r ? y.passkeyRegisterStart : c.passkeyRegisterStart;
|
|
349
|
+
return this.axiosClient.post(h, n);
|
|
350
|
+
}
|
|
351
|
+
passkeyRegisterComplete(e, t, s, r = !1) {
|
|
352
|
+
const o = {
|
|
353
|
+
challenge_id: s,
|
|
354
|
+
device: t,
|
|
355
|
+
passkey_data: e
|
|
356
|
+
}, n = r ? y.passkeyRegisterComplete : c.passkeyRegisterComplete;
|
|
357
|
+
return this.axiosClient.post(n, o);
|
|
358
|
+
}
|
|
359
|
+
passkeyAuthenticateStart(e, t, s, r = !1) {
|
|
360
|
+
const o = {
|
|
361
|
+
...e,
|
|
362
|
+
user_id: e.user_id ?? "",
|
|
363
|
+
device: t,
|
|
364
|
+
os: s
|
|
365
|
+
}, n = r ? y.passkeyAuthenticateStart : c.passkeyAuthenticateStart;
|
|
366
|
+
return this.axiosClient.post(
|
|
367
|
+
n,
|
|
368
|
+
o
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
passkeyAuthenticateComplete(e, t, s, r = !1) {
|
|
372
|
+
const o = {
|
|
373
|
+
challenge_id: s,
|
|
374
|
+
device: t,
|
|
375
|
+
passkey_data: e
|
|
376
|
+
}, n = r ? y.passkeyAuthenticateComplete : c.passkeyAuthenticateComplete;
|
|
377
|
+
return this.axiosClient.post(n, o);
|
|
378
|
+
}
|
|
379
|
+
passkeyValidate(e, t, s, r = !1, o) {
|
|
380
|
+
const n = {
|
|
381
|
+
otp: e,
|
|
382
|
+
device: t,
|
|
383
|
+
challenge_id: s
|
|
384
|
+
};
|
|
385
|
+
let h = c.passkeyValidate;
|
|
386
|
+
!o && r && (h = y.passkeyValidate);
|
|
387
|
+
const l = o ? { [P]: o } : {};
|
|
388
|
+
return this.axiosClient.post(h, n, { headers: l });
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
class j {
|
|
392
|
+
constructor(e) {
|
|
393
|
+
this.axiosClient = new I(e);
|
|
394
|
+
}
|
|
395
|
+
getAppSettings() {
|
|
396
|
+
return this.axiosClient.get(c.appSettings);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
class K {
|
|
400
|
+
constructor(e) {
|
|
401
|
+
this.axiosClient = new I(e);
|
|
402
|
+
}
|
|
403
|
+
getSettingsAll() {
|
|
404
|
+
return this.axiosClient.get(c.settingsAll);
|
|
405
|
+
}
|
|
406
|
+
getPasswordPolicySettings() {
|
|
407
|
+
return this.axiosClient.get(c.settingsPasswordPolicy);
|
|
408
|
+
}
|
|
409
|
+
getPasskeySettings() {
|
|
410
|
+
return this.axiosClient.get(c.settingsPasskey);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
class N {
|
|
414
|
+
constructor(e) {
|
|
415
|
+
this.axiosClient = new I(e);
|
|
416
|
+
}
|
|
417
|
+
getUserPasskeys() {
|
|
418
|
+
return this.axiosClient.get(c.userPasskey);
|
|
419
|
+
}
|
|
420
|
+
renameUserPasskey(e, t) {
|
|
421
|
+
return this.axiosClient.patch(
|
|
422
|
+
`${c.userPasskey}/${t}`,
|
|
423
|
+
{
|
|
424
|
+
name: e
|
|
425
|
+
}
|
|
426
|
+
);
|
|
427
|
+
}
|
|
428
|
+
deleteUserPasskey(e) {
|
|
429
|
+
return this.axiosClient.delete(`${c.userPasskey}/${e}`);
|
|
430
|
+
}
|
|
431
|
+
addUserPasskeyStart({
|
|
432
|
+
relyingPartyId: e,
|
|
433
|
+
deviceId: t,
|
|
434
|
+
os: s,
|
|
435
|
+
passkeyDisplayName: r,
|
|
436
|
+
passkeyUsername: o
|
|
437
|
+
}) {
|
|
438
|
+
const n = {
|
|
439
|
+
passkey_display_name: r,
|
|
440
|
+
passkey_username: o,
|
|
441
|
+
relying_party_id: e,
|
|
442
|
+
deviceId: t,
|
|
443
|
+
os: s
|
|
444
|
+
};
|
|
445
|
+
return this.axiosClient.post(c.addUserPasskey, n);
|
|
446
|
+
}
|
|
447
|
+
addUserPasskeyComplete(e, t, s) {
|
|
448
|
+
return this.axiosClient.post(c.completeAddUserPasskey, {
|
|
449
|
+
challenge_id: s,
|
|
450
|
+
device: t,
|
|
451
|
+
passkey_data: e
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
class B {
|
|
456
|
+
constructor(e) {
|
|
457
|
+
this.axiosClient = new I(e);
|
|
458
|
+
}
|
|
459
|
+
joinInvitation(e, t) {
|
|
460
|
+
const s = {
|
|
461
|
+
invite_token: e,
|
|
462
|
+
scopes: t
|
|
463
|
+
};
|
|
464
|
+
return this.axiosClient.post(
|
|
465
|
+
c.joinInvitation,
|
|
466
|
+
s
|
|
467
|
+
);
|
|
468
|
+
}
|
|
469
|
+
createTenant(e) {
|
|
470
|
+
const t = {
|
|
471
|
+
name: e
|
|
472
|
+
};
|
|
473
|
+
return this.axiosClient.post(
|
|
474
|
+
c.tenantPath,
|
|
475
|
+
t
|
|
476
|
+
);
|
|
477
|
+
}
|
|
478
|
+
// 1. Tenant Management
|
|
479
|
+
/**
|
|
480
|
+
* Get tenant details
|
|
481
|
+
* @param tenantId Tenant ID
|
|
482
|
+
*/
|
|
483
|
+
getTenantDetails(e) {
|
|
484
|
+
const t = `${c.tenantPath}/${e}`;
|
|
485
|
+
return this.axiosClient.get(t);
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Update tenant name
|
|
489
|
+
* @param tenantId Tenant ID
|
|
490
|
+
* @param name New tenant name
|
|
491
|
+
*/
|
|
492
|
+
updateTenant(e, t) {
|
|
493
|
+
const s = `${c.tenantPath}/${e}`, r = { name: t };
|
|
494
|
+
return this.axiosClient.put(s, r);
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Delete a tenant
|
|
498
|
+
* @param tenantId Tenant ID
|
|
499
|
+
*/
|
|
500
|
+
deleteTenant(e) {
|
|
501
|
+
const t = `${c.tenantPath}/${e}`;
|
|
502
|
+
return this.axiosClient.delete(t);
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Get user's tenant memberships
|
|
506
|
+
*/
|
|
507
|
+
getUserTenantMembership() {
|
|
508
|
+
return this.axiosClient.get(c.tenantPath);
|
|
509
|
+
}
|
|
510
|
+
// 2. Group Management
|
|
511
|
+
/**
|
|
512
|
+
* Create a group in a tenant
|
|
513
|
+
* @param tenantId Tenant ID
|
|
514
|
+
* @param name Group name
|
|
515
|
+
*/
|
|
516
|
+
createGroup(e, t) {
|
|
517
|
+
const s = `${c.tenantPath}/${e}/group`, r = { name: t };
|
|
518
|
+
return this.axiosClient.post(s, r);
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Get group information
|
|
522
|
+
* @param tenantId Tenant ID
|
|
523
|
+
* @param groupId Group ID
|
|
524
|
+
*/
|
|
525
|
+
getGroupInfo(e, t) {
|
|
526
|
+
const s = `${c.tenantPath}/${e}/group/${t}`;
|
|
527
|
+
return this.axiosClient.get(s);
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Update a group
|
|
531
|
+
* @param tenantId Tenant ID
|
|
532
|
+
* @param groupId Group ID
|
|
533
|
+
* @param name New group name
|
|
534
|
+
*/
|
|
535
|
+
updateGroup(e, t, s) {
|
|
536
|
+
const r = `${c.tenantPath}/${e}/group/${t}`, o = { name: s };
|
|
537
|
+
return this.axiosClient.put(r, o);
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Delete a group
|
|
541
|
+
* @param tenantId Tenant ID
|
|
542
|
+
* @param groupId Group ID
|
|
543
|
+
*/
|
|
544
|
+
deleteGroup(e, t) {
|
|
545
|
+
const s = `${c.tenantPath}/${e}/group/${t}`;
|
|
546
|
+
return this.axiosClient.delete(s);
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Add a user to a group
|
|
550
|
+
* @param tenantId Tenant ID
|
|
551
|
+
* @param groupId Group ID
|
|
552
|
+
* @param userId User ID
|
|
553
|
+
* @param role Role to assign
|
|
554
|
+
*/
|
|
555
|
+
addUserToGroup(e, t, s, r) {
|
|
556
|
+
const o = `${c.tenantPath}/${e}/group/${t}/add`, n = { user_id: s, role: r };
|
|
557
|
+
return this.axiosClient.post(o, n);
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Remove user roles from a group
|
|
561
|
+
* @param tenantId Tenant ID
|
|
562
|
+
* @param groupId Group ID
|
|
563
|
+
* @param userId User ID
|
|
564
|
+
* @param roles Roles to remove
|
|
565
|
+
*/
|
|
566
|
+
removeUserRolesFromGroup(e, t, s, r) {
|
|
567
|
+
const o = `${c.tenantPath}/${e}/group/${t}/remove_roles`, n = { user_id: s, roles: r };
|
|
568
|
+
return this.axiosClient.post(o, n);
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Change user roles in a group
|
|
572
|
+
* @param tenantId Tenant ID
|
|
573
|
+
* @param groupId Group ID
|
|
574
|
+
* @param userId User ID
|
|
575
|
+
* @param roles New roles to assign
|
|
576
|
+
*/
|
|
577
|
+
changeUserRoles(e, t, s, r) {
|
|
578
|
+
const o = `${c.tenantPath}/${e}/group/${t}/change`, n = { user_id: s, roles: r };
|
|
579
|
+
return this.axiosClient.post(o, n);
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Delete a user from a group
|
|
583
|
+
* @param tenantId Tenant ID
|
|
584
|
+
* @param groupId Group ID
|
|
585
|
+
* @param userId User ID
|
|
586
|
+
*/
|
|
587
|
+
deleteUserFromGroup(e, t, s) {
|
|
588
|
+
const r = `${c.tenantPath}/${e}/group/${t}/${s}`;
|
|
589
|
+
return this.axiosClient.delete(r);
|
|
590
|
+
}
|
|
591
|
+
// 3. Role Management
|
|
592
|
+
/**
|
|
593
|
+
* Get roles for a tenant
|
|
594
|
+
* @param tenantId Tenant ID
|
|
595
|
+
*/
|
|
596
|
+
getRolesForTenant(e) {
|
|
597
|
+
const t = `${c.tenantPath}/${e}/role`;
|
|
598
|
+
return this.axiosClient.get(t);
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* Create a role for a tenant
|
|
602
|
+
* @param tenantId Tenant ID
|
|
603
|
+
* @param name Role name
|
|
604
|
+
*/
|
|
605
|
+
createRoleForTenant(e, t) {
|
|
606
|
+
const s = `${c.tenantPath}/${e}/role`, r = { name: t };
|
|
607
|
+
return this.axiosClient.post(s, r);
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* Update a role
|
|
611
|
+
* @param tenantId Tenant ID
|
|
612
|
+
* @param roleId Role ID
|
|
613
|
+
* @param name New role name
|
|
614
|
+
*/
|
|
615
|
+
updateRole(e, t, s) {
|
|
616
|
+
const r = `${c.tenantPath}/${e}/role/${t}`, o = { name: s };
|
|
617
|
+
return this.axiosClient.put(r, o);
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* Delete a role
|
|
621
|
+
* @param tenantId Tenant ID
|
|
622
|
+
* @param roleId Role ID
|
|
623
|
+
*/
|
|
624
|
+
deleteRole(e, t) {
|
|
625
|
+
const s = `${c.tenantPath}/${e}/role/${t}`;
|
|
626
|
+
return this.axiosClient.delete(s);
|
|
627
|
+
}
|
|
628
|
+
// 4. User Management in Tenants
|
|
629
|
+
/**
|
|
630
|
+
* Delete a user from a tenant
|
|
631
|
+
* @param tenantId Tenant ID
|
|
632
|
+
* @param userId User ID
|
|
633
|
+
*/
|
|
634
|
+
deleteUserFromTenant(e, t) {
|
|
635
|
+
const s = `${c.tenantPath}/${e}/user/${t}`;
|
|
636
|
+
return this.axiosClient.delete(s);
|
|
637
|
+
}
|
|
638
|
+
// 5. Invitation Management
|
|
639
|
+
/**
|
|
640
|
+
* Get invitations to a group
|
|
641
|
+
* @param tenantId Tenant ID
|
|
642
|
+
* @param groupId Group ID
|
|
643
|
+
* @param limit Maximum number of invitations to return
|
|
644
|
+
* @param skip Number of invitations to skip
|
|
645
|
+
*/
|
|
646
|
+
getGroupInvitations(e, t, s, r) {
|
|
647
|
+
const o = `${c.tenantPath}/${e}/group/${t}/invitations`;
|
|
648
|
+
return this.axiosClient.get(o, {
|
|
649
|
+
params: { limit: s, skip: r }
|
|
650
|
+
});
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Get invitations to a tenant
|
|
654
|
+
* @param tenantId Tenant ID
|
|
655
|
+
* @param limit Maximum number of invitations to return
|
|
656
|
+
* @param skip Number of invitations to skip
|
|
657
|
+
*/
|
|
658
|
+
getTenantInvitations(e, t, s) {
|
|
659
|
+
const r = `${c.tenantPath}/${e}/invitations`;
|
|
660
|
+
return this.axiosClient.get(r, {
|
|
661
|
+
params: { limit: t, skip: s }
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
/**
|
|
665
|
+
* Invalidate an invitation by ID
|
|
666
|
+
* @param tenantId Tenant ID
|
|
667
|
+
* @param groupId Group ID
|
|
668
|
+
* @param inviteId Invitation ID
|
|
669
|
+
*/
|
|
670
|
+
invalidateInviteById(e, t, s) {
|
|
671
|
+
const r = `${c.tenantPath}/${e}/group/${t}/invite/${s}`;
|
|
672
|
+
return this.axiosClient.delete(r);
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* Invalidate an invitation by email
|
|
676
|
+
* @param tenantId Tenant ID
|
|
677
|
+
* @param groupId Group ID
|
|
678
|
+
* @param email Email address
|
|
679
|
+
*/
|
|
680
|
+
invalidateInviteByEmail(e, t, s) {
|
|
681
|
+
const r = `${c.tenantPath}/${e}/group/${t}/invite/email/${s}`;
|
|
682
|
+
return this.axiosClient.delete(r);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
class W {
|
|
686
|
+
constructor(e) {
|
|
687
|
+
this.axiosClient = new I(e);
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* Requests an invitation link that can be used to invite users
|
|
691
|
+
* @param payload Request invitation payload
|
|
692
|
+
* @returns Promise with invitation link and token
|
|
693
|
+
*/
|
|
694
|
+
requestInviteLink(e) {
|
|
695
|
+
return this.axiosClient.post(
|
|
696
|
+
c.requestInvitation,
|
|
697
|
+
e
|
|
698
|
+
);
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* Gets a list of active invitations
|
|
702
|
+
* @param options Optional parameters for filtering and pagination
|
|
703
|
+
* @returns Promise with paginated list of invitations
|
|
704
|
+
*/
|
|
705
|
+
getInvitations(e) {
|
|
706
|
+
const t = {};
|
|
707
|
+
e.groupID && (t.group_id = e.groupID.toString()), e.skip !== void 0 && (t.skip = e.skip.toString()), e.limit !== void 0 && (t.limit = e.limit.toString());
|
|
708
|
+
const s = C(c.invitationsPath, {
|
|
709
|
+
tenantID: e.tenantID
|
|
710
|
+
});
|
|
711
|
+
return this.axiosClient.get(s, { params: t }).then((r) => ({
|
|
712
|
+
invites: r.invites,
|
|
713
|
+
nextPageSkip: r.next_page_skip
|
|
714
|
+
}));
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* Deletes an invitation by token
|
|
718
|
+
* @param invitationID The invitation ID to delete
|
|
719
|
+
* @returns Promise with success response
|
|
720
|
+
*/
|
|
721
|
+
deleteInvitation(e) {
|
|
722
|
+
const t = C(c.invitationDelete, {
|
|
723
|
+
invitationID: e
|
|
724
|
+
});
|
|
725
|
+
return this.axiosClient.delete(t);
|
|
726
|
+
}
|
|
727
|
+
/**
|
|
728
|
+
* Resend an invitation by token
|
|
729
|
+
* @param invitationID The invitation ID to resend
|
|
730
|
+
* @returns Promise with success response
|
|
731
|
+
*/
|
|
732
|
+
resendInvitation(e) {
|
|
733
|
+
const t = C(c.invitationResend, {
|
|
734
|
+
invitationID: e
|
|
735
|
+
});
|
|
736
|
+
return this.axiosClient.post(t, {});
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* Get a link to an invitation by id
|
|
740
|
+
* @param invitationID The invitation ID to get link
|
|
741
|
+
* @returns Promise with the link
|
|
742
|
+
*/
|
|
743
|
+
getInvitationLink(e) {
|
|
744
|
+
const t = C(c.invitationGetLink, {
|
|
745
|
+
invitationID: e
|
|
746
|
+
});
|
|
747
|
+
return this.axiosClient.get(t);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
var a = /* @__PURE__ */ ((i) => (i.SignIn = "signin", i.SignInStart = "signin:start", i.Register = "register", i.RegisterStart = "register:start", i.SignOut = "signout", i.Error = "error", i.Refresh = "refresh", i.RefreshStart = "refresh:start", i.TokenCacheExpired = "token-cache-expired", i))(a || {});
|
|
751
|
+
class H {
|
|
752
|
+
constructor() {
|
|
753
|
+
this.subscribers = /* @__PURE__ */ new Map();
|
|
754
|
+
}
|
|
755
|
+
/**
|
|
756
|
+
* Subscribe to authentication events
|
|
757
|
+
* @param subscriber The subscriber to register
|
|
758
|
+
* @param events Optional specific events to subscribe to
|
|
759
|
+
*/
|
|
760
|
+
subscribe(e, t) {
|
|
761
|
+
if (t?.length) {
|
|
762
|
+
const s = new Set(t);
|
|
763
|
+
this.subscribers.set(e, s);
|
|
764
|
+
} else
|
|
765
|
+
this.subscribers.set(e, null);
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* Unsubscribe from authentication events
|
|
769
|
+
* @param subscriber The subscriber to unregister
|
|
770
|
+
* @param events Optional specific events to unsubscribe from
|
|
771
|
+
*/
|
|
772
|
+
unsubscribe(e, t) {
|
|
773
|
+
if (!t?.length) {
|
|
774
|
+
this.subscribers.delete(e);
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
const s = this.subscribers.get(e);
|
|
778
|
+
s && (t.forEach((r) => s.delete(r)), s.size === 0 && this.subscribers.delete(e));
|
|
779
|
+
}
|
|
780
|
+
/**
|
|
781
|
+
* Notify subscribers of an event
|
|
782
|
+
* @param eventType The type of event that occurred
|
|
783
|
+
* @param payload Event-specific payload data
|
|
784
|
+
*/
|
|
785
|
+
notify(e, t) {
|
|
786
|
+
this.subscribers.forEach((s, r) => {
|
|
787
|
+
(!s || s.has(e)) && r.onAuthChange?.(e, t);
|
|
788
|
+
});
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
class q {
|
|
792
|
+
constructor(e, t, s, r, o, n, h, l, p, v, k) {
|
|
793
|
+
this.authApi = e, this.deviceService = t, this.storageManager = s, this.subscribeStore = r, this.tokenCacheService = o, this.scopes = n, this.createTenantForNewUser = h, this.origin = l, this.url = p, this.sessionCallbacks = v, this.appId = k;
|
|
794
|
+
}
|
|
795
|
+
async signIn(e) {
|
|
796
|
+
this.subscribeStore.notify(a.SignInStart, { email: e.email });
|
|
797
|
+
const t = this.deviceService.getDeviceId(), s = w.web;
|
|
798
|
+
e.scopes = e.scopes ?? this.scopes;
|
|
799
|
+
try {
|
|
800
|
+
const r = await this.authApi.signIn(e, t, s);
|
|
801
|
+
return r.scopes = e.scopes, this.storageManager.saveTokens(r), this.tokenCacheService.setTokensCache(r), this.subscribeStore.notify(a.SignIn, {
|
|
802
|
+
tokens: r,
|
|
803
|
+
parsedTokens: this.tokenCacheService.getParsedTokenCache()
|
|
804
|
+
}), await this.submitSessionCheck(), r;
|
|
805
|
+
} catch (r) {
|
|
806
|
+
const o = {
|
|
807
|
+
message: r instanceof Error ? r.message : "Sign in failed",
|
|
808
|
+
originalError: r,
|
|
809
|
+
code: r instanceof u ? r.id : void 0
|
|
810
|
+
};
|
|
811
|
+
throw this.subscribeStore.notify(a.Error, o), r;
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
async signUp(e) {
|
|
815
|
+
this.subscribeStore.notify(a.RegisterStart, { email: e.user.email }), e.scopes = e.scopes ?? this.scopes, e.create_tenant = this.createTenantForNewUser;
|
|
816
|
+
try {
|
|
817
|
+
const t = await this.authApi.signUp(e);
|
|
818
|
+
return t.scopes = e.scopes, this.storageManager.saveTokens(t), this.tokenCacheService.setTokensCache(t), this.subscribeStore.notify(a.Register, {
|
|
819
|
+
tokens: t,
|
|
820
|
+
parsedTokens: this.tokenCacheService.getParsedTokenCache()
|
|
821
|
+
}), await this.submitSessionCheck(), t;
|
|
822
|
+
} catch (t) {
|
|
823
|
+
const s = {
|
|
824
|
+
message: t instanceof Error ? t.message : "Sign up failed",
|
|
825
|
+
originalError: t,
|
|
826
|
+
code: t instanceof u ? t.id : void 0
|
|
827
|
+
};
|
|
828
|
+
throw this.subscribeStore.notify(a.Error, s), t;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
async passwordlessSignIn(e) {
|
|
832
|
+
this.subscribeStore.notify(a.SignInStart, { email: e.email }), e.scopes = e.scopes ?? this.scopes;
|
|
833
|
+
const t = this.deviceService.getDeviceId(), s = w.web;
|
|
834
|
+
try {
|
|
835
|
+
return await this.authApi.passwordlessSignIn(e, t, s);
|
|
836
|
+
} catch (r) {
|
|
837
|
+
const o = {
|
|
838
|
+
message: r instanceof Error ? r.message : "Failed to send passwordless sign-in link",
|
|
839
|
+
originalError: r,
|
|
840
|
+
code: r instanceof u ? r.id : void 0
|
|
841
|
+
};
|
|
842
|
+
throw this.subscribeStore.notify(a.Error, o), r;
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
async passwordlessSignInComplete(e) {
|
|
846
|
+
this.subscribeStore.notify(a.SignInStart, {}), e.scopes = e.scopes ?? this.scopes, e.device = this.deviceService.getDeviceId();
|
|
847
|
+
try {
|
|
848
|
+
const t = await this.authApi.passwordlessSignInComplete(e);
|
|
849
|
+
return t.scopes = e.scopes, this.storageManager.saveTokens(t), this.tokenCacheService.setTokensCache(t), this.subscribeStore.notify(a.SignIn, {
|
|
850
|
+
tokens: t,
|
|
851
|
+
parsedTokens: this.tokenCacheService.getParsedTokenCache()
|
|
852
|
+
}), await this.submitSessionCheck(), t;
|
|
853
|
+
} catch (t) {
|
|
854
|
+
const s = {
|
|
855
|
+
message: t instanceof Error ? t.message : "Passwordless sign in failed",
|
|
856
|
+
originalError: t,
|
|
857
|
+
code: t instanceof u ? t.id : void 0
|
|
858
|
+
};
|
|
859
|
+
throw this.subscribeStore.notify(a.Error, s), t;
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
async logOut() {
|
|
863
|
+
const e = this.storageManager.getToken(g.refresh_token), t = this.storageManager.getDeviceId();
|
|
864
|
+
try {
|
|
865
|
+
if ((await this.authApi.logOut(t, e, !this.appId)).status !== "ok")
|
|
866
|
+
throw new Error("Logout failed");
|
|
867
|
+
this.storageManager.deleteTokens(), this.subscribeStore.notify(a.SignOut, {});
|
|
868
|
+
} catch (s) {
|
|
869
|
+
throw console.error(s), s;
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
async refreshToken() {
|
|
873
|
+
this.subscribeStore.notify(a.RefreshStart, {});
|
|
874
|
+
const e = this.storageManager.getTokens();
|
|
875
|
+
if (e) {
|
|
876
|
+
if (!e?.refresh_token) {
|
|
877
|
+
const s = new Error("No refresh token found"), r = {
|
|
878
|
+
message: "No refresh token found",
|
|
879
|
+
originalError: s
|
|
880
|
+
};
|
|
881
|
+
throw this.subscribeStore.notify(a.Error, r), s;
|
|
882
|
+
}
|
|
883
|
+
} else {
|
|
884
|
+
const s = new Error("No tokens found"), r = {
|
|
885
|
+
message: "No tokens found",
|
|
886
|
+
originalError: s
|
|
887
|
+
};
|
|
888
|
+
throw this.subscribeStore.notify(a.Error, r), s;
|
|
889
|
+
}
|
|
890
|
+
const t = e?.scopes ?? this.scopes;
|
|
891
|
+
try {
|
|
892
|
+
const s = await this.authApi.refreshToken(e?.refresh_token ?? "", t, e?.access_token);
|
|
893
|
+
return s.scopes = t, this.storageManager.saveTokens(s), this.tokenCacheService.setTokensCache(s), this.subscribeStore.notify(a.Refresh, {
|
|
894
|
+
tokens: s,
|
|
895
|
+
parsedTokens: this.tokenCacheService.getParsedTokenCache()
|
|
896
|
+
}), this.subscribeStore.notify(a.TokenCacheExpired, { isExpired: !1 }), this.tokenCacheService.isRefreshing = !1, this.tokenCacheService.isExpired = !1, this.tokenCacheService.startTokenCheck(), s;
|
|
897
|
+
} catch (s) {
|
|
898
|
+
const r = {
|
|
899
|
+
message: s instanceof Error ? s.message : "Token refresh failed",
|
|
900
|
+
originalError: s,
|
|
901
|
+
code: s instanceof u ? s.id : void 0,
|
|
902
|
+
details: T.isAxiosError(s) && s.response ? {
|
|
903
|
+
status: s.response.status,
|
|
904
|
+
data: s.response.data
|
|
905
|
+
} : void 0
|
|
906
|
+
};
|
|
907
|
+
throw this.subscribeStore.notify(a.Error, r), s instanceof u ? s : T.isAxiosError(s) && s.response && s.response?.status >= 400 && s.response?.status < 500 ? new Error(`Getting unknown error message from server with code:${s.response.status}`) : s;
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
async sendPasswordResetEmail(e) {
|
|
911
|
+
try {
|
|
912
|
+
return await this.authApi.sendPasswordResetEmail(e);
|
|
913
|
+
} catch (t) {
|
|
914
|
+
const s = {
|
|
915
|
+
message: t instanceof Error ? t.message : "Failed to send password reset email",
|
|
916
|
+
originalError: t,
|
|
917
|
+
code: t instanceof u ? t.id : void 0
|
|
918
|
+
};
|
|
919
|
+
throw this.subscribeStore.notify(a.Error, s), t;
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
async resetPassword(e, t) {
|
|
923
|
+
this.subscribeStore.notify(a.SignInStart, {});
|
|
924
|
+
const r = new URLSearchParams(window.location.search).get("token") ?? void 0, o = t ?? this.scopes;
|
|
925
|
+
try {
|
|
926
|
+
const n = await this.authApi.resetPassword(e, o, r);
|
|
927
|
+
return n.scopes = o, this.storageManager.saveTokens(n), this.tokenCacheService.setTokensCache(n), this.subscribeStore.notify(a.SignIn, {
|
|
928
|
+
tokens: n,
|
|
929
|
+
parsedTokens: this.tokenCacheService.getParsedTokenCache()
|
|
930
|
+
}), await this.submitSessionCheck(), n;
|
|
931
|
+
} catch (n) {
|
|
932
|
+
const h = {
|
|
933
|
+
message: n instanceof Error ? n.message : "Password reset failed",
|
|
934
|
+
originalError: n,
|
|
935
|
+
code: n instanceof u ? n.id : void 0
|
|
936
|
+
};
|
|
937
|
+
throw this.subscribeStore.notify(a.Error, h), n;
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
async passkeyRegister(e) {
|
|
941
|
+
this.subscribeStore.notify(a.RegisterStart, {});
|
|
942
|
+
const t = this.deviceService.getDeviceId(), s = w.web;
|
|
943
|
+
e.scopes = e.scopes ?? this.scopes, e.create_tenant = this.createTenantForNewUser;
|
|
944
|
+
try {
|
|
945
|
+
const { challenge_id: r, publicKey: o } = await this.authApi.passkeyRegisterStart(e, t, s, !this.appId);
|
|
946
|
+
o.user.id = btoa(o.user.id);
|
|
947
|
+
const n = await _({
|
|
948
|
+
optionsJSON: o
|
|
949
|
+
}), h = await this.authApi.passkeyRegisterComplete(
|
|
950
|
+
n,
|
|
951
|
+
t,
|
|
952
|
+
r,
|
|
953
|
+
!this.appId
|
|
954
|
+
);
|
|
955
|
+
return h.scopes = e.scopes, this.storageManager.saveTokens(h), this.tokenCacheService.setTokensCache(h), this.subscribeStore.notify(a.Register, {
|
|
956
|
+
tokens: h,
|
|
957
|
+
parsedTokens: this.tokenCacheService.getParsedTokenCache()
|
|
958
|
+
}), await this.submitSessionCheck(), h;
|
|
959
|
+
} catch (r) {
|
|
960
|
+
const o = {
|
|
961
|
+
message: r instanceof Error ? r.message : "Passkey registration failed",
|
|
962
|
+
originalError: r,
|
|
963
|
+
code: r instanceof u ? r.id : void 0
|
|
964
|
+
};
|
|
965
|
+
throw this.subscribeStore.notify(a.Error, o), r;
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
async passkeyAuthenticate(e) {
|
|
969
|
+
this.subscribeStore.notify(a.SignInStart, {});
|
|
970
|
+
const t = this.deviceService.getDeviceId(), s = w.web;
|
|
971
|
+
e.scopes = e.scopes ?? this.scopes;
|
|
972
|
+
try {
|
|
973
|
+
const { challenge_id: r, publicKey: o } = await this.authApi.passkeyAuthenticateStart(e, t, s, !this.appId), n = await U({
|
|
974
|
+
optionsJSON: o
|
|
975
|
+
}), h = await this.authApi.passkeyAuthenticateComplete(
|
|
976
|
+
n,
|
|
977
|
+
t,
|
|
978
|
+
r,
|
|
979
|
+
!this.appId
|
|
980
|
+
);
|
|
981
|
+
return "access_token" in h && (h.scopes = e.scopes, this.storageManager.saveTokens(h), this.tokenCacheService.setTokensCache(h), this.subscribeStore.notify(a.SignIn, {
|
|
982
|
+
tokens: h,
|
|
983
|
+
parsedTokens: this.tokenCacheService.getParsedTokenCache()
|
|
984
|
+
}), await this.submitSessionCheck()), h;
|
|
985
|
+
} catch (r) {
|
|
986
|
+
const o = {
|
|
987
|
+
message: r instanceof Error ? r.message : "Passkey authentication failed",
|
|
988
|
+
originalError: r,
|
|
989
|
+
code: r instanceof u ? r.id : void 0
|
|
990
|
+
};
|
|
991
|
+
throw this.subscribeStore.notify(a.Error, o), r;
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
createFederatedAuthUrl(e) {
|
|
995
|
+
const t = `/auth/federated/start/${e.provider}`;
|
|
996
|
+
if (!this.appId) throw new Error("AppId is required for federated auth");
|
|
997
|
+
const r = {
|
|
998
|
+
scopes: (e.scopes ?? this.scopes).join(" "),
|
|
999
|
+
redirect_url: e.redirect_url ?? this.origin,
|
|
1000
|
+
appId: this.appId,
|
|
1001
|
+
...e.invite_token ? { invite_token: e.invite_token } : {},
|
|
1002
|
+
...e.create_tenant ? { create_tenant: e.create_tenant.toString() } : {},
|
|
1003
|
+
...e.device ? { device: e.device } : {}
|
|
1004
|
+
}, o = new URL(t, this.url), n = new URLSearchParams(r);
|
|
1005
|
+
return o.search = n.toString(), o.toString();
|
|
1006
|
+
}
|
|
1007
|
+
federatedAuthWithPopup(e) {
|
|
1008
|
+
this.subscribeStore.notify(a.SignInStart, { provider: e.provider });
|
|
1009
|
+
const t = e.scopes ?? this.scopes, s = this.deviceService.getDeviceId(), r = this.createFederatedAuthUrl({ ...e, scopes: t, device: s }), o = window.open(r, "_blank", "width=500,height=500");
|
|
1010
|
+
if (!o)
|
|
1011
|
+
this.federatedAuthWithRedirect(e);
|
|
1012
|
+
else {
|
|
1013
|
+
const n = setInterval(() => {
|
|
1014
|
+
if (o.location.href.startsWith(this.origin)) {
|
|
1015
|
+
const h = new URLSearchParams(o.location.search), l = h.get("access_token") || "", p = h.get("refresh_token") || "", v = h.get("id_token") || "", k = {
|
|
1016
|
+
access_token: l,
|
|
1017
|
+
refresh_token: p,
|
|
1018
|
+
id_token: v,
|
|
1019
|
+
scopes: t
|
|
1020
|
+
};
|
|
1021
|
+
this.storageManager.saveTokens(k), this.tokenCacheService.setTokensCache(k), this.subscribeStore.notify(a.SignIn, {
|
|
1022
|
+
tokens: k,
|
|
1023
|
+
parsedTokens: this.tokenCacheService.getParsedTokenCache()
|
|
1024
|
+
}), window.location.href = `${this.origin}`, clearInterval(n), o.close();
|
|
1025
|
+
}
|
|
1026
|
+
}, 100);
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
federatedAuthWithRedirect(e) {
|
|
1030
|
+
this.subscribeStore.notify(a.SignInStart, { provider: e.provider });
|
|
1031
|
+
const t = e.scopes ?? this.scopes, s = this.deviceService.getDeviceId(), r = this.createFederatedAuthUrl({ ...e, scopes: t, device: s });
|
|
1032
|
+
window.location.href = r;
|
|
1033
|
+
}
|
|
1034
|
+
// Helper methods for authentication UI redirect
|
|
1035
|
+
authRedirectUrl(e = {}) {
|
|
1036
|
+
try {
|
|
1037
|
+
const { url: t, redirectUrl: s, scopes: r, appId: o } = e ?? {}, n = new URL(t ?? this.url);
|
|
1038
|
+
n.pathname = (n.pathname.endsWith("/") ? n.pathname : n.pathname + "/") + "web";
|
|
1039
|
+
const h = r ?? this.scopes, l = {
|
|
1040
|
+
appId: o ?? this.appId ?? "",
|
|
1041
|
+
redirectto: s ?? window.location.href,
|
|
1042
|
+
scopes: h.join(",")
|
|
1043
|
+
}, p = new URLSearchParams(l);
|
|
1044
|
+
return n.search = p.toString(), n.toString();
|
|
1045
|
+
} catch (t) {
|
|
1046
|
+
const s = {
|
|
1047
|
+
message: t instanceof Error ? t.message : "Failed to create auth redirect URL",
|
|
1048
|
+
originalError: t
|
|
1049
|
+
};
|
|
1050
|
+
throw this.subscribeStore.notify(a.Error, s), t;
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
authRedirect(e = {}) {
|
|
1054
|
+
try {
|
|
1055
|
+
window.location.href = this.authRedirectUrl(e);
|
|
1056
|
+
} catch (t) {
|
|
1057
|
+
const s = {
|
|
1058
|
+
message: t instanceof Error ? t.message : "Failed to redirect to auth page",
|
|
1059
|
+
originalError: t
|
|
1060
|
+
};
|
|
1061
|
+
throw this.subscribeStore.notify(a.Error, s), t;
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
/**
|
|
1065
|
+
* Check if user is authenticated
|
|
1066
|
+
*/
|
|
1067
|
+
isAuthenticated(e) {
|
|
1068
|
+
try {
|
|
1069
|
+
return e ? !f(e.access_token) || !!e.refresh_token && !f(e.refresh_token) : !1;
|
|
1070
|
+
} catch (t) {
|
|
1071
|
+
const s = {
|
|
1072
|
+
message: t instanceof Error ? t.message : "Failed to check authentication status",
|
|
1073
|
+
originalError: t
|
|
1074
|
+
};
|
|
1075
|
+
return this.subscribeStore.notify(a.Error, s), !1;
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
/**
|
|
1079
|
+
* Handle session check and callbacks
|
|
1080
|
+
*/
|
|
1081
|
+
async submitSessionCheck(e = !1) {
|
|
1082
|
+
let t, s;
|
|
1083
|
+
try {
|
|
1084
|
+
t = await this.getTokens(e), s = this.tokenCacheService.getParsedTokenCache();
|
|
1085
|
+
} catch (r) {
|
|
1086
|
+
const o = {
|
|
1087
|
+
message: r instanceof Error || r instanceof u ? r.message : "Session check failed",
|
|
1088
|
+
originalError: r
|
|
1089
|
+
};
|
|
1090
|
+
this.subscribeStore.notify(a.Error, o), t = void 0;
|
|
1091
|
+
}
|
|
1092
|
+
return t && this.sessionCallbacks.createSession && await this.sessionCallbacks.createSession({ tokens: t, parsedTokens: s }), !t && this.sessionCallbacks.expiredSession && await this.sessionCallbacks.expiredSession(), t;
|
|
1093
|
+
}
|
|
1094
|
+
/**
|
|
1095
|
+
* Get tokens and refresh if needed
|
|
1096
|
+
*/
|
|
1097
|
+
async getTokens(e) {
|
|
1098
|
+
try {
|
|
1099
|
+
const t = this.storageManager.getTokens();
|
|
1100
|
+
if (!t || !t.access_token) return;
|
|
1101
|
+
const s = d(t.access_token);
|
|
1102
|
+
return f(s) ? e ? await this.refreshToken() : void 0 : t;
|
|
1103
|
+
} catch (t) {
|
|
1104
|
+
const s = {
|
|
1105
|
+
message: t instanceof Error ? t.message : "Failed to get tokens",
|
|
1106
|
+
originalError: t
|
|
1107
|
+
};
|
|
1108
|
+
this.subscribeStore.notify(a.Error, s);
|
|
1109
|
+
return;
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
class V {
|
|
1114
|
+
constructor(e) {
|
|
1115
|
+
this.invitationAPI = e;
|
|
1116
|
+
}
|
|
1117
|
+
/**
|
|
1118
|
+
* Requests an invitation link that can be used to invite users
|
|
1119
|
+
* @param payload Request invitation payload
|
|
1120
|
+
* @returns Promise with invitation link and token
|
|
1121
|
+
*/
|
|
1122
|
+
requestInviteLink(e) {
|
|
1123
|
+
return this.invitationAPI.requestInviteLink(e);
|
|
1124
|
+
}
|
|
1125
|
+
/**
|
|
1126
|
+
* Gets a list of active invitations
|
|
1127
|
+
* @param options Optional parameters for filtering and pagination
|
|
1128
|
+
* @returns Promise with paginated list of invitations
|
|
1129
|
+
*/
|
|
1130
|
+
getInvitations(e) {
|
|
1131
|
+
return this.invitationAPI.getInvitations(e);
|
|
1132
|
+
}
|
|
1133
|
+
/**
|
|
1134
|
+
* Deletes an invitation by token
|
|
1135
|
+
* @param token The invitation token to delete
|
|
1136
|
+
* @returns Promise with success response
|
|
1137
|
+
*/
|
|
1138
|
+
deleteInvitation(e) {
|
|
1139
|
+
return this.invitationAPI.deleteInvitation(e);
|
|
1140
|
+
}
|
|
1141
|
+
/**
|
|
1142
|
+
* Resends an invitation by token
|
|
1143
|
+
* @param token The invitation token to resend
|
|
1144
|
+
* @returns Promise with success response
|
|
1145
|
+
*/
|
|
1146
|
+
resendInvitation(e) {
|
|
1147
|
+
return this.invitationAPI.resendInvitation(e);
|
|
1148
|
+
}
|
|
1149
|
+
/**
|
|
1150
|
+
* Gets a link to an invitation by id
|
|
1151
|
+
* @param invitationID The invitation ID to get link
|
|
1152
|
+
* @returns Promise with the link
|
|
1153
|
+
*/
|
|
1154
|
+
getInvitationLink(e) {
|
|
1155
|
+
return this.invitationAPI.getInvitationLink(e);
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
class z {
|
|
1159
|
+
error(e, ...t) {
|
|
1160
|
+
console.error(e, ...t);
|
|
1161
|
+
}
|
|
1162
|
+
warn(e, ...t) {
|
|
1163
|
+
console.warn(e, ...t);
|
|
1164
|
+
}
|
|
1165
|
+
info(e, ...t) {
|
|
1166
|
+
console.info(e, ...t);
|
|
1167
|
+
}
|
|
1168
|
+
debug(e, ...t) {
|
|
1169
|
+
console.debug(e, ...t);
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
function J() {
|
|
1173
|
+
return new z();
|
|
1174
|
+
}
|
|
1175
|
+
class Y {
|
|
1176
|
+
constructor(e) {
|
|
1177
|
+
this.data = this.normalize(e);
|
|
1178
|
+
}
|
|
1179
|
+
normalize(e) {
|
|
1180
|
+
const t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), o = [];
|
|
1181
|
+
return e.groups?.forEach((n) => {
|
|
1182
|
+
s.set(n.id, {
|
|
1183
|
+
id: n.id,
|
|
1184
|
+
name: n.name,
|
|
1185
|
+
default: n.default ?? !1,
|
|
1186
|
+
updated_at: n.updated_at,
|
|
1187
|
+
created_at: n.created_at
|
|
1188
|
+
});
|
|
1189
|
+
}), e.roles?.forEach((n) => {
|
|
1190
|
+
r.set(n.id, {
|
|
1191
|
+
id: n.id,
|
|
1192
|
+
tenant_id: n.tenant_id,
|
|
1193
|
+
name: n.name
|
|
1194
|
+
});
|
|
1195
|
+
}), e.users_in_groups?.forEach((n) => {
|
|
1196
|
+
const h = n.user;
|
|
1197
|
+
h && !t.has(h.id) && t.set(h.id, {
|
|
1198
|
+
id: h.id,
|
|
1199
|
+
name: h.name ?? null,
|
|
1200
|
+
email: h.email ?? null,
|
|
1201
|
+
phone: h.phone ?? null
|
|
1202
|
+
}), h && n.group_id && s.has(n.group_id) && o.push({
|
|
1203
|
+
userId: h.id,
|
|
1204
|
+
groupId: n.group_id,
|
|
1205
|
+
roleIds: n.roles?.map((l) => l.id) ?? []
|
|
1206
|
+
});
|
|
1207
|
+
}), {
|
|
1208
|
+
tenant_id: e.tenant_id,
|
|
1209
|
+
tenant_name: e.tenant_name,
|
|
1210
|
+
users: Array.from(t.values()),
|
|
1211
|
+
groups: Array.from(s.values()),
|
|
1212
|
+
roles: Array.from(r.values()),
|
|
1213
|
+
memberships: o,
|
|
1214
|
+
usersById: t,
|
|
1215
|
+
groupsById: s,
|
|
1216
|
+
rolesById: r
|
|
1217
|
+
};
|
|
1218
|
+
}
|
|
1219
|
+
/**
|
|
1220
|
+
* Returns all users in the specified group.
|
|
1221
|
+
*/
|
|
1222
|
+
getUsersInGroup(e) {
|
|
1223
|
+
return this.data.memberships.filter((t) => t.groupId === e).map((t) => this.data.usersById.get(t.userId)).filter((t) => t !== void 0);
|
|
1224
|
+
}
|
|
1225
|
+
/**
|
|
1226
|
+
* Returns all groups to which the specified user belongs.
|
|
1227
|
+
*/
|
|
1228
|
+
getGroupsForUser(e) {
|
|
1229
|
+
return this.data.memberships.filter((t) => t.userId === e).map((t) => this.data.groupsById.get(t.groupId)).filter((t) => t !== void 0);
|
|
1230
|
+
}
|
|
1231
|
+
/**
|
|
1232
|
+
* Returns all roles that the specified user has in the specified group.
|
|
1233
|
+
*/
|
|
1234
|
+
getUserRolesInGroup(e, t) {
|
|
1235
|
+
const s = this.data.memberships.find((r) => r.userId === e && r.groupId === t);
|
|
1236
|
+
return s ? s.roleIds.map((r) => this.data.rolesById.get(r)).filter((r) => r !== void 0) : [];
|
|
1237
|
+
}
|
|
1238
|
+
/**
|
|
1239
|
+
* Returns the full TenantData object.
|
|
1240
|
+
*/
|
|
1241
|
+
getData() {
|
|
1242
|
+
return this.data;
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
class X {
|
|
1246
|
+
constructor(e, t, s) {
|
|
1247
|
+
this.tenantAPI = e, this.scopes = t, this.logger = s || J();
|
|
1248
|
+
}
|
|
1249
|
+
/**
|
|
1250
|
+
* Handle Passflow API errors
|
|
1251
|
+
* @param error The error object
|
|
1252
|
+
* @param context Context information for logging
|
|
1253
|
+
* @throws Formatted error with Passflow API error details
|
|
1254
|
+
*/
|
|
1255
|
+
handlePassflowError(e, t) {
|
|
1256
|
+
if (T.isAxiosError(e) && e.response?.data) {
|
|
1257
|
+
const s = e.response.data;
|
|
1258
|
+
if (typeof s == "object" && s !== null && "error" in s && typeof s.error == "object" && s.error !== null) {
|
|
1259
|
+
const r = s.error;
|
|
1260
|
+
throw this.logger.error(`${t}: ${r.id} - ${r.message} (Status: ${r.status})`), new Error(`Passflow API Error: ${r.id} - ${r.message} (Status: ${r.status})`);
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
throw this.logger.error(`${t}:`, e), e instanceof Error ? e : new Error(String(e));
|
|
1264
|
+
}
|
|
1265
|
+
/**
|
|
1266
|
+
* Join a tenant invitation
|
|
1267
|
+
* @param token The invitation token
|
|
1268
|
+
* @param scopes Optional scopes to request
|
|
1269
|
+
* @returns Promise with invite response
|
|
1270
|
+
*/
|
|
1271
|
+
async joinInvitation(e, t) {
|
|
1272
|
+
try {
|
|
1273
|
+
const s = t ?? this.scopes;
|
|
1274
|
+
return await this.tenantAPI.joinInvitation(e, s);
|
|
1275
|
+
} catch (s) {
|
|
1276
|
+
this.handlePassflowError(s, "Join invitation failed");
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
/**
|
|
1280
|
+
* Create a new tenant
|
|
1281
|
+
* @param name The name of the tenant
|
|
1282
|
+
* @returns Promise with tenant response
|
|
1283
|
+
*/
|
|
1284
|
+
async createTenant(e) {
|
|
1285
|
+
try {
|
|
1286
|
+
return await this.tenantAPI.createTenant(e);
|
|
1287
|
+
} catch (t) {
|
|
1288
|
+
this.handlePassflowError(t, "Tenant creation failed");
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
// 1. Tenant Management
|
|
1292
|
+
/**
|
|
1293
|
+
* Get tenant details
|
|
1294
|
+
* @param tenantId Tenant ID
|
|
1295
|
+
* @returns Promise with tenant response
|
|
1296
|
+
*/
|
|
1297
|
+
/**
|
|
1298
|
+
* Get tenant details
|
|
1299
|
+
* @param tenantId Tenant ID
|
|
1300
|
+
* @returns Promise with tenant response
|
|
1301
|
+
*/
|
|
1302
|
+
async getTenantDetails(e) {
|
|
1303
|
+
try {
|
|
1304
|
+
return await this.tenantAPI.getTenantDetails(e);
|
|
1305
|
+
} catch (t) {
|
|
1306
|
+
this.handlePassflowError(t, `Get tenant details failed for tenant ID ${e}`);
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
/**
|
|
1310
|
+
* Get tenant details and transform into TenantUserMembership
|
|
1311
|
+
* @param tenantId Tenant ID
|
|
1312
|
+
* @returns Promise with TenantUserMembership instance
|
|
1313
|
+
*/
|
|
1314
|
+
async getTenantUserMembership(e) {
|
|
1315
|
+
try {
|
|
1316
|
+
const t = await this.tenantAPI.getTenantDetails(e);
|
|
1317
|
+
return new Y(t);
|
|
1318
|
+
} catch (t) {
|
|
1319
|
+
this.handlePassflowError(t, `Get tenant user membership failed for tenant ID ${e}`);
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
/**
|
|
1323
|
+
* Update tenant name
|
|
1324
|
+
* @param tenantId Tenant ID
|
|
1325
|
+
* @param name New tenant name
|
|
1326
|
+
* @returns Promise with status response
|
|
1327
|
+
*/
|
|
1328
|
+
async updateTenant(e, t) {
|
|
1329
|
+
try {
|
|
1330
|
+
return await this.tenantAPI.updateTenant(e, t);
|
|
1331
|
+
} catch (s) {
|
|
1332
|
+
this.handlePassflowError(s, `Update tenant failed for tenant ID ${e}`);
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
/**
|
|
1336
|
+
* Delete a tenant
|
|
1337
|
+
* @param tenantId Tenant ID
|
|
1338
|
+
* @returns Promise with status response
|
|
1339
|
+
*/
|
|
1340
|
+
async deleteTenant(e) {
|
|
1341
|
+
try {
|
|
1342
|
+
return await this.tenantAPI.deleteTenant(e);
|
|
1343
|
+
} catch (t) {
|
|
1344
|
+
this.handlePassflowError(t, `Delete tenant failed for tenant ID ${e}`);
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
/**
|
|
1348
|
+
* Get user's tenant memberships
|
|
1349
|
+
* @returns Promise with user tenant membership response
|
|
1350
|
+
*/
|
|
1351
|
+
async getUserTenantMembership() {
|
|
1352
|
+
try {
|
|
1353
|
+
return await this.tenantAPI.getUserTenantMembership();
|
|
1354
|
+
} catch (e) {
|
|
1355
|
+
this.handlePassflowError(e, "Get user tenant memberships failed");
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
// 2. Group Management
|
|
1359
|
+
/**
|
|
1360
|
+
* Create a group in a tenant
|
|
1361
|
+
* @param tenantId Tenant ID
|
|
1362
|
+
* @param name Group name
|
|
1363
|
+
* @returns Promise with group response
|
|
1364
|
+
*/
|
|
1365
|
+
async createGroup(e, t) {
|
|
1366
|
+
try {
|
|
1367
|
+
return await this.tenantAPI.createGroup(e, t);
|
|
1368
|
+
} catch (s) {
|
|
1369
|
+
this.handlePassflowError(s, `Group creation failed for tenant ID ${e}`);
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
/**
|
|
1373
|
+
* Get group information
|
|
1374
|
+
* @param tenantId Tenant ID
|
|
1375
|
+
* @param groupId Group ID
|
|
1376
|
+
* @returns Promise with group response
|
|
1377
|
+
*/
|
|
1378
|
+
async getGroupInfo(e, t) {
|
|
1379
|
+
try {
|
|
1380
|
+
return await this.tenantAPI.getGroupInfo(e, t);
|
|
1381
|
+
} catch (s) {
|
|
1382
|
+
this.handlePassflowError(s, `Get group info failed for tenant ID ${e}, group ID ${t}`);
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
/**
|
|
1386
|
+
* Update a group
|
|
1387
|
+
* @param tenantId Tenant ID
|
|
1388
|
+
* @param groupId Group ID
|
|
1389
|
+
* @param name New group name
|
|
1390
|
+
* @returns Promise with group response
|
|
1391
|
+
*/
|
|
1392
|
+
async updateGroup(e, t, s) {
|
|
1393
|
+
try {
|
|
1394
|
+
return await this.tenantAPI.updateGroup(e, t, s);
|
|
1395
|
+
} catch (r) {
|
|
1396
|
+
this.handlePassflowError(r, `Update group failed for tenant ID ${e}, group ID ${t}`);
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
/**
|
|
1400
|
+
* Delete a group
|
|
1401
|
+
* @param tenantId Tenant ID
|
|
1402
|
+
* @param groupId Group ID
|
|
1403
|
+
* @returns Promise with status response
|
|
1404
|
+
*/
|
|
1405
|
+
async deleteGroup(e, t) {
|
|
1406
|
+
try {
|
|
1407
|
+
return await this.tenantAPI.deleteGroup(e, t);
|
|
1408
|
+
} catch (s) {
|
|
1409
|
+
this.handlePassflowError(s, `Delete group failed for tenant ID ${e}, group ID ${t}`);
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
/**
|
|
1413
|
+
* Add a user to a group
|
|
1414
|
+
* @param tenantId Tenant ID
|
|
1415
|
+
* @param groupId Group ID
|
|
1416
|
+
* @param userId User ID
|
|
1417
|
+
* @param role Role to assign
|
|
1418
|
+
* @returns Promise with status response
|
|
1419
|
+
*/
|
|
1420
|
+
async addUserToGroup(e, t, s, r) {
|
|
1421
|
+
try {
|
|
1422
|
+
return await this.tenantAPI.addUserToGroup(e, t, s, r);
|
|
1423
|
+
} catch (o) {
|
|
1424
|
+
this.handlePassflowError(
|
|
1425
|
+
o,
|
|
1426
|
+
`Add user to group failed for tenant ID ${e}, group ID ${t}, user ID ${s}`
|
|
1427
|
+
);
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
/**
|
|
1431
|
+
* Remove user roles from a group
|
|
1432
|
+
* @param tenantId Tenant ID
|
|
1433
|
+
* @param groupId Group ID
|
|
1434
|
+
* @param userId User ID
|
|
1435
|
+
* @param roles Roles to remove
|
|
1436
|
+
* @returns Promise with status response
|
|
1437
|
+
*/
|
|
1438
|
+
async removeUserRolesFromGroup(e, t, s, r) {
|
|
1439
|
+
try {
|
|
1440
|
+
return await this.tenantAPI.removeUserRolesFromGroup(e, t, s, r);
|
|
1441
|
+
} catch (o) {
|
|
1442
|
+
this.handlePassflowError(
|
|
1443
|
+
o,
|
|
1444
|
+
`Remove user roles from group failed for tenant ID ${e}, group ID ${t}, user ID ${s}`
|
|
1445
|
+
);
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
/**
|
|
1449
|
+
* Change user roles in a group
|
|
1450
|
+
* @param tenantId Tenant ID
|
|
1451
|
+
* @param groupId Group ID
|
|
1452
|
+
* @param userId User ID
|
|
1453
|
+
* @param roles New roles to assign
|
|
1454
|
+
* @returns Promise with status response
|
|
1455
|
+
*/
|
|
1456
|
+
async changeUserRoles(e, t, s, r) {
|
|
1457
|
+
try {
|
|
1458
|
+
return await this.tenantAPI.changeUserRoles(e, t, s, r);
|
|
1459
|
+
} catch (o) {
|
|
1460
|
+
this.handlePassflowError(
|
|
1461
|
+
o,
|
|
1462
|
+
`Change user roles failed for tenant ID ${e}, group ID ${t}, user ID ${s}`
|
|
1463
|
+
);
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
/**
|
|
1467
|
+
* Delete a user from a group
|
|
1468
|
+
* @param tenantId Tenant ID
|
|
1469
|
+
* @param groupId Group ID
|
|
1470
|
+
* @param userId User ID
|
|
1471
|
+
* @returns Promise with status response
|
|
1472
|
+
*/
|
|
1473
|
+
async deleteUserFromGroup(e, t, s) {
|
|
1474
|
+
try {
|
|
1475
|
+
return await this.tenantAPI.deleteUserFromGroup(e, t, s);
|
|
1476
|
+
} catch (r) {
|
|
1477
|
+
this.handlePassflowError(
|
|
1478
|
+
r,
|
|
1479
|
+
`Delete user from group failed for tenant ID ${e}, group ID ${t}, user ID ${s}`
|
|
1480
|
+
);
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
// 3. Role Management
|
|
1484
|
+
/**
|
|
1485
|
+
* Get roles for a tenant
|
|
1486
|
+
* @param tenantId Tenant ID
|
|
1487
|
+
* @returns Promise with array of role responses
|
|
1488
|
+
*/
|
|
1489
|
+
async getRolesForTenant(e) {
|
|
1490
|
+
try {
|
|
1491
|
+
return await this.tenantAPI.getRolesForTenant(e);
|
|
1492
|
+
} catch (t) {
|
|
1493
|
+
this.handlePassflowError(t, `Get roles for tenant failed for tenant ID ${e}`);
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
/**
|
|
1497
|
+
* Create a role for a tenant
|
|
1498
|
+
* @param tenantId Tenant ID
|
|
1499
|
+
* @param name Role name
|
|
1500
|
+
* @returns Promise with role response
|
|
1501
|
+
*/
|
|
1502
|
+
async createRoleForTenant(e, t) {
|
|
1503
|
+
try {
|
|
1504
|
+
return await this.tenantAPI.createRoleForTenant(e, t);
|
|
1505
|
+
} catch (s) {
|
|
1506
|
+
this.handlePassflowError(s, `Create role for tenant failed for tenant ID ${e}`);
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
/**
|
|
1510
|
+
* Update a role
|
|
1511
|
+
* @param tenantId Tenant ID
|
|
1512
|
+
* @param roleId Role ID
|
|
1513
|
+
* @param name New role name
|
|
1514
|
+
* @returns Promise with role response
|
|
1515
|
+
*/
|
|
1516
|
+
async updateRole(e, t, s) {
|
|
1517
|
+
try {
|
|
1518
|
+
return await this.tenantAPI.updateRole(e, t, s);
|
|
1519
|
+
} catch (r) {
|
|
1520
|
+
this.handlePassflowError(r, `Update role failed for tenant ID ${e}, role ID ${t}`);
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
/**
|
|
1524
|
+
* Delete a role
|
|
1525
|
+
* @param tenantId Tenant ID
|
|
1526
|
+
* @param roleId Role ID
|
|
1527
|
+
* @returns Promise with status response
|
|
1528
|
+
*/
|
|
1529
|
+
async deleteRole(e, t) {
|
|
1530
|
+
try {
|
|
1531
|
+
return await this.tenantAPI.deleteRole(e, t);
|
|
1532
|
+
} catch (s) {
|
|
1533
|
+
this.handlePassflowError(s, `Delete role failed for tenant ID ${e}, role ID ${t}`);
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
// 4. User Management in Tenants
|
|
1537
|
+
/**
|
|
1538
|
+
* Delete a user from a tenant
|
|
1539
|
+
* @param tenantId Tenant ID
|
|
1540
|
+
* @param userId User ID
|
|
1541
|
+
* @returns Promise with status response
|
|
1542
|
+
*/
|
|
1543
|
+
async deleteUserFromTenant(e, t) {
|
|
1544
|
+
try {
|
|
1545
|
+
return await this.tenantAPI.deleteUserFromTenant(e, t);
|
|
1546
|
+
} catch (s) {
|
|
1547
|
+
this.handlePassflowError(s, `Delete user from tenant failed for tenant ID ${e}, user ID ${t}`);
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
// 5. Invitation Management
|
|
1551
|
+
/**
|
|
1552
|
+
* Get invitations to a group
|
|
1553
|
+
* @param tenantId Tenant ID
|
|
1554
|
+
* @param groupId Group ID
|
|
1555
|
+
* @param limit Maximum number of invitations to return
|
|
1556
|
+
* @param skip Number of invitations to skip
|
|
1557
|
+
* @returns Promise with invitations response
|
|
1558
|
+
*/
|
|
1559
|
+
async getGroupInvitations(e, t, s, r) {
|
|
1560
|
+
try {
|
|
1561
|
+
return await this.tenantAPI.getGroupInvitations(e, t, s, r);
|
|
1562
|
+
} catch (o) {
|
|
1563
|
+
this.handlePassflowError(o, `Get group invitations failed for tenant ID ${e}, group ID ${t}`);
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
/**
|
|
1567
|
+
* Get invitations to a tenant
|
|
1568
|
+
* @param tenantId Tenant ID
|
|
1569
|
+
* @param limit Maximum number of invitations to return
|
|
1570
|
+
* @param skip Number of invitations to skip
|
|
1571
|
+
* @returns Promise with invitations response
|
|
1572
|
+
*/
|
|
1573
|
+
async getTenantInvitations(e, t, s) {
|
|
1574
|
+
try {
|
|
1575
|
+
return await this.tenantAPI.getTenantInvitations(e, t, s);
|
|
1576
|
+
} catch (r) {
|
|
1577
|
+
this.handlePassflowError(r, `Get tenant invitations failed for tenant ID ${e}`);
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1580
|
+
/**
|
|
1581
|
+
* Invalidate an invitation by ID
|
|
1582
|
+
* @param tenantId Tenant ID
|
|
1583
|
+
* @param groupId Group ID
|
|
1584
|
+
* @param inviteId Invitation ID
|
|
1585
|
+
* @returns Promise with empty record
|
|
1586
|
+
*/
|
|
1587
|
+
async invalidateInviteById(e, t, s) {
|
|
1588
|
+
try {
|
|
1589
|
+
return await this.tenantAPI.invalidateInviteById(e, t, s);
|
|
1590
|
+
} catch (r) {
|
|
1591
|
+
this.handlePassflowError(
|
|
1592
|
+
r,
|
|
1593
|
+
`Invalidate invite by ID failed for tenant ID ${e}, group ID ${t}, invite ID ${s}`
|
|
1594
|
+
);
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
/**
|
|
1598
|
+
* Invalidate an invitation by email
|
|
1599
|
+
* @param tenantId Tenant ID
|
|
1600
|
+
* @param groupId Group ID
|
|
1601
|
+
* @param email Email address
|
|
1602
|
+
* @returns Promise with empty record
|
|
1603
|
+
*/
|
|
1604
|
+
async invalidateInviteByEmail(e, t, s) {
|
|
1605
|
+
try {
|
|
1606
|
+
return await this.tenantAPI.invalidateInviteByEmail(e, t, s);
|
|
1607
|
+
} catch (r) {
|
|
1608
|
+
this.handlePassflowError(
|
|
1609
|
+
r,
|
|
1610
|
+
`Invalidate invite by email failed for tenant ID ${e}, group ID ${t}, email ${s}`
|
|
1611
|
+
);
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
class Q {
|
|
1616
|
+
constructor(e, t) {
|
|
1617
|
+
this.userAPI = e, this.deviceService = t;
|
|
1618
|
+
}
|
|
1619
|
+
/**
|
|
1620
|
+
* Get user's registered passkeys
|
|
1621
|
+
* @returns Promise with passkeys array
|
|
1622
|
+
*/
|
|
1623
|
+
getUserPasskeys() {
|
|
1624
|
+
return this.userAPI.getUserPasskeys();
|
|
1625
|
+
}
|
|
1626
|
+
/**
|
|
1627
|
+
* Rename a user passkey
|
|
1628
|
+
* @param name The new name for the passkey
|
|
1629
|
+
* @param passkeyId The ID of the passkey to rename
|
|
1630
|
+
* @returns Promise with success response
|
|
1631
|
+
*/
|
|
1632
|
+
renameUserPasskey(e, t) {
|
|
1633
|
+
return this.userAPI.renameUserPasskey(e, t);
|
|
1634
|
+
}
|
|
1635
|
+
/**
|
|
1636
|
+
* Delete a user passkey
|
|
1637
|
+
* @param passkeyId The ID of the passkey to delete
|
|
1638
|
+
* @returns Promise with success response
|
|
1639
|
+
*/
|
|
1640
|
+
deleteUserPasskey(e) {
|
|
1641
|
+
return this.userAPI.deleteUserPasskey(e);
|
|
1642
|
+
}
|
|
1643
|
+
/**
|
|
1644
|
+
* Add a new passkey for the current user
|
|
1645
|
+
* @param options Optional parameters for the passkey
|
|
1646
|
+
* @returns Promise that resolves when the passkey is added
|
|
1647
|
+
*/
|
|
1648
|
+
async addUserPasskey({
|
|
1649
|
+
relyingPartyId: e,
|
|
1650
|
+
passkeyUsername: t,
|
|
1651
|
+
passkeyDisplayName: s
|
|
1652
|
+
} = {}) {
|
|
1653
|
+
const r = this.deviceService.getDeviceId(), o = w.web, { challenge_id: n, publicKey: h } = await this.userAPI.addUserPasskeyStart({
|
|
1654
|
+
relyingPartyId: e || window?.location?.hostname,
|
|
1655
|
+
deviceId: r,
|
|
1656
|
+
os: o,
|
|
1657
|
+
passkeyDisplayName: s,
|
|
1658
|
+
passkeyUsername: t
|
|
1659
|
+
});
|
|
1660
|
+
h.user.id = btoa(h.user.id);
|
|
1661
|
+
const l = await _({ optionsJSON: h });
|
|
1662
|
+
return await this.userAPI.addUserPasskeyComplete(l, r, n);
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
class Z {
|
|
1666
|
+
constructor(e, t, s) {
|
|
1667
|
+
this.storageManager = e, this.authApi = t, this.subscribeStore = s, this.checkInterval = null, this.CHECK_INTERVAL = 10, this.isRefreshing = !1, this.isExpired = !1, this.storageManager = e, this.authApi = t;
|
|
1668
|
+
}
|
|
1669
|
+
initialize() {
|
|
1670
|
+
try {
|
|
1671
|
+
const e = this.storageManager.getTokens();
|
|
1672
|
+
if (!e || !e.access_token) {
|
|
1673
|
+
this.startTokenCheck();
|
|
1674
|
+
return;
|
|
1675
|
+
}
|
|
1676
|
+
const t = d(e.access_token);
|
|
1677
|
+
f(t) ? (this.isExpired = !0, this.stopTokenCheck(), this.subscribeStore.notify(a.TokenCacheExpired, { isExpired: !0 })) : (this.setTokensCache(e), this.startTokenCheck());
|
|
1678
|
+
} catch (e) {
|
|
1679
|
+
const t = {
|
|
1680
|
+
message: e instanceof Error ? e.message : "Failed to get tokens",
|
|
1681
|
+
originalError: e
|
|
1682
|
+
};
|
|
1683
|
+
this.subscribeStore.notify(a.Error, t), this.setTokensCache(void 0);
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
async refreshTokensCache(e) {
|
|
1687
|
+
if (!this.isRefreshing)
|
|
1688
|
+
try {
|
|
1689
|
+
this.isRefreshing = !0, this.subscribeStore.notify(a.RefreshStart, {});
|
|
1690
|
+
const t = await this.authApi.refreshToken(e?.refresh_token ?? "", e.scopes ?? [], e.access_token);
|
|
1691
|
+
this.setTokensCache(t), this.subscribeStore.notify(a.Refresh, { tokens: t, parsedTokens: this.getParsedTokenCache() }), this.subscribeStore.notify(a.TokenCacheExpired, { isExpired: !1 }), this.isExpired = !1, this.startTokenCheck();
|
|
1692
|
+
} catch (t) {
|
|
1693
|
+
const s = {
|
|
1694
|
+
message: t instanceof Error ? t.message : "Failed to get tokens",
|
|
1695
|
+
originalError: t
|
|
1696
|
+
};
|
|
1697
|
+
this.subscribeStore.notify(a.Error, s), this.setTokensCache(void 0);
|
|
1698
|
+
} finally {
|
|
1699
|
+
this.isRefreshing = !1;
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
startTokenCheck() {
|
|
1703
|
+
this.checkInterval && clearInterval(this.checkInterval), !this.isExpired && (this.checkInterval = setInterval(() => {
|
|
1704
|
+
this.isRefreshing || this.isExpired || this.tokensCacheIsExpired() && !this.isExpired && (this.isExpired = !0, this.subscribeStore.notify(a.TokenCacheExpired, { isExpired: !0 }), this.stopTokenCheck());
|
|
1705
|
+
}, this.CHECK_INTERVAL));
|
|
1706
|
+
}
|
|
1707
|
+
stopTokenCheck() {
|
|
1708
|
+
this.checkInterval && (clearInterval(this.checkInterval), this.checkInterval = null);
|
|
1709
|
+
}
|
|
1710
|
+
setTokensCache(e) {
|
|
1711
|
+
this.tokensCache = e, e ? this.parsedTokensCache = {
|
|
1712
|
+
access_token: d(e.access_token),
|
|
1713
|
+
id_token: e.id_token ? d(e.id_token) : void 0,
|
|
1714
|
+
refresh_token: e.refresh_token ? d(e.refresh_token) : void 0,
|
|
1715
|
+
scopes: e.scopes
|
|
1716
|
+
} : this.parsedTokensCache = void 0;
|
|
1717
|
+
}
|
|
1718
|
+
getTokensCache() {
|
|
1719
|
+
return this.tokensCache;
|
|
1720
|
+
}
|
|
1721
|
+
async getTokensCacheWithRefresh() {
|
|
1722
|
+
try {
|
|
1723
|
+
if (!this.tokensCache) return this.tokensCache;
|
|
1724
|
+
const e = d(this.tokensCache.access_token);
|
|
1725
|
+
return f(e) && !this.isExpired ? (await this.refreshTokensCache(this.tokensCache), this.tokensCache) : this.tokensCache;
|
|
1726
|
+
} catch (e) {
|
|
1727
|
+
const t = {
|
|
1728
|
+
message: e instanceof Error ? e.message : "Failed to get tokens",
|
|
1729
|
+
originalError: e
|
|
1730
|
+
};
|
|
1731
|
+
this.subscribeStore.notify(a.Error, t);
|
|
1732
|
+
return;
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
getParsedTokenCache() {
|
|
1736
|
+
return this.parsedTokensCache;
|
|
1737
|
+
}
|
|
1738
|
+
tokensCacheIsExpired() {
|
|
1739
|
+
if (!this.tokensCache) return !0;
|
|
1740
|
+
const e = d(this.tokensCache.access_token);
|
|
1741
|
+
return f(e);
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
class ie {
|
|
1745
|
+
constructor(e) {
|
|
1746
|
+
this.doRefreshTokens = !1, this.origin = window.location.origin, this.session = async ({
|
|
1747
|
+
createSession: o,
|
|
1748
|
+
expiredSession: n,
|
|
1749
|
+
doRefresh: h = !1
|
|
1750
|
+
}) => {
|
|
1751
|
+
this.createSessionCallback = o, this.expiredSessionCallback = n, this.doRefreshTokens = h, await this.submitSessionCheck();
|
|
1752
|
+
};
|
|
1753
|
+
const { url: t, appId: s, scopes: r } = e;
|
|
1754
|
+
this.url = t || A, this.appId = s, this.authApi = new O(e), this.appApi = new j(e), this.userApi = new N(e), this.settingApi = new K(e), this.tenantAPI = new B(e), this.invitationAPI = new W(e), this.storageManager = new b({
|
|
1755
|
+
prefix: e.keyStoragePrefix ?? ""
|
|
1756
|
+
}), this.deviceService = new $(), this.subscribeStore = new H(), this.tokenCacheService = new Z(this.storageManager, this.authApi, this.subscribeStore), this.scopes = r ?? F, this.createTenantForNewUser = e.createTenantForNewUser ?? !1, this.authService = new q(
|
|
1757
|
+
this.authApi,
|
|
1758
|
+
this.deviceService,
|
|
1759
|
+
this.storageManager,
|
|
1760
|
+
this.subscribeStore,
|
|
1761
|
+
this.tokenCacheService,
|
|
1762
|
+
this.scopes,
|
|
1763
|
+
this.createTenantForNewUser,
|
|
1764
|
+
this.origin,
|
|
1765
|
+
this.url,
|
|
1766
|
+
{
|
|
1767
|
+
createSession: this.createSessionCallback,
|
|
1768
|
+
expiredSession: this.expiredSessionCallback
|
|
1769
|
+
},
|
|
1770
|
+
this.appId ?? ""
|
|
1771
|
+
), this.userService = new Q(this.userApi, this.deviceService), this.tenantService = new X(this.tenantAPI, this.scopes), this.tenant = this.tenantService, this.invitationService = new V(this.invitationAPI), e.parseQueryParams && this.checkAndSetTokens(), this.setTokensToCacheFromLocalStorage();
|
|
1772
|
+
}
|
|
1773
|
+
async submitSessionCheck() {
|
|
1774
|
+
let e, t;
|
|
1775
|
+
try {
|
|
1776
|
+
e = await this.authService.getTokens(this.doRefreshTokens), t = this.tokenCacheService.getParsedTokenCache();
|
|
1777
|
+
} catch (s) {
|
|
1778
|
+
const r = {
|
|
1779
|
+
message: s instanceof Error || s instanceof u ? s.message : "Session check failed",
|
|
1780
|
+
originalError: s
|
|
1781
|
+
};
|
|
1782
|
+
this.subscribeStore.notify(a.Error, r), e = void 0;
|
|
1783
|
+
}
|
|
1784
|
+
e && this.createSessionCallback && await this.createSessionCallback({ tokens: e, parsedTokens: t }), !e && this.expiredSessionCallback && await this.expiredSessionCallback();
|
|
1785
|
+
}
|
|
1786
|
+
// Event subscription
|
|
1787
|
+
subscribe(e, t) {
|
|
1788
|
+
this.subscribeStore.subscribe(e, t), this.tokenCacheService.initialize();
|
|
1789
|
+
}
|
|
1790
|
+
unsubscribe(e, t) {
|
|
1791
|
+
this.subscribeStore.unsubscribe(e, t);
|
|
1792
|
+
}
|
|
1793
|
+
// Token handling
|
|
1794
|
+
handleTokensRedirect() {
|
|
1795
|
+
return this.checkAndSetTokens();
|
|
1796
|
+
}
|
|
1797
|
+
checkAndSetTokens() {
|
|
1798
|
+
const e = new URLSearchParams(window.location.search), t = e.get("access_token"), s = e.get("refresh_token"), r = e.get("id_token"), o = e.get("scopes")?.split(",") ?? this.scopes;
|
|
1799
|
+
let n;
|
|
1800
|
+
if (t)
|
|
1801
|
+
return n = {
|
|
1802
|
+
access_token: t,
|
|
1803
|
+
refresh_token: s ?? void 0,
|
|
1804
|
+
id_token: r ?? void 0,
|
|
1805
|
+
scopes: o
|
|
1806
|
+
}, this.storageManager.saveTokens(n), this.tokenCacheService.setTokensCache(n), this.subscribeStore.notify(a.SignIn, { tokens: n, parsedTokens: this.getParsedTokenCache() }), this.submitSessionCheck(), e.delete("access_token"), e.delete("refresh_token"), e.delete("id_token"), e.delete("client_challenge"), e.size > 0 ? window.history.replaceState({}, document.title, `${window.location.pathname}?${e.toString()}`) : window.history.replaceState({}, document.title, window.location.pathname), this.error = void 0, n;
|
|
1807
|
+
this.error = this.checkErrorsFromURL();
|
|
1808
|
+
}
|
|
1809
|
+
checkErrorsFromURL() {
|
|
1810
|
+
const t = new URLSearchParams(window.location.search).get("error");
|
|
1811
|
+
if (t)
|
|
1812
|
+
return new Error(t);
|
|
1813
|
+
}
|
|
1814
|
+
setTokensToCacheFromLocalStorage() {
|
|
1815
|
+
const e = this.storageManager.getTokens();
|
|
1816
|
+
e && this.tokenCacheService.setTokensCache(e);
|
|
1817
|
+
}
|
|
1818
|
+
getTokensCache() {
|
|
1819
|
+
return this.tokenCacheService.getTokensCache();
|
|
1820
|
+
}
|
|
1821
|
+
getTokensCacheWithRefresh() {
|
|
1822
|
+
return this.tokenCacheService.getTokensCacheWithRefresh();
|
|
1823
|
+
}
|
|
1824
|
+
getParsedTokenCache() {
|
|
1825
|
+
return this.tokenCacheService.getParsedTokenCache();
|
|
1826
|
+
}
|
|
1827
|
+
tokensCacheIsExpired() {
|
|
1828
|
+
return this.tokenCacheService.tokensCacheIsExpired();
|
|
1829
|
+
}
|
|
1830
|
+
// Auth delegation methods
|
|
1831
|
+
isAuthenticated() {
|
|
1832
|
+
const e = this.storageManager.getTokens();
|
|
1833
|
+
if (!e || !e.access_token) return !1;
|
|
1834
|
+
const t = {
|
|
1835
|
+
access_token: d(e.access_token),
|
|
1836
|
+
refresh_token: e.refresh_token ? d(e.refresh_token) : void 0
|
|
1837
|
+
};
|
|
1838
|
+
return this.authService.isAuthenticated(t);
|
|
1839
|
+
}
|
|
1840
|
+
async signIn(e) {
|
|
1841
|
+
return await this.authService.signIn(e);
|
|
1842
|
+
}
|
|
1843
|
+
async signUp(e) {
|
|
1844
|
+
return await this.authService.signUp(e);
|
|
1845
|
+
}
|
|
1846
|
+
passwordlessSignIn(e) {
|
|
1847
|
+
return this.authService.passwordlessSignIn(e);
|
|
1848
|
+
}
|
|
1849
|
+
async passwordlessSignInComplete(e) {
|
|
1850
|
+
return await this.authService.passwordlessSignInComplete(e);
|
|
1851
|
+
}
|
|
1852
|
+
async logOut() {
|
|
1853
|
+
try {
|
|
1854
|
+
await this.authService.logOut(), this.storageManager.deleteTokens(), await this.submitSessionCheck();
|
|
1855
|
+
} catch (e) {
|
|
1856
|
+
const t = {
|
|
1857
|
+
message: e instanceof Error ? e.message : "Failed to log out",
|
|
1858
|
+
originalError: e
|
|
1859
|
+
};
|
|
1860
|
+
this.subscribeStore.notify(a.Error, t);
|
|
1861
|
+
}
|
|
1862
|
+
this.tokenCacheService.setTokensCache(void 0), this.subscribeStore.notify(a.SignOut, {});
|
|
1863
|
+
}
|
|
1864
|
+
federatedAuthWithPopup(e) {
|
|
1865
|
+
this.authService.federatedAuthWithPopup(e);
|
|
1866
|
+
}
|
|
1867
|
+
federatedAuthWithRedirect(e) {
|
|
1868
|
+
this.authService.federatedAuthWithRedirect(e);
|
|
1869
|
+
}
|
|
1870
|
+
reset(e) {
|
|
1871
|
+
if (this.storageManager.deleteTokens(), this.tokenCacheService.setTokensCache(void 0), this.subscribeStore.notify(a.SignOut, {}), e) {
|
|
1872
|
+
this.error = new Error(e);
|
|
1873
|
+
const t = {
|
|
1874
|
+
message: e,
|
|
1875
|
+
code: "RESET_ERROR"
|
|
1876
|
+
};
|
|
1877
|
+
throw this.subscribeStore.notify(a.Error, t), this.error;
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
async refreshToken() {
|
|
1881
|
+
if (!this.tokenCacheService.parsedTokensCache?.refresh_token)
|
|
1882
|
+
throw new Error("No refresh token found");
|
|
1883
|
+
try {
|
|
1884
|
+
return await this.authService.refreshToken();
|
|
1885
|
+
} catch (e) {
|
|
1886
|
+
throw e instanceof u || this.subscribeStore.notify(a.Error, {
|
|
1887
|
+
message: "Failed to refresh token",
|
|
1888
|
+
originalError: e
|
|
1889
|
+
}), e;
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
sendPasswordResetEmail(e) {
|
|
1893
|
+
return this.authService.sendPasswordResetEmail(e);
|
|
1894
|
+
}
|
|
1895
|
+
async resetPassword(e, t) {
|
|
1896
|
+
return await this.authService.resetPassword(e, t);
|
|
1897
|
+
}
|
|
1898
|
+
// App settings
|
|
1899
|
+
async getAppSettings() {
|
|
1900
|
+
try {
|
|
1901
|
+
return await this.appApi.getAppSettings();
|
|
1902
|
+
} catch (e) {
|
|
1903
|
+
const t = {
|
|
1904
|
+
message: e instanceof Error ? e.message : "Failed to get app settings",
|
|
1905
|
+
originalError: e
|
|
1906
|
+
};
|
|
1907
|
+
throw this.subscribeStore.notify(a.Error, t), e;
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1910
|
+
async getSettingsAll() {
|
|
1911
|
+
try {
|
|
1912
|
+
return await this.settingApi.getSettingsAll();
|
|
1913
|
+
} catch (e) {
|
|
1914
|
+
const t = {
|
|
1915
|
+
message: e instanceof Error ? e.message : "Failed to get all settings",
|
|
1916
|
+
originalError: e
|
|
1917
|
+
};
|
|
1918
|
+
throw this.subscribeStore.notify(a.Error, t), e;
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
async getPasswordPolicySettings() {
|
|
1922
|
+
try {
|
|
1923
|
+
return await this.settingApi.getPasswordPolicySettings();
|
|
1924
|
+
} catch (e) {
|
|
1925
|
+
const t = {
|
|
1926
|
+
message: e instanceof Error ? e.message : "Failed to get password policy settings",
|
|
1927
|
+
originalError: e
|
|
1928
|
+
};
|
|
1929
|
+
throw this.subscribeStore.notify(a.Error, t), e;
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1932
|
+
async getPasskeySettings() {
|
|
1933
|
+
try {
|
|
1934
|
+
return await this.settingApi.getPasskeySettings();
|
|
1935
|
+
} catch (e) {
|
|
1936
|
+
const t = {
|
|
1937
|
+
message: e instanceof Error ? e.message : "Failed to get passkey settings",
|
|
1938
|
+
originalError: e
|
|
1939
|
+
};
|
|
1940
|
+
throw this.subscribeStore.notify(a.Error, t), e;
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
1943
|
+
// Passkey methods
|
|
1944
|
+
async passkeyRegister(e) {
|
|
1945
|
+
return await this.authService.passkeyRegister(e);
|
|
1946
|
+
}
|
|
1947
|
+
async passkeyAuthenticate(e) {
|
|
1948
|
+
return await this.authService.passkeyAuthenticate(e);
|
|
1949
|
+
}
|
|
1950
|
+
// Token management
|
|
1951
|
+
setTokens(e) {
|
|
1952
|
+
this.storageManager.saveTokens(e), this.tokenCacheService.setTokensCache(e), this.subscribeStore.notify(a.SignIn, {
|
|
1953
|
+
tokens: e,
|
|
1954
|
+
parsedTokens: this.tokenCacheService.getParsedTokenCache()
|
|
1955
|
+
});
|
|
1956
|
+
}
|
|
1957
|
+
// Add getTokens method
|
|
1958
|
+
async getTokens(e = !1) {
|
|
1959
|
+
return await this.authService.getTokens(e);
|
|
1960
|
+
}
|
|
1961
|
+
// Get token from storage by key
|
|
1962
|
+
getToken(e) {
|
|
1963
|
+
return this.storageManager.getToken(e);
|
|
1964
|
+
}
|
|
1965
|
+
// User passkey methods delegated to UserService
|
|
1966
|
+
async getUserPasskeys() {
|
|
1967
|
+
try {
|
|
1968
|
+
return await this.userService.getUserPasskeys();
|
|
1969
|
+
} catch (e) {
|
|
1970
|
+
const t = {
|
|
1971
|
+
message: e instanceof Error ? e.message : "Failed to get user passkeys",
|
|
1972
|
+
originalError: e
|
|
1973
|
+
};
|
|
1974
|
+
throw this.subscribeStore.notify(a.Error, t), e;
|
|
1975
|
+
}
|
|
1976
|
+
}
|
|
1977
|
+
async renameUserPasskey(e, t) {
|
|
1978
|
+
try {
|
|
1979
|
+
return await this.userService.renameUserPasskey(e, t);
|
|
1980
|
+
} catch (s) {
|
|
1981
|
+
const r = {
|
|
1982
|
+
message: s instanceof Error ? s.message : "Failed to rename user passkey",
|
|
1983
|
+
originalError: s
|
|
1984
|
+
};
|
|
1985
|
+
throw this.subscribeStore.notify(a.Error, r), s;
|
|
1986
|
+
}
|
|
1987
|
+
}
|
|
1988
|
+
async deleteUserPasskey(e) {
|
|
1989
|
+
try {
|
|
1990
|
+
return await this.userService.deleteUserPasskey(e);
|
|
1991
|
+
} catch (t) {
|
|
1992
|
+
const s = {
|
|
1993
|
+
message: t instanceof Error ? t.message : "Failed to delete user passkey",
|
|
1994
|
+
originalError: t
|
|
1995
|
+
};
|
|
1996
|
+
throw this.subscribeStore.notify(a.Error, s), t;
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
async addUserPasskey(e) {
|
|
2000
|
+
try {
|
|
2001
|
+
return await this.userService.addUserPasskey(e);
|
|
2002
|
+
} catch (t) {
|
|
2003
|
+
const s = {
|
|
2004
|
+
message: t instanceof Error ? t.message : "Failed to add user passkey",
|
|
2005
|
+
originalError: t
|
|
2006
|
+
};
|
|
2007
|
+
throw this.subscribeStore.notify(a.Error, s), t;
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
// Tenant methods delegated to TenantService
|
|
2011
|
+
/**
|
|
2012
|
+
* Join a tenant invitation
|
|
2013
|
+
* @param token The invitation token
|
|
2014
|
+
* @param scopes Optional scopes to request
|
|
2015
|
+
* @returns Promise with invite response
|
|
2016
|
+
*/
|
|
2017
|
+
async joinInvitation(e, t) {
|
|
2018
|
+
try {
|
|
2019
|
+
const s = await this.tenant.joinInvitation(e, t);
|
|
2020
|
+
return s.scopes = t ?? this.scopes, this.storageManager.saveTokens(s), this.tokenCacheService.setTokensCache(s), s;
|
|
2021
|
+
} catch (s) {
|
|
2022
|
+
const r = {
|
|
2023
|
+
message: s instanceof Error ? s.message : "Failed to join invitation",
|
|
2024
|
+
originalError: s
|
|
2025
|
+
};
|
|
2026
|
+
throw this.subscribeStore.notify(a.Error, r), s;
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
/**
|
|
2030
|
+
* Create a new tenant
|
|
2031
|
+
* @param name The name of the tenant
|
|
2032
|
+
* @param refreshToken Whether to refresh the token after creating the tenant
|
|
2033
|
+
* @returns Promise with tenant response
|
|
2034
|
+
*/
|
|
2035
|
+
async createTenant(e, t) {
|
|
2036
|
+
try {
|
|
2037
|
+
const s = await this.tenant.createTenant(e);
|
|
2038
|
+
return t && await this.refreshToken(), s;
|
|
2039
|
+
} catch (s) {
|
|
2040
|
+
const r = {
|
|
2041
|
+
message: s instanceof Error ? s.message : "Failed to create tenant",
|
|
2042
|
+
originalError: s
|
|
2043
|
+
};
|
|
2044
|
+
throw this.subscribeStore.notify(a.Error, r), s;
|
|
2045
|
+
}
|
|
2046
|
+
}
|
|
2047
|
+
// Invitation methods delegated to InvitationService
|
|
2048
|
+
async requestInviteLink(e) {
|
|
2049
|
+
try {
|
|
2050
|
+
return e.send_to_email === void 0 && (e.send_to_email = !0), await this.invitationService.requestInviteLink(e);
|
|
2051
|
+
} catch (t) {
|
|
2052
|
+
const s = {
|
|
2053
|
+
message: t instanceof Error ? t.message : "Failed to request invite link",
|
|
2054
|
+
originalError: t
|
|
2055
|
+
};
|
|
2056
|
+
throw this.subscribeStore.notify(a.Error, s), t;
|
|
2057
|
+
}
|
|
2058
|
+
}
|
|
2059
|
+
/**
|
|
2060
|
+
* Gets a list of active invitations
|
|
2061
|
+
* @param options Optional parameters for filtering and pagination
|
|
2062
|
+
* @returns Promise with paginated list of invitations
|
|
2063
|
+
*/
|
|
2064
|
+
async getInvitations(e) {
|
|
2065
|
+
try {
|
|
2066
|
+
return await this.invitationService.getInvitations(e);
|
|
2067
|
+
} catch (t) {
|
|
2068
|
+
const s = {
|
|
2069
|
+
message: t instanceof Error ? t.message : "Failed to get invitations",
|
|
2070
|
+
originalError: t
|
|
2071
|
+
};
|
|
2072
|
+
throw this.subscribeStore.notify(a.Error, s), t;
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
async deleteInvitation(e) {
|
|
2076
|
+
try {
|
|
2077
|
+
return await this.invitationService.deleteInvitation(e);
|
|
2078
|
+
} catch (t) {
|
|
2079
|
+
const s = {
|
|
2080
|
+
message: t instanceof Error ? t.message : "Failed to delete invitation",
|
|
2081
|
+
originalError: t
|
|
2082
|
+
};
|
|
2083
|
+
throw this.subscribeStore.notify(a.Error, s), t;
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
async resendInvitation(e) {
|
|
2087
|
+
try {
|
|
2088
|
+
return await this.invitationService.resendInvitation(e);
|
|
2089
|
+
} catch (t) {
|
|
2090
|
+
const s = {
|
|
2091
|
+
message: t instanceof Error ? t.message : "Failed to resend invitation",
|
|
2092
|
+
originalError: t
|
|
2093
|
+
};
|
|
2094
|
+
throw this.subscribeStore.notify(a.Error, s), t;
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
async getInvitationLink(e) {
|
|
2098
|
+
try {
|
|
2099
|
+
return await this.invitationService.getInvitationLink(e);
|
|
2100
|
+
} catch (t) {
|
|
2101
|
+
const s = {
|
|
2102
|
+
message: t instanceof Error ? t.message : "Failed to get invitation link",
|
|
2103
|
+
originalError: t
|
|
2104
|
+
};
|
|
2105
|
+
throw this.subscribeStore.notify(a.Error, s), t;
|
|
2106
|
+
}
|
|
2107
|
+
}
|
|
2108
|
+
// Auth redirect helpers
|
|
2109
|
+
authRedirectUrl(e = {}) {
|
|
2110
|
+
return this.authService.authRedirectUrl(e);
|
|
2111
|
+
}
|
|
2112
|
+
authRedirect(e = {}) {
|
|
2113
|
+
this.authService.authRedirect(e);
|
|
2114
|
+
}
|
|
2115
|
+
}
|
|
2116
|
+
export {
|
|
2117
|
+
P as APP_ID_HEADER_KEY,
|
|
2118
|
+
m as AUTHORIZATION_HEADER_KEY,
|
|
2119
|
+
j as AppAPI,
|
|
2120
|
+
O as AuthAPI,
|
|
2121
|
+
q as AuthService,
|
|
2122
|
+
re as DEFAULT_GROUP_NAME,
|
|
2123
|
+
F as DEFAULT_SCOPES,
|
|
2124
|
+
D as DEVICE_ID_HEADER_KEY,
|
|
2125
|
+
x as DEVICE_TYPE_HEADER_KEY,
|
|
2126
|
+
W as InvitationAPI,
|
|
2127
|
+
V as InvitationService,
|
|
2128
|
+
w as OS,
|
|
2129
|
+
A as PASSFLOW_CLOUD_URL,
|
|
2130
|
+
ie as Passflow,
|
|
2131
|
+
y as PassflowAdminEndpointPaths,
|
|
2132
|
+
c as PassflowEndpointPaths,
|
|
2133
|
+
u as PassflowError,
|
|
2134
|
+
a as PassflowEvent,
|
|
2135
|
+
L as Providers,
|
|
2136
|
+
S as RequestMethod,
|
|
2137
|
+
K as SettingAPI,
|
|
2138
|
+
B as TenantAPI,
|
|
2139
|
+
X as TenantService,
|
|
2140
|
+
Y as TenantUserMembership,
|
|
2141
|
+
Z as TokenCacheService,
|
|
2142
|
+
g as TokenType,
|
|
2143
|
+
N as UserAPI,
|
|
2144
|
+
Q as UserService,
|
|
2145
|
+
f as isTokenExpired,
|
|
2146
|
+
d as parseToken,
|
|
2147
|
+
C as pathWithParams
|
|
2148
|
+
};
|
|
2149
|
+
//# sourceMappingURL=index.mjs.map
|