@sundaeswap/sprinkles 0.3.0 → 0.5.0
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/Sprinkle/__tests__/encryption.test.js +20 -8
- package/dist/cjs/Sprinkle/__tests__/encryption.test.js.map +1 -1
- package/dist/cjs/Sprinkle/__tests__/enhancements.test.js +41 -16
- package/dist/cjs/Sprinkle/__tests__/enhancements.test.js.map +1 -1
- package/dist/cjs/Sprinkle/__tests__/fill-in-struct.test.js +85 -38
- package/dist/cjs/Sprinkle/__tests__/fill-in-struct.test.js.map +1 -1
- package/dist/cjs/Sprinkle/__tests__/settings-persistence.test.js +120 -0
- package/dist/cjs/Sprinkle/__tests__/settings-persistence.test.js.map +1 -1
- package/dist/cjs/Sprinkle/__tests__/show-menu.test.js +93 -7
- package/dist/cjs/Sprinkle/__tests__/show-menu.test.js.map +1 -1
- package/dist/cjs/Sprinkle/__tests__/tx-dialog.test.js +21 -0
- package/dist/cjs/Sprinkle/__tests__/tx-dialog.test.js.map +1 -1
- package/dist/cjs/Sprinkle/encryption.js +131 -0
- package/dist/cjs/Sprinkle/encryption.js.map +1 -0
- package/dist/cjs/Sprinkle/index.js +318 -352
- package/dist/cjs/Sprinkle/index.js.map +1 -1
- package/dist/cjs/Sprinkle/prompts.js +393 -0
- package/dist/cjs/Sprinkle/prompts.js.map +1 -0
- package/dist/cjs/Sprinkle/schemas.js +97 -0
- package/dist/cjs/Sprinkle/schemas.js.map +1 -0
- package/dist/cjs/Sprinkle/tx-dialog.js +101 -0
- package/dist/cjs/Sprinkle/tx-dialog.js.map +1 -0
- package/dist/cjs/Sprinkle/type-guards.js +42 -0
- package/dist/cjs/Sprinkle/type-guards.js.map +1 -0
- package/dist/cjs/Sprinkle/types.js +49 -0
- package/dist/cjs/Sprinkle/types.js.map +1 -0
- package/dist/cjs/Sprinkle/wallet.js +98 -0
- package/dist/cjs/Sprinkle/wallet.js.map +1 -0
- package/dist/esm/Sprinkle/__tests__/encryption.test.js +20 -8
- package/dist/esm/Sprinkle/__tests__/encryption.test.js.map +1 -1
- package/dist/esm/Sprinkle/__tests__/enhancements.test.js +41 -16
- package/dist/esm/Sprinkle/__tests__/enhancements.test.js.map +1 -1
- package/dist/esm/Sprinkle/__tests__/fill-in-struct.test.js +85 -38
- package/dist/esm/Sprinkle/__tests__/fill-in-struct.test.js.map +1 -1
- package/dist/esm/Sprinkle/__tests__/settings-persistence.test.js +120 -0
- package/dist/esm/Sprinkle/__tests__/settings-persistence.test.js.map +1 -1
- package/dist/esm/Sprinkle/__tests__/show-menu.test.js +94 -8
- package/dist/esm/Sprinkle/__tests__/show-menu.test.js.map +1 -1
- package/dist/esm/Sprinkle/__tests__/tx-dialog.test.js +21 -0
- package/dist/esm/Sprinkle/__tests__/tx-dialog.test.js.map +1 -1
- package/dist/esm/Sprinkle/encryption.js +117 -0
- package/dist/esm/Sprinkle/encryption.js.map +1 -0
- package/dist/esm/Sprinkle/index.js +172 -337
- package/dist/esm/Sprinkle/index.js.map +1 -1
- package/dist/esm/Sprinkle/prompts.js +385 -0
- package/dist/esm/Sprinkle/prompts.js.map +1 -0
- package/dist/esm/Sprinkle/schemas.js +91 -0
- package/dist/esm/Sprinkle/schemas.js.map +1 -0
- package/dist/esm/Sprinkle/tx-dialog.js +90 -0
- package/dist/esm/Sprinkle/tx-dialog.js.map +1 -0
- package/dist/esm/Sprinkle/type-guards.js +24 -0
- package/dist/esm/Sprinkle/type-guards.js.map +1 -0
- package/dist/esm/Sprinkle/types.js +42 -0
- package/dist/esm/Sprinkle/types.js.map +1 -0
- package/dist/esm/Sprinkle/wallet.js +90 -0
- package/dist/esm/Sprinkle/wallet.js.map +1 -0
- package/dist/types/Sprinkle/encryption.d.ts +43 -0
- package/dist/types/Sprinkle/encryption.d.ts.map +1 -0
- package/dist/types/Sprinkle/index.d.ts +13 -174
- package/dist/types/Sprinkle/index.d.ts.map +1 -1
- package/dist/types/Sprinkle/prompts.d.ts +94 -0
- package/dist/types/Sprinkle/prompts.d.ts.map +1 -0
- package/dist/types/Sprinkle/schemas.d.ts +125 -0
- package/dist/types/Sprinkle/schemas.d.ts.map +1 -0
- package/dist/types/Sprinkle/tx-dialog.d.ts +37 -0
- package/dist/types/Sprinkle/tx-dialog.d.ts.map +1 -0
- package/dist/types/Sprinkle/type-guards.d.ts +22 -0
- package/dist/types/Sprinkle/type-guards.d.ts.map +1 -0
- package/dist/types/Sprinkle/types.d.ts +62 -0
- package/dist/types/Sprinkle/types.d.ts.map +1 -0
- package/dist/types/Sprinkle/wallet.d.ts +27 -0
- package/dist/types/Sprinkle/wallet.d.ts.map +1 -0
- package/dist/types/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/Sprinkle/__tests__/encryption.test.ts +21 -8
- package/src/Sprinkle/__tests__/enhancements.test.ts +41 -15
- package/src/Sprinkle/__tests__/fill-in-struct.test.ts +104 -38
- package/src/Sprinkle/__tests__/settings-persistence.test.ts +108 -0
- package/src/Sprinkle/__tests__/show-menu.test.ts +96 -8
- package/src/Sprinkle/__tests__/tx-dialog.test.ts +21 -0
- package/src/Sprinkle/encryption.ts +130 -0
- package/src/Sprinkle/index.ts +265 -478
- package/src/Sprinkle/prompts.ts +481 -0
- package/src/Sprinkle/schemas.ts +111 -0
- package/src/Sprinkle/tx-dialog.ts +100 -0
- package/src/Sprinkle/type-guards.ts +51 -0
- package/src/Sprinkle/types.ts +73 -0
- package/src/Sprinkle/wallet.ts +133 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type guard utilities for TypeBox schema types.
|
|
3
|
+
* These are internal helpers used by FillInStruct, encryption, and other modules.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { Kind, OptionalKind } from "@sinclair/typebox";
|
|
7
|
+
export const isOptional = t => t[OptionalKind] === "Optional";
|
|
8
|
+
export const isImport = t => t[Kind] === "Import";
|
|
9
|
+
export const isArray = t => t[Kind] === "Array";
|
|
10
|
+
export const isBigInt = t => t[Kind] === "BigInt";
|
|
11
|
+
export const isLiteral = t => t[Kind] === "Literal";
|
|
12
|
+
export const isObject = t => t[Kind] === "Object";
|
|
13
|
+
export const isRef = t => t[Kind] === "Ref";
|
|
14
|
+
export const isString = t => t[Kind] === "String";
|
|
15
|
+
export const isThis = t => t[Kind] === "This";
|
|
16
|
+
export const isTuple = t => t[Kind] === "Tuple";
|
|
17
|
+
export const isUnion = t => t[Kind] === "Union";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Check if a schema field is marked as sensitive.
|
|
21
|
+
* Sensitive fields are encrypted when saved and masked when displayed.
|
|
22
|
+
*/
|
|
23
|
+
export const isSensitive = t => isString(t) && t.sensitive === true;
|
|
24
|
+
//# sourceMappingURL=type-guards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-guards.js","names":["Kind","OptionalKind","isOptional","t","isImport","isArray","isBigInt","isLiteral","isObject","isRef","isString","isThis","isTuple","isUnion","isSensitive","sensitive"],"sources":["../../../src/Sprinkle/type-guards.ts"],"sourcesContent":["/**\n * Type guard utilities for TypeBox schema types.\n * These are internal helpers used by FillInStruct, encryption, and other modules.\n */\n\nimport {\n Kind,\n type TBigInt,\n type TLiteral,\n type TObject,\n type TSchema,\n type TString,\n type TTuple,\n type TUnion,\n type TArray,\n type TThis,\n type TRef,\n type TImport,\n type TOptional,\n OptionalKind,\n} from \"@sinclair/typebox\";\n\nexport const isOptional = <T extends TSchema>(t: T): t is TOptional<T> =>\n t[OptionalKind] === \"Optional\";\n\nexport const isImport = (t: TSchema): t is TImport => t[Kind] === \"Import\";\n\nexport const isArray = (t: TSchema): t is TArray => t[Kind] === \"Array\";\n\nexport const isBigInt = (t: TSchema): t is TBigInt => t[Kind] === \"BigInt\";\n\nexport const isLiteral = (t: TSchema): t is TLiteral => t[Kind] === \"Literal\";\n\nexport const isObject = (t: TSchema): t is TObject => t[Kind] === \"Object\";\n\nexport const isRef = (t: TSchema): t is TRef => t[Kind] === \"Ref\";\n\nexport const isString = (t: TSchema): t is TString => t[Kind] === \"String\";\n\nexport const isThis = (t: TSchema): t is TThis => t[Kind] === \"This\";\n\nexport const isTuple = (t: TSchema): t is TTuple => t[Kind] === \"Tuple\";\n\nexport const isUnion = (t: TSchema): t is TUnion => t[Kind] === \"Union\";\n\n/**\n * Check if a schema field is marked as sensitive.\n * Sensitive fields are encrypted when saved and masked when displayed.\n */\nexport const isSensitive = (t: TSchema): boolean =>\n isString(t) && t.sensitive === true;\n"],"mappings":"AAAA;AACA;AACA;AACA;;AAEA,SACEA,IAAI,EAaJC,YAAY,QACP,mBAAmB;AAE1B,OAAO,MAAMC,UAAU,GAAuBC,CAAI,IAChDA,CAAC,CAACF,YAAY,CAAC,KAAK,UAAU;AAEhC,OAAO,MAAMG,QAAQ,GAAID,CAAU,IAAmBA,CAAC,CAACH,IAAI,CAAC,KAAK,QAAQ;AAE1E,OAAO,MAAMK,OAAO,GAAIF,CAAU,IAAkBA,CAAC,CAACH,IAAI,CAAC,KAAK,OAAO;AAEvE,OAAO,MAAMM,QAAQ,GAAIH,CAAU,IAAmBA,CAAC,CAACH,IAAI,CAAC,KAAK,QAAQ;AAE1E,OAAO,MAAMO,SAAS,GAAIJ,CAAU,IAAoBA,CAAC,CAACH,IAAI,CAAC,KAAK,SAAS;AAE7E,OAAO,MAAMQ,QAAQ,GAAIL,CAAU,IAAmBA,CAAC,CAACH,IAAI,CAAC,KAAK,QAAQ;AAE1E,OAAO,MAAMS,KAAK,GAAIN,CAAU,IAAgBA,CAAC,CAACH,IAAI,CAAC,KAAK,KAAK;AAEjE,OAAO,MAAMU,QAAQ,GAAIP,CAAU,IAAmBA,CAAC,CAACH,IAAI,CAAC,KAAK,QAAQ;AAE1E,OAAO,MAAMW,MAAM,GAAIR,CAAU,IAAiBA,CAAC,CAACH,IAAI,CAAC,KAAK,MAAM;AAEpE,OAAO,MAAMY,OAAO,GAAIT,CAAU,IAAkBA,CAAC,CAACH,IAAI,CAAC,KAAK,OAAO;AAEvE,OAAO,MAAMa,OAAO,GAAIV,CAAU,IAAkBA,CAAC,CAACH,IAAI,CAAC,KAAK,OAAO;;AAEvE;AACA;AACA;AACA;AACA,OAAO,MAAMc,WAAW,GAAIX,CAAU,IACpCO,QAAQ,CAACP,CAAC,CAAC,IAAIA,CAAC,CAACY,SAAS,KAAK,IAAI","ignoreList":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility type to extract the static type from a TypeBox schema.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Options for encrypting/decrypting sensitive fields in settings.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Options for configuring a Sprinkle instance.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Metadata for a profile.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Current profile information including ID.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Profile entry as returned by scanProfiles().
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Result of the TxDialog interaction.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Options for TxDialog.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Error thrown when user cancels a prompt via Escape key.
|
|
35
|
+
*/
|
|
36
|
+
export class UserCancelledError extends Error {
|
|
37
|
+
constructor(message = "User cancelled the operation") {
|
|
38
|
+
super(message);
|
|
39
|
+
this.name = "UserCancelledError";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":["UserCancelledError","Error","constructor","message","name"],"sources":["../../../src/Sprinkle/types.ts"],"sourcesContent":["import { Core } from \"@blaze-cardano/sdk\";\nimport type { Static, TSchema } from \"@sinclair/typebox\";\n\n/**\n * Utility type to extract the static type from a TypeBox schema.\n */\nexport type TExact<T> = T extends TSchema ? Static<T> : T;\n\n/**\n * Options for encrypting/decrypting sensitive fields in settings.\n */\nexport interface IEncryptionOptions {\n encrypt: (plaintext: string) => string;\n decrypt: (ciphertext: string) => Promise<string>;\n}\n\n/**\n * Options for configuring a Sprinkle instance.\n */\nexport interface ISprinkleOptions {\n encryption?: IEncryptionOptions;\n}\n\n/**\n * Metadata for a profile.\n */\nexport interface IProfileMeta {\n name: string;\n description?: string;\n createdAt: string;\n updatedAt: string;\n}\n\n/**\n * Current profile information including ID.\n */\nexport interface ICurrentProfile extends IProfileMeta {\n id: string;\n}\n\n/**\n * Profile entry as returned by scanProfiles().\n */\nexport interface IProfileEntry {\n id: string;\n meta: IProfileMeta;\n}\n\n/**\n * Result of the TxDialog interaction.\n */\nexport interface TxDialogResult {\n action: \"submitted\" | \"signed\" | \"cancelled\";\n txId?: string; // present only if action === 'submitted'\n tx: Core.Transaction; // the (potentially signed) transaction\n}\n\n/**\n * Options for TxDialog.\n */\nexport interface TxDialogOptions {\n beforeSign?: () => Promise<void>;\n}\n\n/**\n * Error thrown when user cancels a prompt via Escape key.\n */\nexport class UserCancelledError extends Error {\n constructor(message: string = \"User cancelled the operation\") {\n super(message);\n this.name = \"UserCancelledError\";\n }\n}\n"],"mappings":"AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;;AAKA;AACA;AACA;;AAQA;AACA;AACA;;AAKA;AACA;AACA;;AAMA;AACA;AACA;;AAOA;AACA;AACA;;AAKA;AACA;AACA;AACA,OAAO,MAAMA,kBAAkB,SAASC,KAAK,CAAC;EAC5CC,WAAWA,CAACC,OAAe,GAAG,8BAA8B,EAAE;IAC5D,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,oBAAoB;EAClC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wallet and provider setup utilities.
|
|
3
|
+
* Functions for creating providers, wallets, and Blaze instances.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { Blockfrost } from "@blaze-cardano/query";
|
|
7
|
+
import { Blaze, ColdWallet, Core, HotWallet } from "@blaze-cardano/sdk";
|
|
8
|
+
import { wordlist } from "@blaze-cardano/core";
|
|
9
|
+
import { confirmCancellable } from "./prompts.js";
|
|
10
|
+
import { UserCancelledError } from "./types.js";
|
|
11
|
+
/**
|
|
12
|
+
* Creates a blockchain data provider based on settings.
|
|
13
|
+
*/
|
|
14
|
+
export async function GetProvider(network, settings) {
|
|
15
|
+
switch (settings.type) {
|
|
16
|
+
case "blockfrost":
|
|
17
|
+
return new Blockfrost({
|
|
18
|
+
network: `cardano-${network}`,
|
|
19
|
+
projectId: settings.projectId
|
|
20
|
+
});
|
|
21
|
+
case "maestro":
|
|
22
|
+
// Dynamic import - Maestro may or may not be exported depending on @blaze-cardano/query version
|
|
23
|
+
const queryModule = await import("@blaze-cardano/query");
|
|
24
|
+
if (!queryModule.Maestro) {
|
|
25
|
+
throw new Error("Maestro is not available in the installed version of @blaze-cardano/query. Please install a version that includes Maestro support.");
|
|
26
|
+
}
|
|
27
|
+
return new queryModule.Maestro({
|
|
28
|
+
network: network,
|
|
29
|
+
apiKey: settings.apiKey
|
|
30
|
+
});
|
|
31
|
+
default:
|
|
32
|
+
throw new Error("Invalid provider type");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Creates a wallet instance based on settings.
|
|
38
|
+
*/
|
|
39
|
+
export async function GetWallet(settings, provider) {
|
|
40
|
+
switch (settings.type) {
|
|
41
|
+
case "hot":
|
|
42
|
+
return HotWallet.fromMasterkey(Core.Bip32PrivateKeyHex(settings.privateKey), provider, provider.network);
|
|
43
|
+
case "cold":
|
|
44
|
+
return new ColdWallet(Core.Address.fromBech32(settings.address), provider.network, provider);
|
|
45
|
+
default:
|
|
46
|
+
throw new Error("Invalid wallet type");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Creates a Blaze instance with provider and wallet.
|
|
52
|
+
*/
|
|
53
|
+
export async function GetBlaze(network, providerSettings, walletSettings) {
|
|
54
|
+
const provider = await GetProvider(network, providerSettings);
|
|
55
|
+
const wallet = await GetWallet(walletSettings, provider);
|
|
56
|
+
return Blaze.from(provider, wallet);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Generates a new wallet from a BIP39 mnemonic phrase.
|
|
61
|
+
* Displays the 24-word recovery phrase and requires user confirmation.
|
|
62
|
+
* @returns The Bip32PrivateKey hex string for storage
|
|
63
|
+
*/
|
|
64
|
+
export async function generateWalletFromMnemonic() {
|
|
65
|
+
const mnemonic = Core.generateMnemonic(wordlist, 256); // 24 words
|
|
66
|
+
const words = mnemonic.split(" ");
|
|
67
|
+
console.log("\n=== NEW WALLET GENERATED ===\n");
|
|
68
|
+
console.log("IMPORTANT: Save these 24 words in a secure location.");
|
|
69
|
+
console.log("This is the ONLY way to recover your wallet.\n");
|
|
70
|
+
|
|
71
|
+
// Display in 4 columns
|
|
72
|
+
for (let i = 0; i < 6; i++) {
|
|
73
|
+
console.log(`${(i + 1).toString().padStart(2)}. ${words[i].padEnd(12)} ` + `${(i + 7).toString().padStart(2)}. ${words[i + 6].padEnd(12)} ` + `${(i + 13).toString().padStart(2)}. ${words[i + 12].padEnd(12)} ` + `${(i + 19).toString().padStart(2)}. ${words[i + 18]}`);
|
|
74
|
+
}
|
|
75
|
+
console.log("");
|
|
76
|
+
const confirmed = await confirmCancellable({
|
|
77
|
+
message: "Have you saved your recovery phrase?",
|
|
78
|
+
default: false
|
|
79
|
+
});
|
|
80
|
+
if (confirmed === null) {
|
|
81
|
+
throw new UserCancelledError("Wallet generation cancelled");
|
|
82
|
+
}
|
|
83
|
+
if (!confirmed) {
|
|
84
|
+
throw new Error("Wallet generation cancelled - recovery phrase not saved");
|
|
85
|
+
}
|
|
86
|
+
const entropy = Core.mnemonicToEntropy(mnemonic, wordlist);
|
|
87
|
+
const masterKey = Core.Bip32PrivateKey.fromBip39Entropy(Buffer.from(entropy), "");
|
|
88
|
+
return masterKey.hex();
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=wallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet.js","names":["Blockfrost","Blaze","ColdWallet","Core","HotWallet","wordlist","confirmCancellable","UserCancelledError","GetProvider","network","settings","type","projectId","queryModule","Maestro","Error","apiKey","GetWallet","provider","fromMasterkey","Bip32PrivateKeyHex","privateKey","Address","fromBech32","address","GetBlaze","providerSettings","walletSettings","wallet","from","generateWalletFromMnemonic","mnemonic","generateMnemonic","words","split","console","log","i","toString","padStart","padEnd","confirmed","message","default","entropy","mnemonicToEntropy","masterKey","Bip32PrivateKey","fromBip39Entropy","Buffer","hex"],"sources":["../../../src/Sprinkle/wallet.ts"],"sourcesContent":["/**\n * Wallet and provider setup utilities.\n * Functions for creating providers, wallets, and Blaze instances.\n */\n\nimport { Blockfrost, type Provider } from \"@blaze-cardano/query\";\nimport {\n Blaze,\n ColdWallet,\n Core,\n HotWallet,\n type Wallet,\n} from \"@blaze-cardano/sdk\";\nimport { wordlist } from \"@blaze-cardano/core\";\nimport { confirmCancellable } from \"./prompts.js\";\nimport { UserCancelledError, type TExact } from \"./types.js\";\nimport {\n NetworkSchema,\n ProviderSettingsSchema,\n WalletSettingsSchema,\n} from \"./schemas.js\";\n\n/**\n * Creates a blockchain data provider based on settings.\n */\nexport async function GetProvider(\n network: TExact<typeof NetworkSchema>,\n settings: TExact<typeof ProviderSettingsSchema>,\n): Promise<Provider> {\n switch (settings.type) {\n case \"blockfrost\":\n return new Blockfrost({\n network: `cardano-${network}`,\n projectId: settings.projectId,\n });\n case \"maestro\":\n // Dynamic import - Maestro may or may not be exported depending on @blaze-cardano/query version\n const queryModule = (await import(\"@blaze-cardano/query\")) as any;\n if (!queryModule.Maestro) {\n throw new Error(\n \"Maestro is not available in the installed version of @blaze-cardano/query. Please install a version that includes Maestro support.\",\n );\n }\n return new queryModule.Maestro({\n network: network as \"mainnet\" | \"preview\" | \"preprod\",\n apiKey: settings.apiKey,\n });\n default:\n throw new Error(\"Invalid provider type\");\n }\n}\n\n/**\n * Creates a wallet instance based on settings.\n */\nexport async function GetWallet(\n settings: TExact<typeof WalletSettingsSchema>,\n provider: Provider,\n): Promise<Wallet> {\n switch (settings.type) {\n case \"hot\":\n return HotWallet.fromMasterkey(\n Core.Bip32PrivateKeyHex(settings.privateKey),\n provider,\n provider.network,\n );\n case \"cold\":\n return new ColdWallet(\n Core.Address.fromBech32(settings.address),\n provider.network,\n provider,\n );\n default:\n throw new Error(\"Invalid wallet type\");\n }\n}\n\n/**\n * Creates a Blaze instance with provider and wallet.\n */\nexport async function GetBlaze(\n network: TExact<typeof NetworkSchema>,\n providerSettings: TExact<typeof ProviderSettingsSchema>,\n walletSettings: TExact<typeof WalletSettingsSchema>,\n): Promise<Blaze<Provider, Wallet>> {\n const provider = await GetProvider(network, providerSettings);\n const wallet = await GetWallet(walletSettings, provider);\n return Blaze.from(provider, wallet);\n}\n\n/**\n * Generates a new wallet from a BIP39 mnemonic phrase.\n * Displays the 24-word recovery phrase and requires user confirmation.\n * @returns The Bip32PrivateKey hex string for storage\n */\nexport async function generateWalletFromMnemonic(): Promise<string> {\n const mnemonic = Core.generateMnemonic(wordlist, 256); // 24 words\n const words = mnemonic.split(\" \");\n\n console.log(\"\\n=== NEW WALLET GENERATED ===\\n\");\n console.log(\"IMPORTANT: Save these 24 words in a secure location.\");\n console.log(\"This is the ONLY way to recover your wallet.\\n\");\n\n // Display in 4 columns\n for (let i = 0; i < 6; i++) {\n console.log(\n `${(i + 1).toString().padStart(2)}. ${words[i]!.padEnd(12)} ` +\n `${(i + 7).toString().padStart(2)}. ${words[i + 6]!.padEnd(12)} ` +\n `${(i + 13).toString().padStart(2)}. ${words[i + 12]!.padEnd(12)} ` +\n `${(i + 19).toString().padStart(2)}. ${words[i + 18]}`,\n );\n }\n console.log(\"\");\n\n const confirmed = await confirmCancellable({\n message: \"Have you saved your recovery phrase?\",\n default: false,\n });\n\n if (confirmed === null) {\n throw new UserCancelledError(\"Wallet generation cancelled\");\n }\n if (!confirmed) {\n throw new Error(\"Wallet generation cancelled - recovery phrase not saved\");\n }\n\n const entropy = Core.mnemonicToEntropy(mnemonic, wordlist);\n const masterKey = Core.Bip32PrivateKey.fromBip39Entropy(\n Buffer.from(entropy),\n \"\",\n );\n return masterKey.hex();\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;;AAEA,SAASA,UAAU,QAAuB,sBAAsB;AAChE,SACEC,KAAK,EACLC,UAAU,EACVC,IAAI,EACJC,SAAS,QAEJ,oBAAoB;AAC3B,SAASC,QAAQ,QAAQ,qBAAqB;AAC9C,SAASC,kBAAkB,QAAQ,cAAc;AACjD,SAASC,kBAAkB,QAAqB,YAAY;AAO5D;AACA;AACA;AACA,OAAO,eAAeC,WAAWA,CAC/BC,OAAqC,EACrCC,QAA+C,EAC5B;EACnB,QAAQA,QAAQ,CAACC,IAAI;IACnB,KAAK,YAAY;MACf,OAAO,IAAIX,UAAU,CAAC;QACpBS,OAAO,EAAE,WAAWA,OAAO,EAAE;QAC7BG,SAAS,EAAEF,QAAQ,CAACE;MACtB,CAAC,CAAC;IACJ,KAAK,SAAS;MACZ;MACA,MAAMC,WAAW,GAAI,MAAM,MAAM,CAAC,sBAAsB,CAAS;MACjE,IAAI,CAACA,WAAW,CAACC,OAAO,EAAE;QACxB,MAAM,IAAIC,KAAK,CACb,oIACF,CAAC;MACH;MACA,OAAO,IAAIF,WAAW,CAACC,OAAO,CAAC;QAC7BL,OAAO,EAAEA,OAA4C;QACrDO,MAAM,EAAEN,QAAQ,CAACM;MACnB,CAAC,CAAC;IACJ;M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AAC4C,eAAe,CAACC,gBAAgB,CACrDC,MAAM,CAACpB,IAAI,CAACe,OAAO,CAAC,EACpB,EACF,CAAC;EACD,OAAOE,SAAS,CAACI,GAAG,CAAC,CAAC;AACxB","ignoreList":[]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encryption utilities for sensitive field handling.
|
|
3
|
+
* Functions for encrypting, decrypting, and masking sensitive data in settings.
|
|
4
|
+
*/
|
|
5
|
+
import type { TSchema } from "@sinclair/typebox";
|
|
6
|
+
import type { IEncryptionOptions } from "./types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Recursively collect paths to all sensitive fields in a schema.
|
|
9
|
+
*/
|
|
10
|
+
export declare function collectSensitivePaths(type: TSchema, prefix?: string): string[];
|
|
11
|
+
/**
|
|
12
|
+
* Get a nested value from an object by dot-separated path.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getNestedValue(obj: any, path: string): unknown;
|
|
15
|
+
/**
|
|
16
|
+
* Set a nested value in an object by dot-separated path.
|
|
17
|
+
*/
|
|
18
|
+
export declare function setNestedValue(obj: any, path: string, value: unknown): void;
|
|
19
|
+
/**
|
|
20
|
+
* JSON replacer that converts BigInt to string with 'n' suffix.
|
|
21
|
+
*/
|
|
22
|
+
export declare function bigIntReplacer(_key: string, value: unknown): unknown;
|
|
23
|
+
/**
|
|
24
|
+
* JSON reviver that converts strings with 'n' suffix back to BigInt.
|
|
25
|
+
*/
|
|
26
|
+
export declare function bigIntReviver(_key: string, value: unknown): unknown;
|
|
27
|
+
/**
|
|
28
|
+
* Deep clone an object, preserving BigInt values.
|
|
29
|
+
*/
|
|
30
|
+
export declare function cloneWithBigInt<T>(obj: T): T;
|
|
31
|
+
/**
|
|
32
|
+
* Encrypt all sensitive fields in a settings object.
|
|
33
|
+
*/
|
|
34
|
+
export declare function encryptSensitiveFields<T>(settings: T, type: TSchema, encryption: IEncryptionOptions): T;
|
|
35
|
+
/**
|
|
36
|
+
* Decrypt all sensitive fields in a settings object.
|
|
37
|
+
*/
|
|
38
|
+
export declare function decryptSensitiveFields<T>(settings: T, type: TSchema, encryption: IEncryptionOptions): Promise<T>;
|
|
39
|
+
/**
|
|
40
|
+
* Mask all sensitive fields in a settings object for display.
|
|
41
|
+
*/
|
|
42
|
+
export declare function maskSensitiveFields<T>(settings: T, type: TSchema): T;
|
|
43
|
+
//# sourceMappingURL=encryption.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encryption.d.ts","sourceRoot":"","sources":["../../../src/Sprinkle/encryption.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,OAAO,EACb,MAAM,GAAE,MAAW,GAClB,MAAM,EAAE,CAkBV;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAE9D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAO3E;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAEpE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAKnE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAE5C;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EACtC,QAAQ,EAAE,CAAC,EACX,IAAI,EAAE,OAAO,EACb,UAAU,EAAE,kBAAkB,GAC7B,CAAC,CAUH;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAAC,CAAC,EAC5C,QAAQ,EAAE,CAAC,EACX,IAAI,EAAE,OAAO,EACb,UAAU,EAAE,kBAAkB,GAC7B,OAAO,CAAC,CAAC,CAAC,CAUZ;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,GAAG,CAAC,CAUpE"}
|
|
@@ -1,144 +1,16 @@
|
|
|
1
1
|
import { type Provider } from "@blaze-cardano/query";
|
|
2
2
|
import { Blaze, Core, type Wallet } from "@blaze-cardano/sdk";
|
|
3
|
-
import { type
|
|
3
|
+
import { type TSchema } from "@sinclair/typebox";
|
|
4
4
|
export * from "@sinclair/typebox";
|
|
5
|
-
export type TExact
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
export
|
|
14
|
-
name: string;
|
|
15
|
-
description?: string;
|
|
16
|
-
createdAt: string;
|
|
17
|
-
updatedAt: string;
|
|
18
|
-
}
|
|
19
|
-
export interface IProfileEntry {
|
|
20
|
-
id: string;
|
|
21
|
-
meta: IProfileMeta;
|
|
22
|
-
}
|
|
23
|
-
export interface TxDialogResult {
|
|
24
|
-
action: "submitted" | "signed" | "cancelled";
|
|
25
|
-
txId?: string;
|
|
26
|
-
tx: Core.Transaction;
|
|
27
|
-
}
|
|
28
|
-
export interface TxDialogOptions {
|
|
29
|
-
beforeSign?: () => Promise<void>;
|
|
30
|
-
}
|
|
31
|
-
export declare const NetworkSchema: TUnion<[TLiteral<"mainnet">, TLiteral<"preview">, TLiteral<"preprod">]>;
|
|
32
|
-
export declare const MultisigScriptModule: import("@sinclair/typebox").TModule<{
|
|
33
|
-
MultisigScript: TUnion<[TObject<{
|
|
34
|
-
Signature: TObject<{
|
|
35
|
-
key_hash: TString;
|
|
36
|
-
}>;
|
|
37
|
-
}>, TObject<{
|
|
38
|
-
AllOf: TObject<{
|
|
39
|
-
scripts: TArray<TRef<"MultisigScript">>;
|
|
40
|
-
}>;
|
|
41
|
-
}>, TObject<{
|
|
42
|
-
AnyOf: TObject<{
|
|
43
|
-
scripts: TArray<TRef<"MultisigScript">>;
|
|
44
|
-
}>;
|
|
45
|
-
}>, TObject<{
|
|
46
|
-
AtLeast: TObject<{
|
|
47
|
-
required: TBigInt;
|
|
48
|
-
scripts: TArray<TRef<"MultisigScript">>;
|
|
49
|
-
}>;
|
|
50
|
-
}>, TObject<{
|
|
51
|
-
Before: TObject<{
|
|
52
|
-
time: TBigInt;
|
|
53
|
-
}>;
|
|
54
|
-
}>, TObject<{
|
|
55
|
-
After: TObject<{
|
|
56
|
-
time: TBigInt;
|
|
57
|
-
}>;
|
|
58
|
-
}>, TObject<{
|
|
59
|
-
Script: TObject<{
|
|
60
|
-
script_hash: TString;
|
|
61
|
-
}>;
|
|
62
|
-
}>]>;
|
|
63
|
-
}, {
|
|
64
|
-
MultisigScript: TUnion<[TObject<{
|
|
65
|
-
Signature: TObject<{
|
|
66
|
-
key_hash: TString;
|
|
67
|
-
}>;
|
|
68
|
-
}>, TObject<{
|
|
69
|
-
AllOf: TObject<{
|
|
70
|
-
scripts: TArray<TRef<"MultisigScript">>;
|
|
71
|
-
}>;
|
|
72
|
-
}>, TObject<{
|
|
73
|
-
AnyOf: TObject<{
|
|
74
|
-
scripts: TArray<TRef<"MultisigScript">>;
|
|
75
|
-
}>;
|
|
76
|
-
}>, TObject<{
|
|
77
|
-
AtLeast: TObject<{
|
|
78
|
-
required: TBigInt;
|
|
79
|
-
scripts: TArray<TRef<"MultisigScript">>;
|
|
80
|
-
}>;
|
|
81
|
-
}>, TObject<{
|
|
82
|
-
Before: TObject<{
|
|
83
|
-
time: TBigInt;
|
|
84
|
-
}>;
|
|
85
|
-
}>, TObject<{
|
|
86
|
-
After: TObject<{
|
|
87
|
-
time: TBigInt;
|
|
88
|
-
}>;
|
|
89
|
-
}>, TObject<{
|
|
90
|
-
Script: TObject<{
|
|
91
|
-
script_hash: TString;
|
|
92
|
-
}>;
|
|
93
|
-
}>]>;
|
|
94
|
-
}>;
|
|
95
|
-
export declare const MultisigScript: TImport<{
|
|
96
|
-
MultisigScript: TUnion<[TObject<{
|
|
97
|
-
Signature: TObject<{
|
|
98
|
-
key_hash: TString;
|
|
99
|
-
}>;
|
|
100
|
-
}>, TObject<{
|
|
101
|
-
AllOf: TObject<{
|
|
102
|
-
scripts: TArray<TRef<"MultisigScript">>;
|
|
103
|
-
}>;
|
|
104
|
-
}>, TObject<{
|
|
105
|
-
AnyOf: TObject<{
|
|
106
|
-
scripts: TArray<TRef<"MultisigScript">>;
|
|
107
|
-
}>;
|
|
108
|
-
}>, TObject<{
|
|
109
|
-
AtLeast: TObject<{
|
|
110
|
-
required: TBigInt;
|
|
111
|
-
scripts: TArray<TRef<"MultisigScript">>;
|
|
112
|
-
}>;
|
|
113
|
-
}>, TObject<{
|
|
114
|
-
Before: TObject<{
|
|
115
|
-
time: TBigInt;
|
|
116
|
-
}>;
|
|
117
|
-
}>, TObject<{
|
|
118
|
-
After: TObject<{
|
|
119
|
-
time: TBigInt;
|
|
120
|
-
}>;
|
|
121
|
-
}>, TObject<{
|
|
122
|
-
Script: TObject<{
|
|
123
|
-
script_hash: TString;
|
|
124
|
-
}>;
|
|
125
|
-
}>]>;
|
|
126
|
-
}, "MultisigScript">;
|
|
127
|
-
export type TMultisigScript = TExact<typeof MultisigScript>;
|
|
128
|
-
export declare const ProviderSettingsSchema: TUnion<[TObject<{
|
|
129
|
-
type: TLiteral<"blockfrost">;
|
|
130
|
-
projectId: TString;
|
|
131
|
-
}>, TObject<{
|
|
132
|
-
type: TLiteral<"maestro">;
|
|
133
|
-
apiKey: TString;
|
|
134
|
-
}>]>;
|
|
135
|
-
export declare const WalletSettingsSchema: TUnion<[TObject<{
|
|
136
|
-
type: TLiteral<"hot">;
|
|
137
|
-
privateKey: TString;
|
|
138
|
-
}>, TObject<{
|
|
139
|
-
type: TLiteral<"cold">;
|
|
140
|
-
address: TString;
|
|
141
|
-
}>]>;
|
|
5
|
+
export type { TExact } from "./types.js";
|
|
6
|
+
export type { IEncryptionOptions, ISprinkleOptions, IProfileMeta, ICurrentProfile, IProfileEntry, TxDialogResult, TxDialogOptions, } from "./types.js";
|
|
7
|
+
export { UserCancelledError } from "./types.js";
|
|
8
|
+
import type { TExact, ISprinkleOptions, IProfileMeta, ICurrentProfile, IProfileEntry, TxDialogResult, TxDialogOptions } from "./types.js";
|
|
9
|
+
export { NetworkSchema, MultisigScriptModule, MultisigScript, ProviderSettingsSchema, WalletSettingsSchema, } from "./schemas.js";
|
|
10
|
+
export type { TMultisigScript } from "./schemas.js";
|
|
11
|
+
export { isOptional, isImport, isArray, isBigInt, isLiteral, isObject, isRef, isString, isThis, isTuple, isUnion, isSensitive, } from "./type-guards.js";
|
|
12
|
+
import { NetworkSchema, ProviderSettingsSchema, WalletSettingsSchema } from "./schemas.js";
|
|
13
|
+
export { GetProvider, GetWallet, GetBlaze } from "./wallet.js";
|
|
142
14
|
export interface IMenuAction<S extends TSchema> {
|
|
143
15
|
title: string;
|
|
144
16
|
action: (sprinkle: Sprinkle<S>) => Promise<Sprinkle<S> | void>;
|
|
@@ -158,6 +30,7 @@ export declare class Sprinkle<S extends TSchema> {
|
|
|
158
30
|
profileId: string;
|
|
159
31
|
profileMeta: IProfileMeta;
|
|
160
32
|
constructor(type: S, storagePath: string, options?: ISprinkleOptions);
|
|
33
|
+
get currentProfile(): ICurrentProfile | null;
|
|
161
34
|
static sanitizeProfileId(name: string): string;
|
|
162
35
|
private static profilesDir;
|
|
163
36
|
private static profilePath;
|
|
@@ -195,48 +68,14 @@ export declare class Sprinkle<S extends TSchema> {
|
|
|
195
68
|
name: string;
|
|
196
69
|
value: T;
|
|
197
70
|
}[];
|
|
198
|
-
}): Promise<T>;
|
|
71
|
+
}): Promise<T | null>;
|
|
199
72
|
static SettingsPath(storagePath: string): string;
|
|
200
73
|
LoadSettings(type: S, storagePath: string): Promise<void>;
|
|
201
74
|
static bigIntReviver(key: string, value: unknown): unknown;
|
|
202
|
-
private static bigIntReplacer;
|
|
203
|
-
private static collectSensitivePaths;
|
|
204
|
-
private static getNestedValue;
|
|
205
|
-
private static setNestedValue;
|
|
206
75
|
private encryptSettings;
|
|
207
76
|
private decryptSettings;
|
|
208
77
|
saveSettings(): void;
|
|
209
|
-
|
|
210
|
-
* Get the payment key hash from a HotWallet's first address
|
|
211
|
-
*/
|
|
212
|
-
private getWalletPaymentKeyHash;
|
|
213
|
-
/**
|
|
214
|
-
* Count the number of vkey signatures in a transaction's witness set
|
|
215
|
-
*/
|
|
216
|
-
private countSignatures;
|
|
217
|
-
/**
|
|
218
|
-
* Check if a specific public key has already signed the transaction
|
|
219
|
-
* Compares by vkey (public key bytes)
|
|
220
|
-
*/
|
|
221
|
-
private hasVkeySigned;
|
|
222
|
-
/**
|
|
223
|
-
* Get the list of required signer key hashes from the transaction body
|
|
224
|
-
*/
|
|
225
|
-
private getRequiredSigners;
|
|
226
|
-
/**
|
|
227
|
-
* Compute the transaction body hash for display
|
|
228
|
-
*/
|
|
229
|
-
private getTxBodyHash;
|
|
230
|
-
/**
|
|
231
|
-
* Format a hash for display: first 8 chars + ... + last 8 chars
|
|
232
|
-
*/
|
|
233
|
-
private formatHash;
|
|
234
|
-
/**
|
|
235
|
-
* Merge signatures from source transaction into target transaction.
|
|
236
|
-
* Prevents duplicate signatures by comparing vkey (public key).
|
|
237
|
-
* Returns the count of newly added signatures.
|
|
238
|
-
*/
|
|
239
|
-
private mergeSignatures;
|
|
78
|
+
getDisplaySettings(): TExact<S>;
|
|
240
79
|
TxDialog<P extends Provider, W extends Wallet>(blaze: Blaze<P, W>, tx: Core.Transaction, opts?: TxDialogOptions): Promise<TxDialogResult>;
|
|
241
80
|
EditStruct<U extends TSchema>(type: U, current: TExact<U>): Promise<TExact<U>>;
|
|
242
81
|
_editStruct<U extends TSchema>(type: U, path: string[], current?: TExact<U>): Promise<TExact<U>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Sprinkle/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Sprinkle/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EACL,KAAK,EACL,IAAI,EAEJ,KAAK,MAAM,EACZ,MAAM,oBAAoB,CAAC;AAU5B,OAAO,EAAE,KAAK,OAAO,EAAsB,MAAM,mBAAmB,CAAC;AAGrE,cAAc,mBAAmB,CAAC;AAGlC,YAAY,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACzC,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,cAAc,EACd,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EACV,MAAM,EAEN,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,cAAc,EACd,eAAe,EAChB,MAAM,YAAY,CAAC;AAIpB,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAiBpD,OAAO,EACL,UAAU,EACV,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,MAAM,EACN,OAAO,EACP,OAAO,EACP,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,cAAc,CAAC;AAStB,OAAO,EAAE,WA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CAAC,CAAC,CAAC,CAAC;IAIf,aAAa,CAAC,CAAC,SAAS,OAAO,EACnC,IAAI,EAAE,CAAC,EACP,IAAI,EAAE,MAAM,EAAE,EACd,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,GACd,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAyMrB,WAAW,CAAC,CAAC,SAAS,OAAO,EAC3B,IAAI,EAAE,CAAC,EACP,IAAI,EAAE,MAAM,EAAE,EACd,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,CAAC;IAcJ,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM;CA0B1D"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cancellable prompt wrappers with escape key support.
|
|
3
|
+
* Uses @inquirer/core's createPrompt and useKeypress for proper escape handling.
|
|
4
|
+
*/
|
|
5
|
+
import { Separator, type Theme } from "@inquirer/core";
|
|
6
|
+
import type { PartialDeep } from "@inquirer/type";
|
|
7
|
+
declare const selectTheme: {
|
|
8
|
+
icon: {
|
|
9
|
+
cursor: string;
|
|
10
|
+
};
|
|
11
|
+
style: {
|
|
12
|
+
disabled: (text: string) => string;
|
|
13
|
+
description: (text: string) => string;
|
|
14
|
+
helpTip: string;
|
|
15
|
+
};
|
|
16
|
+
helpMode: "always";
|
|
17
|
+
};
|
|
18
|
+
interface SelectChoice<T> {
|
|
19
|
+
name?: string;
|
|
20
|
+
value: T;
|
|
21
|
+
description?: string;
|
|
22
|
+
short?: string;
|
|
23
|
+
disabled?: boolean | string;
|
|
24
|
+
}
|
|
25
|
+
interface SelectConfig<T> {
|
|
26
|
+
message: string;
|
|
27
|
+
choices: ReadonlyArray<SelectChoice<T> | Separator | string>;
|
|
28
|
+
default?: T;
|
|
29
|
+
pageSize?: number;
|
|
30
|
+
loop?: boolean;
|
|
31
|
+
theme?: PartialDeep<Theme<typeof selectTheme>>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Select prompt with escape key support.
|
|
35
|
+
* Returns null if user presses Escape.
|
|
36
|
+
*/
|
|
37
|
+
export declare const selectCancellable: import("@inquirer/type").Prompt<unknown, SelectConfig<unknown>>;
|
|
38
|
+
interface InputConfig {
|
|
39
|
+
message: string;
|
|
40
|
+
default?: string;
|
|
41
|
+
transformer?: (value: string, options: {
|
|
42
|
+
isFinal: boolean;
|
|
43
|
+
}) => string;
|
|
44
|
+
validate?: (value: string) => boolean | string | Promise<boolean | string>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Input prompt with escape key support.
|
|
48
|
+
* Returns null if user presses Escape.
|
|
49
|
+
*/
|
|
50
|
+
export declare const inputCancellable: import("@inquirer/type").Prompt<string | null, InputConfig>;
|
|
51
|
+
interface PasswordConfig {
|
|
52
|
+
message: string;
|
|
53
|
+
mask?: string;
|
|
54
|
+
validate?: (value: string) => boolean | string | Promise<boolean | string>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Password prompt with escape key support.
|
|
58
|
+
* Returns null if user presses Escape.
|
|
59
|
+
*/
|
|
60
|
+
export declare const passwordCancellable: import("@inquirer/type").Prompt<string | null, PasswordConfig>;
|
|
61
|
+
interface ConfirmConfig {
|
|
62
|
+
message: string;
|
|
63
|
+
default?: boolean;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Confirm prompt with escape key support.
|
|
67
|
+
* Returns null if user presses Escape.
|
|
68
|
+
*/
|
|
69
|
+
export declare const confirmCancellable: import("@inquirer/type").Prompt<boolean | null, ConfirmConfig>;
|
|
70
|
+
/**
|
|
71
|
+
* Type-safe wrapper for selectCancellable.
|
|
72
|
+
* Returns the selected value with proper typing, or null if cancelled.
|
|
73
|
+
*/
|
|
74
|
+
export declare function select<T>(config: SelectConfig<T>): Promise<T | null>;
|
|
75
|
+
interface SearchConfig<T> {
|
|
76
|
+
message: string;
|
|
77
|
+
source: (term: string | undefined) => Promise<{
|
|
78
|
+
name: string;
|
|
79
|
+
value: T;
|
|
80
|
+
}[]> | {
|
|
81
|
+
name: string;
|
|
82
|
+
value: T;
|
|
83
|
+
}[];
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Search prompt with escape key support.
|
|
87
|
+
* Returns null if user presses Escape.
|
|
88
|
+
*
|
|
89
|
+
* Note: This wraps @inquirer/search which has built-in escape handling,
|
|
90
|
+
* but we provide a consistent API with other cancellable prompts.
|
|
91
|
+
*/
|
|
92
|
+
export declare const searchCancellable: import("@inquirer/type").Prompt<unknown, SearchConfig<unknown>>;
|
|
93
|
+
export {};
|
|
94
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/Sprinkle/prompts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAYL,SAAS,EAET,KAAK,KAAK,EACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAQlD,QAAA,MAAM,WAAW;;;;;yBAGI,MAAM;4BACH,MAAM;;;;CAI7B,CAAC;AASF,UAAU,YAAY,CAAC,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,CAAC,CAAC;IACT,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAC7B;AAED,UAAU,YAAY,CAAC,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC,CAAC;IAC7D,OAAO,CAAC,EAA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