Skip to content

Commit

Permalink
chore: add deprecation notice to keychain package methods
Browse files Browse the repository at this point in the history
  • Loading branch information
janniks committed Sep 6, 2022
1 parent c5536b7 commit 9341e20
Show file tree
Hide file tree
Showing 13 changed files with 409 additions and 375 deletions.
748 changes: 374 additions & 374 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions packages/keychain/src/address-derivation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ export const derivationPaths = {
[ChainID.Testnet]: networkDerivationPath,
};

/** @deprecated */
export function getDerivationPath(chain: ChainID) {
return derivationPaths[chain];
}

/** @deprecated */
export function deriveStxAddressChain(chain: ChainID) {
return (rootNode: BIP32Interface) => {
const childKey = rootNode.derivePath(getDerivationPath(chain));
Expand Down
3 changes: 2 additions & 1 deletion packages/keychain/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { IdentityKeyPair } from './utils';
interface RefreshOptions {
gaiaUrl: string;
}

/** @deprecated use `@stacks/profile` instead */
export interface Identity {
keyPair: IdentityKeyPair;
address: string;
Expand All @@ -27,6 +27,7 @@ const PERSON_TYPE = 'Person';
const CONTEXT = 'http://schema.org';
const IMAGE_TYPE = 'ImageObject';

/** @deprecated use `@stacks/profile` instead */
export interface ProfileImage {
'@type': typeof IMAGE_TYPE;
name: string;
Expand Down
1 change: 1 addition & 0 deletions packages/keychain/src/encryption/decrypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { decryptMnemonic } from '@stacks/encryption';
* @param data - Buffer or hex-encoded string of the encrypted mnemonic
* @param password - Password for data
* @return the raw mnemonic phrase
* @deprecated use `decrypt` from `@stacks/wallet-sdk` instead
*/
export async function decrypt(dataBuffer: Buffer | string, password: string): Promise<string> {
const result = await decryptMnemonic(dataBuffer, password, triplesecDecrypt);
Expand Down
1 change: 1 addition & 0 deletions packages/keychain/src/encryption/encrypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { encryptMnemonic } from '@stacks/encryption';
* @param phrase - Raw mnemonic phrase
* @param password - Password to encrypt mnemonic with
* @return The encrypted phrase
* @deprecated use `encrypt` from `@stacks/wallet-sdk` instead
* */
export async function encrypt(phrase: string, password: string) {
const result = await encryptMnemonic(phrase, password);
Expand Down
1 change: 1 addition & 0 deletions packages/keychain/src/identity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ interface RefreshOptions {
gaiaUrl: string;
}

/** @deprecated use `@stacks/auth` and `@stacks/profile` instead */
export class Identity implements IdentifyInterface {
public keyPair: IdentityKeyPair;
public address: string;
Expand Down
4 changes: 4 additions & 0 deletions packages/keychain/src/mnemonic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { encryptMnemonic } from '@stacks/encryption';

export type AllowedKeyEntropyBits = 128 | 256;

/** @deprecated use `generateSecretKey` and `generateWallet` from `@stacks/wallet-sdk` instead */
export async function generateMnemonicRootKeychain(entropy: AllowedKeyEntropyBits) {
const plaintextMnemonic = generateBip39Mnemonic(wordlist, entropy);
const seed = await mnemonicToSeed(plaintextMnemonic);
Expand All @@ -25,6 +26,7 @@ export async function generateMnemonicRootKeychain(entropy: AllowedKeyEntropyBit
};
}

/** @deprecated use `generateWallet` from `@stacks/wallet-sdk` instead */
export async function generateEncryptedMnemonicRootKeychain(
password: string,
entropy: AllowedKeyEntropyBits
Expand All @@ -40,12 +42,14 @@ export async function generateEncryptedMnemonicRootKeychain(
};
}

/** @deprecated use `generateWallet` from `@stacks/wallet-sdk` instead */
export async function deriveRootKeychainFromMnemonic(plaintextMnemonic: string) {
const seed = await mnemonicToSeed(plaintextMnemonic);
const rootNode = bip32.fromSeed(Buffer.from(seed));
return rootNode;
}

/** @deprecated use `encrypt` from `@stacks/wallet-sdk` instead */
export async function encryptMnemonicFormatted(plaintextMnemonic: string, password: string) {
const encryptedMnemonic = await encryptMnemonic(plaintextMnemonic, password);
const encryptedMnemonicHex = encryptedMnemonic.toString('hex');
Expand Down
1 change: 1 addition & 0 deletions packages/keychain/src/nodes/identity-address-owner-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const SIGNING_NODE_INDEX = 1;
const ENCRYPTION_NODE_INDEX = 2;
const STX_NODE_INDEX = 6;

/** @deprecated use `@stacks/wallet-sdk` instead */
export default class IdentityAddressOwnerNode {
hdNode: BIP32Interface;

Expand Down
5 changes: 5 additions & 0 deletions packages/keychain/src/profiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const registrars = {
},
};

/** @deprecated use `@stacks/profile` instead */
export function signProfileForUpload(profile: Profile, keypair: IdentityKeyPair) {
const privateKey = keypair.key;
const publicKey = keypair.keyID;
Expand All @@ -38,6 +39,7 @@ export function signProfileForUpload(profile: Profile, keypair: IdentityKeyPair)
return JSON.stringify(tokenRecords, null, 2);
}

/** @deprecated use `@stacks/profile` instead */
export async function uploadProfile(
gaiaHubUrl: string,
identity: Identity,
Expand Down Expand Up @@ -111,6 +113,7 @@ interface RegisterParams {

/**
* Register a subdomain for a given identity
* @deprecated use `@stacks/profile` instead
*/
export const registerSubdomain = async ({
identity,
Expand All @@ -134,6 +137,7 @@ export const registerSubdomain = async ({
return identity;
};

/** @deprecated use `@stacks/profile` instead */
export const signAndUploadProfile = async ({
profile,
gaiaHubUrl,
Expand All @@ -149,6 +153,7 @@ export const signAndUploadProfile = async ({
await uploadProfile(gaiaHubUrl, identity, signedProfileTokenData, gaiaHubConfig);
};

/** @deprecated use `@stacks/profile` instead */
export const fetchProfile = async ({
identity,
gaiaUrl,
Expand Down
6 changes: 6 additions & 0 deletions packages/keychain/src/utils/gaia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ interface HubInfo {
read_url_prefix: string;
}

/** @deprecated use `@stacks/storage` instead */
export const getHubInfo = async (hubUrl: string, fetchFn: FetchFn = createFetchFn()) => {
const response = await fetchFn(`${hubUrl}/hub_info`);
const data: HubInfo = await response.json();
return data;
};

/** @deprecated use `@stacks/storage` instead */
export const makeGaiaAssociationToken = (
secretKeyHex: string,
childPublicKeyHex: string
Expand Down Expand Up @@ -44,6 +46,7 @@ interface ConnectToGaiaOptions {
gaiaHubUrl: string;
}

/** @deprecated use `@stacks/storage` instead */
export const connectToGaiaHubWithConfig = ({
hubInfo,
privateKey,
Expand All @@ -68,6 +71,7 @@ interface ReadOnlyGaiaConfigOptions {

/**
* When you already know the Gaia read URL, make a Gaia config that doesn't have to fetch `/hub_info`
* @deprecated use `@stacks/storage` instead
*/
export const makeReadOnlyGaiaConfig = ({
readURL,
Expand All @@ -83,6 +87,7 @@ export const makeReadOnlyGaiaConfig = ({
};
};

/** @deprecated use `@stacks/storage` instead */
interface GaiaAuthPayload {
gaiaHubUrl: string;
iss: string;
Expand All @@ -107,6 +112,7 @@ const makeGaiaAuthToken = ({ hubInfo, privateKey, gaiaHubUrl }: ConnectToGaiaOpt
return `v1:${token}`;
};

/** @deprecated use `@stacks/storage` instead */
export const uploadToGaiaHub = async (
filename: string,
// eslint-disable-next-line node/prefer-global/buffer
Expand Down
10 changes: 10 additions & 0 deletions packages/keychain/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ import { registrars, Subdomains } from '../profiles';
const IDENTITY_KEYCHAIN = 888;
const BLOCKSTACK_ON_BITCOIN = 0;

/** @deprecated */
export function getIdentityPrivateKeychain(rootNode: BIP32Interface) {
return rootNode.deriveHardened(IDENTITY_KEYCHAIN).deriveHardened(BLOCKSTACK_ON_BITCOIN);
}

const EXTERNAL_ADDRESS = 'EXTERNAL_ADDRESS';
const CHANGE_ADDRESS = 'CHANGE_ADDRESS';

/** @deprecated */
export function getBitcoinPrivateKeychain(rootNode: BIP32Interface) {
const BIP_44_PURPOSE = 44;
const BITCOIN_COIN_TYPE = 0;
Expand All @@ -28,6 +30,7 @@ export function getBitcoinPrivateKeychain(rootNode: BIP32Interface) {
.deriveHardened(ACCOUNT_INDEX);
}

/** @deprecated */
export function getBitcoinAddressNode(
bitcoinKeychain: BIP32Interface,
addressIndex = 0,
Expand All @@ -46,6 +49,7 @@ export function getBitcoinAddressNode(
return bitcoinKeychain.derive(chain).derive(addressIndex);
}

/** @deprecated */
export async function getIdentityOwnerAddressNode(
identityPrivateKeychain: BIP32Interface,
identityIndex = 0
Expand Down Expand Up @@ -76,6 +80,7 @@ export interface IdentityKeyPair {
salt: string;
}

/** @deprecated */
export function deriveIdentityKeyPair(
identityOwnerAddressNode: IdentityAddressOwnerNode
): IdentityKeyPair {
Expand All @@ -95,6 +100,7 @@ export function deriveIdentityKeyPair(
return keyPair;
}

/** @deprecated */
export async function getBlockchainIdentities(
rootNode: BIP32Interface,
identitiesToGenerate: number
Expand Down Expand Up @@ -133,6 +139,7 @@ export async function getBlockchainIdentities(
};
}

/** @deprecated */
export const makeIdentity = async (rootNode: BIP32Interface, index: number) => {
const identityPrivateKeychainNode = getIdentityPrivateKeychain(rootNode);
const identityOwnerAddressNode = await getIdentityOwnerAddressNode(
Expand Down Expand Up @@ -163,6 +170,7 @@ export enum IdentityNameValidityError {

const containsLegalCharacters = (name: string) => /^[a-z0-9_]+$/.test(name);

/** @deprecated */
export const validateSubdomainFormat = (identityName: string): IdentityNameValidityError | null => {
const nameLength = identityName.length;

Expand All @@ -181,6 +189,7 @@ export const validateSubdomainFormat = (identityName: string): IdentityNameValid
return null;
};

/** @deprecated */
export const validateSubdomainAvailability = async (
name: string,
subdomain: Subdomains = Subdomains.BLOCKSTACK,
Expand All @@ -202,6 +211,7 @@ interface RecursiveMakeIdentitiesOptions {
* Restore identities by recursively making a new identity, and checking if it has a username.
*
* As soon as a username is not found for an identity, the recursion stops.
* @deprecated
*/
export const recursiveRestoreIdentities = async ({
rootNode,
Expand Down
1 change: 1 addition & 0 deletions packages/keychain/src/wallet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export interface ConstructorOptions {
walletConfig?: WalletConfig;
}

/** @deprecated use `@stacks/wallet-sdk` instead */
export class Wallet {
chain: ChainID;
encryptedBackupPhrase: string;
Expand Down
1 change: 1 addition & 0 deletions packages/keychain/src/wallet/signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ interface STXTransferOptions {
anchorMode: AnchorMode;
}

/** @deprecated use `@stacks/wallet-sdk` and `@stacks/transactions` instead */
export class WalletSigner {
privateKey: Buffer;

Expand Down

1 comment on commit 9341e20

@vercel
Copy link

@vercel vercel bot commented on 9341e20 Sep 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.