Skip to content

Commit

Permalink
Merge pull request #448 from arconnectio/staging
Browse files Browse the repository at this point in the history
ArConnect 1.17.0
  • Loading branch information
nicholaswma authored Jul 16, 2024
2 parents dc1d616 + 5bb86e2 commit f686682
Show file tree
Hide file tree
Showing 35 changed files with 1,063 additions and 411 deletions.
58 changes: 47 additions & 11 deletions assets/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@
"message": "Hide",
"description": "Hide text"
},
"close": {
"message": "Close",
"description": "Close button text"
},
"retry": {
"message": "Retry",
"description": "Retry button text"
},
"save": {
"message": "Save",
"description": "Save button text"
},
"add_wallet": {
"message": "Add wallet",
"description": "Add a wallet text"
Expand Down Expand Up @@ -248,39 +260,39 @@
"description": "Send transaction button"
},
"permissionDescriptionAccessAddress": {
"message": "Access the current address selected in ArConnect",
"message": "Allows access to the active address",
"description": "Description for the \"ACCESS_ADDRESS\" permission"
},
"permissionDescriptionAccessPublicKey": {
"message": "Access the public key of the current address selected in ArConnect",
"message": "Allows access to the active address public key",
"description": "Description for the \"ACCESS_PUBLIC_KEY\" permission"
},
"permissionDescriptionAccessAllAddresses": {
"message": "Access all addresses added to ArConnect",
"message": "Allows access to all the active and non-active wallet addresses",
"description": "Description for the \"ACCESS_ALL_ADDRESSES\" permission"
},
"permissionDescriptionSign": {
"message": "Sign a transaction",
"message": "Allows the signing of a transaction.",
"description": "Description for the \"SIGN_TRANSACTION\" permission"
},
"permissionDescriptionEncrypt": {
"message": "Encrypt data using the user's keyfile",
"message": "Allows encrypting data using wallet's keyfile. It does not grant access to keyfile.",
"description": "Description for the \"ENCRYPT\" permission"
},
"permissionDescriptionDecrypt": {
"message": "Decrypt data using the user's keyfile",
"message": "Allows decrypting data using wallet's keyfile. It does not grant access to keyfile.",
"description": "Description for the \"DECRYPT\" permission"
},
"permissionDescriptionSignature": {
"message": "Sign data using the user's keyfile",
"message": "Allows the signing of data.",
"description": "Description for the \"SIGNATURE\" permission"
},
"permissionDescriptionArweaveConfig": {
"message": "Access the user's custom Arweave config",
"message": "Access read access to ArConnect configuration file",
"description": "Description for the \"ACCESS_ARWEAVE_CONFIG\" permission"
},
"permissionDescriptionDispatch": {
"message": "Dispatch an Arweave transaction or interaction",
"message": "Allows using dispatch transactions.",
"description": "Description for the \"DISPATCH\" permission"
},
"copyId": {
Expand Down Expand Up @@ -665,6 +677,18 @@
"message": "Error exporting wallet",
"description": "Wallet export error notification"
},
"import_wallet_key_length_short_error_title": {
"message": "Key Length Too Short",
"description": "Key Length Too Short error title"
},
"import_wallet_key_length_short_error": {
"message": "The key length of the wallet you are importing is less than the required length to transact on the AO network. It is recommended you create a new ArConnect wallet and transfer your assets to your new wallet.",
"description": "Key Length Too Short error"
},
"generate_wallet_in_progress": {
"message": "The wallet creation process can take 30-60 seconds.",
"description": "Generate wallet in progresss text"
},
"development_version": {
"message": "Development",
"description": "Development version badge text"
Expand Down Expand Up @@ -779,6 +803,10 @@
"message": "Generating wallet...",
"description": "Generating wallet in progress text"
},
"longer_than_usual": {
"message": "Please wait, this is taking longer than usual...",
"description": "Longer than usual text"
},
"keyfile": {
"message": "Keyfile",
"description": "Keyfile text"
Expand Down Expand Up @@ -1909,11 +1937,11 @@
"description": "Popup description about ao token transfer learn more"
},
"ao_degraded": {
"message": "AO Token Process Network Degraded.",
"message": "Unable to connect to AO Token Process",
"description": "ao degraded title text"
},
"ao_degraded_description": {
"message": "AO token process will be available when <br/>the network issues are resolved.",
"message": "AO balance will be available when <br/>network issues are resolved.",
"description": "ao degraded description text"
},
"network_issue": {
Expand Down Expand Up @@ -2109,5 +2137,13 @@
"incorrect_password_error_message": {
"message": "Password incorrect. Please enter the password to your ArConnect and try again. Not the password to the wallet you are importing.",
"description": "Error message if password is incorrect"
},
"mismatch_warning_title": {
"message": "Wallet Mismatch Detected.",
"description": "Title for wallet mismatch warning on sda"
},
"mismatch_warning": {
"message": "Your wallet has a mismatched bit length. You can proceed, but may encounter errors. Transactions could fail or behave unexpectedly.",
"description": "warning for mismatch wallet"
}
}
58 changes: 47 additions & 11 deletions assets/_locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@
"message": "隐藏",
"description": "Hide text"
},
"close": {
"message": "关闭",
"description": "Close button text"
},
"retry": {
"message": "重试",
"description": "Retry button text"
},
"save": {
"message": "节省",
"description": "Save button text"
},
"add_wallet": {
"message": "添加钱包",
"description": "Add a wallet text"
Expand Down Expand Up @@ -248,39 +260,39 @@
"description": "Send transaction button"
},
"permissionDescriptionAccessAddress": {
"message": "访问 ArConnect 中选择的当前地址",
"message": "允许访问活动地址",
"description": "Description for the \"ACCESS_ADDRESS\" permission"
},
"permissionDescriptionAccessPublicKey": {
"message": "访问 ArConnect 中选择的当前地址的公钥",
"message": "允许访问活动地址的公钥",
"description": "Description for the \"ACCESS_PUBLIC_KEY\" permission"
},
"permissionDescriptionAccessAllAddresses": {
"message": "访问添加到 ArConnect 的所有地址",
"message": "允许访问所有活动和非活动钱包地址",
"description": "Description for the \"ACCESS_ALL_ADDRESSES\" permission"
},
"permissionDescriptionSign": {
"message": "签署交易",
"message": "允许签署交易。",
"description": "Description for the \"SIGN_TRANSACTION\" permission"
},
"permissionDescriptionEncrypt": {
"message": "使用用户的密钥文件加密数据",
"message": "允许使用钱包的密钥文件加密数据。这并不授予对密钥文件的访问权限",
"description": "Description for the \"ENCRYPT\" permission"
},
"permissionDescriptionDecrypt": {
"message": "使用用户的密钥文件解密数据",
"message": "允许使用钱包的密钥文件解密数据。这并不授予对密钥文件的访问权限",
"description": "Description for the \"DECRYPT\" permission"
},
"permissionDescriptionSignature": {
"message": "使用用户的密钥文件签署数据",
"message": "允许签署数据。",
"description": "Description for the \"SIGNATURE\" permission"
},
"permissionDescriptionArweaveConfig": {
"message": "访问用户的自定义 Arweave 配置",
"message": "允许读取 ArConnect 配置文件",
"description": "Description for the \"ACCESS_ARWEAVE_CONFIG\" permission"
},
"permissionDescriptionDispatch": {
"message": "发送 Arweave 交易或互动",
"message": "允许使用调度交易。",
"description": "Description for the \"DISPATCH\" permission"
},
"copyId": {
Expand Down Expand Up @@ -665,6 +677,18 @@
"message": "导出钱包出错",
"description": "Wallet export error notification"
},
"import_wallet_key_length_short_error_title": {
"message": "密钥长度太短",
"description": "Key Length Too Short error"
},
"import_wallet_key_length_short_error": {
"message": "您导入的钱包的密钥长度小于在 AO 网络上进行交易所需的长度。建议您创建一个新的ArConnect钱包,并将您的资产转移到新钱包中。",
"description": "Key Length Too Short error"
},
"generate_wallet_in_progress": {
"message": "钱包创建过程可能需要 30-60 秒。",
"description": "Generate wallet in progresss text"
},
"development_version": {
"message": "开发版本",
"description": "Development version badge text"
Expand Down Expand Up @@ -779,6 +803,10 @@
"message": "生成钱包中...",
"description": "Generating wallet in progress text"
},
"longer_than_usual": {
"message": "请稍等,这比平常需要更长的时间...",
"description": "Longer than usual text"
},
"keyfile": {
"message": "密钥文件",
"description": "Keyfile text"
Expand Down Expand Up @@ -1907,11 +1935,11 @@
"description": "Popup description about ao token transfer learn more"
},
"ao_degraded": {
"message": "AO 代币处理网络降级。",
"message": "无法连接到 AO 令牌进程",
"description": "ao degraded title text"
},
"ao_degraded_description": {
"message": "网络问题解决后,AO 代币处理将可用",
"message": "网络问题解决后,AO 余额将可用",
"description": "ao degraded description text"
},
"network_issue": {
Expand Down Expand Up @@ -2103,5 +2131,13 @@
"incorrect_password_error_message": {
"message": "密码错误。请输入 ArConnect 的密码后再试,而不是您正在导入的钱包密码。",
"description": "Error message if password is incorrect"
},
"mismatch_warning_title": {
"message": "检测到钱包不匹配。",
"description": "Title for wallet mismatch warning on sda"
},
"mismatch_warning": {
"message": "您的钱包存在不匹配的位长度。您可以继续操作,但可能会遇到错误。交易可能会失败或表现异常。",
"description": "warning for mismatch wallet"
}
}
2 changes: 1 addition & 1 deletion src/api/modules/connect/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type AuthType =
| "token"
| "sign"
| "subscription"
| "signMessage"
| "signKeystone"
| "signature"
| "signDataItem";

