@malevich-studio/strapi-sdk-typescript 1.2.3 → 1.2.4

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/dist/cli.cjs CHANGED
@@ -20122,6 +20122,9 @@ class Strapi {
20122
20122
  setToken(token) {
20123
20123
  this.token = token;
20124
20124
  }
20125
+ getToken() {
20126
+ return this.token;
20127
+ }
20125
20128
  async baseLogin(identifier, password) {
20126
20129
  const response = await this.fetchData('/auth/local', {
20127
20130
  identifier,
@@ -20129,8 +20132,55 @@ class Strapi {
20129
20132
  }, {
20130
20133
  method: 'POST',
20131
20134
  });
20132
- this.setToken(response.jwt);
20133
- return response.user;
20135
+ if (!response.error) {
20136
+ this.setToken(response.jwt);
20137
+ }
20138
+ return response;
20139
+ }
20140
+ async baseRegister(data) {
20141
+ const response = await this.fetchData('/auth/local/register', data, {
20142
+ method: 'POST',
20143
+ });
20144
+ if (!response.error) {
20145
+ this.setToken(response.jwt);
20146
+ }
20147
+ return response;
20148
+ }
20149
+ async forgotPassword(email) {
20150
+ return await this.fetchData('/auth/forgot-password', { email }, {
20151
+ method: 'POST',
20152
+ });
20153
+ }
20154
+ async sendEmailConfirmation(email) {
20155
+ return await this.fetchData('/auth/send-email-confirmation', { email }, {
20156
+ method: 'POST',
20157
+ });
20158
+ }
20159
+ async baseResetPassword(password, code) {
20160
+ const response = await this.fetchData('/auth/reset-password', {
20161
+ password,
20162
+ passwordConfirmation: password,
20163
+ code,
20164
+ }, {
20165
+ method: 'POST',
20166
+ });
20167
+ if (!response.error) {
20168
+ this.setToken(response.jwt);
20169
+ }
20170
+ return response;
20171
+ }
20172
+ async baseChangePassword(password, currentPassword) {
20173
+ const response = await this.fetchData('/auth/change-password', {
20174
+ password,
20175
+ passwordConfirmation: password,
20176
+ currentPassword,
20177
+ }, {
20178
+ method: 'POST',
20179
+ });
20180
+ if (!response.error) {
20181
+ this.setToken(response.jwt);
20182
+ }
20183
+ return response;
20134
20184
  }
20135
20185
  async getLocales(params) {
20136
20186
  return await this.baseFetch('i18n/locales', _.merge({
@@ -20751,7 +20801,19 @@ async function generateStrapiTypes(strapi) {
20751
20801
  ` public async login(identifier: string, password: string) {`,
20752
20802
  ` return await this.baseLogin<User>(identifier, password);`,
20753
20803
  ' }',
20754
- '',
20804
+ ' ',
20805
+ ` public async register(data: UserInput) {`,
20806
+ ` return await this.baseRegister<User, UserInput>(data);`,
20807
+ ' }',
20808
+ ' ',
20809
+ ` public async resetPassword(password: string, code: string) {`,
20810
+ ` return await this.baseResetPassword<User>(password, code);`,
20811
+ ' }',
20812
+ ' ',
20813
+ ` public async changePassword(password: string, currentPassword: string) {`,
20814
+ ` return await this.baseChangePassword<User>(password, currentPassword);`,
20815
+ ' }',
20816
+ ' ',
20755
20817
  methods.join('\n\n'),
20756
20818
  '}',
20757
20819
  '',