@nymphjs/tilmeld-client 1.0.0-beta.15 → 1.0.0-beta.150
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +613 -0
- package/README.md +7 -4
- package/dist/Group.d.ts +85 -0
- package/dist/Group.js +81 -0
- package/dist/Group.js.map +1 -0
- package/dist/LDAPSource.d.ts +128 -0
- package/dist/LDAPSource.js +121 -0
- package/dist/LDAPSource.js.map +1 -0
- package/dist/Tilmeld.types.d.ts +12 -0
- package/dist/Tilmeld.types.js +2 -0
- package/dist/Tilmeld.types.js.map +1 -0
- package/{lib → dist}/User.d.ts +146 -14
- package/{lib → dist}/User.js +110 -42
- package/dist/User.js.map +1 -0
- package/dist/helpers.d.ts +58 -0
- package/{lib → dist}/helpers.js +23 -17
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/index.test.d.ts +1 -0
- package/dist/index.test.js +256 -0
- package/dist/index.test.js.map +1 -0
- package/jest.config.js +31 -5
- package/package.json +37 -33
- package/src/Group.ts +81 -40
- package/src/LDAPSource.ts +257 -0
- package/src/Tilmeld.types.ts +13 -0
- package/src/User.ts +207 -87
- package/src/helpers.ts +25 -12
- package/src/index.test.ts +332 -0
- package/src/index.ts +7 -7
- package/tsconfig.json +7 -4
- package/typedoc.json +4 -0
- package/lib/Group.d.ts +0 -41
- package/lib/Group.js +0 -54
- package/lib/Group.js.map +0 -1
- package/lib/User.js.map +0 -1
- package/lib/helpers.d.ts +0 -46
- package/lib/helpers.js.map +0 -1
- package/lib/index.d.ts +0 -7
- package/lib/index.js +0 -28
- package/lib/index.js.map +0 -1
- package/webpack.config.js +0 -31
package/dist/Group.d.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Entity, Options, Selector } from '@nymphjs/client';
|
|
2
|
+
import type { User, CurrentUserData } from './User.js';
|
|
3
|
+
export interface GroupData {
|
|
4
|
+
/**
|
|
5
|
+
* The group's groupname.
|
|
6
|
+
*/
|
|
7
|
+
groupname?: string;
|
|
8
|
+
/**
|
|
9
|
+
* The group's name.
|
|
10
|
+
*/
|
|
11
|
+
name?: string;
|
|
12
|
+
/**
|
|
13
|
+
* The group's avatar URL. (Use getAvatar() to support Gravatar.)
|
|
14
|
+
*/
|
|
15
|
+
avatar?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The group's parent.
|
|
18
|
+
*/
|
|
19
|
+
parent?: Group;
|
|
20
|
+
/**
|
|
21
|
+
* Whether the group can be used.
|
|
22
|
+
*/
|
|
23
|
+
enabled?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Whether this group is the default primary group for new users.
|
|
26
|
+
*/
|
|
27
|
+
defaultPrimary?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Whether this group is a default secondary group for new users.
|
|
30
|
+
*/
|
|
31
|
+
defaultSecondary?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Whether this group is a default secondary group for unverified users.
|
|
34
|
+
*/
|
|
35
|
+
unverifiedSecondary?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface CurrentGroupData extends GroupData {
|
|
38
|
+
/**
|
|
39
|
+
* The abilities granted to the group.
|
|
40
|
+
*/
|
|
41
|
+
abilities?: string[];
|
|
42
|
+
/**
|
|
43
|
+
* The group's email address.
|
|
44
|
+
*/
|
|
45
|
+
email?: string;
|
|
46
|
+
/**
|
|
47
|
+
* The group's telephone number.
|
|
48
|
+
*/
|
|
49
|
+
phone?: string;
|
|
50
|
+
/**
|
|
51
|
+
* If generatePrimary is on, this will be the user who generated this group.
|
|
52
|
+
*/
|
|
53
|
+
user?: (User & CurrentUserData) | null;
|
|
54
|
+
}
|
|
55
|
+
export interface AdminGroupData extends CurrentGroupData {
|
|
56
|
+
}
|
|
57
|
+
export interface Group extends GroupData {
|
|
58
|
+
}
|
|
59
|
+
export declare class Group extends Entity<GroupData> {
|
|
60
|
+
static class: string;
|
|
61
|
+
static factoryGroupname(groupname?: string): Promise<Group>;
|
|
62
|
+
constructor();
|
|
63
|
+
$checkGroupname(): Promise<{
|
|
64
|
+
result: boolean;
|
|
65
|
+
message: string;
|
|
66
|
+
}>;
|
|
67
|
+
$checkEmail(): Promise<{
|
|
68
|
+
result: boolean;
|
|
69
|
+
message: string;
|
|
70
|
+
}>;
|
|
71
|
+
$getAvatar(): Promise<string>;
|
|
72
|
+
$getChildren(limit?: number, offset?: number, reverse?: boolean, sort?: string): Promise<{
|
|
73
|
+
entities: Group[];
|
|
74
|
+
count: number;
|
|
75
|
+
}>;
|
|
76
|
+
$getDescendants(andSelf?: boolean): Promise<Group[]>;
|
|
77
|
+
$getLevel(): Promise<number>;
|
|
78
|
+
$isDescendant(givenGroup: Group | string): Promise<boolean>;
|
|
79
|
+
$getUsers(descendants?: boolean, limit?: number, offset?: number, reverse?: boolean, sort?: string, enabled?: boolean): Promise<{
|
|
80
|
+
entities: User[];
|
|
81
|
+
count: number;
|
|
82
|
+
}>;
|
|
83
|
+
static getPrimaryGroups(options?: Options, selectors?: Selector[]): Promise<Group[]>;
|
|
84
|
+
static getSecondaryGroups(options?: Options, selectors?: Selector[]): Promise<Group[]>;
|
|
85
|
+
}
|
package/dist/Group.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Entity } from '@nymphjs/client';
|
|
2
|
+
export class Group extends Entity {
|
|
3
|
+
// The name of the server class
|
|
4
|
+
static class = 'Group';
|
|
5
|
+
static async factoryGroupname(groupname) {
|
|
6
|
+
const entity = new this();
|
|
7
|
+
if (groupname != null) {
|
|
8
|
+
const entity = await this.nymph.getEntity({
|
|
9
|
+
class: this,
|
|
10
|
+
}, {
|
|
11
|
+
type: '&',
|
|
12
|
+
ilike: ['groupname', groupname.replace(/([\\%_])/g, (s) => `\\${s}`)],
|
|
13
|
+
});
|
|
14
|
+
if (entity != null) {
|
|
15
|
+
return entity;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return entity;
|
|
19
|
+
}
|
|
20
|
+
constructor() {
|
|
21
|
+
super();
|
|
22
|
+
this.enabled = true;
|
|
23
|
+
this.abilities = [];
|
|
24
|
+
this.$markClean();
|
|
25
|
+
}
|
|
26
|
+
async $checkGroupname() {
|
|
27
|
+
return await this.$serverCall('$checkGroupname', [], {
|
|
28
|
+
pushState: true,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
async $checkEmail() {
|
|
32
|
+
return await this.$serverCall('$checkEmail', [], {
|
|
33
|
+
pushState: true,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async $getAvatar() {
|
|
37
|
+
return await this.$serverCall('$getAvatar', [], {
|
|
38
|
+
pushState: true,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
async $getChildren(limit, offset, reverse, sort) {
|
|
42
|
+
return await this.$serverCall('$getChildren', [
|
|
43
|
+
limit,
|
|
44
|
+
offset,
|
|
45
|
+
reverse,
|
|
46
|
+
sort,
|
|
47
|
+
]);
|
|
48
|
+
}
|
|
49
|
+
async $getDescendants(andSelf = false) {
|
|
50
|
+
return await this.$serverCall('$getDescendants', [andSelf]);
|
|
51
|
+
}
|
|
52
|
+
async $getLevel() {
|
|
53
|
+
return await this.$serverCall('$getLevel', []);
|
|
54
|
+
}
|
|
55
|
+
async $isDescendant(givenGroup) {
|
|
56
|
+
return await this.$serverCall('$isDescendant', [givenGroup]);
|
|
57
|
+
}
|
|
58
|
+
async $getUsers(descendants = false, limit, offset, reverse, sort, enabled) {
|
|
59
|
+
return await this.$serverCall('$getUsers', [
|
|
60
|
+
descendants,
|
|
61
|
+
limit,
|
|
62
|
+
offset,
|
|
63
|
+
reverse,
|
|
64
|
+
sort,
|
|
65
|
+
enabled,
|
|
66
|
+
]);
|
|
67
|
+
}
|
|
68
|
+
static async getPrimaryGroups(options, selectors) {
|
|
69
|
+
return await this.serverCallStatic('getPrimaryGroups', [
|
|
70
|
+
{ ...options, class: this.class },
|
|
71
|
+
selectors,
|
|
72
|
+
]);
|
|
73
|
+
}
|
|
74
|
+
static async getSecondaryGroups(options, selectors) {
|
|
75
|
+
return await this.serverCallStatic('getSecondaryGroups', [
|
|
76
|
+
{ ...options, class: this.class },
|
|
77
|
+
selectors,
|
|
78
|
+
]);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=Group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Group.js","sourceRoot":"","sources":["../src/Group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAqB,MAAM,iBAAiB,CAAC;AA+D5D,MAAM,OAAO,KAAM,SAAQ,MAAiB;IAC1C,+BAA+B;IACxB,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC;IAE9B,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,SAAkB;QAC9C,MAAM,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QAC1B,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;YACtB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,SAAS,CACvC;gBACE,KAAK,EAAE,IAAI;aACZ,EACD;gBACE,IAAI,EAAE,GAAG;gBACT,KAAK,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;aACtE,CACF,CAAC;YACF,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;gBACnB,OAAO,MAAM,CAAC;YAChB,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;QACE,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACnB,IAAyB,CAAC,SAAS,GAAG,EAAE,CAAC;QAC1C,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;IAEM,KAAK,CAAC,eAAe;QAI1B,OAA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CAAC;IACL,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAClC,OAAiB,EACjB,SAAsB;QAEtB,OAAO,MAAM,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,EAAE;YACrD,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE;YACjC,SAAS;SACV,CAAC,CAAC;IACL,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,kBAAkB,CACpC,OAAiB,EACjB,SAAsB;QAEtB,OAAO,MAAM,IAAI,CAAC,gBAAgB,CAAC,oBAAoB,EAAE;YACvD,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE;YACjC,SAAS;SACV,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Entity, Options, Selector } from '@nymphjs/client';
|
|
2
|
+
import type { AdminGroupData, Group, Group as GroupClass } from './Group.js';
|
|
3
|
+
import type { AdminUserData, User } from './User.js';
|
|
4
|
+
import { AccessControlData } from './Tilmeld.types.js';
|
|
5
|
+
export type RawLDAPBinaryData = {
|
|
6
|
+
base64: string;
|
|
7
|
+
};
|
|
8
|
+
export type RawLDAPEntry = {
|
|
9
|
+
dn: string;
|
|
10
|
+
[index: string]: RawLDAPBinaryData | RawLDAPBinaryData[] | string[] | string;
|
|
11
|
+
};
|
|
12
|
+
export type RawLDAPSearchResult = RawLDAPEntry[];
|
|
13
|
+
export interface LDAPSourceData extends AccessControlData {
|
|
14
|
+
/**
|
|
15
|
+
* The host of the server.
|
|
16
|
+
*/
|
|
17
|
+
host: string;
|
|
18
|
+
/**
|
|
19
|
+
* The port on the server. Default is 389 for plain/StartTLS, 636 for LDAPS.
|
|
20
|
+
*/
|
|
21
|
+
port?: number;
|
|
22
|
+
/**
|
|
23
|
+
* The encryption type.
|
|
24
|
+
*/
|
|
25
|
+
encryption: 'none' | 'starttls' | 'ldaps';
|
|
26
|
+
/**
|
|
27
|
+
* Whether to ignore SSL certificate errors.
|
|
28
|
+
*
|
|
29
|
+
* This is not secure, and should not be used in production environments.
|
|
30
|
+
*/
|
|
31
|
+
ignoreCertificateErrors: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* The Distinguished Name or User Principal Name of a service account.
|
|
34
|
+
*
|
|
35
|
+
* This account will be used to search the directory. Leave empty for
|
|
36
|
+
* anonymous bind.
|
|
37
|
+
*/
|
|
38
|
+
bindUsername: string;
|
|
39
|
+
/**
|
|
40
|
+
* The password for the bind account.
|
|
41
|
+
*/
|
|
42
|
+
bindPassword: string;
|
|
43
|
+
/**
|
|
44
|
+
* The base Distinguished Name used to search for user entries.
|
|
45
|
+
*/
|
|
46
|
+
searchBase: string;
|
|
47
|
+
/**
|
|
48
|
+
* The LDAP search filter used to find all users.
|
|
49
|
+
*
|
|
50
|
+
* Use `(objectClass=organizationalPerson)` for most directories.
|
|
51
|
+
*/
|
|
52
|
+
userFilter: string;
|
|
53
|
+
/**
|
|
54
|
+
* The LDAP search filter used to find the user.
|
|
55
|
+
*
|
|
56
|
+
* Use `{0}` as a placeholder for the username.
|
|
57
|
+
*
|
|
58
|
+
* Use `(sAMAccountName={0})` for Active Directory. Use `(uid={0})` for
|
|
59
|
+
* OpenLDAP. Use `(userPrincipalName={0})` if usernames in the directory are
|
|
60
|
+
* stored under the "userPrincipalName" attribute.
|
|
61
|
+
*/
|
|
62
|
+
userSearchFilter: string;
|
|
63
|
+
/**
|
|
64
|
+
* The user attribute listing group memberships.
|
|
65
|
+
*
|
|
66
|
+
* Use `memberOf` for Active Directory.
|
|
67
|
+
*/
|
|
68
|
+
groupAttributeOnUser?: string;
|
|
69
|
+
/**
|
|
70
|
+
* The group attribute listing member users.
|
|
71
|
+
*
|
|
72
|
+
* Use `uniqueMember` for LDAP. Empty for Active Directory.
|
|
73
|
+
*/
|
|
74
|
+
groupAttributeOnGroup?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Restrict user registration only to users belonging to a mapped group.
|
|
77
|
+
*
|
|
78
|
+
* If you set this to true and don't map any groups, no users will be able to
|
|
79
|
+
* register an account through this LDAP source.
|
|
80
|
+
*/
|
|
81
|
+
restrictRegistrationToMappedUsers: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* A map of remote groups to their local group equivalents.
|
|
84
|
+
*
|
|
85
|
+
* An LDAP user's group membership in these groups will be synced every time
|
|
86
|
+
* they log in.
|
|
87
|
+
*/
|
|
88
|
+
groupMap: {
|
|
89
|
+
remoteDN: string;
|
|
90
|
+
localGroup: GroupClass & AdminGroupData;
|
|
91
|
+
}[];
|
|
92
|
+
/**
|
|
93
|
+
* The mapping of attributes from Nymph to LDAP.
|
|
94
|
+
*
|
|
95
|
+
* The only required attribute is username.
|
|
96
|
+
*/
|
|
97
|
+
attributeMap: {
|
|
98
|
+
nameFirst?: string;
|
|
99
|
+
nameMiddle?: string;
|
|
100
|
+
nameLast?: string;
|
|
101
|
+
name?: string;
|
|
102
|
+
phone?: string;
|
|
103
|
+
email?: string;
|
|
104
|
+
username: string;
|
|
105
|
+
avatar?: string;
|
|
106
|
+
enabled?: string;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Whether users from this LDAP Source are synced and enabled.
|
|
110
|
+
*/
|
|
111
|
+
enabled: boolean;
|
|
112
|
+
}
|
|
113
|
+
export interface LDAPSource extends LDAPSourceData {
|
|
114
|
+
}
|
|
115
|
+
export declare class LDAPSource extends Entity<LDAPSourceData> {
|
|
116
|
+
static class: string;
|
|
117
|
+
constructor();
|
|
118
|
+
$fillWithTestServer(source: 'forumsys' | 'freeipa'): void;
|
|
119
|
+
$testBind(): Promise<void>;
|
|
120
|
+
$testList(): Promise<RawLDAPSearchResult>;
|
|
121
|
+
$testMapping(username: string): Promise<(User & AdminUserData) | null>;
|
|
122
|
+
$testSearch(username: string): Promise<RawLDAPEntry | null>;
|
|
123
|
+
$getUsers(limit?: number, offset?: number, reverse?: boolean, sort?: string, enabled?: boolean): Promise<{
|
|
124
|
+
entities: User[];
|
|
125
|
+
count: number;
|
|
126
|
+
}>;
|
|
127
|
+
static getMappableGroups(options?: Options, selectors?: Selector[]): Promise<Group[]>;
|
|
128
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { Entity } from '@nymphjs/client';
|
|
2
|
+
export class LDAPSource extends Entity {
|
|
3
|
+
// The name of the server class
|
|
4
|
+
static class = 'LDAPSource';
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
// Defaults.
|
|
8
|
+
this.host = '';
|
|
9
|
+
this.encryption = 'starttls';
|
|
10
|
+
this.ignoreCertificateErrors = false;
|
|
11
|
+
this.bindUsername = '';
|
|
12
|
+
this.bindPassword = '';
|
|
13
|
+
this.searchBase = 'DC=example,DC=com';
|
|
14
|
+
this.userFilter = '(objectClass=organizationalPerson)';
|
|
15
|
+
this.userSearchFilter = '(sAMAccountName={0})';
|
|
16
|
+
this.groupAttributeOnUser = 'memberOf';
|
|
17
|
+
this.restrictRegistrationToMappedUsers = false;
|
|
18
|
+
this.groupMap = [];
|
|
19
|
+
this.attributeMap = {
|
|
20
|
+
nameFirst: 'givenName',
|
|
21
|
+
nameMiddle: 'initials',
|
|
22
|
+
nameLast: 'sn',
|
|
23
|
+
name: 'displayName',
|
|
24
|
+
phone: 'telephoneNumber',
|
|
25
|
+
email: 'mail',
|
|
26
|
+
username: 'sAMAccountName',
|
|
27
|
+
// AD stores this as a bitmask. We store it as a boolean.
|
|
28
|
+
// 512 = normal user
|
|
29
|
+
// 2 = disabled
|
|
30
|
+
enabled: '(userAccountControl & 512) == 512 && (userAccountControl & 2) == 0',
|
|
31
|
+
};
|
|
32
|
+
this.enabled = true;
|
|
33
|
+
}
|
|
34
|
+
$fillWithTestServer(source) {
|
|
35
|
+
if (source === 'forumsys') {
|
|
36
|
+
this.host = 'ldap.forumsys.com';
|
|
37
|
+
this.bindUsername = 'cn=read-only-admin,dc=example,dc=com';
|
|
38
|
+
this.bindPassword = 'password';
|
|
39
|
+
this.searchBase = 'dc=example,dc=com';
|
|
40
|
+
this.userFilter = '(objectClass=organizationalPerson)';
|
|
41
|
+
this.userSearchFilter = '(uid={0})';
|
|
42
|
+
this.groupAttributeOnUser = '';
|
|
43
|
+
this.groupAttributeOnGroup = 'uniqueMember';
|
|
44
|
+
this.attributeMap = {
|
|
45
|
+
nameFirst: '',
|
|
46
|
+
nameMiddle: '',
|
|
47
|
+
nameLast: 'sn',
|
|
48
|
+
name: 'cn',
|
|
49
|
+
phone: 'telephoneNumber',
|
|
50
|
+
email: 'mail',
|
|
51
|
+
username: 'uid',
|
|
52
|
+
avatar: '',
|
|
53
|
+
enabled: 'true',
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
this.host = 'ipa.demo1.freeipa.org';
|
|
58
|
+
this.bindUsername =
|
|
59
|
+
'uid=admin,cn=users,cn=accounts,dc=demo1,dc=freeipa,dc=org';
|
|
60
|
+
this.bindPassword = 'Secret123';
|
|
61
|
+
this.searchBase = 'cn=users,cn=accounts,dc=demo1,dc=freeipa,dc=org';
|
|
62
|
+
this.userFilter = '(objectClass=inetuser)';
|
|
63
|
+
this.userSearchFilter = '(uid={0})';
|
|
64
|
+
this.groupAttributeOnUser = 'memberOf';
|
|
65
|
+
this.groupAttributeOnGroup = '';
|
|
66
|
+
this.attributeMap = {
|
|
67
|
+
nameFirst: 'givenName',
|
|
68
|
+
nameMiddle: '',
|
|
69
|
+
nameLast: 'sn',
|
|
70
|
+
name: 'cn',
|
|
71
|
+
phone: '',
|
|
72
|
+
email: 'mail || uid+"@demo1.freeipa.org"',
|
|
73
|
+
username: 'uid',
|
|
74
|
+
avatar: '',
|
|
75
|
+
enabled: 'objectClass =~ /(^|,)posixaccount(,|$)/',
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
this.port = 389;
|
|
79
|
+
this.encryption = 'none';
|
|
80
|
+
this.ignoreCertificateErrors = false;
|
|
81
|
+
this.restrictRegistrationToMappedUsers = false;
|
|
82
|
+
this.groupMap = [];
|
|
83
|
+
this.enabled = true;
|
|
84
|
+
}
|
|
85
|
+
async $testBind() {
|
|
86
|
+
return await this.$serverCall('$testBind', [], {
|
|
87
|
+
pushState: true,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
async $testList() {
|
|
91
|
+
return await this.$serverCall('$testList', [], {
|
|
92
|
+
pushState: true,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
async $testMapping(username) {
|
|
96
|
+
return await this.$serverCall('$testMapping', [username], {
|
|
97
|
+
pushState: true,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
async $testSearch(username) {
|
|
101
|
+
return await this.$serverCall('$testSearch', [username], {
|
|
102
|
+
pushState: true,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
async $getUsers(limit, offset, reverse, sort, enabled) {
|
|
106
|
+
return await this.$serverCall('$getUsers', [
|
|
107
|
+
limit,
|
|
108
|
+
offset,
|
|
109
|
+
reverse,
|
|
110
|
+
sort,
|
|
111
|
+
enabled,
|
|
112
|
+
]);
|
|
113
|
+
}
|
|
114
|
+
static async getMappableGroups(options, selectors) {
|
|
115
|
+
return await this.serverCallStatic('getMappableGroups', [
|
|
116
|
+
{ ...options, class: this.class },
|
|
117
|
+
selectors,
|
|
118
|
+
]);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=LDAPSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LDAPSource.js","sourceRoot":"","sources":["../src/LDAPSource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAqB,MAAM,iBAAiB,CAAC;AAsH5D,MAAM,OAAO,UAAW,SAAQ,MAAsB;IACpD,+BAA+B;IACxB,MAAM,CAAC,KAAK,GAAG,YAAY,CAAC;IAEnC;QACE,KAAK,EAAE,CAAC;QAER,YAAY;QACZ,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC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CAAC,WAAW,EAAE,EAAE,EAAE;YAC7C,SAAS,EAAE,IAAI;SAChB,CAAC,CAAC;IACL,CAAC;IAEM,KAAK,CAAC,SAAS;QACpB,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,EAAE,EAAE;YAC7C,SAAS,EAAE,IAAI;SAChB,CAAC,CAAC;IACL,CAAC;IAEM,KAAK,CAAC,YAAY,CACvB,QAAgB;QAEhB,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE,CAAC,QAAQ,CAAC,EAAE;YACxD,SAAS,EAAE,IAAI;SAChB,CAAC,CAAC;IACL,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,QAAgB;QACvC,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,aAAa,EAAE,CAAC,QAAQ,CAAC,EAAE;YACvD,SAAS,EAAE,IAAI;SAChB,CAAC,CAAC;IACL,CAAC;IAEM,KAAK,CAAC,SAAS,CACpB,KAAc,EACd,MAAe,EACf,OAAiB,EACjB,IAAa,EACb,OAAiB;QAEjB,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE;YACzC,KAAK;YACL,MAAM;YACN,OAAO;YACP,IAAI;YACJ,OAAO;SACR,CAAC,CAAC;IACL,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,iBAAiB,CACnC,OAAiB,EACjB,SAAsB;QAEtB,OAAO,MAAM,IAAI,CAAC,gBAAgB,CAAC,mBAAmB,EAAE;YACtD,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE;YACjC,SAAS;SACV,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Group } from './Group.js';
|
|
2
|
+
import { User } from './User.js';
|
|
3
|
+
export interface AccessControlData {
|
|
4
|
+
user?: User;
|
|
5
|
+
group?: Group;
|
|
6
|
+
acUser?: number;
|
|
7
|
+
acGroup?: number;
|
|
8
|
+
acOther?: number;
|
|
9
|
+
acFull?: string[];
|
|
10
|
+
acWrite?: string[];
|
|
11
|
+
acRead?: string[];
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tilmeld.types.js","sourceRoot":"","sources":["../src/Tilmeld.types.ts"],"names":[],"mappings":""}
|
package/{lib → dist}/User.d.ts
RENAMED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Nymph, Entity } from '@nymphjs/client';
|
|
2
|
-
import type Group from './Group';
|
|
3
|
-
import
|
|
2
|
+
import type { Group, AdminGroupData, CurrentGroupData } from './Group.js';
|
|
3
|
+
import { LDAPSource } from './LDAPSource.js';
|
|
4
4
|
export type EventType = 'register' | 'login' | 'logout';
|
|
5
5
|
export type RegisterCallback = (user: User & CurrentUserData) => void;
|
|
6
6
|
export type LoginCallback = (user: User & CurrentUserData) => void;
|
|
7
|
-
export type LogoutCallback = (user: User
|
|
7
|
+
export type LogoutCallback = (user: User) => void;
|
|
8
8
|
export type ClientConfig = {
|
|
9
9
|
regFields: string[];
|
|
10
10
|
userFields: string[];
|
|
@@ -15,36 +15,122 @@ export type ClientConfig = {
|
|
|
15
15
|
verifyEmail: boolean;
|
|
16
16
|
unverifiedAccess: boolean;
|
|
17
17
|
};
|
|
18
|
-
export
|
|
18
|
+
export interface UserData {
|
|
19
|
+
/**
|
|
20
|
+
* The user's username.
|
|
21
|
+
*/
|
|
19
22
|
username?: string;
|
|
23
|
+
/**
|
|
24
|
+
* The user's first name.
|
|
25
|
+
*/
|
|
20
26
|
nameFirst?: string;
|
|
27
|
+
/**
|
|
28
|
+
* The user's middle name.
|
|
29
|
+
*/
|
|
21
30
|
nameMiddle?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The user's last name.
|
|
33
|
+
*/
|
|
22
34
|
nameLast?: string;
|
|
35
|
+
/**
|
|
36
|
+
* The user's full name.
|
|
37
|
+
*/
|
|
23
38
|
name?: string;
|
|
39
|
+
/**
|
|
40
|
+
* The user's avatar URL. (Use $getAvatar() to support Gravatar.)
|
|
41
|
+
*/
|
|
24
42
|
avatar?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Whether the user can log in.
|
|
45
|
+
*/
|
|
25
46
|
enabled?: boolean;
|
|
26
|
-
}
|
|
27
|
-
export
|
|
47
|
+
}
|
|
48
|
+
export interface CurrentUserData extends UserData {
|
|
49
|
+
/**
|
|
50
|
+
* The abilities granted to the user.
|
|
51
|
+
*/
|
|
28
52
|
abilities?: string[];
|
|
53
|
+
/**
|
|
54
|
+
* The user's email address.
|
|
55
|
+
*/
|
|
29
56
|
email?: string;
|
|
57
|
+
/**
|
|
58
|
+
* The user's telephone number.
|
|
59
|
+
*/
|
|
30
60
|
phone?: string;
|
|
61
|
+
/**
|
|
62
|
+
* The user's primary group.
|
|
63
|
+
*/
|
|
31
64
|
group?: Group & CurrentGroupData;
|
|
65
|
+
/**
|
|
66
|
+
* The user's secondary groups.
|
|
67
|
+
*/
|
|
32
68
|
groups?: (Group & CurrentGroupData)[];
|
|
69
|
+
/**
|
|
70
|
+
* Whether the user should inherit the abilities of his groups.
|
|
71
|
+
*/
|
|
33
72
|
inheritAbilities?: boolean;
|
|
34
|
-
|
|
35
|
-
|
|
73
|
+
/**
|
|
74
|
+
* If the user has changed their email address, this is the new one, awaiting
|
|
75
|
+
* verification.
|
|
76
|
+
*/
|
|
77
|
+
newEmailAddress?: string;
|
|
78
|
+
}
|
|
79
|
+
export interface AdminUserData extends CurrentUserData {
|
|
80
|
+
/**
|
|
81
|
+
* The user's primary group.
|
|
82
|
+
*/
|
|
36
83
|
group?: Group & AdminGroupData;
|
|
84
|
+
/**
|
|
85
|
+
* The user's secondary groups.
|
|
86
|
+
*/
|
|
37
87
|
groups?: (Group & AdminGroupData)[];
|
|
88
|
+
/**
|
|
89
|
+
* A verification secret.
|
|
90
|
+
*/
|
|
38
91
|
secret?: string;
|
|
92
|
+
/**
|
|
93
|
+
* The timestamp of when the email address was last changed.
|
|
94
|
+
*/
|
|
39
95
|
emailChangeDate?: number;
|
|
96
|
+
/**
|
|
97
|
+
* An email change proceed secret.
|
|
98
|
+
*/
|
|
40
99
|
newEmailSecret?: string;
|
|
100
|
+
/**
|
|
101
|
+
* The new email address.
|
|
102
|
+
*/
|
|
41
103
|
newEmailAddress?: string;
|
|
104
|
+
/**
|
|
105
|
+
* An email change cancellation secret.
|
|
106
|
+
*/
|
|
42
107
|
cancelEmailSecret?: string;
|
|
108
|
+
/**
|
|
109
|
+
* The old email address.
|
|
110
|
+
*/
|
|
43
111
|
cancelEmailAddress?: string;
|
|
112
|
+
/**
|
|
113
|
+
* A recovery secret.
|
|
114
|
+
*/
|
|
44
115
|
recoverSecret?: string;
|
|
116
|
+
/**
|
|
117
|
+
* The timestamp of when the recovery secret was issued.
|
|
118
|
+
*/
|
|
45
119
|
recoverSecretDate?: number;
|
|
120
|
+
/**
|
|
121
|
+
* Used by admins to change a user's password. Not saved to the database.
|
|
122
|
+
*/
|
|
46
123
|
passwordTemp?: string;
|
|
47
|
-
|
|
124
|
+
/**
|
|
125
|
+
* If set, this timestamp is the cutoff point for JWT issue dates. Any token
|
|
126
|
+
* issued before this date will not authenticate the user.
|
|
127
|
+
*/
|
|
128
|
+
revokeTokenDate?: number;
|
|
129
|
+
/**
|
|
130
|
+
* The source of this user.
|
|
131
|
+
*/
|
|
132
|
+
source?: LDAPSource;
|
|
133
|
+
}
|
|
48
134
|
type InstanceStore = {
|
|
49
135
|
registerCallbacks: RegisterCallback[];
|
|
50
136
|
loginCallbacks: LoginCallback[];
|
|
@@ -52,15 +138,23 @@ type InstanceStore = {
|
|
|
52
138
|
clientConfig?: ClientConfig;
|
|
53
139
|
clientConfigPromise?: Promise<ClientConfig>;
|
|
54
140
|
removeNymphResponseListener?: () => void;
|
|
141
|
+
currentToken?: string;
|
|
142
|
+
switchToken?: string;
|
|
55
143
|
};
|
|
56
|
-
export
|
|
144
|
+
export interface User extends UserData {
|
|
145
|
+
}
|
|
146
|
+
export declare class User extends Entity<UserData> {
|
|
57
147
|
protected static stores: WeakMap<Nymph, InstanceStore>;
|
|
58
148
|
static class: string;
|
|
59
149
|
static init(nymph: Nymph): void;
|
|
60
|
-
|
|
61
|
-
static
|
|
62
|
-
|
|
63
|
-
|
|
150
|
+
static factoryUsername(username?: string): Promise<User>;
|
|
151
|
+
static getDomainUsers(domain: string, options?: {
|
|
152
|
+
limit?: number;
|
|
153
|
+
offset?: number;
|
|
154
|
+
sort?: string;
|
|
155
|
+
reverse?: boolean;
|
|
156
|
+
}): Promise<User[]>;
|
|
157
|
+
constructor();
|
|
64
158
|
$checkUsername(): Promise<{
|
|
65
159
|
result: boolean;
|
|
66
160
|
message: string;
|
|
@@ -84,6 +178,14 @@ export default class User extends Entity<UserData> {
|
|
|
84
178
|
loggedin: boolean;
|
|
85
179
|
message: string;
|
|
86
180
|
}>;
|
|
181
|
+
$switchUser(data?: {
|
|
182
|
+
additionalData?: {
|
|
183
|
+
[k: string]: any;
|
|
184
|
+
};
|
|
185
|
+
}): Promise<{
|
|
186
|
+
result: boolean;
|
|
187
|
+
message: string;
|
|
188
|
+
}>;
|
|
87
189
|
$logout(): Promise<{
|
|
88
190
|
result: boolean;
|
|
89
191
|
message: string;
|
|
@@ -92,6 +194,34 @@ export default class User extends Entity<UserData> {
|
|
|
92
194
|
$changePassword(data: {
|
|
93
195
|
newPassword: string;
|
|
94
196
|
currentPassword: string;
|
|
197
|
+
revokeCurrentTokens?: boolean;
|
|
198
|
+
}): Promise<{
|
|
199
|
+
result: boolean;
|
|
200
|
+
message: string;
|
|
201
|
+
}>;
|
|
202
|
+
$revokeCurrentTokens(data?: {
|
|
203
|
+
password: string;
|
|
204
|
+
}): Promise<{
|
|
205
|
+
result: boolean;
|
|
206
|
+
message: string;
|
|
207
|
+
}>;
|
|
208
|
+
$hasTOTPSecret(): Promise<boolean>;
|
|
209
|
+
$getNewTOTPSecret(): Promise<{
|
|
210
|
+
uri: string;
|
|
211
|
+
qrcode: string;
|
|
212
|
+
secret: string;
|
|
213
|
+
}>;
|
|
214
|
+
$saveTOTPSecret(data: {
|
|
215
|
+
password: string;
|
|
216
|
+
secret: string;
|
|
217
|
+
code: string;
|
|
218
|
+
}): Promise<{
|
|
219
|
+
result: boolean;
|
|
220
|
+
message: string;
|
|
221
|
+
}>;
|
|
222
|
+
$removeTOTPSecret(data?: {
|
|
223
|
+
password: string;
|
|
224
|
+
code: string;
|
|
95
225
|
}): Promise<{
|
|
96
226
|
result: boolean;
|
|
97
227
|
message: string;
|
|
@@ -101,12 +231,14 @@ export default class User extends Entity<UserData> {
|
|
|
101
231
|
static loginUser(data: {
|
|
102
232
|
username: string;
|
|
103
233
|
password: string;
|
|
234
|
+
code?: string;
|
|
104
235
|
additionalData?: {
|
|
105
236
|
[k: string]: any;
|
|
106
237
|
};
|
|
107
238
|
}): Promise<{
|
|
108
239
|
result: boolean;
|
|
109
240
|
message: string;
|
|
241
|
+
needTOTP?: true;
|
|
110
242
|
user?: User & CurrentUserData;
|
|
111
243
|
}>;
|
|
112
244
|
static sendRecovery(data: {
|