@thirdweb-dev/service-utils 0.5.0-nightly-6cf298a29-20240308012322 → 0.5.1
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/cjs/cf-worker/index.js +152 -0
- package/dist/cjs/cf-worker/index.js.map +1 -0
- package/dist/cjs/cf-worker/usage.js +55 -0
- package/dist/cjs/cf-worker/usage.js.map +1 -0
- package/dist/cjs/core/api.js +42 -0
- package/dist/cjs/core/api.js.map +1 -0
- package/dist/cjs/core/authorize/client.js +104 -0
- package/dist/cjs/core/authorize/client.js.map +1 -0
- package/dist/cjs/core/authorize/index.js +110 -0
- package/dist/cjs/core/authorize/index.js.map +1 -0
- package/dist/cjs/core/authorize/service.js +60 -0
- package/dist/cjs/core/authorize/service.js.map +1 -0
- package/dist/cjs/core/authorize/types.js +3 -0
- package/dist/cjs/core/authorize/types.js.map +1 -0
- package/dist/cjs/core/rateLimit/index.js +60 -0
- package/dist/cjs/core/rateLimit/index.js.map +1 -0
- package/dist/cjs/core/rateLimit/types.js +3 -0
- package/dist/cjs/core/rateLimit/types.js.map +1 -0
- package/dist/cjs/core/services.js +85 -0
- package/dist/cjs/core/services.js.map +1 -0
- package/dist/cjs/core/types.js +3 -0
- package/dist/cjs/core/types.js.map +1 -0
- package/dist/cjs/core/usage.js +85 -0
- package/dist/cjs/core/usage.js.map +1 -0
- package/dist/cjs/index.js +13 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/mocks.js +61 -0
- package/dist/cjs/mocks.js.map +1 -0
- package/dist/cjs/node/index.js +156 -0
- package/dist/cjs/node/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/cf-worker/index.js +145 -0
- package/dist/esm/cf-worker/index.js.map +1 -0
- package/dist/esm/cf-worker/usage.js +53 -0
- package/dist/esm/cf-worker/usage.js.map +1 -0
- package/dist/esm/core/api.js +38 -0
- package/dist/esm/core/api.js.map +1 -0
- package/dist/esm/core/authorize/client.js +99 -0
- package/dist/esm/core/authorize/client.js.map +1 -0
- package/dist/esm/core/authorize/index.js +107 -0
- package/dist/esm/core/authorize/index.js.map +1 -0
- package/dist/esm/core/authorize/service.js +57 -0
- package/dist/esm/core/authorize/service.js.map +1 -0
- package/dist/esm/core/authorize/types.js +2 -0
- package/dist/esm/core/authorize/types.js.map +1 -0
- package/dist/esm/core/rateLimit/index.js +57 -0
- package/dist/esm/core/rateLimit/index.js.map +1 -0
- package/dist/esm/core/rateLimit/types.js +2 -0
- package/dist/esm/core/rateLimit/types.js.map +1 -0
- package/dist/esm/core/services.js +81 -0
- package/dist/esm/core/services.js.map +1 -0
- package/dist/esm/core/types.js +2 -0
- package/dist/esm/core/types.js.map +1 -0
- package/dist/esm/core/usage.js +82 -0
- package/dist/esm/core/usage.js.map +1 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/mocks.js +58 -0
- package/dist/esm/mocks.js.map +1 -0
- package/dist/esm/node/index.js +149 -0
- package/dist/esm/node/index.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/{declarations/src → types}/cf-worker/index.d.ts +8 -10
- package/dist/types/cf-worker/index.d.ts.map +1 -0
- package/dist/types/cf-worker/usage.d.ts +24 -0
- package/dist/types/cf-worker/usage.d.ts.map +1 -0
- package/dist/types/core/api.d.ts +121 -0
- package/dist/types/core/api.d.ts.map +1 -0
- package/dist/types/core/authorize/client.d.ts +17 -0
- package/dist/types/core/authorize/client.d.ts.map +1 -0
- package/dist/{declarations/src → types}/core/authorize/index.d.ts +6 -5
- package/dist/types/core/authorize/index.d.ts.map +1 -0
- package/dist/types/core/authorize/service.d.ts +4 -0
- package/dist/types/core/authorize/service.d.ts.map +1 -0
- package/dist/types/core/authorize/types.d.ts +10 -0
- package/dist/types/core/authorize/types.d.ts.map +1 -0
- package/dist/{declarations/src → types}/core/rateLimit/index.d.ts +4 -4
- package/dist/types/core/rateLimit/index.d.ts.map +1 -0
- package/dist/types/core/rateLimit/types.d.ts.map +1 -0
- package/dist/{declarations/src → types}/core/services.d.ts +55 -23
- package/dist/types/core/services.d.ts.map +1 -0
- package/dist/types/core/types.d.ts.map +1 -0
- package/dist/{declarations/src/cf-worker → types/core}/usage.d.ts +84 -30
- package/dist/types/core/usage.d.ts.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/mocks.d.ts +7 -0
- package/dist/types/mocks.d.ts.map +1 -0
- package/dist/types/node/index.d.ts +23 -0
- package/dist/types/node/index.d.ts.map +1 -0
- package/package.json +42 -45
- package/cf-worker/dist/thirdweb-dev-service-utils-cf-worker.cjs.d.ts +0 -2
- package/cf-worker/dist/thirdweb-dev-service-utils-cf-worker.cjs.d.ts.map +0 -1
- package/cf-worker/dist/thirdweb-dev-service-utils-cf-worker.cjs.dev.js +0 -272
- package/cf-worker/dist/thirdweb-dev-service-utils-cf-worker.cjs.js +0 -7
- package/cf-worker/dist/thirdweb-dev-service-utils-cf-worker.cjs.prod.js +0 -272
- package/cf-worker/dist/thirdweb-dev-service-utils-cf-worker.esm.js +0 -258
- package/cf-worker/package.json +0 -4
- package/dist/declarations/src/cf-worker/index.d.ts.map +0 -1
- package/dist/declarations/src/cf-worker/usage.d.ts.map +0 -1
- package/dist/declarations/src/core/api.d.ts +0 -84
- package/dist/declarations/src/core/api.d.ts.map +0 -1
- package/dist/declarations/src/core/authorize/client.d.ts +0 -9
- package/dist/declarations/src/core/authorize/client.d.ts.map +0 -1
- package/dist/declarations/src/core/authorize/index.d.ts.map +0 -1
- package/dist/declarations/src/core/authorize/service.d.ts +0 -7
- package/dist/declarations/src/core/authorize/service.d.ts.map +0 -1
- package/dist/declarations/src/core/authorize/types.d.ts +0 -12
- package/dist/declarations/src/core/authorize/types.d.ts.map +0 -1
- package/dist/declarations/src/core/rateLimit/index.d.ts.map +0 -1
- package/dist/declarations/src/core/rateLimit/types.d.ts.map +0 -1
- package/dist/declarations/src/core/services.d.ts.map +0 -1
- package/dist/declarations/src/core/types.d.ts.map +0 -1
- package/dist/declarations/src/core/usageLimit/index.d.ts +0 -5
- package/dist/declarations/src/core/usageLimit/index.d.ts.map +0 -1
- package/dist/declarations/src/core/usageLimit/types.d.ts +0 -9
- package/dist/declarations/src/core/usageLimit/types.d.ts.map +0 -1
- package/dist/declarations/src/index.d.ts +0 -2
- package/dist/declarations/src/index.d.ts.map +0 -1
- package/dist/declarations/src/node/index.d.ts +0 -43
- package/dist/declarations/src/node/index.d.ts.map +0 -1
- package/dist/index-3b9a0743.esm.js +0 -572
- package/dist/index-62b88cac.cjs.dev.js +0 -576
- package/dist/index-aa324361.cjs.prod.js +0 -576
- package/dist/services-2aecbda8.esm.js +0 -65
- package/dist/services-508322f3.cjs.dev.js +0 -70
- package/dist/services-5c4d6977.cjs.prod.js +0 -70
- package/dist/thirdweb-dev-service-utils.cjs.d.ts +0 -2
- package/dist/thirdweb-dev-service-utils.cjs.d.ts.map +0 -1
- package/dist/thirdweb-dev-service-utils.cjs.dev.js +0 -12
- package/dist/thirdweb-dev-service-utils.cjs.js +0 -7
- package/dist/thirdweb-dev-service-utils.cjs.prod.js +0 -12
- package/dist/thirdweb-dev-service-utils.esm.js +0 -1
- package/node/dist/thirdweb-dev-service-utils-node.cjs.d.ts +0 -2
- package/node/dist/thirdweb-dev-service-utils-node.cjs.d.ts.map +0 -1
- package/node/dist/thirdweb-dev-service-utils-node.cjs.dev.js +0 -193
- package/node/dist/thirdweb-dev-service-utils-node.cjs.js +0 -7
- package/node/dist/thirdweb-dev-service-utils-node.cjs.prod.js +0 -193
- package/node/dist/thirdweb-dev-service-utils-node.esm.js +0 -180
- package/node/package.json +0 -4
- /package/dist/{declarations/src → types}/core/rateLimit/types.d.ts +0 -0
- /package/dist/{declarations/src → types}/core/types.d.ts +0 -0
@@ -1,258 +0,0 @@
|
|
1
|
-
import { a as authorize } from '../../dist/index-3b9a0743.esm.js';
|
2
|
-
export { r as rateLimit, u as usageLimit } from '../../dist/index-3b9a0743.esm.js';
|
3
|
-
import { AwsClient } from 'aws4fetch';
|
4
|
-
import { z } from 'zod';
|
5
|
-
export { b as SERVICES, S as SERVICE_DEFINITIONS, a as SERVICE_NAMES, g as getServiceByName } from '../../dist/services-2aecbda8.esm.js';
|
6
|
-
|
7
|
-
// Initialize a singleton for aws usage.
|
8
|
-
let _aws;
|
9
|
-
function getAws(options) {
|
10
|
-
if (!_aws) {
|
11
|
-
_aws = new AwsClient(options);
|
12
|
-
}
|
13
|
-
return _aws;
|
14
|
-
}
|
15
|
-
|
16
|
-
/**
|
17
|
-
* Types
|
18
|
-
*/
|
19
|
-
const usageEventSchema = z.object({
|
20
|
-
source: z.enum(["embeddedWallets", "rpc", "storage", "bundler", "paymaster", "relayer", "connectWallet", "checkout", "engine"]),
|
21
|
-
action: z.string(),
|
22
|
-
/**
|
23
|
-
* The following fields are optional.
|
24
|
-
*/
|
25
|
-
|
26
|
-
accountId: z.string().optional(),
|
27
|
-
isClientEvent: z.boolean().optional(),
|
28
|
-
apiKeyId: z.string().optional(),
|
29
|
-
creatorWalletAddress: z.string().optional(),
|
30
|
-
clientId: z.string().optional(),
|
31
|
-
walletAddress: z.string().optional(),
|
32
|
-
walletType: 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
|
-
evmMethod: z.string().optional(),
|
39
|
-
userOpHash: z.string().optional(),
|
40
|
-
gasLimit: z.number().nonnegative().optional(),
|
41
|
-
gasPricePerUnit: z.string().optional(),
|
42
|
-
transactionFeeUsd: z.number().optional(),
|
43
|
-
transactionHash: z.string().optional(),
|
44
|
-
sdkName: z.string().optional(),
|
45
|
-
sdkVersion: z.string().optional(),
|
46
|
-
sdkPlatform: z.string().optional(),
|
47
|
-
productName: z.string().optional(),
|
48
|
-
transactionValue: z.string().optional(),
|
49
|
-
pathname: z.string().optional(),
|
50
|
-
contractAddress: z.string().optional(),
|
51
|
-
errorCode: z.string().optional(),
|
52
|
-
httpStatusCode: z.number().int().nonnegative().optional(),
|
53
|
-
functionName: z.string().optional(),
|
54
|
-
extension: z.string().optional(),
|
55
|
-
retryCount: z.number().int().nonnegative().optional(),
|
56
|
-
policyId: z.string().optional(),
|
57
|
-
msSinceQueue: z.number().nonnegative().optional(),
|
58
|
-
msSinceSend: z.number().nonnegative().optional(),
|
59
|
-
msTotalDuration: z.number().nonnegative().optional()
|
60
|
-
});
|
61
|
-
/**
|
62
|
-
* Publish usage events. Provide the relevant fields for your application.
|
63
|
-
*
|
64
|
-
* Usage in Cloudflare Workers:
|
65
|
-
* ctx.waitUntil(
|
66
|
-
* publishUsageEvents(
|
67
|
-
* [event1, event2],
|
68
|
-
* { queueUrl, accessKeyId, secretAccessKey },
|
69
|
-
* )
|
70
|
-
* )
|
71
|
-
*
|
72
|
-
* @param usageEvents
|
73
|
-
* @param config
|
74
|
-
*/
|
75
|
-
async function publishUsageEvents(usageEvents, config) {
|
76
|
-
const {
|
77
|
-
queueUrl,
|
78
|
-
accessKeyId,
|
79
|
-
secretAccessKey,
|
80
|
-
region = "us-west-2"
|
81
|
-
} = config;
|
82
|
-
const entries = usageEvents.map(event => {
|
83
|
-
// Enforce schema of usage event.
|
84
|
-
const parsed = usageEventSchema.parse(event);
|
85
|
-
return {
|
86
|
-
Id: crypto.randomUUID(),
|
87
|
-
MessageBody: JSON.stringify(parsed)
|
88
|
-
};
|
89
|
-
});
|
90
|
-
const aws = getAws({
|
91
|
-
accessKeyId,
|
92
|
-
secretAccessKey,
|
93
|
-
region
|
94
|
-
});
|
95
|
-
await aws.fetch(`https://sqs.${region}.amazonaws.com`, {
|
96
|
-
headers: {
|
97
|
-
"X-Amz-Target": "AmazonSQS.SendMessageBatch",
|
98
|
-
"X-Amz-Date": new Date().toISOString(),
|
99
|
-
"Content-Type": "application/x-amz-json-1.0"
|
100
|
-
},
|
101
|
-
body: JSON.stringify({
|
102
|
-
QueueUrl: queueUrl,
|
103
|
-
Entries: entries
|
104
|
-
})
|
105
|
-
});
|
106
|
-
}
|
107
|
-
|
108
|
-
const DEFAULT_CACHE_TTL_SECONDS = 60;
|
109
|
-
async function authorizeWorker(authInput, serviceConfig) {
|
110
|
-
let authData;
|
111
|
-
try {
|
112
|
-
authData = await extractAuthorizationData(authInput);
|
113
|
-
} catch (e) {
|
114
|
-
if (e instanceof Error && e.message === "KEY_CONFLICT") {
|
115
|
-
return {
|
116
|
-
authorized: false,
|
117
|
-
status: 400,
|
118
|
-
errorMessage: "Please pass either a client id or a secret key.",
|
119
|
-
errorCode: "KEY_CONFLICT"
|
120
|
-
};
|
121
|
-
}
|
122
|
-
return {
|
123
|
-
authorized: false,
|
124
|
-
status: 500,
|
125
|
-
errorMessage: "Internal Server Error",
|
126
|
-
errorCode: "INTERNAL_SERVER_ERROR"
|
127
|
-
};
|
128
|
-
}
|
129
|
-
return await authorize(authData, serviceConfig, {
|
130
|
-
get: async clientId => serviceConfig.kvStore.get(clientId),
|
131
|
-
put: (clientId, apiKeyMeta) => serviceConfig.ctx.waitUntil(serviceConfig.kvStore.put(clientId, JSON.stringify({
|
132
|
-
updatedAt: Date.now(),
|
133
|
-
apiKeyMeta
|
134
|
-
}), {
|
135
|
-
expirationTtl: serviceConfig.cacheTtlSeconds && serviceConfig.cacheTtlSeconds >= DEFAULT_CACHE_TTL_SECONDS ? serviceConfig.cacheTtlSeconds : DEFAULT_CACHE_TTL_SECONDS
|
136
|
-
})),
|
137
|
-
cacheTtlSeconds: serviceConfig.cacheTtlSeconds ?? DEFAULT_CACHE_TTL_SECONDS
|
138
|
-
});
|
139
|
-
}
|
140
|
-
async function extractAuthorizationData(authInput) {
|
141
|
-
const requestUrl = new URL(authInput.req.url);
|
142
|
-
const headers = authInput.req.headers;
|
143
|
-
const secretKey = headers.get("x-secret-key");
|
144
|
-
|
145
|
-
// prefer clientId that is explicitly passed in
|
146
|
-
let clientId = authInput.clientId ?? null;
|
147
|
-
if (!clientId) {
|
148
|
-
// next preference is clientId from header
|
149
|
-
clientId = headers.get("x-client-id");
|
150
|
-
}
|
151
|
-
|
152
|
-
// next preference is search param
|
153
|
-
if (!clientId) {
|
154
|
-
clientId = requestUrl.searchParams.get("clientId");
|
155
|
-
}
|
156
|
-
// bundle id from header is first preference
|
157
|
-
let bundleId = headers.get("x-bundle-id");
|
158
|
-
|
159
|
-
// next preference is search param
|
160
|
-
if (!bundleId) {
|
161
|
-
bundleId = requestUrl.searchParams.get("bundleId");
|
162
|
-
}
|
163
|
-
let origin = headers.get("origin");
|
164
|
-
// if origin header is not available we'll fall back to referrer;
|
165
|
-
if (!origin) {
|
166
|
-
origin = headers.get("referer");
|
167
|
-
}
|
168
|
-
// if we have an origin at this point, normalize it
|
169
|
-
if (origin) {
|
170
|
-
try {
|
171
|
-
origin = new URL(origin).host;
|
172
|
-
} catch (e) {
|
173
|
-
console.warn("failed to parse origin", origin, e);
|
174
|
-
}
|
175
|
-
}
|
176
|
-
|
177
|
-
// handle if we a secret key is passed in the headers
|
178
|
-
let secretKeyHash = null;
|
179
|
-
if (secretKey) {
|
180
|
-
// hash the secret key
|
181
|
-
secretKeyHash = await hashSecretKey(secretKey);
|
182
|
-
// derive the client id from the secret key hash
|
183
|
-
const derivedClientId = deriveClientIdFromSecretKeyHash(secretKeyHash);
|
184
|
-
// if we already have a client id passed in we need to make sure they match
|
185
|
-
if (clientId && clientId !== derivedClientId) {
|
186
|
-
throw new Error("KEY_CONFLICT");
|
187
|
-
}
|
188
|
-
// otherwise set the client id to the derived client id (client id based off of secret key)
|
189
|
-
clientId = derivedClientId;
|
190
|
-
}
|
191
|
-
let jwt = null;
|
192
|
-
if (headers.has("authorization")) {
|
193
|
-
const authHeader = headers.get("authorization");
|
194
|
-
if (authHeader) {
|
195
|
-
const [type, token] = authHeader.split(" ");
|
196
|
-
if (type.toLowerCase() === "bearer" && !!token) {
|
197
|
-
jwt = token;
|
198
|
-
}
|
199
|
-
}
|
200
|
-
}
|
201
|
-
return {
|
202
|
-
jwt,
|
203
|
-
hashedJWT: jwt ? await hashSecretKey(jwt) : null,
|
204
|
-
secretKey,
|
205
|
-
clientId,
|
206
|
-
origin,
|
207
|
-
bundleId,
|
208
|
-
secretKeyHash,
|
209
|
-
targetAddress: authInput.targetAddress
|
210
|
-
};
|
211
|
-
}
|
212
|
-
async function hashSecretKey(secretKey) {
|
213
|
-
return bufferToHex(await crypto.subtle.digest("SHA-256", new TextEncoder().encode(secretKey)));
|
214
|
-
}
|
215
|
-
function deriveClientIdFromSecretKeyHash(secretKeyHash) {
|
216
|
-
return secretKeyHash.slice(0, 32);
|
217
|
-
}
|
218
|
-
function bufferToHex(buffer) {
|
219
|
-
return [...new Uint8Array(buffer)].map(x => x.toString(16).padStart(2, "0")).join("");
|
220
|
-
}
|
221
|
-
async function logHttpRequest(_ref) {
|
222
|
-
let {
|
223
|
-
source,
|
224
|
-
clientId,
|
225
|
-
req,
|
226
|
-
res,
|
227
|
-
isAuthed,
|
228
|
-
statusMessage,
|
229
|
-
latencyMs
|
230
|
-
} = _ref;
|
231
|
-
try {
|
232
|
-
const authorizationData = await extractAuthorizationData({
|
233
|
-
req,
|
234
|
-
clientId
|
235
|
-
});
|
236
|
-
const headers = req.headers;
|
237
|
-
console.log(JSON.stringify({
|
238
|
-
source,
|
239
|
-
pathname: req.url,
|
240
|
-
hasSecretKey: !!authorizationData.secretKey,
|
241
|
-
hasClientId: !!authorizationData.clientId,
|
242
|
-
hasJwt: !!authorizationData.jwt,
|
243
|
-
clientId: authorizationData.clientId,
|
244
|
-
isAuthed: !!isAuthed ?? null,
|
245
|
-
status: res.status,
|
246
|
-
sdkName: headers.get("x-sdk-name") ?? "unknown",
|
247
|
-
sdkVersion: headers.get("x-sdk-version") ?? "unknown",
|
248
|
-
platform: headers.get("x-sdk-platform") ?? "unknown",
|
249
|
-
os: headers.get("x-sdk-os") ?? "unknown",
|
250
|
-
latencyMs: latencyMs ?? null
|
251
|
-
}));
|
252
|
-
console.log(`statusMessage=${statusMessage ?? res.statusText}`);
|
253
|
-
} catch (err) {
|
254
|
-
console.error("Failed to log HTTP request:", err);
|
255
|
-
}
|
256
|
-
}
|
257
|
-
|
258
|
-
export { authorizeWorker, deriveClientIdFromSecretKeyHash, extractAuthorizationData, hashSecretKey, logHttpRequest, publishUsageEvents };
|
package/cf-worker/package.json
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"../../../../src/cf-worker","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACX,QAAQ,EACT,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAGV,iBAAiB,EAClB,MAAM,aAAa,CAAC;AAGrB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AAEnC,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,GAAG;IACpD,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;AAED,wBAAsB,wBAAwB,CAC5C,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC,kBAAkB,CAAC,CA2E7B;AAED,wBAAsB,aAAa,CAAC,SAAS,EAAE,MAAM,mBAIpD;AAED,wBAAgB,+BAA+B,CAAC,aAAa,EAAE,MAAM,UAEpE;AAQD,wBAAsB,cAAc,CAAC,EACnC,MAAM,EACN,QAAQ,EACR,GAAG,EACH,GAAG,EACH,QAAQ,EACR,aAAa,EACb,SAAS,GACV,EAAE,SAAS,GAAG;IACb,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,QAAQ,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,iBA0BA"}
|
@@ -1 +0,0 @@
|
|
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;;;IAcpB;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoCH,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,84 +0,0 @@
|
|
1
|
-
import type { ServiceName } from "./services";
|
2
|
-
export type UserOpData = {
|
3
|
-
sender: string;
|
4
|
-
targets: string[];
|
5
|
-
gasLimit: string;
|
6
|
-
gasPrice: string;
|
7
|
-
};
|
8
|
-
export type PolicyResult = {
|
9
|
-
policyId: string | null;
|
10
|
-
isAllowed: boolean;
|
11
|
-
reason: string;
|
12
|
-
};
|
13
|
-
export type CoreServiceConfig = {
|
14
|
-
enforceAuth?: boolean;
|
15
|
-
apiUrl: string;
|
16
|
-
serviceScope: ServiceName;
|
17
|
-
serviceApiKey: string;
|
18
|
-
serviceAction?: string;
|
19
|
-
useWalletAuth?: boolean;
|
20
|
-
checkPolicy?: boolean;
|
21
|
-
policyMetadata?: {
|
22
|
-
chainId: number;
|
23
|
-
userOp: UserOpData;
|
24
|
-
};
|
25
|
-
};
|
26
|
-
type Usage = {
|
27
|
-
storage?: {
|
28
|
-
sumFileSizeBytes: number;
|
29
|
-
};
|
30
|
-
embeddedWallets?: {
|
31
|
-
countWalletAddresses: number;
|
32
|
-
};
|
33
|
-
};
|
34
|
-
export type ApiKeyMetadata = {
|
35
|
-
id: string;
|
36
|
-
key: string;
|
37
|
-
accountId: string;
|
38
|
-
accountStatus: "noCustomer" | "noPayment" | "validPayment" | "invalidPayment";
|
39
|
-
accountPlan: "free" | "growth" | "pro" | "enterprise";
|
40
|
-
creatorWalletAddress: string;
|
41
|
-
secretHash: string;
|
42
|
-
walletAddresses: string[];
|
43
|
-
domains: string[];
|
44
|
-
bundleIds: string[];
|
45
|
-
redirectUrls: string[];
|
46
|
-
services: {
|
47
|
-
name: string;
|
48
|
-
targetAddresses: string[];
|
49
|
-
actions: string[];
|
50
|
-
}[];
|
51
|
-
usage?: Usage;
|
52
|
-
limits: Partial<Record<ServiceName, number>>;
|
53
|
-
rateLimits: Partial<Record<ServiceName, number>>;
|
54
|
-
policyResult?: PolicyResult;
|
55
|
-
};
|
56
|
-
export type AccountMetadata = {
|
57
|
-
id: string;
|
58
|
-
name: string;
|
59
|
-
creatorWalletAddress: string;
|
60
|
-
usage?: Usage;
|
61
|
-
limits: Partial<Record<ServiceName, number>>;
|
62
|
-
rateLimits: Partial<Record<ServiceName, number>>;
|
63
|
-
};
|
64
|
-
export type ApiResponse = {
|
65
|
-
data: ApiKeyMetadata | null;
|
66
|
-
error: {
|
67
|
-
code: string;
|
68
|
-
statusCode: number;
|
69
|
-
message: string;
|
70
|
-
};
|
71
|
-
};
|
72
|
-
export type ApiAccountResponse = {
|
73
|
-
data: AccountMetadata | null;
|
74
|
-
error: {
|
75
|
-
code: string;
|
76
|
-
statusCode: number;
|
77
|
-
message: string;
|
78
|
-
};
|
79
|
-
};
|
80
|
-
export declare function fetchKeyMetadataFromApi(clientId: string, config: CoreServiceConfig): Promise<ApiResponse>;
|
81
|
-
export declare function fetchAccountFromApi(jwt: string, config: CoreServiceConfig, useWalletAuth: boolean): Promise<ApiAccountResponse>;
|
82
|
-
export declare function updateRateLimitedAt(apiKeyId: string, config: CoreServiceConfig): Promise<void>;
|
83
|
-
export {};
|
84
|
-
//# sourceMappingURL=api.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"../../../../src/core","sources":["api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,WAAW,CAA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type ClientAuthorizationPayload = {
|
4
|
-
secretKeyHash: string | null;
|
5
|
-
bundleId: string | null;
|
6
|
-
origin: string | null;
|
7
|
-
};
|
8
|
-
export declare function authorizeClient(authOptions: ClientAuthorizationPayload, apiKeyMeta: ApiKeyMetadata): AuthorizationResult;
|
9
|
-
//# sourceMappingURL=client.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"../../../../../src/core/authorize","sources":["client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD,MAAM,MAAM,0BAA0B,GAAG;IACvC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC;AAEF,wBAAgB,eAAe,CAC7B,WAAW,EAAE,0BAA0B,EACvC,UAAU,EAAE,cAAc,GACzB,mBAAmB,CA2GrB"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"../../../../../src/core/authorize","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,cAAc,EACd,iBAAiB,EAGlB,MAAM,QAAQ,CAAC;AAGhB,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAElC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,GAAG,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAClD,GAAG,EAAE,CACH,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,cAAc,GAAG,eAAe,KACnC,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAgBF,wBAAsB,SAAS,CAC7B,QAAQ,EAAE,kBAAkB,EAC5B,aAAa,EAAE,iBAAiB,EAChC,YAAY,CAAC,EAAE,YAAY,GAC1B,OAAO,CAAC,mBAAmB,CAAC,CAsN9B"}
|
@@ -1,7 +0,0 @@
|
|
1
|
-
import { ApiKeyMetadata, CoreServiceConfig } from "../api";
|
2
|
-
import { AuthorizationResult } from "./types";
|
3
|
-
export type ServiceAuthorizationPayload = {
|
4
|
-
targetAddress?: string | string[];
|
5
|
-
};
|
6
|
-
export declare function authorizeService(apiKeyMetadata: ApiKeyMetadata, serviceConfig: CoreServiceConfig, authorizationPayload?: ServiceAuthorizationPayload): AuthorizationResult;
|
7
|
-
//# sourceMappingURL=service.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"../../../../../src/core/authorize","sources":["service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,MAAM,2BAA2B,GAAG;IAAE,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CAAE,CAAC;AAEhF,wBAAgB,gBAAgB,CAC9B,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,iBAAiB,EAChC,oBAAoB,CAAC,EAAE,2BAA2B,GACjD,mBAAmB,CAgErB"}
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import { AccountMetadata, ApiKeyMetadata } from "../api";
|
2
|
-
export type AuthorizationResult = {
|
3
|
-
authorized: true;
|
4
|
-
apiKeyMeta: ApiKeyMetadata | null;
|
5
|
-
accountMeta: AccountMetadata | null;
|
6
|
-
} | {
|
7
|
-
authorized: false;
|
8
|
-
status: number;
|
9
|
-
errorMessage: string;
|
10
|
-
errorCode: string;
|
11
|
-
};
|
12
|
-
//# sourceMappingURL=types.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"../../../../../src/core/authorize","sources":["types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAEzD,MAAM,MAAM,mBAAmB,GAC3B;IACE,UAAU,EAAE,IAAI,CAAC;IACjB,UAAU,EAAE,cAAc,GAAG,IAAI,CAAC;IAClC,WAAW,EAAE,eAAe,GAAG,IAAI,CAAC;CACrC,GACD;IACE,UAAU,EAAE,KAAK,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"../../../../../src/core/rateLimit","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAuB,MAAM,QAAQ,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAK1C,KAAK,MAAM,GAAG;IACZ,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACvC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;CAC7D,CAAC;AAEF,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACpC,WAAW,EAAE,mBAAmB,CAAC;IACjC,aAAa,EAAE,iBAAiB,CAAC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,OAAO,CAAC,eAAe,CAAC,CAsE3B"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"../../../../../src/core/rateLimit","sources":["types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GACvB;IACE,WAAW,EAAE,KAAK,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,GACD;IACE,WAAW,EAAE,IAAI,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"services.d.ts","sourceRoot":"../../../../src/core","sources":["services.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4DtB,CAAC;AAEX,eAAO,MAAM,aAAa,wFAEe,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"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"../../../../src/core","sources":["types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAE1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACnC,CAAC"}
|
@@ -1,5 +0,0 @@
|
|
1
|
-
import { CoreServiceConfig } from "../api";
|
2
|
-
import { AuthorizationResult } from "../authorize/types";
|
3
|
-
import { UsageLimitResult } from "./types";
|
4
|
-
export declare function usageLimit(authzResult: AuthorizationResult, serviceConfig: CoreServiceConfig): Promise<UsageLimitResult>;
|
5
|
-
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +0,0 @@
|
|
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,CAmD3B"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"../../../../../src/core/usageLimit","sources":["types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GACxB;IACE,YAAY,EAAE,KAAK,CAAC;CACrB,GACD;IACE,YAAY,EAAE,IAAI,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"../../../src","sources":["index.ts"],"names":[],"mappings":"AACA,cAAc,iBAAiB,CAAC"}
|
@@ -1,43 +0,0 @@
|
|
1
|
-
/// <reference types="node" />
|
2
|
-
import type { ServerResponse } from "http";
|
3
|
-
import type { IncomingMessage } from "node:http";
|
4
|
-
import type { CoreServiceConfig } from "../core/api";
|
5
|
-
import type { AuthorizationInput } from "../core/authorize";
|
6
|
-
import type { AuthorizationResult } from "../core/authorize/types";
|
7
|
-
import type { CoreAuthInput } from "../core/types";
|
8
|
-
export * from "../core/services";
|
9
|
-
export * from "../core/rateLimit";
|
10
|
-
export * from "../core/usageLimit";
|
11
|
-
type NodeServiceConfig = CoreServiceConfig;
|
12
|
-
export type AuthInput = CoreAuthInput & {
|
13
|
-
req: IncomingMessage;
|
14
|
-
};
|
15
|
-
/**
|
16
|
-
*
|
17
|
-
* @param {AuthInput['req']} authInput.req - The incoming request from which information will be pulled from. These information includes (checks are in order and terminates on first match):
|
18
|
-
* - clientId: Checks header `x-client-id`, search param `clientId`
|
19
|
-
* - bundleId: Checks header `x-bundle-id`, search param `bundleId`
|
20
|
-
* - secretKey: Checks header `x-secret-key`
|
21
|
-
* - origin (the requesting domain): Checks header `origin`, `referer`
|
22
|
-
* @param {AuthInput['clientId']} authInput.clientId - Overrides any clientId found on the `req` object
|
23
|
-
* @param {AuthInput['targetAddress']} authInput.targetAddress - Only used in smart wallets to determine if the request is authorized to interact with the target address.
|
24
|
-
* @param {NodeServiceConfig['enforceAuth']} serviceConfig - Always `true` unless you need to turn auth off. Tells the service whether or not to enforce auth.
|
25
|
-
* @param {NodeServiceConfig['apiUrl']} serviceConfig.apiUrl - The url of the api server to fetch information for verification. `https://api.thirdweb.com` for production and `https://api.staging.thirdweb.com` for staging
|
26
|
-
* @param {NodeServiceConfig['serviceApiKey']} serviceConfig.serviceApiKey - secret key to be used authenticate the caller of the api-server. Check the api-server's env variable for the keys.
|
27
|
-
* @param {NodeServiceConfig['serviceScope']} serviceConfig.serviceScope - The service that we are requesting authorization for. E.g. `relayer`, `rpc`, 'bundler', 'storage' etc.
|
28
|
-
* @param {NodeServiceConfig['serviceAction']} serviceConfig.serviceAction - Needed when the `serviceScope` is `storage`. Can be either `read` or `write`.
|
29
|
-
* @param {NodeServiceConfig['useWalletAuth']} serviceConfig.useWalletAuth - If true it pings the `wallet/me` or else, `account/me`. You most likely can leave this as false.
|
30
|
-
* @returns {AuthorizationResult} authorizationResult - contains if the request is authorized, and information about the account if it is authorized. Otherwise, it contains the error message and status code.
|
31
|
-
*/
|
32
|
-
export declare function authorizeNode(authInput: AuthInput, serviceConfig: NodeServiceConfig): Promise<AuthorizationResult>;
|
33
|
-
export declare function extractAuthorizationData(authInput: AuthInput): AuthorizationInput;
|
34
|
-
export declare function hashSecretKey(secretKey: string): string;
|
35
|
-
export declare function deriveClientIdFromSecretKeyHash(secretKeyHash: string): string;
|
36
|
-
export declare function logHttpRequest({ source, clientId, req, res, isAuthed, statusMessage, latencyMs, }: AuthInput & {
|
37
|
-
source: string;
|
38
|
-
res: ServerResponse;
|
39
|
-
isAuthed?: boolean;
|
40
|
-
statusMessage?: Error | string;
|
41
|
-
latencyMs?: number;
|
42
|
-
}): void;
|
43
|
-
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"../../../../src/node","sources":["index.ts"],"names":[],"mappings":";AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAC3C,OAAO,KAAK,EAAuB,eA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