@neuralinnovations/dataisland-sdk 0.0.1-dev3 → 0.0.1-dev31
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/LICENSE +201 -0
- package/README.md +294 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/package.json +103 -0
- package/dist/src/appBuilder.d.ts +44 -0
- package/dist/src/appBuilder.d.ts.map +1 -0
- package/dist/src/appBuilder.js +10 -0
- package/dist/src/appBuilder.js.map +1 -0
- package/dist/src/commands/deleteUserFullCommandHandler.d.ts +7 -0
- package/dist/src/commands/deleteUserFullCommandHandler.d.ts.map +1 -0
- package/dist/src/commands/deleteUserFullCommandHandler.js +21 -0
- package/dist/src/commands/deleteUserFullCommandHandler.js.map +1 -0
- package/dist/src/commands/startCommandHandler.d.ts +7 -0
- package/dist/src/commands/startCommandHandler.d.ts.map +1 -0
- package/dist/src/commands/startCommandHandler.js +27 -0
- package/dist/src/commands/startCommandHandler.js.map +1 -0
- package/dist/src/context.d.ts +24 -0
- package/dist/src/context.d.ts.map +1 -0
- package/dist/src/context.js +31 -0
- package/dist/src/context.js.map +1 -0
- package/dist/src/credentials.d.ts +33 -0
- package/dist/src/credentials.d.ts.map +1 -0
- package/dist/src/credentials.js +87 -0
- package/dist/src/credentials.js.map +1 -0
- package/dist/src/dataIslandApp.d.ts +50 -0
- package/dist/src/dataIslandApp.d.ts.map +1 -0
- package/dist/src/dataIslandApp.js +10 -0
- package/dist/src/dataIslandApp.js.map +1 -0
- package/dist/src/disposable.d.ts +84 -0
- package/dist/src/disposable.d.ts.map +1 -0
- package/dist/src/disposable.js +147 -0
- package/dist/src/disposable.js.map +1 -0
- package/dist/src/dto/accessGroupResponse.d.ts +27 -0
- package/dist/src/dto/accessGroupResponse.d.ts.map +1 -0
- package/dist/src/dto/accessGroupResponse.js +3 -0
- package/dist/src/dto/accessGroupResponse.js.map +1 -0
- package/dist/src/dto/chatResponse.d.ts +81 -0
- package/dist/src/dto/chatResponse.d.ts.map +1 -0
- package/dist/src/dto/chatResponse.js +45 -0
- package/dist/src/dto/chatResponse.js.map +1 -0
- package/dist/src/dto/userInfoResponse.d.ts +43 -0
- package/dist/src/dto/userInfoResponse.d.ts.map +1 -0
- package/dist/src/dto/userInfoResponse.js +3 -0
- package/dist/src/dto/userInfoResponse.js.map +1 -0
- package/dist/src/dto/workspacesResponse.d.ts +43 -0
- package/dist/src/dto/workspacesResponse.d.ts.map +1 -0
- package/dist/src/dto/workspacesResponse.js +3 -0
- package/dist/src/dto/workspacesResponse.js.map +1 -0
- package/dist/src/events.d.ts +17 -0
- package/dist/src/events.d.ts.map +1 -0
- package/dist/src/events.js +52 -0
- package/dist/src/events.js.map +1 -0
- package/dist/src/index.d.ts +65 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +110 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/internal/app.impl.d.ts +28 -0
- package/dist/src/internal/app.impl.d.ts.map +1 -0
- package/dist/src/internal/app.impl.js +173 -0
- package/dist/src/internal/app.impl.js.map +1 -0
- package/dist/src/internal/appBuilder.impl.d.ts +27 -0
- package/dist/src/internal/appBuilder.impl.d.ts.map +1 -0
- package/dist/src/internal/appBuilder.impl.js +71 -0
- package/dist/src/internal/appBuilder.impl.js.map +1 -0
- package/dist/src/internal/createApp.impl.d.ts +4 -0
- package/dist/src/internal/createApp.impl.d.ts.map +1 -0
- package/dist/src/internal/createApp.impl.js +11 -0
- package/dist/src/internal/createApp.impl.js.map +1 -0
- package/dist/src/internal/registry.d.ts +66 -0
- package/dist/src/internal/registry.d.ts.map +1 -0
- package/dist/src/internal/registry.js +114 -0
- package/dist/src/internal/registry.js.map +1 -0
- package/dist/src/middleware.d.ts +6 -0
- package/dist/src/middleware.d.ts.map +1 -0
- package/dist/src/middleware.js +3 -0
- package/dist/src/middleware.js.map +1 -0
- package/dist/src/services/anonymousService.d.ts +8 -0
- package/dist/src/services/anonymousService.d.ts.map +1 -0
- package/dist/src/services/anonymousService.js +41 -0
- package/dist/src/services/anonymousService.js.map +1 -0
- package/dist/src/services/commandService.d.ts +18 -0
- package/dist/src/services/commandService.d.ts.map +1 -0
- package/dist/src/services/commandService.js +40 -0
- package/dist/src/services/commandService.js.map +1 -0
- package/dist/src/services/cookieService.d.ts +7 -0
- package/dist/src/services/cookieService.d.ts.map +1 -0
- package/dist/src/services/cookieService.js +18 -0
- package/dist/src/services/cookieService.js.map +1 -0
- package/dist/src/services/credentialService.d.ts +9 -0
- package/dist/src/services/credentialService.d.ts.map +1 -0
- package/dist/src/services/credentialService.js +26 -0
- package/dist/src/services/credentialService.js.map +1 -0
- package/dist/src/services/httpMethod.d.ts +2 -0
- package/dist/src/services/httpMethod.d.ts.map +1 -0
- package/dist/src/services/httpMethod.js +3 -0
- package/dist/src/services/httpMethod.js.map +1 -0
- package/dist/src/services/middlewareService.d.ts +10 -0
- package/dist/src/services/middlewareService.d.ts.map +1 -0
- package/dist/src/services/middlewareService.js +34 -0
- package/dist/src/services/middlewareService.js.map +1 -0
- package/dist/src/services/organizationService.d.ts +10 -0
- package/dist/src/services/organizationService.d.ts.map +1 -0
- package/dist/src/services/organizationService.js +19 -0
- package/dist/src/services/organizationService.js.map +1 -0
- package/dist/src/services/requestBuilder.d.ts +17 -0
- package/dist/src/services/requestBuilder.d.ts.map +1 -0
- package/dist/src/services/requestBuilder.js +105 -0
- package/dist/src/services/requestBuilder.js.map +1 -0
- package/dist/src/services/responseUtils.d.ts +7 -0
- package/dist/src/services/responseUtils.d.ts.map +1 -0
- package/dist/src/services/responseUtils.js +32 -0
- package/dist/src/services/responseUtils.js.map +1 -0
- package/dist/src/services/rpcService.d.ts +77 -0
- package/dist/src/services/rpcService.d.ts.map +1 -0
- package/dist/src/services/rpcService.js +125 -0
- package/dist/src/services/rpcService.js.map +1 -0
- package/dist/src/services/service.d.ts +21 -0
- package/dist/src/services/service.d.ts.map +1 -0
- package/dist/src/services/service.js +41 -0
- package/dist/src/services/service.js.map +1 -0
- package/dist/src/services/userProfileService.d.ts +9 -0
- package/dist/src/services/userProfileService.d.ts.map +1 -0
- package/dist/src/services/userProfileService.js +43 -0
- package/dist/src/services/userProfileService.js.map +1 -0
- package/dist/src/storages/chats/answer.d.ts +41 -0
- package/dist/src/storages/chats/answer.d.ts.map +1 -0
- package/dist/src/storages/chats/answer.impl.d.ts +29 -0
- package/dist/src/storages/chats/answer.impl.d.ts.map +1 -0
- package/dist/src/storages/chats/answer.impl.js +116 -0
- package/dist/src/storages/chats/answer.impl.js.map +1 -0
- package/dist/src/storages/chats/answer.js +15 -0
- package/dist/src/storages/chats/answer.js.map +1 -0
- package/dist/src/storages/chats/chat.d.ts +35 -0
- package/dist/src/storages/chats/chat.d.ts.map +1 -0
- package/dist/src/storages/chats/chat.impl.d.ts +23 -0
- package/dist/src/storages/chats/chat.impl.d.ts.map +1 -0
- package/dist/src/storages/chats/chat.impl.js +74 -0
- package/dist/src/storages/chats/chat.impl.js.map +1 -0
- package/dist/src/storages/chats/chat.js +12 -0
- package/dist/src/storages/chats/chat.js.map +1 -0
- package/dist/src/storages/chats/chats.d.ts +40 -0
- package/dist/src/storages/chats/chats.d.ts.map +1 -0
- package/dist/src/storages/chats/chats.impl.d.ts +18 -0
- package/dist/src/storages/chats/chats.impl.d.ts.map +1 -0
- package/dist/src/storages/chats/chats.impl.js +102 -0
- package/dist/src/storages/chats/chats.impl.js.map +1 -0
- package/dist/src/storages/chats/chats.js +16 -0
- package/dist/src/storages/chats/chats.js.map +1 -0
- package/dist/src/storages/files/file.d.ts +39 -0
- package/dist/src/storages/files/file.d.ts.map +1 -0
- package/dist/src/storages/files/file.impl.d.ts +23 -0
- package/dist/src/storages/files/file.impl.d.ts.map +1 -0
- package/dist/src/storages/files/file.impl.js +89 -0
- package/dist/src/storages/files/file.impl.js.map +1 -0
- package/dist/src/storages/files/file.js +17 -0
- package/dist/src/storages/files/file.js.map +1 -0
- package/dist/src/storages/files/files.d.ts +34 -0
- package/dist/src/storages/files/files.d.ts.map +1 -0
- package/dist/src/storages/files/files.impl.d.ts +22 -0
- package/dist/src/storages/files/files.impl.d.ts.map +1 -0
- package/dist/src/storages/files/files.impl.js +142 -0
- package/dist/src/storages/files/files.impl.js.map +1 -0
- package/dist/src/storages/files/files.js +20 -0
- package/dist/src/storages/files/files.js.map +1 -0
- package/dist/src/storages/files/filesPage.d.ts +28 -0
- package/dist/src/storages/files/filesPage.d.ts.map +1 -0
- package/dist/src/storages/files/filesPage.impl.d.ts +15 -0
- package/dist/src/storages/files/filesPage.impl.d.ts.map +1 -0
- package/dist/src/storages/files/filesPage.impl.js +38 -0
- package/dist/src/storages/files/filesPage.impl.js.map +1 -0
- package/dist/src/storages/files/filesPage.js +10 -0
- package/dist/src/storages/files/filesPage.js.map +1 -0
- package/dist/src/storages/groups/group.d.ts +63 -0
- package/dist/src/storages/groups/group.d.ts.map +1 -0
- package/dist/src/storages/groups/group.impl.d.ts +38 -0
- package/dist/src/storages/groups/group.impl.d.ts.map +1 -0
- package/dist/src/storages/groups/group.impl.js +210 -0
- package/dist/src/storages/groups/group.impl.js.map +1 -0
- package/dist/src/storages/groups/group.js +15 -0
- package/dist/src/storages/groups/group.js.map +1 -0
- package/dist/src/storages/groups/groups.d.ts +39 -0
- package/dist/src/storages/groups/groups.d.ts.map +1 -0
- package/dist/src/storages/groups/groups.impl.d.ts +30 -0
- package/dist/src/storages/groups/groups.impl.d.ts.map +1 -0
- package/dist/src/storages/groups/groups.impl.js +132 -0
- package/dist/src/storages/groups/groups.impl.js.map +1 -0
- package/dist/src/storages/groups/groups.js +20 -0
- package/dist/src/storages/groups/groups.js.map +1 -0
- package/dist/src/storages/organizations/organization.d.ts +55 -0
- package/dist/src/storages/organizations/organization.d.ts.map +1 -0
- package/dist/src/storages/organizations/organization.impl.d.ts +32 -0
- package/dist/src/storages/organizations/organization.impl.d.ts.map +1 -0
- package/dist/src/storages/organizations/organization.impl.js +120 -0
- package/dist/src/storages/organizations/organization.impl.js.map +1 -0
- package/dist/src/storages/organizations/organization.js +18 -0
- package/dist/src/storages/organizations/organization.js.map +1 -0
- package/dist/src/storages/organizations/organizations.d.ts +46 -0
- package/dist/src/storages/organizations/organizations.d.ts.map +1 -0
- package/dist/src/storages/organizations/organizations.impl.d.ts +38 -0
- package/dist/src/storages/organizations/organizations.impl.d.ts.map +1 -0
- package/dist/src/storages/organizations/organizations.impl.js +157 -0
- package/dist/src/storages/organizations/organizations.impl.js.map +1 -0
- package/dist/src/storages/organizations/organizations.js +20 -0
- package/dist/src/storages/organizations/organizations.js.map +1 -0
- package/dist/src/storages/user/userProfile.d.ts +36 -0
- package/dist/src/storages/user/userProfile.d.ts.map +1 -0
- package/dist/src/storages/user/userProfile.impl.d.ts +14 -0
- package/dist/src/storages/user/userProfile.impl.d.ts.map +1 -0
- package/dist/src/storages/user/userProfile.impl.js +57 -0
- package/dist/src/storages/user/userProfile.impl.js.map +1 -0
- package/dist/src/storages/user/userProfile.js +12 -0
- package/dist/src/storages/user/userProfile.js.map +1 -0
- package/dist/src/storages/workspaces/workspace.d.ts +44 -0
- package/dist/src/storages/workspaces/workspace.d.ts.map +1 -0
- package/dist/src/storages/workspaces/workspace.impl.d.ts +23 -0
- package/dist/src/storages/workspaces/workspace.impl.d.ts.map +1 -0
- package/dist/src/storages/workspaces/workspace.impl.js +98 -0
- package/dist/src/storages/workspaces/workspace.impl.js.map +1 -0
- package/dist/src/storages/workspaces/workspace.js +18 -0
- package/dist/src/storages/workspaces/workspace.js.map +1 -0
- package/dist/src/storages/workspaces/workspaces.d.ts +47 -0
- package/dist/src/storages/workspaces/workspaces.d.ts.map +1 -0
- package/dist/src/storages/workspaces/workspaces.impl.d.ts +33 -0
- package/dist/src/storages/workspaces/workspaces.impl.d.ts.map +1 -0
- package/dist/src/storages/workspaces/workspaces.impl.js +159 -0
- package/dist/src/storages/workspaces/workspaces.impl.js.map +1 -0
- package/dist/src/storages/workspaces/workspaces.js +19 -0
- package/dist/src/storages/workspaces/workspaces.js.map +1 -0
- package/dist/src/unitTest.d.ts +12 -0
- package/dist/src/unitTest.d.ts.map +1 -0
- package/dist/src/unitTest.js +44 -0
- package/dist/src/unitTest.js.map +1 -0
- package/dist/src/utils/browserUtils.d.ts +4 -0
- package/dist/src/utils/browserUtils.d.ts.map +1 -0
- package/dist/src/utils/browserUtils.js +68 -0
- package/dist/src/utils/browserUtils.js.map +1 -0
- package/dist/src/utils/request.d.ts +6 -0
- package/dist/src/utils/request.d.ts.map +1 -0
- package/dist/src/utils/request.js +3 -0
- package/dist/src/utils/request.js.map +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +46 -5
- package/src/commands/deleteUserFullCommandHandler.ts +19 -0
- package/src/commands/startCommandHandler.ts +16 -5
- package/src/context.ts +4 -2
- package/src/credentials.ts +22 -0
- package/src/{appSdk.ts → dataIslandApp.ts} +3 -3
- package/src/disposable.ts +20 -8
- package/src/dto/accessGroupResponse.ts +15 -16
- package/src/dto/chatResponse.ts +57 -54
- package/src/dto/userInfoResponse.ts +5 -2
- package/src/dto/workspacesResponse.ts +3 -3
- package/src/events.ts +12 -12
- package/src/index.ts +45 -10
- package/src/internal/app.impl.ts +47 -17
- package/src/internal/createApp.impl.ts +4 -4
- package/src/internal/registry.ts +54 -6
- package/src/middleware.ts +2 -0
- package/src/services/anonymousService.ts +43 -0
- package/src/services/commandService.ts +4 -2
- package/src/services/cookieService.ts +16 -0
- package/src/services/httpMethod.ts +1 -0
- package/src/services/middlewareService.ts +2 -1
- package/src/services/organizationService.ts +2 -2
- package/src/services/requestBuilder.ts +42 -15
- package/src/services/responseUtils.ts +2 -0
- package/src/services/rpcService.ts +24 -6
- package/src/services/service.ts +7 -5
- package/src/services/userProfileService.ts +16 -2
- package/src/storages/chats/answer.impl.ts +160 -0
- package/src/storages/chats/answer.ts +53 -0
- package/src/storages/chats/chat.impl.ts +95 -0
- package/src/storages/chats/chat.ts +45 -0
- package/src/storages/chats/chats.impl.ts +144 -0
- package/src/storages/chats/chats.ts +47 -0
- package/src/storages/files/file.impl.ts +113 -0
- package/src/storages/files/file.ts +49 -0
- package/src/storages/{files.impl.ts → files/files.impl.ts} +63 -61
- package/src/storages/files/files.ts +39 -0
- package/src/storages/files/filesPage.impl.ts +37 -0
- package/src/storages/files/filesPage.ts +33 -0
- package/src/storages/groups/group.impl.ts +276 -0
- package/src/storages/groups/group.ts +73 -0
- package/src/storages/groups/groups.impl.ts +175 -0
- package/src/storages/groups/groups.ts +45 -0
- package/src/storages/organizations/organization.impl.ts +165 -0
- package/src/storages/organizations/organization.ts +67 -0
- package/src/storages/{organizations.impl.ts → organizations/organizations.impl.ts} +30 -13
- package/src/storages/{organizations.ts → organizations/organizations.ts} +1 -1
- package/src/storages/{userProfile.impl.ts → user/userProfile.impl.ts} +8 -1
- package/src/storages/{userProfile.ts → user/userProfile.ts} +6 -1
- package/src/storages/{workspace.impl.ts → workspaces/workspace.impl.ts} +28 -8
- package/src/storages/{workspace.ts → workspaces/workspace.ts} +13 -2
- package/src/storages/{workspaces.impl.ts → workspaces/workspaces.impl.ts} +18 -13
- package/src/storages/{workspaces.ts → workspaces/workspaces.ts} +6 -2
- package/src/unitTest.ts +14 -3
- package/src/utils/browserUtils.ts +72 -0
- package/src/utils/request.ts +6 -0
- package/.browserslistrc +0 -5
- package/.editorconfig +0 -25
- package/.eslintrc.json +0 -44
- package/.github/workflows/publish-npm.yml +0 -28
- package/.prettierignore +0 -1
- package/.prettierrc +0 -11
- package/.yarnrc +0 -2
- package/babel.config.js +0 -6
- package/jest.config.ts +0 -199
- package/jest.setup.ts +0 -2
- package/src/storages/chat.ts +0 -37
- package/src/storages/file.impl.ts +0 -68
- package/src/storages/files.ts +0 -67
- package/src/storages/groups.impl.ts +0 -337
- package/src/storages/groups.ts +0 -43
- package/src/storages/organization.impl.ts +0 -68
- package/src/storages/organization.ts +0 -33
- package/test/commands.test.ts +0 -24
- package/test/disposable.test.ts +0 -39
- package/test/events.test.ts +0 -151
- package/test/index.test.ts +0 -225
- package/test/registry.test.ts +0 -44
- package/test/services.test.ts +0 -56
- package/test/setup.ts +0 -2
- package/test/unitTest.test.ts +0 -21
- package/test_file.pdf +0 -0
- package/tsconfig.json +0 -31
@@ -0,0 +1,165 @@
|
|
1
|
+
import { OrganizationId } from "./organizations"
|
2
|
+
import { Disposable } from "../../disposable"
|
3
|
+
import { OrganizationDto, UserDto } from "../../dto/userInfoResponse"
|
4
|
+
import { Workspaces } from "../workspaces/workspaces"
|
5
|
+
import { WorkspacesImpl } from "../workspaces/workspaces.impl"
|
6
|
+
import { Context } from "../../context"
|
7
|
+
import { Organization, OrganizationEvent } from "./organization"
|
8
|
+
import { GroupsImpl } from "../groups/groups.impl"
|
9
|
+
import { Groups } from "../groups/groups"
|
10
|
+
import { ChatsImpl } from "../chats/chats.impl"
|
11
|
+
import { Chats } from "../chats/chats"
|
12
|
+
import { RpcService } from "../../services/rpcService"
|
13
|
+
import { ResponseUtils } from "../../services/responseUtils"
|
14
|
+
|
15
|
+
export class OrganizationImpl extends Organization implements Disposable {
|
16
|
+
private _isDisposed: boolean = false
|
17
|
+
private _isAdmin: boolean = false
|
18
|
+
private _content?: OrganizationDto
|
19
|
+
private readonly _workspaces: WorkspacesImpl
|
20
|
+
private readonly _accessGroups: GroupsImpl
|
21
|
+
private readonly _chats: ChatsImpl
|
22
|
+
|
23
|
+
constructor(private readonly context: Context) {
|
24
|
+
super()
|
25
|
+
this._workspaces = new WorkspacesImpl(this, this.context)
|
26
|
+
this._accessGroups = new GroupsImpl(this, this.context)
|
27
|
+
this._chats = new ChatsImpl(this, this.context)
|
28
|
+
}
|
29
|
+
|
30
|
+
public async initFrom(
|
31
|
+
content: OrganizationDto,
|
32
|
+
isAdmin: boolean
|
33
|
+
): Promise<OrganizationImpl> {
|
34
|
+
this._content = content
|
35
|
+
this._isAdmin = isAdmin
|
36
|
+
|
37
|
+
// init workspaces by organization id
|
38
|
+
await this._workspaces.initFrom(content.id)
|
39
|
+
await this._chats.initFrom(content.id)
|
40
|
+
await this._accessGroups.initialize()
|
41
|
+
|
42
|
+
return this
|
43
|
+
}
|
44
|
+
|
45
|
+
get isAdmin(): boolean {
|
46
|
+
return this._isAdmin
|
47
|
+
}
|
48
|
+
|
49
|
+
get isDisposed(): boolean {
|
50
|
+
return this._isDisposed
|
51
|
+
}
|
52
|
+
|
53
|
+
dispose(): void {
|
54
|
+
this._isDisposed = true
|
55
|
+
}
|
56
|
+
|
57
|
+
get id(): OrganizationId {
|
58
|
+
return <OrganizationId>this._content?.id
|
59
|
+
}
|
60
|
+
|
61
|
+
get name(): string {
|
62
|
+
return <OrganizationId>this._content?.profile.name
|
63
|
+
}
|
64
|
+
|
65
|
+
get description(): string {
|
66
|
+
return <OrganizationId>this._content?.profile.description
|
67
|
+
}
|
68
|
+
|
69
|
+
get workspaces(): Workspaces {
|
70
|
+
return this._workspaces
|
71
|
+
}
|
72
|
+
|
73
|
+
get accessGroups(): Groups {
|
74
|
+
return this._accessGroups
|
75
|
+
}
|
76
|
+
|
77
|
+
get chats(): Chats {
|
78
|
+
return this._chats
|
79
|
+
}
|
80
|
+
|
81
|
+
async members(): Promise<UserDto[]> {
|
82
|
+
// send request to the server
|
83
|
+
const response = await this.context
|
84
|
+
.resolve(RpcService)
|
85
|
+
?.requestBuilder("api/v1/Organizations/members")
|
86
|
+
.searchParam("id", this.id)
|
87
|
+
.sendGet()
|
88
|
+
|
89
|
+
// check response status
|
90
|
+
if (ResponseUtils.isFail(response)) {
|
91
|
+
await ResponseUtils.throwError(
|
92
|
+
`Failed during fetch of organization members ${this.id}`,
|
93
|
+
response
|
94
|
+
)
|
95
|
+
}
|
96
|
+
|
97
|
+
return (await response!.json() as {
|
98
|
+
members: UserDto[]
|
99
|
+
}).members as UserDto[]
|
100
|
+
}
|
101
|
+
|
102
|
+
async change(name: string, description: string): Promise<void> {
|
103
|
+
if (!this._content) {
|
104
|
+
throw new Error("Organization is not loaded.")
|
105
|
+
}
|
106
|
+
|
107
|
+
if (name === this.name && description === this.description) {
|
108
|
+
return Promise.resolve()
|
109
|
+
}
|
110
|
+
if (name === undefined || name === null || name.trim() === "") {
|
111
|
+
throw new Error("Name is required. Please provide a valid name.")
|
112
|
+
}
|
113
|
+
if (
|
114
|
+
description === undefined ||
|
115
|
+
description === null ||
|
116
|
+
description.trim() === ""
|
117
|
+
) {
|
118
|
+
throw new Error(
|
119
|
+
"Description is required. Please provide a valid description."
|
120
|
+
)
|
121
|
+
}
|
122
|
+
|
123
|
+
const response = await this.context
|
124
|
+
.resolve(RpcService)
|
125
|
+
?.requestBuilder("api/v1/Organizations")
|
126
|
+
.sendPutJson({
|
127
|
+
organizationId: this.id,
|
128
|
+
profile: {
|
129
|
+
name,
|
130
|
+
description
|
131
|
+
}
|
132
|
+
})
|
133
|
+
|
134
|
+
if (ResponseUtils.isFail(response)) {
|
135
|
+
await ResponseUtils.throwError("Failed to change organization", response)
|
136
|
+
}
|
137
|
+
|
138
|
+
if (this._content) {
|
139
|
+
this._content.profile.name = name
|
140
|
+
this._content.profile.description = description
|
141
|
+
}
|
142
|
+
|
143
|
+
this.dispatch({
|
144
|
+
type: OrganizationEvent.CHANGED,
|
145
|
+
data: this
|
146
|
+
})
|
147
|
+
}
|
148
|
+
|
149
|
+
async createInviteLink(emails: string[], accessGroups: string[]): Promise<void> {
|
150
|
+
const response = await this.context
|
151
|
+
.resolve(RpcService)
|
152
|
+
?.requestBuilder("api/v1/Invites")
|
153
|
+
.sendPostJson({
|
154
|
+
organizationId: this.id,
|
155
|
+
emails: emails,
|
156
|
+
accessGroupIds: accessGroups
|
157
|
+
})
|
158
|
+
if (ResponseUtils.isFail(response)) {
|
159
|
+
await ResponseUtils.throwError(
|
160
|
+
`Invite link creation failed for organization ${this.id}`,
|
161
|
+
response
|
162
|
+
)
|
163
|
+
}
|
164
|
+
}
|
165
|
+
}
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import { Workspaces } from "../workspaces/workspaces"
|
2
|
+
import { OrganizationId } from "./organizations"
|
3
|
+
import { Groups } from "../groups/groups"
|
4
|
+
import { Chats } from "../chats/chats"
|
5
|
+
import { EventDispatcher } from "../../events"
|
6
|
+
import { UserDto } from "../../dto/userInfoResponse"
|
7
|
+
import { GroupId } from "../groups/group"
|
8
|
+
|
9
|
+
/**
|
10
|
+
* Organization event.
|
11
|
+
*/
|
12
|
+
export enum OrganizationEvent {
|
13
|
+
CHANGED = "changed"
|
14
|
+
}
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Organization.
|
18
|
+
*/
|
19
|
+
export abstract class Organization extends EventDispatcher<
|
20
|
+
OrganizationEvent,
|
21
|
+
Organization
|
22
|
+
> {
|
23
|
+
/**
|
24
|
+
* Organization id.
|
25
|
+
*/
|
26
|
+
abstract get id(): OrganizationId
|
27
|
+
|
28
|
+
/**
|
29
|
+
* Organization name.
|
30
|
+
*/
|
31
|
+
abstract get name(): string
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Organization description.
|
35
|
+
*/
|
36
|
+
abstract get description(): string
|
37
|
+
|
38
|
+
/**
|
39
|
+
* Workspaces.
|
40
|
+
*/
|
41
|
+
abstract get workspaces(): Workspaces
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Chats.
|
45
|
+
*/
|
46
|
+
abstract get chats(): Chats
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Groups.
|
50
|
+
*/
|
51
|
+
abstract get accessGroups(): Groups
|
52
|
+
|
53
|
+
/**
|
54
|
+
* Get organization members
|
55
|
+
*/
|
56
|
+
abstract members(): Promise<UserDto[]>
|
57
|
+
|
58
|
+
/**
|
59
|
+
* Change organization name and description.
|
60
|
+
*/
|
61
|
+
abstract change(name: string, description: string): Promise<void>
|
62
|
+
|
63
|
+
/**
|
64
|
+
* Create invite link
|
65
|
+
*/
|
66
|
+
abstract createInviteLink(emails: string[], accessGroups: GroupId[]): Promise<void>
|
67
|
+
}
|
@@ -4,11 +4,11 @@ import {
|
|
4
4
|
Organizations
|
5
5
|
} from "./organizations"
|
6
6
|
import { OrganizationImpl } from "./organization.impl"
|
7
|
-
import { RpcService } from "
|
8
|
-
import { OrganizationDto, UserSettings } from "
|
9
|
-
import { Context } from "
|
7
|
+
import { RpcService } from "../../services/rpcService"
|
8
|
+
import { OrganizationDto, UserSettings } from "../../dto/userInfoResponse"
|
9
|
+
import { Context } from "../../context"
|
10
10
|
import { Organization } from "./organization"
|
11
|
-
import { ResponseUtils } from "
|
11
|
+
import { ResponseUtils } from "../../services/responseUtils"
|
12
12
|
|
13
13
|
export class OrganizationsImpl extends Organizations {
|
14
14
|
constructor(public readonly context: Context) {
|
@@ -79,17 +79,22 @@ export class OrganizationsImpl extends Organizations {
|
|
79
79
|
if (!this.contains(id)) {
|
80
80
|
throw new Error(`Organization delete, id: ${id} is not found`)
|
81
81
|
}
|
82
|
+
// send request to the server
|
82
83
|
const response = await this.context
|
83
84
|
.resolve(RpcService)
|
84
85
|
?.requestBuilder("/api/v1/Organizations")
|
85
86
|
.searchParam("id", id)
|
86
87
|
.sendDelete()
|
88
|
+
|
89
|
+
// check response status
|
87
90
|
if (ResponseUtils.isFail(response)) {
|
88
91
|
await ResponseUtils.throwError(
|
89
92
|
`Organization ${id} delete, failed`,
|
90
93
|
response
|
91
94
|
)
|
92
95
|
}
|
96
|
+
|
97
|
+
// check organization in collection
|
93
98
|
const org = <OrganizationImpl>this.get(id)
|
94
99
|
const index = this.organizations.indexOf(org)
|
95
100
|
if (index < 0) {
|
@@ -130,7 +135,7 @@ export class OrganizationsImpl extends Organizations {
|
|
130
135
|
const response = await this.context
|
131
136
|
.resolve(RpcService)
|
132
137
|
?.requestBuilder("api/v1/Organizations")
|
133
|
-
.
|
138
|
+
.sendPostJson({
|
134
139
|
profile: {
|
135
140
|
name: name,
|
136
141
|
description: description
|
@@ -142,7 +147,9 @@ export class OrganizationsImpl extends Organizations {
|
|
142
147
|
response
|
143
148
|
)
|
144
149
|
}
|
145
|
-
const content = (await response!.json()
|
150
|
+
const content = (await response!.json() as {
|
151
|
+
organization: OrganizationDto
|
152
|
+
}).organization as OrganizationDto
|
146
153
|
|
147
154
|
// create organization and init from content
|
148
155
|
const org = await new OrganizationImpl(this.context).initFrom(content, true)
|
@@ -170,22 +177,32 @@ export class OrganizationsImpl extends Organizations {
|
|
170
177
|
organizations: OrganizationDto[],
|
171
178
|
settings: UserSettings | null | undefined
|
172
179
|
): Promise<void> {
|
180
|
+
|
181
|
+
// set current organization
|
173
182
|
this.currentOrganizationId = settings?.activeOrganizationId
|
183
|
+
|
184
|
+
// wait list
|
185
|
+
const waitList: Promise<OrganizationImpl>[] = []
|
186
|
+
|
187
|
+
// init organizations
|
174
188
|
for (const organization of organizations) {
|
175
189
|
// create organization and init from content
|
176
|
-
const
|
190
|
+
const orgPromise = new OrganizationImpl(this.context).initFrom(
|
177
191
|
organization,
|
178
192
|
adminInOrganization.includes(organization.id)
|
179
193
|
)
|
180
194
|
|
195
|
+
// add organization to wait list
|
196
|
+
waitList.push(orgPromise)
|
197
|
+
}
|
198
|
+
|
199
|
+
// wait for all organizations
|
200
|
+
const orgImpls = await Promise.all(waitList)
|
201
|
+
|
202
|
+
// add organizations to collection
|
203
|
+
for (const org of orgImpls) {
|
181
204
|
// add organization to collection
|
182
205
|
this.organizations.push(org)
|
183
|
-
|
184
|
-
// dispatch event, organization added
|
185
|
-
this.dispatch({
|
186
|
-
type: OrganizationsEvent.ADDED,
|
187
|
-
data: org
|
188
|
-
})
|
189
206
|
}
|
190
207
|
}
|
191
208
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { UserEvent, UserProfile } from "./userProfile"
|
2
|
-
import { UserInfoResponse } from "
|
2
|
+
import { UserInfoResponse } from "../../dto/userInfoResponse"
|
3
3
|
|
4
4
|
export class UserProfileImpl extends UserProfile {
|
5
5
|
private content?: UserInfoResponse
|
@@ -32,6 +32,13 @@ export class UserProfileImpl extends UserProfile {
|
|
32
32
|
throw new Error("The profile is not loaded.")
|
33
33
|
}
|
34
34
|
|
35
|
+
get isAnonymous(): boolean {
|
36
|
+
if (this.content) {
|
37
|
+
return this.content.user.isAnonymousMode
|
38
|
+
}
|
39
|
+
throw new Error("The profile is not loaded.")
|
40
|
+
}
|
41
|
+
|
35
42
|
get createdAt(): Date {
|
36
43
|
if (this.content) {
|
37
44
|
return new Date(this.content.user.created_at)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { EventDispatcher } from "
|
1
|
+
import { EventDispatcher } from "../../events"
|
2
2
|
|
3
3
|
export type UserId = string
|
4
4
|
|
@@ -30,6 +30,11 @@ export abstract class UserProfile extends EventDispatcher<
|
|
30
30
|
*/
|
31
31
|
abstract get isDeleted(): boolean
|
32
32
|
|
33
|
+
/**
|
34
|
+
* Is user anonymous
|
35
|
+
*/
|
36
|
+
abstract get isAnonymous(): boolean
|
37
|
+
|
33
38
|
/**
|
34
39
|
* Created at.
|
35
40
|
*/
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import { Context } from "
|
2
|
-
import { Files } from "
|
1
|
+
import { Context } from "../../context"
|
2
|
+
import { Files } from "../files/files"
|
3
3
|
import { Workspace, WorkspaceEvent } from "./workspace"
|
4
|
-
import { OrganizationImpl } from "
|
5
|
-
import { WorkspaceDto } from "
|
6
|
-
import { RpcService } from "
|
7
|
-
import { FilesImpl } from "
|
8
|
-
import { ResponseUtils } from "
|
4
|
+
import { OrganizationImpl } from "../organizations/organization.impl"
|
5
|
+
import { WorkspaceDto } from "../../dto/workspacesResponse"
|
6
|
+
import { RpcService } from "../../services/rpcService"
|
7
|
+
import { FilesImpl } from "../files/files.impl"
|
8
|
+
import { ResponseUtils } from "../../services/responseUtils"
|
9
9
|
|
10
10
|
export class WorkspaceImpl extends Workspace {
|
11
11
|
private _isMarkAsDeleted: boolean = false
|
@@ -46,6 +46,26 @@ export class WorkspaceImpl extends Workspace {
|
|
46
46
|
return this._files
|
47
47
|
}
|
48
48
|
|
49
|
+
async filesCount(): Promise<number> {
|
50
|
+
// send request to the server
|
51
|
+
const response = await this.context
|
52
|
+
.resolve(RpcService)
|
53
|
+
?.requestBuilder("api/v1/Workspaces/files/count")
|
54
|
+
.searchParam("workspaceId", this.id)
|
55
|
+
.searchParam("organizationId", this.organization.id)
|
56
|
+
.sendGet()
|
57
|
+
|
58
|
+
// check response status
|
59
|
+
if (ResponseUtils.isFail(response)) {
|
60
|
+
await ResponseUtils.throwError(
|
61
|
+
`Failed during get workspace total files count for ${this.id} of ${this.organization.id}`,
|
62
|
+
response
|
63
|
+
)
|
64
|
+
}
|
65
|
+
|
66
|
+
return ((await response!.json()) as { count: number }).count
|
67
|
+
}
|
68
|
+
|
49
69
|
async change(name: string, description: string): Promise<void> {
|
50
70
|
if (!this._workspace) {
|
51
71
|
throw new Error("Workspace is not loaded.")
|
@@ -72,7 +92,7 @@ export class WorkspaceImpl extends Workspace {
|
|
72
92
|
const response = await this.context
|
73
93
|
.resolve(RpcService)
|
74
94
|
?.requestBuilder("api/v1/Workspaces")
|
75
|
-
.
|
95
|
+
.sendPutJson({
|
76
96
|
workspaceId: this.id,
|
77
97
|
profile: {
|
78
98
|
name,
|
@@ -1,6 +1,7 @@
|
|
1
|
-
import { EventDispatcher } from "
|
2
|
-
import { Files } from "
|
1
|
+
import { EventDispatcher } from "../../events"
|
2
|
+
import { Files } from "../files/files"
|
3
3
|
import { WorkspaceId } from "./workspaces"
|
4
|
+
import { Organization } from "../organizations/organization"
|
4
5
|
|
5
6
|
/**
|
6
7
|
* Workspace event.
|
@@ -16,6 +17,11 @@ export abstract class Workspace extends EventDispatcher<
|
|
16
17
|
WorkspaceEvent,
|
17
18
|
Workspace
|
18
19
|
> {
|
20
|
+
/**
|
21
|
+
* Organization.
|
22
|
+
*/
|
23
|
+
abstract get organization(): Organization
|
24
|
+
|
19
25
|
/**
|
20
26
|
* Workspace id.
|
21
27
|
*/
|
@@ -36,6 +42,11 @@ export abstract class Workspace extends EventDispatcher<
|
|
36
42
|
*/
|
37
43
|
abstract get files(): Files
|
38
44
|
|
45
|
+
/**
|
46
|
+
* Workspace files count.
|
47
|
+
*/
|
48
|
+
abstract filesCount(): Promise<number>
|
49
|
+
|
39
50
|
/**
|
40
51
|
* Change workspace name and description.
|
41
52
|
*/
|
@@ -1,13 +1,15 @@
|
|
1
1
|
import { WorkspaceId, Workspaces, WorkspacesEvent } from "./workspaces"
|
2
|
-
import { OrganizationImpl } from "
|
3
|
-
import { Context } from "
|
2
|
+
import { OrganizationImpl } from "../organizations/organization.impl"
|
3
|
+
import { Context } from "../../context"
|
4
4
|
import { Workspace } from "./workspace"
|
5
5
|
import { WorkspaceImpl } from "./workspace.impl"
|
6
|
-
import { OrganizationId } from "
|
7
|
-
import { RpcService } from "
|
8
|
-
import { OrganizationWorkspaces } from "
|
9
|
-
import { WorkspaceDto } from "
|
10
|
-
import { ResponseUtils } from "
|
6
|
+
import { OrganizationId } from "../organizations/organizations"
|
7
|
+
import { RpcService } from "../../services/rpcService"
|
8
|
+
import { OrganizationWorkspaces } from "../../dto/userInfoResponse"
|
9
|
+
import { WorkspaceDto } from "../../dto/workspacesResponse"
|
10
|
+
import { ResponseUtils } from "../../services/responseUtils"
|
11
|
+
import { UserProfileService } from "../../services/userProfileService"
|
12
|
+
import { UserProfile } from "../user/userProfile"
|
11
13
|
|
12
14
|
export class WorkspacesImpl extends Workspaces {
|
13
15
|
private readonly _workspaces: WorkspaceImpl[] = []
|
@@ -87,7 +89,7 @@ export class WorkspacesImpl extends Workspaces {
|
|
87
89
|
const response = await this.context
|
88
90
|
.resolve(RpcService)
|
89
91
|
?.requestBuilder("api/v1/Workspaces")
|
90
|
-
.
|
92
|
+
.sendPostJson({
|
91
93
|
organizationId: this.organization.id,
|
92
94
|
profile: {
|
93
95
|
name: name,
|
@@ -102,11 +104,13 @@ export class WorkspacesImpl extends Workspaces {
|
|
102
104
|
|
103
105
|
// check response status
|
104
106
|
if (ResponseUtils.isFail(response)) {
|
105
|
-
await ResponseUtils.throwError(
|
107
|
+
await ResponseUtils.throwError(`Failed to create workspace, in organization: ${this.organization.id}`, response)
|
106
108
|
}
|
107
109
|
|
108
110
|
// parse workspace from the server's response
|
109
|
-
const content = (await response!.json())
|
111
|
+
const content = ((await response!.json()) as {
|
112
|
+
workspace: WorkspaceDto
|
113
|
+
}).workspace as WorkspaceDto
|
110
114
|
|
111
115
|
// create workspace implementation
|
112
116
|
const workspace = new WorkspaceImpl(this.organization, this.context)
|
@@ -139,7 +143,7 @@ export class WorkspacesImpl extends Workspaces {
|
|
139
143
|
|
140
144
|
// check if workspace is already marked as deleted
|
141
145
|
if (workspace.isMarkAsDeleted) {
|
142
|
-
throw new Error(`Workspace ${id} is already marked as deleted`)
|
146
|
+
throw new Error(`Workspace ${id} is already marked as deleted, in organization: ${this.organization.id}`)
|
143
147
|
}
|
144
148
|
|
145
149
|
// mark workspace as deleted
|
@@ -155,7 +159,7 @@ export class WorkspacesImpl extends Workspaces {
|
|
155
159
|
// check response status
|
156
160
|
if (ResponseUtils.isFail(response)) {
|
157
161
|
await ResponseUtils.throwError(
|
158
|
-
`Failed to delete workspace: ${workspace.organization.name}/${workspace.name}:${id}`,
|
162
|
+
`Failed to delete workspace: ${workspace.organization.name}/${workspace.name}:${id}, in organization: ${this.organization.id}`,
|
159
163
|
response
|
160
164
|
)
|
161
165
|
}
|
@@ -184,7 +188,8 @@ export class WorkspacesImpl extends Workspaces {
|
|
184
188
|
|
185
189
|
// check response status
|
186
190
|
if (ResponseUtils.isFail(response)) {
|
187
|
-
|
191
|
+
const userProfile = this.context.resolve(UserProfileService)?.userProfile as UserProfile
|
192
|
+
await ResponseUtils.throwError(`Failed to fetch workspaces in organization: ${organizationId}, userId: ${userProfile.id}, email: ${userProfile.email}`, response)
|
188
193
|
}
|
189
194
|
|
190
195
|
// parse workspaces from the server's response
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { EventDispatcher } from "
|
1
|
+
import { EventDispatcher } from "../../events"
|
2
2
|
import { Workspace } from "./workspace"
|
3
3
|
|
4
4
|
export type WorkspaceId = string
|
@@ -44,7 +44,11 @@ export abstract class Workspaces extends EventDispatcher<
|
|
44
44
|
/**
|
45
45
|
* Create workspace.
|
46
46
|
*/
|
47
|
-
abstract create(name: string, description: string
|
47
|
+
abstract create(name: string, description: string, regulation?: {
|
48
|
+
isCreateNewGroup: boolean,
|
49
|
+
newGroupName: string,
|
50
|
+
groupIds: string[]
|
51
|
+
}): Promise<Workspace>
|
48
52
|
|
49
53
|
/**
|
50
54
|
* Delete workspace.
|
package/src/unitTest.ts
CHANGED
@@ -3,13 +3,13 @@ export enum UnitTest {
|
|
3
3
|
DO_NOT_START = 1 << 0,
|
4
4
|
DO_NOT_PRINT_INITIALIZED_LOG = 1 << 1,
|
5
5
|
|
6
|
-
|
6
|
+
DO_NOT_START_SDK = DO_NOT_START | DO_NOT_PRINT_INITIALIZED_LOG
|
7
7
|
}
|
8
8
|
|
9
9
|
export type UnitTestProfileSyncAction = () => void
|
10
10
|
export type UnitTestProfileAsyncAction = () => Promise<void>
|
11
11
|
|
12
|
-
|
12
|
+
class AppSdkUnitTest {
|
13
13
|
private static _stack: UnitTest[] = [UnitTest.DO_NOTHING]
|
14
14
|
|
15
15
|
public static get current(): UnitTest {
|
@@ -17,7 +17,7 @@ export class AppSdkUnitTest {
|
|
17
17
|
}
|
18
18
|
|
19
19
|
public static async test(
|
20
|
-
unitTest: UnitTest = UnitTest.
|
20
|
+
unitTest: UnitTest = UnitTest.DO_NOT_START_SDK,
|
21
21
|
func: UnitTestProfileSyncAction | UnitTestProfileAsyncAction
|
22
22
|
): Promise<void> {
|
23
23
|
this._stack.push(unitTest)
|
@@ -37,6 +37,17 @@ export class AppSdkUnitTest {
|
|
37
37
|
}
|
38
38
|
}
|
39
39
|
|
40
|
+
export const appTest = async (
|
41
|
+
unitTest: UnitTest = UnitTest.DO_NOT_START_SDK,
|
42
|
+
func: UnitTestProfileSyncAction | UnitTestProfileAsyncAction
|
43
|
+
): Promise<void> => {
|
44
|
+
await AppSdkUnitTest.test(unitTest, func)
|
45
|
+
}
|
46
|
+
|
47
|
+
export const appTestCurrent = (): UnitTest => {
|
48
|
+
return AppSdkUnitTest.current
|
49
|
+
}
|
50
|
+
|
40
51
|
export const isUnitTest = (mask: UnitTest): boolean => {
|
41
52
|
return (AppSdkUnitTest.current & mask) == mask
|
42
53
|
}
|
@@ -0,0 +1,72 @@
|
|
1
|
+
const getDocument = () => {
|
2
|
+
if (!(globalThis as any).document) {
|
3
|
+
(globalThis as any).document = {
|
4
|
+
cookie: ""
|
5
|
+
}
|
6
|
+
}
|
7
|
+
return document
|
8
|
+
}
|
9
|
+
|
10
|
+
const getNavigator = () => {
|
11
|
+
if (!(globalThis as any).navigator) {
|
12
|
+
(globalThis as any).navigator = {
|
13
|
+
userAgent: "",
|
14
|
+
language: "",
|
15
|
+
hardwareConcurrency: 0,
|
16
|
+
cookieEnabled: false
|
17
|
+
}
|
18
|
+
}
|
19
|
+
return navigator
|
20
|
+
}
|
21
|
+
|
22
|
+
const getWidow = () => {
|
23
|
+
if (!(globalThis as any).window) {
|
24
|
+
(globalThis as any).window = {
|
25
|
+
devicePixelRatio: 16 / 9.0,
|
26
|
+
sessionStorage: {},
|
27
|
+
localStorage: {}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
return window
|
31
|
+
}
|
32
|
+
|
33
|
+
export const setCookie = (name: string, value: string | undefined): void => {
|
34
|
+
const doc = getDocument()
|
35
|
+
doc.cookie = `${name}=${value || ""};`
|
36
|
+
}
|
37
|
+
|
38
|
+
export const getCookie = (name: string): string | undefined => {
|
39
|
+
const doc = getDocument()
|
40
|
+
const nameValidator = `${name}=`
|
41
|
+
const cookieItems = doc.cookie.split(";")
|
42
|
+
|
43
|
+
for (let index = 0; index < cookieItems.length; index++) {
|
44
|
+
let cookie = cookieItems[index]
|
45
|
+
|
46
|
+
while (cookie.charAt(0) === " ") {
|
47
|
+
cookie = cookie.substring(1, cookie.length)
|
48
|
+
}
|
49
|
+
|
50
|
+
if (cookie.indexOf(nameValidator) === 0) {
|
51
|
+
return cookie.substring(nameValidator.length, cookie.length)
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
return undefined
|
56
|
+
}
|
57
|
+
|
58
|
+
export const createFingerprint = () => {
|
59
|
+
const nav = getNavigator()
|
60
|
+
const win = getWidow()
|
61
|
+
const fingerprint = new Map<string, any>()
|
62
|
+
|
63
|
+
fingerprint.set("userAgent", nav.userAgent)
|
64
|
+
fingerprint.set("language", nav.language)
|
65
|
+
fingerprint.set("hardware_concurrency", nav.hardwareConcurrency)
|
66
|
+
fingerprint.set("cookie_enabled", nav.cookieEnabled)
|
67
|
+
fingerprint.set("pixel_ratio", win.devicePixelRatio)
|
68
|
+
fingerprint.set("session_storage", win.sessionStorage)
|
69
|
+
fingerprint.set("local_storage", win.localStorage)
|
70
|
+
|
71
|
+
return fingerprint
|
72
|
+
}
|