@thirdweb-dev/service-utils 0.4.5 → 0.4.6-nightly-52b1a0fc-20231008053354

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('../../dist/index-253f4888.cjs.dev.js');
5
+ var index = require('../../dist/index-18abcc30.cjs.dev.js');
6
6
  var aws4fetch = require('aws4fetch');
7
7
  var zod = require('zod');
8
8
  var services = require('../../dist/services-79b4664f.cjs.dev.js');
@@ -20,10 +20,14 @@ function getAws(options) {
20
20
  * Types
21
21
  */
22
22
  const usageEventSchema = zod.z.object({
23
- source: zod.z.enum(["embeddedWallets", "rpc", "storage", "bundler", "paymaster", "relayer"]),
23
+ source: zod.z.enum(["embeddedWallets", "rpc", "storage", "bundler", "paymaster", "relayer", "connectWallet"]),
24
24
  action: zod.z.string(),
25
- accountId: zod.z.string(),
26
- // Optional
25
+ /**
26
+ * The following fields are optional.
27
+ */
28
+
29
+ accountId: zod.z.string().optional(),
30
+ isClientEvent: zod.z.boolean().optional(),
27
31
  apiKeyId: zod.z.string().optional(),
28
32
  creatorWalletAddress: zod.z.string().optional(),
29
33
  clientId: zod.z.string().optional(),
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('../../dist/index-209e3e52.cjs.prod.js');
5
+ var index = require('../../dist/index-aac16290.cjs.prod.js');
6
6
  var aws4fetch = require('aws4fetch');
7
7
  var zod = require('zod');
8
8
  var services = require('../../dist/services-04997839.cjs.prod.js');
@@ -20,10 +20,14 @@ function getAws(options) {
20
20
  * Types
21
21
  */
22
22
  const usageEventSchema = zod.z.object({
23
- source: zod.z.enum(["embeddedWallets", "rpc", "storage", "bundler", "paymaster", "relayer"]),
23
+ source: zod.z.enum(["embeddedWallets", "rpc", "storage", "bundler", "paymaster", "relayer", "connectWallet"]),
24
24
  action: zod.z.string(),
25
- accountId: zod.z.string(),
26
- // Optional
25
+ /**
26
+ * The following fields are optional.
27
+ */
28
+
29
+ accountId: zod.z.string().optional(),
30
+ isClientEvent: zod.z.boolean().optional(),
27
31
  apiKeyId: zod.z.string().optional(),
28
32
  creatorWalletAddress: zod.z.string().optional(),
29
33
  clientId: zod.z.string().optional(),
@@ -1,5 +1,5 @@
1
- import { a as authorize } from '../../dist/index-25086ddf.esm.js';
2
- export { r as rateLimit, u as usageLimit } from '../../dist/index-25086ddf.esm.js';
1
+ import { a as authorize } from '../../dist/index-b140304d.esm.js';
2
+ export { r as rateLimit, u as usageLimit } from '../../dist/index-b140304d.esm.js';
3
3
  import { AwsClient } from 'aws4fetch';
4
4
  import { z } from 'zod';
5
5
  export { b as SERVICES, S as SERVICE_DEFINITIONS, a as SERVICE_NAMES, g as getServiceByName } from '../../dist/services-bc12a5f6.esm.js';
@@ -17,10 +17,14 @@ function getAws(options) {
17
17
  * Types
18
18
  */
19
19
  const usageEventSchema = z.object({
20
- source: z.enum(["embeddedWallets", "rpc", "storage", "bundler", "paymaster", "relayer"]),
20
+ source: z.enum(["embeddedWallets", "rpc", "storage", "bundler", "paymaster", "relayer", "connectWallet"]),
21
21
  action: z.string(),
22
- accountId: z.string(),
23
- // Optional
22
+ /**
23
+ * The following fields are optional.
24
+ */
25
+
26
+ accountId: z.string().optional(),
27
+ isClientEvent: z.boolean().optional(),
24
28
  apiKeyId: z.string().optional(),
25
29
  creatorWalletAddress: z.string().optional(),
26
30
  clientId: z.string().optional(),
@@ -3,9 +3,13 @@ import { z } from "zod";
3
3
  * Types
4
4
  */
5
5
  declare const usageEventSchema: z.ZodObject<{
6
- source: z.ZodEnum<["embeddedWallets", "rpc", "storage", "bundler", "paymaster", "relayer"]>;
6
+ source: z.ZodEnum<["embeddedWallets", "rpc", "storage", "bundler", "paymaster", "relayer", "connectWallet"]>;
7
7
  action: z.ZodString;
8
- accountId: z.ZodString;
8
+ /**
9
+ * The following fields are optional.
10
+ */
11
+ accountId: z.ZodOptional<z.ZodString>;
12
+ isClientEvent: z.ZodOptional<z.ZodBoolean>;
9
13
  apiKeyId: z.ZodOptional<z.ZodString>;
10
14
  creatorWalletAddress: z.ZodOptional<z.ZodString>;
11
15
  clientId: z.ZodOptional<z.ZodString>;
@@ -25,9 +29,10 @@ declare const usageEventSchema: z.ZodObject<{
25
29
  sdkPlatform: z.ZodOptional<z.ZodString>;
26
30
  productName: z.ZodOptional<z.ZodString>;
27
31
  }, "strip", z.ZodTypeAny, {
28
- source: "storage" | "rpc" | "bundler" | "relayer" | "embeddedWallets" | "paymaster";
29
- accountId: string;
32
+ source: "storage" | "rpc" | "bundler" | "relayer" | "embeddedWallets" | "paymaster" | "connectWallet";
30
33
  action: string;
34
+ accountId?: string | undefined;
35
+ isClientEvent?: boolean | undefined;
31
36
  apiKeyId?: string | undefined;
32
37
  creatorWalletAddress?: string | undefined;
33
38
  clientId?: string | undefined;
@@ -47,9 +52,10 @@ declare const usageEventSchema: z.ZodObject<{
47
52
  sdkPlatform?: string | undefined;
48
53
  productName?: string | undefined;
49
54
  }, {
50
- source: "storage" | "rpc" | "bundler" | "relayer" | "embeddedWallets" | "paymaster";
51
- accountId: string;
55
+ source: "storage" | "rpc" | "bundler" | "relayer" | "embeddedWallets" | "paymaster" | "connectWallet";
52
56
  action: string;
57
+ accountId?: string | undefined;
58
+ isClientEvent?: boolean | undefined;
53
59
  apiKeyId?: string | undefined;
54
60
  creatorWalletAddress?: string | undefined;
55
61
  clientId?: string | undefined;
@@ -1 +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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+BpB,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,IAAI,CAAC,CAiCf"}
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;;;IAYpB;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsBH,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,IAAI,CAAC,CAiCf"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"../../../../../src/core/usageLimit","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,wBAAsB,UAAU,CAC9B,WAAW,EAAE,mBAAmB,EAChC,aAAa,EAAE,iBAAiB,GAC/B,OAAO,CAAC,gBAAgB,CAAC,CAwC3B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"../../../../../src/core/usageLimit","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,wBAAsB,UAAU,CAC9B,WAAW,EAAE,mBAAmB,EAChC,aAAa,EAAE,iBAAiB,GAC/B,OAAO,CAAC,gBAAgB,CAAC,CAoD3B"}
@@ -556,6 +556,14 @@ async function usageLimit(authzResult, serviceConfig) {
556
556
  errorCode: "PAYMENT_METHOD_REQUIRED"
557
557
  };
558
558
  }
559
+ if (serviceScope === "embeddedWallets" && (usage.embeddedWallets?.countWalletAddresses || 0) > limit) {
560
+ return {
561
+ usageLimited: true,
562
+ status: 403,
563
+ errorMessage: `You've used all of your total usage limit for Embedded Wallets. Please add your payment method at https://thirdweb.com/dashboard/settings/billing.`,
564
+ errorCode: "PAYMENT_METHOD_REQUIRED"
565
+ };
566
+ }
559
567
  return {
560
568
  usageLimited: false
561
569
  };
@@ -556,6 +556,14 @@ async function usageLimit(authzResult, serviceConfig) {
556
556
  errorCode: "PAYMENT_METHOD_REQUIRED"
557
557
  };
558
558
  }
559
+ if (serviceScope === "embeddedWallets" && (usage.embeddedWallets?.countWalletAddresses || 0) > limit) {
560
+ return {
561
+ usageLimited: true,
562
+ status: 403,
563
+ errorMessage: `You've used all of your total usage limit for Embedded Wallets. Please add your payment method at https://thirdweb.com/dashboard/settings/billing.`,
564
+ errorCode: "PAYMENT_METHOD_REQUIRED"
565
+ };
566
+ }
559
567
  return {
560
568
  usageLimited: false
561
569
  };
@@ -554,6 +554,14 @@ async function usageLimit(authzResult, serviceConfig) {
554
554
  errorCode: "PAYMENT_METHOD_REQUIRED"
555
555
  };
556
556
  }
557
+ if (serviceScope === "embeddedWallets" && (usage.embeddedWallets?.countWalletAddresses || 0) > limit) {
558
+ return {
559
+ usageLimited: true,
560
+ status: 403,
561
+ errorMessage: `You've used all of your total usage limit for Embedded Wallets. Please add your payment method at https://thirdweb.com/dashboard/settings/billing.`,
562
+ errorCode: "PAYMENT_METHOD_REQUIRED"
563
+ };
564
+ }
557
565
  return {
558
566
  usageLimited: false
559
567
  };
@@ -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-253f4888.cjs.dev.js');
6
+ var index = require('../../dist/index-18abcc30.cjs.dev.js');
7
7
  var services = require('../../dist/services-79b4664f.cjs.dev.js');
8
8
 
9
9
  /**
@@ -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-209e3e52.cjs.prod.js');
6
+ var index = require('../../dist/index-aac16290.cjs.prod.js');
7
7
  var services = require('../../dist/services-04997839.cjs.prod.js');
8
8
 
9
9
  /**
@@ -1,6 +1,6 @@
1
1
  import { createHash } from 'node:crypto';
2
- import { a as authorize } from '../../dist/index-25086ddf.esm.js';
3
- export { r as rateLimit, u as usageLimit } from '../../dist/index-25086ddf.esm.js';
2
+ import { a as authorize } from '../../dist/index-b140304d.esm.js';
3
+ export { r as rateLimit, u as usageLimit } from '../../dist/index-b140304d.esm.js';
4
4
  export { b as SERVICES, S as SERVICE_DEFINITIONS, a as SERVICE_NAMES, g as getServiceByName } from '../../dist/services-bc12a5f6.esm.js';
5
5
 
6
6
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thirdweb-dev/service-utils",
3
- "version": "0.4.5",
3
+ "version": "0.4.6-nightly-52b1a0fc-20231008053354",
4
4
  "main": "dist/thirdweb-dev-service-utils.cjs.js",
5
5
  "module": "dist/thirdweb-dev-service-utils.esm.js",
6
6
  "exports": {