@thirdweb-dev/service-utils 0.0.0-dev-619fe6f-20230731210829 → 0.0.0-dev-67a70f5-20230801205511

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('../../dist/index-4496b57e.cjs.dev.js');
5
+ var index = require('../../dist/index-89fa8ac4.cjs.dev.js');
6
6
  var services = require('../../dist/services-a3f36057.cjs.dev.js');
7
7
 
8
8
  const DEFAULT_CACHE_TTL_SECONDS = 60;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('../../dist/index-7c6b47cd.cjs.prod.js');
5
+ var index = require('../../dist/index-d665926b.cjs.prod.js');
6
6
  var services = require('../../dist/services-9e185105.cjs.prod.js');
7
7
 
8
8
  const DEFAULT_CACHE_TTL_SECONDS = 60;
@@ -1,4 +1,4 @@
1
- import { a as authorize } from '../../dist/index-d752cff8.esm.js';
1
+ import { a as authorize } from '../../dist/index-e63c70ed.esm.js';
2
2
  export { b as SERVICES, S as SERVICE_DEFINITIONS, a as SERVICE_NAMES, g as getServiceByName } from '../../dist/services-86283509.esm.js';
3
3
 
4
4
  const DEFAULT_CACHE_TTL_SECONDS = 60;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"../../../../../src/core/authorize","sources":["client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD,MAAM,MAAM,0BAA0B,GAAG;IACvC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC;AAEF,wBAAgB,eAAe,CAC7B,WAAW,EAAE,0BAA0B,EACvC,UAAU,EAAE,cAAc,GACzB,mBAAmB,CAsFrB"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"../../../../../src/core/authorize","sources":["client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD,MAAM,MAAM,0BAA0B,GAAG;IACvC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC;AAEF,wBAAgB,eAAe,CAC7B,WAAW,EAAE,0BAA0B,EACvC,UAAU,EAAE,cAAc,GACzB,mBAAmB,CA+FrB"}
@@ -31,6 +31,8 @@ function authorizeClient(authOptions, apiKeyMeta) {
31
31
  bundleIds,
32
32
  secretHash
33
33
  } = apiKeyMeta;
34
+
35
+ // check for secretHash
34
36
  if (providedSecretHash) {
35
37
  if (secretHash !== providedSecretHash) {
36
38
  return {
@@ -46,6 +48,14 @@ function authorizeClient(authOptions, apiKeyMeta) {
46
48
  };
47
49
  }
48
50
 
51
+ // check for public restrictions
52
+ if (domains.includes("*")) {
53
+ return {
54
+ authorized: true,
55
+ apiKeyMeta
56
+ };
57
+ }
58
+
49
59
  // validate domains
50
60
  if (origin) {
51
61
  if (
@@ -175,7 +185,7 @@ async function authorize(authData, serviceConfig, cacheOptions) {
175
185
  };
176
186
  }
177
187
 
178
- // if we don't have a client id at this point we can't authorize
188
+ // if we don't have a client id at this point, we can't authorize
179
189
  if (!clientId) {
180
190
  return {
181
191
  authorized: false,
@@ -186,7 +196,7 @@ async function authorize(authData, serviceConfig, cacheOptions) {
186
196
  }
187
197
  let apiKeyMeta = null;
188
198
  // if we have cache options we want to check the cache first
189
- if (cacheOptions) {
199
+ if (cacheOptions && clientId) {
190
200
  try {
191
201
  const cachedKey = await cacheOptions.get(clientId);
192
202
  if (cachedKey) {
@@ -211,7 +221,7 @@ async function authorize(authData, serviceConfig, cacheOptions) {
211
221
  }
212
222
 
213
223
  // if we don't have a cached key, fetch from the API
214
- if (!apiKeyMeta) {
224
+ if (!apiKeyMeta && clientId) {
215
225
  try {
216
226
  const {
217
227
  data,
@@ -31,6 +31,8 @@ function authorizeClient(authOptions, apiKeyMeta) {
31
31
  bundleIds,
32
32
  secretHash
33
33
  } = apiKeyMeta;
34
+
35
+ // check for secretHash
34
36
  if (providedSecretHash) {
35
37
  if (secretHash !== providedSecretHash) {
36
38
  return {
@@ -46,6 +48,14 @@ function authorizeClient(authOptions, apiKeyMeta) {
46
48
  };
47
49
  }
48
50
 
51
+ // check for public restrictions
52
+ if (domains.includes("*")) {
53
+ return {
54
+ authorized: true,
55
+ apiKeyMeta
56
+ };
57
+ }
58
+
49
59
  // validate domains
50
60
  if (origin) {
51
61
  if (
@@ -175,7 +185,7 @@ async function authorize(authData, serviceConfig, cacheOptions) {
175
185
  };
176
186
  }
177
187
 
178
- // if we don't have a client id at this point we can't authorize
188
+ // if we don't have a client id at this point, we can't authorize
179
189
  if (!clientId) {
180
190
  return {
181
191
  authorized: false,
@@ -186,7 +196,7 @@ async function authorize(authData, serviceConfig, cacheOptions) {
186
196
  }
187
197
  let apiKeyMeta = null;
188
198
  // if we have cache options we want to check the cache first
189
- if (cacheOptions) {
199
+ if (cacheOptions && clientId) {
190
200
  try {
191
201
  const cachedKey = await cacheOptions.get(clientId);
192
202
  if (cachedKey) {
@@ -211,7 +221,7 @@ async function authorize(authData, serviceConfig, cacheOptions) {
211
221
  }
212
222
 
213
223
  // if we don't have a cached key, fetch from the API
214
- if (!apiKeyMeta) {
224
+ if (!apiKeyMeta && clientId) {
215
225
  try {
216
226
  const {
217
227
  data,
@@ -29,6 +29,8 @@ function authorizeClient(authOptions, apiKeyMeta) {
29
29
  bundleIds,
30
30
  secretHash
31
31
  } = apiKeyMeta;
32
+
33
+ // check for secretHash
32
34
  if (providedSecretHash) {
33
35
  if (secretHash !== providedSecretHash) {
34
36
  return {
@@ -44,6 +46,14 @@ function authorizeClient(authOptions, apiKeyMeta) {
44
46
  };
45
47
  }
46
48
 
49
+ // check for public restrictions
50
+ if (domains.includes("*")) {
51
+ return {
52
+ authorized: true,
53
+ apiKeyMeta
54
+ };
55
+ }
56
+
47
57
  // validate domains
48
58
  if (origin) {
49
59
  if (
@@ -173,7 +183,7 @@ async function authorize(authData, serviceConfig, cacheOptions) {
173
183
  };
174
184
  }
175
185
 
176
- // if we don't have a client id at this point we can't authorize
186
+ // if we don't have a client id at this point, we can't authorize
177
187
  if (!clientId) {
178
188
  return {
179
189
  authorized: false,
@@ -184,7 +194,7 @@ async function authorize(authData, serviceConfig, cacheOptions) {
184
194
  }
185
195
  let apiKeyMeta = null;
186
196
  // if we have cache options we want to check the cache first
187
- if (cacheOptions) {
197
+ if (cacheOptions && clientId) {
188
198
  try {
189
199
  const cachedKey = await cacheOptions.get(clientId);
190
200
  if (cachedKey) {
@@ -209,7 +219,7 @@ async function authorize(authData, serviceConfig, cacheOptions) {
209
219
  }
210
220
 
211
221
  // if we don't have a cached key, fetch from the API
212
- if (!apiKeyMeta) {
222
+ if (!apiKeyMeta && clientId) {
213
223
  try {
214
224
  const {
215
225
  data,
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var node_crypto = require('node:crypto');
6
- var index = require('../../dist/index-4496b57e.cjs.dev.js');
6
+ var index = require('../../dist/index-89fa8ac4.cjs.dev.js');
7
7
  var services = require('../../dist/services-a3f36057.cjs.dev.js');
8
8
 
9
9
  async function authorizeNode(authInput, serviceConfig) {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var node_crypto = require('node:crypto');
6
- var index = require('../../dist/index-7c6b47cd.cjs.prod.js');
6
+ var index = require('../../dist/index-d665926b.cjs.prod.js');
7
7
  var services = require('../../dist/services-9e185105.cjs.prod.js');
8
8
 
9
9
  async function authorizeNode(authInput, serviceConfig) {
@@ -1,5 +1,5 @@
1
1
  import { createHash } from 'node:crypto';
2
- import { a as authorize } from '../../dist/index-d752cff8.esm.js';
2
+ import { a as authorize } from '../../dist/index-e63c70ed.esm.js';
3
3
  export { b as SERVICES, S as SERVICE_DEFINITIONS, a as SERVICE_NAMES, g as getServiceByName } from '../../dist/services-86283509.esm.js';
4
4
 
5
5
  async function authorizeNode(authInput, serviceConfig) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thirdweb-dev/service-utils",
3
- "version": "0.0.0-dev-619fe6f-20230731210829",
3
+ "version": "0.0.0-dev-67a70f5-20230801205511",
4
4
  "main": "dist/thirdweb-dev-service-utils.cjs.js",
5
5
  "module": "dist/thirdweb-dev-service-utils.esm.js",
6
6
  "exports": {