@whereby.com/browser-sdk 2.0.0-beta1 → 2.0.0-beta3
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 +12 -24
- package/dist/embed/index.d.ts +4 -1
- package/dist/embed/{index.js → index.esm.js} +117 -110
- package/dist/react/index.d.ts +397 -6
- package/dist/react/index.esm.js +8245 -0
- package/dist/utils/index.d.ts +5 -2
- package/dist/utils/{fakeWebcamFrame.js → index.esm.js} +68 -47
- package/dist/v2-beta3.js +15 -0
- package/package.json +50 -27
- package/dist/LocalMedia.d.ts +0 -63
- package/dist/LocalMedia.js +0 -211
- package/dist/RoomConnection.d.ts +0 -184
- package/dist/RoomConnection.js +0 -627
- package/dist/RoomParticipant.d.ts +0 -50
- package/dist/RoomParticipant.js +0 -48
- package/dist/api/ApiClient.d.ts +0 -26
- package/dist/api/ApiClient.js +0 -63
- package/dist/api/Credentials.d.ts +0 -17
- package/dist/api/Credentials.js +0 -16
- package/dist/api/HttpClient.d.ts +0 -16
- package/dist/api/HttpClient.js +0 -53
- package/dist/api/MultipartHttpClient.d.ts +0 -10
- package/dist/api/MultipartHttpClient.js +0 -25
- package/dist/api/OrganizationApiClient.d.ts +0 -16
- package/dist/api/OrganizationApiClient.js +0 -29
- package/dist/api/Response.d.ts +0 -29
- package/dist/api/Response.js +0 -9
- package/dist/api/credentialsService/index.d.ts +0 -27
- package/dist/api/credentialsService/index.js +0 -89
- package/dist/api/deviceService/index.d.ts +0 -9
- package/dist/api/deviceService/index.js +0 -23
- package/dist/api/extractUtils.d.ts +0 -16
- package/dist/api/extractUtils.js +0 -51
- package/dist/api/index.d.ts +0 -7
- package/dist/api/index.js +0 -7
- package/dist/api/localStorageWrapper/index.d.ts +0 -2
- package/dist/api/localStorageWrapper/index.js +0 -15
- package/dist/api/models/Account.d.ts +0 -20
- package/dist/api/models/Account.js +0 -24
- package/dist/api/models/Meeting.d.ts +0 -12
- package/dist/api/models/Meeting.js +0 -29
- package/dist/api/models/Organization.d.ts +0 -102
- package/dist/api/models/Organization.js +0 -81
- package/dist/api/models/Room.d.ts +0 -4
- package/dist/api/models/Room.js +0 -38
- package/dist/api/models/account/EmbeddedFreeTierStatus.d.ts +0 -13
- package/dist/api/models/account/EmbeddedFreeTierStatus.js +0 -17
- package/dist/api/modules/AbstractStore.d.ts +0 -5
- package/dist/api/modules/AbstractStore.js +0 -1
- package/dist/api/modules/ChromeStorageStore.d.ts +0 -10
- package/dist/api/modules/ChromeStorageStore.js +0 -21
- package/dist/api/modules/LocalStorageStore.d.ts +0 -9
- package/dist/api/modules/LocalStorageStore.js +0 -35
- package/dist/api/modules/tests/__mocks__/storage.d.ts +0 -10
- package/dist/api/modules/tests/__mocks__/storage.js +0 -19
- package/dist/api/organizationService/index.d.ts +0 -46
- package/dist/api/organizationService/index.js +0 -158
- package/dist/api/organizationServiceCache/index.d.ts +0 -13
- package/dist/api/organizationServiceCache/index.js +0 -16
- package/dist/api/parameterAssertUtils.d.ts +0 -13
- package/dist/api/parameterAssertUtils.js +0 -64
- package/dist/api/roomService/index.d.ts +0 -54
- package/dist/api/roomService/index.js +0 -160
- package/dist/api/test/helpers.d.ts +0 -7
- package/dist/api/test/helpers.js +0 -32
- package/dist/api/types.d.ts +0 -5
- package/dist/api/types.js +0 -1
- package/dist/react/VideoView.d.ts +0 -15
- package/dist/react/VideoView.js +0 -37
- package/dist/react/index.js +0 -4
- package/dist/react/useLocalMedia.d.ts +0 -28
- package/dist/react/useLocalMedia.js +0 -109
- package/dist/react/useRoomConnection.d.ts +0 -55
- package/dist/react/useRoomConnection.js +0 -315
- package/dist/utils/debounce.d.ts +0 -9
- package/dist/utils/debounce.js +0 -20
- package/dist/utils/fakeAudioStream.d.ts +0 -1
- package/dist/utils/fakeAudioStream.js +0 -18
- package/dist/utils/fakeWebcamFrame.d.ts +0 -1
- package/dist/utils/index.js +0 -2
- package/dist/v2-beta1.js +0 -2001
- package/dist/version.d.ts +0 -1
- package/dist/version.js +0 -1
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { assertBoolean } from "../parameterAssertUtils";
|
|
2
|
-
import EmbeddedFreeTierStatus from "./account/EmbeddedFreeTierStatus";
|
|
3
|
-
export default class Account {
|
|
4
|
-
constructor({ basePlanId, embeddedFreeTierStatus, isDeactivated, isOnTrial, onTrialUntil, trialStatus, }) {
|
|
5
|
-
this.basePlanId = basePlanId;
|
|
6
|
-
this.isDeactivated = isDeactivated;
|
|
7
|
-
this.isOnTrial = isOnTrial;
|
|
8
|
-
this.onTrialUntil = onTrialUntil || null;
|
|
9
|
-
this.trialStatus = trialStatus || null;
|
|
10
|
-
this.embeddedFreeTierStatus = embeddedFreeTierStatus || null;
|
|
11
|
-
}
|
|
12
|
-
static fromJson(data) {
|
|
13
|
-
return new Account({
|
|
14
|
-
basePlanId: typeof data.basePlanId === "string" ? data.basePlanId : null,
|
|
15
|
-
isDeactivated: assertBoolean(data.isDeactivated, "isDeactivated"),
|
|
16
|
-
isOnTrial: assertBoolean(data.isOnTrial, "isOnTrial"),
|
|
17
|
-
onTrialUntil: typeof data.onTrialUntil === "string" ? new Date(data.onTrialUntil) : null,
|
|
18
|
-
trialStatus: typeof data.trialStatus === "string" ? data.trialStatus : null,
|
|
19
|
-
embeddedFreeTierStatus: data.embeddedFreeTierStatus
|
|
20
|
-
? EmbeddedFreeTierStatus.fromJson(data.embeddedFreeTierStatus)
|
|
21
|
-
: null,
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Json } from "../Response";
|
|
2
|
-
export default class Meeting {
|
|
3
|
-
meetingId: string;
|
|
4
|
-
roomName: string;
|
|
5
|
-
roomUrl: string;
|
|
6
|
-
startDate: Date;
|
|
7
|
-
endDate: Date;
|
|
8
|
-
hostRoomUrl: string | null;
|
|
9
|
-
viewerRoomUrl: string | null;
|
|
10
|
-
constructor({ meetingId, roomName, roomUrl, startDate, endDate, hostRoomUrl, viewerRoomUrl }: Meeting);
|
|
11
|
-
static fromJson(data: Json): Meeting;
|
|
12
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { extractDate, extractNullOrString, extractString } from "../extractUtils";
|
|
2
|
-
import { assertString, assertInstanceOf } from "../parameterAssertUtils";
|
|
3
|
-
export default class Meeting {
|
|
4
|
-
constructor({ meetingId, roomName, roomUrl, startDate, endDate, hostRoomUrl, viewerRoomUrl }) {
|
|
5
|
-
assertString(meetingId, "meetingId");
|
|
6
|
-
assertString(roomName, "roomName");
|
|
7
|
-
assertString(roomUrl, "roomUrl");
|
|
8
|
-
assertInstanceOf(startDate, Date, "startDate");
|
|
9
|
-
assertInstanceOf(endDate, Date, "endDate");
|
|
10
|
-
this.meetingId = meetingId;
|
|
11
|
-
this.roomName = roomName;
|
|
12
|
-
this.roomUrl = roomUrl;
|
|
13
|
-
this.startDate = startDate;
|
|
14
|
-
this.endDate = endDate;
|
|
15
|
-
this.hostRoomUrl = hostRoomUrl;
|
|
16
|
-
this.viewerRoomUrl = viewerRoomUrl;
|
|
17
|
-
}
|
|
18
|
-
static fromJson(data) {
|
|
19
|
-
return new Meeting({
|
|
20
|
-
meetingId: extractString(data, "meetingId"),
|
|
21
|
-
roomName: extractString(data, "roomName"),
|
|
22
|
-
roomUrl: extractString(data, "roomUrl"),
|
|
23
|
-
startDate: extractDate(data, "startDate"),
|
|
24
|
-
endDate: extractDate(data, "endDate"),
|
|
25
|
-
hostRoomUrl: extractNullOrString(data, "hostRoomUrl"),
|
|
26
|
-
viewerRoomUrl: extractNullOrString(data, "viewerRoomUrl"),
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { Json } from "../Response";
|
|
2
|
-
import Account from "./Account";
|
|
3
|
-
interface OrganizationPermissionAction {
|
|
4
|
-
isAllowed: boolean;
|
|
5
|
-
isSupported: boolean;
|
|
6
|
-
}
|
|
7
|
-
interface FullOrganizationPermissions {
|
|
8
|
-
images: {
|
|
9
|
-
logoImageUrl: {
|
|
10
|
-
set: OrganizationPermissionAction;
|
|
11
|
-
reset: OrganizationPermissionAction;
|
|
12
|
-
};
|
|
13
|
-
roomBackgroundImageUrl: {
|
|
14
|
-
set: OrganizationPermissionAction;
|
|
15
|
-
reset: OrganizationPermissionAction;
|
|
16
|
-
};
|
|
17
|
-
roomKnockPageBackgroundImageUrl: {
|
|
18
|
-
set: OrganizationPermissionAction;
|
|
19
|
-
reset: OrganizationPermissionAction;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
invitations: {
|
|
23
|
-
add: OrganizationPermissionAction;
|
|
24
|
-
delete: OrganizationPermissionAction;
|
|
25
|
-
list: OrganizationPermissionAction;
|
|
26
|
-
};
|
|
27
|
-
roles: {
|
|
28
|
-
set: OrganizationPermissionAction;
|
|
29
|
-
remove: OrganizationPermissionAction;
|
|
30
|
-
removeSelf: OrganizationPermissionAction;
|
|
31
|
-
list: OrganizationPermissionAction;
|
|
32
|
-
};
|
|
33
|
-
users: {
|
|
34
|
-
signUpWithoutInvitation: OrganizationPermissionAction;
|
|
35
|
-
};
|
|
36
|
-
rooms: {
|
|
37
|
-
customize: OrganizationPermissionAction;
|
|
38
|
-
customizeSelf: OrganizationPermissionAction;
|
|
39
|
-
list: OrganizationPermissionAction;
|
|
40
|
-
lock: OrganizationPermissionAction;
|
|
41
|
-
unclaim: OrganizationPermissionAction;
|
|
42
|
-
unclaimSelf: OrganizationPermissionAction;
|
|
43
|
-
};
|
|
44
|
-
subscriptions: {
|
|
45
|
-
add: OrganizationPermissionAction;
|
|
46
|
-
list: OrganizationPermissionAction;
|
|
47
|
-
payLatestInvoice: OrganizationPermissionAction;
|
|
48
|
-
updatePlan: OrganizationPermissionAction;
|
|
49
|
-
};
|
|
50
|
-
browserExtension: {
|
|
51
|
-
install: OrganizationPermissionAction;
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
type OrganizationPermissions = Partial<FullOrganizationPermissions>;
|
|
55
|
-
interface OrganizationLimits {
|
|
56
|
-
maxNumberOfInvitationsAndUsers: number | null;
|
|
57
|
-
maxNumberOfClaimedRooms: number | null;
|
|
58
|
-
maxRoomLimitPerOrganization: number | null;
|
|
59
|
-
trialMinutesLimit: number | null;
|
|
60
|
-
includedUnits: number | null;
|
|
61
|
-
}
|
|
62
|
-
interface OrganizationOnboardingSurvey {
|
|
63
|
-
name: string;
|
|
64
|
-
value: unknown;
|
|
65
|
-
}
|
|
66
|
-
export type OrganizationPreferences = Record<string, boolean | string | null | number>;
|
|
67
|
-
export declare function hasValue(value: unknown): boolean;
|
|
68
|
-
export default class Organization {
|
|
69
|
-
static GLOBAL_ORGANIZATION_ID: string;
|
|
70
|
-
organizationId: string;
|
|
71
|
-
organizationName: string;
|
|
72
|
-
subdomain: string;
|
|
73
|
-
permissions: OrganizationPermissions;
|
|
74
|
-
limits: OrganizationLimits;
|
|
75
|
-
account: Account | null;
|
|
76
|
-
logoImageUrl: string | null;
|
|
77
|
-
roomBackgroundImageUrl: string | null;
|
|
78
|
-
roomBackgroundThumbnailUrl: string | null;
|
|
79
|
-
roomKnockPageBackgroundImageUrl: string | null;
|
|
80
|
-
roomKnockPageBackgroundThumbnailUrl: string | null;
|
|
81
|
-
preferences: OrganizationPreferences | null;
|
|
82
|
-
onboardingSurvey: OrganizationOnboardingSurvey | null;
|
|
83
|
-
type: string | null;
|
|
84
|
-
constructor(properties: {
|
|
85
|
-
account: Account | null;
|
|
86
|
-
organizationId: string;
|
|
87
|
-
organizationName: string;
|
|
88
|
-
subdomain: string;
|
|
89
|
-
permissions: OrganizationPermissions;
|
|
90
|
-
limits: OrganizationLimits;
|
|
91
|
-
logoImageUrl: string | null;
|
|
92
|
-
roomBackgroundImageUrl: string | null;
|
|
93
|
-
roomBackgroundThumbnailUrl: string | null;
|
|
94
|
-
roomKnockPageBackgroundImageUrl: string | null;
|
|
95
|
-
roomKnockPageBackgroundThumbnailUrl: string | null;
|
|
96
|
-
preferences: OrganizationPreferences | null;
|
|
97
|
-
onboardingSurvey: OrganizationOnboardingSurvey | null;
|
|
98
|
-
type: string | null;
|
|
99
|
-
});
|
|
100
|
-
static fromJson(data: Json): Organization;
|
|
101
|
-
}
|
|
102
|
-
export {};
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { assertInstanceOf, assertString } from "../parameterAssertUtils";
|
|
2
|
-
import Account from "./Account";
|
|
3
|
-
export function hasValue(value) {
|
|
4
|
-
return value !== null && value !== undefined;
|
|
5
|
-
}
|
|
6
|
-
function createOrganizationLimits(limits = {}) {
|
|
7
|
-
return {
|
|
8
|
-
maxNumberOfInvitationsAndUsers: hasValue(limits === null || limits === void 0 ? void 0 : limits.maxNumberOfInvitationsAndUsers)
|
|
9
|
-
? Number(limits === null || limits === void 0 ? void 0 : limits.maxNumberOfInvitationsAndUsers)
|
|
10
|
-
: null,
|
|
11
|
-
maxNumberOfClaimedRooms: hasValue(limits === null || limits === void 0 ? void 0 : limits.maxNumberOfClaimedRooms)
|
|
12
|
-
? Number(limits === null || limits === void 0 ? void 0 : limits.maxNumberOfClaimedRooms)
|
|
13
|
-
: null,
|
|
14
|
-
maxRoomLimitPerOrganization: hasValue(limits === null || limits === void 0 ? void 0 : limits.maxRoomLimitPerOrganization)
|
|
15
|
-
? Number(limits === null || limits === void 0 ? void 0 : limits.maxRoomLimitPerOrganization)
|
|
16
|
-
: null,
|
|
17
|
-
trialMinutesLimit: hasValue(limits === null || limits === void 0 ? void 0 : limits.trialMinutesLimit) ? Number(limits === null || limits === void 0 ? void 0 : limits.trialMinutesLimit) : null,
|
|
18
|
-
includedUnits: hasValue(limits === null || limits === void 0 ? void 0 : limits.includedUnits) ? Number(limits === null || limits === void 0 ? void 0 : limits.includedUnits) : null,
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
export default class Organization {
|
|
22
|
-
constructor(properties) {
|
|
23
|
-
this.logoImageUrl = null;
|
|
24
|
-
this.roomBackgroundImageUrl = null;
|
|
25
|
-
this.roomBackgroundThumbnailUrl = null;
|
|
26
|
-
this.roomKnockPageBackgroundImageUrl = null;
|
|
27
|
-
this.roomKnockPageBackgroundThumbnailUrl = null;
|
|
28
|
-
this.preferences = null;
|
|
29
|
-
this.onboardingSurvey = null;
|
|
30
|
-
this.type = null;
|
|
31
|
-
assertInstanceOf(properties, Object, "properties");
|
|
32
|
-
assertString(properties.organizationId, "organizationId");
|
|
33
|
-
assertString(properties.organizationName, "organizationName");
|
|
34
|
-
assertString(properties.subdomain, "subdomain");
|
|
35
|
-
assertInstanceOf(properties.permissions, Object, "permissions");
|
|
36
|
-
assertInstanceOf(properties.limits, Object, "limits");
|
|
37
|
-
this.organizationId = properties.organizationId;
|
|
38
|
-
this.organizationName = properties.organizationName;
|
|
39
|
-
this.subdomain = properties.subdomain;
|
|
40
|
-
this.permissions = properties.permissions;
|
|
41
|
-
this.limits = properties.limits;
|
|
42
|
-
this.account = properties.account ? new Account(properties.account) : null;
|
|
43
|
-
this.logoImageUrl = properties.logoImageUrl;
|
|
44
|
-
this.roomBackgroundImageUrl = properties.roomBackgroundImageUrl;
|
|
45
|
-
this.roomBackgroundThumbnailUrl = properties.roomBackgroundThumbnailUrl;
|
|
46
|
-
this.roomKnockPageBackgroundImageUrl = properties.roomKnockPageBackgroundImageUrl;
|
|
47
|
-
this.roomKnockPageBackgroundThumbnailUrl = properties.roomKnockPageBackgroundThumbnailUrl;
|
|
48
|
-
this.preferences = properties.preferences;
|
|
49
|
-
this.onboardingSurvey = properties.onboardingSurvey;
|
|
50
|
-
this.type = properties.type;
|
|
51
|
-
}
|
|
52
|
-
static fromJson(data) {
|
|
53
|
-
const parsedData = assertInstanceOf(data, Object, "data");
|
|
54
|
-
const preferences = ((parsedData === null || parsedData === void 0 ? void 0 : parsedData.preferences) || {});
|
|
55
|
-
const onboardingSurvey = ((parsedData === null || parsedData === void 0 ? void 0 : parsedData.onboardingSurvey) || null);
|
|
56
|
-
const permissions = assertInstanceOf(parsedData.permissions, Object, "permissions");
|
|
57
|
-
return new Organization({
|
|
58
|
-
organizationId: assertString(parsedData.organizationId, "organizationId"),
|
|
59
|
-
organizationName: assertString(parsedData.organizationName, "organizationName"),
|
|
60
|
-
subdomain: assertString(parsedData.subdomain, "subdomain"),
|
|
61
|
-
permissions,
|
|
62
|
-
limits: createOrganizationLimits(assertInstanceOf(parsedData.limits, Object, "limits")),
|
|
63
|
-
account: parsedData.account ? Account.fromJson(parsedData.account) : null,
|
|
64
|
-
logoImageUrl: typeof parsedData.logoImageUrl === "string" ? parsedData.logoImageUrl : null,
|
|
65
|
-
roomBackgroundImageUrl: typeof parsedData.roomBackgroundImageUrl === "string" ? parsedData.roomBackgroundImageUrl : null,
|
|
66
|
-
roomBackgroundThumbnailUrl: typeof parsedData.roomBackgroundThumbnailUrl === "string"
|
|
67
|
-
? parsedData.roomBackgroundThumbnailUrl
|
|
68
|
-
: null,
|
|
69
|
-
roomKnockPageBackgroundImageUrl: typeof parsedData.roomKnockPageBackgroundImageUrl === "string"
|
|
70
|
-
? parsedData.roomKnockPageBackgroundImageUrl
|
|
71
|
-
: null,
|
|
72
|
-
roomKnockPageBackgroundThumbnailUrl: typeof parsedData.roomKnockPageBackgroundThumbnailUrl === "string"
|
|
73
|
-
? parsedData.roomKnockPageBackgroundThumbnailUrl
|
|
74
|
-
: null,
|
|
75
|
-
preferences,
|
|
76
|
-
onboardingSurvey,
|
|
77
|
-
type: typeof parsedData.type === "string" ? parsedData.type : null,
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
Organization.GLOBAL_ORGANIZATION_ID = "1";
|
package/dist/api/models/Room.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import assert from "assert";
|
|
2
|
-
export default class Room {
|
|
3
|
-
constructor(properties = {}) {
|
|
4
|
-
assert.ok(properties instanceof Object, "properties<object> must be empty or an object");
|
|
5
|
-
this.isClaimed = false;
|
|
6
|
-
this.isBanned = false;
|
|
7
|
-
this.isLocked = false;
|
|
8
|
-
this.knockPage = {
|
|
9
|
-
backgroundImageUrl: null,
|
|
10
|
-
backgroundThumbnailUrl: null,
|
|
11
|
-
};
|
|
12
|
-
this.logoUrl = null;
|
|
13
|
-
this.backgroundImageUrl = null;
|
|
14
|
-
this.backgroundThumbnailUrl = null;
|
|
15
|
-
this.type = null;
|
|
16
|
-
this.legacyRoomType = null;
|
|
17
|
-
this.mode = null;
|
|
18
|
-
this.product = null;
|
|
19
|
-
this.roomName = null;
|
|
20
|
-
this.theme = null;
|
|
21
|
-
this.preferences = {};
|
|
22
|
-
this.protectedPreferences = {};
|
|
23
|
-
this.publicProfile = null;
|
|
24
|
-
const validProperties = {};
|
|
25
|
-
Object.getOwnPropertyNames(properties).forEach((prop) => {
|
|
26
|
-
if (Object.getOwnPropertyNames(this).indexOf(prop) !== -1) {
|
|
27
|
-
validProperties[prop] = properties[prop];
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
if (properties.ownerId !== undefined) {
|
|
31
|
-
this.ownerId = properties.ownerId;
|
|
32
|
-
}
|
|
33
|
-
if (properties.meeting !== undefined) {
|
|
34
|
-
this.meeting = properties.meeting;
|
|
35
|
-
}
|
|
36
|
-
Object.assign(this, validProperties);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export default class EmbeddedFreeTierStatus {
|
|
2
|
-
isExhausted: boolean;
|
|
3
|
-
renewsAt: Date;
|
|
4
|
-
totalMinutesLimit: number;
|
|
5
|
-
totalMinutesUsed: number;
|
|
6
|
-
constructor({ isExhausted, renewsAt, totalMinutesLimit, totalMinutesUsed, }: {
|
|
7
|
-
isExhausted: boolean;
|
|
8
|
-
renewsAt: Date;
|
|
9
|
-
totalMinutesLimit: number;
|
|
10
|
-
totalMinutesUsed: number;
|
|
11
|
-
});
|
|
12
|
-
static fromJson(data: Record<string, unknown>): EmbeddedFreeTierStatus;
|
|
13
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { assertBoolean, assertNumber, assertString } from "../../parameterAssertUtils";
|
|
2
|
-
export default class EmbeddedFreeTierStatus {
|
|
3
|
-
constructor({ isExhausted, renewsAt, totalMinutesLimit, totalMinutesUsed, }) {
|
|
4
|
-
this.isExhausted = isExhausted;
|
|
5
|
-
this.renewsAt = renewsAt;
|
|
6
|
-
this.totalMinutesLimit = totalMinutesLimit;
|
|
7
|
-
this.totalMinutesUsed = totalMinutesUsed;
|
|
8
|
-
}
|
|
9
|
-
static fromJson(data) {
|
|
10
|
-
return new EmbeddedFreeTierStatus({
|
|
11
|
-
isExhausted: assertBoolean(data.isExhausted, "isExhausted"),
|
|
12
|
-
renewsAt: new Date(assertString(data.renewsAt, "renewsAt")),
|
|
13
|
-
totalMinutesLimit: assertNumber(data.totalMinutesLimit, "totalMinutesLimit"),
|
|
14
|
-
totalMinutesUsed: assertNumber(data.totalMinutesUsed, "totalMinutesUsed"),
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/// <reference types="chrome" />
|
|
2
|
-
import { Json } from "../Response";
|
|
3
|
-
import AbstractStore from "./AbstractStore";
|
|
4
|
-
export default class ChromeStorageStore implements AbstractStore {
|
|
5
|
-
_key: string;
|
|
6
|
-
_chromeStorage: chrome.storage.StorageArea;
|
|
7
|
-
constructor(key: string, chromeStorage: chrome.storage.StorageArea);
|
|
8
|
-
loadOrDefault(defaultValue: Json): Promise<Json>;
|
|
9
|
-
save(value: Json): Promise<void>;
|
|
10
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export default class ChromeStorageStore {
|
|
2
|
-
constructor(key, chromeStorage) {
|
|
3
|
-
this._key = key;
|
|
4
|
-
this._chromeStorage = chromeStorage;
|
|
5
|
-
}
|
|
6
|
-
loadOrDefault(defaultValue) {
|
|
7
|
-
return new Promise((resolve) => {
|
|
8
|
-
this._chromeStorage.get(this._key, (result) => {
|
|
9
|
-
const unknownResult = result;
|
|
10
|
-
resolve(unknownResult[this._key] || defaultValue);
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
save(value) {
|
|
15
|
-
return new Promise((resolve) => {
|
|
16
|
-
this._chromeStorage.set({ [this._key]: value }, () => {
|
|
17
|
-
resolve();
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Json } from "../Response";
|
|
2
|
-
import AbstractStore from "./AbstractStore";
|
|
3
|
-
export default class LocalStorageStore implements AbstractStore {
|
|
4
|
-
_key: string;
|
|
5
|
-
_localStorage: Storage;
|
|
6
|
-
constructor(key: string, localStorage: Storage);
|
|
7
|
-
loadOrDefault(defaultValue: Json): Promise<Json>;
|
|
8
|
-
save(value: Json): Promise<void>;
|
|
9
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { assertString, assertTruthy } from "../parameterAssertUtils";
|
|
2
|
-
export default class LocalStorageStore {
|
|
3
|
-
constructor(key, localStorage) {
|
|
4
|
-
assertTruthy(localStorage, "localStorage");
|
|
5
|
-
this._key = assertString(key, "key");
|
|
6
|
-
this._localStorage = localStorage;
|
|
7
|
-
}
|
|
8
|
-
loadOrDefault(defaultValue) {
|
|
9
|
-
try {
|
|
10
|
-
const value = this._localStorage.getItem(this._key);
|
|
11
|
-
if (value) {
|
|
12
|
-
try {
|
|
13
|
-
return Promise.resolve(JSON.parse(value));
|
|
14
|
-
}
|
|
15
|
-
catch (e) {
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return Promise.resolve(defaultValue);
|
|
19
|
-
}
|
|
20
|
-
catch (e) {
|
|
21
|
-
console.warn("Error getting access to storage. Are cookies blocked?", e);
|
|
22
|
-
return Promise.resolve(defaultValue);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
save(value) {
|
|
26
|
-
try {
|
|
27
|
-
this._localStorage.setItem(this._key, JSON.stringify(value));
|
|
28
|
-
return Promise.resolve();
|
|
29
|
-
}
|
|
30
|
-
catch (e) {
|
|
31
|
-
console.warn("Error getting access to storage. Are cookies blocked?", e);
|
|
32
|
-
return Promise.reject(e);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export default class DummyStore {
|
|
2
|
-
constructor() {
|
|
3
|
-
this.length = 0;
|
|
4
|
-
}
|
|
5
|
-
clear() {
|
|
6
|
-
throw new Error("Method not implemented.");
|
|
7
|
-
}
|
|
8
|
-
getItem(_key) {
|
|
9
|
-
return "{}";
|
|
10
|
-
}
|
|
11
|
-
key() {
|
|
12
|
-
throw new Error("Method not implemented.");
|
|
13
|
-
}
|
|
14
|
-
removeItem() {
|
|
15
|
-
throw new Error("Method not implemented.");
|
|
16
|
-
}
|
|
17
|
-
setItem() {
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import Organization, { OrganizationPreferences } from "../models/Organization";
|
|
2
|
-
import ApiClient from "../ApiClient";
|
|
3
|
-
import { ConsentGrantRequest } from "../types";
|
|
4
|
-
export default class OrganizationService {
|
|
5
|
-
_apiClient: ApiClient;
|
|
6
|
-
constructor({ apiClient }: {
|
|
7
|
-
apiClient: ApiClient;
|
|
8
|
-
});
|
|
9
|
-
createOrganization({ organizationName, subdomain, owner, }: {
|
|
10
|
-
organizationName: string;
|
|
11
|
-
subdomain: string;
|
|
12
|
-
owner: {
|
|
13
|
-
email: string;
|
|
14
|
-
displayName: string;
|
|
15
|
-
verificationCode: string;
|
|
16
|
-
consents?: ReadonlyArray<ConsentGrantRequest>;
|
|
17
|
-
} | {
|
|
18
|
-
idToken: string;
|
|
19
|
-
displayName: string;
|
|
20
|
-
consents?: ReadonlyArray<ConsentGrantRequest>;
|
|
21
|
-
};
|
|
22
|
-
}): Promise<string>;
|
|
23
|
-
getOrganizationBySubdomain(subdomain: string): Promise<Organization | null>;
|
|
24
|
-
getOrganizationByOrganizationId(organizationId: string): Promise<Organization | null>;
|
|
25
|
-
getOrganizationsByContactPoint(options: {
|
|
26
|
-
email: string;
|
|
27
|
-
code: string;
|
|
28
|
-
} | {
|
|
29
|
-
phoneNumber: string;
|
|
30
|
-
code: string;
|
|
31
|
-
}): Promise<ReadonlyArray<Organization>>;
|
|
32
|
-
getOrganizationsByIdToken({ idToken }: {
|
|
33
|
-
idToken: string;
|
|
34
|
-
}): Promise<ReadonlyArray<Organization>>;
|
|
35
|
-
getOrganizationsByLoggedInUser(): Promise<ReadonlyArray<Organization>>;
|
|
36
|
-
getSubdomainAvailability(subdomain: string): Promise<{
|
|
37
|
-
status: string;
|
|
38
|
-
}>;
|
|
39
|
-
updatePreferences({ organizationId, preferences, }: {
|
|
40
|
-
organizationId: string;
|
|
41
|
-
preferences: OrganizationPreferences;
|
|
42
|
-
}): Promise<undefined>;
|
|
43
|
-
deleteOrganization({ organizationId }: {
|
|
44
|
-
organizationId: string;
|
|
45
|
-
}): Promise<undefined>;
|
|
46
|
-
}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import assert from "assert";
|
|
2
|
-
import Organization from "../models/Organization";
|
|
3
|
-
import { assertInstanceOf, assertTruthy, assertString, assertArray, assertNullOrString, assertRecord, } from "../parameterAssertUtils";
|
|
4
|
-
import Response from "../Response";
|
|
5
|
-
import { extractArray, extractString } from "../extractUtils";
|
|
6
|
-
export default class OrganizationService {
|
|
7
|
-
constructor({ apiClient }) {
|
|
8
|
-
this._apiClient = apiClient;
|
|
9
|
-
}
|
|
10
|
-
createOrganization({ organizationName, subdomain, owner, }) {
|
|
11
|
-
const { displayName, consents } = owner || {};
|
|
12
|
-
const email = "email" in owner
|
|
13
|
-
? {
|
|
14
|
-
value: owner.email,
|
|
15
|
-
verificationCode: assertString(owner.verificationCode, "owner.verificationCode"),
|
|
16
|
-
}
|
|
17
|
-
: null;
|
|
18
|
-
const idToken = "idToken" in owner ? owner.idToken : null;
|
|
19
|
-
assertString(subdomain, "subdomain");
|
|
20
|
-
assertString(organizationName, "organizationName");
|
|
21
|
-
assertString(displayName, "owner.displayName");
|
|
22
|
-
assert.ok(email || idToken, "owner.email or owner.idToken is required");
|
|
23
|
-
if (consents) {
|
|
24
|
-
assertArray(consents, "consents");
|
|
25
|
-
for (const { consentRevisionId, action } of consents) {
|
|
26
|
-
assertString(consentRevisionId, "consentRevisionId");
|
|
27
|
-
assertNullOrString(action, "action");
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return this._apiClient
|
|
31
|
-
.request(`/organizations`, {
|
|
32
|
-
method: "POST",
|
|
33
|
-
data: {
|
|
34
|
-
organizationName,
|
|
35
|
-
type: "private",
|
|
36
|
-
subdomain,
|
|
37
|
-
owner: Object.assign(Object.assign(Object.assign(Object.assign({}, (email && { email })), (idToken && { idToken })), (consents && { consents })), { displayName }),
|
|
38
|
-
},
|
|
39
|
-
})
|
|
40
|
-
.then(({ data }) => {
|
|
41
|
-
return extractString(data, "organizationId");
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
getOrganizationBySubdomain(subdomain) {
|
|
45
|
-
assertString(subdomain, "subdomain");
|
|
46
|
-
return this._apiClient
|
|
47
|
-
.request(`/organization-subdomains/${encodeURIComponent(subdomain)}/?fields=permissions,account,onboardingSurvey`, {
|
|
48
|
-
method: "GET",
|
|
49
|
-
})
|
|
50
|
-
.then(({ data }) => {
|
|
51
|
-
return Organization.fromJson(data);
|
|
52
|
-
})
|
|
53
|
-
.catch((res) => {
|
|
54
|
-
if (res instanceof Response) {
|
|
55
|
-
if (res.status === 404) {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
throw new Error(res.statusText);
|
|
59
|
-
}
|
|
60
|
-
throw res;
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
getOrganizationByOrganizationId(organizationId) {
|
|
64
|
-
assertString(organizationId, "organizationId");
|
|
65
|
-
return this._apiClient
|
|
66
|
-
.request(`/organizations/${encodeURIComponent(organizationId)}?fields=permissions,account`, {
|
|
67
|
-
method: "GET",
|
|
68
|
-
})
|
|
69
|
-
.then(({ data }) => {
|
|
70
|
-
return Organization.fromJson(data);
|
|
71
|
-
})
|
|
72
|
-
.catch((res) => {
|
|
73
|
-
if (res instanceof Response) {
|
|
74
|
-
if (res.status === 404) {
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
throw new Error(res.statusText);
|
|
78
|
-
}
|
|
79
|
-
throw res;
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
getOrganizationsByContactPoint(options) {
|
|
83
|
-
const { code } = options;
|
|
84
|
-
const email = "email" in options ? options.email : null;
|
|
85
|
-
const phoneNumber = "phoneNumber" in options ? options.phoneNumber : null;
|
|
86
|
-
assert.ok((email || phoneNumber) && !(email && phoneNumber), "either email or phoneNumber is required");
|
|
87
|
-
assertString(code, "code");
|
|
88
|
-
const contactPoint = email ? { type: "email", value: email } : { type: "phoneNumber", value: phoneNumber };
|
|
89
|
-
return this._apiClient
|
|
90
|
-
.request("/organization-queries", {
|
|
91
|
-
method: "POST",
|
|
92
|
-
data: {
|
|
93
|
-
contactPoint,
|
|
94
|
-
code,
|
|
95
|
-
},
|
|
96
|
-
})
|
|
97
|
-
.then(({ data }) => {
|
|
98
|
-
return extractArray(data, "organizations", (organization) => Organization.fromJson(organization));
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
getOrganizationsByIdToken({ idToken }) {
|
|
102
|
-
assertString(idToken, "idToken");
|
|
103
|
-
return this._apiClient
|
|
104
|
-
.request("/organization-queries", {
|
|
105
|
-
method: "POST",
|
|
106
|
-
data: {
|
|
107
|
-
idToken,
|
|
108
|
-
},
|
|
109
|
-
})
|
|
110
|
-
.then(({ data }) => {
|
|
111
|
-
return extractArray(data, "organizations", (organization) => {
|
|
112
|
-
return Organization.fromJson(Object.assign({ permissions: {}, limits: {} }, assertRecord(organization, "organization")));
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
getOrganizationsByLoggedInUser() {
|
|
117
|
-
return this._apiClient
|
|
118
|
-
.request("/user/organizations", {
|
|
119
|
-
method: "GET",
|
|
120
|
-
})
|
|
121
|
-
.then(({ data }) => {
|
|
122
|
-
return extractArray(data, "organizations", (o) => {
|
|
123
|
-
return Organization.fromJson(Object.assign({ permissions: {}, limits: {} }, assertRecord(o, "organization")));
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
getSubdomainAvailability(subdomain) {
|
|
128
|
-
assertString(subdomain, "subdomain");
|
|
129
|
-
return this._apiClient
|
|
130
|
-
.request(`/organization-subdomains/${encodeURIComponent(subdomain)}/availability`, {
|
|
131
|
-
method: "GET",
|
|
132
|
-
})
|
|
133
|
-
.then(({ data }) => {
|
|
134
|
-
assertInstanceOf(data, Object, "data");
|
|
135
|
-
return {
|
|
136
|
-
status: extractString(data, "status"),
|
|
137
|
-
};
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
updatePreferences({ organizationId, preferences, }) {
|
|
141
|
-
assertTruthy(organizationId, "organizationId");
|
|
142
|
-
assertTruthy(preferences, "preferences");
|
|
143
|
-
return this._apiClient
|
|
144
|
-
.request(`/organizations/${encodeURIComponent(organizationId)}/preferences`, {
|
|
145
|
-
method: "PATCH",
|
|
146
|
-
data: preferences,
|
|
147
|
-
})
|
|
148
|
-
.then(() => undefined);
|
|
149
|
-
}
|
|
150
|
-
deleteOrganization({ organizationId }) {
|
|
151
|
-
assertTruthy(organizationId, "organizationId");
|
|
152
|
-
return this._apiClient
|
|
153
|
-
.request(`/organizations/${encodeURIComponent(organizationId)}`, {
|
|
154
|
-
method: "DELETE",
|
|
155
|
-
})
|
|
156
|
-
.then(() => undefined);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import OrganizationService from "../organizationService/index";
|
|
2
|
-
import Organization from "../models/Organization";
|
|
3
|
-
export default class OrganizationServiceCache {
|
|
4
|
-
private _organizationService;
|
|
5
|
-
private _subdomain;
|
|
6
|
-
private _organizationPromise;
|
|
7
|
-
constructor({ organizationService, subdomain }: {
|
|
8
|
-
organizationService: OrganizationService;
|
|
9
|
-
subdomain: string;
|
|
10
|
-
});
|
|
11
|
-
initOrganization(): Promise<void>;
|
|
12
|
-
fetchOrganization(): Promise<Organization | null>;
|
|
13
|
-
}
|