@thirdweb-dev/service-utils 0.3.0-nightly-5ee700e8-20230803010712 → 0.3.0-nightly-5ec0f064-20230803205151

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.
@@ -4,6 +4,82 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var index = require('../../dist/index-6e878a86.cjs.dev.js');
6
6
  var services = require('../../dist/services-a3f36057.cjs.dev.js');
7
+ var aws4fetch = require('aws4fetch');
8
+ var zod = require('zod');
9
+
10
+ // Initialize a singleton for aws usage.
11
+ let _aws;
12
+ function getAws(options) {
13
+ if (!_aws) {
14
+ _aws = new aws4fetch.AwsClient(options);
15
+ }
16
+ return _aws;
17
+ }
18
+
19
+ /**
20
+ * Types
21
+ */
22
+ zod.z.object({
23
+ source: zod.z.enum(["wallet", "rpc", "storage", "bundler", "paymaster", "relayer"]),
24
+ action: zod.z.string(),
25
+ accountId: zod.z.string(),
26
+ // Optional
27
+ apiKeyId: zod.z.string().optional(),
28
+ creatorWalletAddress: zod.z.string().optional(),
29
+ clientId: zod.z.string().optional(),
30
+ walletAddress: zod.z.string().optional(),
31
+ chainId: zod.z.number().int().positive().optional(),
32
+ provider: zod.z.string().optional(),
33
+ mimeType: zod.z.string().optional(),
34
+ fileSize: zod.z.number().int().nonnegative().optional(),
35
+ fileCid: zod.z.string().optional(),
36
+ transactionHash: zod.z.string().optional(),
37
+ gasLimit: zod.z.number().nonnegative().optional(),
38
+ gasPricePerUnit: zod.z.string().optional()
39
+ });
40
+ /**
41
+ * Publish usage events. Provide the relevant fields for your application.
42
+ *
43
+ * Usage in Cloudflare Workers:
44
+ * ctx.waitUntil(
45
+ * publishUsageEvents(
46
+ * [event1, event2],
47
+ * { queueUrl, accessKeyId, secretAccessKey },
48
+ * )
49
+ * )
50
+ *
51
+ * @param usageEvents
52
+ * @param config
53
+ */
54
+ async function publishUsageEvents(usageEvents, config) {
55
+ const {
56
+ queueUrl,
57
+ accessKeyId,
58
+ secretAccessKey,
59
+ region = "us-west-2"
60
+ } = config;
61
+ const entries = usageEvents.map(event => ({
62
+ Id: crypto.randomUUID(),
63
+ MessageBody: JSON.stringify(event)
64
+ }));
65
+ const aws = getAws({
66
+ accessKeyId,
67
+ secretAccessKey,
68
+ region
69
+ });
70
+ const res = await aws.fetch(`https://sqs.${region}.amazonaws.com`, {
71
+ headers: {
72
+ "X-Amz-Target": "AmazonSQS.SendMessageBatch",
73
+ "X-Amz-Date": new Date().toISOString(),
74
+ "Content-Type": "application/x-amz-json-1.0"
75
+ },
76
+ body: JSON.stringify({
77
+ QueueUrl: queueUrl,
78
+ Entries: entries
79
+ })
80
+ });
81
+ return await res.text();
82
+ }
7
83
 
8
84
  const DEFAULT_CACHE_TTL_SECONDS = 60;
