@thru/passkey-manager 0.2.1 → 0.2.3
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/index.cjs +499 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -2
- package/dist/index.d.ts +24 -2
- package/dist/index.js +495 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/abi/thru/program/passkey_manager/types.ts +586 -1
- package/src/constants.ts +2 -1
- package/src/index.ts +4 -1
- package/src/instructions/register-credential.ts +33 -0
- package/src/seeds.ts +33 -0
- package/src/types.ts +7 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
declare const PASSKEY_MANAGER_PROGRAM_ADDRESS = "
|
|
1
|
+
declare const PASSKEY_MANAGER_PROGRAM_ADDRESS = "taUDdQyFxvM5i0HFRkEK3W45kWLyblAHSnMg4zplgUnz6Z";
|
|
2
2
|
declare const INSTRUCTION_CREATE = 0;
|
|
3
3
|
declare const INSTRUCTION_VALIDATE = 1;
|
|
4
4
|
declare const INSTRUCTION_TRANSFER = 2;
|
|
5
5
|
declare const INSTRUCTION_INVOKE = 3;
|
|
6
6
|
declare const INSTRUCTION_ADD_AUTHORITY = 4;
|
|
7
7
|
declare const INSTRUCTION_REMOVE_AUTHORITY = 5;
|
|
8
|
+
declare const INSTRUCTION_REGISTER_CREDENTIAL = 6;
|
|
8
9
|
declare const AUTHORITY_TAG_PASSKEY = 1;
|
|
9
10
|
declare const AUTHORITY_TAG_PUBKEY = 2;
|
|
10
11
|
|
|
@@ -80,6 +81,12 @@ interface AccountContext {
|
|
|
80
81
|
walletAccountIdx: number;
|
|
81
82
|
getAccountIndex: (pubkey: Uint8Array) => number;
|
|
82
83
|
}
|
|
84
|
+
interface RegisterCredentialInstructionParams {
|
|
85
|
+
walletAccountIdx: number;
|
|
86
|
+
lookupAccountIdx: number;
|
|
87
|
+
seed: Uint8Array;
|
|
88
|
+
stateProof: Uint8Array;
|
|
89
|
+
}
|
|
83
90
|
type WalletSigner = {
|
|
84
91
|
signTransaction: (payloadBase64: string) => Promise<string>;
|
|
85
92
|
};
|
|
@@ -105,6 +112,8 @@ declare function encodeRemoveAuthorityInstruction(params: {
|
|
|
105
112
|
authIdx: number;
|
|
106
113
|
}): Uint8Array;
|
|
107
114
|
|
|
115
|
+
declare function encodeRegisterCredentialInstruction(params: RegisterCredentialInstructionParams): Uint8Array;
|
|
116
|
+
|
|
108
117
|
declare function concatenateInstructions(instructions: Uint8Array[]): Uint8Array;
|
|
109
118
|
|
|
110
119
|
/**
|
|
@@ -123,6 +132,19 @@ declare function createWalletSeed(walletName: string, pubkeyX: Uint8Array, pubke
|
|
|
123
132
|
* SHA256(program_address || is_ephemeral || seed)
|
|
124
133
|
*/
|
|
125
134
|
declare function deriveWalletAddress(seed: Uint8Array, programAddress: string): Promise<Uint8Array>;
|
|
135
|
+
/**
|
|
136
|
+
* Create a 32-byte seed for a credential lookup PDA.
|
|
137
|
+
* SHA-256(credentialId || walletName)
|
|
138
|
+
*
|
|
139
|
+
* Including walletName makes the lookup unique per (credential, wallet) pair,
|
|
140
|
+
* so one passkey can be an authority on multiple wallets with separate lookups.
|
|
141
|
+
*/
|
|
142
|
+
declare function createCredentialLookupSeed(credentialId: Uint8Array, walletName: string): Promise<Uint8Array>;
|
|
143
|
+
/**
|
|
144
|
+
* Derive credential lookup PDA address from a credential ID and wallet name.
|
|
145
|
+
* Convenience wrapper: deriveWalletAddress(SHA-256(credentialId || walletName), programAddress)
|
|
146
|
+
*/
|
|
147
|
+
declare function deriveCredentialLookupAddress(credentialId: Uint8Array, walletName: string, programAddress: string): Promise<Uint8Array>;
|
|
126
148
|
|
|
127
149
|
/**
|
|
128
150
|
* Default fee payer address (manager profile).
|
|
@@ -198,4 +220,4 @@ declare function bytesEqual(a: Uint8Array, b: Uint8Array): boolean;
|
|
|
198
220
|
declare function compareBytes(a: Uint8Array, b: Uint8Array): number;
|
|
199
221
|
declare function uniqueAccounts(accounts: Uint8Array[]): Uint8Array[];
|
|
200
222
|
|
|
201
|
-
export { AUTHORITY_TAG_PASSKEY, AUTHORITY_TAG_PUBKEY, type AccountContext, type Authority, type CreateInstructionParams, FEE_PAYER_ADDRESS, INSTRUCTION_ADD_AUTHORITY, INSTRUCTION_CREATE, INSTRUCTION_INVOKE, INSTRUCTION_REMOVE_AUTHORITY, INSTRUCTION_TRANSFER, INSTRUCTION_VALIDATE, P256_HALF_N, P256_N, PASSKEY_MANAGER_PROGRAM_ADDRESS, type PasskeyDiscoverableSigningResult, type PasskeyMetadata, type PasskeyRegistrationResult, type PasskeySigningResult, type TransactionExecutionSummary, type TransferInstructionParams, type ValidateInstructionParams, type WalletSigner, arrayBufferToBase64Url, base64UrlToArrayBuffer, base64UrlToBytes, bigIntToBytesBE, buildAccountContext, buildPasskeyReadWriteAccounts, bytesEqual, bytesToBase64Url, bytesToBigIntBE, bytesToHex, compareBytes, concatenateInstructions, createValidateChallenge, createWalletSeed, deriveWalletAddress, encodeAddAuthorityInstruction, encodeCreateInstruction, encodeInvokeInstruction, encodeRemoveAuthorityInstruction, encodeTransferInstruction, encodeValidateInstruction, fetchWalletNonce, hexToBytes, normalizeLowS, normalizeSignatureComponent, parseDerSignature, parseWalletNonce, uniqueAccounts };
|
|
223
|
+
export { AUTHORITY_TAG_PASSKEY, AUTHORITY_TAG_PUBKEY, type AccountContext, type Authority, 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 PasskeyDiscoverableSigningResult, type PasskeyMetadata, type PasskeyRegistrationResult, type PasskeySigningResult, type RegisterCredentialInstructionParams, type TransactionExecutionSummary, type TransferInstructionParams, type ValidateInstructionParams, type WalletSigner, arrayBufferToBase64Url, base64UrlToArrayBuffer, base64UrlToBytes, bigIntToBytesBE, buildAccountContext, buildPasskeyReadWriteAccounts, bytesEqual, bytesToBase64Url, bytesToBigIntBE, bytesToHex, compareBytes, concatenateInstructions, createCredentialLookupSeed, createValidateChallenge, createWalletSeed, deriveCredentialLookupAddress, deriveWalletAddress, encodeAddAuthorityInstruction, encodeCreateInstruction, encodeInvokeInstruction, encodeRegisterCredentialInstruction, encodeRemoveAuthorityInstruction, encodeTransferInstruction, encodeValidateInstruction, fetchWalletNonce, hexToBytes, normalizeLowS, normalizeSignatureComponent, parseDerSignature, parseWalletNonce, uniqueAccounts };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
declare const PASSKEY_MANAGER_PROGRAM_ADDRESS = "
|
|
1
|
+
declare const PASSKEY_MANAGER_PROGRAM_ADDRESS = "taUDdQyFxvM5i0HFRkEK3W45kWLyblAHSnMg4zplgUnz6Z";
|
|
2
2
|
declare const INSTRUCTION_CREATE = 0;
|
|
3
3
|
declare const INSTRUCTION_VALIDATE = 1;
|
|
4
4
|
declare const INSTRUCTION_TRANSFER = 2;
|
|
5
5
|
declare const INSTRUCTION_INVOKE = 3;
|
|
6
6
|
declare const INSTRUCTION_ADD_AUTHORITY = 4;
|
|
7
7
|
declare const INSTRUCTION_REMOVE_AUTHORITY = 5;
|
|
8
|
+
declare const INSTRUCTION_REGISTER_CREDENTIAL = 6;
|
|
8
9
|
declare const AUTHORITY_TAG_PASSKEY = 1;
|
|
9
10
|
declare const AUTHORITY_TAG_PUBKEY = 2;
|
|
10
11
|
|
|
@@ -80,6 +81,12 @@ interface AccountContext {
|
|
|
80
81
|
walletAccountIdx: number;
|
|
81
82
|
getAccountIndex: (pubkey: Uint8Array) => number;
|
|
82
83
|
}
|
|
84
|
+
interface RegisterCredentialInstructionParams {
|
|
85
|
+
walletAccountIdx: number;
|
|
86
|
+
lookupAccountIdx: number;
|
|
87
|
+
seed: Uint8Array;
|
|
88
|
+
stateProof: Uint8Array;
|
|
89
|
+
}
|
|
83
90
|
type WalletSigner = {
|
|
84
91
|
signTransaction: (payloadBase64: string) => Promise<string>;
|
|
85
92
|
};
|
|
@@ -105,6 +112,8 @@ declare function encodeRemoveAuthorityInstruction(params: {
|
|
|
105
112
|
authIdx: number;
|
|
106
113
|
}): Uint8Array;
|
|
107
114
|
|
|
115
|
+
declare function encodeRegisterCredentialInstruction(params: RegisterCredentialInstructionParams): Uint8Array;
|
|
116
|
+
|
|
108
117
|
declare function concatenateInstructions(instructions: Uint8Array[]): Uint8Array;
|
|
109
118
|
|
|
110
119
|
/**
|
|
@@ -123,6 +132,19 @@ declare function createWalletSeed(walletName: string, pubkeyX: Uint8Array, pubke
|
|
|
123
132
|
* SHA256(program_address || is_ephemeral || seed)
|
|
124
133
|
*/
|
|
125
134
|
declare function deriveWalletAddress(seed: Uint8Array, programAddress: string): Promise<Uint8Array>;
|
|
135
|
+
/**
|
|
136
|
+
* Create a 32-byte seed for a credential lookup PDA.
|
|
137
|
+
* SHA-256(credentialId || walletName)
|
|
138
|
+
*
|
|
139
|
+
* Including walletName makes the lookup unique per (credential, wallet) pair,
|
|
140
|
+
* so one passkey can be an authority on multiple wallets with separate lookups.
|
|
141
|
+
*/
|
|
142
|
+
declare function createCredentialLookupSeed(credentialId: Uint8Array, walletName: string): Promise<Uint8Array>;
|
|
143
|
+
/**
|
|
144
|
+
* Derive credential lookup PDA address from a credential ID and wallet name.
|
|
145
|
+
* Convenience wrapper: deriveWalletAddress(SHA-256(credentialId || walletName), programAddress)
|
|
146
|
+
*/
|
|
147
|
+
declare function deriveCredentialLookupAddress(credentialId: Uint8Array, walletName: string, programAddress: string): Promise<Uint8Array>;
|
|
126
148
|
|
|
127
149
|
/**
|
|
128
150
|
* Default fee payer address (manager profile).
|
|
@@ -198,4 +220,4 @@ declare function bytesEqual(a: Uint8Array, b: Uint8Array): boolean;
|
|
|
198
220
|
declare function compareBytes(a: Uint8Array, b: Uint8Array): number;
|
|
199
221
|
declare function uniqueAccounts(accounts: Uint8Array[]): Uint8Array[];
|
|
200
222
|
|
|
201
|
-
export { AUTHORITY_TAG_PASSKEY, AUTHORITY_TAG_PUBKEY, type AccountContext, type Authority, type CreateInstructionParams, FEE_PAYER_ADDRESS, INSTRUCTION_ADD_AUTHORITY, INSTRUCTION_CREATE, INSTRUCTION_INVOKE, INSTRUCTION_REMOVE_AUTHORITY, INSTRUCTION_TRANSFER, INSTRUCTION_VALIDATE, P256_HALF_N, P256_N, PASSKEY_MANAGER_PROGRAM_ADDRESS, type PasskeyDiscoverableSigningResult, type PasskeyMetadata, type PasskeyRegistrationResult, type PasskeySigningResult, type TransactionExecutionSummary, type TransferInstructionParams, type ValidateInstructionParams, type WalletSigner, arrayBufferToBase64Url, base64UrlToArrayBuffer, base64UrlToBytes, bigIntToBytesBE, buildAccountContext, buildPasskeyReadWriteAccounts, bytesEqual, bytesToBase64Url, bytesToBigIntBE, bytesToHex, compareBytes, concatenateInstructions, createValidateChallenge, createWalletSeed, deriveWalletAddress, encodeAddAuthorityInstruction, encodeCreateInstruction, encodeInvokeInstruction, encodeRemoveAuthorityInstruction, encodeTransferInstruction, encodeValidateInstruction, fetchWalletNonce, hexToBytes, normalizeLowS, normalizeSignatureComponent, parseDerSignature, parseWalletNonce, uniqueAccounts };
|
|
223
|
+
export { AUTHORITY_TAG_PASSKEY, AUTHORITY_TAG_PUBKEY, type AccountContext, type Authority, 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 PasskeyDiscoverableSigningResult, type PasskeyMetadata, type PasskeyRegistrationResult, type PasskeySigningResult, type RegisterCredentialInstructionParams, type TransactionExecutionSummary, type TransferInstructionParams, type ValidateInstructionParams, type WalletSigner, arrayBufferToBase64Url, base64UrlToArrayBuffer, base64UrlToBytes, bigIntToBytesBE, buildAccountContext, buildPasskeyReadWriteAccounts, bytesEqual, bytesToBase64Url, bytesToBigIntBE, bytesToHex, compareBytes, concatenateInstructions, createCredentialLookupSeed, createValidateChallenge, createWalletSeed, deriveCredentialLookupAddress, deriveWalletAddress, encodeAddAuthorityInstruction, encodeCreateInstruction, encodeInvokeInstruction, encodeRegisterCredentialInstruction, encodeRemoveAuthorityInstruction, encodeTransferInstruction, encodeValidateInstruction, fetchWalletNonce, hexToBytes, normalizeLowS, normalizeSignatureComponent, parseDerSignature, parseWalletNonce, uniqueAccounts };
|