@thirdweb-dev/service-utils 0.0.0-dev-2666fdc-20230713214856 → 0.0.0-dev-d4941e0-20230714040644
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/declarations/src/auth/index.d.ts +0 -2
- package/dist/declarations/src/auth/index.d.ts.map +1 -1
- package/dist/declarations/src/auth/types.d.ts +1 -0
- package/dist/declarations/src/auth/types.d.ts.map +1 -1
- package/dist/thirdweb-dev-service-utils.cjs.dev.js +1 -17
- package/dist/thirdweb-dev-service-utils.cjs.prod.js +1 -17
- package/dist/thirdweb-dev-service-utils.esm.js +2 -12
- package/package.json +1 -4
@@ -1,6 +1,4 @@
|
|
1
1
|
import { AuthorizationResponse, AuthorizeCFWorkerOptions, AuthorizeNodeServiceOptions } from "./types";
|
2
2
|
export declare function authorizeCFWorkerService(options: AuthorizeCFWorkerOptions): Promise<AuthorizationResponse>;
|
3
3
|
export declare function authorizeNodeService(options: AuthorizeNodeServiceOptions): Promise<AuthorizationResponse>;
|
4
|
-
export declare function hashSecret(secret: string): string;
|
5
|
-
export declare function hashClientId(secret: string): string;
|
6
4
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"../../../../src/auth","sources":["index.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"../../../../src/auth","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,qBAAqB,EAErB,wBAAwB,EACxB,2BAA2B,EAE5B,MAAM,SAAS,CAAC;AAEjB,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,wBAAwB,kCAkClC;AAED,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,2BAA2B,kCASrC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"../../../../src/auth","sources":["types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAA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
var fetch = require('isomorphic-unfetch');
|
6
|
-
var crypto = require('crypto');
|
7
|
-
|
8
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
9
|
-
|
10
|
-
var fetch__default = /*#__PURE__*/_interopDefault(fetch);
|
11
|
-
|
12
5
|
const SERVICE_NAMES = ["bundler", "rpc", "storage"];
|
13
6
|
const SERVICES = [{
|
14
7
|
name: "storage",
|
@@ -88,13 +81,6 @@ async function authorizeNodeService(options) {
|
|
88
81
|
validations
|
89
82
|
});
|
90
83
|
}
|
91
|
-
function hashSecret(secret) {
|
92
|
-
return crypto.createHash("sha256").update(secret).digest("hex");
|
93
|
-
}
|
94
|
-
function hashClientId(secret) {
|
95
|
-
const hashed = crypto.createHash("sha256").update(secret).digest("hex");
|
96
|
-
return hashed.slice(0, 32);
|
97
|
-
}
|
98
84
|
|
99
85
|
/**
|
100
86
|
* Authorizes a request for a given client ID
|
@@ -122,7 +108,7 @@ async function authorize(options) {
|
|
122
108
|
|
123
109
|
// no cached key, re-fetch from API
|
124
110
|
if (!keyData) {
|
125
|
-
const response = await
|
111
|
+
const response = await fetch(`${apiUrl}/v1/keys/use?scope=${scope}&clientId=${clientId}`, {
|
126
112
|
method: "GET",
|
127
113
|
headers: {
|
128
114
|
"x-service-api-key": serviceKey,
|
@@ -291,5 +277,3 @@ exports.SERVICE_NAMES = SERVICE_NAMES;
|
|
291
277
|
exports.authorizeCFWorkerService = authorizeCFWorkerService;
|
292
278
|
exports.authorizeNodeService = authorizeNodeService;
|
293
279
|
exports.getServiceByName = getServiceByName;
|
294
|
-
exports.hashClientId = hashClientId;
|
295
|
-
exports.hashSecret = hashSecret;
|
@@ -2,13 +2,6 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var fetch = require('isomorphic-unfetch');
|
6
|
-
var crypto = require('crypto');
|
7
|
-
|
8
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
9
|
-
|
10
|
-
var fetch__default = /*#__PURE__*/_interopDefault(fetch);
|
11
|
-
|
12
5
|
const SERVICE_NAMES = ["bundler", "rpc", "storage"];
|
13
6
|
const SERVICES = [{
|
14
7
|
name: "storage",
|
@@ -88,13 +81,6 @@ async function authorizeNodeService(options) {
|
|
88
81
|
validations
|
89
82
|
});
|
90
83
|
}
|
91
|
-
function hashSecret(secret) {
|
92
|
-
return crypto.createHash("sha256").update(secret).digest("hex");
|
93
|
-
}
|
94
|
-
function hashClientId(secret) {
|
95
|
-
const hashed = crypto.createHash("sha256").update(secret).digest("hex");
|
96
|
-
return hashed.slice(0, 32);
|
97
|
-
}
|
98
84
|
|
99
85
|
/**
|
100
86
|
* Authorizes a request for a given client ID
|
@@ -122,7 +108,7 @@ async function authorize(options) {
|
|
122
108
|
|
123
109
|
// no cached key, re-fetch from API
|
124
110
|
if (!keyData) {
|
125
|
-
const response = await
|
111
|
+
const response = await fetch(`${apiUrl}/v1/keys/use?scope=${scope}&clientId=${clientId}`, {
|
126
112
|
method: "GET",
|
127
113
|
headers: {
|
128
114
|
"x-service-api-key": serviceKey,
|
@@ -291,5 +277,3 @@ exports.SERVICE_NAMES = SERVICE_NAMES;
|
|
291
277
|
exports.authorizeCFWorkerService = authorizeCFWorkerService;
|
292
278
|
exports.authorizeNodeService = authorizeNodeService;
|
293
279
|
exports.getServiceByName = getServiceByName;
|
294
|
-
exports.hashClientId = hashClientId;
|
295
|
-
exports.hashSecret = hashSecret;
|
@@ -1,6 +1,3 @@
|
|
1
|
-
import fetch from 'isomorphic-unfetch';
|
2
|
-
import { createHash } from 'crypto';
|
3
|
-
|
4
1
|
const SERVICE_NAMES = ["bundler", "rpc", "storage"];
|
5
2
|
const SERVICES = [{
|
6
3
|
name: "storage",
|
@@ -80,13 +77,6 @@ async function authorizeNodeService(options) {
|
|
80
77
|
validations
|
81
78
|
});
|
82
79
|
}
|
83
|
-
function hashSecret(secret) {
|
84
|
-
return createHash("sha256").update(secret).digest("hex");
|
85
|
-
}
|
86
|
-
function hashClientId(secret) {
|
87
|
-
const hashed = createHash("sha256").update(secret).digest("hex");
|
88
|
-
return hashed.slice(0, 32);
|
89
|
-
}
|
90
80
|
|
91
81
|
/**
|
92
82
|
* Authorizes a request for a given client ID
|
@@ -114,7 +104,7 @@ async function authorize(options) {
|
|
114
104
|
|
115
105
|
// no cached key, re-fetch from API
|
116
106
|
if (!keyData) {
|
117
|
-
const response = await fetch(`${apiUrl}/v1/keys/use
|
107
|
+
const response = await fetch(`${apiUrl}/v1/keys/use?scope=${scope}&clientId=${clientId}`, {
|
118
108
|
method: "GET",
|
119
109
|
headers: {
|
120
110
|
"x-service-api-key": serviceKey,
|
@@ -278,4 +268,4 @@ function getServiceByName(name) {
|
|
278
268
|
return SERVICES.find(srv => srv.name === name);
|
279
269
|
}
|
280
270
|
|
281
|
-
export { SERVICES, SERVICE_NAMES, authorizeCFWorkerService, authorizeNodeService, getServiceByName
|
271
|
+
export { SERVICES, SERVICE_NAMES, authorizeCFWorkerService, authorizeNodeService, getServiceByName };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@thirdweb-dev/service-utils",
|
3
|
-
"version": "0.0.0-dev-
|
3
|
+
"version": "0.0.0-dev-d4941e0-20230714040644",
|
4
4
|
"main": "dist/thirdweb-dev-service-utils.cjs.js",
|
5
5
|
"module": "dist/thirdweb-dev-service-utils.esm.js",
|
6
6
|
"exports": {
|
@@ -42,9 +42,6 @@
|
|
42
42
|
"eslint-config-thirdweb": "^0.1.5",
|
43
43
|
"typescript": "^5.1.6"
|
44
44
|
},
|
45
|
-
"dependencies": {
|
46
|
-
"isomorphic-unfetch": "^4.0.2"
|
47
|
-
},
|
48
45
|
"scripts": {
|
49
46
|
"format": "prettier --write 'src/**/*'",
|
50
47
|
"lint": "eslint src/",
|