@thru/passkey-manager 0.2.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/README.md +150 -0
- package/dist/index.cjs +6800 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +201 -0
- package/dist/index.d.ts +201 -0
- package/dist/index.js +6734 -0
- package/dist/index.js.map +1 -0
- package/package.json +27 -0
- package/src/abi/thru/blockchain/state_proof/types.ts +1667 -0
- package/src/abi/thru/common/primitives/types.ts +2191 -0
- package/src/abi/thru/program/passkey_manager/types.ts +4392 -0
- package/src/accounts.ts +26 -0
- package/src/challenge.ts +39 -0
- package/src/constants.ts +14 -0
- package/src/context.ts +112 -0
- package/src/crypto.ts +80 -0
- package/src/encoding.ts +67 -0
- package/src/index.ts +73 -0
- package/src/instructions/add-authority.ts +21 -0
- package/src/instructions/create.ts +54 -0
- package/src/instructions/invoke.ts +25 -0
- package/src/instructions/remove-authority.ts +20 -0
- package/src/instructions/shared.ts +12 -0
- package/src/instructions/transfer.ts +30 -0
- package/src/instructions/validate.ts +33 -0
- package/src/seeds.ts +47 -0
- package/src/types.ts +92 -0
- package/tsconfig.json +9 -0
- package/tsup.config.ts +11 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result of passkey registration (credential creation).
|
|
3
|
+
*/
|
|
4
|
+
export interface PasskeyRegistrationResult {
|
|
5
|
+
credentialId: string; // base64url-encoded
|
|
6
|
+
publicKeyX: string; // hex-encoded (32 bytes)
|
|
7
|
+
publicKeyY: string; // hex-encoded (32 bytes)
|
|
8
|
+
rpId: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Result of passkey signing (assertion).
|
|
13
|
+
*/
|
|
14
|
+
export interface PasskeySigningResult {
|
|
15
|
+
signature: Uint8Array; // Raw P-256 signature (r || s, 64 bytes)
|
|
16
|
+
authenticatorData: Uint8Array;
|
|
17
|
+
clientDataJSON: Uint8Array;
|
|
18
|
+
signatureR: Uint8Array; // 32 bytes
|
|
19
|
+
signatureS: Uint8Array; // 32 bytes
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Signing result with discoverable credential info.
|
|
24
|
+
*/
|
|
25
|
+
export interface PasskeyDiscoverableSigningResult extends PasskeySigningResult {
|
|
26
|
+
credentialId: string; // base64url-encoded
|
|
27
|
+
rpId: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Passkey metadata stored locally (the actual private key lives in the device's secure enclave).
|
|
32
|
+
*/
|
|
33
|
+
export interface PasskeyMetadata {
|
|
34
|
+
credentialId: string;
|
|
35
|
+
publicKeyX: string;
|
|
36
|
+
publicKeyY: string;
|
|
37
|
+
rpId: string;
|
|
38
|
+
label?: string;
|
|
39
|
+
createdAt: string;
|
|
40
|
+
lastUsedAt: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export type Authority =
|
|
44
|
+
| {
|
|
45
|
+
tag: 1; // passkey
|
|
46
|
+
pubkeyX: Uint8Array; // 32 bytes
|
|
47
|
+
pubkeyY: Uint8Array; // 32 bytes
|
|
48
|
+
}
|
|
49
|
+
| {
|
|
50
|
+
tag: 2; // pubkey
|
|
51
|
+
pubkey: Uint8Array; // 32 bytes
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export interface CreateInstructionParams {
|
|
55
|
+
walletAccountIdx: number;
|
|
56
|
+
authority: Authority;
|
|
57
|
+
seed: Uint8Array;
|
|
58
|
+
stateProof: Uint8Array;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface TransferInstructionParams {
|
|
62
|
+
walletAccountIdx: number;
|
|
63
|
+
toAccountIdx: number;
|
|
64
|
+
amount: bigint;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface ValidateInstructionParams {
|
|
68
|
+
walletAccountIdx: number;
|
|
69
|
+
authIdx: number;
|
|
70
|
+
signatureR: Uint8Array;
|
|
71
|
+
signatureS: Uint8Array;
|
|
72
|
+
authenticatorData: Uint8Array;
|
|
73
|
+
clientDataJSON: Uint8Array;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface AccountContext {
|
|
77
|
+
readWriteAddresses: string[];
|
|
78
|
+
readOnlyAddresses: string[];
|
|
79
|
+
accountAddresses: string[];
|
|
80
|
+
walletAccountIdx: number;
|
|
81
|
+
getAccountIndex: (pubkey: Uint8Array) => number;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export type WalletSigner = {
|
|
85
|
+
signTransaction: (payloadBase64: string) => Promise<string>;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export type TransactionExecutionSummary = {
|
|
89
|
+
executionResult?: bigint | number | null;
|
|
90
|
+
userErrorCode?: bigint | number | null;
|
|
91
|
+
vmError?: number | string | bigint | null;
|
|
92
|
+
};
|
package/tsconfig.json
ADDED
package/tsup.config.ts
ADDED