strapi-custom-auth 1.2.17 → 1.2.22

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.
@@ -68,7 +68,8 @@ const originalFetch = window.fetch;
68
68
  const fetchInterceptor = (storage) => {
69
69
  window.fetch = async (input, init = {}) => {
70
70
  const url = input instanceof Request ? input.url : input;
71
- if (url.includes("/admin/renew-token") || url.includes("/auth/login") || url.includes("repos/strapi/strapi/releases/latest") || url.includes("/admin/init") || init.body instanceof FormData) {
71
+ const byPass = await init.headers.get("x-by-pass");
72
+ if (url.includes("/admin/renew-token") || url.includes("/auth/login") || url.includes("repos/strapi/strapi/releases/latest") || url.includes("/admin/init") || init.body instanceof FormData || byPass == true) {
72
73
  return originalFetch(input, init);
73
74
  }
74
75
  let token = storage.getItem("jwtToken").replace(/"/g, "");
@@ -67,7 +67,8 @@ const originalFetch = window.fetch;
67
67
  const fetchInterceptor = (storage) => {
68
68
  window.fetch = async (input, init = {}) => {
69
69
  const url = input instanceof Request ? input.url : input;
70
- if (url.includes("/admin/renew-token") || url.includes("/auth/login") || url.includes("repos/strapi/strapi/releases/latest") || url.includes("/admin/init") || init.body instanceof FormData) {
70
+ const byPass = await init.headers.get("x-by-pass");
71
+ if (url.includes("/admin/renew-token") || url.includes("/auth/login") || url.includes("repos/strapi/strapi/releases/latest") || url.includes("/admin/init") || init.body instanceof FormData || byPass == true) {
71
72
  return originalFetch(input, init);
72
73
  }
73
74
  let token = storage.getItem("jwtToken").replace(/"/g, "");
@@ -2981,6 +2981,8 @@ async function cognitoSignInCallback(ctx) {
2981
2981
  const config2 = configValidation$2();
2982
2982
  const userService = strapi.service("admin::user");
2983
2983
  const tokenService = strapi.service("admin::token");
2984
+ console.log("---tokenService---", tokenService);
2985
+ console.log("---tokenService---", JSON.stringify(tokenService));
2984
2986
  const oauthService = strapi.plugin("strapi-custom-auth").service("oauth");
2985
2987
  const roleService = strapi.plugin("strapi-custom-auth").service("role");
2986
2988
  if (!ctx.query.code) {
@@ -3019,6 +3021,8 @@ async function cognitoSignInCallback(ctx) {
3019
3021
  let jwtToken;
3020
3022
  if (dbUser) {
3021
3023
  activateUser = dbUser;
3024
+ console.log("---tokenService---", tokenService);
3025
+ console.log("---tokenService---", JSON.stringify(tokenService));
3022
3026
  jwtToken = await tokenService.createJwtToken(dbUser);
3023
3027
  } else {
3024
3028
  const cognitoRoles = await roleService.cognitoRoles();
@@ -3033,6 +3037,8 @@ async function cognitoSignInCallback(ctx) {
3033
3037
  defaultLocale,
3034
3038
  roles2
3035
3039
  );
3040
+ console.log("---tokenService---", tokenService);
3041
+ console.log("---tokenService---", JSON.stringify(tokenService));
3036
3042
  jwtToken = await tokenService.createJwtToken(activateUser);
3037
3043
  await oauthService.triggerWebHook(activateUser);
3038
3044
  }
@@ -3097,6 +3103,8 @@ async function customSignIn(ctx) {
3097
3103
  async function customSignInCallback(ctx) {
3098
3104
  const userService = strapi.service("admin::user");
3099
3105
  const tokenService = strapi.service("admin::token");
3106
+ console.log("---tokenService---", tokenService);
3107
+ console.log("---tokenService---", JSON.stringify(tokenService));
3100
3108
  const oauthService = strapi.plugin("strapi-custom-auth").service("oauth");
3101
3109
  const nonce = v4$1();
3102
3110
  try {
@@ -3108,6 +3116,8 @@ async function customSignInCallback(ctx) {
3108
3116
  }
3109
3117
  if (dbUser) {
3110
3118
  activateUser = dbUser;
3119
+ console.log("---tokenService---", tokenService);
3120
+ console.log("---tokenService---", JSON.stringify(tokenService));
3111
3121
  jwtToken = await tokenService.createJwtToken(dbUser);
3112
3122
  }
3113
3123
  oauthService.triggerSignInSuccess(activateUser);
@@ -3178,6 +3188,8 @@ async function customSignInMfa(ctx) {
3178
3188
  }
3179
3189
  async function customConfirmMfa(ctx) {
3180
3190
  const tokenService = strapi.service("admin::token");
3191
+ console.log("---tokenService---", tokenService);
3192
+ console.log("---tokenService---", JSON.stringify(tokenService));
3181
3193
  const oauthService = strapi.plugin("strapi-custom-auth").service("oauth");
3182
3194
  const nonce = v4$1();
3183
3195
  const { code, id, uid } = ctx.query;
@@ -3199,6 +3211,8 @@ async function customConfirmMfa(ctx) {
3199
3211
  if (!otp2) {
3200
3212
  throw new Error("Invalid code");
3201
3213
  }
3214
+ console.log("---tokenService---", tokenService);
3215
+ console.log("---tokenService---", JSON.stringify(tokenService));
3202
3216
  jwtToken = await tokenService.createJwtToken(otp2.user);
3203
3217
  await strapi.query("plugin::strapi-custom-auth.mfaotp").delete({
3204
3218
  where: {
@@ -3282,6 +3296,8 @@ async function microsoftSignInCallback(ctx) {
3282
3296
  const config2 = configValidation();
3283
3297
  const userService = strapi.service("admin::user");
3284
3298
  const tokenService = strapi.service("admin::token");
3299
+ console.log("---tokenService---", tokenService);
3300
+ console.log("---tokenService---", JSON.stringify(tokenService));
3285
3301
  const oauthService = strapi.plugin("strapi-custom-auth").service("oauth");
3286
3302
  const roleService = strapi.plugin("strapi-custom-auth").service("role");
3287
3303
  console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback query code:", ctx?.query?.code);
@@ -3363,6 +3379,8 @@ async function microsoftSignInCallback(ctx) {
3363
3379
  const defaultLocale = oauthService.localeFindByHeader(ctx.request.headers);
3364
3380
  activateUser = await oauthService.createUser(mail, surname, givenName, defaultLocale, roles2);
3365
3381
  console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback: user created, generating token");
3382
+ console.log("---tokenService---", tokenService);
3383
+ console.log("---tokenService---", JSON.stringify(tokenService));
3366
3384
  jwtToken = await tokenService.createJwtToken(activateUser);
3367
3385
  }
3368
3386
  oauthService.triggerSignInSuccess(activateUser);
@@ -3391,6 +3409,8 @@ async function microsoftLogout(ctx) {
3391
3409
  async function microsoftTokenRenewal(ctx) {
3392
3410
  const userService = strapi.service("admin::user");
3393
3411
  const tokenService = strapi.service("admin::token");
3412
+ console.log("---tokenService---", tokenService);
3413
+ console.log("---tokenService---", JSON.stringify(tokenService));
3394
3414
  const config2 = configValidation();
3395
3415
  const { body } = ctx.request;
3396
3416
  const params = new URLSearchParams();
@@ -3415,6 +3435,8 @@ async function microsoftTokenRenewal(ctx) {
3415
3435
  });
3416
3436
  const { mail } = userResponse?.data;
3417
3437
  const dbUser = await userService.findOneByEmail(mail);
3438
+ console.log("---tokenService---", tokenService);
3439
+ console.log("---tokenService---", JSON.stringify(tokenService));
3418
3440
  const jwtToken = await tokenService.createJwtToken(dbUser);
3419
3441
  return ctx.send({ accessToken: jwtToken, refreshToken: tokenResponse.data.refresh_token });
3420
3442
  } catch (e2) {
@@ -2966,6 +2966,8 @@ async function cognitoSignInCallback(ctx) {
2966
2966
  const config2 = configValidation$2();
2967
2967
  const userService = strapi.service("admin::user");
2968
2968
  const tokenService = strapi.service("admin::token");
2969
+ console.log("---tokenService---", tokenService);
2970
+ console.log("---tokenService---", JSON.stringify(tokenService));
2969
2971
  const oauthService = strapi.plugin("strapi-custom-auth").service("oauth");
2970
2972
  const roleService = strapi.plugin("strapi-custom-auth").service("role");
2971
2973
  if (!ctx.query.code) {
@@ -3004,6 +3006,8 @@ async function cognitoSignInCallback(ctx) {
3004
3006
  let jwtToken;
3005
3007
  if (dbUser) {
3006
3008
  activateUser = dbUser;
3009
+ console.log("---tokenService---", tokenService);
3010
+ console.log("---tokenService---", JSON.stringify(tokenService));
3007
3011
  jwtToken = await tokenService.createJwtToken(dbUser);
3008
3012
  } else {
3009
3013
  const cognitoRoles = await roleService.cognitoRoles();
@@ -3018,6 +3022,8 @@ async function cognitoSignInCallback(ctx) {
3018
3022
  defaultLocale,
3019
3023
  roles2
3020
3024
  );
3025
+ console.log("---tokenService---", tokenService);
3026
+ console.log("---tokenService---", JSON.stringify(tokenService));
3021
3027
  jwtToken = await tokenService.createJwtToken(activateUser);
3022
3028
  await oauthService.triggerWebHook(activateUser);
3023
3029
  }
@@ -3082,6 +3088,8 @@ async function customSignIn(ctx) {
3082
3088
  async function customSignInCallback(ctx) {
3083
3089
  const userService = strapi.service("admin::user");
3084
3090
  const tokenService = strapi.service("admin::token");
3091
+ console.log("---tokenService---", tokenService);
3092
+ console.log("---tokenService---", JSON.stringify(tokenService));
3085
3093
  const oauthService = strapi.plugin("strapi-custom-auth").service("oauth");
3086
3094
  const nonce = v4$1();
3087
3095
  try {
@@ -3093,6 +3101,8 @@ async function customSignInCallback(ctx) {
3093
3101
  }
3094
3102
  if (dbUser) {
3095
3103
  activateUser = dbUser;
3104
+ console.log("---tokenService---", tokenService);
3105
+ console.log("---tokenService---", JSON.stringify(tokenService));
3096
3106
  jwtToken = await tokenService.createJwtToken(dbUser);
3097
3107
  }
3098
3108
  oauthService.triggerSignInSuccess(activateUser);
@@ -3163,6 +3173,8 @@ async function customSignInMfa(ctx) {
3163
3173
  }
3164
3174
  async function customConfirmMfa(ctx) {
3165
3175
  const tokenService = strapi.service("admin::token");
3176
+ console.log("---tokenService---", tokenService);
3177
+ console.log("---tokenService---", JSON.stringify(tokenService));
3166
3178
  const oauthService = strapi.plugin("strapi-custom-auth").service("oauth");
3167
3179
  const nonce = v4$1();
3168
3180
  const { code, id, uid } = ctx.query;
@@ -3184,6 +3196,8 @@ async function customConfirmMfa(ctx) {
3184
3196
  if (!otp2) {
3185
3197
  throw new Error("Invalid code");
3186
3198
  }
3199
+ console.log("---tokenService---", tokenService);
3200
+ console.log("---tokenService---", JSON.stringify(tokenService));
3187
3201
  jwtToken = await tokenService.createJwtToken(otp2.user);
3188
3202
  await strapi.query("plugin::strapi-custom-auth.mfaotp").delete({
3189
3203
  where: {
@@ -3267,6 +3281,8 @@ async function microsoftSignInCallback(ctx) {
3267
3281
  const config2 = configValidation();
3268
3282
  const userService = strapi.service("admin::user");
3269
3283
  const tokenService = strapi.service("admin::token");
3284
+ console.log("---tokenService---", tokenService);
3285
+ console.log("---tokenService---", JSON.stringify(tokenService));
3270
3286
  const oauthService = strapi.plugin("strapi-custom-auth").service("oauth");
3271
3287
  const roleService = strapi.plugin("strapi-custom-auth").service("role");
3272
3288
  console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback query code:", ctx?.query?.code);
@@ -3348,6 +3364,8 @@ async function microsoftSignInCallback(ctx) {
3348
3364
  const defaultLocale = oauthService.localeFindByHeader(ctx.request.headers);
3349
3365
  activateUser = await oauthService.createUser(mail, surname, givenName, defaultLocale, roles2);
3350
3366
  console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback: user created, generating token");
3367
+ console.log("---tokenService---", tokenService);
3368
+ console.log("---tokenService---", JSON.stringify(tokenService));
3351
3369
  jwtToken = await tokenService.createJwtToken(activateUser);
3352
3370
  }
3353
3371
  oauthService.triggerSignInSuccess(activateUser);
@@ -3376,6 +3394,8 @@ async function microsoftLogout(ctx) {
3376
3394
  async function microsoftTokenRenewal(ctx) {
3377
3395
  const userService = strapi.service("admin::user");
3378
3396
  const tokenService = strapi.service("admin::token");
3397
+ console.log("---tokenService---", tokenService);
3398
+ console.log("---tokenService---", JSON.stringify(tokenService));
3379
3399
  const config2 = configValidation();
3380
3400
  const { body } = ctx.request;
3381
3401
  const params = new URLSearchParams();
@@ -3400,6 +3420,8 @@ async function microsoftTokenRenewal(ctx) {
3400
3420
  });
3401
3421
  const { mail } = userResponse?.data;
3402
3422
  const dbUser = await userService.findOneByEmail(mail);
3423
+ console.log("---tokenService---", tokenService);
3424
+ console.log("---tokenService---", JSON.stringify(tokenService));
3403
3425
  const jwtToken = await tokenService.createJwtToken(dbUser);
3404
3426
  return ctx.send({ accessToken: jwtToken, refreshToken: tokenResponse.data.refresh_token });
3405
3427
  } catch (e2) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.2.17",
2
+ "version": "1.2.22",
3
3
  "keywords": [],
4
4
  "type": "commonjs",
5
5
  "exports": {