@thru/programs 0.2.22 → 0.2.23

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.
Files changed (32) hide show
  1. package/dist/multicall/index.cjs +2579 -0
  2. package/dist/multicall/index.cjs.map +1 -0
  3. package/dist/multicall/index.d.cts +253 -0
  4. package/dist/multicall/index.d.ts +253 -0
  5. package/dist/multicall/index.js +2573 -0
  6. package/dist/multicall/index.js.map +1 -0
  7. package/dist/passkey-manager/index.cjs +582 -706
  8. package/dist/passkey-manager/index.cjs.map +1 -1
  9. package/dist/passkey-manager/index.d.cts +20 -14
  10. package/dist/passkey-manager/index.d.ts +20 -14
  11. package/dist/passkey-manager/index.js +551 -673
  12. package/dist/passkey-manager/index.js.map +1 -1
  13. package/package.json +7 -2
  14. package/src/multicall/abi/thru/common/primitives/types.ts +2265 -0
  15. package/src/multicall/abi/thru/program/multicall/types.ts +1232 -0
  16. package/src/multicall/index.test.ts +46 -0
  17. package/src/multicall/index.ts +81 -0
  18. package/src/passkey-manager/abi/thru/blockchain/state_proof/types.ts +95 -19
  19. package/src/passkey-manager/abi/thru/common/primitives/types.ts +111 -37
  20. package/src/passkey-manager/abi/thru/program/passkey_manager/types.ts +248 -660
  21. package/src/passkey-manager/challenge.ts +52 -12
  22. package/src/passkey-manager/constants.ts +0 -1
  23. package/src/passkey-manager/index.ts +4 -4
  24. package/src/passkey-manager/instructions/add-authority.ts +8 -2
  25. package/src/passkey-manager/instructions/remove-authority.ts +9 -2
  26. package/src/passkey-manager/instructions/validate.ts +60 -14
  27. package/src/passkey-manager/target-instruction.ts +29 -0
  28. package/src/passkey-manager/types.ts +16 -0
  29. package/src/passkey-manager/validate.test.ts +173 -0
  30. package/tsup.config.ts +1 -0
  31. package/src/passkey-manager/instructions/invoke.ts +0 -25
  32. package/src/passkey-manager/instructions/shared.ts +0 -12
@@ -4,7 +4,6 @@ declare const PASSKEY_MANAGER_PROGRAM_ADDRESS = "taUDdQyFxvM5i0HFRkEK3W45kWLyblA
4
4
  declare const INSTRUCTION_CREATE = 0;
5
5
  declare const INSTRUCTION_VALIDATE = 1;
6
6
  declare const INSTRUCTION_TRANSFER = 2;
7
- declare const INSTRUCTION_INVOKE = 3;
8
7
  declare const INSTRUCTION_ADD_AUTHORITY = 4;
9
8
  declare const INSTRUCTION_REMOVE_AUTHORITY = 5;
10
9
  declare const INSTRUCTION_REGISTER_CREDENTIAL = 6;
@@ -81,14 +80,27 @@ interface TransferInstructionParams {
81
80
  toAccountIdx: number;
82
81
  amount: bigint;
83
82
  }
83
+ interface TargetInstructionParams {
84
+ programIdx: number;
85
+ instructionData: Uint8Array;
86
+ }
84
87
  interface ValidateInstructionParams {
85
88
  walletAccountIdx: number;
86
89
  authIdx: number;
90
+ targetInstruction: TargetInstructionParams;
87
91
  signatureR: Uint8Array;
88
92
  signatureS: Uint8Array;
89
93
  authenticatorData: Uint8Array;
90
94
  clientDataJSON: Uint8Array;
91
95
  }
