Compare commits

...
Author SHA1 Message Date
github-actions[bot]GitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
9a7b2098ee Version Packages (#1426)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-08-02 08:45:39 -07:00
Mariano FuentesandGitHub 2b96f71e19 see if this fixes bug with creating directory (#1419) 2023-08-02 05:24:22 +00:00
3b6b0746b3 [service-utils] - allow account level auth via jwt (#1411)
Co-authored-by: Tair Asim <[email protected]>
2023-08-02 05:23:15 +00:00
iketwandGitHub b0ec1d8083 [Wallets] Add plugin to transform flow types to fix RN FlatList bug (#1425) 2023-08-01 23:09:45 +00:00
40 changed files with 412 additions and 85 deletions
+7
View File
@@ -1,5 +1,12 @@
# @thirdweb-dev/auth
## 3.2.24
### Patch Changes
- Updated dependencies [[`3b6b0746`](https://github.com/thirdweb-dev/js/commit/3b6b0746b3fc792f4c5092814a7abfabcbc9801e), [`b0ec1d80`](https://github.com/thirdweb-dev/js/commit/b0ec1d80839efccad11b50afbf2216c2c132cf7e)]:
- @thirdweb-dev/wallets@1.1.7
## 3.2.23
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/auth",
"version": "3.2.23",
"version": "3.2.24",
"main": "dist/thirdweb-dev-auth.cjs.js",
"module": "dist/thirdweb-dev-auth.esm.js",
"browser": {
+10
View File
@@ -1,5 +1,15 @@
# thirdweb
## 0.11.7
### Patch Changes
- [#1419](https://github.com/thirdweb-dev/js/pull/1419) [`2b96f71e`](https://github.com/thirdweb-dev/js/commit/2b96f71e191d7f69c2c75f9c6a9ee4537bac65aa) Thanks [@Marfuen](https://github.com/Marfuen)! - Fix path of cache to work with windows.
- Updated dependencies [[`3b6b0746`](https://github.com/thirdweb-dev/js/commit/3b6b0746b3fc792f4c5092814a7abfabcbc9801e)]:
- @thirdweb-dev/storage@1.2.3
- @thirdweb-dev/sdk@3.10.43
## 0.11.6
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "thirdweb",
"main": "dist/cli/index.js",
"version": "0.11.6",
"version": "0.11.7",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/cli",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
+1 -1
View File
@@ -26,7 +26,7 @@ const main = async () => {
const skipIntro = process.env.THIRDWEB_CLI_SKIP_INTRO === "true";
const program = new Command();
const cache = new Cache("thirdweb:cli", {
const cache = new Cache("thirdweb-cli", {
location: path.join(os.homedir(), ".thirdweb", "creds"),
});
+9
View File
@@ -1,5 +1,14 @@
# @thirdweb-dev/react-core
## 3.14.24
### Patch Changes
- Updated dependencies [[`3b6b0746`](https://github.com/thirdweb-dev/js/commit/3b6b0746b3fc792f4c5092814a7abfabcbc9801e), [`b0ec1d80`](https://github.com/thirdweb-dev/js/commit/b0ec1d80839efccad11b50afbf2216c2c132cf7e)]:
- @thirdweb-dev/storage@1.2.3
- @thirdweb-dev/wallets@1.1.7
- @thirdweb-dev/sdk@3.10.43
## 3.14.23
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react-core",
"version": "3.14.23",
"version": "3.14.24",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-core",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
@@ -1,5 +1,7 @@
# @thirdweb-dev/react-native-compat
## 0.2.43
## 0.2.42
## 0.2.41
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@thirdweb-dev/react-native-compat",
"description": "Shims for Thirdweb in React Native Projects",
"version": "0.2.42",
"version": "0.2.43",
"author": "thirdweb eng <[email protected]>",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native-compat",
"license": "Apache-2.0",
+10
View File
@@ -1,5 +1,15 @@
# @thirdweb-dev/react-native
## 0.2.43
### Patch Changes
- Updated dependencies [[`3b6b0746`](https://github.com/thirdweb-dev/js/commit/3b6b0746b3fc792f4c5092814a7abfabcbc9801e), [`b0ec1d80`](https://github.com/thirdweb-dev/js/commit/b0ec1d80839efccad11b50afbf2216c2c132cf7e)]:
- @thirdweb-dev/storage@1.2.3
- @thirdweb-dev/wallets@1.1.7
- @thirdweb-dev/sdk@3.10.43
- @thirdweb-dev/react-core@3.14.24
## 0.2.42
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react-native",
"version": "0.2.42",
"version": "0.2.43",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
+9
View File
@@ -1,5 +1,14 @@
# @thirdweb-dev/react
## 3.14.24
### Patch Changes
- Updated dependencies [[`3b6b0746`](https://github.com/thirdweb-dev/js/commit/3b6b0746b3fc792f4c5092814a7abfabcbc9801e), [`b0ec1d80`](https://github.com/thirdweb-dev/js/commit/b0ec1d80839efccad11b50afbf2216c2c132cf7e)]:
- @thirdweb-dev/wallets@1.1.7
- @thirdweb-dev/sdk@3.10.43
- @thirdweb-dev/react-core@3.14.24
## 3.14.23
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react",
"version": "3.14.23",
"version": "3.14.24",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
+9
View File
@@ -1,5 +1,14 @@
# @thirdweb-dev/sdk
## 3.10.43
### Patch Changes
- [#1411](https://github.com/thirdweb-dev/js/pull/1411) [`3b6b0746`](https://github.com/thirdweb-dev/js/commit/3b6b0746b3fc792f4c5092814a7abfabcbc9801e) Thanks [@jnsdls](https://github.com/jnsdls)! - add auth token
- Updated dependencies [[`3b6b0746`](https://github.com/thirdweb-dev/js/commit/3b6b0746b3fc792f4c5092814a7abfabcbc9801e)]:
- @thirdweb-dev/storage@1.2.3
## 3.10.42
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/sdk",
"version": "3.10.42",
"version": "3.10.43",
"description": "The main thirdweb SDK.",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/sdk",
"license": "Apache-2.0",
+7 -1
View File
@@ -158,7 +158,7 @@ export function getProviderFromRpcUrl(
chainId?: number,
) {
try {
const headers: Record<string, string> = {};
const headers: HeadersInit = {};
if (isTwUrl(rpcUrl)) {
if (sdkOptions?.clientId) {
headers["x-client-id"] = sdkOptions?.clientId;
@@ -173,6 +173,12 @@ export function getProviderFromRpcUrl(
} else if (sdkOptions?.secretKey) {
headers["x-secret-key"] = sdkOptions?.secretKey;
}
// if we have a tw auth token on global context add it to the headers
if (typeof globalThis !== "undefined" && "TW_AUTH_TOKEN" in globalThis) {
headers["authorization"] = `Bearer ${
(globalThis as any).TW_AUTH_TOKEN as string
}`;
}
}
const match = rpcUrl.match(/^(ws|http)s?:/i);
// Try the JSON batch provider if available
+6
View File
@@ -1,5 +1,11 @@
# @thirdweb-dev/service-utils
## 0.2.5
### Patch Changes
- [#1411](https://github.com/thirdweb-dev/js/pull/1411) [`3b6b0746`](https://github.com/thirdweb-dev/js/commit/3b6b0746b3fc792f4c5092814a7abfabcbc9801e) Thanks [@jnsdls](https://github.com/jnsdls)! - allow account level auth via jwt
## 0.2.4
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/service-utils",
"version": "0.2.4",
"version": "0.2.5",
"main": "dist/thirdweb-dev-service-utils.cjs.js",
"module": "dist/thirdweb-dev-service-utils.esm.js",
"exports": {
+19 -2
View File
@@ -1,5 +1,9 @@
import type { ExecutionContext, KVNamespace } from "@cloudflare/workers-types";
import type { ApiKeyMetadata, CoreServiceConfig } from "../core/api";
import type {
ApiKeyMetadata,
AccountMetadata,
CoreServiceConfig,
} from "../core/api";
import { authorize } from "../core/authorize";
import type { Request } from "@cloudflare/workers-types";
@@ -47,7 +51,7 @@ export async function authorizeWorker(
return await authorize(authData, serviceConfig, {
get: async (clientId: string) => serviceConfig.kvStore.get(clientId),
put: (clientId: string, apiKeyMeta: ApiKeyMetadata) =>
put: (clientId: string, apiKeyMeta: ApiKeyMetadata | AccountMetadata) =>
serviceConfig.ctx.waitUntil(
serviceConfig.kvStore.put(
clientId,
@@ -124,7 +128,20 @@ async function extractAuthorizationData(
clientId = derivedClientId;
}
let jwt: string | null = null;
if (headers.has("authorization")) {
const authHeader = headers.get("authorization");
if (authHeader) {
const [type, token] = authHeader.split(" ");
if (type.toLowerCase() === "bearer") {
jwt = token;
}
}
}
return {
jwt,
hashedJWT: jwt ? await hashSecretKey(jwt) : null,
secretKey,
clientId,
origin,
+35
View File
@@ -24,6 +24,12 @@ export type ApiKeyMetadata = {
}[];
};
export type AccountMetadata = {
id: string;
name: string;
creatorWalletAddress: string;
};
export type ApiResponse = {
data: ApiKeyMetadata | null;
error: {
@@ -33,6 +39,15 @@ export type ApiResponse = {
};
};
export type ApiAccountResponse = {
data: AccountMetadata | null;
error: {
code: string;
statusCode: number;
message: string;
};
};
export async function fetchKeyMetadataFromApi(
clientId: string,
config: CoreServiceConfig,
@@ -53,3 +68,23 @@ export async function fetchKeyMetadataFromApi(
}
return (await response.json()) as ApiResponse;
}
export async function fetchAccountFromApi(
jwt: string,
config: CoreServiceConfig,
): Promise<ApiAccountResponse> {
const { apiUrl, serviceApiKey } = config;
const url = `${apiUrl}/v1/account/me`;
const response = await fetch(url, {
method: "GET",
headers: {
"x-service-api-key": serviceApiKey,
"content-type": "application/json",
authorization: `Bearer ${jwt}`,
},
});
if (!response.ok) {
throw new Error(`Error fetching account from API: ${response.statusText}`);
}
return (await response.json()) as ApiAccountResponse;
}
@@ -17,6 +17,8 @@ describe("authorizeClient", () => {
origin: null,
bundleId: null,
secretKeyHash: null,
hashedJWT: null,
jwt: null,
},
validServiceConfig,
)) as any;
@@ -33,6 +35,8 @@ describe("authorizeClient", () => {
origin: null,
bundleId: null,
secretKeyHash: null,
hashedJWT: null,
jwt: null,
},
{ ...validServiceConfig, enforceAuth: true },
)) as any;
@@ -5,13 +5,13 @@ describe("authorizeClient", () => {
const validApiKeyMeta: ApiKeyMetadata = {
id: "1",
key: "your-api-key",
accountId: "account-id",
creatorWalletAddress: "creator-address",
secretHash: "secret-hash",
walletAddresses: [],
domains: ["example.com", "*.example.com"],
bundleIds: ["com.example.app"],
services: [],
accountId: "test-account-id",
};
const validAuthOptions: ClientAuthorizationPayload = {
@@ -41,6 +41,26 @@ describe("authorizeClient", () => {
expect(result.apiKeyMeta).toEqual(validApiKeyMeta);
});
it("should authorize client with any domain w/o origin check", () => {
const authOptionsWithAnyDomain: ClientAuthorizationPayload = {
secretKeyHash: null,
bundleId: null,
origin: null,
};
const validApiKeyMetaAnyDomain = {
...validApiKeyMeta,
domains: ["*"],
};
const result = authorizeClient(
authOptionsWithAnyDomain,
validApiKeyMetaAnyDomain,
) as any;
expect(result.authorized).toBe(true);
expect(result.apiKeyMeta).toEqual(validApiKeyMetaAnyDomain);
});
it("should not authorize client with non-matching bundle id", () => {
const authOptionsWithBundleId: ClientAuthorizationPayload = {
secretKeyHash: null,
@@ -14,6 +14,22 @@ export function authorizeClient(
const { origin, bundleId, secretKeyHash: providedSecretHash } = authOptions;
const { domains, bundleIds, secretHash } = apiKeyMeta;
const authResult: AuthorizationResult = {
authorized: true,
apiKeyMeta,
accountMeta: {
id: apiKeyMeta.accountId,
// TODO update this later
name: "",
creatorWalletAddress: apiKeyMeta.creatorWalletAddress,
},
};
// check for public restrictions
if (domains.includes("*")) {
return authResult;
}
// check for secretHash
if (providedSecretHash) {
if (secretHash !== providedSecretHash) {
@@ -24,18 +40,8 @@ export function authorizeClient(
status: 401,
};
}
return {
authorized: true,
apiKeyMeta,
};
}
// check for public restrictions
if (domains.includes("*")) {
return {
authorized: true,
apiKeyMeta,
};
return authResult;
}
// validate domains
@@ -43,14 +49,22 @@ export function authorizeClient(
if (
// find matching domain, or if all domains allowed
domains.find((d) => {
// if any domain is allowed, we'll return true
if (d === "*") {
return true;
}
// special rule for `localhost`
// if the domain is localhost, we'll allow any origin that starts with localhost
if (d === "localhost" && origin.startsWith("localhost")) {
return true;
}
// If the allowedDomain has a wildcard,
// we'll check that the ending of our domain matches the wildcard
if (d.startsWith("*.")) {
const domainRoot = d.slice(2);
// get rid of the * and check if it ends with the `.<domain>.<tld>`
const domainRoot = d.slice(1);
return origin.endsWith(domainRoot);
}
@@ -58,10 +72,7 @@ export function authorizeClient(
return d === origin;
})
) {
return {
authorized: true,
apiKeyMeta,
};
return authResult;
}
return {
@@ -84,10 +95,7 @@ export function authorizeClient(
return b === bundleId;
})
) {
return {
authorized: true,
apiKeyMeta,
};
return authResult;
}
return {
@@ -1,6 +1,8 @@
import {
AccountMetadata,
ApiKeyMetadata,
CoreServiceConfig,
fetchAccountFromApi,
fetchKeyMetadataFromApi,
} from "../api";
import { authorizeClient } from "./client";
@@ -13,36 +15,124 @@ export type AuthorizationInput = {
origin: string | null;
bundleId: string | null;
secretKeyHash: string | null;
jwt: string | null;
hashedJWT: string | null;
targetAddress?: string | string[];
};
type CacheOptions = {
get: (clientId: string) => Promise<string | null>;
put: (clientId: string, data: ApiKeyMetadata) => Promise<void> | void;
put: (
clientId: string,
data: ApiKeyMetadata | AccountMetadata,
) => Promise<void> | void;
cacheTtlSeconds: number;
};
type CacheWithPossibleTtl =
type ApiKeyCacheWithPossibleTTL =
| {
apiKeyMeta: ApiKeyMetadata;
updatedAt: number;
}
| ApiKeyMetadata;
type AccountCacheWithPossibleTTL =
| {
apiKeyMeta: AccountMetadata;
updatedAt: number;
}
| AccountMetadata;
export async function authorize(
authData: AuthorizationInput,
serviceConfig: CoreServiceConfig,
cacheOptions?: CacheOptions,
): Promise<AuthorizationResult> {
const { clientId, targetAddress, secretKeyHash } = authData;
const { clientId, targetAddress, secretKeyHash, jwt, hashedJWT } = authData;
const { enforceAuth } = serviceConfig;
// BACKWARDS COMPAT: if auth not enforced and
// we don't have auth credentials bypass
// BACKWARDS COMPAT: if auth not enforced and we don't have auth credentials bypass
if (!enforceAuth && !clientId && !secretKeyHash) {
return {
authorized: true,
apiKeyMeta: null,
accountMeta: null,
};
}
// if we come in with a JWT then we only check the account is valid
if (jwt && hashedJWT) {
let accountMeta: AccountMetadata | null = null;
if (cacheOptions) {
try {
const cachedAccountInfo = await cacheOptions.get(hashedJWT);
if (cachedAccountInfo) {
const parsed = JSON.parse(
cachedAccountInfo,
) as AccountCacheWithPossibleTTL;
if ("updatedAt" in parsed) {
// we want to compare the updatedAt time to the current time
// if the difference is greater than the cacheTtl we want to ignore the cached data
const now = Date.now();
const diff = now - parsed.updatedAt;
const cacheTtl = cacheOptions.cacheTtlSeconds * 1000;
// only if the diff is less than the cacheTtl do we want to use the cached key
if (diff < cacheTtl * 1000) {
accountMeta = parsed.apiKeyMeta;
}
} else {
accountMeta = parsed;
}
}
} catch (err) {
// ignore errors, proceed as if not in cache
}
}
if (!accountMeta) {
try {
const { data, error } = await fetchAccountFromApi(jwt, serviceConfig);
if (error) {
return {
authorized: false,
errorCode: error.code,
errorMessage: error.message,
status: error.statusCode,
};
} else if (!data) {
return {
authorized: false,
errorCode: "NO_ACCOUNT",
errorMessage: "No error but also no account returned.",
status: 500,
};
}
accountMeta = data;
if (cacheOptions) {
await cacheOptions.put(hashedJWT, accountMeta);
}
} catch (err) {
console.warn("failed to fetch account from api", err);
return {
authorized: false,
status: 500,
errorMessage: "Failed to account information.",
errorCode: "FAILED_TO_ACCOUNT",
};
}
}
// if we still don't have an accountMeta at this point we can't authorize
if (!accountMeta) {
return {
authorized: false,
status: 401,
errorMessage: "Missing account information.",
errorCode: "MISSING_ACCOUNT",
};
}
// otherwise we want to return early with the accountMeta
return {
authorized: true,
apiKeyMeta: null,
accountMeta,
};
}
@@ -62,7 +152,7 @@ export async function authorize(
try {
const cachedKey = await cacheOptions.get(clientId);
if (cachedKey) {
const parsed = JSON.parse(cachedKey) as CacheWithPossibleTtl;
const parsed = JSON.parse(cachedKey) as ApiKeyCacheWithPossibleTTL;
if ("updatedAt" in parsed) {
// we want to compare the updatedAt time to the current time
// if the difference is greater than the cacheTtl we want to ignore the cached data
@@ -161,5 +251,11 @@ export async function authorize(
return {
authorized: true,
apiKeyMeta,
accountMeta: {
id: apiKeyMeta.accountId,
// TODO update this later
name: "",
creatorWalletAddress: apiKeyMeta.creatorWalletAddress,
},
};
}
@@ -5,12 +5,12 @@ describe("authorizeService", () => {
const validApiKeyMeta: ApiKeyMetadata = {
id: "1",
key: "your-api-key",
accountId: "account-id",
creatorWalletAddress: "creator-address",
secretHash: "secret-hash",
walletAddresses: [],
domains: [],
bundleIds: [],
accountId: "test-account-id",
services: [
{
name: "storage",
@@ -61,6 +61,11 @@ export function authorizeService(
return {
authorized: true,
accountMeta: {
id: apiKeyMetadata.accountId,
name: "",
creatorWalletAddress: apiKeyMetadata.creatorWalletAddress,
},
apiKeyMeta: apiKeyMetadata,
};
}
@@ -1,9 +1,10 @@
import { ApiKeyMetadata } from "../api";
import { AccountMetadata, ApiKeyMetadata } from "../api";
export type AuthorizationResult =
| {
authorized: true;
apiKeyMeta: ApiKeyMetadata | null;
accountMeta: AccountMetadata | null;
}
| {
authorized: false;
+12
View File
@@ -118,7 +118,19 @@ export function extractAuthorizationData(
clientId = derivedClientId;
}
let jwt: null | string = null;
// check for authorization header on the request
const authorizationHeader = getHeader(headers, "authorization");
if (authorizationHeader) {
const [type, token] = authorizationHeader.split(" ");
if (type.toLowerCase() === "bearer") {
jwt = token;
}
}
return {
jwt,
hashedJWT: jwt ? hashSecretKey(jwt) : null,
secretKeyHash,
secretKey,
clientId,
+6
View File
@@ -1,5 +1,11 @@
# @thirdweb-dev/storage
## 1.2.3
### Patch Changes
- [#1411](https://github.com/thirdweb-dev/js/pull/1411) [`3b6b0746`](https://github.com/thirdweb-dev/js/commit/3b6b0746b3fc792f4c5092814a7abfabcbc9801e) Thanks [@jnsdls](https://github.com/jnsdls)! - add auth token
## 1.2.2
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/storage",
"version": "1.2.2",
"version": "1.2.3",
"main": "dist/thirdweb-dev-storage.cjs.js",
"module": "dist/thirdweb-dev-storage.esm.js",
"browser": {
@@ -70,7 +70,7 @@ export class StorageDownloader implements IStorageDownloader {
console.warn(`Retrying download with backup gateway URL: ${resolvedUri}`);
}
let headers;
let headers: HeadersInit = {};
if (isTwGatewayUrl(resolvedUri)) {
if (this.secretKey) {
headers = { "x-secret-key": this.secretKey };
@@ -87,6 +87,15 @@ export class StorageDownloader implements IStorageDownloader {
"x-client-Id": this.clientId,
};
}
// if we have a authorization token on global context then add that to the headers
if (typeof globalThis !== "undefined" && "TW_AUTH_TOKEN" in globalThis) {
headers = {
...headers,
authorization: `Bearer ${
(globalThis as any).TW_AUTH_TOKEN as string
}`,
};
}
}
if (isTooManyRequests(resolvedUri)) {
@@ -270,18 +270,27 @@ export class IpfsUploader implements IStorageUploader<IpfsUploadBatchOptions> {
xhr.open("POST", `${TW_UPLOAD_SERVER_URL}/ipfs/upload`);
if (this.secretKey && this.clientId) {
throw new Error(
"Cannot use both secret key and client ID. Please use secretKey for server-side applications and clientId for client-side applications.",
);
}
if (this.secretKey) {
xhr.setRequestHeader("x-secret-key", this.secretKey);
} else if (this.clientId) {
xhr.setRequestHeader("x-client-id", this.clientId);
}
if (typeof globalThis !== "undefined" && "APP_BUNDLE_ID" in globalThis) {
xhr.setRequestHeader(
"x-bundle-id",
(globalThis as any).APP_BUNDLE_ID as string,
);
}
// if we have a authorization token on global context then add that to the headers
if (typeof globalThis !== "undefined" && "TW_AUTH_TOKEN" in globalThis) {
xhr.setRequestHeader(
"authorization",
`Bearer ${(globalThis as any).TW_AUTH_TOKEN as string}`,
);
}
xhr.send(form as any);
});
}
@@ -295,12 +304,6 @@ export class IpfsUploader implements IStorageUploader<IpfsUploadBatchOptions> {
console.warn("The onProgress option is only supported in the browser");
}
if (this.secretKey && this.clientId) {
throw new Error(
"Cannot use both secret key and client ID. Please use secretKey for server-side applications and clientId for client-side applications.",
);
}
const headers: HeadersInit = {};
if (this.secretKey) {
headers["x-secret-key"] = this.secretKey;
@@ -308,6 +311,18 @@ export class IpfsUploader implements IStorageUploader<IpfsUploadBatchOptions> {
headers["x-client-id"] = this.clientId;
}
// if we have a bundle id on global context then add that to the headers
if (typeof globalThis !== "undefined" && "APP_BUNDLE_ID" in globalThis) {
headers["x-bundle-id"] = (globalThis as any).APP_BUNDLE_ID as string;
}
// if we have a authorization token on global context then add that to the headers
if (typeof globalThis !== "undefined" && "TW_AUTH_TOKEN" in globalThis) {
headers["authorization"] = `Bearer ${
(globalThis as any).TW_AUTH_TOKEN as string
}`;
}
const res = await fetch(`${TW_UPLOAD_SERVER_URL}/ipfs/upload`, {
method: "POST",
headers: {
+10
View File
@@ -1,5 +1,15 @@
# @thirdweb-dev/unity-js-bridge
## 0.2.61
### Patch Changes
- Updated dependencies [[`3b6b0746`](https://github.com/thirdweb-dev/js/commit/3b6b0746b3fc792f4c5092814a7abfabcbc9801e), [`b0ec1d80`](https://github.com/thirdweb-dev/js/commit/b0ec1d80839efccad11b50afbf2216c2c132cf7e)]:
- @thirdweb-dev/storage@1.2.3
- @thirdweb-dev/wallets@1.1.7
- @thirdweb-dev/sdk@3.10.43
- @thirdweb-dev/auth@3.2.24
## 0.2.60
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/unity-js-bridge",
"version": "0.2.60",
"version": "0.2.61",
"main": "dist/thirdweb-unity-bridge.js",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/unity-js-bridge",
"license": "Apache-2.0",
+1
View File
@@ -4,6 +4,7 @@
["@babel/preset-env", { "targets": "defaults, not ie 11" }]
],
"plugins": [
"@babel/plugin-transform-flow-strip-types",
"@babel/plugin-transform-private-methods",
"@babel/plugin-proposal-class-properties"
]
+11
View File
@@ -1,5 +1,16 @@
# @thirdweb-dev/wallets
## 1.1.7
### Patch Changes
- [#1411](https://github.com/thirdweb-dev/js/pull/1411) [`3b6b0746`](https://github.com/thirdweb-dev/js/commit/3b6b0746b3fc792f4c5092814a7abfabcbc9801e) Thanks [@jnsdls](https://github.com/jnsdls)! - add auth token
- [#1425](https://github.com/thirdweb-dev/js/pull/1425) [`b0ec1d80`](https://github.com/thirdweb-dev/js/commit/b0ec1d80839efccad11b50afbf2216c2c132cf7e) Thanks [@iketw](https://github.com/iketw)! - Adding plugin-transform-flow-strip-types plugin to solve issues with RN FlatList
- Updated dependencies [[`3b6b0746`](https://github.com/thirdweb-dev/js/commit/3b6b0746b3fc792f4c5092814a7abfabcbc9801e)]:
- @thirdweb-dev/sdk@3.10.43
## 1.1.6
### Patch Changes
+2 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/wallets",
"version": "1.1.6",
"version": "1.1.7",
"main": "dist/thirdweb-dev-wallets.cjs.js",
"module": "dist/thirdweb-dev-wallets.esm.js",
"types": "dist/thirdweb-dev-wallets.cjs.d.ts",
@@ -396,6 +396,7 @@
},
"devDependencies": {
"@aws-sdk/client-secrets-manager": "^3.378.0",
"@babel/plugin-transform-flow-strip-types": "^7.22.5",
"@babel/plugin-transform-private-methods": "7.22.5",
"@babel/plugin-proposal-class-properties": "7.18.6",
"@noble/ed25519": "^1.7.1",
@@ -45,6 +45,12 @@ export class HttpRpcClient {
headers["x-bundle-id"] = (globalThis as any).APP_BUNDLE_ID as string;
}
}
if (typeof globalThis !== "undefined" && "TW_AUTH_TOKEN" in globalThis) {
headers["authorization"] = `Bearer ${
(globalThis as any).TW_AUTH_TOKEN as string
}`;
}
}
this.userOpJsonRpcProvider = new providers.JsonRpcProvider(
@@ -34,12 +34,6 @@ class VerifyingPaymasterAPI extends PaymasterAPI {
};
if (isTwUrl(this.paymasterUrl)) {
if (this.secretKey && this.clientId) {
throw new Error(
"Cannot use both secret key and client ID. Please use secretKey for server-side applications and clientId for client-side applications.",
);
}
if (this.secretKey) {
headers["x-secret-key"] = this.secretKey;
} else if (this.clientId) {
@@ -52,6 +46,11 @@ class VerifyingPaymasterAPI extends PaymasterAPI {
headers["x-bundle-id"] = (globalThis as any).APP_BUNDLE_ID as string;
}
}
if (typeof globalThis !== "undefined" && "TW_AUTH_TOKEN" in globalThis) {
headers["authorization"] = `Bearer ${
(globalThis as any).TW_AUTH_TOKEN as string
}`;
}
}
// Ask the paymaster to sign the transaction and return a valid paymasterAndData value.
+25 -22
View File
@@ -1391,6 +1391,9 @@ importers:
'@babel/plugin-proposal-class-properties':
specifier: 7.18.6
version: 7.18.6
'@babel/plugin-transform-flow-strip-types':
specifier: ^7.22.5
version: 7.22.5
'@babel/plugin-transform-private-methods':
specifier: 7.22.5
version: 7.22.5
@@ -2848,16 +2851,16 @@ packages:
'@babel/core': 7.22.9
'@babel/helper-plugin-utils': 7.22.5
/@babel/plugin-syntax-flow@7.18.6:
resolution: {integrity: sha512-LUbR+KNTBWCUAqRG9ex5Gnzu2IOkt8jRJbHHXFT9q+L9zm7M/QQbEqXyw1n1pohYvOyWC8CjeyjrSaIwiYjK7A==}
/@babel/plugin-syntax-flow@7.22.5:
resolution: {integrity: sha512-9RdCl0i+q0QExayk2nOS7853w08yLucnnPML6EN9S8fgMPVtdLDCdx/cOQ/i44Lb9UeQX9A35yaqBBOMMZxPxQ==}
engines: {node: '>=6.9.0'}
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
'@babel/helper-plugin-utils': 7.22.5
/@babel/plugin-syntax-flow@7.18.6(@babel/[email protected]):
resolution: {integrity: sha512-LUbR+KNTBWCUAqRG9ex5Gnzu2IOkt8jRJbHHXFT9q+L9zm7M/QQbEqXyw1n1pohYvOyWC8CjeyjrSaIwiYjK7A==}
/@babel/plugin-syntax-flow@7.22.5(@babel/[email protected]):
resolution: {integrity: sha512-9RdCl0i+q0QExayk2nOS7853w08yLucnnPML6EN9S8fgMPVtdLDCdx/cOQ/i44Lb9UeQX9A35yaqBBOMMZxPxQ==}
engines: {node: '>=6.9.0'}
peerDependencies:
'@babel/core': ^7.0.0-0
@@ -3478,24 +3481,24 @@ packages:
'@babel/helper-plugin-utils': 7.22.5
'@babel/plugin-syntax-export-namespace-from': 7.8.3(@babel/[email protected])
/@babel/[email protected]1.0:
resolution: {integrity: sha512-FlFA2Mj87a6sDkW4gfGrQQqwY/dLlBAyJa2dJEZ+FHXUVHBflO2wyKvg+OOEzXfrKYIa4HWl0mgmbCzt0cMb7w==}
/@babel/[email protected]2.5:
resolution: {integrity: sha512-tujNbZdxdG0/54g/oua8ISToaXTFBf8EnSb5PgQSciIXWOWKX3S4+JR7ZE9ol8FZwf9kxitzkGQ+QWeov/mCiA==}
engines: {node: '>=6.9.0'}
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
'@babel/helper-plugin-utils': 7.22.5
'@babel/plugin-syntax-flow': 7.18.6
'@babel/plugin-syntax-flow': 7.22.5
/@babel/[email protected]1.0(@babel/[email protected]):
resolution: {integrity: sha512-FlFA2Mj87a6sDkW4gfGrQQqwY/dLlBAyJa2dJEZ+FHXUVHBflO2wyKvg+OOEzXfrKYIa4HWl0mgmbCzt0cMb7w==}
/@babel/[email protected]2.5(@babel/[email protected]):
resolution: {integrity: sha512-tujNbZdxdG0/54g/oua8ISToaXTFBf8EnSb5PgQSciIXWOWKX3S4+JR7ZE9ol8FZwf9kxitzkGQ+QWeov/mCiA==}
engines: {node: '>=6.9.0'}
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
'@babel/core': 7.22.9
'@babel/helper-plugin-utils': 7.22.5
'@babel/plugin-syntax-flow': 7.18.6(@babel/[email protected])
'@babel/plugin-syntax-flow': 7.22.5(@babel/[email protected])
/@babel/[email protected]:
resolution: {integrity: sha512-3kxQjX1dU9uudwSshyLeEipvrLjBCVthCgeTp6CzE/9JYrlAIaeekVxRpCWsDDfYTfRZRoCeZatCQvwo+wvK8A==}
@@ -4527,7 +4530,7 @@ packages:
'@babel/core': 7.22.9
'@babel/helper-plugin-utils': 7.22.5
'@babel/helper-validator-option': 7.22.5
'@babel/plugin-transform-flow-strip-types': 7.21.0(@babel/[email protected])
'@babel/plugin-transform-flow-strip-types': 7.22.5(@babel/[email protected])
/@babel/[email protected]:
resolution: {integrity: sha512-A57th6YRG7oR3cq/yt/Y84MvGgE0eJG2F1JLhKuyG+jFxEgrd/HAMJatiFtmOiZurz+0DkrvbheCLaV5f2JfjA==}
@@ -14507,7 +14510,7 @@ packages:
'@babel/plugin-proposal-class-properties': 7.18.6
'@babel/plugin-proposal-object-rest-spread': 7.20.7
'@babel/plugin-syntax-class-properties': 7.12.13
'@babel/plugin-syntax-flow': 7.18.6
'@babel/plugin-syntax-flow': 7.22.5
'@babel/plugin-syntax-jsx': 7.22.5
'@babel/plugin-syntax-object-rest-spread': 7.8.3
'@babel/plugin-transform-arrow-functions': 7.22.5
@@ -14516,7 +14519,7 @@ packages:
'@babel/plugin-transform-classes': 7.22.5
'@babel/plugin-transform-computed-properties': 7.22.5
'@babel/plugin-transform-destructuring': 7.22.5
'@babel/plugin-transform-flow-strip-types': 7.21.0
'@babel/plugin-transform-flow-strip-types': 7.22.5
'@babel/plugin-transform-for-of': 7.22.5
'@babel/plugin-transform-function-name': 7.22.5
'@babel/plugin-transform-literals': 7.22.5
@@ -14543,7 +14546,7 @@ packages:
'@babel/plugin-proposal-class-properties': 7.18.6(@babel/[email protected])
'@babel/plugin-proposal-object-rest-spread': 7.20.7(@babel/[email protected])
'@babel/plugin-syntax-class-properties': 7.12.13(@babel/[email protected])
'@babel/plugin-syntax-flow': 7.18.6(@babel/[email protected])
'@babel/plugin-syntax-flow': 7.22.5(@babel/[email protected])
'@babel/plugin-syntax-jsx': 7.22.5(@babel/[email protected])
'@babel/plugin-syntax-object-rest-spread': 7.8.3(@babel/[email protected])
'@babel/plugin-transform-arrow-functions': 7.22.5(@babel/[email protected])
@@ -14552,7 +14555,7 @@ packages:
'@babel/plugin-transform-classes': 7.22.5(@babel/[email protected])
'@babel/plugin-transform-computed-properties': 7.22.5(@babel/[email protected])
'@babel/plugin-transform-destructuring': 7.22.5(@babel/[email protected])
'@babel/plugin-transform-flow-strip-types': 7.21.0(@babel/[email protected])
'@babel/plugin-transform-flow-strip-types': 7.22.5(@babel/[email protected])
'@babel/plugin-transform-for-of': 7.22.5(@babel/[email protected])
'@babel/plugin-transform-function-name': 7.22.5(@babel/[email protected])
'@babel/plugin-transform-literals': 7.22.5(@babel/[email protected])
@@ -14603,7 +14606,7 @@ packages:
'@babel/plugin-proposal-optional-chaining': 7.21.0(@babel/[email protected])
'@babel/plugin-proposal-private-methods': 7.18.6(@babel/[email protected])
'@babel/plugin-proposal-private-property-in-object': 7.21.0(@babel/[email protected])
'@babel/plugin-transform-flow-strip-types': 7.21.0(@babel/[email protected])
'@babel/plugin-transform-flow-strip-types': 7.22.5(@babel/[email protected])
'@babel/plugin-transform-react-display-name': 7.22.5(@babel/[email protected])
'@babel/plugin-transform-runtime': 7.21.0(@babel/[email protected])
'@babel/preset-env': 7.22.9(@babel/[email protected])
@@ -23406,7 +23409,7 @@ packages:
'@babel/plugin-proposal-optional-chaining': 7.21.0(@babel/[email protected])
'@babel/plugin-syntax-dynamic-import': 7.8.3(@babel/[email protected])
'@babel/plugin-syntax-export-default-from': 7.18.6(@babel/[email protected])
'@babel/plugin-syntax-flow': 7.18.6(@babel/[email protected])
'@babel/plugin-syntax-flow': 7.22.5(@babel/[email protected])
'@babel/plugin-syntax-nullish-coalescing-operator': 7.8.3(@babel/[email protected])
'@babel/plugin-syntax-optional-chaining': 7.8.3(@babel/[email protected])
'@babel/plugin-transform-arrow-functions': 7.22.5(@babel/[email protected])
@@ -23416,7 +23419,7 @@ packages:
'@babel/plugin-transform-computed-properties': 7.22.5(@babel/[email protected])
'@babel/plugin-transform-destructuring': 7.22.5(@babel/[email protected])
'@babel/plugin-transform-exponentiation-operator': 7.22.5(@babel/[email protected])
'@babel/plugin-transform-flow-strip-types': 7.21.0(@babel/[email protected])
'@babel/plugin-transform-flow-strip-types': 7.22.5(@babel/[email protected])
'@babel/plugin-transform-function-name': 7.22.5(@babel/[email protected])
'@babel/plugin-transform-literals': 7.22.5(@babel/[email protected])
'@babel/plugin-transform-modules-commonjs': 7.22.5(@babel/[email protected])
@@ -23452,7 +23455,7 @@ packages:
'@babel/plugin-proposal-optional-chaining': 7.21.0
'@babel/plugin-syntax-dynamic-import': 7.8.3
'@babel/plugin-syntax-export-default-from': 7.18.6
'@babel/plugin-syntax-flow': 7.18.6
'@babel/plugin-syntax-flow': 7.22.5
'@babel/plugin-syntax-nullish-coalescing-operator': 7.8.3
'@babel/plugin-syntax-optional-chaining': 7.8.3
'@babel/plugin-transform-arrow-functions': 7.22.5
@@ -23461,7 +23464,7 @@ packages:
'@babel/plugin-transform-classes': 7.22.5
'@babel/plugin-transform-computed-properties': 7.22.5
'@babel/plugin-transform-destructuring': 7.22.5
'@babel/plugin-transform-flow-strip-types': 7.21.0
'@babel/plugin-transform-flow-strip-types': 7.22.5
'@babel/plugin-transform-function-name': 7.22.5
'@babel/plugin-transform-literals': 7.22.5
'@babel/plugin-transform-modules-commonjs': 7.22.5
@@ -23498,7 +23501,7 @@ packages:
'@babel/plugin-proposal-optional-chaining': 7.21.0(@babel/[email protected])
'@babel/plugin-syntax-dynamic-import': 7.8.3(@babel/[email protected])
'@babel/plugin-syntax-export-default-from': 7.18.6(@babel/[email protected])
'@babel/plugin-syntax-flow': 7.18.6(@babel/[email protected])
'@babel/plugin-syntax-flow': 7.22.5(@babel/[email protected])
'@babel/plugin-syntax-nullish-coalescing-operator': 7.8.3(@babel/[email protected])
'@babel/plugin-syntax-optional-chaining': 7.8.3(@babel/[email protected])
'@babel/plugin-transform-arrow-functions': 7.22.5(@babel/[email protected])
@@ -23507,7 +23510,7 @@ packages:
'@babel/plugin-transform-classes': 7.22.5(@babel/[email protected])
'@babel/plugin-transform-computed-properties': 7.22.5(@babel/[email protected])
'@babel/plugin-transform-destructuring': 7.22.5(@babel/[email protected])
'@babel/plugin-transform-flow-strip-types': 7.21.0(@babel/[email protected])
'@babel/plugin-transform-flow-strip-types': 7.22.5(@babel/[email protected])
'@babel/plugin-transform-function-name': 7.22.5(@babel/[email protected])
'@babel/plugin-transform-literals': 7.22.5(@babel/[email protected])
'@babel/plugin-transform-modules-commonjs': 7.22.5(@babel/[email protected])