9
85
  async function authorizeWorker(authInput, serviceConfig) {
@@ -126,3 +202,4 @@ exports.getServiceByName = services.getServiceByName;
126
202
  exports.authorizeWorker = authorizeWorker;
127
203
  exports.deriveClientIdFromSecretKeyHash = deriveClientIdFromSecretKeyHash;
128
204
  exports.hashSecretKey = hashSecretKey;
205
+ exports.publishUsageEvents = publishUsageEvents;
@@ -4,6 +4,82 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var index = require('../../dist/index-bd1fbe19.cjs.prod.js');
6
6
  var services = require('../../dist/services-9e185105.cjs.prod.js');
7
+ var aws4fetch = require('aws4fetch');
8
+ var zod = require('zod');
9
+
10
+ // Initialize a singleton for aws usage.
11
+ let _aws;
12
+ function getAws(options) {
13
+ if (!_aws) {
14
+ _aws = new aws4fetch.AwsClient(options);
15
+ }
16
+ return _aws;
17
+ }
18
+
19
+ /**
20
+ * Types
21
+ */
22
+ zod.z.object({
23
+ source: zod.z.enum(["wallet", "rpc", "storage", "bundler", "paymaster", "relayer"]),
24
+ action: zod.z.string(),
25
+ accountId: zod.z.string(),
26
+ // Optional
27
+ apiKeyId: zod.z.string().optional(),
28
+ creatorWalletAddress: zod.z.string().optional(),
29
+ clientId: zod.z.string().optional(),
30
+ walletAddress: zod.z.string().optional(),
31
+ chainId: zod.z.number().int().positive().optional(),
32
+ provider: zod.z.string().optional(),
33
+ mimeType: zod.z.string().optional(),
34
+ fileSize: zod.z.number().int().nonnegative().optional(),
35
+ fileCid: zod.z.string().optional(),
36
+ transactionHash: zod.z.string().optional(),
37
+ gasLimit: zod.z.number().nonnegative().optional(),
38
+ gasPricePerUnit: zod.z.string().optional()
39
+ });
40
+ /**
41
+ * Publish usage events. Provide the relevant fields for your application.
42
+ *
43
+ * Usage in Cloudflare Workers:
44
+ * ctx.waitUntil(
45
+ * publishUsageEvents(
46
+ * [event1, event2],
47
+ * { queueUrl, accessKeyId, secretAccessKey },
48
+ * )
49
+ * )
50
+ *
51
+ * @param usageEvents
52
+ * @param config
53
+ */
54
+ async function publishUsageEvents(usageEvents, config) {
55
+ const {
56
+ queueUrl,
57
+ accessKeyId,
58
+ secretAccessKey,
59
+ region = "us-west-2"
60
+ } = config;
61
+ const entries = usageEvents.map(event => ({
62
+ Id: crypto.randomUUID(),
63
+ MessageBody: JSON.stringify(event)
64
+ }));
65
+ const aws = getAws({
66
+ accessKeyId,
67
+ secretAccessKey,
68
+ region
69
+ });
70
+ const res = await aws.fetch(`https://sqs.${region}.amazonaws.com`, {
71
+ headers: {
72
+ "X-Amz-Target": "AmazonSQS.SendMessageBatch",
73
+ "X-Amz-Date": new Date().toISOString(),
74
+ "Content-Type": "application/x-amz-json-1.0"
75
+ },
76
+ body: JSON.stringify({
77
+ QueueUrl: queueUrl,
78
+ Entries: entries
79
+ })
80
+ });
81
+ return await res.text();
82
+ }
7
83
 
8
84
  const DEFAULT_CACHE_TTL_SECONDS = 60;
9
85
  async function authorizeWorker(authInput, serviceConfig) {
@@ -126,3 +202,4 @@ exports.getServiceByName = services.getServiceByName;
126
202
  exports.authorizeWorker = authorizeWorker;
127
203
  exports.deriveClientIdFromSecretKeyHash = deriveClientIdFromSecretKeyHash;
128
204
  exports.hashSecretKey = hashSecretKey;
205
+ exports.publishUsageEvents = publishUsageEvents;
@@ -1,5 +1,81 @@
1
1
  import { a as authorize } from '../../dist/index-f4c85072.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
+ import { AwsClient } from 'aws4fetch';
4
+ import { z } from 'zod';
5
+
6
+ // Initialize a singleton for aws usage.
7
+ let _aws;
8
+ function getAws(options) {
9
+ if (!_aws) {
10
+ _aws = new AwsClient(options);
11
+ }
12
+ return _aws;
13
+ }
14
+
15
+ /**
16
+ * Types
17
+ */
18
+ z.object({
19
+ source: z.enum(["wallet", "rpc", "storage", "bundler", "paymaster", "relayer"]),
20
+ action: z.string(),
21
+ accountId: z.string(),
22
+ // Optional
23
+ apiKeyId: z.string().optional(),
24
+ creatorWalletAddress: z.string().optional(),
25
+ clientId: z.string().optional(),
26
+ walletAddress: z.string().optional(),
27
+ chainId: z.number().int().positive().optional(),
28
+ provider: z.string().optional(),
29
+ mimeType: z.string().optional(),
30
+ fileSize: z.number().int().nonnegative().optional(),
31
+ fileCid: z.string().optional(),
32
+ transactionHash: z.string().optional(),
33
+ gasLimit: z.number().nonnegative().optional(),
34
+ gasPricePerUnit: z.string().optional()
35
+ });
36
+ /**
37
+ * Publish usage events. Provide the relevant fields for your application.
38
+ *
39
+ * Usage in Cloudflare Workers:
40
+ * ctx.waitUntil(
41
+ * publishUsageEvents(
42
+ * [event1, event2],
43
+ * { queueUrl, accessKeyId, secretAccessKey },
44
+ * )
45
+ * )
46
+ *
47
+ * @param usageEvents
48
+ * @param config
49
+ */
50
+ async function publishUsageEvents(usageEvents, config) {
51
+ const {
52
+ queueUrl,
53
+ accessKeyId,
54
+ secretAccessKey,
55
+ region = "us-west-2"
56
+ } = config;
57
+ const entries = usageEvents.map(event => ({
58
+ Id: crypto.randomUUID(),
59
+ MessageBody: JSON.stringify(event)
60
+ }));
61
+ const aws = getAws({
62
+ accessKeyId,
63
+ secretAccessKey,
64
+ region
65
+ });
66
+ const res = await aws.fetch(`https://sqs.${region}.amazonaws.com`, {
67
+ headers: {
68
+ "X-Amz-Target": "AmazonSQS.SendMessageBatch",
69
+ "X-Amz-Date": new Date().toISOString(),
70
+ "Content-Type": "application/x-amz-json-1.0"
71
+ },
72
+ body: JSON.stringify({
73
+ QueueUrl: queueUrl,
74
+ Entries: entries
75
+ })
76
+ });
77
+ return await res.text();
78
+ }
3
79
 
4
80
  const DEFAULT_CACHE_TTL_SECONDS = 60;
5
81
  async function authorizeWorker(authInput, serviceConfig) {
@@ -115,4 +191,4 @@ function bufferToHex(buffer) {
115
191
  return [...new Uint8Array(buffer)].map(x => x.toString(16).padStart(2, "0")).join("");
116
192
  }
117
193
 
118
- export { authorizeWorker, deriveClientIdFromSecretKeyHash, hashSecretKey };
194
+ export { authorizeWorker, deriveClientIdFromSecretKeyHash, hashSecretKey, publishUsageEvents };
@@ -4,6 +4,7 @@ import type { Request } from "@cloudflare/workers-types";
4
4
  import type { AuthorizationResult } from "../core/authorize/types";
5
5
  import type { CoreAuthInput } from "../core/types";
6
6
  export * from "../core/services";
7
+ export * from "./usage";
7
8
  type WorkerServiceConfig = CoreServiceConfig & {
8
9
  kvStore: KVNamespace;
9
10
  ctx: ExecutionContext;
@@ -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,EAGV,iBAAiB,EAClB,MAAM,aAAa,CAAC;AAGrB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,cAAc,kBAAkB,CAAC;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;AAiFD,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,EAGV,iBAAiB,EAClB,MAAM,aAAa,CAAC;AAGrB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC;AAExB,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;AAiFD,wBAAsB,aAAa,CAAC,SAAS,EAAE,MAAM,mBAIpD;AAED,wBAAgB,+BAA+B,CAAC,aAAa,EAAE,MAAM,UAEpE"}
@@ -1,5 +1,4 @@
1
1
  import { z } from "zod";
2
- import { AwsCredentialIdentity } from "@smithy/types";
3
2
  /**
4
3
  * Types
5
4
  */
@@ -56,13 +55,22 @@ export type UsageEvent = z.infer<typeof usageEventSchema>;
56
55
  /**
57
56
  * Publish usage events. Provide the relevant fields for your application.
58
57
  *
58
+ * Usage in Cloudflare Workers:
59
+ * ctx.waitUntil(
60
+ * publishUsageEvents(
61
+ * [event1, event2],
62
+ * { queueUrl, accessKeyId, secretAccessKey },
63
+ * )
64
+ * )
65
+ *
59
66
  * @param usageEvents
60
67
  * @param config
61
68
  */
62
69
  export declare function publishUsageEvents(usageEvents: UsageEvent[], config: {
63
70
  queueUrl: string;
71
+ accessKeyId: string;
72
+ secretAccessKey: string;
64
73
  region?: string;
65
- credentials?: AwsCredentialIdentity;
66
- }): Promise<void>;
74
+ }): Promise<string>;
67
75
  export {};
68
76
  //# sourceMappingURL=usage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage.d.ts","sourceRoot":"../../../../src/cf-worker","sources":["usage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB;;GAEG;AACH,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyBpB,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D;;;;;;;;;;;;;GAaG;AACH,wBAAsB,kBAAkB,CACtC,WAAW,EAAE,UAAU,EAAE,EACzB,MAAM,EAAE;IACN,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GACA,OAAO,CAAC,MAAM,CAAC,CA8BjB"}
@@ -1,3 +1,2 @@
1
1
  export * from "./core/services";
2
- export * from "./core/usage";
3
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"../../../src","sources":["index.ts"],"names":[],"mappings":"AACA,cAAc,iBAAiB,CAAC;AAGhC,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"../../../src","sources":["index.ts"],"names":[],"mappings":"AACA,cAAc,iBAAiB,CAAC"}
@@ -3,74 +3,10 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var services = require('./services-a3f36057.cjs.dev.js');
6
- var zod = require('zod');
7
- var clientSqs = require('@aws-sdk/client-sqs');
8
- var crypto = require('crypto');
9
6
 
10
- let sqs;
11
- function getSqs(_ref) {
12
- let {
13
- region,
14
- credentials
15
- } = _ref;
16
- if (!sqs) {
17
- sqs = new clientSqs.SQSClient({
18
- region,
19
- credentials
20
- });
21
- }
22
- return sqs;
23
- }
24
7
 
25
- /**
26
- * Types
27
- */
28
- const usageEventSchema = zod.z.object({
29
- source: zod.z.enum(["wallet", "rpc", "storage", "bundler", "paymaster", "relayer"]),
30
- action: zod.z.string(),
31
- accountId: zod.z.string(),
32
- // Optional
33
- apiKeyId: zod.z.string().optional(),
34
- creatorWalletAddress: zod.z.string().optional(),
35
- clientId: zod.z.string().optional(),
36
- walletAddress: zod.z.string().optional(),
37
- chainId: zod.z.number().int().positive().optional(),
38
- provider: zod.z.string().optional(),
39
- mimeType: zod.z.string().optional(),
40
- fileSize: zod.z.number().int().nonnegative().optional(),
41
- fileCid: zod.z.string().optional(),
42
- transactionHash: zod.z.string().optional(),
43
- gasLimit: zod.z.number().nonnegative().optional(),
44
- gasPricePerUnit: zod.z.string().optional()
45
- });
46
- /**
47
- * Publish usage events. Provide the relevant fields for your application.
48
- *
49
- * @param usageEvents
50
- * @param config
51
- */
52
- async function publishUsageEvents(usageEvents, config) {
53
- const {
54
- queueUrl,
55
- region = "us-west-2",
56
- credentials
57
- } = config;
58
- const entries = usageEvents.map(event => ({
59
- Id: crypto.randomUUID(),
60
- MessageBody: JSON.stringify(usageEventSchema.parse(event))
61
- }));
62
- const input = new clientSqs.SendMessageBatchCommand({
63
- QueueUrl: queueUrl,
64
- Entries: entries
65
- });
66
- await getSqs({
67
- region,
68
- credentials
69
- }).send(input);
70
- }
71
8
 
72
9
  exports.SERVICES = services.SERVICES;
73
10
  exports.SERVICE_DEFINITIONS = services.SERVICE_DEFINITIONS;
74
11
  exports.SERVICE_NAMES = services.SERVICE_NAMES;
75
12
  exports.getServiceByName = services.getServiceByName;
76
- exports.publishUsageEvents = publishUsageEvents;
@@ -3,74 +3,10 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var services = require('./services-9e185105.cjs.prod.js');
6
- var zod = require('zod');
7
- var clientSqs = require('@aws-sdk/client-sqs');
8
- var crypto = require('crypto');
9
6
 
10
- let sqs;
11
- function getSqs(_ref) {
12
- let {
13
- region,
14
- credentials
15
- } = _ref;
16
- if (!sqs) {
17
- sqs = new clientSqs.SQSClient({
18
- region,
19
- credentials
20
- });
21
- }
22
- return sqs;
23
- }
24
7
 
25
- /**
26
- * Types
27
- */
28
- const usageEventSchema = zod.z.object({
29
- source: zod.z.enum(["wallet", "rpc", "storage", "bundler", "paymaster", "relayer"]),
30
- action: zod.z.string(),
31
- accountId: zod.z.string(),
32
- // Optional
33
- apiKeyId: zod.z.string().optional(),
34
- creatorWalletAddress: zod.z.string().optional(),
35
- clientId: zod.z.string().optional(),
36
- walletAddress: zod.z.string().optional(),
37
- chainId: zod.z.number().int().positive().optional(),
38
- provider: zod.z.string().optional(),
39
- mimeType: zod.z.string().optional(),
40
- fileSize: zod.z.number().int().nonnegative().optional(),
41
- fileCid: zod.z.string().optional(),
42
- transactionHash: zod.z.string().optional(),
43
- gasLimit: zod.z.number().nonnegative().optional(),
44
- gasPricePerUnit: zod.z.string().optional()
45
- });
46
- /**
47
- * Publish usage events. Provide the relevant fields for your application.
48
- *
49
- * @param usageEvents
50
- * @param config
51
- */
52
- async function publishUsageEvents(usageEvents, config) {
53
- const {
54
- queueUrl,
55
- region = "us-west-2",
56
- credentials
57
- } = config;
58
- const entries = usageEvents.map(event => ({
59
- Id: crypto.randomUUID(),
60
- MessageBody: JSON.stringify(usageEventSchema.parse(event))
61
- }));
62
- const input = new clientSqs.SendMessageBatchCommand({
63
- QueueUrl: queueUrl,
64
- Entries: entries
65
- });
66
- await getSqs({
67
- region,
68
- credentials
69
- }).send(input);
70
- }
71
8
 
72
9
  exports.SERVICES = services.SERVICES;
73
10
  exports.SERVICE_DEFINITIONS = services.SERVICE_DEFINITIONS;
74
11
  exports.SERVICE_NAMES = services.SERVICE_NAMES;
75
12
  exports.getServiceByName = services.getServiceByName;
76
- exports.publishUsageEvents = publishUsageEvents;
@@ -1,68 +1 @@
1
1
  export { b as SERVICES, S as SERVICE_DEFINITIONS, a as SERVICE_NAMES, g as getServiceByName } from './services-86283509.esm.js';
2
- import { z } from 'zod';
3
- import { SendMessageBatchCommand, SQSClient } from '@aws-sdk/client-sqs';
4
- import { randomUUID } from 'crypto';
5
-
6
- let sqs;
7
- function getSqs(_ref) {
8
- let {
9
- region,
10
- credentials
11
- } = _ref;
12
- if (!sqs) {
13
- sqs = new SQSClient({
14
- region,
15
- credentials
16
- });
17
- }
18
- return sqs;
19
- }
20
-
21
- /**
22
- * Types
23
- */
24
- const usageEventSchema = z.object({
25
- source: z.enum(["wallet", "rpc", "storage", "bundler", "paymaster", "relayer"]),
26
- action: z.string(),
27
- accountId: z.string(),
28
- // Optional
29
- apiKeyId: z.string().optional(),
30
- creatorWalletAddress: z.string().optional(),
31
- clientId: z.string().optional(),
32
- walletAddress: z.string().optional(),
33
- chainId: z.number().int().positive().optional(),
34
- provider: z.string().optional(),
35
- mimeType: z.string().optional(),
36
- fileSize: z.number().int().nonnegative().optional(),
37
- fileCid: z.string().optional(),
38
- transactionHash: z.string().optional(),
39
- gasLimit: z.number().nonnegative().optional(),
40
- gasPricePerUnit: z.string().optional()
41
- });
42
- /**
43
- * Publish usage events. Provide the relevant fields for your application.
44
- *
45
- * @param usageEvents
46
- * @param config
47
- */
48
- async function publishUsageEvents(usageEvents, config) {
49
- const {
50
- queueUrl,
51
- region = "us-west-2",
52
- credentials
53
- } = config;
54
- const entries = usageEvents.map(event => ({
55
- Id: randomUUID(),
56
- MessageBody: JSON.stringify(usageEventSchema.parse(event))
57
- }));
58
- const input = new SendMessageBatchCommand({
59
- QueueUrl: queueUrl,
60
- Entries: entries
61
- });
62
- await getSqs({
63
- region,
64
- credentials
65
- }).send(input);
66
- }
67
-
68
- export { publishUsageEvents };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thirdweb-dev/service-utils",
3
- "version": "0.3.0-nightly-5ee700e8-20230803010712",
3
+ "version": "0.3.0-nightly-5ec0f064-20230803205151",
4
4
  "main": "dist/thirdweb-dev-service-utils.cjs.js",
5
5
  "module": "dist/thirdweb-dev-service-utils.esm.js",
6
6
  "exports": {
@@ -55,7 +55,7 @@
55
55
  "typescript": "^5.1.6"
56
56
  },
57
57
  "dependencies": {
58
- "@aws-sdk/client-sqs": "^3.379.1",
58
+ "aws4fetch": "^1.0.17",
59
59
  "zod": "^3.20.2"
60
60
  },
61
61
  "scripts": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"usage.d.ts","sourceRoot":"../../../../src/core","sources":["usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAkBtD;;GAEG;AACH,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyBpB,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,WAAW,EAAE,UAAU,EAAE,EACzB,MAAM,EAAE;IACN,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,qBAAqB,CAAC;CACrC,GACA,OAAO,CAAC,IAAI,CAAC,CAaf"}