@thirdweb-dev/service-utils 0.1.0 → 0.1.1-nightly-4915ac50-20230714041125

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.
@@ -1,4 +1,4 @@
1
- import { AuthorizationResponse, AuthorizeCFWorkerOptions, AuthorizeNodeServiceOptions } from "./types";
1
+ import type { 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
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
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
+ {"version":3,"file":"index.d.ts","sourceRoot":"../../../../src/auth","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,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,5 +1,5 @@
1
- import { KVNamespace, ExecutionContext } from "@cloudflare/workers-types";
2
- import { ServiceName } from "../types";
1
+ import type { KVNamespace, ExecutionContext } from "@cloudflare/workers-types";
2
+ import type { ServiceName } from "../services";
3
3
  export interface AuthOptions {
4
4
  clientId: string;
5
5
  secretHash?: string;
@@ -1 +1 @@
1
- {"version":3,"file":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): import("./types").Service | undefined;
2
- export * from "./types";
1
+ export * from "./services";
3
2
  export * from "./auth";
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"../../../src","sources":["index.ts"],"names":[],"mappings":"AAEA,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,yCAE5C;AAED,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"../../../src","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC"}
@@ -0,0 +1,101 @@
1
+ export declare const SERVICE_DEFINITIONS: {
2
+ readonly storage: {
3
+ readonly name: "storage";
4
+ readonly title: "Storage";
5
+ readonly description: "IPFS Upload and Download";
6
+ readonly actions: readonly [{
7
+ readonly name: "read";
8
+ readonly title: "Download";
9
+ readonly description: "Download a file from Storage";
10
+ }, {
11
+ readonly name: "write";
12
+ readonly title: "Upload";
13
+ readonly description: "Upload a file to Storage";
14
+ }];
15
+ };
16
+ readonly rpc: {
17
+ readonly name: "rpc";
18
+ readonly title: "RPC";
19
+ readonly description: "Accelerated RPC Edge";
20
+ readonly actions: readonly [];
21
+ };
22
+ readonly bundler: {
23
+ readonly name: "bundler";
24
+ readonly title: "Smart Wallets";
25
+ readonly description: "Bundler & Paymaster services";
26
+ readonly actions: readonly [];
27
+ };
28
+ readonly relayer: {
29
+ readonly name: "relayer";
30
+ readonly title: "Gasless Relayer";
31
+ readonly description: "Enable gasless transactions";
32
+ readonly actions: readonly [];
33
+ };
34
+ };
35
+ export declare const SERVICE_NAMES: ("storage" | "rpc" | "bundler" | "relayer")[];
36
+ export declare const SERVICES: ({
37
+ readonly name: "storage";
38
+ readonly title: "Storage";
39
+ readonly description: "IPFS Upload and Download";
40
+ readonly actions: readonly [{
41
+ readonly name: "read";
42
+ readonly title: "Download";
43
+ readonly description: "Download a file from Storage";
44
+ }, {
45
+ readonly name: "write";
46
+ readonly title: "Upload";
47
+ readonly description: "Upload a file to Storage";
48
+ }];
49
+ } | {
50
+ readonly name: "rpc";
51
+ readonly title: "RPC";
52
+ readonly description: "Accelerated RPC Edge";
53
+ readonly actions: readonly [];
54
+ } | {
55
+ readonly name: "bundler";
56
+ readonly title: "Smart Wallets";
57
+ readonly description: "Bundler & Paymaster services";
58
+ readonly actions: readonly [];
59
+ } | {
60
+ readonly name: "relayer";
61
+ readonly title: "Gasless Relayer";
62
+ readonly description: "Enable gasless transactions";
63
+ readonly actions: readonly [];
64
+ })[];
65
+ export type ServiceName = (typeof SERVICE_NAMES)[number];
66
+ export type ServiceAction = {
67
+ name: string;
68
+ title: string;
69
+ description?: string;
70
+ };
71
+ export type Service = (typeof SERVICE_DEFINITIONS)[keyof typeof SERVICE_DEFINITIONS];
72
+ export declare function getServiceByName(name: ServiceName): {
73
+ readonly name: "storage";
74
+ readonly title: "Storage";
75
+ readonly description: "IPFS Upload and Download";
76
+ readonly actions: readonly [{
77
+ readonly name: "read";
78
+ readonly title: "Download";
79
+ readonly description: "Download a file from Storage";
80
+ }, {
81
+ readonly name: "write";
82
+ readonly title: "Upload";
83
+ readonly description: "Upload a file to Storage";
84
+ }];
85
+ } | {
86
+ readonly name: "rpc";
87
+ readonly title: "RPC";
88
+ readonly description: "Accelerated RPC Edge";
89
+ readonly actions: readonly [];
90
+ } | {
91
+ readonly name: "bundler";
92
+ readonly title: "Smart Wallets";
93
+ readonly description: "Bundler & Paymaster services";
94
+ readonly actions: readonly [];
95
+ } | {
96
+ readonly name: "relayer";
97
+ readonly title: "Gasless Relayer";
98
+ readonly description: "Enable gasless transactions";
99
+ readonly actions: readonly [];
100
+ };
101
+ //# sourceMappingURL=services.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"services.d.ts","sourceRoot":"../../../src","sources":["services.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCtB,CAAC;AAEX,eAAO,MAAM,aAAa,+CAEe,CAAC;AAE1C,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAqC,CAAC;AAE3D,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,OAAO,GACjB,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,OAAO,mBAAmB,CAAC,CAAC;AAEjE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEjD"}
@@ -2,33 +2,48 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const SERVICE_NAMES = ["bundler", "rpc", "storage"];
6
- const SERVICES = [{
7
- name: "storage",
8
- title: "Storage",
9
- description: "IPFS Upload and Download",
10
- actions: [{
11
- name: "read",
12
- title: "Download",
13
- description: "Download a file from Storage"
14
- }, {
15
- name: "write",
16
- title: "Upload",
17
- description: "Upload a file to Storage"
18
- }]
19
- }, {
20
- name: "rpc",
21
- title: "RPC",
22
- description: "Accelerated RPC Edge",
23
- // all actions allowed
24
- actions: []
25
- }, {
26
- name: "bundler",
27
- title: "Smart Wallets",
28
- description: "Bundler & Paymaster services",
29
- // all actions allowed
30
- actions: []
31
- }];
5
+ const SERVICE_DEFINITIONS = {
6
+ storage: {
7
+ name: "storage",
8
+ title: "Storage",
9
+ description: "IPFS Upload and Download",
10
+ actions: [{
11
+ name: "read",
12
+ title: "Download",
13
+ description: "Download a file from Storage"
14
+ }, {
15
+ name: "write",
16
+ title: "Upload",
17
+ description: "Upload a file to Storage"
18
+ }]
19
+ },
20
+ rpc: {
21
+ name: "rpc",
22
+ title: "RPC",
23
+ description: "Accelerated RPC Edge",
24
+ // all actions allowed
25
+ actions: []
26
+ },
27
+ bundler: {
28
+ name: "bundler",
29
+ title: "Smart Wallets",
30
+ description: "Bundler & Paymaster services",
31
+ // all actions allowed
32
+ actions: []
33
+ },
34
+ relayer: {
35
+ name: "relayer",
36
+ title: "Gasless Relayer",
37
+ description: "Enable gasless transactions",
38
+ // all actions allowed
39
+ actions: []
40
+ }
41
+ };
42
+ const SERVICE_NAMES = Object.keys(SERVICE_DEFINITIONS);
43
+ const SERVICES = Object.values(SERVICE_DEFINITIONS);
44
+ function getServiceByName(name) {
45
+ return SERVICE_DEFINITIONS[name];
46
+ }
32
47
 
33
48
  async function authorizeCFWorkerService(options) {
34
49
  const {
@@ -108,7 +123,7 @@ async function authorize(options) {
108
123
 
109
124
  // no cached key, re-fetch from API
110
125
  if (!keyData) {
111
- const response = await fetch(`${apiUrl}/v1/keys/use/?scope=${scope}&clientId=${clientId}`, {
126
+ const response = await fetch(`${apiUrl}/v1/keys/use?scope=${scope}&clientId=${clientId}`, {
112
127
  method: "GET",
113
128
  headers: {
114
129
  "x-service-api-key": serviceKey,
@@ -268,11 +283,8 @@ function authzServices(validations, apiKey, scope) {
268
283
  };
269
284
  }
270
285
 
271
- function getServiceByName(name) {
272
- return SERVICES.find(srv => srv.name === name);
273
- }
274
-
275
286
  exports.SERVICES = SERVICES;
287
+ exports.SERVICE_DEFINITIONS = SERVICE_DEFINITIONS;
276
288
  exports.SERVICE_NAMES = SERVICE_NAMES;
277
289
  exports.authorizeCFWorkerService = authorizeCFWorkerService;
278
290
  exports.authorizeNodeService = authorizeNodeService;
@@ -2,33 +2,48 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const SERVICE_NAMES = ["bundler", "rpc", "storage"];
6
- const SERVICES = [{
7
- name: "storage",
8
- title: "Storage",
9
- description: "IPFS Upload and Download",
10
- actions: [{
11
- name: "read",
12
- title: "Download",
13
- description: "Download a file from Storage"
14
- }, {
15
- name: "write",
16
- title: "Upload",
17
- description: "Upload a file to Storage"
18
- }]
19
- }, {
20
- name: "rpc",
21
- title: "RPC",
22
- description: "Accelerated RPC Edge",
23
- // all actions allowed
24
- actions: []
25
- }, {
26
- name: "bundler",
27
- title: "Smart Wallets",
28
- description: "Bundler & Paymaster services",
29
- // all actions allowed
30
- actions: []
31
- }];
5
+ const SERVICE_DEFINITIONS = {
6
+ storage: {
7
+ name: "storage",
8
+ title: "Storage",
9
+ description: "IPFS Upload and Download",
10
+ actions: [{
11
+ name: "read",
12
+ title: "Download",
13
+ description: "Download a file from Storage"
14
+ }, {
15
+ name: "write",
16
+ title: "Upload",
17
+ description: "Upload a file to Storage"
18
+ }]
19
+ },
20
+ rpc: {
21
+ name: "rpc",
22
+ title: "RPC",
23
+ description: "Accelerated RPC Edge",
24
+ // all actions allowed
25
+ actions: []
26
+ },
27
+ bundler: {
28
+ name: "bundler",
29
+ title: "Smart Wallets",
30
+ description: "Bundler & Paymaster services",
31
+ // all actions allowed
32
+ actions: []
33
+ },
34
+ relayer: {
35
+ name: "relayer",
36
+ title: "Gasless Relayer",
37
+ description: "Enable gasless transactions",
38
+ // all actions allowed
39
+ actions: []
40
+ }
41
+ };
42
+ const SERVICE_NAMES = Object.keys(SERVICE_DEFINITIONS);
43
+ const SERVICES = Object.values(SERVICE_DEFINITIONS);
44
+ function getServiceByName(name) {
45
+ return SERVICE_DEFINITIONS[name];
46
+ }
32
47
 
33
48
  async function authorizeCFWorkerService(options) {
34
49
  const {
@@ -108,7 +123,7 @@ async function authorize(options) {
108
123
 
109
124
  // no cached key, re-fetch from API
110
125
  if (!keyData) {
111
- const response = await fetch(`${apiUrl}/v1/keys/use/?scope=${scope}&clientId=${clientId}`, {
126
+ const response = await fetch(`${apiUrl}/v1/keys/use?scope=${scope}&clientId=${clientId}`, {
112
127
  method: "GET",
113
128
  headers: {
114
129
  "x-service-api-key": serviceKey,
@@ -268,11 +283,8 @@ function authzServices(validations, apiKey, scope) {
268
283
  };
269
284
  }
270
285
 
271
- function getServiceByName(name) {
272
- return SERVICES.find(srv => srv.name === name);
273
- }
274
-
275
286
  exports.SERVICES = SERVICES;
287
+ exports.SERVICE_DEFINITIONS = SERVICE_DEFINITIONS;
276
288
  exports.SERVICE_NAMES = SERVICE_NAMES;
277
289
  exports.authorizeCFWorkerService = authorizeCFWorkerService;
278
290
  exports.authorizeNodeService = authorizeNodeService;
@@ -1,30 +1,45 @@
1
- const SERVICE_NAMES = ["bundler", "rpc", "storage"];
2
- const SERVICES = [{
3
- name: "storage",
4
- title: "Storage",
5
- description: "IPFS Upload and Download",
6
- actions: [{
7
- name: "read",
8
- title: "Download",
9
- description: "Download a file from Storage"
10
- }, {
11
- name: "write",
12
- title: "Upload",
13
- description: "Upload a file to Storage"
14
- }]
15
- }, {
16
- name: "rpc",
17
- title: "RPC",
18
- description: "Accelerated RPC Edge",
19
- // all actions allowed
20
- actions: []
21
- }, {
22
- name: "bundler",
23
- title: "Smart Wallets",
24
- description: "Bundler & Paymaster services",
25
- // all actions allowed
26
- actions: []
27
- }];
1
+ const SERVICE_DEFINITIONS = {
2
+ storage: {
3
+ name: "storage",
4
+ title: "Storage",
5
+ description: "IPFS Upload and Download",
6
+ actions: [{
7
+ name: "read",
8
+ title: "Download",
9
+ description: "Download a file from Storage"
10
+ }, {
11
+ name: "write",
12
+ title: "Upload",
13
+ description: "Upload a file to Storage"
14
+ }]
15
+ },
16
+ rpc: {
17
+ name: "rpc",
18
+ title: "RPC",
19
+ description: "Accelerated RPC Edge",
20
+ // all actions allowed
21
+ actions: []
22
+ },
23
+ bundler: {
24
+ name: "bundler",
25
+ title: "Smart Wallets",
26
+ description: "Bundler & Paymaster services",
27
+ // all actions allowed
28
+ actions: []
29
+ },
30
+ relayer: {
31
+ name: "relayer",
32
+ title: "Gasless Relayer",
33
+ description: "Enable gasless transactions",
34
+ // all actions allowed
35
+ actions: []
36
+ }
37
+ };
38
+ const SERVICE_NAMES = Object.keys(SERVICE_DEFINITIONS);
39
+ const SERVICES = Object.values(SERVICE_DEFINITIONS);
40
+ function getServiceByName(name) {
41
+ return SERVICE_DEFINITIONS[name];
42
+ }
28
43
 
29
44
  async function authorizeCFWorkerService(options) {
30
45
  const {
@@ -104,7 +119,7 @@ async function authorize(options) {
104
119
 
105
120
  // no cached key, re-fetch from API
106
121
  if (!keyData) {
107
- const response = await fetch(`${apiUrl}/v1/keys/use/?scope=${scope}&clientId=${clientId}`, {
122
+ const response = await fetch(`${apiUrl}/v1/keys/use?scope=${scope}&clientId=${clientId}`, {
108
123
  method: "GET",
109
124
  headers: {
110
125
  "x-service-api-key": serviceKey,
@@ -264,8 +279,4 @@ function authzServices(validations, apiKey, scope) {
264
279
  };
265
280
  }
266
281
 
267
- function getServiceByName(name) {
268
- return SERVICES.find(srv => srv.name === name);
269
- }
270
-
271
- export { SERVICES, SERVICE_NAMES, authorizeCFWorkerService, authorizeNodeService, getServiceByName };
282
+ export { SERVICES, SERVICE_DEFINITIONS, 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.1.0",
3
+ "version": "0.1.1-nightly-4915ac50-20230714041125",
4
4
  "main": "dist/thirdweb-dev-service-utils.cjs.js",
5
5
  "module": "dist/thirdweb-dev-service-utils.esm.js",
6
6
  "exports": {
@@ -1,15 +0,0 @@
1
- export declare const SERVICE_NAMES: readonly ["bundler", "rpc", "storage"];
2
- export declare const SERVICES: Service[];
3
- export type ServiceName = (typeof SERVICE_NAMES)[number];
4
- export interface ServiceAction {
5
- name: string;
6
- title: string;
7
- description?: string;
8
- }
9
- export interface Service {
10
- name: ServiceName;
11
- title: string;
12
- description?: string;
13
- actions: ServiceAction[];
14
- }
15
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"../../../src","sources":["types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,wCAAyC,CAAC;AAEpE,eAAO,MAAM,QAAQ,EAAE,OAAO,EAgC7B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,aAAa,EAAE,CAAC;CAC1B"}