@thirdweb-dev/service-utils 0.2.0-nightly-5eb6fc1b-20230714082745 → 0.2.0-nightly-781e26d8-20230714165556
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/{index-294e111f.esm.js → index-1125bae0.esm.js} +28 -5
- package/dist/{index-3060948e.cjs.prod.js → index-bc2b86a5.cjs.prod.js} +28 -5
- package/dist/{index-fcf69a55.cjs.dev.js → index-ded83ecc.cjs.dev.js} +28 -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-ded83ecc.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-bc2b86a5.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-1125bae0.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;
|
@@ -7,7 +7,7 @@ async function fetchKeyMetadataFromApi(clientId, config) {
|
|
7
7
|
const url = new URL(`${apiUrl}/v1/keys/use`);
|
8
8
|
url.searchParams.set("clientId", clientId);
|
9
9
|
url.searchParams.set("scope", serviceScope);
|
10
|
-
const response = await fetch(url, {
|
10
|
+
const response = await fetch(url.href, {
|
11
11
|
method: "GET",
|
12
12
|
headers: {
|
13
13
|
"x-service-api-key": serviceApiKey,
|
@@ -23,10 +23,12 @@ async function fetchKeyMetadataFromApi(clientId, config) {
|
|
23
23
|
function authorizeClient(authOptions, apiKeyMeta) {
|
24
24
|
const {
|
25
25
|
origin,
|
26
|
+
bundleId,
|
26
27
|
secretKeyHash: providedSecretHash
|
27
28
|
} = authOptions;
|
28
29
|
const {
|
29
30
|
domains,
|
31
|
+
bundleIds,
|
30
32
|
secretHash
|
31
33
|
} = apiKeyMeta;
|
32
34
|
if (providedSecretHash) {
|
@@ -76,7 +78,28 @@ function authorizeClient(authOptions, apiKeyMeta) {
|
|
76
78
|
};
|
77
79
|
}
|
78
80
|
|
79
|
-
//
|
81
|
+
// validate bundleId
|
82
|
+
if (bundleId) {
|
83
|
+
if (
|
84
|
+
// find matching bundle id, or if all bundles allowed
|
85
|
+
bundleIds.find(b => {
|
86
|
+
if (b === "*") {
|
87
|
+
return true;
|
88
|
+
}
|
89
|
+
return b === bundleId;
|
90
|
+
})) {
|
91
|
+
return {
|
92
|
+
authorized: true,
|
93
|
+
apiKeyMeta
|
94
|
+
};
|
95
|
+
}
|
96
|
+
return {
|
97
|
+
authorized: false,
|
98
|
+
errorMessage: "The bundle is not authorized for this key.",
|
99
|
+
errorCode: "BUNDLE_UNAUTHORIZED",
|
100
|
+
status: 401
|
101
|
+
};
|
102
|
+
}
|
80
103
|
return {
|
81
104
|
authorized: false,
|
82
105
|
errorMessage: "The keys are invalid.",
|
@@ -85,10 +108,10 @@ function authorizeClient(authOptions, apiKeyMeta) {
|
|
85
108
|
};
|
86
109
|
}
|
87
110
|
|
88
|
-
function authorizeService(
|
111
|
+
function authorizeService(apiKeyMetadata, serviceConfig, authorizationPayload) {
|
89
112
|
const {
|
90
113
|
services
|
91
|
-
} =
|
114
|
+
} = apiKeyMetadata;
|
92
115
|
// const { serviceTargetAddresses, serviceAction } = validations;
|
93
116
|
|
94
117
|
// validate services
|
@@ -130,7 +153,7 @@ function authorizeService(apikeyMetadata, serviceConfig, authorizationPayload) {
|
|
130
153
|
}
|
131
154
|
return {
|
132
155
|
authorized: true,
|
133
|
-
apiKeyMeta:
|
156
|
+
apiKeyMeta: apiKeyMetadata
|
134
157
|
};
|
135
158
|
}
|
136
159
|
|
@@ -9,7 +9,7 @@ async function fetchKeyMetadataFromApi(clientId, config) {
|
|
9
9
|
const url = new URL(`${apiUrl}/v1/keys/use`);
|
10
10
|
url.searchParams.set("clientId", clientId);
|
11
11
|
url.searchParams.set("scope", serviceScope);
|
12
|
-
const response = await fetch(url, {
|
12
|
+
const response = await fetch(url.href, {
|
13
13
|
method: "GET",
|
14
14
|
headers: {
|
15
15
|
"x-service-api-key": serviceApiKey,
|
@@ -25,10 +25,12 @@ async function fetchKeyMetadataFromApi(clientId, config) {
|
|
25
25
|
function authorizeClient(authOptions, apiKeyMeta) {
|
26
26
|
const {
|
27
27
|
origin,
|
28
|
+
bundleId,
|
28
29
|
secretKeyHash: providedSecretHash
|
29
30
|
} = authOptions;
|
30
31
|
const {
|
31
32
|
domains,
|
33
|
+
bundleIds,
|
32
34
|
secretHash
|
33
35
|
} = apiKeyMeta;
|
34
36
|
if (providedSecretHash) {
|
@@ -78,7 +80,28 @@ function authorizeClient(authOptions, apiKeyMeta) {
|
|
78
80
|
};
|
79
81
|
}
|
80
82
|
|
81
|
-
//
|
83
|
+
// validate bundleId
|
84
|
+
if (bundleId) {
|
85
|
+
if (
|
86
|
+
// find matching bundle id, or if all bundles allowed
|
87
|
+
bundleIds.find(b => {
|
88
|
+
if (b === "*") {
|
89
|
+
return true;
|
90
|
+
}
|
91
|
+
return b === bundleId;
|
92
|
+
})) {
|
93
|
+
return {
|
94
|
+
authorized: true,
|
95
|
+
apiKeyMeta
|
96
|
+
};
|
97
|
+
}
|
98
|
+
return {
|
99
|
+
authorized: false,
|
100
|
+
errorMessage: "The bundle is not authorized for this key.",
|
101
|
+
errorCode: "BUNDLE_UNAUTHORIZED",
|
102
|
+
status: 401
|
103
|
+
};
|
104
|
+
}
|
82
105
|
return {
|
83
106
|
authorized: false,
|
84
107
|
errorMessage: "The keys are invalid.",
|
@@ -87,10 +110,10 @@ function authorizeClient(authOptions, apiKeyMeta) {
|
|
87
110
|
};
|
88
111
|
}
|
89
112
|
|
90
|
-
function authorizeService(
|
113
|
+
function authorizeService(apiKeyMetadata, serviceConfig, authorizationPayload) {
|
91
114
|
const {
|
92
115
|
services
|
93
|
-
} =
|
116
|
+
} = apiKeyMetadata;
|
94
117
|
// const { serviceTargetAddresses, serviceAction } = validations;
|
95
118
|
|
96
119
|
// validate services
|
@@ -132,7 +155,7 @@ function authorizeService(apikeyMetadata, serviceConfig, authorizationPayload) {
|
|
132
155
|
}
|
133
156
|
return {
|
134
157
|
authorized: true,
|
135
|
-
apiKeyMeta:
|
158
|
+
apiKeyMeta: apiKeyMetadata
|
136
159
|
};
|
137
160
|
}
|
138
161
|
|
@@ -9,7 +9,7 @@ async function fetchKeyMetadataFromApi(clientId, config) {
|
|
9
9
|
const url = new URL(`${apiUrl}/v1/keys/use`);
|
10
10
|
url.searchParams.set("clientId", clientId);
|
11
11
|
url.searchParams.set("scope", serviceScope);
|
12
|
-
const response = await fetch(url, {
|
12
|
+
const response = await fetch(url.href, {
|
13
13
|
method: "GET",
|
14
14
|
headers: {
|
15
15
|
"x-service-api-key": serviceApiKey,
|
@@ -25,10 +25,12 @@ async function fetchKeyMetadataFromApi(clientId, config) {
|
|
25
25
|
function authorizeClient(authOptions, apiKeyMeta) {
|
26
26
|
const {
|
27
27
|
origin,
|
28
|
+
bundleId,
|
28
29
|
secretKeyHash: providedSecretHash
|
29
30
|
} = authOptions;
|
30
31
|
const {
|
31
32
|
domains,
|
33
|
+
bundleIds,
|
32
34
|
secretHash
|
33
35
|
} = apiKeyMeta;
|
34
36
|
if (providedSecretHash) {
|
@@ -78,7 +80,28 @@ function authorizeClient(authOptions, apiKeyMeta) {
|
|
78
80
|
};
|
79
81
|
}
|
80
82
|
|
81
|
-
//
|
83
|
+
// validate bundleId
|
84
|
+
if (bundleId) {
|
85
|
+
if (
|
86
|
+
// find matching bundle id, or if all bundles allowed
|
87
|
+
bundleIds.find(b => {
|
88
|
+
if (b === "*") {
|
89
|
+
return true;
|
90
|
+
}
|
91
|
+
return b === bundleId;
|
92
|
+
})) {
|
93
|
+
return {
|
94
|
+
authorized: true,
|
95
|
+
apiKeyMeta
|
96
|
+
};
|
97
|
+
}
|
98
|
+
return {
|
99
|
+
authorized: false,
|
100
|
+
errorMessage: "The bundle is not authorized for this key.",
|
101
|
+
errorCode: "BUNDLE_UNAUTHORIZED",
|
102
|
+
status: 401
|
103
|
+
};
|
104
|
+
}
|
82
105
|
return {
|
83
106
|
authorized: false,
|
84
107
|
errorMessage: "The keys are invalid.",
|
@@ -87,10 +110,10 @@ function authorizeClient(authOptions, apiKeyMeta) {
|
|
87
110
|
};
|
88
111
|
}
|
89
112
|
|
90
|
-
function authorizeService(
|
113
|
+
function authorizeService(apiKeyMetadata, serviceConfig, authorizationPayload) {
|
91
114
|
const {
|
92
115
|
services
|
93
|
-
} =
|
116
|
+
} = apiKeyMetadata;
|
94
117
|
// const { serviceTargetAddresses, serviceAction } = validations;
|
95
118
|
|
96
119
|
// validate services
|
@@ -132,7 +155,7 @@ function authorizeService(apikeyMetadata, serviceConfig, authorizationPayload) {
|
|
132
155
|
}
|
133
156
|
return {
|
134
157
|
authorized: true,
|
135
|
-
apiKeyMeta:
|
158
|
+
apiKeyMeta: apiKeyMetadata
|
136
159
|
};
|
137
160
|
}
|
138
161
|
|
@@ -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-ded83ecc.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-bc2b86a5.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-1125bae0.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.2.0-nightly-
|
3
|
+
"version": "0.2.0-nightly-781e26d8-20230714165556",
|
4
4
|
"main": "dist/thirdweb-dev-service-utils.cjs.js",
|
5
5
|
"module": "dist/thirdweb-dev-service-utils.esm.js",
|
6
6
|
"exports": {
|