96
+ interface AddAuthorityInstructionParams {
97
+ walletAccountIdx: number;
98
+ authority: Authority;
99
+ }
100
+ interface RemoveAuthorityInstructionParams {
101
+ walletAccountIdx: number;
102
+ authIdx: number;
103
+ }
92
104
  interface AccountContext {
93
105
  readWriteAddresses: string[];
94
106
  readOnlyAddresses: string[];
@@ -117,25 +129,19 @@ declare function encodeValidateInstruction(params: ValidateInstructionParams): U
117
129
 
118
130
  declare function encodeTransferInstruction(params: TransferInstructionParams): Uint8Array;
119
131
 
120
- declare function encodeInvokeInstruction(programPubkey: Uint8Array, instruction: Uint8Array): Uint8Array;
132
+ declare function encodeAddAuthorityInstruction(params: AddAuthorityInstructionParams): Uint8Array;
121
133
 
122
- declare function encodeAddAuthorityInstruction(params: {
123
- authority: Authority;
124
- }): Uint8Array;
125
-
126
- declare function encodeRemoveAuthorityInstruction(params: {
127
- authIdx: number;
128
- }): Uint8Array;
134
+ declare function encodeRemoveAuthorityInstruction(params: RemoveAuthorityInstructionParams): Uint8Array;
129
135
 
130
136
  declare function encodeRegisterCredentialInstruction(params: RegisterCredentialInstructionParams): Uint8Array;
131
137
 
132
- declare function concatenateInstructions(instructions: Uint8Array[]): Uint8Array;
133
-
134
138
  /**
135
139
  * Create challenge for VALIDATE instruction.
136
- * SHA256(nonce || account_0 || account_1 || ... || trailing_instruction_bytes)
140
+ * SHA256(domain || nonce || wallet_account_idx || auth_idx || account_count ||
141
+ * account_0 || account_1 || ... || target_instruction)
137
142
  */
138
- declare function createValidateChallenge(nonce: bigint, accountAddresses: string[], trailingInstructionData: Uint8Array): Promise<Uint8Array>;
143
+ declare const VALIDATE_CHALLENGE_DOMAIN = "thru.passkey.validate";
144
+ declare function createValidateChallenge(nonce: bigint, accountAddresses: string[], walletAccountIdx: number, authIdx: number, targetInstruction: TargetInstructionParams): Promise<Uint8Array>;
139
145
 
140
146
  /**
141
147
  * Create a 32-byte seed from wallet name and passkey coordinates.
@@ -316,4 +322,4 @@ declare function bytesEqual(a: Uint8Array, b: Uint8Array): boolean;
316
322
  declare function compareBytes(a: Uint8Array, b: Uint8Array): number;
317
323
  declare function uniqueAccounts(accounts: Uint8Array[]): Uint8Array[];
318
324
 
319
- export { AUTHORITY_TAG_PASSKEY, AUTHORITY_TAG_PUBKEY, type AccountContext, type Authority, type CheckablePasskeyAuthorityIdentity, type CreateInstructionParams, FEE_PAYER_ADDRESS, INSTRUCTION_ADD_AUTHORITY, INSTRUCTION_CREATE, INSTRUCTION_INVOKE, INSTRUCTION_REGISTER_CREDENTIAL, INSTRUCTION_REMOVE_AUTHORITY, INSTRUCTION_TRANSFER, INSTRUCTION_VALIDATE, P256_HALF_N, P256_N, PASSKEY_MANAGER_PROGRAM_ADDRESS, type ParsedAuthority, type PasskeyAuthorityIdentity, type PasskeyAuthorityTarget, type PasskeyDiscoverableSigningResult, type PasskeyMetadata, type PasskeyRegistrationResult, type PasskeySigningResult, type PreparePasskeyAuthorityTargetsOptions, type RegisterCredentialInstructionParams, type TransactionExecutionSummary, type TransferInstructionParams, type ValidateInstructionParams, type WalletAuthorities, type WalletSigner, arrayBufferToBase64Url, base64UrlToArrayBuffer, base64UrlToBytes, bigIntToBytesBE, buildAccountContext, buildPasskeyReadWriteAccounts, bytesEqual, bytesToBase64, bytesToBase64Url, bytesToBigIntBE, bytesToHex, compareBytes, concatenateInstructions, createCredentialLookupSeed, createValidateChallenge, createWalletSeed, deriveCredentialLookupAddress, deriveWalletAddress, encodeAddAuthorityInstruction, encodeCreateInstruction, encodeInvokeInstruction, encodeRegisterCredentialInstruction, encodeRemoveAuthorityInstruction, encodeTransferInstruction, encodeValidateInstruction, fetchWalletNonce, findPasskeyAuthorityIndexForIdentity, findPasskeyAuthorityIndexInWalletData, formatAuthorityPubkey, hexToBytes, isPasskeyAuthorityCheckable, normalizeLowS, normalizeSignatureComponent, parseCredentialLookupWallet, parseDerSignature, parseWalletAuthorities, parseWalletNonce, preparePasskeyAuthorityTargets, resolvePasskeyAuthorityIndex, uniqueAccounts };
325
+ export { AUTHORITY_TAG_PASSKEY, AUTHORITY_TAG_PUBKEY, type AccountContext, type AddAuthorityInstructionParams, type Authority, type CheckablePasskeyAuthorityIdentity, type CreateInstructionParams, FEE_PAYER_ADDRESS, INSTRUCTION_ADD_AUTHORITY, INSTRUCTION_CREATE, INSTRUCTION_REGISTER_CREDENTIAL, INSTRUCTION_REMOVE_AUTHORITY, INSTRUCTION_TRANSFER, INSTRUCTION_VALIDATE, P256_HALF_N, P256_N, PASSKEY_MANAGER_PROGRAM_ADDRESS, type ParsedAuthority, type PasskeyAuthorityIdentity, type PasskeyAuthorityTarget, type PasskeyDiscoverableSigningResult, type PasskeyMetadata, type PasskeyRegistrationResult, type PasskeySigningResult, type PreparePasskeyAuthorityTargetsOptions, type RegisterCredentialInstructionParams, type RemoveAuthorityInstructionParams, type TargetInstructionParams, type TransactionExecutionSummary, type TransferInstructionParams, VALIDATE_CHALLENGE_DOMAIN, type ValidateInstructionParams, type WalletAuthorities, type WalletSigner, arrayBufferToBase64Url, base64UrlToArrayBuffer, base64UrlToBytes, bigIntToBytesBE, buildAccountContext, buildPasskeyReadWriteAccounts, bytesEqual, bytesToBase64, bytesToBase64Url, bytesToBigIntBE, bytesToHex, compareBytes, createCredentialLookupSeed, createValidateChallenge, createWalletSeed, deriveCredentialLookupAddress, deriveWalletAddress, encodeAddAuthorityInstruction, encodeCreateInstruction, encodeRegisterCredentialInstruction, encodeRemoveAuthorityInstruction, encodeTransferInstruction, encodeValidateInstruction, fetchWalletNonce, findPasskeyAuthorityIndexForIdentity, findPasskeyAuthorityIndexInWalletData, formatAuthorityPubkey, hexToBytes, isPasskeyAuthorityCheckable, normalizeLowS, normalizeSignatureComponent, parseCredentialLookupWallet, parseDerSignature, parseWalletAuthorities, parseWalletNonce, preparePasskeyAuthorityTargets, resolvePasskeyAuthorityIndex, uniqueAccounts };
@@ -4,7 +4,6 @@ declare const PASSKEY_MANAGER_PROGRAM_ADDRESS = "taUDdQyFxvM5i0HFRkEK3W45kWLyblA
4
4
  declare const INSTRUCTION_CREATE = 0;
5
5
  declare const INSTRUCTION_VALIDATE = 1;
6
6
  declare const INSTRUCTION_TRANSFER = 2;
7
- declare const INSTRUCTION_INVOKE = 3;
8
7
  declare const INSTRUCTION_ADD_AUTHORITY = 4;
9
8
  declare const INSTRUCTION_REMOVE_AUTHORITY = 5;
10
9
  declare const INSTRUCTION_REGISTER_CREDENTIAL = 6;
@@ -81,14 +80,27 @@ interface TransferInstructionParams {
81
80
  toAccountIdx: number;
82
81
  amount: bigint;
83
82
  }
83
+ interface TargetInstructionParams {
84
+ programIdx: number;
85
+ instructionData: Uint8Array;
86
+ }
84
87
  interface ValidateInstructionParams {
85
88
  walletAccountIdx: number;
86
89
  authIdx: number;
90
+ targetInstruction: TargetInstructionParams;
87
91
  signatureR: Uint8Array;
88
92
  signatureS: Uint8Array;
89
93
  authenticatorData: Uint8Array;
90
94
  clientDataJSON: Uint8Array;
91
95
  }
96
+ interface AddAuthorityInstructionParams {
97
+ walletAccountIdx: number;
98
+ authority: Authority;
99
+ }
100
+ interface RemoveAuthorityInstructionParams {
101
+ walletAccountIdx: number;
102
+ authIdx: number;
103
+ }
92
104
  interface AccountContext {
93
105
  readWriteAddresses: string[];
94
106
  readOnlyAddresses: string[];
@@ -117,25 +129,19 @@ declare function encodeValidateInstruction(params: ValidateInstructionParams): U
117
129
 
118
130
  declare function encodeTransferInstruction(params: TransferInstructionParams): Uint8Array;
119
131
 
120
- declare function encodeInvokeInstruction(programPubkey: Uint8Array, instruction: Uint8Array): Uint8Array;
132
+ declare function encodeAddAuthorityInstruction(params: AddAuthorityInstructionParams): Uint8Array;
121
133
 
122
- declare function encodeAddAuthorityInstruction(params: {
123
- authority: Authority;
124
- }): Uint8Array;
125
-
126
- declare function encodeRemoveAuthorityInstruction(params: {
127
- authIdx: number;
128
- }): Uint8Array;
134
+ declare function encodeRemoveAuthorityInstruction(params: RemoveAuthorityInstructionParams): Uint8Array;
129
135
 
130
136
  declare function encodeRegisterCredentialInstruction(params: RegisterCredentialInstructionParams): Uint8Array;
131
137
 
132
- declare function concatenateInstructions(instructions: Uint8Array[]): Uint8Array;
133
-
134
138
  /**
135
139
  * Create challenge for VALIDATE instruction.
136
- * SHA256(nonce || account_0 || account_1 || ... || trailing_instruction_bytes)
140
+ * SHA256(domain || nonce || wallet_account_idx || auth_idx || account_count ||
141
+ * account_0 || account_1 || ... || target_instruction)
137
142
  */
138
- declare function createValidateChallenge(nonce: bigint, accountAddresses: string[], trailingInstructionData: Uint8Array): Promise<Uint8Array>;
143
+ declare const VALIDATE_CHALLENGE_DOMAIN = "thru.passkey.validate";
144
+ declare function createValidateChallenge(nonce: bigint, accountAddresses: string[], walletAccountIdx: number, authIdx: number, targetInstruction: TargetInstructionParams): Promise<Uint8Array>;
139
145
 
140
146
  /**
141
147
  * Create a 32-byte seed from wallet name and passkey coordinates.
@@ -316,4 +322,4 @@ declare function bytesEqual(a: Uint8Array, b: Uint8Array): boolean;
316
322
  declare function compareBytes(a: Uint8Array, b: Uint8Array): number;
317
323
  declare function uniqueAccounts(accounts: Uint8Array[]): Uint8Array[];
318
324
 
319
- export { AUTHORITY_TAG_PASSKEY, AUTHORITY_TAG_PUBKEY, type AccountContext, type Authority, type CheckablePasskeyAuthorityIdentity, type CreateInstructionParams, FEE_PAYER_ADDRESS, INSTRUCTION_ADD_AUTHORITY, INSTRUCTION_CREATE, INSTRUCTION_INVOKE, INSTRUCTION_REGISTER_CREDENTIAL, INSTRUCTION_REMOVE_AUTHORITY, INSTRUCTION_TRANSFER, INSTRUCTION_VALIDATE, P256_HALF_N, P256_N, PASSKEY_MANAGER_PROGRAM_ADDRESS, type ParsedAuthority, type PasskeyAuthorityIdentity, type PasskeyAuthorityTarget, type PasskeyDiscoverableSigningResult, type PasskeyMetadata, type PasskeyRegistrationResult, type PasskeySigningResult, type PreparePasskeyAuthorityTargetsOptions, type RegisterCredentialInstructionParams, type TransactionExecutionSummary, type TransferInstructionParams, type ValidateInstructionParams, type WalletAuthorities, type WalletSigner, arrayBufferToBase64Url, base64UrlToArrayBuffer, base64UrlToBytes, bigIntToBytesBE, buildAccountContext, buildPasskeyReadWriteAccounts, bytesEqual, bytesToBase64, bytesToBase64Url, bytesToBigIntBE, bytesToHex, compareBytes, concatenateInstructions, createCredentialLookupSeed, createValidateChallenge, createWalletSeed, deriveCredentialLookupAddress, deriveWalletAddress, encodeAddAuthorityInstruction, encodeCreateInstruction, encodeInvokeInstruction, encodeRegisterCredentialInstruction, encodeRemoveAuthorityInstruction, encodeTransferInstruction, encodeValidateInstruction, fetchWalletNonce, findPasskeyAuthorityIndexForIdentity, findPasskeyAuthorityIndexInWalletData, formatAuthorityPubkey, hexToBytes, isPasskeyAuthorityCheckable, normalizeLowS, normalizeSignatureComponent, parseCredentialLookupWallet, parseDerSignature, parseWalletAuthorities, parseWalletNonce, preparePasskeyAuthorityTargets, resolvePasskeyAuthorityIndex, uniqueAccounts };
325
+ export { AUTHORITY_TAG_PASSKEY, AUTHORITY_TAG_PUBKEY, type AccountContext, type AddAuthorityInstructionParams, type Authority, type CheckablePasskeyAuthorityIdentity, type CreateInstructionParams, FEE_PAYER_ADDRESS, INSTRUCTION_ADD_AUTHORITY, INSTRUCTION_CREATE, INSTRUCTION_REGISTER_CREDENTIAL, INSTRUCTION_REMOVE_AUTHORITY, INSTRUCTION_TRANSFER, INSTRUCTION_VALIDATE, P256_HALF_N, P256_N, PASSKEY_MANAGER_PROGRAM_ADDRESS, type ParsedAuthority, type PasskeyAuthorityIdentity, type PasskeyAuthorityTarget, type PasskeyDiscoverableSigningResult, type PasskeyMetadata, type PasskeyRegistrationResult, type PasskeySigningResult, type PreparePasskeyAuthorityTargetsOptions, type RegisterCredentialInstructionParams, type RemoveAuthorityInstructionParams, type TargetInstructionParams, type TransactionExecutionSummary, type TransferInstructionParams, VALIDATE_CHALLENGE_DOMAIN, type ValidateInstructionParams, type WalletAuthorities, type WalletSigner, arrayBufferToBase64Url, base64UrlToArrayBuffer, base64UrlToBytes, bigIntToBytesBE, buildAccountContext, buildPasskeyReadWriteAccounts, bytesEqual, bytesToBase64, bytesToBase64Url, bytesToBigIntBE, bytesToHex, compareBytes, createCredentialLookupSeed, createValidateChallenge, createWalletSeed, deriveCredentialLookupAddress, deriveWalletAddress, encodeAddAuthorityInstruction, encodeCreateInstruction, encodeRegisterCredentialInstruction, encodeRemoveAuthorityInstruction, encodeTransferInstruction, encodeValidateInstruction, fetchWalletNonce, findPasskeyAuthorityIndexForIdentity, findPasskeyAuthorityIndexInWalletData, formatAuthorityPubkey, hexToBytes, isPasskeyAuthorityCheckable, normalizeLowS, normalizeSignatureComponent, parseCredentialLookupWallet, parseDerSignature, parseWalletAuthorities, parseWalletNonce, preparePasskeyAuthorityTargets, resolvePasskeyAuthorityIndex, uniqueAccounts };