@forgerock/login-widget 1.2.0-beta.4 → 1.2.0-beta.5

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 CHANGED
@@ -1,3 +1,10 @@
1
+ # [1.2.0-beta.5](https://github.com/forgerock/forgerock-web-login-framework/compare/v1.2.0-beta.4...v1.2.0-beta.5) (2023-10-10)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **zod:** improve the use of zod for configuration strictness ([25c330b](https://github.com/forgerock/forgerock-web-login-framework/commit/25c330b17a3289cccf8dd459f0ae71a05fd3f32a))
7
+
1
8
  # [1.2.0-beta.4](https://github.com/forgerock/forgerock-web-login-framework/compare/v1.2.0-beta.3...v1.2.0-beta.4) (2023-10-05)
2
9
 
3
10
 
package/index.cjs CHANGED
@@ -9089,7 +9089,8 @@ const configSchema = z
9089
9089
  realmPath: z.string(),
9090
9090
  redirectUri: z.string().optional(),
9091
9091
  scope: z.string().optional(),
9092
- serverConfig: z.object({
9092
+ serverConfig: z
9093
+ .object({
9093
9094
  baseUrl: z
9094
9095
  .string({
9095
9096
  invalid_type_error: '`serverConfig.baseUrl` is a required URL string (this is generated by the Zod library).',
@@ -9100,25 +9101,28 @@ const configSchema = z
9100
9101
  }),
9101
9102
  paths: z
9102
9103
  .object({
9103
- authenticate: z.string(),
9104
- authorize: z.string(),
9105
- accessToken: z.string(),
9106
- endSession: z.string(),
9107
- userInfo: z.string(),
9108
- revoke: z.string(),
9109
- sessions: z.string(),
9104
+ authenticate: z.string().optional(),
9105
+ authorize: z.string().optional(),
9106
+ accessToken: z.string().optional(),
9107
+ endSession: z.string().optional(),
9108
+ userInfo: z.string().optional(),
9109
+ revoke: z.string().optional(),
9110
+ sessions: z.string().optional(),
9110
9111
  })
9112
+ .strict()
9111
9113
  .optional(),
9112
- // TODO: timeout should be optional; fix in SDK
9113
- timeout: z.number({
9114
+ timeout: z
9115
+ .number({
9114
9116
  invalid_type_error: '`serverConfig.timeout` is a required number and in milliseconds (this is generated by the Zod library).',
9115
- required_error: 'Setting the `serverConfig.timeout` is required (this is generated by the Zod library).',
9116
- }),
9117
- }),
9117
+ })
9118
+ .optional(),
9119
+ })
9120
+ .strict(),
9118
9121
  support: z.union([z.literal('legacy'), z.literal('modern')]).optional(),
9119
9122
  tokenStore: z
9120
9123
  .union([
9121
- z.object({
9124
+ z
9125
+ .object({
9122
9126
  get: z
9123
9127
  .function()
9124
9128
  .args(z.string())
@@ -9130,7 +9134,8 @@ const configSchema = z
9130
9134
  }))),
9131
9135
  set: z.function().args(z.string()).returns(z.promise(z.void())),
9132
9136
  remove: z.function().args(z.string()).returns(z.promise(z.void())),
9133
- }),
9137
+ })
9138
+ .strict(),
9134
9139
  z.literal('sessionStorage'),
9135
9140
  z.literal('localStorage'),
9136
9141
  ])
@@ -12072,7 +12077,9 @@ function initialize$3(customLinks) {
12072
12077
  return linksStore;
12073
12078
  }
12074
12079
 
12080
+ const authorizationTimedOut = 'Authorization timed out';
12075
12081
  const interactionNeeded = 'The request requires some interaction that is not allowed.';
12082
+ const timeoutErrorMessage = 'Timeouts are likely an issue with OAuth client misconfiguration. If you are getting a 4xx error in the network tab, copy the full `/authorize` URL and paste it directly into your browsers URL field to directly visit the page. The error should be displayed on the page.';
12076
12083
  const sessionCookieConsentMessage = `The user either doesn't have a valid session, the cookie is not being sent due to third-party cookies being disabled, or the user is needing to provide consent as the OAuth client setting does not have "implied consent" enabled.`;
12077
12084
  const oauthStore = writable({
12078
12085
  completed: false,
@@ -12081,6 +12088,16 @@ const oauthStore = writable({
12081
12088
  successful: false,
12082
12089
  response: null,
12083
12090
  });
12091
+ function getTroubleshootingMessage(message) {
12092
+ switch (message) {
12093
+ case interactionNeeded:
12094
+ return sessionCookieConsentMessage;
12095
+ case authorizationTimedOut:
12096
+ return timeoutErrorMessage;
12097
+ default:
12098
+ return '';
12099
+ }
12100
+ }
12084
12101
  /**
12085
12102
  * @function initialize - Initializes the OAuth store with a get function and a reset function
12086
12103
  * @param {object} initOptions - The options to pass to the TokenManager.getTokens function
@@ -12121,7 +12138,7 @@ function initialize$2(initOptions) {
12121
12138
  completed: true,
12122
12139
  error: {
12123
12140
  message: err.message,
12124
- troubleshoot: err.message === interactionNeeded ? sessionCookieConsentMessage : '',
12141
+ troubleshoot: getTroubleshootingMessage(err.message),
12125
12142
  },
12126
12143
  loading: false,
12127
12144
  successful: false,
@@ -12247,11 +12264,13 @@ const styleSchema = z
12247
12264
  .object({
12248
12265
  header: z.boolean().optional(),
12249
12266
  })
12267
+ .strict()
12250
12268
  .optional(),
12251
12269
  stage: z
12252
12270
  .object({
12253
12271
  icon: z.boolean().optional(),
12254
12272
  })
12273
+ .strict()
12255
12274
  .optional(),
12256
12275
  })
12257
12276
  .strict();