@crossauth/sveltekit 0.0.4 → 0.0.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/dist/index.cjs CHANGED
@@ -5412,7 +5412,8 @@ class SvelteKitSharedClientEndpoints {
5412
5412
  this.validFlows = common.OAuthFlows.allFlows();
5413
5413
  }
5414
5414
  this.valid_flowNames = common.OAuthFlows.flowNames(this.validFlows);
5415
- this.clientManager = new backend.OAuthClientManager(options);
5415
+ if (options.clientStorage)
5416
+ this.clientManager = new backend.OAuthClientManager(options);
5416
5417
  this.clientStorage = options.clientStorage;
5417
5418
  }
5418
5419
  ///////////////////////////////////////////////////////////////////
@@ -5602,7 +5603,7 @@ class SvelteKitSharedClientEndpoints {
5602
5603
  if (this.sessionServer.enableCsrfProtection && event.locals.authType == "cookie" && !event.locals.csrfToken) {
5603
5604
  throw new common.CrossauthError(common.ErrorCode.InvalidCsrf);
5604
5605
  }
5605
- const redirect_uri = !formData.redirect_uri || formData.redirect_uri.trim().length == 0 ? [] : formData.redirect_uri.trim().split(/,?[ \t\n]*/);
5606
+ const redirect_uri = !formData.redirect_uri || formData.redirect_uri.trim().length == 0 ? [] : formData.redirect_uri.trim().split(/[, ][ \t\n]*/);
5606
5607
  let redirect_uriErrors = [];
5607
5608
  for (let uri of redirect_uri) {
5608
5609
  try {
@@ -5637,6 +5638,7 @@ class SvelteKitSharedClientEndpoints {
5637
5638
  clientUpdate.userid = formData.userid ? Number(formData.userid) : null;
5638
5639
  }
5639
5640
  const resetSecret = data.getAsBoolean("resetSecret");
5641
+ if (!this.clientManager) throw new common.CrossauthError(common.ErrorCode.Configuration, "Cannot call this endpoint as you did not provide a clientStorage");
5640
5642
  const { client: newClient, newSecret } = await this.clientManager.updateClient(
5641
5643
  client_id,
5642
5644
  clientUpdate,
@@ -5744,7 +5746,7 @@ class SvelteKitSharedClientEndpoints {
5744
5746
  if (this.sessionServer.enableCsrfProtection && event.locals.authType == "cookie" && !event.locals.csrfToken) {
5745
5747
  throw new common.CrossauthError(common.ErrorCode.InvalidCsrf);
5746
5748
  }
5747
- const redirect_uri = !formData.redirect_uri || formData.redirect_uri.trim().length == 0 ? [] : formData.redirect_uri.trim().split(/,?[ \t\n]*/);
5749
+ const redirect_uri = !formData.redirect_uri || formData.redirect_uri.trim().length == 0 ? [] : formData.redirect_uri.trim().split(/[, ][ \t\n]*/);
5748
5750
  let redirect_uriErrors = [];
5749
5751
  for (let uri of redirect_uri) {
5750
5752
  try {
@@ -5773,6 +5775,7 @@ class SvelteKitSharedClientEndpoints {
5773
5775
  if (isAdmin) {
5774
5776
  clientUpdate.userid = formData.userid ? Number(formData.userid) : null;
5775
5777
  }
5778
+ if (!this.clientManager) throw new common.CrossauthError(common.ErrorCode.Configuration, "Cannot call this endpoint as you did not provide a clientStorage");
5776
5779
  const newClient = await this.clientManager.createClient(
5777
5780
  formData.client_name,
5778
5781
  redirect_uri,
package/dist/index.js CHANGED
@@ -5410,7 +5410,8 @@ class SvelteKitSharedClientEndpoints {
5410
5410
  this.validFlows = OAuthFlows.allFlows();
5411
5411
  }
5412
5412
  this.valid_flowNames = OAuthFlows.flowNames(this.validFlows);
5413
- this.clientManager = new OAuthClientManager(options);
5413
+ if (options.clientStorage)
5414
+ this.clientManager = new OAuthClientManager(options);
5414
5415
  this.clientStorage = options.clientStorage;
5415
5416
  }
5416
5417
  ///////////////////////////////////////////////////////////////////
@@ -5600,7 +5601,7 @@ class SvelteKitSharedClientEndpoints {
5600
5601
  if (this.sessionServer.enableCsrfProtection && event.locals.authType == "cookie" && !event.locals.csrfToken) {
5601
5602
  throw new CrossauthError(ErrorCode.InvalidCsrf);
5602
5603
  }
5603
- const redirect_uri = !formData.redirect_uri || formData.redirect_uri.trim().length == 0 ? [] : formData.redirect_uri.trim().split(/,?[ \t\n]*/);
5604
+ const redirect_uri = !formData.redirect_uri || formData.redirect_uri.trim().length == 0 ? [] : formData.redirect_uri.trim().split(/[, ][ \t\n]*/);
5604
5605
  let redirect_uriErrors = [];
5605
5606
  for (let uri of redirect_uri) {
5606
5607
  try {
@@ -5635,6 +5636,7 @@ class SvelteKitSharedClientEndpoints {
5635
5636
  clientUpdate.userid = formData.userid ? Number(formData.userid) : null;
5636
5637
  }
5637
5638
  const resetSecret = data.getAsBoolean("resetSecret");
5639
+ if (!this.clientManager) throw new CrossauthError(ErrorCode.Configuration, "Cannot call this endpoint as you did not provide a clientStorage");
5638
5640
  const { client: newClient, newSecret } = await this.clientManager.updateClient(
5639
5641
  client_id,
5640
5642
  clientUpdate,
@@ -5742,7 +5744,7 @@ class SvelteKitSharedClientEndpoints {
5742
5744
  if (this.sessionServer.enableCsrfProtection && event.locals.authType == "cookie" && !event.locals.csrfToken) {
5743
5745
  throw new CrossauthError(ErrorCode.InvalidCsrf);
5744
5746
  }
5745
- const redirect_uri = !formData.redirect_uri || formData.redirect_uri.trim().length == 0 ? [] : formData.redirect_uri.trim().split(/,?[ \t\n]*/);
5747
+ const redirect_uri = !formData.redirect_uri || formData.redirect_uri.trim().length == 0 ? [] : formData.redirect_uri.trim().split(/[, ][ \t\n]*/);
5746
5748
  let redirect_uriErrors = [];
5747
5749
  for (let uri of redirect_uri) {
5748
5750
  try {
@@ -5771,6 +5773,7 @@ class SvelteKitSharedClientEndpoints {
5771
5773
  if (isAdmin) {
5772
5774
  clientUpdate.userid = formData.userid ? Number(formData.userid) : null;
5773
5775
  }
5776
+ if (!this.clientManager) throw new CrossauthError(ErrorCode.Configuration, "Cannot call this endpoint as you did not provide a clientStorage");
5774
5777
  const newClient = await this.clientManager.createClient(
5775
5778
  formData.client_name,
5776
5779
  redirect_uri,
@@ -167,7 +167,7 @@ export declare class SvelteKitSharedClientEndpoints {
167
167
  /**
168
168
  * The OAuth client manager instantiated during construction
169
169
  */
170
- protected clientManager: OAuthClientManager;
170
+ protected clientManager?: OAuthClientManager;
171
171
  /**
172
172
  * Taken from the {@link SvelteKitSessionServerOptions}
173
173
  * in the constructor.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crossauth/sveltekit",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -45,8 +45,8 @@
45
45
  "minimatch": "^10.0.1",
46
46
  "qrcode": "^1.5.4",
47
47
  "vite-plugin-dts": "^3.6.4",
48
- "@crossauth/backend": "^0.0.4",
49
- "@crossauth/common": "^0.0.4"
48
+ "@crossauth/backend": "^0.0.5",
49
+ "@crossauth/common": "^0.0.5"
50
50
  },
51
51
  "scripts": {
52
52
  "dev": "vite dev",