@thirdweb-dev/service-utils 0.0.0-dev-11d3fa6-20230714225821 → 0.0.0-dev-83d14ce-20230725071935

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-03e2bf97.cjs.dev.js');
5
+ var index = require('../../dist/index-4496b57e.cjs.dev.js');
6
6
  var services = require('../../dist/services-a3f36057.cjs.dev.js');
7
7
 
8
8
  const DEFAULT_CACHE_TTL_SECONDS = 60;
@@ -68,7 +68,7 @@ async function extractAuthorizationData(authInput) {
68
68
  // if we have an origin at this point, normalize it
69
69
  if (origin) {
70
70
  try {
71
- origin = new URL(origin).hostname;
71
+ origin = new URL(origin).host;
72
72
  } catch (e) {
73
73
  console.warn("failed to parse origin", origin, e);
74
74
  }
@@ -94,8 +94,7 @@ async function extractAuthorizationData(authInput) {
94
94
  origin,
95
95
  bundleId,
96
96
  secretKeyHash,
97
- targetAddress: authInput.targetAddress,
98
- enforceAuth: authInput.enforcedAuth
97
+ targetAddress: authInput.targetAddress
99
98
  };
100
99
  }
101
100
  async function hashSecretKey(secretKey) {
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('../../dist/index-2facafef.cjs.prod.js');
5
+ var index = require('../../dist/index-7c6b47cd.cjs.prod.js');
6
6
  var services = require('../../dist/services-9e185105.cjs.prod.js');
7
7
 
8
8
  const DEFAULT_CACHE_TTL_SECONDS = 60;
@@ -68,7 +68,7 @@ async function extractAuthorizationData(authInput) {
68
68
  // if we have an origin at this point, normalize it
69
69
  if (origin) {
70
70
  try {
71
- origin = new URL(origin).hostname;
71
+ origin = new URL(origin).host;
72
72
  } catch (e) {
73
73
  console.warn("failed to parse origin", origin, e);
74
74
  }
@@ -94,8 +94,7 @@ async function extractAuthorizationData(authInput) {
94
94
  origin,
95
95
  bundleId,
96
96
  secretKeyHash,
97
- targetAddress: authInput.targetAddress,
98
- enforceAuth: authInput.enforcedAuth
97
+ targetAddress: authInput.targetAddress
99
98
  };
100
99
  }
101
100
  async function hashSecretKey(secretKey) {
@@ -1,4 +1,4 @@
1
- import { a as authorize } from '../../dist/index-e7c3b3be.esm.js';
1
+ import { a as authorize } from '../../dist/index-d752cff8.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;
@@ -64,7 +64,7 @@ async function extractAuthorizationData(authInput) {
64
64
  // if we have an origin at this point, normalize it
65
65
  if (origin) {
66
66
  try {
67
- origin = new URL(origin).hostname;
67
+ origin = new URL(origin).host;
68
68
  } catch (e) {
69
69
  console.warn("failed to parse origin", origin, e);
70
70
  }
@@ -90,8 +90,7 @@ async function extractAuthorizationData(authInput) {
90
90
  origin,
91
91
  bundleId,
92
92
  secretKeyHash,
93
- targetAddress: authInput.targetAddress,
94
- enforceAuth: authInput.enforcedAuth
93
+ targetAddress: authInput.targetAddress
95
94
  };
96
95
  }
97
96
  async function hashSecretKey(secretKey) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"../../../../src/cf-worker","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,KAAK,EAAkB,iBAAiB,EAAE,uBAAoB;AAGrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,mCAAgC;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAsB;AAEnD,oCAAiC;AAEjC,KAAK,mBAAmB,GAAG,iBAAiB,GAAG;IAC7C,OAAO,EAAE,WAAW,CAAC;IACrB,GAAG,EAAE,gBAAgB,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAIF,KAAK,SAAS,GAAG,aAAa,GAAG;IAC/B,GAAG,EAAE,OAAO,CAAC;CACd,CAAC;AAEF,wBAAsB,eAAe,CACnC,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,mBAAmB,GACjC,OAAO,CAAC,mBAAmB,CAAC,CA0C9B;AAqED,wBAAsB,aAAa,CAAC,SAAS,EAAE,MAAM,mBAIpD;AAED,wBAAgB,+BAA+B,CAAC,aAAa,EAAE,MAAM,UAEpE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"../../../../src/cf-worker","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,KAAK,EAAkB,iBAAiB,EAAE,uBAAoB;AAGrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,mCAAgC;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAsB;AAEnD,oCAAiC;AAEjC,KAAK,mBAAmB,GAAG,iBAAiB,GAAG;IAC7C,OAAO,EAAE,WAAW,CAAC;IACrB,GAAG,EAAE,gBAAgB,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAIF,KAAK,SAAS,GAAG,aAAa,GAAG;IAC/B,GAAG,EAAE,OAAO,CAAC;CACd,CAAC;AAEF,wBAAsB,eAAe,CACnC,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,mBAAmB,GACjC,OAAO,CAAC,mBAAmB,CAAC,CA0C9B;AAoED,wBAAsB,aAAa,CAAC,SAAS,EAAE,MAAM,mBAIpD;AAED,wBAAgB,+BAA+B,CAAC,aAAa,EAAE,MAAM,UAEpE"}
@@ -1,5 +1,6 @@
1
1
  import type { ServiceName } from "./services.js";
2
2
  export type CoreServiceConfig = {
3
+ enforceAuth: boolean;
3
4
  apiUrl: string;
4
5
  serviceScope: ServiceName;
5
6
  serviceApiKey: string;
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"../../../../src/core","sources":["api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,sBAAmB;AAE9C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,WAAW,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,oBAAoB,EAAE,MAAM,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,eAAe,EAAE,MAAM,EAAE,CAAC;QAC1B,OAAO,EAAE,MAAM,EAAE,CAAC;KACnB,EAAE,CAAC;CACL,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,cAAc,GAAG,IAAI,CAAC;IAC5B,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH,CAAC;AAEF,wBAAsB,uBAAuB,CAC3C,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,WAAW,CAAC,CAgBtB"}
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"../../../../src/core","sources":["api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,sBAAmB;AAE9C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,WAAW,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,oBAAoB,EAAE,MAAM,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,eAAe,EAAE,MAAM,EAAE,CAAC;QAC1B,OAAO,EAAE,MAAM,EAAE,CAAC;KACnB,EAAE,CAAC;CACL,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,cAAc,GAAG,IAAI,CAAC;IAC5B,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH,CAAC;AAEF,wBAAsB,uBAAuB,CAC3C,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,WAAW,CAAC,CAgBtB"}
@@ -7,7 +7,6 @@ export type AuthorizationInput = {
7
7
  bundleId: string | null;
8
8
  secretKeyHash: string | null;
9
9
  targetAddress?: string | string[];
10
- enforceAuth: boolean;
11
10
  };
12
11
  type CacheOptions = {
13
12
  get: (clientId: string) => Promise<string | null>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"../../../../../src/core/authorize","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd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AAG,IAAI,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACnC,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,GAAG,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAClD,GAAG,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACtE,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AASF,wBAAsB,SAAS,CAC7B,QAAQ,EAAE,kBAAkB,EAC5B,aAAa,EAAE,iBAAiB,EAChC,YAAY,CAAC,EAAE,YAAY,GAC1B,OAAO,CAAC,mBAAmB,CAAC,CAiI9B"}
@@ -1,6 +1,5 @@
1
1
  export type CoreAuthInput = {
2
2
  clientId?: string;
3
3
  targetAddress?: string | string[];
4
- enforcedAuth: boolean;
5
4
  };
6
5
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"../../../../src/core","sources":["types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAE1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAElC,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"../../../../src/core","sources":["types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAE1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACnC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"../../../../src/node","sources":["index.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAuB,eAAe,EAAE,MAAM,WAAW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AAE,SAAS,GACnB,kBAAkB,CAwEpB;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,UAE9C;AAED,wBAAgB,+BAA+B,CAAC,aAAa,EAAE,MAAM,UAEpE"}
@@ -35,7 +35,7 @@ function authorizeClient(authOptions, apiKeyMeta) {
35
35
  if (secretHash !== providedSecretHash) {
36
36
  return {
37
37
  authorized: false,
38
- errorMessage: "The secret is invalid.",
38
+ errorMessage: "The secret is invalid. Please check you secret-key",
39
39
  errorCode: "SECRET_INVALID",
40
40
  status: 401
41
41
  };
@@ -72,7 +72,7 @@ function authorizeClient(authOptions, apiKeyMeta) {
72
72
  }
73
73
  return {
74
74
  authorized: false,
75
- errorMessage: "The origin is not authorized for this key.",
75
+ errorMessage: `The domain: ${origin}, is not authorized for this key. Please update your key permissions on the thirdweb dashboard`,
76
76
  errorCode: "ORIGIN_UNAUTHORIZED",
77
77
  status: 401
78
78
  };
@@ -95,14 +95,14 @@ function authorizeClient(authOptions, apiKeyMeta) {
95
95
  }
96
96
  return {
97
97
  authorized: false,
98
- errorMessage: "The bundle is not authorized for this key.",
98
+ errorMessage: `The bundleId: ${bundleId}, is not authorized for this key. Please update your key permissions on the thirdweb dashboard`,
99
99
  errorCode: "BUNDLE_UNAUTHORIZED",
100
100
  status: 401
101
101
  };
102
102
  }
103
103
  return {
104
104
  authorized: false,
105
- errorMessage: "The keys are invalid.",
105
+ errorMessage: "The keys are invalid. Please check the secret-key/clientId and try again.",
106
106
  errorCode: "UNAUTHORIZED",
107
107
  status: 401
108
108
  };
@@ -117,7 +117,7 @@ function authorizeService(apiKeyMetadata, serviceConfig, authorizationPayload) {
117
117
  if (!service) {
118
118
  return {
119
119
  authorized: false,
120
- errorMessage: `The service "${serviceConfig.serviceScope}" is not authorized for this key.`,
120
+ errorMessage: `The service "${serviceConfig.serviceScope}" is not authorized for this key. Please update your key permissions on the thirdweb dashboard.`,
121
121
  errorCode: "SERVICE_UNAUTHORIZED",
122
122
  status: 403
123
123
  };
@@ -129,7 +129,7 @@ function authorizeService(apiKeyMetadata, serviceConfig, authorizationPayload) {
129
129
  if (!isActionAllowed) {
130
130
  return {
131
131
  authorized: false,
132
- errorMessage: `The service "${serviceConfig.serviceScope}" action "${serviceConfig.serviceAction}" is not authorized for this key.`,
132
+ errorMessage: `The service "${serviceConfig.serviceScope}" action "${serviceConfig.serviceAction}" is not authorized for this key. Please update your key permissions on the thirdweb dashboard.`,
133
133
  errorCode: "SERVICE_ACTION_UNAUTHORIZED",
134
134
  status: 403
135
135
  };
@@ -144,7 +144,7 @@ function authorizeService(apiKeyMetadata, serviceConfig, authorizationPayload) {
144
144
  if (!allAllowed && checkedAddresses.some(ta => !service.targetAddresses.includes(ta))) {
145
145
  return {
146
146
  authorized: false,
147
- errorMessage: `The service "${serviceConfig.serviceScope}" target address is not authorized for this key.`,
147
+ errorMessage: `The target address: ${checkedAddresses}, for service "${serviceConfig.serviceScope}" is not authorized for this key. Please update your key permissions on the thirdweb dashboard.`,
148
148
  errorCode: "SERVICE_TARGET_ADDRESS_UNAUTHORIZED",
149
149
  status: 403
150
150
  };
@@ -160,9 +160,11 @@ async function authorize(authData, serviceConfig, cacheOptions) {
160
160
  const {
161
161
  clientId,
162
162
  targetAddress,
163
- enforceAuth,
164
163
  secretKeyHash
165
164
  } = authData;
165
+ const {
166
+ enforceAuth
167
+ } = serviceConfig;
166
168
 
167
169
  // BACKWARDS COMPAT: if auth not enforced and
168
170
  // we don't have auth credentials bypass
@@ -243,7 +245,7 @@ async function authorize(authData, serviceConfig, cacheOptions) {
243
245
  return {
244
246
  authorized: false,
245
247
  status: 500,
246
- errorMessage: "Failed to fetch key metadata.",
248
+ errorMessage: "Failed to fetch key metadata. Please check your secret-key/clientId.",
247
249
  errorCode: "FAILED_TO_FETCH_KEY"
248
250
  };
249
251
  }
@@ -252,7 +254,7 @@ async function authorize(authData, serviceConfig, cacheOptions) {
252
254
  return {
253
255
  authorized: false,
254
256
  status: 401,
255
- errorMessage: "Key is invalid.",
257
+ errorMessage: "Key is invalid. Please check your secret-key/clientId.",
256
258
  errorCode: "INVALID_KEY"
257
259
  };
258
260
  }
@@ -35,7 +35,7 @@ function authorizeClient(authOptions, apiKeyMeta) {
35
35
  if (secretHash !== providedSecretHash) {
36
36
  return {
37
37
  authorized: false,
38
- errorMessage: "The secret is invalid.",
38
+ errorMessage: "The secret is invalid. Please check you secret-key",
39
39
  errorCode: "SECRET_INVALID",
40
40
  status: 401
41
41
  };
@@ -72,7 +72,7 @@ function authorizeClient(authOptions, apiKeyMeta) {
72
72
  }
73
73
  return {
74
74
  authorized: false,
75
- errorMessage: "The origin is not authorized for this key.",
75
+ errorMessage: `The domain: ${origin}, is not authorized for this key. Please update your key permissions on the thirdweb dashboard`,
76
76
  errorCode: "ORIGIN_UNAUTHORIZED",
77
77
  status: 401
78
78
  };
@@ -95,14 +95,14 @@ function authorizeClient(authOptions, apiKeyMeta) {
95
95
  }
96
96
  return {
97
97
  authorized: false,
98
- errorMessage: "The bundle is not authorized for this key.",
98
+ errorMessage: `The bundleId: ${bundleId}, is not authorized for this key. Please update your key permissions on the thirdweb dashboard`,
99
99
  errorCode: "BUNDLE_UNAUTHORIZED",
100
100
  status: 401
101
101
  };
102
102
  }
103
103
  return {
104
104
  authorized: false,
105
- errorMessage: "The keys are invalid.",
105
+ errorMessage: "The keys are invalid. Please check the secret-key/clientId and try again.",
106
106
  errorCode: "UNAUTHORIZED",
107
107
  status: 401
108
108
  };
@@ -117,7 +117,7 @@ function authorizeService(apiKeyMetadata, serviceConfig, authorizationPayload) {
117
117
  if (!service) {
118
118
  return {
119
119
  authorized: false,
120
- errorMessage: `The service "${serviceConfig.serviceScope}" is not authorized for this key.`,
120
+ errorMessage: `The service "${serviceConfig.serviceScope}" is not authorized for this key. Please update your key permissions on the thirdweb dashboard.`,
121
121
  errorCode: "SERVICE_UNAUTHORIZED",
122
122
  status: 403
123
123
  };
@@ -129,7 +129,7 @@ function authorizeService(apiKeyMetadata, serviceConfig, authorizationPayload) {
129
129
  if (!isActionAllowed) {
130
130
  return {
131
131
  authorized: false,
132
- errorMessage: `The service "${serviceConfig.serviceScope}" action "${serviceConfig.serviceAction}" is not authorized for this key.`,
132
+ errorMessage: `The service "${serviceConfig.serviceScope}" action "${serviceConfig.serviceAction}" is not authorized for this key. Please update your key permissions on the thirdweb dashboard.`,
133
133
  errorCode: "SERVICE_ACTION_UNAUTHORIZED",
134
134
  status: 403
135
135
  };
@@ -144,7 +144,7 @@ function authorizeService(apiKeyMetadata, serviceConfig, authorizationPayload) {
144
144
  if (!allAllowed && checkedAddresses.some(ta => !service.targetAddresses.includes(ta))) {
145
145
  return {
146
146
  authorized: false,
147
- errorMessage: `The service "${serviceConfig.serviceScope}" target address is not authorized for this key.`,
147
+ errorMessage: `The target address: ${checkedAddresses}, for service "${serviceConfig.serviceScope}" is not authorized for this key. Please update your key permissions on the thirdweb dashboard.`,
148
148
  errorCode: "SERVICE_TARGET_ADDRESS_UNAUTHORIZED",
149
149
  status: 403
150
150
  };
@@ -160,9 +160,11 @@ async function authorize(authData, serviceConfig, cacheOptions) {
160
160
  const {
161
161
  clientId,
162
162
  targetAddress,
163
- enforceAuth,
164
163
  secretKeyHash
165
164
  } = authData;
165
+ const {
166
+ enforceAuth
167
+ } = serviceConfig;
166
168
 
167
169
  // BACKWARDS COMPAT: if auth not enforced and
168
170
  // we don't have auth credentials bypass
@@ -243,7 +245,7 @@ async function authorize(authData, serviceConfig, cacheOptions) {
243
245
  return {
244
246
  authorized: false,
245
247
  status: 500,
246
- errorMessage: "Failed to fetch key metadata.",
248
+ errorMessage: "Failed to fetch key metadata. Please check your secret-key/clientId.",
247
249
  errorCode: "FAILED_TO_FETCH_KEY"
248
250
  };
249
251
  }
@@ -252,7 +254,7 @@ async function authorize(authData, serviceConfig, cacheOptions) {
252
254
  return {
253
255
  authorized: false,
254
256
  status: 401,
255
- errorMessage: "Key is invalid.",
257
+ errorMessage: "Key is invalid. Please check your secret-key/clientId.",
256
258
  errorCode: "INVALID_KEY"
257
259
  };
258
260
  }
@@ -33,7 +33,7 @@ function authorizeClient(authOptions, apiKeyMeta) {
33
33
  if (secretHash !== providedSecretHash) {
34
34
  return {
35
35
  authorized: false,
36
- errorMessage: "The secret is invalid.",
36
+ errorMessage: "The secret is invalid. Please check you secret-key",
37
37
  errorCode: "SECRET_INVALID",
38
38
  status: 401
39
39
  };
@@ -70,7 +70,7 @@ function authorizeClient(authOptions, apiKeyMeta) {
70
70
  }
71
71
  return {
72
72
  authorized: false,
73
- errorMessage: "The origin is not authorized for this key.",
73
+ errorMessage: `The domain: ${origin}, is not authorized for this key. Please update your key permissions on the thirdweb dashboard`,
74
74
  errorCode: "ORIGIN_UNAUTHORIZED",
75
75
  status: 401
76
76
  };
@@ -93,14 +93,14 @@ function authorizeClient(authOptions, apiKeyMeta) {
93
93
  }
94
94
  return {
95
95
  authorized: false,
96
- errorMessage: "The bundle is not authorized for this key.",
96
+ errorMessage: `The bundleId: ${bundleId}, is not authorized for this key. Please update your key permissions on the thirdweb dashboard`,
97
97
  errorCode: "BUNDLE_UNAUTHORIZED",
98
98
  status: 401
99
99
  };
100
100
  }
101
101
  return {
102
102
  authorized: false,
103
- errorMessage: "The keys are invalid.",
103
+ errorMessage: "The keys are invalid. Please check the secret-key/clientId and try again.",
104
104
  errorCode: "UNAUTHORIZED",
105
105
  status: 401
106
106
  };
@@ -115,7 +115,7 @@ function authorizeService(apiKeyMetadata, serviceConfig, authorizationPayload) {
115
115
  if (!service) {
116
116
  return {
117
117
  authorized: false,
118
- errorMessage: `The service "${serviceConfig.serviceScope}" is not authorized for this key.`,
118
+ errorMessage: `The service "${serviceConfig.serviceScope}" is not authorized for this key. Please update your key permissions on the thirdweb dashboard.`,
119
119
  errorCode: "SERVICE_UNAUTHORIZED",
120
120
  status: 403
121
121
  };
@@ -127,7 +127,7 @@ function authorizeService(apiKeyMetadata, serviceConfig, authorizationPayload) {
127
127
  if (!isActionAllowed) {
128
128
  return {
129
129
  authorized: false,
130
- errorMessage: `The service "${serviceConfig.serviceScope}" action "${serviceConfig.serviceAction}" is not authorized for this key.`,
130
+ errorMessage: `The service "${serviceConfig.serviceScope}" action "${serviceConfig.serviceAction}" is not authorized for this key. Please update your key permissions on the thirdweb dashboard.`,
131
131
  errorCode: "SERVICE_ACTION_UNAUTHORIZED",
132
132
  status: 403
133
133
  };
@@ -142,7 +142,7 @@ function authorizeService(apiKeyMetadata, serviceConfig, authorizationPayload) {
142
142
  if (!allAllowed && checkedAddresses.some(ta => !service.targetAddresses.includes(ta))) {
143
143
  return {
144
144
  authorized: false,
145
- errorMessage: `The service "${serviceConfig.serviceScope}" target address is not authorized for this key.`,
145
+ errorMessage: `The target address: ${checkedAddresses}, for service "${serviceConfig.serviceScope}" is not authorized for this key. Please update your key permissions on the thirdweb dashboard.`,
146
146
  errorCode: "SERVICE_TARGET_ADDRESS_UNAUTHORIZED",
147
147
  status: 403
148
148
  };
@@ -158,9 +158,11 @@ async function authorize(authData, serviceConfig, cacheOptions) {
158
158
  const {
159
159
  clientId,
160
160
  targetAddress,
161
- enforceAuth,
162
161
  secretKeyHash
163
162
  } = authData;
163
+ const {
164
+ enforceAuth
165
+ } = serviceConfig;
164
166
 
165
167
  // BACKWARDS COMPAT: if auth not enforced and
166
168
  // we don't have auth credentials bypass
@@ -241,7 +243,7 @@ async function authorize(authData, serviceConfig, cacheOptions) {
241
243
  return {
242
244
  authorized: false,
243
245
  status: 500,
244
- errorMessage: "Failed to fetch key metadata.",
246
+ errorMessage: "Failed to fetch key metadata. Please check your secret-key/clientId.",
245
247
  errorCode: "FAILED_TO_FETCH_KEY"
246
248
  };
247
249
  }
@@ -250,7 +252,7 @@ async function authorize(authData, serviceConfig, cacheOptions) {
250
252
  return {
251
253
  authorized: false,
252
254
  status: 401,
253
- errorMessage: "Key is invalid.",
255
+ errorMessage: "Key is invalid. Please check your secret-key/clientId.",
254
256
  errorCode: "INVALID_KEY"
255
257
  };
256
258
  }
@@ -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-03e2bf97.cjs.dev.js');
6
+ var index = require('../../dist/index-4496b57e.cjs.dev.js');
7
7
  var services = require('../../dist/services-a3f36057.cjs.dev.js');
8
8
 
9
9
  async function authorizeNode(authInput, serviceConfig) {
@@ -71,7 +71,7 @@ function extractAuthorizationData(authInput) {
71
71
  // if we have an origin at this point, normalize it
72
72
  if (origin) {
73
73
  try {
74
- origin = new URL(origin).hostname;
74
+ origin = new URL(origin).host;
75
75
  } catch (e) {
76
76
  console.warn("failed to parse origin", origin, e);
77
77
  }
@@ -97,8 +97,7 @@ function extractAuthorizationData(authInput) {
97
97
  clientId,
98
98
  origin,
99
99
  bundleId,
100
- targetAddress: authInput.targetAddress,
101
- enforceAuth: authInput.enforcedAuth
100
+ targetAddress: authInput.targetAddress
102
101
  };
103
102
  }
104
103
  function hashSecretKey(secretKey) {
@@ -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-2facafef.cjs.prod.js');
6
+ var index = require('../../dist/index-7c6b47cd.cjs.prod.js');
7
7
  var services = require('../../dist/services-9e185105.cjs.prod.js');
8
8
 
9
9
  async function authorizeNode(authInput, serviceConfig) {
@@ -71,7 +71,7 @@ function extractAuthorizationData(authInput) {
71
71
  // if we have an origin at this point, normalize it
72
72
  if (origin) {
73
73
  try {
74
- origin = new URL(origin).hostname;
74
+ origin = new URL(origin).host;
75
75
  } catch (e) {
76
76
  console.warn("failed to parse origin", origin, e);
77
77
  }
@@ -97,8 +97,7 @@ function extractAuthorizationData(authInput) {
97
97
  clientId,
98
98
  origin,
99
99
  bundleId,
100
- targetAddress: authInput.targetAddress,
101
- enforceAuth: authInput.enforcedAuth
100
+ targetAddress: authInput.targetAddress
102
101
  };
103
102
  }
104
103
  function hashSecretKey(secretKey) {
@@ -1,5 +1,5 @@
1
1
  import { createHash } from 'node:crypto';
2
- import { a as authorize } from '../../dist/index-e7c3b3be.esm.js';
2
+ import { a as authorize } from '../../dist/index-d752cff8.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) {
@@ -67,7 +67,7 @@ function extractAuthorizationData(authInput) {
67
67
  // if we have an origin at this point, normalize it
68
68
  if (origin) {
69
69
  try {
70
- origin = new URL(origin).hostname;
70
+ origin = new URL(origin).host;
71
71
  } catch (e) {
72
72
  console.warn("failed to parse origin", origin, e);
73
73
  }
@@ -93,8 +93,7 @@ function extractAuthorizationData(authInput) {
93
93
  clientId,
94
94
  origin,
95
95
  bundleId,
96
- targetAddress: authInput.targetAddress,
97
- enforceAuth: authInput.enforcedAuth
96
+ targetAddress: authInput.targetAddress
98
97
  };
99
98
  }
100
99
  function hashSecretKey(secretKey) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thirdweb-dev/service-utils",
3
- "version": "0.0.0-dev-11d3fa6-20230714225821",
3
+ "version": "0.0.0-dev-83d14ce-20230725071935",
4
4
  "main": "dist/thirdweb-dev-service-utils.cjs.js",
5
5
  "module": "dist/thirdweb-dev-service-utils.esm.js",
6
6
  "exports": {
@@ -46,7 +46,7 @@
46
46
  "@types/node": "^20.4.1",
47
47
  "@typescript-eslint/eslint-plugin": "^6.0.0",
48
48
  "@typescript-eslint/parser": "^6.0.0",
49
- "eslint": "^8.44.0",
49
+ "eslint": "^8.45.0",
50
50
  "eslint-config-prettier": "^8.8.0",
51
51
  "eslint-config-thirdweb": "^0.1.5",
52
52
  "jest": "^29.4.3",