phygital-token-sdk 1.0.1 → 1.0.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/README.md +15 -7
- package/dist/generated/instructions/index.d.ts +0 -1
- package/dist/generated/instructions/index.d.ts.map +1 -1
- package/dist/generated/instructions/index.js +0 -1
- package/dist/generated/instructions/index.js.map +1 -1
- package/dist/generated/instructions/initialize.d.ts +3 -0
- package/dist/generated/instructions/initialize.d.ts.map +1 -1
- package/dist/generated/instructions/initialize.js +3 -1
- package/dist/generated/instructions/initialize.js.map +1 -1
- package/dist/generated/programs/phygitalToken.d.ts +4 -8
- package/dist/generated/programs/phygitalToken.d.ts.map +1 -1
- package/dist/generated/programs/phygitalToken.js +4 -16
- package/dist/generated/programs/phygitalToken.js.map +1 -1
- package/dist/instructions/transfer.d.ts +15 -4
- package/dist/instructions/transfer.d.ts.map +1 -1
- package/dist/instructions/transfer.js +17 -7
- package/dist/instructions/transfer.js.map +1 -1
- package/dist/instructions/verify.d.ts +3 -1
- package/dist/instructions/verify.d.ts.map +1 -1
- package/dist/instructions/verify.js +3 -2
- package/dist/instructions/verify.js.map +1 -1
- package/dist/utils/parseSecp256r1Pubkey.js +1 -1
- package/dist/utils/passkey/internal.d.ts +8 -23
- package/dist/utils/passkey/internal.d.ts.map +1 -1
- package/dist/utils/passkey/internal.js +65 -116
- package/dist/utils/passkey/internal.js.map +1 -1
- package/dist/utils/passkey/nfc/fromWebAuthnJson.js +1 -1
- package/dist/utils/passkey/secp256r1.d.ts +5 -10
- package/dist/utils/passkey/secp256r1.d.ts.map +1 -1
- package/dist/utils/passkey/secp256r1.js +6 -6
- package/dist/utils/passkey/secp256r1.js.map +1 -1
- package/dist/utils/passkey/webauthn.d.ts +11 -4
- package/dist/utils/passkey/webauthn.d.ts.map +1 -1
- package/dist/utils/passkey/webauthn.js +19 -16
- package/dist/utils/passkey/webauthn.js.map +1 -1
- package/dist/utils/pdas/token.d.ts +7 -1
- package/dist/utils/pdas/token.d.ts.map +1 -1
- package/dist/utils/pdas/token.js +25 -0
- package/dist/utils/pdas/token.js.map +1 -1
- package/dist/utils/verify.d.ts +8 -2
- package/dist/utils/verify.d.ts.map +1 -1
- package/dist/utils/verify.js +10 -8
- package/dist/utils/verify.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,8 +12,6 @@ pnpm add phygital-token-sdk @solana/kit
|
|
|
12
12
|
|
|
13
13
|
## Off-chain authentication
|
|
14
14
|
|
|
15
|
-
The authenticator uses the compressed secp256r1 **public key** as the WebAuthn `credential.id`.
|
|
16
|
-
|
|
17
15
|
```ts
|
|
18
16
|
import { createSolanaRpc } from "@solana/kit";
|
|
19
17
|
import {
|
|
@@ -23,11 +21,13 @@ import {
|
|
|
23
21
|
fetchPhygitalToken,
|
|
24
22
|
} from "phygital-token-sdk";
|
|
25
23
|
|
|
24
|
+
const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com");
|
|
25
|
+
|
|
26
26
|
// Server: issue a short-lived challenge
|
|
27
27
|
const message = crypto.randomUUID();
|
|
28
28
|
|
|
29
|
-
// Client: native NFC modal
|
|
30
|
-
const response = await startAuthentication(message);
|
|
29
|
+
// Client: native NFC modal (rpc required for placeholder recovery)
|
|
30
|
+
const response = await startAuthentication(message, rpc);
|
|
31
31
|
|
|
32
32
|
// Server: check the signature (no RPC)
|
|
33
33
|
const { isVerified, secp256r1PublicKey } = verifyResponse({
|
|
@@ -36,7 +36,6 @@ const { isVerified, secp256r1PublicKey } = verifyResponse({
|
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
if (isVerified) {
|
|
39
|
-
const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com");
|
|
40
39
|
const { data } = await fetchPhygitalToken(
|
|
41
40
|
rpc,
|
|
42
41
|
await findPhygitalTokenPda(secp256r1PublicKey),
|
|
@@ -45,6 +44,12 @@ if (isVerified) {
|
|
|
45
44
|
}
|
|
46
45
|
```
|
|
47
46
|
|
|
47
|
+
Native / kiosk readers: pass `transceive` in the third argument — browser WebAuthn (and `rpc`) is skipped.
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
const response = await startAuthentication(message, rpc, { transceive });
|
|
51
|
+
```
|
|
52
|
+
|
|
48
53
|
## On-chain `verify` (CPI)
|
|
49
54
|
|
|
50
55
|
Use this when **your program** needs a possession proof. Your program CPIs `verify` with `VerifyCpiBuilder`.
|
|
@@ -54,22 +59,25 @@ The tap uses your `messageHash` (32 bytes) as the WebAuthn challenge. Hash with
|
|
|
54
59
|
### Client (TypeScript)
|
|
55
60
|
|
|
56
61
|
```ts
|
|
62
|
+
import { createSolanaRpc } from "@solana/kit";
|
|
57
63
|
import {
|
|
58
64
|
buildMessageHash,
|
|
59
65
|
authenticatePasskeyForSecp256r1Verify,
|
|
60
66
|
buildSecp256r1VerifyInstruction,
|
|
61
67
|
} from "phygital-token-sdk";
|
|
62
68
|
|
|
69
|
+
const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com");
|
|
63
70
|
const messageHash = buildMessageHash(message);
|
|
64
71
|
const tap = await authenticatePasskeyForSecp256r1Verify({
|
|
72
|
+
rpc,
|
|
65
73
|
messageHash,
|
|
66
74
|
});
|
|
67
75
|
const { secp256r1VerifyInstruction, phygitalTokenPda, secp256r1VerifyArgs } =
|
|
68
|
-
|
|
76
|
+
buildSecp256r1VerifyInstruction(tap);
|
|
69
77
|
|
|
70
78
|
const instructions = [
|
|
71
79
|
secp256r1VerifyInstruction, // immediately before your instruction
|
|
72
|
-
yourProgramInstruction, // use phygitalTokenPda & secp256r1VerifyArgs as inputs
|
|
80
|
+
yourProgramInstruction, // use phygitalTokenPda & secp256r1VerifyArgs as inputs
|
|
73
81
|
];
|
|
74
82
|
```
|
|
75
83
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/generated/instructions/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/generated/instructions/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/generated/instructions/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/generated/instructions/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC"}
|
|
@@ -21,11 +21,13 @@ export type InitializeInstructionData = {
|
|
|
21
21
|
identifier: Secp256r1Pubkey;
|
|
22
22
|
secp256r1Pubkey: Secp256r1Pubkey;
|
|
23
23
|
tokenType: PhygitalTokenType;
|
|
24
|
+
owner: Address;
|
|
24
25
|
};
|
|
25
26
|
export type InitializeInstructionDataArgs = {
|
|
26
27
|
identifier: Secp256r1PubkeyArgs;
|
|
27
28
|
secp256r1Pubkey: Secp256r1PubkeyArgs;
|
|
28
29
|
tokenType: PhygitalTokenTypeArgs;
|
|
30
|
+
owner: Address;
|
|
29
31
|
};
|
|
30
32
|
export declare function getInitializeInstructionDataEncoder(): FixedSizeEncoder<InitializeInstructionDataArgs>;
|
|
31
33
|
export declare function getInitializeInstructionDataDecoder(): FixedSizeDecoder<InitializeInstructionData>;
|
|
@@ -37,6 +39,7 @@ export type InitializeInput<TAccountAuthority extends string = string, TAccountP
|
|
|
37
39
|
identifier: InitializeInstructionDataArgs["identifier"];
|
|
38
40
|
secp256r1Pubkey: InitializeInstructionDataArgs["secp256r1Pubkey"];
|
|
39
41
|
tokenType: InitializeInstructionDataArgs["tokenType"];
|
|
42
|
+
owner: InitializeInstructionDataArgs["owner"];
|
|
40
43
|
};
|
|
41
44
|
export declare function getInitializeInstruction<TAccountAuthority extends string, TAccountPhygitalToken extends string, TAccountSystemProgram extends string, TProgramAddress extends Address = typeof PHYGITAL_TOKEN_PROGRAM_ADDRESS>(input: InitializeInput<TAccountAuthority, TAccountPhygitalToken, TAccountSystemProgram>, config?: {
|
|
42
45
|
programAddress?: TProgramAddress;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../../../src/generated/instructions/initialize.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../../../src/generated/instructions/initialize.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAaL,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC3B,MAAM,aAAa,CAAC;AAKrB,OAAO,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAKL,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACzB,MAAM,mBAAmB,CAAC;AAE3B,eAAO,MAAM,wBAAwB,EAAE,kBAErC,CAAC;AAEH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QACR,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;QAC5B,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;QAChC,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;KACjC,CAAC;IACF,IAAI,EAAE,yBAAyB,CAAC;CACjC,CAAC;AAEF,wBAAgB,0BAA0B,CACxC,QAAQ,SAAS,MAAM,EACvB,aAAa,SAAS,SAAS,WAAW,EAAE,EAE5C,WAAW,EAAE,WAAW,CAAC,QAAQ,CAAC,GAChC,uBAAuB,CAAC,aAAa,CAAC,GACtC,mBAAmB,CAAC,kBAAkB,CAAC,GACxC,2BAA2B,CAAC,QAAQ,EAAE,aAAa,CAAC,CAyBtD"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @see https://github.com/codama-idl/codama
|
|
7
7
|
*/
|
|
8
|
-
import { combineCodec, fixDecoderSize, fixEncoderSize, getBytesDecoder, getBytesEncoder, getStructDecoder, getStructEncoder, SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, SolanaError, transformEncoder, } from "@solana/kit";
|
|
8
|
+
import { combineCodec, fixDecoderSize, fixEncoderSize, getAddressDecoder, getAddressEncoder, getBytesDecoder, getBytesEncoder, getStructDecoder, getStructEncoder, SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, SolanaError, transformEncoder, } from "@solana/kit";
|
|
9
9
|
import { getAccountMetaFactory, } from "@solana/kit/program-client-core";
|
|
10
10
|
import { PHYGITAL_TOKEN_PROGRAM_ADDRESS } from "../programs/index.js";
|
|
11
11
|
import { getPhygitalTokenTypeDecoder, getPhygitalTokenTypeEncoder, getSecp256r1PubkeyDecoder, getSecp256r1PubkeyEncoder, } from "../types/index.js";
|
|
@@ -21,6 +21,7 @@ export function getInitializeInstructionDataEncoder() {
|
|
|
21
21
|
["identifier", getSecp256r1PubkeyEncoder()],
|
|
22
22
|
["secp256r1Pubkey", getSecp256r1PubkeyEncoder()],
|
|
23
23
|
["tokenType", getPhygitalTokenTypeEncoder()],
|
|
24
|
+
["owner", getAddressEncoder()],
|
|
24
25
|
]), (value) => ({ ...value, discriminator: INITIALIZE_DISCRIMINATOR }));
|
|
25
26
|
}
|
|
26
27
|
export function getInitializeInstructionDataDecoder() {
|
|
@@ -29,6 +30,7 @@ export function getInitializeInstructionDataDecoder() {
|
|
|
29
30
|
["identifier", getSecp256r1PubkeyDecoder()],
|
|
30
31
|
["secp256r1Pubkey", getSecp256r1PubkeyDecoder()],
|
|
31
32
|
["tokenType", getPhygitalTokenTypeDecoder()],
|
|
33
|
+
["owner", getAddressDecoder()],
|
|
32
34
|
]);
|
|
33
35
|
}
|
|
34
36
|
export function getInitializeInstructionDataCodec() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../src/generated/instructions/initialize.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,YAAY,EACZ,cAAc,EACd,cAAc,EACd,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,yDAAyD,EACzD,WAAW,EACX,gBAAgB,GAejB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,qBAAqB,GAEtB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,EAC3B,yBAAyB,EACzB,yBAAyB,GAK1B,MAAM,mBAAmB,CAAC;AAE3B,MAAM,CAAC,MAAM,wBAAwB,GAAuB,IAAI,UAAU,CAAC;IACzE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;CACrC,CAAC,CAAC;AAEH,MAAM,UAAU,+BAA+B;IAC7C,OAAO,cAAc,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC;AAC/E,CAAC;
|
|
1
|
+
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../src/generated/instructions/initialize.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,YAAY,EACZ,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,yDAAyD,EACzD,WAAW,EACX,gBAAgB,GAejB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,qBAAqB,GAEtB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,EAC3B,yBAAyB,EACzB,yBAAyB,GAK1B,MAAM,mBAAmB,CAAC;AAE3B,MAAM,CAAC,MAAM,wBAAwB,GAAuB,IAAI,UAAU,CAAC;IACzE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;CACrC,CAAC,CAAC;AAEH,MAAM,UAAU,+BAA+B;IAC7C,OAAO,cAAc,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC;AAC/E,CAAC;AA2CD,MAAM,UAAU,mCAAmC;IACjD,OAAO,gBAAgB,CACrB,gBAAgB,CAAC;QACf,CAAC,eAAe,EAAE,cAAc,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,CAAC;QACvD,CAAC,YAAY,EAAE,yBAAyB,EAAE,CAAC;QAC3C,CAAC,iBAAiB,EAAE,yBAAyB,EAAE,CAAC;QAChD,CAAC,WAAW,EAAE,2BAA2B,EAAE,CAAC;QAC5C,CAAC,OAAO,EAAE,iBAAiB,EAAE,CAAC;KAC/B,CAAC,EACF,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,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MAAM,CAAC,WAAW,CAAC,IAAI,CAAC;KACrE,CAAC;AACJ,CAAC"}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { type Address, type ClientWithRpc, type ClientWithTransactionPlanning, type ClientWithTransactionSending, type ExtendedClient, type GetAccountInfoApi, type GetMultipleAccountsApi, type Instruction, type InstructionWithData, type ReadonlyUint8Array } from "@solana/kit";
|
|
9
9
|
import { type SelfFetchFunctions, type SelfPlanAndSendFunctions } from "@solana/kit/program-client-core";
|
|
10
10
|
import { getPhygitalTokenCodec, type PhygitalToken, type PhygitalTokenArgs } from "../accounts/index.js";
|
|
11
|
-
import { getInitializeInstruction, getRemoveOwnershipInstruction,
|
|
11
|
+
import { getInitializeInstruction, getRemoveOwnershipInstruction, getSetMintInstruction, getTransferOwnershipInstruction, getVerifyInstruction, type InitializeInput, type ParsedInitializeInstruction, type ParsedRemoveOwnershipInstruction, type ParsedSetMintInstruction, type ParsedTransferOwnershipInstruction, type ParsedVerifyInstruction, type RemoveOwnershipInput, type SetMintInput, type TransferOwnershipInput, type VerifyInput } from "../instructions/index.js";
|
|
12
12
|
export declare const PHYGITAL_TOKEN_PROGRAM_ADDRESS: Address<"DuPpckdjjgVAnYok2aTMAt264ZPBXqq3JSazJjCUzTJQ">;
|
|
13
13
|
export declare enum PhygitalTokenAccount {
|
|
14
14
|
PhygitalToken = 0
|
|
@@ -19,10 +19,9 @@ export declare function identifyPhygitalTokenAccount(account: {
|
|
|
19
19
|
export declare enum PhygitalTokenInstruction {
|
|
20
20
|
Initialize = 0,
|
|
21
21
|
RemoveOwnership = 1,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Verify = 5
|
|
22
|
+
SetMint = 2,
|
|
23
|
+
TransferOwnership = 3,
|
|
24
|
+
Verify = 4
|
|
26
25
|
}
|
|
27
26
|
export declare function identifyPhygitalTokenInstruction(instruction: {
|
|
28
27
|
data: ReadonlyUint8Array;
|
|
@@ -32,8 +31,6 @@ export type ParsedPhygitalTokenInstruction<TProgram extends string = "DuPpckdjjg
|
|
|
32
31
|
} & ParsedInitializeInstruction<TProgram>) | ({
|
|
33
32
|
instructionType: PhygitalTokenInstruction.RemoveOwnership;
|
|
34
33
|
} & ParsedRemoveOwnershipInstruction<TProgram>) | ({
|
|
35
|
-
instructionType: PhygitalTokenInstruction.SetLockState;
|
|
36
|
-
} & ParsedSetLockStateInstruction<TProgram>) | ({
|
|
37
34
|
instructionType: PhygitalTokenInstruction.SetMint;
|
|
38
35
|
} & ParsedSetMintInstruction<TProgram>) | ({
|
|
39
36
|
instructionType: PhygitalTokenInstruction.TransferOwnership;
|
|
@@ -54,7 +51,6 @@ export type PhygitalTokenPluginAccounts = {
|
|
|
54
51
|
export type PhygitalTokenPluginInstructions = {
|
|
55
52
|
initialize: (input: InitializeInput) => ReturnType<typeof getInitializeInstruction> & SelfPlanAndSendFunctions;
|
|
56
53
|
removeOwnership: (input: RemoveOwnershipInput) => ReturnType<typeof getRemoveOwnershipInstruction> & SelfPlanAndSendFunctions;
|
|
57
|
-
setLockState: (input: SetLockStateInput) => ReturnType<typeof getSetLockStateInstruction> & SelfPlanAndSendFunctions;
|
|
58
54
|
setMint: (input: SetMintInput) => ReturnType<typeof getSetMintInstruction> & SelfPlanAndSendFunctions;
|
|
59
55
|
transferOwnership: (input: TransferOwnershipInput) => ReturnType<typeof getTransferOwnershipInstruction> & SelfPlanAndSendFunctions;
|
|
60
56
|
verify: (input: VerifyInput) => ReturnType<typeof getVerifyInstruction> & SelfPlanAndSendFunctions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phygitalToken.d.ts","sourceRoot":"","sources":["../../../src/generated/programs/phygitalToken.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAUL,KAAK,OAAO,EACZ,KAAK,aAAa,EAClB,KAAK,6BAA6B,EAClC,KAAK,4BAA4B,EACjC,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC9B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,qBAAqB,EACrB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,wBAAwB,EACxB,6BAA6B,EAC7B,
|
|
1
|
+
{"version":3,"file":"phygitalToken.d.ts","sourceRoot":"","sources":["../../../src/generated/programs/phygitalToken.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAUL,KAAK,OAAO,EACZ,KAAK,aAAa,EAClB,KAAK,6BAA6B,EAClC,KAAK,4BAA4B,EACjC,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC9B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,qBAAqB,EACrB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,wBAAwB,EACxB,6BAA6B,EAC7B,qBAAqB,EACrB,+BAA+B,EAC/B,oBAAoB,EAMpB,KAAK,eAAe,EACpB,KAAK,2BAA2B,EAChC,KAAK,gCAAgC,EACrC,KAAK,wBAAwB,EAC7B,KAAK,kCAAkC,EACvC,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,WAAW,EACjB,MAAM,0BAA0B,CAAC;AAElC,eAAO,MAAM,8BAA8B,EACS,OAAO,CAAC,8CAA8C,CAAC,CAAC;AAE5G,oBAAY,oBAAoB;IAC9B,aA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T, SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, SolanaError, } from "@solana/kit";
|
|
9
9
|
import { addSelfFetchFunctions, addSelfPlanAndSendFunctions, } from "@solana/kit/program-client-core";
|
|
10
10
|
import { getPhygitalTokenCodec, } from "../accounts/index.js";
|
|
11
|
-
import { getInitializeInstruction, getRemoveOwnershipInstruction,
|
|
11
|
+
import { getInitializeInstruction, getRemoveOwnershipInstruction, getSetMintInstruction, getTransferOwnershipInstruction, getVerifyInstruction, parseInitializeInstruction, parseRemoveOwnershipInstruction, parseSetMintInstruction, parseTransferOwnershipInstruction, parseVerifyInstruction, } from "../instructions/index.js";
|
|
12
12
|
export const PHYGITAL_TOKEN_PROGRAM_ADDRESS = "DuPpckdjjgVAnYok2aTMAt264ZPBXqq3JSazJjCUzTJQ";
|
|
13
13
|
export var PhygitalTokenAccount;
|
|
14
14
|
(function (PhygitalTokenAccount) {
|
|
@@ -25,10 +25,9 @@ export var PhygitalTokenInstruction;
|
|
|
25
25
|
(function (PhygitalTokenInstruction) {
|
|
26
26
|
PhygitalTokenInstruction[PhygitalTokenInstruction["Initialize"] = 0] = "Initialize";
|
|
27
27
|
PhygitalTokenInstruction[PhygitalTokenInstruction["RemoveOwnership"] = 1] = "RemoveOwnership";
|
|
28
|
-
PhygitalTokenInstruction[PhygitalTokenInstruction["
|
|
29
|
-
PhygitalTokenInstruction[PhygitalTokenInstruction["
|
|
30
|
-
PhygitalTokenInstruction[PhygitalTokenInstruction["
|
|
31
|
-
PhygitalTokenInstruction[PhygitalTokenInstruction["Verify"] = 5] = "Verify";
|
|
28
|
+
PhygitalTokenInstruction[PhygitalTokenInstruction["SetMint"] = 2] = "SetMint";
|
|
29
|
+
PhygitalTokenInstruction[PhygitalTokenInstruction["TransferOwnership"] = 3] = "TransferOwnership";
|
|
30
|
+
PhygitalTokenInstruction[PhygitalTokenInstruction["Verify"] = 4] = "Verify";
|
|
32
31
|
})(PhygitalTokenInstruction || (PhygitalTokenInstruction = {}));
|
|
33
32
|
export function identifyPhygitalTokenInstruction(instruction) {
|
|
34
33
|
const data = "data" in instruction ? instruction.data : instruction;
|
|
@@ -38,9 +37,6 @@ export function identifyPhygitalTokenInstruction(instruction) {
|
|
|
38
37
|
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([58, 70, 125, 46, 39, 24, 46, 240])), 0)) {
|
|
39
38
|
return PhygitalTokenInstruction.RemoveOwnership;
|
|
40
39
|
}
|
|
41
|
-
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([16, 40, 80, 140, 163, 156, 68, 120])), 0)) {
|
|
42
|
-
return PhygitalTokenInstruction.SetLockState;
|
|
43
|
-
}
|
|
44
40
|
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([166, 129, 167, 223, 137, 118, 212, 47])), 0)) {
|
|
45
41
|
return PhygitalTokenInstruction.SetMint;
|
|
46
42
|
}
|
|
@@ -69,13 +65,6 @@ export function parsePhygitalTokenInstruction(instruction) {
|
|
|
69
65
|
...parseRemoveOwnershipInstruction(instruction),
|
|
70
66
|
};
|
|
71
67
|
}
|
|
72
|
-
case PhygitalTokenInstruction.SetLockState: {
|
|
73
|
-
assertIsInstructionWithAccounts(instruction);
|
|
74
|
-
return {
|
|
75
|
-
instructionType: PhygitalTokenInstruction.SetLockState,
|
|
76
|
-
...parseSetLockStateInstruction(instruction),
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
68
|
case PhygitalTokenInstruction.SetMint: {
|
|
80
69
|
assertIsInstructionWithAccounts(instruction);
|
|
81
70
|
return {
|
|
@@ -114,7 +103,6 @@ export function phygitalTokenProgram() {
|
|
|
114
103
|
instructions: {
|
|
115
104
|
initialize: (input) => addSelfPlanAndSendFunctions(client, getInitializeInstruction(input)),
|
|
116
105
|
removeOwnership: (input) => addSelfPlanAndSendFunctions(client, getRemoveOwnershipInstruction(input)),
|
|
117
|
-
setLockState: (input) => addSelfPlanAndSendFunctions(client, getSetLockStateInstruction(input)),
|
|
118
106
|
setMint: (input) => addSelfPlanAndSendFunctions(client, getSetMintInstruction(input)),
|
|
119
107
|
transferOwnership: (input) => addSelfPlanAndSendFunctions(client, getTransferOwnershipInstruction(input)),
|
|
120
108
|
verify: (input) => addSelfPlanAndSendFunctions(client, getVerifyInstruction(input)),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phygitalToken.js","sourceRoot":"","sources":["../../../src/generated/programs/phygitalToken.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,+BAA+B,EAC/B,aAAa,EACb,YAAY,EACZ,cAAc,EACd,eAAe,EACf,yDAAyD,EACzD,6DAA6D,EAC7D,4DAA4D,EAC5D,WAAW,GAWZ,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,qBAAqB,EACrB,2BAA2B,GAG5B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,qBAAqB,GAGtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,wBAAwB,EACxB,6BAA6B,EAC7B,
|
|
1
|
+
{"version":3,"file":"phygitalToken.js","sourceRoot":"","sources":["../../../src/generated/programs/phygitalToken.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,+BAA+B,EAC/B,aAAa,EACb,YAAY,EACZ,cAAc,EACd,eAAe,EACf,yDAAyD,EACzD,6DAA6D,EAC7D,4DAA4D,EAC5D,WAAW,GAWZ,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,qBAAqB,EACrB,2BAA2B,GAG5B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,qBAAqB,GAGtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,wBAAwB,EACxB,6BAA6B,EAC7B,qBAAqB,EACrB,+BAA+B,EAC/B,oBAAoB,EACpB,0BAA0B,EA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6BAA6B;aAChD;SACF,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { type Address, type Instruction, type Rpc, type SolanaRpcApi, type TransactionSigner } from "@solana/kit";
|
|
2
2
|
import { type AuthenticationResponseJSON } from "../utils/passkey/webauthn.js";
|
|
3
3
|
import { type Secp256r1VerifyEntry } from "../utils/passkey/secp256r1.js";
|
|
4
|
+
import type { Base64URLString } from "../utils/passkey/webauthn.js";
|
|
4
5
|
export type TransferSession = {
|
|
5
6
|
rpc: Rpc<SolanaRpcApi>;
|
|
7
|
+
/** Phygital token PDA derived from {@link secp256r1Pubkey}. */
|
|
6
8
|
phygitalToken: Address;
|
|
9
|
+
/** Base64url compressed secp256r1 passkey public key for the physical token. */
|
|
10
|
+
secp256r1Pubkey: Base64URLString;
|
|
7
11
|
slotHash: Uint8Array;
|
|
8
12
|
slotNumber: bigint;
|
|
9
13
|
challenge: Uint8Array;
|
|
@@ -16,15 +20,22 @@ export type TransferSession = {
|
|
|
16
20
|
* {@link completeTransfer}.
|
|
17
21
|
*
|
|
18
22
|
* @param input.rpc - Kit `Rpc`. Convert a web3.js Connection with `toRpc`.
|
|
19
|
-
* @param input.
|
|
20
|
-
*
|
|
23
|
+
* @param input.secp256r1Pubkey - Base64url compressed secp256r1 public key for the
|
|
24
|
+
* physical token (same shape as `verifyResponse().secp256r1PublicKey`). The phygital
|
|
25
|
+
* token PDA is derived via {@link findPhygitalTokenPda}.
|
|
26
|
+
* @param input.rpId - Relying party ID for the NFC tap. Defaults to `window.location.hostname`.
|
|
21
27
|
*/
|
|
22
28
|
export declare function beginTransfer(input: {
|
|
23
29
|
rpc: Rpc<SolanaRpcApi>;
|
|
24
|
-
|
|
30
|
+
secp256r1Pubkey: Base64URLString;
|
|
25
31
|
rpId?: string;
|
|
26
32
|
}): Promise<TransferSession>;
|
|
27
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Prompts the physical token passkey (WebAuthn / NFC tap).
|
|
35
|
+
* Passes {@link TransferSession.secp256r1Pubkey} in `allowCredentials` for the browser UI.
|
|
36
|
+
* If the platform echoes a random placeholder id, recovery disambiguates by checking
|
|
37
|
+
* which candidate has an initialized PhygitalToken PDA on-chain.
|
|
38
|
+
*/
|
|
28
39
|
export declare function authenticatePasskeyForTransfer(session: TransferSession): Promise<AuthenticationResponseJSON>;
|
|
29
40
|
/**
|
|
30
41
|
* Builds the two on-chain instructions after passkey authentication.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../../src/instructions/transfer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,GAAG,EACR,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EAIL,KAAK,0BAA0B,EAChC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,+BAA+B,CAAC;AAKvC,MAAM,MAAM,eAAe,GAAG;IAC5B,GAAG,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;IACvB,QAAQ,EAAE,UAAU,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,UAAU,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../../src/instructions/transfer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,GAAG,EACR,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EAIL,KAAK,0BAA0B,EAChC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,+BAA+B,CAAC;AAKvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpE,MAAM,MAAM,eAAe,GAAG;IAC5B,GAAG,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC;IACvB,+DAA+D;IAC/D,aAAa,EAAE,OAAO,CAAC;IACvB,gFAAgF;IAChF,eAAe,EAAE,eAAe,CAAC;IACjC,QAAQ,EAAE,UAAU,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,UAAU,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CAAC,KAAK,EAAE;IACzC,GAAG,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC;IACvB,eAAe,EAAE,eAAe,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,OAAO,CAAC,eAAe,CAAC,CAiB3B;AAED;;;;;GAKG;AACH,wBAAsB,8BAA8B,CAClD,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,0BAA0B,CAAC,CASrC;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,0BAA0B,EACpC,SAAS,EAAE,iBAAiB,EAC5B,6BAA6B,CAAC,EAAE,oBAAoB,EAAE,GACrD,OAAO,CAAC,WAAW,EAAE,CAAC,CAoBxB"}
|
|
@@ -4,6 +4,7 @@ import { buildSecp256r1VerifyInstructionFromWebAuthnResponse, buildTransferChall
|
|
|
4
4
|
import { getLatestSlotHash } from "../utils/slotHash.js";
|
|
5
5
|
import { getTransferOwnershipInstruction } from "../generated/index.js";
|
|
6
6
|
import { parseSecp256r1Pubkey } from "../utils/parseSecp256r1Pubkey.js";
|
|
7
|
+
import { findPhygitalTokenPda } from "../utils/pdas/token.js";
|
|
7
8
|
/**
|
|
8
9
|
* Prepares a transfer session with slot-bound challenge data.
|
|
9
10
|
* Recipient is chosen at wallet confirmation and must sign the transfer transaction.
|
|
@@ -11,27 +12,36 @@ import { parseSecp256r1Pubkey } from "../utils/parseSecp256r1Pubkey.js";
|
|
|
11
12
|
* {@link completeTransfer}.
|
|
12
13
|
*
|
|
13
14
|
* @param input.rpc - Kit `Rpc`. Convert a web3.js Connection with `toRpc`.
|
|
14
|
-
* @param input.
|
|
15
|
-
*
|
|
15
|
+
* @param input.secp256r1Pubkey - Base64url compressed secp256r1 public key for the
|
|
16
|
+
* physical token (same shape as `verifyResponse().secp256r1PublicKey`). The phygital
|
|
17
|
+
* token PDA is derived via {@link findPhygitalTokenPda}.
|
|
18
|
+
* @param input.rpId - Relying party ID for the NFC tap. Defaults to `window.location.hostname`.
|
|
16
19
|
*/
|
|
17
20
|
export async function beginTransfer(input) {
|
|
21
|
+
const phygitalToken = await findPhygitalTokenPda(input.secp256r1Pubkey);
|
|
18
22
|
const { slotHash, slotNumber } = await getLatestSlotHash(input.rpc);
|
|
19
23
|
const challenge = await buildTransferChallenge({
|
|
20
|
-
phygitalToken
|
|
24
|
+
phygitalToken,
|
|
21
25
|
slotHash,
|
|
22
26
|
});
|
|
23
27
|
return {
|
|
24
28
|
rpc: input.rpc,
|
|
25
|
-
|
|
29
|
+
secp256r1Pubkey: input.secp256r1Pubkey,
|
|
30
|
+
phygitalToken,
|
|
26
31
|
slotHash,
|
|
27
32
|
slotNumber,
|
|
28
33
|
challenge,
|
|
29
34
|
rpId: input.rpId ?? window.location.hostname,
|
|
30
35
|
};
|
|
31
36
|
}
|
|
32
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* Prompts the physical token passkey (WebAuthn / NFC tap).
|
|
39
|
+
* Passes {@link TransferSession.secp256r1Pubkey} in `allowCredentials` for the browser UI.
|
|
40
|
+
* If the platform echoes a random placeholder id, recovery disambiguates by checking
|
|
41
|
+
* which candidate has an initialized PhygitalToken PDA on-chain.
|
|
42
|
+
*/
|
|
33
43
|
export async function authenticatePasskeyForTransfer(session) {
|
|
34
|
-
return authenticateWithWebauthn(nfcWebAuthnRequestOptions(bufferToBase64URLString(session.challenge), session.rpId));
|
|
44
|
+
return authenticateWithWebauthn(nfcWebAuthnRequestOptions(bufferToBase64URLString(session.challenge), session.rpId, session.secp256r1Pubkey), session.rpc);
|
|
35
45
|
}
|
|
36
46
|
/**
|
|
37
47
|
* Builds the two on-chain instructions after passkey authentication.
|
|
@@ -40,7 +50,7 @@ export async function authenticatePasskeyForTransfer(session) {
|
|
|
40
50
|
* @param recipient - Kit `TransactionSigner`. Convert a web3.js Keypair with `toTransactionSigner`.
|
|
41
51
|
*/
|
|
42
52
|
export async function completeTransfer(session, response, recipient, existingSecp256r1VerifyInputs) {
|
|
43
|
-
const { secp256r1VerifyInstruction, signedMessageIndex, clientDataJson } =
|
|
53
|
+
const { secp256r1VerifyInstruction, signedMessageIndex, clientDataJson } = buildSecp256r1VerifyInstructionFromWebAuthnResponse({
|
|
44
54
|
response,
|
|
45
55
|
secp256r1PublicKey: parseSecp256r1Pubkey(response.id),
|
|
46
56
|
existingSecp256r1VerifyInputs,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transfer.js","sourceRoot":"","sources":["../../src/instructions/transfer.ts"],"names":[],"mappings":"AAAA,OAAO,EAMN,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,GAE1B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,mDAAmD,EACnD,sBAAsB,GAEvB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,+BAA+B,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"transfer.js","sourceRoot":"","sources":["../../src/instructions/transfer.ts"],"names":[],"mappings":"AAAA,OAAO,EAMN,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,uBAA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SAA4B,EAC5B,6BAAsD;IAEtD,MAAM,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,cAAc,EAAE,GACtE,mDAAmD,CAAC;QAClD,QAAQ;QACR,kBAAkB,EAAE,oBAAoB,CAAC,QAAQ,CAAC,EAAE,CAAC;QACrD,6BAA6B;KAC9B,CAAC,CAAC;IAEL,MAAM,iBAAiB,GAAG,+BAA+B,CAAC;QACxD,SAAS;QACT,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,mBAAmB,EAAE;YACnB,uBAAuB,EAAE,CAAC,CAAC;YAC3B,kBAAkB;YAClB,cAAc;SACf;KACF,CAAC,CAAC;IAEH,OAAO,CAAC,0BAA0B,EAAE,iBAAiB,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AuthenticationResponseJSON } from "../utils/passkey/webauthn.js";
|
|
2
|
-
import type { Address, Instruction } from "@solana/kit";
|
|
2
|
+
import type { Address, Instruction, Rpc, SolanaRpcApi } from "@solana/kit";
|
|
3
3
|
import { type Secp256r1VerifyEntry } from "../utils/passkey/secp256r1.js";
|
|
4
4
|
import { type Secp256r1VerifyArgsArgs } from "../generated/index.js";
|
|
5
5
|
/** SHA-256 `message` to a 32-byte digest for on-chain `verify`. */
|
|
@@ -11,12 +11,14 @@ export declare function buildMessageHash(message: Uint8Array): Uint8Array;
|
|
|
11
11
|
* digest your program must pass to `VerifyCpiBuilder.message_hash`. Hash with
|
|
12
12
|
* {@link buildMessageHash} first.
|
|
13
13
|
*
|
|
14
|
+
* @param input.rpc - Kit `Rpc`. Used when the platform echoes a placeholder credential id.
|
|
14
15
|
* @param input.messageHash - SHA-256 of the message you bind on-chain (32 bytes).
|
|
15
16
|
* @param input.rpId - WebAuthn relying party for the **browser tap** only.
|
|
16
17
|
* Defaults to `window.location.hostname`. On-chain `expected_rp_id` /
|
|
17
18
|
* `expected_origins` are set on your CPI, not here.
|
|
18
19
|
*/
|
|
19
20
|
export declare function authenticatePasskeyForSecp256r1Verify(input: {
|
|
21
|
+
rpc: Rpc<SolanaRpcApi>;
|
|
20
22
|
messageHash: Uint8Array;
|
|
21
23
|
rpId?: string;
|
|
22
24
|
}): Promise<AuthenticationResponseJSON>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../src/instructions/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,0BAA0B,EAIhC,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../src/instructions/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,0BAA0B,EAIhC,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAKrE,mEAAmE;AACnE,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,UAAU,GAAG,UAAU,CAEhE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,qCAAqC,CAAC,KAAK,EAAE;IACjE,GAAG,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC;IACvB,WAAW,EAAE,UAAU,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAQtC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,+BAA+B,CACnD,QAAQ,EAAE,0BAA0B,EACpC,6BAA6B,CAAC,EAAE,oBAAoB,EAAE,EACtD,uBAAuB,SAAK,GAC3B,OAAO,CAAC;IACT,0BAA0B,EAAE,WAAW,CAAC;IACxC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,mBAAmB,EAAE,uBAAuB,CAAC;CAC9C,CAAC,CAkBD"}
|
|
@@ -15,13 +15,14 @@ export function buildMessageHash(message) {
|
|
|
15
15
|
* digest your program must pass to `VerifyCpiBuilder.message_hash`. Hash with
|
|
16
16
|
* {@link buildMessageHash} first.
|
|
17
17
|
*
|
|
18
|
+
* @param input.rpc - Kit `Rpc`. Used when the platform echoes a placeholder credential id.
|
|
18
19
|
* @param input.messageHash - SHA-256 of the message you bind on-chain (32 bytes).
|
|
19
20
|
* @param input.rpId - WebAuthn relying party for the **browser tap** only.
|
|
20
21
|
* Defaults to `window.location.hostname`. On-chain `expected_rp_id` /
|
|
21
22
|
* `expected_origins` are set on your CPI, not here.
|
|
22
23
|
*/
|
|
23
24
|
export async function authenticatePasskeyForSecp256r1Verify(input) {
|
|
24
|
-
return authenticateWithWebauthn(nfcWebAuthnRequestOptions(bufferToBase64URLString(input.messageHash), input.rpId ?? window.location.hostname));
|
|
25
|
+
return authenticateWithWebauthn(nfcWebAuthnRequestOptions(bufferToBase64URLString(input.messageHash), input.rpId ?? window.location.hostname), input.rpc);
|
|
25
26
|
}
|
|
26
27
|
/**
|
|
27
28
|
* After the tap: secp256r1_verify instruction to prepend, plus the phygital
|
|
@@ -39,7 +40,7 @@ export async function authenticatePasskeyForSecp256r1Verify(input) {
|
|
|
39
40
|
export async function buildSecp256r1VerifyInstruction(response, existingSecp256r1VerifyInputs, verifyArgsRelativeIndex = -1) {
|
|
40
41
|
const secp256r1PublicKey = parseSecp256r1Pubkey(response.id);
|
|
41
42
|
const phygitalTokenPda = await findPhygitalTokenPda(secp256r1PublicKey);
|
|
42
|
-
const { secp256r1VerifyInstruction, signedMessageIndex, clientDataJson } =
|
|
43
|
+
const { secp256r1VerifyInstruction, signedMessageIndex, clientDataJson } = buildSecp256r1VerifyInstructionFromWebAuthnResponse({
|
|
43
44
|
secp256r1PublicKey,
|
|
44
45
|
response,
|
|
45
46
|
existingSecp256r1VerifyInputs,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../../src/instructions/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,wBAAwB,EACxB,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACL,mDAAmD,GAEpD,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAgC,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,mEAAmE;AACnE,MAAM,UAAU,gBAAgB,CAAC,OAAmB;IAClD,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC;AACzB,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../../src/instructions/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,wBAAwB,EACxB,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACL,mDAAmD,GAEpD,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAgC,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,mEAAmE;AACnE,MAAM,UAAU,gBAAgB,CAAC,OAAmB;IAClD,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC;AACzB,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,qCAAqC,CAAC,KAI3D;IACC,OAAO,wBAAwB,CAC7B,yBAAyB,CACvB,uBAAuB,CAAC,KAAK,CAAC,WAAW,CAAC,EAC1C,KAAK,CAAC,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CACvC,EACD,KAAK,CAAC,GAAG,CACV,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,+BAA+B,CACnD,QAAoC,EACpC,6BAAsD,EACtD,uBAAuB,GAAG,CAAC,CAAC;IAM5B,MAAM,kBAAkB,GAAG,oBAAoB,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC7D,MAAM,gBAAgB,GAAG,MAAM,oBAAoB,CAAC,kBAAkB,CAAC,CAAC;IACxE,MAAM,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,cAAc,EAAE,GACtE,mDAAmD,CAAC;QAClD,kBAAkB;QAClB,QAAQ;QACR,6BAA6B;KAC9B,CAAC,CAAC;IACL,OAAO;QACL,0BAA0B;QAC1B,gBAAgB;QAChB,mBAAmB,EAAE;YACnB,uBAAuB;YACvB,kBAAkB;YAClB,cAAc;SACf;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { base64URLStringToBuffer } from "./passkey/
|
|
1
|
+
import { base64URLStringToBuffer } from "./passkey/webauthn.js";
|
|
2
2
|
/**
|
|
3
3
|
* Parse a base64url-encoded 33-byte compressed secp256r1 value
|
|
4
4
|
* (passkey public key **or** chip identifier — both use the same wire shape).
|
|
@@ -1,31 +1,16 @@
|
|
|
1
1
|
import { type AuthenticationResponseJSON } from "./webauthn.js";
|
|
2
|
-
export { base64URLStringToBuffer } from "./webauthn.js";
|
|
3
|
-
/**
|
|
4
|
-
* Normalizes a raw 64-byte `r||s` P-256 ECDSA signature to its canonical
|
|
5
|
-
* low-S form (`s <= n/2`).
|
|
6
|
-
*
|
|
7
|
-
* Hardware signers — NFC secure elements and platform authenticators — often
|
|
8
|
-
* emit high-S signatures. They are valid ECDSA but non-canonical, and both
|
|
9
|
-
* `@noble/curves` (default `lowS: true`) and Solana's secp256r1 precompile
|
|
10
|
-
* reject them. Always run a raw signature through this before verifying or
|
|
11
|
-
* before building an on-chain secp256r1 verify instruction.
|
|
12
|
-
*/
|
|
13
|
-
export declare function normalizeSignatureToLowS(signature: Uint8Array): Uint8Array;
|
|
14
2
|
export declare function convertSignatureDERtoRS(signature: Uint8Array): Uint8Array;
|
|
15
|
-
|
|
16
|
-
export declare function
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
*/
|
|
24
|
-
export declare function recoverSecp256r1PublicKey(signature: Uint8Array, message: Uint8Array): Uint8Array;
|
|
3
|
+
/** WebAuthn signed payload: `authenticatorData || SHA-256(clientDataJSON)`. */
|
|
4
|
+
export declare function buildSecp256r1Message(authenticatorData: Uint8Array, clientDataJSON: Uint8Array): Uint8Array;
|
|
5
|
+
/** DER signature and signed message bytes from a WebAuthn assertion. */
|
|
6
|
+
export declare function parseWebAuthnAssertion(response: AuthenticationResponseJSON): {
|
|
7
|
+
signature: Uint8Array;
|
|
8
|
+
message: Uint8Array;
|
|
9
|
+
};
|
|
10
|
+
export declare function recoverSecp256r1PublicKeyCandidates(signature: Uint8Array, message: Uint8Array): Uint8Array[];
|
|
25
11
|
export declare function parseWebAuthnClientData(clientDataJSON: string): {
|
|
26
12
|
challenge: string;
|
|
27
13
|
origin: string;
|
|
28
14
|
crossOrigin: boolean;
|
|
29
|
-
truncatedClientDataJson: Uint8Array<ArrayBuffer>;
|
|
30
15
|
};
|
|
31
16
|
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/utils/passkey/internal.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,0BAA0B,EAChC,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/utils/passkey/internal.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,0BAA0B,EAChC,MAAM,eAAe,CAAC;AAgDvB,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,UAAU,GAAG,UAAU,CAEzE;AAED,+EAA+E;AAC/E,wBAAgB,qBAAqB,CACnC,iBAAiB,EAAE,UAAU,EAC7B,cAAc,EAAE,UAAU,GACzB,UAAU,CAQZ;AAED,wEAAwE;AACxE,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,0BAA0B,GAAG;IAC5E,SAAS,EAAE,UAAU,CAAC;IACtB,OAAO,EAAE,UAAU,CAAC;CACrB,CAUA;AAED,wBAAgB,mCAAmC,CACjD,SAAS,EAAE,UAAU,EACrB,OAAO,EAAE,UAAU,GAClB,UAAU,EAAE,CAwBd;AAiBD,wBAAgB,uBAAuB,CAAC,cAAc,EAAE,MAAM,GAAG;IAC/D,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,OAAO,CAAC;CACtB,CAeA"}
|