passkey-kit 0.0.23 → 0.0.25
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/package.json +3 -3
- package/packages/passkey-factory-sdk/package.json +1 -1
- package/packages/passkey-factory-sdk/src/index.ts +18 -34
- package/packages/passkey-factory-sdk/types/index.d.ts +2 -4
- package/packages/passkey-kit-sdk/package.json +1 -1
- package/packages/passkey-kit-sdk/src/index.ts +23 -40
- package/packages/passkey-kit-sdk/types/index.d.ts +2 -4
- package/src/index.ts +25 -23
- package/types/index.d.ts +5 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "passkey-kit",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.25",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"bigint-conversion": "^2.4.3",
|
|
13
13
|
"buffer": "^6.0.3",
|
|
14
14
|
"cbor-x": "^1.5.9",
|
|
15
|
-
"passkey-factory-sdk": "0.0.
|
|
16
|
-
"passkey-kit-sdk": "0.0.
|
|
15
|
+
"passkey-factory-sdk": "0.0.6",
|
|
16
|
+
"passkey-kit-sdk": "0.0.6"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"typescript": "^5.4.5"
|
|
@@ -1,35 +1,19 @@
|
|
|
1
1
|
import { Buffer } from "buffer";
|
|
2
|
-
import { Address } from '@stellar/stellar-sdk';
|
|
3
2
|
import {
|
|
4
|
-
AssembledTransaction,
|
|
5
3
|
Client as ContractClient,
|
|
6
|
-
ClientOptions as ContractClientOptions,
|
|
7
|
-
Result,
|
|
8
4
|
Spec as ContractSpec,
|
|
9
5
|
} from '@stellar/stellar-sdk/contract';
|
|
10
6
|
import type {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
i64,
|
|
15
|
-
u128,
|
|
16
|
-
i128,
|
|
17
|
-
u256,
|
|
18
|
-
i256,
|
|
19
|
-
Option,
|
|
20
|
-
Typepoint,
|
|
21
|
-
Duration,
|
|
7
|
+
AssembledTransaction,
|
|
8
|
+
ClientOptions as ContractClientOptions,
|
|
9
|
+
Result,
|
|
22
10
|
} from '@stellar/stellar-sdk/contract';
|
|
23
|
-
export * from '@stellar/stellar-sdk'
|
|
24
|
-
export * as contract from '@stellar/stellar-sdk/contract'
|
|
25
|
-
export * as rpc from '@stellar/stellar-sdk/rpc'
|
|
26
11
|
|
|
27
12
|
if (typeof window !== 'undefined') {
|
|
28
13
|
//@ts-ignore Buffer exists
|
|
29
14
|
window.Buffer = window.Buffer || Buffer;
|
|
30
15
|
}
|
|
31
16
|
|
|
32
|
-
|
|
33
17
|
export const networks = {
|
|
34
18
|
testnet: {
|
|
35
19
|
networkPassphrase: "Test SDF Network ; September 2015",
|
|
@@ -38,11 +22,11 @@ export const networks = {
|
|
|
38
22
|
} as const
|
|
39
23
|
|
|
40
24
|
export const Errors = {
|
|
41
|
-
1: {message:""},
|
|
42
|
-
2: {message:""},
|
|
43
|
-
3: {message:""},
|
|
44
|
-
4: {message:""},
|
|
45
|
-
5: {message:""}
|
|
25
|
+
1: { message: "" },
|
|
26
|
+
2: { message: "" },
|
|
27
|
+
3: { message: "" },
|
|
28
|
+
4: { message: "" },
|
|
29
|
+
5: { message: "" }
|
|
46
30
|
}
|
|
47
31
|
|
|
48
32
|
export interface Client {
|
|
@@ -69,7 +53,7 @@ export interface Client {
|
|
|
69
53
|
/**
|
|
70
54
|
* Construct and simulate a init transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
71
55
|
*/
|
|
72
|
-
init: ({wasm_hash}: {wasm_hash: Buffer}, options?: {
|
|
56
|
+
init: ({ wasm_hash }: { wasm_hash: Buffer }, options?: {
|
|
73
57
|
/**
|
|
74
58
|
* The fee to pay for the transaction. Default: BASE_FEE
|
|
75
59
|
*/
|
|
@@ -89,7 +73,7 @@ export interface Client {
|
|
|
89
73
|
/**
|
|
90
74
|
* Construct and simulate a deploy transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
91
75
|
*/
|
|
92
|
-
deploy: ({id, pk}: {id: Buffer, pk: Buffer}, options?: {
|
|
76
|
+
deploy: ({ id, pk }: { id: Buffer, pk: Buffer }, options?: {
|
|
93
77
|
/**
|
|
94
78
|
* The fee to pay for the transaction. Default: BASE_FEE
|
|
95
79
|
*/
|
|
@@ -109,7 +93,7 @@ export interface Client {
|
|
|
109
93
|
/**
|
|
110
94
|
* Construct and simulate a add_sig transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
111
95
|
*/
|
|
112
|
-
add_sig: ({id, contract}: {id: Buffer, contract: string}, options?: {
|
|
96
|
+
add_sig: ({ id, contract }: { id: Buffer, contract: string }, options?: {
|
|
113
97
|
/**
|
|
114
98
|
* The fee to pay for the transaction. Default: BASE_FEE
|
|
115
99
|
*/
|
|
@@ -129,7 +113,7 @@ export interface Client {
|
|
|
129
113
|
/**
|
|
130
114
|
* Construct and simulate a rm_sig transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
131
115
|
*/
|
|
132
|
-
rm_sig: ({id, contract}: {id: Buffer, contract: string}, options?: {
|
|
116
|
+
rm_sig: ({ id, contract }: { id: Buffer, contract: string }, options?: {
|
|
133
117
|
/**
|
|
134
118
|
* The fee to pay for the transaction. Default: BASE_FEE
|
|
135
119
|
*/
|
|
@@ -150,20 +134,20 @@ export interface Client {
|
|
|
150
134
|
export class Client extends ContractClient {
|
|
151
135
|
constructor(public readonly options: ContractClientOptions) {
|
|
152
136
|
super(
|
|
153
|
-
new ContractSpec([
|
|
137
|
+
new ContractSpec(["AAAABAAAAAAAAAAAAAAABUVycm9yAAAAAAAABQAAAAAAAAAJTm90SW5pdGVkAAAAAAAAAQAAAAAAAAAITm90Rm91bmQAAAACAAAAAAAAAAxOb3RQZXJtaXR0ZWQAAAADAAAAAAAAAA1BbHJlYWR5SW5pdGVkAAAAAAAABAAAAAAAAAANQWxyZWFkeU1hcHBlZAAAAAAAAAU=",
|
|
154
138
|
"AAAAAAAAAAAAAAAKZXh0ZW5kX3R0bAAAAAAAAAAAAAA=",
|
|
155
139
|
"AAAAAAAAAAAAAAAEaW5pdAAAAAEAAAAAAAAACXdhc21faGFzaAAAAAAAA+4AAAAgAAAAAQAAA+kAAAPtAAAAAAAAAAM=",
|
|
156
140
|
"AAAAAAAAAAAAAAAGZGVwbG95AAAAAAACAAAAAAAAAAJpZAAAAAAADgAAAAAAAAACcGsAAAAAA+4AAABBAAAAAQAAA+kAAAATAAAAAw==",
|
|
157
141
|
"AAAAAAAAAAAAAAAHYWRkX3NpZwAAAAACAAAAAAAAAAJpZAAAAAAADgAAAAAAAAAIY29udHJhY3QAAAATAAAAAQAAA+kAAAPtAAAAAAAAAAM=",
|
|
158
|
-
"AAAAAAAAAAAAAAAGcm1fc2lnAAAAAAACAAAAAAAAAAJpZAAAAAAADgAAAAAAAAAIY29udHJhY3QAAAATAAAAAQAAA+kAAAPtAAAAAAAAAAM="
|
|
142
|
+
"AAAAAAAAAAAAAAAGcm1fc2lnAAAAAAACAAAAAAAAAAJpZAAAAAAADgAAAAAAAAAIY29udHJhY3QAAAATAAAAAQAAA+kAAAPtAAAAAAAAAAM="]),
|
|
159
143
|
options
|
|
160
144
|
)
|
|
161
145
|
}
|
|
162
146
|
public readonly fromJSON = {
|
|
163
147
|
extend_ttl: this.txFromJSON<null>,
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
148
|
+
init: this.txFromJSON<Result<void>>,
|
|
149
|
+
deploy: this.txFromJSON<Result<string>>,
|
|
150
|
+
add_sig: this.txFromJSON<Result<void>>,
|
|
151
|
+
rm_sig: this.txFromJSON<Result<void>>
|
|
168
152
|
}
|
|
169
153
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Buffer } from "buffer";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export * as contract from '@stellar/stellar-sdk/contract';
|
|
5
|
-
export * as rpc from '@stellar/stellar-sdk/rpc';
|
|
2
|
+
import { Client as ContractClient } from '@stellar/stellar-sdk/contract';
|
|
3
|
+
import type { AssembledTransaction, ClientOptions as ContractClientOptions, Result } from '@stellar/stellar-sdk/contract';
|
|
6
4
|
export declare const networks: {
|
|
7
5
|
readonly testnet: {
|
|
8
6
|
readonly networkPassphrase: "Test SDF Network ; September 2015";
|
|
@@ -1,35 +1,19 @@
|
|
|
1
1
|
import { Buffer } from "buffer";
|
|
2
|
-
import { Address } from '@stellar/stellar-sdk';
|
|
3
2
|
import {
|
|
4
|
-
AssembledTransaction,
|
|
5
3
|
Client as ContractClient,
|
|
6
|
-
ClientOptions as ContractClientOptions,
|
|
7
|
-
Result,
|
|
8
4
|
Spec as ContractSpec,
|
|
9
5
|
} from '@stellar/stellar-sdk/contract';
|
|
10
6
|
import type {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
i64,
|
|
15
|
-
u128,
|
|
16
|
-
i128,
|
|
17
|
-
u256,
|
|
18
|
-
i256,
|
|
19
|
-
Option,
|
|
20
|
-
Typepoint,
|
|
21
|
-
Duration,
|
|
7
|
+
AssembledTransaction,
|
|
8
|
+
ClientOptions as ContractClientOptions,
|
|
9
|
+
Result,
|
|
22
10
|
} from '@stellar/stellar-sdk/contract';
|
|
23
|
-
export * from '@stellar/stellar-sdk'
|
|
24
|
-
export * as contract from '@stellar/stellar-sdk/contract'
|
|
25
|
-
export * as rpc from '@stellar/stellar-sdk/rpc'
|
|
26
11
|
|
|
27
12
|
if (typeof window !== 'undefined') {
|
|
28
13
|
//@ts-ignore Buffer exists
|
|
29
14
|
window.Buffer = window.Buffer || Buffer;
|
|
30
15
|
}
|
|
31
16
|
|
|
32
|
-
|
|
33
17
|
export const networks = {
|
|
34
18
|
testnet: {
|
|
35
19
|
networkPassphrase: "Test SDF Network ; September 2015",
|
|
@@ -38,16 +22,16 @@ export const networks = {
|
|
|
38
22
|
} as const
|
|
39
23
|
|
|
40
24
|
export const Errors = {
|
|
41
|
-
1: {message:""},
|
|
42
|
-
2: {message:""},
|
|
43
|
-
3: {message:""},
|
|
44
|
-
4: {message:""},
|
|
45
|
-
5: {message:""},
|
|
46
|
-
6: {message:""},
|
|
47
|
-
7: {message:""},
|
|
48
|
-
8: {message:""},
|
|
49
|
-
9: {message:""},
|
|
50
|
-
10: {message:""}
|
|
25
|
+
1: { message: "" },
|
|
26
|
+
2: { message: "" },
|
|
27
|
+
3: { message: "" },
|
|
28
|
+
4: { message: "" },
|
|
29
|
+
5: { message: "" },
|
|
30
|
+
6: { message: "" },
|
|
31
|
+
7: { message: "" },
|
|
32
|
+
8: { message: "" },
|
|
33
|
+
9: { message: "" },
|
|
34
|
+
10: { message: "" }
|
|
51
35
|
}
|
|
52
36
|
|
|
53
37
|
export interface Signature {
|
|
@@ -57,7 +41,6 @@ export interface Signature {
|
|
|
57
41
|
signature: Buffer;
|
|
58
42
|
}
|
|
59
43
|
|
|
60
|
-
|
|
61
44
|
export interface Client {
|
|
62
45
|
/**
|
|
63
46
|
* Construct and simulate a extend_ttl transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
@@ -82,7 +65,7 @@ export interface Client {
|
|
|
82
65
|
/**
|
|
83
66
|
* Construct and simulate a init transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
84
67
|
*/
|
|
85
|
-
init: ({id, pk, factory}: {id: Buffer, pk: Buffer, factory: string}, options?: {
|
|
68
|
+
init: ({ id, pk, factory }: { id: Buffer, pk: Buffer, factory: string }, options?: {
|
|
86
69
|
/**
|
|
87
70
|
* The fee to pay for the transaction. Default: BASE_FEE
|
|
88
71
|
*/
|
|
@@ -102,7 +85,7 @@ export interface Client {
|
|
|
102
85
|
/**
|
|
103
86
|
* Construct and simulate a resudo transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
104
87
|
*/
|
|
105
|
-
resudo: ({id}: {id: Buffer}, options?: {
|
|
88
|
+
resudo: ({ id }: { id: Buffer }, options?: {
|
|
106
89
|
/**
|
|
107
90
|
* The fee to pay for the transaction. Default: BASE_FEE
|
|
108
91
|
*/
|
|
@@ -122,7 +105,7 @@ export interface Client {
|
|
|
122
105
|
/**
|
|
123
106
|
* Construct and simulate a rm_sig transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
124
107
|
*/
|
|
125
|
-
rm_sig: ({id}: {id: Buffer}, options?: {
|
|
108
|
+
rm_sig: ({ id }: { id: Buffer }, options?: {
|
|
126
109
|
/**
|
|
127
110
|
* The fee to pay for the transaction. Default: BASE_FEE
|
|
128
111
|
*/
|
|
@@ -142,7 +125,7 @@ export interface Client {
|
|
|
142
125
|
/**
|
|
143
126
|
* Construct and simulate a add_sig transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
144
127
|
*/
|
|
145
|
-
add_sig: ({id, pk}: {id: Buffer, pk: Buffer}, options?: {
|
|
128
|
+
add_sig: ({ id, pk }: { id: Buffer, pk: Buffer }, options?: {
|
|
146
129
|
/**
|
|
147
130
|
* The fee to pay for the transaction. Default: BASE_FEE
|
|
148
131
|
*/
|
|
@@ -162,22 +145,22 @@ export interface Client {
|
|
|
162
145
|
export class Client extends ContractClient {
|
|
163
146
|
constructor(public readonly options: ContractClientOptions) {
|
|
164
147
|
super(
|
|
165
|
-
new ContractSpec([
|
|
148
|
+
new ContractSpec(["AAAABAAAAAAAAAAAAAAABUVycm9yAAAAAAAACgAAAAAAAAAJTm90SW5pdGVkAAAAAAAAAQAAAAAAAAAITm90Rm91bmQAAAACAAAAAAAAAAxOb3RQZXJtaXR0ZWQAAAADAAAAAAAAAA1BbHJlYWR5SW5pdGVkAAAAAAAABAAAAAAAAAAOSnNvblBhcnNlRXJyb3IAAAAAAAUAAAAAAAAADkludmFsaWRDb250ZXh0AAAAAAAGAAAAAAAAACBDbGllbnREYXRhSnNvbkNoYWxsZW5nZUluY29ycmVjdAAAAAcAAAAAAAAAF1NlY3AyNTZyMVB1YmxpY0tleVBhcnNlAAAAAAgAAAAAAAAAF1NlY3AyNTZyMVNpZ25hdHVyZVBhcnNlAAAAAAkAAAAAAAAAFVNlY3AyNTZyMVZlcmlmeUZhaWxlZAAAAAAAAAo=",
|
|
166
149
|
"AAAAAAAAAAAAAAAKZXh0ZW5kX3R0bAAAAAAAAAAAAAA=",
|
|
167
150
|
"AAAAAAAAAAAAAAAEaW5pdAAAAAMAAAAAAAAAAmlkAAAAAAAOAAAAAAAAAAJwawAAAAAD7gAAAEEAAAAAAAAAB2ZhY3RvcnkAAAAAEwAAAAEAAAPpAAAD7QAAAAAAAAAD",
|
|
168
151
|
"AAAAAAAAAAAAAAAGcmVzdWRvAAAAAAABAAAAAAAAAAJpZAAAAAAADgAAAAEAAAPpAAAD7QAAAAAAAAAD",
|
|
169
152
|
"AAAAAAAAAAAAAAAGcm1fc2lnAAAAAAABAAAAAAAAAAJpZAAAAAAADgAAAAEAAAPpAAAD7QAAAAAAAAAD",
|
|
170
153
|
"AAAAAAAAAAAAAAAHYWRkX3NpZwAAAAACAAAAAAAAAAJpZAAAAAAADgAAAAAAAAACcGsAAAAAA+4AAABBAAAAAQAAA+kAAAPtAAAAAAAAAAM=",
|
|
171
154
|
"AAAAAQAAAAAAAAAAAAAACVNpZ25hdHVyZQAAAAAAAAQAAAAAAAAAEmF1dGhlbnRpY2F0b3JfZGF0YQAAAAAADgAAAAAAAAAQY2xpZW50X2RhdGFfanNvbgAAAA4AAAAAAAAAAmlkAAAAAAAOAAAAAAAAAAlzaWduYXR1cmUAAAAAAAPuAAAAQA==",
|
|
172
|
-
"AAAAAAAAAAAAAAAMX19jaGVja19hdXRoAAAAAwAAAAAAAAARc2lnbmF0dXJlX3BheWxvYWQAAAAAAAPuAAAAIAAAAAAAAAAJc2lnbmF0dXJlAAAAAAAH0AAAAAlTaWduYXR1cmUAAAAAAAAAAAAADWF1dGhfY29udGV4dHMAAAAAAAPqAAAH0AAAAAdDb250ZXh0AAAAAAEAAAPpAAAD7QAAAAAAAAAD"
|
|
155
|
+
"AAAAAAAAAAAAAAAMX19jaGVja19hdXRoAAAAAwAAAAAAAAARc2lnbmF0dXJlX3BheWxvYWQAAAAAAAPuAAAAIAAAAAAAAAAJc2lnbmF0dXJlAAAAAAAH0AAAAAlTaWduYXR1cmUAAAAAAAAAAAAADWF1dGhfY29udGV4dHMAAAAAAAPqAAAH0AAAAAdDb250ZXh0AAAAAAEAAAPpAAAD7QAAAAAAAAAD"]),
|
|
173
156
|
options
|
|
174
157
|
)
|
|
175
158
|
}
|
|
176
159
|
public readonly fromJSON = {
|
|
177
160
|
extend_ttl: this.txFromJSON<null>,
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
161
|
+
init: this.txFromJSON<Result<void>>,
|
|
162
|
+
resudo: this.txFromJSON<Result<void>>,
|
|
163
|
+
rm_sig: this.txFromJSON<Result<void>>,
|
|
164
|
+
add_sig: this.txFromJSON<Result<void>>,
|
|
182
165
|
}
|
|
183
166
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Buffer } from "buffer";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export * as contract from '@stellar/stellar-sdk/contract';
|
|
5
|
-
export * as rpc from '@stellar/stellar-sdk/rpc';
|
|
2
|
+
import { Client as ContractClient } from '@stellar/stellar-sdk/contract';
|
|
3
|
+
import type { AssembledTransaction, ClientOptions as ContractClientOptions, Result } from '@stellar/stellar-sdk/contract';
|
|
6
4
|
export declare const networks: {
|
|
7
5
|
readonly testnet: {
|
|
8
6
|
readonly networkPassphrase: "Test SDF Network ; September 2015";
|
package/src/index.ts
CHANGED
|
@@ -15,8 +15,8 @@ import { Buffer } from 'buffer'
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
export class PasskeyAccount {
|
|
18
|
-
public
|
|
19
|
-
public
|
|
18
|
+
public keyId: string | undefined
|
|
19
|
+
public sudoKeyId: string | undefined
|
|
20
20
|
public wallet: PasskeyClient | undefined
|
|
21
21
|
public factory: FactoryClient
|
|
22
22
|
public sequencePublicKey: string
|
|
@@ -86,6 +86,7 @@ export class PasskeyAccount {
|
|
|
86
86
|
})
|
|
87
87
|
|
|
88
88
|
return {
|
|
89
|
+
keyId,
|
|
89
90
|
contractId,
|
|
90
91
|
xdr: built!.toXDR() as string
|
|
91
92
|
}
|
|
@@ -112,11 +113,12 @@ export class PasskeyAccount {
|
|
|
112
113
|
attestation: "none",
|
|
113
114
|
});
|
|
114
115
|
|
|
115
|
-
if (!this.
|
|
116
|
-
this.
|
|
116
|
+
if (!this.keyId) {
|
|
117
|
+
this.keyId = startRegistrationResponse.id
|
|
117
118
|
|
|
118
|
-
|
|
119
|
-
|
|
119
|
+
// If there was no keyId we're likely about to deploy a new wallet so we should set the sudoKeyId
|
|
120
|
+
if (!this.sudoKeyId)
|
|
121
|
+
this.sudoKeyId = startRegistrationResponse.id
|
|
120
122
|
}
|
|
121
123
|
|
|
122
124
|
return this.getKey(startRegistrationResponse)
|
|
@@ -129,8 +131,8 @@ export class PasskeyAccount {
|
|
|
129
131
|
userVerification: "discouraged",
|
|
130
132
|
});
|
|
131
133
|
|
|
132
|
-
if (!this.
|
|
133
|
-
this.
|
|
134
|
+
if (!this.keyId)
|
|
135
|
+
this.keyId = startAuthenticationResponse.id
|
|
134
136
|
|
|
135
137
|
const { keyId } = await this.getKey(startAuthenticationResponse)
|
|
136
138
|
|
|
@@ -173,12 +175,12 @@ export class PasskeyAccount {
|
|
|
173
175
|
public async sign(
|
|
174
176
|
txn: Transaction | string,
|
|
175
177
|
options?: {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
+
keyId?: 'any' | 'sudo' | string | Uint8Array
|
|
179
|
+
ledgersToLive?: number
|
|
178
180
|
}
|
|
179
181
|
) {
|
|
180
182
|
// Default mirrors DEFAULT_TIMEOUT (currently 5 minutes) https://github.com/stellar/js-stellar-sdk/blob/master/src/contract/utils.ts#L7
|
|
181
|
-
let {
|
|
183
|
+
let { keyId, ledgersToLive = 60 } = options || {}
|
|
182
184
|
|
|
183
185
|
// hack to ensure we don't stack fees when simulating and assembling multiple times
|
|
184
186
|
txn = TransactionBuilder.cloneFrom(new Transaction(
|
|
@@ -197,14 +199,14 @@ export class PasskeyAccount {
|
|
|
197
199
|
new xdr.HashIdPreimageSorobanAuthorization({
|
|
198
200
|
networkId: hash(Buffer.from(this.networkPassphrase, 'utf-8')),
|
|
199
201
|
nonce: auth.credentials().address().nonce(),
|
|
200
|
-
signatureExpirationLedger: lastLedger +
|
|
202
|
+
signatureExpirationLedger: lastLedger + ledgersToLive,
|
|
201
203
|
invocation: auth.rootInvocation()
|
|
202
204
|
})
|
|
203
205
|
).toXDR()
|
|
204
206
|
)
|
|
205
207
|
|
|
206
208
|
const authenticationResponse = await startAuthentication(
|
|
207
|
-
|
|
209
|
+
keyId === 'any' || (keyId === 'sudo' && !this.sudoKeyId)
|
|
208
210
|
? {
|
|
209
211
|
challenge: base64url(authHash),
|
|
210
212
|
// rpId: undefined,
|
|
@@ -215,11 +217,11 @@ export class PasskeyAccount {
|
|
|
215
217
|
// rpId: undefined,
|
|
216
218
|
allowCredentials: [
|
|
217
219
|
{
|
|
218
|
-
id:
|
|
219
|
-
? this.
|
|
220
|
-
:
|
|
221
|
-
? base64url(
|
|
222
|
-
:
|
|
220
|
+
id: keyId === 'sudo'
|
|
221
|
+
? this.sudoKeyId!
|
|
222
|
+
: keyId instanceof Uint8Array
|
|
223
|
+
? base64url(keyId)
|
|
224
|
+
: keyId || this.keyId!,
|
|
223
225
|
type: "public-key",
|
|
224
226
|
},
|
|
225
227
|
],
|
|
@@ -228,17 +230,17 @@ export class PasskeyAccount {
|
|
|
228
230
|
);
|
|
229
231
|
|
|
230
232
|
// set sudo if this is a sudo request
|
|
231
|
-
if (
|
|
232
|
-
this.
|
|
233
|
+
if (keyId === 'sudo')
|
|
234
|
+
this.sudoKeyId = authenticationResponse.id
|
|
233
235
|
|
|
234
236
|
// reset this.id to be the most recently used passkey
|
|
235
|
-
this.
|
|
237
|
+
this.keyId = authenticationResponse.id
|
|
236
238
|
|
|
237
239
|
const signatureRaw = base64url.toBuffer(authenticationResponse.response.signature);
|
|
238
240
|
const signature = this.convertEcdsaSignatureAsnToCompact(signatureRaw);
|
|
239
241
|
const creds = auth.credentials().address();
|
|
240
242
|
|
|
241
|
-
creds.signatureExpirationLedger(lastLedger +
|
|
243
|
+
creds.signatureExpirationLedger(lastLedger + ledgersToLive)
|
|
242
244
|
creds.signature(xdr.ScVal.scvMap([
|
|
243
245
|
new xdr.ScMapEntry({
|
|
244
246
|
key: xdr.ScVal.scvSymbol('authenticator_data'),
|
|
@@ -308,7 +310,7 @@ export class PasskeyAccount {
|
|
|
308
310
|
);
|
|
309
311
|
});
|
|
310
312
|
|
|
311
|
-
this.
|
|
313
|
+
this.sudoKeyId = base64url(data.get('sudo_sig'))
|
|
312
314
|
|
|
313
315
|
return data
|
|
314
316
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { Client as FactoryClient } from 'passkey-factory-sdk';
|
|
|
3
3
|
import { Networks, Transaction, Horizon, SorobanRpc } from '@stellar/stellar-sdk';
|
|
4
4
|
import { Buffer } from 'buffer';
|
|
5
5
|
export declare class PasskeyAccount {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
keyId: string | undefined;
|
|
7
|
+
sudoKeyId: string | undefined;
|
|
8
8
|
wallet: PasskeyClient | undefined;
|
|
9
9
|
factory: FactoryClient;
|
|
10
10
|
sequencePublicKey: string;
|
|
@@ -26,6 +26,7 @@ export declare class PasskeyAccount {
|
|
|
26
26
|
factoryContractId?: string;
|
|
27
27
|
});
|
|
28
28
|
createWallet(name: string, user: string): Promise<{
|
|
29
|
+
keyId: Buffer;
|
|
29
30
|
contractId: string;
|
|
30
31
|
xdr: string;
|
|
31
32
|
}>;
|
|
@@ -35,8 +36,8 @@ export declare class PasskeyAccount {
|
|
|
35
36
|
}>;
|
|
36
37
|
connectWallet(): Promise<string>;
|
|
37
38
|
sign(txn: Transaction | string, options?: {
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
keyId?: 'any' | 'sudo' | string | Uint8Array;
|
|
40
|
+
ledgersToLive?: number;
|
|
40
41
|
}): Promise<string>;
|
|
41
42
|
send(txn: Transaction, fee?: number): Promise<Horizon.HorizonApi.SubmitTransactionResponse>;
|
|
42
43
|
getData(): Promise<Map<string, any>>;
|