@thirdweb-dev/service-utils 0.0.0-dev-282b3cc-20230714220714 → 0.0.0-dev-ffd23fc-20230715220148
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/cf-worker/dist/thirdweb-dev-service-utils-cf-worker.cjs.dev.js +1 -1
- package/cf-worker/dist/thirdweb-dev-service-utils-cf-worker.cjs.prod.js +1 -1
- package/cf-worker/dist/thirdweb-dev-service-utils-cf-worker.esm.js +1 -1
- package/dist/declarations/src/core/api.d.ts +1 -0
- package/dist/declarations/src/core/api.d.ts.map +1 -1
- package/dist/declarations/src/core/authorize/index.d.ts.map +1 -1
- package/dist/declarations/src/core/authorize/types.d.ts +1 -1
- package/dist/declarations/src/core/authorize/types.d.ts.map +1 -1
- package/dist/{index-b1597fc7.cjs.prod.js → index-6e980870.cjs.dev.js} +23 -5
- package/dist/{index-e63ba474.cjs.dev.js → index-96491db6.cjs.prod.js} +23 -5
- package/dist/{index-bcedf9fe.esm.js → index-c332ae71.esm.js} +23 -5
- package/node/dist/thirdweb-dev-service-utils-node.cjs.dev.js +1 -1
- package/node/dist/thirdweb-dev-service-utils-node.cjs.prod.js +1 -1
- package/node/dist/thirdweb-dev-service-utils-node.esm.js +1 -1
- package/package.json +1 -1
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var index = require('../../dist/index-
|
5
|
+
var index = require('../../dist/index-6e980870.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-
|
5
|
+
var index = require('../../dist/index-96491db6.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-
|
1
|
+
import { a as authorize } from '../../dist/index-c332ae71.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":"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"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"../../../../../src/core/authorize","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,iBAAiB,EAElB,kBAAe;AAGhB,OAAO,EAAE,mBAAmB,EAAE,mBAAgB;AAE9C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,aAAa,EAAE,MAAM,GAAG,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,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"../../../../../src/core/authorize","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,iBAAiB,EAElB,kBAAe;AAGhB,OAAO,EAAE,mBAAmB,EAAE,mBAAgB;AAE9C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,aAAa,EAAE,MAAM,GAAG,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,CAgI9B"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"../../../../../src/core/authorize","sources":["types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,kBAAe;AAExC,MAAM,MAAM,mBAAmB,GAC3B;IACE,UAAU,EAAE,IAAI,CAAC;IACjB,UAAU,EAAE,cAAc,CAAC;
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"../../../../../src/core/authorize","sources":["types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,kBAAe;AAExC,MAAM,MAAM,mBAAmB,GAC3B;IACE,UAAU,EAAE,IAAI,CAAC;IACjB,UAAU,EAAE,cAAc,GAAG,IAAI,CAAC;CACnC,GACD;IACE,UAAU,EAAE,KAAK,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC"}
|
@@ -157,8 +157,26 @@ function authorizeService(apiKeyMetadata, serviceConfig, authorizationPayload) {
|
|
157
157
|
}
|
158
158
|
|
159
159
|
async function authorize(authData, serviceConfig, cacheOptions) {
|
160
|
+
const {
|
161
|
+
clientId,
|
162
|
+
targetAddress,
|
163
|
+
secretKeyHash
|
164
|
+
} = authData;
|
165
|
+
const {
|
166
|
+
enforceAuth
|
167
|
+
} = serviceConfig;
|
168
|
+
|
169
|
+
// BACKWARDS COMPAT: if auth not enforced and
|
170
|
+
// we don't have auth credentials bypass
|
171
|
+
if (!enforceAuth && !clientId && !secretKeyHash) {
|
172
|
+
return {
|
173
|
+
authorized: true,
|
174
|
+
apiKeyMeta: null
|
175
|
+
};
|
176
|
+
}
|
177
|
+
|
160
178
|
// if we don't have a client id at this point we can't authorize
|
161
|
-
if (!
|
179
|
+
if (!clientId) {
|
162
180
|
return {
|
163
181
|
authorized: false,
|
164
182
|
status: 401,
|
@@ -170,7 +188,7 @@ async function authorize(authData, serviceConfig, cacheOptions) {
|
|
170
188
|
// if we have cache options we want to check the cache first
|
171
189
|
if (cacheOptions) {
|
172
190
|
try {
|
173
|
-
const cachedKey = await cacheOptions.get(
|
191
|
+
const cachedKey = await cacheOptions.get(clientId);
|
174
192
|
if (cachedKey) {
|
175
193
|
const parsed = JSON.parse(cachedKey);
|
176
194
|
if ("updatedAt" in parsed) {
|
@@ -198,7 +216,7 @@ async function authorize(authData, serviceConfig, cacheOptions) {
|
|
198
216
|
const {
|
199
217
|
data,
|
200
218
|
error
|
201
|
-
} = await fetchKeyMetadataFromApi(
|
219
|
+
} = await fetchKeyMetadataFromApi(clientId, serviceConfig);
|
202
220
|
if (error) {
|
203
221
|
return {
|
204
222
|
authorized: false,
|
@@ -220,7 +238,7 @@ async function authorize(authData, serviceConfig, cacheOptions) {
|
|
220
238
|
// cache the retrieved key if we have cache options
|
221
239
|
if (cacheOptions) {
|
222
240
|
// we await this always because it can be a promise or not
|
223
|
-
await cacheOptions.put(
|
241
|
+
await cacheOptions.put(clientId, data);
|
224
242
|
}
|
225
243
|
} catch (err) {
|
226
244
|
console.warn("failed to fetch key metadata from api", err);
|
@@ -253,7 +271,7 @@ async function authorize(authData, serviceConfig, cacheOptions) {
|
|
253
271
|
|
254
272
|
// if we've made it this far we need to check service specific authorization
|
255
273
|
const serviceAuth = authorizeService(apiKeyMeta, serviceConfig, {
|
256
|
-
targetAddress
|
274
|
+
targetAddress
|
257
275
|
});
|
258
276
|
if (!serviceAuth.authorized) {
|
259
277
|
return {
|
@@ -157,8 +157,26 @@ function authorizeService(apiKeyMetadata, serviceConfig, authorizationPayload) {
|
|
157
157
|
}
|
158
158
|
|
159
159
|
async function authorize(authData, serviceConfig, cacheOptions) {
|
160
|
+
const {
|
161
|
+
clientId,
|
162
|
+
targetAddress,
|
163
|
+
secretKeyHash
|
164
|
+
} = authData;
|
165
|
+
const {
|
166
|
+
enforceAuth
|
167
|
+
} = serviceConfig;
|
168
|
+
|
169
|
+
// BACKWARDS COMPAT: if auth not enforced and
|
170
|
+
// we don't have auth credentials bypass
|
171
|
+
if (!enforceAuth && !clientId && !secretKeyHash) {
|
172
|
+
return {
|
173
|
+
authorized: true,
|
174
|
+
apiKeyMeta: null
|
175
|
+
};
|
176
|
+
}
|
177
|
+
|
160
178
|
// if we don't have a client id at this point we can't authorize
|
161
|
-
if (!
|
179
|
+
if (!clientId) {
|
162
180
|
return {
|
163
181
|
authorized: false,
|
164
182
|
status: 401,
|
@@ -170,7 +188,7 @@ async function authorize(authData, serviceConfig, cacheOptions) {
|
|
170
188
|
// if we have cache options we want to check the cache first
|
171
189
|
if (cacheOptions) {
|
172
190
|
try {
|
173
|
-
const cachedKey = await cacheOptions.get(
|
191
|
+
const cachedKey = await cacheOptions.get(clientId);
|
174
192
|
if (cachedKey) {
|
175
193
|
const parsed = JSON.parse(cachedKey);
|
176
194
|
if ("updatedAt" in parsed) {
|
@@ -198,7 +216,7 @@ async function authorize(authData, serviceConfig, cacheOptions) {
|
|
198
216
|
const {
|
199
217
|
data,
|
200
218
|
error
|
201
|
-
} = await fetchKeyMetadataFromApi(
|
219
|
+
} = await fetchKeyMetadataFromApi(clientId, serviceConfig);
|
202
220
|
if (error) {
|
203
221
|
return {
|
204
222
|
authorized: false,
|
@@ -220,7 +238,7 @@ async function authorize(authData, serviceConfig, cacheOptions) {
|
|
220
238
|
// cache the retrieved key if we have cache options
|
221
239
|
if (cacheOptions) {
|
222
240
|
// we await this always because it can be a promise or not
|
223
|
-
await cacheOptions.put(
|
241
|
+
await cacheOptions.put(clientId, data);
|
224
242
|
}
|
225
243
|
} catch (err) {
|
226
244
|
console.warn("failed to fetch key metadata from api", err);
|
@@ -253,7 +271,7 @@ async function authorize(authData, serviceConfig, cacheOptions) {
|
|
253
271
|
|
254
272
|
// if we've made it this far we need to check service specific authorization
|
255
273
|
const serviceAuth = authorizeService(apiKeyMeta, serviceConfig, {
|
256
|
-
targetAddress
|
274
|
+
targetAddress
|
257
275
|
});
|
258
276
|
if (!serviceAuth.authorized) {
|
259
277
|
return {
|
@@ -155,8 +155,26 @@ function authorizeService(apiKeyMetadata, serviceConfig, authorizationPayload) {
|
|
155
155
|
}
|
156
156
|
|
157
157
|
async function authorize(authData, serviceConfig, cacheOptions) {
|
158
|
+
const {
|
159
|
+
clientId,
|
160
|
+
targetAddress,
|
161
|
+
secretKeyHash
|
162
|
+
} = authData;
|
163
|
+
const {
|
164
|
+
enforceAuth
|
165
|
+
} = serviceConfig;
|
166
|
+
|
167
|
+
// BACKWARDS COMPAT: if auth not enforced and
|
168
|
+
// we don't have auth credentials bypass
|
169
|
+
if (!enforceAuth && !clientId && !secretKeyHash) {
|
170
|
+
return {
|
171
|
+
authorized: true,
|
172
|
+
apiKeyMeta: null
|
173
|
+
};
|
174
|
+
}
|
175
|
+
|
158
176
|
// if we don't have a client id at this point we can't authorize
|
159
|
-
if (!
|
177
|
+
if (!clientId) {
|
160
178
|
return {
|
161
179
|
authorized: false,
|
162
180
|
status: 401,
|
@@ -168,7 +186,7 @@ async function authorize(authData, serviceConfig, cacheOptions) {
|
|
168
186
|
// if we have cache options we want to check the cache first
|
169
187
|
if (cacheOptions) {
|
170
188
|
try {
|
171
|
-
const cachedKey = await cacheOptions.get(
|
189
|
+
const cachedKey = await cacheOptions.get(clientId);
|
172
190
|
if (cachedKey) {
|
173
191
|
const parsed = JSON.parse(cachedKey);
|
174
192
|
if ("updatedAt" in parsed) {
|
@@ -196,7 +214,7 @@ async function authorize(authData, serviceConfig, cacheOptions) {
|
|
196
214
|
const {
|
197
215
|
data,
|
198
216
|
error
|
199
|
-
} = await fetchKeyMetadataFromApi(
|
217
|
+
} = await fetchKeyMetadataFromApi(clientId, serviceConfig);
|
200
218
|
if (error) {
|
201
219
|
return {
|
202
220
|
authorized: false,
|
@@ -218,7 +236,7 @@ async function authorize(authData, serviceConfig, cacheOptions) {
|
|
218
236
|
// cache the retrieved key if we have cache options
|
219
237
|
if (cacheOptions) {
|
220
238
|
// we await this always because it can be a promise or not
|
221
|
-
await cacheOptions.put(
|
239
|
+
await cacheOptions.put(clientId, data);
|
222
240
|
}
|
223
241
|
} catch (err) {
|
224
242
|
console.warn("failed to fetch key metadata from api", err);
|
@@ -251,7 +269,7 @@ async function authorize(authData, serviceConfig, cacheOptions) {
|
|
251
269
|
|
252
270
|
// if we've made it this far we need to check service specific authorization
|
253
271
|
const serviceAuth = authorizeService(apiKeyMeta, serviceConfig, {
|
254
|
-
targetAddress
|
272
|
+
targetAddress
|
255
273
|
});
|
256
274
|
if (!serviceAuth.authorized) {
|
257
275
|
return {
|
@@ -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-
|
6
|
+
var index = require('../../dist/index-6e980870.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-
|
6
|
+
var index = require('../../dist/index-96491db6.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-
|
2
|
+
import { a as authorize } from '../../dist/index-c332ae71.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