2 Commits

Author SHA1 Message Date
19a4c9ef48 1.0.6 2024-05-03 10:39:25 +02:00
02a01ca35c fix(core): update 2024-05-03 10:39:24 +02:00
3 changed files with 42 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@apiclient.xyz/zitadel",
"version": "1.0.5",
"version": "1.0.6",
"private": false,
"description": "An unofficial client for interacting with Zitadel API.",
"main": "dist_ts/index.js",

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@apiclient.xyz/zitadel',
version: '1.0.5',
version: '1.0.6',
description: 'An unofficial client for interacting with Zitadel API.'
}

View File

@ -6,7 +6,7 @@ export interface IZitadelUserData {
id: string;
lastLogin: Date;
username: string;
};
}
export class ZitaldelUser {
// INSTANCE
@ -19,11 +19,49 @@ export class ZitaldelUser {
}
public async addRole(projectRole: ZitadelProjectRole) {
this.zitadelclientRef.managementClient.addUserGrant({
const response = await this.zitadelclientRef.managementClient.addUserGrant({
userId: this.data.id,
roleKeys: [projectRole.data.key],
projectId: projectRole.data.project.data.id,
});
}
/**
* change email address of user,
* optionally supply own url for email verification
* @param emailAddress
* @param verificationUrl
*/
public async changeEmail(optionsArg: { emailAddress: string; verificationUrl?: string }) {
const response = await this.zitadelclientRef.userClient.setEmail({
userId: this.data.id,
email: optionsArg.emailAddress,
...(optionsArg.verificationUrl
? {
sendCode: {
urlTemplate: optionsArg.verificationUrl,
},
}
: {}),
});
}
public async setPassword(optionsArg: { password: string; changeRequired?: boolean }) {
const response = await this.zitadelclientRef.userClient.setPassword({
userId: this.data.id,
newPassword: {
password: optionsArg.password,
...(optionsArg.changeRequired ? { changeRequired: optionsArg.changeRequired } : {}),
},
});
}
/**
* triggers a password reset action for the user
*/
public async resetPassword() {
const response = await this.zitadelclientRef.userClient.passwordReset({
userId: this.data.id,
});
}
}