ns-auth-sdk 1.14.0 → 1.14.2
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/{cjs-CSUAVztq.cjs → browser-index.cjs} +5476 -296
- package/dist/browser-index.cjs.map +1 -0
- package/dist/browser-index.d.cts +1998 -0
- package/dist/browser-index.d.cts.map +1 -0
- package/dist/browser-index.d.mts +1998 -0
- package/dist/browser-index.d.mts.map +1 -0
- package/dist/{cjs-sm5h7qxv.mjs → browser-index.mjs} +5169 -69
- package/dist/browser-index.mjs.map +1 -0
- package/dist/{group-coordination-BlFpBVpn.mjs → group-coordination-BV6PKlKp.mjs} +1 -1
- package/dist/{group-coordination-BlFpBVpn.mjs.map → group-coordination-BV6PKlKp.mjs.map} +1 -1
- package/dist/{group-coordination-ImuoJEoy.mjs → group-coordination-BytkmY9j.mjs} +1 -1
- package/dist/{group-coordination-LGIyipaX.cjs → group-coordination-DL39hJ3R.cjs} +1 -1
- package/dist/{group-coordination-LGIyipaX.cjs.map → group-coordination-DL39hJ3R.cjs.map} +1 -1
- package/dist/{group-coordination-Cf18OjZt.cjs → group-coordination-DLban6a7.cjs} +1 -1
- package/dist/index.cjs +8899 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.mjs +9072 -213
- package/dist/index.mjs.map +1 -1
- package/dist/{prf-handler-D3EqUNWe.cjs → prf-handler-BNd7gmXJ.cjs} +1 -1
- package/dist/{prf-handler-D3EqUNWe.cjs.map → prf-handler-BNd7gmXJ.cjs.map} +1 -1
- package/dist/prf-handler-CRMgzJG2.cjs +3 -0
- package/dist/{prf-handler-Dly_WZGn.mjs → prf-handler-DG99ZkS2.mjs} +1 -1
- package/dist/{prf-handler-Db8CsoIP.mjs → prf-handler-Dj2WTO9i.mjs} +1 -1
- package/dist/{prf-handler-Db8CsoIP.mjs.map → prf-handler-Dj2WTO9i.mjs.map} +1 -1
- package/dist/zkm.service-Bv88tVS5.mjs +3 -0
- package/dist/zkm.service-D2BZ_aqA.cjs +3 -0
- package/dist/{zkm.service-DfSPbuOl.cjs → zkm.service-DX06sSfB.cjs} +1 -1
- package/dist/{zkm.service-DfSPbuOl.cjs.map → zkm.service-DX06sSfB.cjs.map} +1 -1
- package/dist/{zkm.service-B24N_0FB.mjs → zkm.service-j0HlN7Oq.mjs} +1 -1
- package/dist/{zkm.service-B24N_0FB.mjs.map → zkm.service-j0HlN7Oq.mjs.map} +1 -1
- package/package.json +19 -6
- package/dist/_esm-C7FRLTj2.cjs +0 -9030
- package/dist/_esm-C7FRLTj2.cjs.map +0 -1
- package/dist/_esm-D_oMW5T5.mjs +0 -9028
- package/dist/_esm-D_oMW5T5.mjs.map +0 -1
- package/dist/base64-js-B8y7dH5k.mjs +0 -93
- package/dist/base64-js-B8y7dH5k.mjs.map +0 -1
- package/dist/base64-js-Tm-kCeud.cjs +0 -98
- package/dist/base64-js-Tm-kCeud.cjs.map +0 -1
- package/dist/ccip-157tdxqP.cjs +0 -7947
- package/dist/ccip-157tdxqP.cjs.map +0 -1
- package/dist/ccip-BEMMdVyd.cjs +0 -4
- package/dist/ccip-BSmCdJ3K.mjs +0 -3
- package/dist/ccip-okqXkslP.mjs +0 -6567
- package/dist/ccip-okqXkslP.mjs.map +0 -1
- package/dist/chains-CTeD2UcS.mjs +0 -33
- package/dist/chains-CTeD2UcS.mjs.map +0 -1
- package/dist/chains-Du-lv_5i.cjs +0 -33
- package/dist/chains-Du-lv_5i.cjs.map +0 -1
- package/dist/chunk-Bnu9O96Y.cjs +0 -60
- package/dist/chunk-CVYhg9ik.mjs +0 -45
- package/dist/cjs-CSUAVztq.cjs.map +0 -1
- package/dist/cjs-sm5h7qxv.mjs.map +0 -1
- package/dist/defineChain-7QG67hYU.cjs +0 -30
- package/dist/defineChain-7QG67hYU.cjs.map +0 -1
- package/dist/defineChain-DBem8ZQY.mjs +0 -24
- package/dist/defineChain-DBem8ZQY.mjs.map +0 -1
- package/dist/dist-BPmSxkxc.cjs +0 -10676
- package/dist/dist-BPmSxkxc.cjs.map +0 -1
- package/dist/dist-BSjH4t6s.cjs +0 -12932
- package/dist/dist-BSjH4t6s.cjs.map +0 -1
- package/dist/dist-C-KjTK4Q.cjs +0 -447
- package/dist/dist-C-KjTK4Q.cjs.map +0 -1
- package/dist/dist-C2h97xM-.mjs +0 -355
- package/dist/dist-C2h97xM-.mjs.map +0 -1
- package/dist/dist-CT7grDWb.mjs +0 -12920
- package/dist/dist-CT7grDWb.mjs.map +0 -1
- package/dist/dist-D7fRmK6G.mjs +0 -10632
- package/dist/dist-D7fRmK6G.mjs.map +0 -1
- package/dist/dist-DlmcyFmM.mjs +0 -16951
- package/dist/dist-DlmcyFmM.mjs.map +0 -1
- package/dist/dist-O0uZr5OF.cjs +0 -17122
- package/dist/dist-O0uZr5OF.cjs.map +0 -1
- package/dist/echo-BB-JgAYZ.cjs +0 -339
- package/dist/echo-BB-JgAYZ.cjs.map +0 -1
- package/dist/echo-Bwy4_Cvh.mjs +0 -316
- package/dist/echo-Bwy4_Cvh.mjs.map +0 -1
- package/dist/echo-D6X2IuNW.cjs +0 -9
- package/dist/echo-DvfG_heb.mjs +0 -8
- package/dist/esm-BcHKCX5i.mjs +0 -569
- package/dist/esm-BcHKCX5i.mjs.map +0 -1
- package/dist/esm-Bh_YwFIz.cjs +0 -599
- package/dist/esm-Bh_YwFIz.cjs.map +0 -1
- package/dist/esm-C0XO9TQm.cjs +0 -30449
- package/dist/esm-C0XO9TQm.cjs.map +0 -1
- package/dist/esm-vMUVj9k4.mjs +0 -30440
- package/dist/esm-vMUVj9k4.mjs.map +0 -1
- package/dist/keyset-CKMQXvsb.mjs +0 -172
- package/dist/keyset-CKMQXvsb.mjs.map +0 -1
- package/dist/keyset-Cxdgu110.cjs +0 -237
- package/dist/keyset-Cxdgu110.cjs.map +0 -1
- package/dist/keyset-DLxpGhdu.cjs +0 -6
- package/dist/keyset-IKjlhvqF.mjs +0 -4
- package/dist/node-3EUJ4ga9.cjs +0 -9
- package/dist/node-C2UpE11T.cjs +0 -444
- package/dist/node-C2UpE11T.cjs.map +0 -1
- package/dist/node-CHdpTQdN.mjs +0 -8679
- package/dist/node-CHdpTQdN.mjs.map +0 -1
- package/dist/node-DQt1CVGl.mjs +0 -6
- package/dist/node-Dy8ww1LG.cjs +0 -8680
- package/dist/node-Dy8ww1LG.cjs.map +0 -1
- package/dist/node-IX55IH6z.mjs +0 -397
- package/dist/node-IX55IH6z.mjs.map +0 -1
- package/dist/nostr-BTOpBN_5.cjs +0 -11
- package/dist/nostr-D4E52XRU.mjs +0 -224
- package/dist/nostr-D4E52XRU.mjs.map +0 -1
- package/dist/nostr-Hv2tsnuI.cjs +0 -272
- package/dist/nostr-Hv2tsnuI.cjs.map +0 -1
- package/dist/nostr-ZwJe_DlZ.mjs +0 -4
- package/dist/pako.esm-DTVnlCJh.cjs +0 -3856
- package/dist/pako.esm-DTVnlCJh.cjs.map +0 -1
- package/dist/pako.esm-ORhkEHM2.mjs +0 -3838
- package/dist/pako.esm-ORhkEHM2.mjs.map +0 -1
- package/dist/peer-B9g3OQ5D.cjs +0 -18
- package/dist/peer-CptDj7zu.mjs +0 -745
- package/dist/peer-CptDj7zu.mjs.map +0 -1
- package/dist/peer-CtqL0yiE.mjs +0 -9
- package/dist/peer-XrPL0O6z.cjs +0 -822
- package/dist/peer-XrPL0O6z.cjs.map +0 -1
- package/dist/ping-BXKREIdI.mjs +0 -7
- package/dist/ping-BtVhKocl.cjs +0 -379
- package/dist/ping-BtVhKocl.cjs.map +0 -1
- package/dist/ping-D5fpMhGC.cjs +0 -11
- package/dist/ping-DOD50kW_.mjs +0 -332
- package/dist/ping-DOD50kW_.mjs.map +0 -1
- package/dist/policy-8HcjulLD.cjs +0 -293
- package/dist/policy-8HcjulLD.cjs.map +0 -1
- package/dist/policy-BA6MEOBY.mjs +0 -5
- package/dist/policy-BFNdXvmM.cjs +0 -11
- package/dist/policy-D_nFHHjo.mjs +0 -228
- package/dist/policy-D_nFHHjo.mjs.map +0 -1
- package/dist/prf-handler-BNiyCQMt.cjs +0 -3
- package/dist/src-CVfTUJQl.mjs +0 -822
- package/dist/src-CVfTUJQl.mjs.map +0 -1
- package/dist/src-D5S86Xpf.cjs +0 -827
- package/dist/src-D5S86Xpf.cjs.map +0 -1
- package/dist/types-B-TLIS13.cjs +0 -212
- package/dist/types-B-TLIS13.cjs.map +0 -1
- package/dist/types-CTm_FHYD.mjs +0 -111
- package/dist/types-CTm_FHYD.mjs.map +0 -1
- package/dist/validation-1xwWVXqE.mjs +0 -3
- package/dist/validation-DnpurN79.cjs +0 -405
- package/dist/validation-DnpurN79.cjs.map +0 -1
- package/dist/validation-IsAUvsvy.mjs +0 -334
- package/dist/validation-IsAUvsvy.mjs.map +0 -1
- package/dist/validation-yCvZCqIs.cjs +0 -6
- package/dist/wrapper-C5NpyacC.cjs +0 -3552
- package/dist/wrapper-C5NpyacC.cjs.map +0 -1
- package/dist/wrapper-CHq_CV4J.mjs +0 -3552
- package/dist/wrapper-CHq_CV4J.mjs.map +0 -1
- package/dist/zkm.service-BrXyI4BS.mjs +0 -3
- package/dist/zkm.service-BvQ01wSH.cjs +0 -3
package/dist/keyset-CKMQXvsb.mjs
DELETED
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import { PackageEncoder, n as generate_dealer_pkg, r as recover_secret_key, t as nip19_exports } from "./dist-D7fRmK6G.mjs";
|
|
2
|
-
import { _ as SecretKeySchema, h as RecoveryError, o as KeysetError, s as KeysetParamsSchema } from "./types-CTm_FHYD.mjs";
|
|
3
|
-
|
|
4
|
-
//#region node_modules/@frostr/igloo-core/dist/keyset.js
|
|
5
|
-
/**
|
|
6
|
-
* Validates keyset parameters
|
|
7
|
-
*/
|
|
8
|
-
function validateKeysetParams(params) {
|
|
9
|
-
try {
|
|
10
|
-
KeysetParamsSchema.parse(params);
|
|
11
|
-
} catch (error) {
|
|
12
|
-
throw new KeysetError(`Invalid keyset parameters: ${error.message}`, {
|
|
13
|
-
params,
|
|
14
|
-
validationError: error
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Validates a secret key
|
|
20
|
-
*/
|
|
21
|
-
function validateSecretKey(secretKey) {
|
|
22
|
-
try {
|
|
23
|
-
SecretKeySchema.parse(secretKey);
|
|
24
|
-
} catch (error) {
|
|
25
|
-
throw new KeysetError(`Invalid secret key: ${error.message}`, { validationError: error });
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Generates a keyset with a provided secret key
|
|
30
|
-
* @param threshold Number of shares required to sign
|
|
31
|
-
* @param totalMembers Total number of shares to create
|
|
32
|
-
* @param secretKey Hex-encoded secret key
|
|
33
|
-
* @returns Object containing encoded group and share credentials
|
|
34
|
-
*/
|
|
35
|
-
function generateKeysetWithSecret(threshold, totalMembers, secretKey) {
|
|
36
|
-
const params = {
|
|
37
|
-
threshold,
|
|
38
|
-
totalMembers
|
|
39
|
-
};
|
|
40
|
-
try {
|
|
41
|
-
validateKeysetParams(params);
|
|
42
|
-
validateSecretKey(secretKey);
|
|
43
|
-
const { group, shares } = generate_dealer_pkg(threshold, totalMembers, [secretKey]);
|
|
44
|
-
return {
|
|
45
|
-
groupCredential: PackageEncoder.group.encode(group),
|
|
46
|
-
shareCredentials: shares.map((share) => PackageEncoder.share.encode(share))
|
|
47
|
-
};
|
|
48
|
-
} catch (error) {
|
|
49
|
-
if (error instanceof KeysetError) throw error;
|
|
50
|
-
throw new KeysetError(`Failed to generate keyset: ${error.message}`, {
|
|
51
|
-
params,
|
|
52
|
-
error
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Decodes a share credential string into a SharePackage
|
|
58
|
-
*/
|
|
59
|
-
function decodeShare(shareCredential) {
|
|
60
|
-
try {
|
|
61
|
-
return PackageEncoder.share.decode(shareCredential);
|
|
62
|
-
} catch (error) {
|
|
63
|
-
throw new KeysetError(`Failed to decode share: ${error.message}`, {
|
|
64
|
-
shareCredential,
|
|
65
|
-
error
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Decodes a group credential string into a GroupPackage
|
|
71
|
-
*/
|
|
72
|
-
function decodeGroup(groupCredential) {
|
|
73
|
-
try {
|
|
74
|
-
return PackageEncoder.group.decode(groupCredential);
|
|
75
|
-
} catch (error) {
|
|
76
|
-
throw new KeysetError(`Failed to decode group: ${error.message}`, {
|
|
77
|
-
groupCredential,
|
|
78
|
-
error
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Gets basic details about a share (index only for now)
|
|
84
|
-
* For full details including threshold, use getShareDetailsWithGroup
|
|
85
|
-
*/
|
|
86
|
-
function getShareDetails(shareCredential) {
|
|
87
|
-
return { idx: decodeShare(shareCredential).idx };
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Gets complete details about a share including threshold info from group
|
|
91
|
-
*/
|
|
92
|
-
function getShareDetailsWithGroup(shareCredential, groupCredential) {
|
|
93
|
-
const share = decodeShare(shareCredential);
|
|
94
|
-
const group = decodeGroup(groupCredential);
|
|
95
|
-
if (share.keysetId && group.keysetId && share.keysetId !== group.keysetId) throw new KeysetError("Share and group do not belong to the same keyset", {
|
|
96
|
-
shareKeysetId: share.keysetId,
|
|
97
|
-
groupKeysetId: group.keysetId
|
|
98
|
-
});
|
|
99
|
-
return {
|
|
100
|
-
idx: share.idx,
|
|
101
|
-
threshold: group.threshold,
|
|
102
|
-
totalMembers: group.total_members || group.totalMembers
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Recovers the secret key from a group package and array of share packages
|
|
107
|
-
* @param group The group package containing threshold signing parameters
|
|
108
|
-
* @param shares Array of share packages containing the key shares
|
|
109
|
-
* @returns The recovered secret key as an nsec string
|
|
110
|
-
*/
|
|
111
|
-
function recoverSecretKey(group, shares) {
|
|
112
|
-
if (!group || !shares || shares.length === 0) throw new RecoveryError("Group package and at least one share package are required");
|
|
113
|
-
if (shares.length < group.threshold) throw new RecoveryError(`Not enough shares provided. Need at least ${group.threshold} shares`, {
|
|
114
|
-
providedShares: shares.length,
|
|
115
|
-
requiredThreshold: group.threshold
|
|
116
|
-
});
|
|
117
|
-
try {
|
|
118
|
-
const hexSecret = recover_secret_key(group, shares);
|
|
119
|
-
const secretBytes = Buffer.from(hexSecret, "hex");
|
|
120
|
-
return nip19_exports.nsecEncode(secretBytes);
|
|
121
|
-
} catch (error) {
|
|
122
|
-
throw new RecoveryError(`Failed to recover secret key: ${error.message}`, {
|
|
123
|
-
group,
|
|
124
|
-
shares: shares.length,
|
|
125
|
-
error
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Recovers the secret key from credential strings
|
|
131
|
-
* @param groupCredential The group credential string
|
|
132
|
-
* @param shareCredentials Array of share credential strings
|
|
133
|
-
* @returns The recovered secret key as an nsec string
|
|
134
|
-
*/
|
|
135
|
-
function recoverSecretKeyFromCredentials(groupCredential, shareCredentials) {
|
|
136
|
-
try {
|
|
137
|
-
return recoverSecretKey(decodeGroup(groupCredential), shareCredentials.map(decodeShare));
|
|
138
|
-
} catch (error) {
|
|
139
|
-
if (error instanceof KeysetError || error instanceof RecoveryError) throw error;
|
|
140
|
-
throw new RecoveryError(`Failed to recover secret key from credentials: ${error.message}`, {
|
|
141
|
-
groupCredential,
|
|
142
|
-
shareCredentials,
|
|
143
|
-
error
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Validates that shares belong to the same keyset
|
|
149
|
-
* Note: This validation is simplified since share.group property access needs verification
|
|
150
|
-
*/
|
|
151
|
-
function validateSharesCompatibility(shares) {
|
|
152
|
-
if (shares.length === 0) throw new KeysetError("No shares provided for validation");
|
|
153
|
-
if (shares.some((share) => !share || typeof share.idx !== "number")) throw new KeysetError("Invalid share package structure");
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Validates that share credentials belong to the same keyset
|
|
157
|
-
*/
|
|
158
|
-
function validateShareCredentialsCompatibility(shareCredentials) {
|
|
159
|
-
try {
|
|
160
|
-
validateSharesCompatibility(shareCredentials.map(decodeShare));
|
|
161
|
-
} catch (error) {
|
|
162
|
-
if (error instanceof KeysetError) throw error;
|
|
163
|
-
throw new KeysetError(`Failed to validate share credentials compatibility: ${error.message}`, {
|
|
164
|
-
shareCredentials,
|
|
165
|
-
error
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
//#endregion
|
|
171
|
-
export { getShareDetailsWithGroup as a, validateKeysetParams as c, validateSharesCompatibility as d, getShareDetails as i, validateSecretKey as l, decodeShare as n, recoverSecretKey as o, generateKeysetWithSecret as r, recoverSecretKeyFromCredentials as s, decodeGroup as t, validateShareCredentialsCompatibility as u };
|
|
172
|
-
//# sourceMappingURL=keyset-CKMQXvsb.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"keyset-CKMQXvsb.mjs","names":["nip19"],"sources":["../node_modules/@frostr/igloo-core/dist/keyset.js"],"sourcesContent":["import { generate_dealer_pkg, recover_secret_key } from '@frostr/bifrost/lib';\nimport { PackageEncoder } from '@frostr/bifrost';\nimport { nip19 } from 'nostr-tools';\nimport { KeysetError, RecoveryError, KeysetParamsSchema, SecretKeySchema } from './types.js';\n/**\n * Validates keyset parameters\n */\nexport function validateKeysetParams(params) {\n try {\n KeysetParamsSchema.parse(params);\n }\n catch (error) {\n throw new KeysetError(`Invalid keyset parameters: ${error.message}`, { params, validationError: error });\n }\n}\n/**\n * Validates a secret key\n */\nexport function validateSecretKey(secretKey) {\n try {\n SecretKeySchema.parse(secretKey);\n }\n catch (error) {\n throw new KeysetError(`Invalid secret key: ${error.message}`, { validationError: error });\n }\n}\n/**\n * Generates a keyset with a provided secret key\n * @param threshold Number of shares required to sign\n * @param totalMembers Total number of shares to create\n * @param secretKey Hex-encoded secret key\n * @returns Object containing encoded group and share credentials\n */\nexport function generateKeysetWithSecret(threshold, totalMembers, secretKey) {\n const params = { threshold, totalMembers };\n try {\n validateKeysetParams(params);\n validateSecretKey(secretKey);\n const { group, shares } = generate_dealer_pkg(threshold, totalMembers, [secretKey]);\n // Encode the group and shares as bech32 strings\n const groupCredential = PackageEncoder.group.encode(group);\n const shareCredentials = shares.map((share) => PackageEncoder.share.encode(share));\n return {\n groupCredential,\n shareCredentials\n };\n }\n catch (error) {\n if (error instanceof KeysetError) {\n throw error;\n }\n throw new KeysetError(`Failed to generate keyset: ${error.message}`, { params, error });\n }\n}\n/**\n * Decodes a share credential string into a SharePackage\n */\nexport function decodeShare(shareCredential) {\n try {\n return PackageEncoder.share.decode(shareCredential);\n }\n catch (error) {\n throw new KeysetError(`Failed to decode share: ${error.message}`, { shareCredential, error });\n }\n}\n/**\n * Decodes a group credential string into a GroupPackage\n */\nexport function decodeGroup(groupCredential) {\n try {\n return PackageEncoder.group.decode(groupCredential);\n }\n catch (error) {\n throw new KeysetError(`Failed to decode group: ${error.message}`, { groupCredential, error });\n }\n}\n/**\n * Gets basic details about a share (index only for now)\n * For full details including threshold, use getShareDetailsWithGroup\n */\nexport function getShareDetails(shareCredential) {\n const share = decodeShare(shareCredential);\n return {\n idx: share.idx\n };\n}\n/**\n * Gets complete details about a share including threshold info from group\n */\nexport function getShareDetailsWithGroup(shareCredential, groupCredential) {\n const share = decodeShare(shareCredential);\n const group = decodeGroup(groupCredential);\n // Validate that share and group belong to the same keyset (mock validation)\n if (share.keysetId && group.keysetId &&\n share.keysetId !== group.keysetId) {\n throw new KeysetError('Share and group do not belong to the same keyset', { shareKeysetId: share.keysetId, groupKeysetId: group.keysetId });\n }\n return {\n idx: share.idx,\n threshold: group.threshold,\n // Note: Using totalMembers instead of total_members - need to verify actual property name\n totalMembers: group.total_members || group.totalMembers\n };\n}\n/**\n * Recovers the secret key from a group package and array of share packages\n * @param group The group package containing threshold signing parameters\n * @param shares Array of share packages containing the key shares\n * @returns The recovered secret key as an nsec string\n */\nexport function recoverSecretKey(group, shares) {\n if (!group || !shares || shares.length === 0) {\n throw new RecoveryError('Group package and at least one share package are required');\n }\n if (shares.length < group.threshold) {\n throw new RecoveryError(`Not enough shares provided. Need at least ${group.threshold} shares`, { providedShares: shares.length, requiredThreshold: group.threshold });\n }\n try {\n const hexSecret = recover_secret_key(group, shares);\n const secretBytes = Buffer.from(hexSecret, 'hex');\n return nip19.nsecEncode(secretBytes);\n }\n catch (error) {\n throw new RecoveryError(`Failed to recover secret key: ${error.message}`, { group, shares: shares.length, error });\n }\n}\n/**\n * Recovers the secret key from credential strings\n * @param groupCredential The group credential string\n * @param shareCredentials Array of share credential strings\n * @returns The recovered secret key as an nsec string\n */\nexport function recoverSecretKeyFromCredentials(groupCredential, shareCredentials) {\n try {\n const group = decodeGroup(groupCredential);\n const shares = shareCredentials.map(decodeShare);\n return recoverSecretKey(group, shares);\n }\n catch (error) {\n if (error instanceof KeysetError || error instanceof RecoveryError) {\n throw error;\n }\n throw new RecoveryError(`Failed to recover secret key from credentials: ${error.message}`, { groupCredential, shareCredentials, error });\n }\n}\n/**\n * Validates that shares belong to the same keyset\n * Note: This validation is simplified since share.group property access needs verification\n */\nexport function validateSharesCompatibility(shares) {\n if (shares.length === 0) {\n throw new KeysetError('No shares provided for validation');\n }\n // TODO: Implement proper validation once we confirm SharePackage structure\n // For now, just validate that we have shares\n if (shares.some(share => !share || typeof share.idx !== 'number')) {\n throw new KeysetError('Invalid share package structure');\n }\n}\n/**\n * Validates that share credentials belong to the same keyset\n */\nexport function validateShareCredentialsCompatibility(shareCredentials) {\n try {\n const shares = shareCredentials.map(decodeShare);\n validateSharesCompatibility(shares);\n }\n catch (error) {\n if (error instanceof KeysetError) {\n throw error;\n }\n throw new KeysetError(`Failed to validate share credentials compatibility: ${error.message}`, { shareCredentials, error });\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AS,CAC7D,OAAM,IAAI,YAAY,kCAAkC;;;;;AAMhE,SAAgB,sCAAsC,kBAAkB;AACpE,KAAI;AAEA,8BADe,iBAAiB,IAAI,YAAY,CACb;UAEhC,OAAO;AACV,MAAI,iBAAiB,YACjB,OAAM;AAEV,QAAM,IAAI,YAAY,uDAAuD,MAAM,WAAW;GAAE;GAAkB;GAAO,CAAC"}
|
package/dist/keyset-Cxdgu110.cjs
DELETED
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
const require_dist = require('./dist-BPmSxkxc.cjs');
|
|
2
|
-
const require_types = require('./types-B-TLIS13.cjs');
|
|
3
|
-
|
|
4
|
-
//#region node_modules/@frostr/igloo-core/dist/keyset.js
|
|
5
|
-
/**
|
|
6
|
-
* Validates keyset parameters
|
|
7
|
-
*/
|
|
8
|
-
function validateKeysetParams(params) {
|
|
9
|
-
try {
|
|
10
|
-
require_types.KeysetParamsSchema.parse(params);
|
|
11
|
-
} catch (error) {
|
|
12
|
-
throw new require_types.KeysetError(`Invalid keyset parameters: ${error.message}`, {
|
|
13
|
-
params,
|
|
14
|
-
validationError: error
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Validates a secret key
|
|
20
|
-
*/
|
|
21
|
-
function validateSecretKey(secretKey) {
|
|
22
|
-
try {
|
|
23
|
-
require_types.SecretKeySchema.parse(secretKey);
|
|
24
|
-
} catch (error) {
|
|
25
|
-
throw new require_types.KeysetError(`Invalid secret key: ${error.message}`, { validationError: error });
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Generates a keyset with a provided secret key
|
|
30
|
-
* @param threshold Number of shares required to sign
|
|
31
|
-
* @param totalMembers Total number of shares to create
|
|
32
|
-
* @param secretKey Hex-encoded secret key
|
|
33
|
-
* @returns Object containing encoded group and share credentials
|
|
34
|
-
*/
|
|
35
|
-
function generateKeysetWithSecret(threshold, totalMembers, secretKey) {
|
|
36
|
-
const params = {
|
|
37
|
-
threshold,
|
|
38
|
-
totalMembers
|
|
39
|
-
};
|
|
40
|
-
try {
|
|
41
|
-
validateKeysetParams(params);
|
|
42
|
-
validateSecretKey(secretKey);
|
|
43
|
-
const { group, shares } = require_dist.generate_dealer_pkg(threshold, totalMembers, [secretKey]);
|
|
44
|
-
return {
|
|
45
|
-
groupCredential: require_dist.PackageEncoder$1.group.encode(group),
|
|
46
|
-
shareCredentials: shares.map((share) => require_dist.PackageEncoder$1.share.encode(share))
|
|
47
|
-
};
|
|
48
|
-
} catch (error) {
|
|
49
|
-
if (error instanceof require_types.KeysetError) throw error;
|
|
50
|
-
throw new require_types.KeysetError(`Failed to generate keyset: ${error.message}`, {
|
|
51
|
-
params,
|
|
52
|
-
error
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Decodes a share credential string into a SharePackage
|
|
58
|
-
*/
|
|
59
|
-
function decodeShare(shareCredential) {
|
|
60
|
-
try {
|
|
61
|
-
return require_dist.PackageEncoder$1.share.decode(shareCredential);
|
|
62
|
-
} catch (error) {
|
|
63
|
-
throw new require_types.KeysetError(`Failed to decode share: ${error.message}`, {
|
|
64
|
-
shareCredential,
|
|
65
|
-
error
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Decodes a group credential string into a GroupPackage
|
|
71
|
-
*/
|
|
72
|
-
function decodeGroup(groupCredential) {
|
|
73
|
-
try {
|
|
74
|
-
return require_dist.PackageEncoder$1.group.decode(groupCredential);
|
|
75
|
-
} catch (error) {
|
|
76
|
-
throw new require_types.KeysetError(`Failed to decode group: ${error.message}`, {
|
|
77
|
-
groupCredential,
|
|
78
|
-
error
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Gets basic details about a share (index only for now)
|
|
84
|
-
* For full details including threshold, use getShareDetailsWithGroup
|
|
85
|
-
*/
|
|
86
|
-
function getShareDetails(shareCredential) {
|
|
87
|
-
return { idx: decodeShare(shareCredential).idx };
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Gets complete details about a share including threshold info from group
|
|
91
|
-
*/
|
|
92
|
-
function getShareDetailsWithGroup(shareCredential, groupCredential) {
|
|
93
|
-
const share = decodeShare(shareCredential);
|
|
94
|
-
const group = decodeGroup(groupCredential);
|
|
95
|
-
if (share.keysetId && group.keysetId && share.keysetId !== group.keysetId) throw new require_types.KeysetError("Share and group do not belong to the same keyset", {
|
|
96
|
-
shareKeysetId: share.keysetId,
|
|
97
|
-
groupKeysetId: group.keysetId
|
|
98
|
-
});
|
|
99
|
-
return {
|
|
100
|
-
idx: share.idx,
|
|
101
|
-
threshold: group.threshold,
|
|
102
|
-
totalMembers: group.total_members || group.totalMembers
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Recovers the secret key from a group package and array of share packages
|
|
107
|
-
* @param group The group package containing threshold signing parameters
|
|
108
|
-
* @param shares Array of share packages containing the key shares
|
|
109
|
-
* @returns The recovered secret key as an nsec string
|
|
110
|
-
*/
|
|
111
|
-
function recoverSecretKey(group, shares) {
|
|
112
|
-
if (!group || !shares || shares.length === 0) throw new require_types.RecoveryError("Group package and at least one share package are required");
|
|
113
|
-
if (shares.length < group.threshold) throw new require_types.RecoveryError(`Not enough shares provided. Need at least ${group.threshold} shares`, {
|
|
114
|
-
providedShares: shares.length,
|
|
115
|
-
requiredThreshold: group.threshold
|
|
116
|
-
});
|
|
117
|
-
try {
|
|
118
|
-
const hexSecret = require_dist.recover_secret_key(group, shares);
|
|
119
|
-
const secretBytes = Buffer.from(hexSecret, "hex");
|
|
120
|
-
return require_dist.nip19_exports.nsecEncode(secretBytes);
|
|
121
|
-
} catch (error) {
|
|
122
|
-
throw new require_types.RecoveryError(`Failed to recover secret key: ${error.message}`, {
|
|
123
|
-
group,
|
|
124
|
-
shares: shares.length,
|
|
125
|
-
error
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Recovers the secret key from credential strings
|
|
131
|
-
* @param groupCredential The group credential string
|
|
132
|
-
* @param shareCredentials Array of share credential strings
|
|
133
|
-
* @returns The recovered secret key as an nsec string
|
|
134
|
-
*/
|
|
135
|
-
function recoverSecretKeyFromCredentials(groupCredential, shareCredentials) {
|
|
136
|
-
try {
|
|
137
|
-
return recoverSecretKey(decodeGroup(groupCredential), shareCredentials.map(decodeShare));
|
|
138
|
-
} catch (error) {
|
|
139
|
-
if (error instanceof require_types.KeysetError || error instanceof require_types.RecoveryError) throw error;
|
|
140
|
-
throw new require_types.RecoveryError(`Failed to recover secret key from credentials: ${error.message}`, {
|
|
141
|
-
groupCredential,
|
|
142
|
-
shareCredentials,
|
|
143
|
-
error
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Validates that shares belong to the same keyset
|
|
149
|
-
* Note: This validation is simplified since share.group property access needs verification
|
|
150
|
-
*/
|
|
151
|
-
function validateSharesCompatibility(shares) {
|
|
152
|
-
if (shares.length === 0) throw new require_types.KeysetError("No shares provided for validation");
|
|
153
|
-
if (shares.some((share) => !share || typeof share.idx !== "number")) throw new require_types.KeysetError("Invalid share package structure");
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Validates that share credentials belong to the same keyset
|
|
157
|
-
*/
|
|
158
|
-
function validateShareCredentialsCompatibility(shareCredentials) {
|
|
159
|
-
try {
|
|
160
|
-
validateSharesCompatibility(shareCredentials.map(decodeShare));
|
|
161
|
-
} catch (error) {
|
|
162
|
-
if (error instanceof require_types.KeysetError) throw error;
|
|
163
|
-
throw new require_types.KeysetError(`Failed to validate share credentials compatibility: ${error.message}`, {
|
|
164
|
-
shareCredentials,
|
|
165
|
-
error
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
//#endregion
|
|
171
|
-
Object.defineProperty(exports, 'decodeGroup', {
|
|
172
|
-
enumerable: true,
|
|
173
|
-
get: function () {
|
|
174
|
-
return decodeGroup;
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
Object.defineProperty(exports, 'decodeShare', {
|
|
178
|
-
enumerable: true,
|
|
179
|
-
get: function () {
|
|
180
|
-
return decodeShare;
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
Object.defineProperty(exports, 'generateKeysetWithSecret', {
|
|
184
|
-
enumerable: true,
|
|
185
|
-
get: function () {
|
|
186
|
-
return generateKeysetWithSecret;
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
Object.defineProperty(exports, 'getShareDetails', {
|
|
190
|
-
enumerable: true,
|
|
191
|
-
get: function () {
|
|
192
|
-
return getShareDetails;
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
Object.defineProperty(exports, 'getShareDetailsWithGroup', {
|
|
196
|
-
enumerable: true,
|
|
197
|
-
get: function () {
|
|
198
|
-
return getShareDetailsWithGroup;
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
Object.defineProperty(exports, 'recoverSecretKey', {
|
|
202
|
-
enumerable: true,
|
|
203
|
-
get: function () {
|
|
204
|
-
return recoverSecretKey;
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
Object.defineProperty(exports, 'recoverSecretKeyFromCredentials', {
|
|
208
|
-
enumerable: true,
|
|
209
|
-
get: function () {
|
|
210
|
-
return recoverSecretKeyFromCredentials;
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
Object.defineProperty(exports, 'validateKeysetParams', {
|
|
214
|
-
enumerable: true,
|
|
215
|
-
get: function () {
|
|
216
|
-
return validateKeysetParams;
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
Object.defineProperty(exports, 'validateSecretKey', {
|
|
220
|
-
enumerable: true,
|
|
221
|
-
get: function () {
|
|
222
|
-
return validateSecretKey;
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
Object.defineProperty(exports, 'validateShareCredentialsCompatibility', {
|
|
226
|
-
enumerable: true,
|
|
227
|
-
get: function () {
|
|
228
|
-
return validateShareCredentialsCompatibility;
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
Object.defineProperty(exports, 'validateSharesCompatibility', {
|
|
232
|
-
enumerable: true,
|
|
233
|
-
get: function () {
|
|
234
|
-
return validateSharesCompatibility;
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
//# sourceMappingURL=keyset-Cxdgu110.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"keyset-Cxdgu110.cjs","names":["KeysetError","generate_dealer_pkg","PackageEncoder","RecoveryError","recover_secret_key","nip19"],"sources":["../node_modules/@frostr/igloo-core/dist/keyset.js"],"sourcesContent":["import { generate_dealer_pkg, recover_secret_key } from '@frostr/bifrost/lib';\nimport { PackageEncoder } from '@frostr/bifrost';\nimport { nip19 } from 'nostr-tools';\nimport { KeysetError, RecoveryError, KeysetParamsSchema, SecretKeySchema } from './types.js';\n/**\n * Validates keyset parameters\n */\nexport function validateKeysetParams(params) {\n try {\n KeysetParamsSchema.parse(params);\n }\n catch (error) {\n throw new KeysetError(`Invalid keyset parameters: ${error.message}`, { params, validationError: error });\n }\n}\n/**\n * Validates a secret key\n */\nexport function validateSecretKey(secretKey) {\n try {\n SecretKeySchema.parse(secretKey);\n }\n catch (error) {\n throw new KeysetError(`Invalid secret key: ${error.message}`, { validationError: error });\n }\n}\n/**\n * Generates a keyset with a provided secret key\n * @param threshold Number of shares required to sign\n * @param totalMembers Total number of shares to create\n * @param secretKey Hex-encoded secret key\n * @returns Object containing encoded group and share credentials\n */\nexport function generateKeysetWithSecret(threshold, totalMembers, secretKey) {\n const params = { threshold, totalMembers };\n try {\n validateKeysetParams(params);\n validateSecretKey(secretKey);\n const { group, shares } = generate_dealer_pkg(threshold, totalMembers, [secretKey]);\n // Encode the group and shares as bech32 strings\n const groupCredential = PackageEncoder.group.encode(group);\n const shareCredentials = shares.map((share) => PackageEncoder.share.encode(share));\n return {\n groupCredential,\n shareCredentials\n };\n }\n catch (error) {\n if (error instanceof KeysetError) {\n throw error;\n }\n throw new KeysetError(`Failed to generate keyset: ${error.message}`, { params, error });\n }\n}\n/**\n * Decodes a share credential string into a SharePackage\n */\nexport function decodeShare(shareCredential) {\n try {\n return PackageEncoder.share.decode(shareCredential);\n }\n catch (error) {\n throw new KeysetError(`Failed to decode share: ${error.message}`, { shareCredential, error });\n }\n}\n/**\n * Decodes a group credential string into a GroupPackage\n */\nexport function decodeGroup(groupCredential) {\n try {\n return PackageEncoder.group.decode(groupCredential);\n }\n catch (error) {\n throw new KeysetError(`Failed to decode group: ${error.message}`, { groupCredential, error });\n }\n}\n/**\n * Gets basic details about a share (index only for now)\n * For full details including threshold, use getShareDetailsWithGroup\n */\nexport function getShareDetails(shareCredential) {\n const share = decodeShare(shareCredential);\n return {\n idx: share.idx\n };\n}\n/**\n * Gets complete details about a share including threshold info from group\n */\nexport function getShareDetailsWithGroup(shareCredential, groupCredential) {\n const share = decodeShare(shareCredential);\n const group = decodeGroup(groupCredential);\n // Validate that share and group belong to the same keyset (mock validation)\n if (share.keysetId && group.keysetId &&\n share.keysetId !== group.keysetId) {\n throw new KeysetError('Share and group do not belong to the same keyset', { shareKeysetId: share.keysetId, groupKeysetId: group.keysetId });\n }\n return {\n idx: share.idx,\n threshold: group.threshold,\n // Note: Using totalMembers instead of total_members - need to verify actual property name\n totalMembers: group.total_members || group.totalMembers\n };\n}\n/**\n * Recovers the secret key from a group package and array of share packages\n * @param group The group package containing threshold signing parameters\n * @param shares Array of share packages containing the key shares\n * @returns The recovered secret key as an nsec string\n */\nexport function recoverSecretKey(group, shares) {\n if (!group || !shares || shares.length === 0) {\n throw new RecoveryError('Group package and at least one share package are required');\n }\n if (shares.length < group.threshold) {\n throw new RecoveryError(`Not enough shares provided. Need at least ${group.threshold} shares`, { providedShares: shares.length, requiredThreshold: group.threshold });\n }\n try {\n const hexSecret = recover_secret_key(group, shares);\n const secretBytes = Buffer.from(hexSecret, 'hex');\n return nip19.nsecEncode(secretBytes);\n }\n catch (error) {\n throw new RecoveryError(`Failed to recover secret key: ${error.message}`, { group, shares: shares.length, error });\n }\n}\n/**\n * Recovers the secret key from credential strings\n * @param groupCredential The group credential string\n * @param shareCredentials Array of share credential strings\n * @returns The recovered secret key as an nsec string\n */\nexport function recoverSecretKeyFromCredentials(groupCredential, shareCredentials) {\n try {\n const group = decodeGroup(groupCredential);\n const shares = shareCredentials.map(decodeShare);\n return recoverSecretKey(group, shares);\n }\n catch (error) {\n if (error instanceof KeysetError || error instanceof RecoveryError) {\n throw error;\n }\n throw new RecoveryError(`Failed to recover secret key from credentials: ${error.message}`, { groupCredential, shareCredentials, error });\n }\n}\n/**\n * Validates that shares belong to the same keyset\n * Note: This validation is simplified since share.group property access needs verification\n */\nexport function validateSharesCompatibility(shares) {\n if (shares.length === 0) {\n throw new KeysetError('No shares provided for validation');\n }\n // TODO: Implement proper validation once we confirm SharePackage structure\n // For now, just validate that we have shares\n if (shares.some(share => !share || typeof share.idx !== 'number')) {\n throw new KeysetError('Invalid share package structure');\n }\n}\n/**\n * Validates that share credentials belong to the same keyset\n */\nexport function validateShareCredentialsCompatibility(shareCredentials) {\n try {\n const shares = shareCredentials.map(decodeShare);\n validateSharesCompatibility(shares);\n }\n catch (error) {\n if (error instanceof KeysetError) {\n throw error;\n }\n throw new KeysetError(`Failed to validate share credentials compatibility: ${error.message}`, { shareCredentials, error });\n }\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;AAOA,SAAgB,qBAAqB,QAAQ;AACzC,KAAI;AACA,mCAAmB,MAAM,OAAO;UAE7B,OAAO;AACV,QAAM,IAAIA,0BAAY,8BAA8B,MAAM,WAAW;GAAE;GAAQ,iBAAiB;GAAO,CAAC;;;;;;AAMhH,SAAgB,kBAAkB,WAAW;AACzC,KAAI;AACA,gCAAgB,MA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W;GAAE;GAAkB;GAAO,CAAC"}
|
package/dist/keyset-DLxpGhdu.cjs
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
require('./types-B-TLIS13.cjs');
|
|
2
|
-
const require_keyset = require('./keyset-Cxdgu110.cjs');
|
|
3
|
-
|
|
4
|
-
exports.generateKeysetWithSecret = require_keyset.generateKeysetWithSecret;
|
|
5
|
-
exports.getShareDetails = require_keyset.getShareDetails;
|
|
6
|
-
exports.recoverSecretKeyFromCredentials = require_keyset.recoverSecretKeyFromCredentials;
|
package/dist/keyset-IKjlhvqF.mjs
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import "./types-CTm_FHYD.mjs";
|
|
2
|
-
import { a as getShareDetailsWithGroup, c as validateKeysetParams, d as validateSharesCompatibility, i as getShareDetails, l as validateSecretKey, n as decodeShare, o as recoverSecretKey, r as generateKeysetWithSecret, s as recoverSecretKeyFromCredentials, t as decodeGroup, u as validateShareCredentialsCompatibility } from "./keyset-CKMQXvsb.mjs";
|
|
3
|
-
|
|
4
|
-
export { generateKeysetWithSecret, getShareDetails, recoverSecretKeyFromCredentials };
|
package/dist/node-3EUJ4ga9.cjs
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
require('./types-B-TLIS13.cjs');
|
|
2
|
-
require('./nostr-Hv2tsnuI.cjs');
|
|
3
|
-
require('./policy-8HcjulLD.cjs');
|
|
4
|
-
const require_node = require('./node-C2UpE11T.cjs');
|
|
5
|
-
|
|
6
|
-
exports.cleanupBifrostNode = require_node.cleanupBifrostNode;
|
|
7
|
-
exports.createAndConnectNode = require_node.createAndConnectNode;
|
|
8
|
-
exports.createConnectedNode = require_node.createConnectedNode;
|
|
9
|
-
exports.isNodeReady = require_node.isNodeReady;
|