Expand Down
2 changes: 1 addition & 1 deletion src/api/modules/sign/chunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { nanoid } from "nanoid";
*/
export interface Chunk {
collectionID: string; // unique ID for the collection, that is the parent of this chunk
type: "tag" | "data" | "start" | "end";
type: "tag" | "data" | "bytes" | "start" | "end";
index: number; // index of the chunk, to make sure it is not in the wrong order
value?: number[] | Tag; // Uint8Array converted to number array or a tag
}
Expand Down
51 changes: 47 additions & 4 deletions src/api/modules/sign/sign_auth.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { onMessage, sendMessage } from "@arconnect/webext-bridge";
import { deconstructTransaction } from "./transaction_builder";
import { bytesToChunks, deconstructTransaction } from "./transaction_builder";
import type Transaction from "arweave/web/lib/transaction";
import type { AuthResult } from "shim";
import authenticate from "../connect/auth";
import { nanoid } from "nanoid";

/**
* Request a manual signature for the transaction.
Expand Down Expand Up @@ -73,15 +74,57 @@ export const signAuth = (
}
);

export const signAuthMessage = (dataToSign: Uint8Array) =>
export type AuthKeystoneType = "Message" | "DataItem";

export interface AuthKeystoneData {
type: AuthKeystoneType;
data: Uint8Array;
}

export const signAuthKeystone = (dataToSign: AuthKeystoneData) =>
new Promise<AuthResult<{ id: string; signature: string } | undefined>>(
(resolve, reject) => {
// start auth
const collectionID = nanoid();
authenticate({
type: "signMessage",
data: Buffer.from(dataToSign).toString("base64")
type: "signKeystone",
keystoneSignType: dataToSign.type,
collectionID
})
.then((res) => resolve(res))
.catch((err) => reject(err));
const dataChunks = bytesToChunks(dataToSign.data, collectionID, 0);

// send tx in chunks to sign if requested
onMessage("auth_listening", async ({ sender }) => {
if (sender.context !== "web_accessible") return;

// send data chunks
for (const chunk of dataChunks) {
try {
await sendMessage(
"auth_chunk",
chunk,
`web_accessible@${sender.tabId}`
);
} catch (e) {
// chunk fail
return reject(
`Error while sending a data chunk of collection "${collectionID}": \n${e}`
);
}
}

// end chunk
await sendMessage(
"auth_chunk",
{
collectionID,
type: "end",
index: dataChunks.length
},
`web_accessible@${sender.tabId}`
);
});
}
);
Loading

0 comments on commit f686682

Please sign in to comment.