passkey-kit 0.7.5 → 0.7.6
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/cheatsheet +1 -2
- package/clone-js-sdk.sh +8 -0
- package/package.json +7 -6
- package/packages/passkey-factory-sdk/package.json +2 -2
- package/packages/passkey-factory-sdk/src/index.ts +3 -11
- package/packages/passkey-factory-sdk/types/index.d.ts +1 -7
- package/packages/passkey-kit-sdk/package.json +2 -2
- package/packages/passkey-kit-sdk/src/index.ts +3 -9
- package/packages/passkey-kit-sdk/types/index.d.ts +1 -6
- package/packages/sac-sdk/package.json +1 -1
- package/packages/sac-sdk/src/index.ts +0 -8
- package/packages/sac-sdk/types/index.d.ts +0 -6
- package/src/kit.ts +43 -51
package/cheatsheet
CHANGED
|
@@ -5,7 +5,6 @@ npm publish --workspaces
|
|
|
5
5
|
pnpm publish --no-git-checks
|
|
6
6
|
|
|
7
7
|
# Stellar commands
|
|
8
|
-
stellar contract bindings rust --wasm target/wasm32-unknown-unknown/release/webauthn_wallet.wasm
|
|
9
8
|
stellar contract deploy --wasm target/wasm32-unknown-unknown/release/sample_policy.wasm --network testnet --source default
|
|
10
9
|
|
|
11
10
|
# Mercury commands
|
|
@@ -13,7 +12,7 @@ stellar contract deploy --wasm target/wasm32-unknown-unknown/release/sample_poli
|
|
|
13
12
|
|
|
14
13
|
export JWT=???
|
|
15
14
|
mercury-cli --jwt $JWT --local false --mainnet false deploy
|
|
16
|
-
mercury-cli --jwt $JWT --local false --mainnet false catchup --project-name "smart-wallets-data-multi-signer-multi-sig" --contracts "
|
|
15
|
+
mercury-cli --jwt $JWT --local false --mainnet false catchup --project-name "smart-wallets-data-multi-signer-multi-sig" --contracts "CC3TMW7O43G3WJBZ2RVWMBBKL3B5KIO275D2LHQ43KJQF4TUOHFEYVOR"
|
|
17
16
|
curl -X GET https://api.mercurydata.app/catchups/4
|
|
18
17
|
curl -X POST https://api.mercurydata.app/zephyr/execute -H "Authorization: Bearer $MERCURY_JWT" -H 'Content-Type: application/json' -d '{"mode":{"Function": {"fname": "get_signers_by_address", "arguments": "{\"address\": \"CA4G3X75IGGNXNLXFIVFNYIGC6YAVLA7KSIFFDBSR7RQ7KEZMZWLXQBH\"}"}}}'
|
|
19
18
|
curl -X POST https://api.mercurydata.app/zephyr/execute -H "Authorization: Bearer $MERCURY_JWT" -H 'Content-Type: application/json' -d '{"mode":{"Function": {"fname": "get_address_by_signer", "arguments": "{\"id\": [78,127,30,69,248,174,95,168,47,59,161,168,51,120,117,135,112,133,232,92]}"}}}'
|
package/clone-js-sdk.sh
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
rm -rf ext/@stellar
|
|
4
|
+
mkdir -p ext/@stellar/stellar-sdk
|
|
5
|
+
cp -R ext/js-stellar-sdk/lib ext/@stellar/stellar-sdk/
|
|
6
|
+
cp -R ext/js-stellar-sdk/dist ext/@stellar/stellar-sdk/
|
|
7
|
+
cp -R ext/js-stellar-sdk/types ext/@stellar/stellar-sdk/
|
|
8
|
+
cp ext/js-stellar-sdk/package.json ext/@stellar/stellar-sdk/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "passkey-kit",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.6",
|
|
4
4
|
"description": "A helper library for creating and using passkey accounts on the Stellar blockchain.",
|
|
5
5
|
"author": "Tyler van der Hoeven",
|
|
6
6
|
"license": "MIT",
|
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@darkedges/capacitor-native-webauthn": "^0.0.4",
|
|
12
12
|
"@simplewebauthn/browser": "^10.0.0",
|
|
13
|
-
"@stellar/stellar-sdk": "file:./ext/
|
|
13
|
+
"@stellar/stellar-sdk": "file:./ext/@stellar/stellar-sdk",
|
|
14
14
|
"base64url": "^3.0.1",
|
|
15
15
|
"buffer": "^6.0.3",
|
|
16
|
-
"passkey-factory-sdk": "0.3.
|
|
17
|
-
"
|
|
18
|
-
"
|
|
16
|
+
"passkey-factory-sdk": "0.3.2",
|
|
17
|
+
"passkey-kit-sdk": "0.3.2",
|
|
18
|
+
"sac-sdk": "0.1.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@simplewebauthn/types": "^10.0.0",
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"build:sac": "pnpm --filter ./packages/sac-sdk run build",
|
|
54
54
|
"build:pfs": "pnpm --filter ./packages/passkey-factory-sdk run build",
|
|
55
55
|
"build:pks": "pnpm --filter ./packages/passkey-kit-sdk run build",
|
|
56
|
-
"build": "pnpm run build:sac && pnpm run build:pfs && pnpm run build:pks && tsc"
|
|
56
|
+
"build": "pnpm run build:sac && pnpm run build:pfs && pnpm run build:pks && tsc",
|
|
57
|
+
"ext:cp": "./clone-js-sdk.sh"
|
|
57
58
|
}
|
|
58
59
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.3.
|
|
2
|
+
"version": "0.3.2",
|
|
3
3
|
"name": "passkey-factory-sdk",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "src/index.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"buffer": "6.0.3",
|
|
13
|
-
"@stellar/stellar-sdk": "file:../../ext/
|
|
13
|
+
"@stellar/stellar-sdk": "file:../../ext/@stellar/stellar-sdk"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"typescript": "5.6.2"
|
|
@@ -26,17 +26,9 @@ if (typeof window !== 'undefined') {
|
|
|
26
26
|
window.Buffer = window.Buffer || Buffer;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
export const networks = {
|
|
31
|
-
testnet: {
|
|
32
|
-
networkPassphrase: "Test SDF Network ; September 2015",
|
|
33
|
-
contractId: "CBFNOEJVO4WVIHAYIBGES5AFTOWBBN274B3VD32QSD7AYJ6J4EH3K6HC",
|
|
34
|
-
}
|
|
35
|
-
} as const
|
|
36
|
-
|
|
37
|
-
export type SignerLimits = readonly [Map<string, Option<Array<SignerKey>>>];
|
|
38
29
|
export type SignerKey = { tag: "Policy", values: readonly [string] } | { tag: "Ed25519", values: readonly [Buffer] } | { tag: "Secp256r1", values: readonly [Buffer] };
|
|
39
30
|
|
|
31
|
+
export type SignerLimits = readonly [Map<string, Option<Array<SignerKey>>>];
|
|
40
32
|
export type SignerStorage = { tag: "Persistent", values: void } | { tag: "Temporary", values: void };
|
|
41
33
|
|
|
42
34
|
export type Signer = { tag: "Policy", values: readonly [string, SignerLimits, SignerStorage] } | { tag: "Ed25519", values: readonly [Buffer, SignerLimits, SignerStorage] } | { tag: "Secp256r1", values: readonly [Buffer, Buffer, SignerLimits, SignerStorage] };
|
|
@@ -92,8 +84,8 @@ export interface Client {
|
|
|
92
84
|
export class Client extends ContractClient {
|
|
93
85
|
constructor(public readonly options: ContractClientOptions) {
|
|
94
86
|
super(
|
|
95
|
-
new ContractSpec(["
|
|
96
|
-
"
|
|
87
|
+
new ContractSpec(["AAAAAgAAAAAAAAAAAAAACVNpZ25lcktleQAAAAAAAAMAAAABAAAAAAAAAAZQb2xpY3kAAAAAAAEAAAATAAAAAQAAAAAAAAAHRWQyNTUxOQAAAAABAAAD7gAAACAAAAABAAAAAAAAAAlTZWNwMjU2cjEAAAAAAAABAAAADg==",
|
|
88
|
+
"AAAAAQAAAAAAAAAAAAAADFNpZ25lckxpbWl0cwAAAAEAAAAAAAAAATAAAAAAAAPsAAAAEwAAA+gAAAPqAAAH0AAAAAlTaWduZXJLZXkAAAA=",
|
|
97
89
|
"AAAAAgAAAAAAAAAAAAAADVNpZ25lclN0b3JhZ2UAAAAAAAACAAAAAAAAAAAAAAAKUGVyc2lzdGVudAAAAAAAAAAAAAAAAAAJVGVtcG9yYXJ5AAAA",
|
|
98
90
|
"AAAAAgAAAAAAAAAAAAAABlNpZ25lcgAAAAAAAwAAAAEAAAAAAAAABlBvbGljeQAAAAAAAwAAABMAAAfQAAAADFNpZ25lckxpbWl0cwAAB9AAAAANU2lnbmVyU3RvcmFnZQAAAAAAAAEAAAAAAAAAB0VkMjU1MTkAAAAAAwAAA+4AAAAgAAAH0AAAAAxTaWduZXJMaW1pdHMAAAfQAAAADVNpZ25lclN0b3JhZ2UAAAAAAAABAAAAAAAAAAlTZWNwMjU2cjEAAAAAAAAEAAAADgAAA+4AAABBAAAH0AAAAAxTaWduZXJMaW1pdHMAAAfQAAAADVNpZ25lclN0b3JhZ2UAAAA=",
|
|
99
91
|
"AAAABAAAAAAAAAAAAAAABUVycm9yAAAAAAAAAgAAAAAAAAAOTm90SW5pdGlhbGl6ZWQAAAAAAAEAAAAAAAAAEkFscmVhZHlJbml0aWFsaXplZAAAAAAAAg==",
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import { Buffer } from "buffer";
|
|
2
2
|
import { AssembledTransaction, Client as ContractClient, ClientOptions as ContractClientOptions, Result } from '@stellar/stellar-sdk/contract';
|
|
3
3
|
import type { Option } from '@stellar/stellar-sdk/contract';
|
|
4
|
-
export declare const networks: {
|
|
5
|
-
readonly testnet: {
|
|
6
|
-
readonly networkPassphrase: "Test SDF Network ; September 2015";
|
|
7
|
-
readonly contractId: "CBFNOEJVO4WVIHAYIBGES5AFTOWBBN274B3VD32QSD7AYJ6J4EH3K6HC";
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
export type SignerLimits = readonly [Map<string, Option<Array<SignerKey>>>];
|
|
11
4
|
export type SignerKey = {
|
|
12
5
|
tag: "Policy";
|
|
13
6
|
values: readonly [string];
|
|
@@ -18,6 +11,7 @@ export type SignerKey = {
|
|
|
18
11
|
tag: "Secp256r1";
|
|
19
12
|
values: readonly [Buffer];
|
|
20
13
|
};
|
|
14
|
+
export type SignerLimits = readonly [Map<string, Option<Array<SignerKey>>>];
|
|
21
15
|
export type SignerStorage = {
|
|
22
16
|
tag: "Persistent";
|
|
23
17
|
values: void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.3.
|
|
2
|
+
"version": "0.3.2",
|
|
3
3
|
"name": "passkey-kit-sdk",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "src/index.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"buffer": "6.0.3",
|
|
13
|
-
"@stellar/stellar-sdk": "file:../../ext/
|
|
13
|
+
"@stellar/stellar-sdk": "file:../../ext/@stellar/stellar-sdk"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"typescript": "5.6.2"
|
|
@@ -26,14 +26,6 @@ if (typeof window !== 'undefined') {
|
|
|
26
26
|
window.Buffer = window.Buffer || Buffer;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
export const networks = {
|
|
31
|
-
testnet: {
|
|
32
|
-
networkPassphrase: "Test SDF Network ; September 2015",
|
|
33
|
-
contractId: "CBFNOEJVO4WVIHAYIBGES5AFTOWBBN274B3VD32QSD7AYJ6J4EH3K6HC",
|
|
34
|
-
}
|
|
35
|
-
} as const
|
|
36
|
-
|
|
37
29
|
export const Errors = {
|
|
38
30
|
1: { message: "NotFound" },
|
|
39
31
|
|
|
@@ -67,6 +59,7 @@ export interface Secp256r1Signature {
|
|
|
67
59
|
|
|
68
60
|
export type Signature = { tag: "Ed25519", values: readonly [Buffer] } | { tag: "Secp256r1", values: readonly [Secp256r1Signature] };
|
|
69
61
|
|
|
62
|
+
export type Signatures = readonly [Map<SignerKey, Option<Signature>>];
|
|
70
63
|
|
|
71
64
|
export interface Client {
|
|
72
65
|
/**
|
|
@@ -141,10 +134,11 @@ export class Client extends ContractClient {
|
|
|
141
134
|
"AAAAAgAAAAAAAAAAAAAABlNpZ25lcgAAAAAAAwAAAAEAAAAAAAAABlBvbGljeQAAAAAAAwAAABMAAAfQAAAADFNpZ25lckxpbWl0cwAAB9AAAAANU2lnbmVyU3RvcmFnZQAAAAAAAAEAAAAAAAAAB0VkMjU1MTkAAAAAAwAAA+4AAAAgAAAH0AAAAAxTaWduZXJMaW1pdHMAAAfQAAAADVNpZ25lclN0b3JhZ2UAAAAAAAABAAAAAAAAAAlTZWNwMjU2cjEAAAAAAAAEAAAADgAAA+4AAABBAAAH0AAAAAxTaWduZXJMaW1pdHMAAAfQAAAADVNpZ25lclN0b3JhZ2UAAAA=",
|
|
142
135
|
"AAAAAQAAAAAAAAAAAAAAElNlY3AyNTZyMVNpZ25hdHVyZQAAAAAAAwAAAAAAAAASYXV0aGVudGljYXRvcl9kYXRhAAAAAAAOAAAAAAAAABBjbGllbnRfZGF0YV9qc29uAAAADgAAAAAAAAAJc2lnbmF0dXJlAAAAAAAD7gAAAEA=",
|
|
143
136
|
"AAAAAgAAAAAAAAAAAAAACVNpZ25hdHVyZQAAAAAAAAIAAAABAAAAAAAAAAdFZDI1NTE5AAAAAAEAAAPuAAAAQAAAAAEAAAAAAAAACVNlY3AyNTZyMQAAAAAAAAEAAAfQAAAAElNlY3AyNTZyMVNpZ25hdHVyZQAA",
|
|
137
|
+
"AAAAAQAAAAAAAAAAAAAAClNpZ25hdHVyZXMAAAAAAAEAAAAAAAAAATAAAAAAAAPsAAAH0AAAAAlTaWduZXJLZXkAAAAAAAPoAAAH0AAAAAlTaWduYXR1cmUAAAA=",
|
|
144
138
|
"AAAAAAAAAAAAAAADYWRkAAAAAAEAAAAAAAAABnNpZ25lcgAAAAAH0AAAAAZTaWduZXIAAAAAAAEAAAPpAAAD7QAAAAAAAAAD",
|
|
145
139
|
"AAAAAAAAAAAAAAAGcmVtb3ZlAAAAAAABAAAAAAAAAApzaWduZXJfa2V5AAAAAAfQAAAACVNpZ25lcktleQAAAAAAAAEAAAPpAAAD7QAAAAAAAAAD",
|
|
146
140
|
"AAAAAAAAAAAAAAAGdXBkYXRlAAAAAAABAAAAAAAAAARoYXNoAAAD7gAAACAAAAABAAAD6QAAA+0AAAAAAAAAAw==",
|
|
147
|
-
"
|
|
141
|
+
"AAAAAAAAAAAAAAAMX19jaGVja19hdXRoAAAAAwAAAAAAAAARc2lnbmF0dXJlX3BheWxvYWQAAAAAAAPuAAAAIAAAAAAAAAAKc2lnbmF0dXJlcwAAAAAH0AAAAApTaWduYXR1cmVzAAAAAAAAAAAADWF1dGhfY29udGV4dHMAAAAAAAPqAAAH0AAAAAdDb250ZXh0AAAAAAEAAAPpAAAD7QAAAAAAAAAD"]),
|
|
148
142
|
options
|
|
149
143
|
)
|
|
150
144
|
}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { Buffer } from "buffer";
|
|
2
2
|
import { AssembledTransaction, Client as ContractClient, ClientOptions as ContractClientOptions, Result } from '@stellar/stellar-sdk/contract';
|
|
3
3
|
import type { Option } from '@stellar/stellar-sdk/contract';
|
|
4
|
-
export declare const networks: {
|
|
5
|
-
readonly testnet: {
|
|
6
|
-
readonly networkPassphrase: "Test SDF Network ; September 2015";
|
|
7
|
-
readonly contractId: "CBFNOEJVO4WVIHAYIBGES5AFTOWBBN274B3VD32QSD7AYJ6J4EH3K6HC";
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
4
|
export declare const Errors: {
|
|
11
5
|
1: {
|
|
12
6
|
message: string;
|
|
@@ -80,6 +74,7 @@ export type Signature = {
|
|
|
80
74
|
tag: "Secp256r1";
|
|
81
75
|
values: readonly [Secp256r1Signature];
|
|
82
76
|
};
|
|
77
|
+
export type Signatures = readonly [Map<SignerKey, Option<Signature>>];
|
|
83
78
|
export interface Client {
|
|
84
79
|
/**
|
|
85
80
|
* Construct and simulate a add 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.
|
|
@@ -26,14 +26,6 @@ if (typeof window !== 'undefined') {
|
|
|
26
26
|
window.Buffer = window.Buffer || Buffer;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
export const networks = {
|
|
31
|
-
testnet: {
|
|
32
|
-
networkPassphrase: "Test SDF Network ; September 2015",
|
|
33
|
-
contractId: "CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC",
|
|
34
|
-
}
|
|
35
|
-
} as const
|
|
36
|
-
|
|
37
29
|
export const Errors = {
|
|
38
30
|
|
|
39
31
|
}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { AssembledTransaction, Client as ContractClient, ClientOptions as ContractClientOptions } from '@stellar/stellar-sdk/contract';
|
|
2
2
|
import type { u32, i128 } from '@stellar/stellar-sdk/contract';
|
|
3
|
-
export declare const networks: {
|
|
4
|
-
readonly testnet: {
|
|
5
|
-
readonly networkPassphrase: "Test SDF Network ; September 2015";
|
|
6
|
-
readonly contractId: "CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC";
|
|
7
|
-
};
|
|
8
|
-
};
|
|
9
3
|
export declare const Errors: {};
|
|
10
4
|
export interface Client {
|
|
11
5
|
/**
|
package/src/kit.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Client as PasskeyClient, type Signature, type SignerKey } from 'passkey-kit-sdk'
|
|
1
|
+
import { Client as PasskeyClient, type Signature, type Signatures, type SignerKey } from 'passkey-kit-sdk'
|
|
2
2
|
import { Client as FactoryClient } from 'passkey-factory-sdk'
|
|
3
|
-
import { Address, StrKey, hash, xdr, SorobanRpc, Keypair, Transaction, Operation } from '@stellar/stellar-sdk'
|
|
3
|
+
import { Address, StrKey, hash, xdr, SorobanRpc, Keypair, Transaction, Operation, nativeToScVal } from '@stellar/stellar-sdk'
|
|
4
4
|
import base64url from 'base64url'
|
|
5
5
|
import { startRegistration, startAuthentication } from "@simplewebauthn/browser"
|
|
6
6
|
import type { AuthenticatorAttestationResponseJSON, AuthenticatorSelectionCriteria } from "@simplewebauthn/types"
|
|
@@ -191,7 +191,7 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
191
191
|
) {
|
|
192
192
|
let { rpId, keyId, keypair, policy, expiration } = options || {}
|
|
193
193
|
|
|
194
|
-
if ([keyId, keypair, policy].filter((arg) => arg).length
|
|
194
|
+
if ([keyId, keypair, policy].filter((arg) => !!arg).length > 1)
|
|
195
195
|
throw new Error('Exactly one of `options.keyId`, `options.keypair`, or `options.policy` must be provided.');
|
|
196
196
|
|
|
197
197
|
const credentials = entry.credentials().address();
|
|
@@ -218,9 +218,23 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
218
218
|
|
|
219
219
|
const payload = hash(preimage.toXDR())
|
|
220
220
|
|
|
221
|
+
// let signatures: Signatures
|
|
221
222
|
let key: SignerKey
|
|
222
223
|
let val: Signature | undefined
|
|
223
224
|
|
|
225
|
+
// const scSpecTypeDefSignatures = xdr.ScSpecTypeDef.scSpecTypeUdt(
|
|
226
|
+
// new xdr.ScSpecTypeUdt({ name: "Signatures" }),
|
|
227
|
+
// );
|
|
228
|
+
|
|
229
|
+
// switch (credentials.signature().switch()) {
|
|
230
|
+
// case xdr.ScValType.scvVoid():
|
|
231
|
+
// signatures = [new Map()]
|
|
232
|
+
// break;
|
|
233
|
+
// default: {
|
|
234
|
+
// signatures = this.wallet!.spec.scValToNative(credentials.signature(), scSpecTypeDefSignatures)
|
|
235
|
+
// }
|
|
236
|
+
// }
|
|
237
|
+
|
|
224
238
|
// Sign with a policy
|
|
225
239
|
if (policy) {
|
|
226
240
|
key = {
|
|
@@ -307,15 +321,17 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
307
321
|
|
|
308
322
|
switch (credentials.signature().switch().name) {
|
|
309
323
|
case 'scvVoid':
|
|
310
|
-
credentials.signature(xdr.ScVal.
|
|
324
|
+
credentials.signature(xdr.ScVal.scvVec([
|
|
325
|
+
xdr.ScVal.scvMap([scEntry])
|
|
326
|
+
]))
|
|
311
327
|
break;
|
|
312
|
-
case '
|
|
328
|
+
case 'scvVec':
|
|
313
329
|
// Add the new signature to the existing map
|
|
314
|
-
credentials.signature().map()?.push(scEntry)
|
|
330
|
+
credentials.signature().vec()?.[0].map()?.push(scEntry)
|
|
315
331
|
|
|
316
332
|
// Order the map by key
|
|
317
333
|
// Not using Buffer.compare because Symbols are 9 bytes and unused bytes _append_ 0s vs prepending them, which is too bad
|
|
318
|
-
credentials.signature().map()?.sort((a, b) => {
|
|
334
|
+
credentials.signature().vec()?.[0].map()?.sort((a, b) => {
|
|
319
335
|
return (
|
|
320
336
|
a.key().vec()![0].sym() +
|
|
321
337
|
a.key().vec()![1].toXDR().join('')
|
|
@@ -329,33 +345,28 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
329
345
|
throw new Error('Unsupported signature')
|
|
330
346
|
}
|
|
331
347
|
|
|
348
|
+
// Insert the new signature into the signatures Map
|
|
349
|
+
// signatures[0].set(key, val)
|
|
350
|
+
|
|
351
|
+
// Insert the new signatures Map into the credentials
|
|
352
|
+
// credentials.signature(
|
|
353
|
+
// this.wallet!.spec.nativeToScVal(signatures, scSpecTypeDefSignatures)
|
|
354
|
+
// )
|
|
355
|
+
|
|
356
|
+
// Order the signatures map
|
|
357
|
+
// credentials.signature().vec()?.[0].map()?.sort((a, b) => {
|
|
358
|
+
// return (
|
|
359
|
+
// a.key().vec()![0].sym() +
|
|
360
|
+
// a.key().vec()![1].toXDR().join('')
|
|
361
|
+
// ).localeCompare(
|
|
362
|
+
// b.key().vec()![0].sym() +
|
|
363
|
+
// b.key().vec()![1].toXDR().join('')
|
|
364
|
+
// )
|
|
365
|
+
// })
|
|
366
|
+
|
|
332
367
|
return entry
|
|
333
368
|
}
|
|
334
369
|
|
|
335
|
-
// public async signAuthEntries(
|
|
336
|
-
// entries: xdr.SorobanAuthorizationEntry[],
|
|
337
|
-
// options?: {
|
|
338
|
-
// rpId?: string,
|
|
339
|
-
// keyId?: 'any' | string | Uint8Array
|
|
340
|
-
// keypair?: Keypair,
|
|
341
|
-
// policy?: string,
|
|
342
|
-
// expiration?: number
|
|
343
|
-
// }
|
|
344
|
-
// ) {
|
|
345
|
-
// // TODO should there be more control over which auth entries are signed? Especially given we support multiple signers now?
|
|
346
|
-
// // As-is .sign() will always sign every smart wallet auth entry. This may be okay but likely we should have more control over which auth entry the signer is signing
|
|
347
|
-
// for (const auth of entries) {
|
|
348
|
-
// if (
|
|
349
|
-
// auth.credentials().switch().name === 'sorobanCredentialsAddress'
|
|
350
|
-
// && auth.credentials().address().address().switch().name === 'scAddressTypeContract'
|
|
351
|
-
// ) {
|
|
352
|
-
// // If auth entry matches our Smart Wallet move forward with the signature request
|
|
353
|
-
// if (Address.contract(auth.credentials().address().address().contractId()).toString() === this.wallet?.options.contractId)
|
|
354
|
-
// await this.signAuthEntry(auth, options)
|
|
355
|
-
// }
|
|
356
|
-
// }
|
|
357
|
-
// }
|
|
358
|
-
|
|
359
370
|
public async sign(
|
|
360
371
|
txn: AssembledTransaction<unknown>,
|
|
361
372
|
options?: {
|
|
@@ -375,26 +386,7 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
375
386
|
})
|
|
376
387
|
}
|
|
377
388
|
|
|
378
|
-
//
|
|
379
|
-
// if (txn.operations.length !== 1)
|
|
380
|
-
// throw new Error('Must include only one Soroban operation')
|
|
381
|
-
|
|
382
|
-
// for (const op of txn.operations) {
|
|
383
|
-
// if (
|
|
384
|
-
// op.type !== 'invokeHostFunction'
|
|
385
|
-
// && op.type !== 'extendFootprintTtl'
|
|
386
|
-
// && op.type !== 'restoreFootprint'
|
|
387
|
-
// ) throw new Error('Must include only one operation of type `invokeHostFunction` or `extendFootprintTtl` or `restoreFootprint`')
|
|
388
|
-
// }
|
|
389
|
-
|
|
390
|
-
// // Only need to sign auth for `invokeHostFunction` operations
|
|
391
|
-
// if (txn.operations[0].type === 'invokeHostFunction') {
|
|
392
|
-
// const entries = txn.operations[0].auth
|
|
393
|
-
|
|
394
|
-
// if (entries && entries.length)
|
|
395
|
-
// return entries
|
|
396
|
-
// }
|
|
397
|
-
// }
|
|
389
|
+
// Add little utility helpers for adding and removing signers
|
|
398
390
|
|
|
399
391
|
/* LATER
|
|
400
392
|
- Add a getKeyInfo action to get info about a specific passkey
|