@ecency/sdk 1.3.3 → 1.3.5
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/browser/index.d.ts +12 -1
- package/dist/browser/index.js +48 -22
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +51 -22
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +48 -22
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ interface AccountProfile {
|
|
|
24
24
|
website?: string;
|
|
25
25
|
pinned?: string;
|
|
26
26
|
reputation?: number;
|
|
27
|
+
version?: number;
|
|
27
28
|
beneficiary?: {
|
|
28
29
|
account: string;
|
|
29
30
|
weight: number;
|
|
@@ -465,6 +466,16 @@ declare function getAccountPendingRecoveryQueryOptions(username: string | undefi
|
|
|
465
466
|
};
|
|
466
467
|
};
|
|
467
468
|
|
|
469
|
+
type ProfileTokens = AccountProfile["tokens"];
|
|
470
|
+
interface BuildProfileMetadataArgs {
|
|
471
|
+
existingProfile?: AccountProfile;
|
|
472
|
+
profile?: Partial<AccountProfile> | null;
|
|
473
|
+
tokens?: ProfileTokens | null;
|
|
474
|
+
}
|
|
475
|
+
declare function parseProfileMetadata(postingJsonMetadata?: string | null): AccountProfile;
|
|
476
|
+
declare function extractAccountProfile(data?: Pick<FullAccount, "posting_json_metadata"> | null): AccountProfile;
|
|
477
|
+
declare function buildProfileMetadata({ existingProfile, profile, tokens, }: BuildProfileMetadataArgs): AccountProfile;
|
|
478
|
+
|
|
468
479
|
declare function useSignOperationByKey(username: string | undefined): _tanstack_react_query.UseMutationResult<_hiveio_dhive.TransactionConfirmation, Error, {
|
|
469
480
|
operation: Operation;
|
|
470
481
|
keyOrSeed: string;
|
|
@@ -1028,4 +1039,4 @@ declare function getCommunityPermissions({ communityType, userRole, subscribed,
|
|
|
1028
1039
|
isModerator: boolean;
|
|
1029
1040
|
};
|
|
1030
1041
|
|
|
1031
|
-
export { type AccountBookmark, type AccountFavorite, type AccountFollowStats, type AccountProfile, type AccountRelationship, type AccountReputation, type Asset, CONFIG, type CantAfford, type CheckUsernameWalletsPendingResponse, type Communities, type Community, type CommunityRole, type CommunityTeam, type CommunityType, ConfigManager, type DynamicProps, index as EcencyAnalytics, EcencyQueriesManager, type Fragment, type FullAccount, type GameClaim, type GetGameStatus, type GetRecoveriesEmailResponse, HiveSignerIntegration, keychain as Keychain, type Keys, NaiMap, type Payer, ROLES, type RcStats, type Recoveries, type StatsResponse, type StoringUser, Symbol, ThreeSpeakIntegration, type ThreeSpeakVideo, type TrendingTag, type WalletMetadataCandidate, broadcastJson, checkUsernameWalletsPendingQueryOptions, decodeObj, dedupeAndSortKeyAuths, encodeObj, getAccessToken, getAccountFullQueryOptions, getAccountPendingRecoveryQueryOptions, getAccountRcQueryOptions, getAccountRecoveriesQueryOptions, getAccountSubscriptionsQueryOptions, getActiveAccountBookmarksQueryOptions, getActiveAccountFavouritesQueryOptions, getBoundFetch, getChainPropertiesQueryOptions, getCommunitiesQueryOptions, getCommunityContextQueryOptions, getCommunityPermissions, getCommunityType, getDynamicPropsQueryOptions, getFragmentsQueryOptions, getGameStatusCheckQueryOptions, getHivePoshLinksQueryOptions, getLoginType, getPostingKey, getPromotedPostsQuery, getQueryClient, getRcStatsQueryOptions, getRefreshToken, getRelationshipBetweenAccountsQueryOptions, getSearchAccountsByUsernameQueryOptions, getStatsQueryOptions, getTrendingTagsQueryOptions, getUser, makeQueryClient, parseAsset, roleMap, useAccountFavouriteAdd, useAccountFavouriteDelete, useAccountRelationsUpdate, useAccountRevokeKey, useAccountRevokePosting, useAccountUpdate, useAccountUpdateKeyAuths, useAccountUpdatePassword, useAccountUpdateRecovery, useAddFragment, useBookmarkAdd, useBookmarkDelete, useBroadcastMutation, useEditFragment, useGameClaim, useRemoveFragment, useSignOperationByHivesigner, useSignOperationByKey, useSignOperationByKeychain };
|
|
1042
|
+
export { type AccountBookmark, type AccountFavorite, type AccountFollowStats, type AccountProfile, type AccountRelationship, type AccountReputation, type Asset, type BuildProfileMetadataArgs, CONFIG, type CantAfford, type CheckUsernameWalletsPendingResponse, type Communities, type Community, type CommunityRole, type CommunityTeam, type CommunityType, ConfigManager, type DynamicProps, index as EcencyAnalytics, EcencyQueriesManager, type Fragment, type FullAccount, type GameClaim, type GetGameStatus, type GetRecoveriesEmailResponse, HiveSignerIntegration, keychain as Keychain, type Keys, NaiMap, type Payer, type ProfileTokens, ROLES, type RcStats, type Recoveries, type StatsResponse, type StoringUser, Symbol, ThreeSpeakIntegration, type ThreeSpeakVideo, type TrendingTag, type WalletMetadataCandidate, broadcastJson, buildProfileMetadata, checkUsernameWalletsPendingQueryOptions, decodeObj, dedupeAndSortKeyAuths, encodeObj, extractAccountProfile, getAccessToken, getAccountFullQueryOptions, getAccountPendingRecoveryQueryOptions, getAccountRcQueryOptions, getAccountRecoveriesQueryOptions, getAccountSubscriptionsQueryOptions, getActiveAccountBookmarksQueryOptions, getActiveAccountFavouritesQueryOptions, getBoundFetch, getChainPropertiesQueryOptions, getCommunitiesQueryOptions, getCommunityContextQueryOptions, getCommunityPermissions, getCommunityType, getDynamicPropsQueryOptions, getFragmentsQueryOptions, getGameStatusCheckQueryOptions, getHivePoshLinksQueryOptions, getLoginType, getPostingKey, getPromotedPostsQuery, getQueryClient, getRcStatsQueryOptions, getRefreshToken, getRelationshipBetweenAccountsQueryOptions, getSearchAccountsByUsernameQueryOptions, getStatsQueryOptions, getTrendingTagsQueryOptions, getUser, makeQueryClient, parseAsset, parseProfileMetadata, roleMap, useAccountFavouriteAdd, useAccountFavouriteDelete, useAccountRelationsUpdate, useAccountRevokeKey, useAccountRevokePosting, useAccountUpdate, useAccountUpdateKeyAuths, useAccountUpdatePassword, useAccountUpdateRecovery, useAddFragment, useBookmarkAdd, useBookmarkDelete, useBroadcastMutation, useEditFragment, useGameClaim, useRemoveFragment, useSignOperationByHivesigner, useSignOperationByKey, useSignOperationByKeychain };
|
package/dist/browser/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { QueryClient, useQuery, useInfiniteQuery, useMutation, queryOptions, useQueryClient, infiniteQueryOptions } from '@tanstack/react-query';
|
|
2
2
|
import { Client, PrivateKey, cryptoUtils, RCAPI } from '@hiveio/dhive';
|
|
3
3
|
import hs from 'hivesigner';
|
|
4
|
-
import * as
|
|
4
|
+
import * as R4 from 'remeda';
|
|
5
5
|
|
|
6
6
|
var __defProp = Object.defineProperty;
|
|
7
7
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -406,11 +406,7 @@ function getAccountFullQueryOptions(username) {
|
|
|
406
406
|
if (!response[0]) {
|
|
407
407
|
throw new Error("[SDK] No account with given username");
|
|
408
408
|
}
|
|
409
|
-
|
|
410
|
-
try {
|
|
411
|
-
profile = JSON.parse(response[0].posting_json_metadata).profile;
|
|
412
|
-
} catch (e) {
|
|
413
|
-
}
|
|
409
|
+
const profile = parseProfileMetadata(response[0].posting_json_metadata);
|
|
414
410
|
let follow_stats;
|
|
415
411
|
try {
|
|
416
412
|
follow_stats = await CONFIG.hiveClient.database.call(
|
|
@@ -704,21 +700,42 @@ function sanitizeTokens(tokens) {
|
|
|
704
700
|
return { ...rest, meta: safeMeta };
|
|
705
701
|
});
|
|
706
702
|
}
|
|
707
|
-
function
|
|
703
|
+
function parseProfileMetadata(postingJsonMetadata) {
|
|
704
|
+
if (!postingJsonMetadata) {
|
|
705
|
+
return {};
|
|
706
|
+
}
|
|
707
|
+
try {
|
|
708
|
+
const parsed = JSON.parse(postingJsonMetadata);
|
|
709
|
+
if (parsed && typeof parsed === "object" && parsed.profile && typeof parsed.profile === "object") {
|
|
710
|
+
return parsed.profile;
|
|
711
|
+
}
|
|
712
|
+
} catch (err) {
|
|
713
|
+
}
|
|
714
|
+
return {};
|
|
715
|
+
}
|
|
716
|
+
function extractAccountProfile(data) {
|
|
717
|
+
return parseProfileMetadata(data?.posting_json_metadata);
|
|
718
|
+
}
|
|
719
|
+
function buildProfileMetadata({
|
|
720
|
+
existingProfile,
|
|
708
721
|
profile,
|
|
709
|
-
tokens
|
|
710
|
-
data
|
|
722
|
+
tokens
|
|
711
723
|
}) {
|
|
712
|
-
const
|
|
713
|
-
|
|
714
|
-
|
|
724
|
+
const { tokens: profileTokens, version: _ignoredVersion, ...profileRest } = profile ?? {};
|
|
725
|
+
const metadata = R4.mergeDeep(
|
|
726
|
+
existingProfile ?? {},
|
|
727
|
+
profileRest
|
|
715
728
|
);
|
|
716
|
-
|
|
717
|
-
|
|
729
|
+
const nextTokens = tokens ?? profileTokens;
|
|
730
|
+
if (nextTokens && nextTokens.length > 0) {
|
|
731
|
+
metadata.tokens = nextTokens;
|
|
718
732
|
}
|
|
719
733
|
metadata.tokens = sanitizeTokens(metadata.tokens);
|
|
734
|
+
metadata.version = 2;
|
|
720
735
|
return metadata;
|
|
721
736
|
}
|
|
737
|
+
|
|
738
|
+
// src/modules/accounts/mutations/use-account-update.ts
|
|
722
739
|
function useAccountUpdate(username) {
|
|
723
740
|
const queryClient = useQueryClient();
|
|
724
741
|
const { data } = useQuery(getAccountFullQueryOptions(username));
|
|
@@ -729,6 +746,11 @@ function useAccountUpdate(username) {
|
|
|
729
746
|
if (!data) {
|
|
730
747
|
throw new Error("[SDK][Accounts] \u2013 cannot update not existing account");
|
|
731
748
|
}
|
|
749
|
+
const profile = buildProfileMetadata({
|
|
750
|
+
existingProfile: extractAccountProfile(data),
|
|
751
|
+
profile: payload.profile,
|
|
752
|
+
tokens: payload.tokens
|
|
753
|
+
});
|
|
732
754
|
return [
|
|
733
755
|
[
|
|
734
756
|
"account_update2",
|
|
@@ -737,7 +759,7 @@ function useAccountUpdate(username) {
|
|
|
737
759
|
json_metadata: "",
|
|
738
760
|
extensions: [],
|
|
739
761
|
posting_json_metadata: JSON.stringify({
|
|
740
|
-
profile
|
|
762
|
+
profile
|
|
741
763
|
})
|
|
742
764
|
}
|
|
743
765
|
]
|
|
@@ -749,8 +771,12 @@ function useAccountUpdate(username) {
|
|
|
749
771
|
if (!data2) {
|
|
750
772
|
return data2;
|
|
751
773
|
}
|
|
752
|
-
const obj =
|
|
753
|
-
obj.profile =
|
|
774
|
+
const obj = R4.clone(data2);
|
|
775
|
+
obj.profile = buildProfileMetadata({
|
|
776
|
+
existingProfile: extractAccountProfile(data2),
|
|
777
|
+
profile: variables.profile,
|
|
778
|
+
tokens: variables.tokens
|
|
779
|
+
});
|
|
754
780
|
return obj;
|
|
755
781
|
}
|
|
756
782
|
)
|
|
@@ -945,7 +971,7 @@ function useAccountUpdateKeyAuths(username, options) {
|
|
|
945
971
|
);
|
|
946
972
|
}
|
|
947
973
|
const prepareAuth = (keyName) => {
|
|
948
|
-
const auth =
|
|
974
|
+
const auth = R4.clone(accountData[keyName]);
|
|
949
975
|
auth.key_auths = dedupeAndSortKeyAuths(
|
|
950
976
|
keepCurrent ? auth.key_auths : [],
|
|
951
977
|
keys.map(
|
|
@@ -1016,9 +1042,9 @@ function useAccountRevokePosting(username, options) {
|
|
|
1016
1042
|
"[SDK][Accounts] \u2013\xA0cannot revoke posting for anonymous user"
|
|
1017
1043
|
);
|
|
1018
1044
|
}
|
|
1019
|
-
const posting =
|
|
1045
|
+
const posting = R4.pipe(
|
|
1020
1046
|
{},
|
|
1021
|
-
|
|
1047
|
+
R4.mergeDeep(data.posting)
|
|
1022
1048
|
);
|
|
1023
1049
|
posting.account_auths = posting.account_auths.filter(
|
|
1024
1050
|
([account]) => account !== accountName
|
|
@@ -1135,7 +1161,7 @@ function useAccountRevokeKey(username, options) {
|
|
|
1135
1161
|
);
|
|
1136
1162
|
}
|
|
1137
1163
|
const prepareAuth = (keyName) => {
|
|
1138
|
-
const auth =
|
|
1164
|
+
const auth = R4.clone(accountData[keyName]);
|
|
1139
1165
|
auth.key_auths = auth.key_auths.filter(
|
|
1140
1166
|
([key]) => key !== revokingKey.toString()
|
|
1141
1167
|
);
|
|
@@ -1720,6 +1746,6 @@ function getCommunityPermissions({
|
|
|
1720
1746
|
};
|
|
1721
1747
|
}
|
|
1722
1748
|
|
|
1723
|
-
export { CONFIG, ConfigManager, mutations_exports as EcencyAnalytics, EcencyQueriesManager, HiveSignerIntegration, keychain_exports as Keychain, NaiMap, ROLES, Symbol2 as Symbol, ThreeSpeakIntegration, broadcastJson, checkUsernameWalletsPendingQueryOptions, decodeObj, dedupeAndSortKeyAuths, encodeObj, getAccessToken, getAccountFullQueryOptions, getAccountPendingRecoveryQueryOptions, getAccountRcQueryOptions, getAccountRecoveriesQueryOptions, getAccountSubscriptionsQueryOptions, getActiveAccountBookmarksQueryOptions, getActiveAccountFavouritesQueryOptions, getBoundFetch, getChainPropertiesQueryOptions, getCommunitiesQueryOptions, getCommunityContextQueryOptions, getCommunityPermissions, getCommunityType, getDynamicPropsQueryOptions, getFragmentsQueryOptions, getGameStatusCheckQueryOptions, getHivePoshLinksQueryOptions, getLoginType, getPostingKey, getPromotedPostsQuery, getQueryClient, getRcStatsQueryOptions, getRefreshToken, getRelationshipBetweenAccountsQueryOptions, getSearchAccountsByUsernameQueryOptions, getStatsQueryOptions, getTrendingTagsQueryOptions, getUser, makeQueryClient, parseAsset, roleMap, useAccountFavouriteAdd, useAccountFavouriteDelete, useAccountRelationsUpdate, useAccountRevokeKey, useAccountRevokePosting, useAccountUpdate, useAccountUpdateKeyAuths, useAccountUpdatePassword, useAccountUpdateRecovery, useAddFragment, useBookmarkAdd, useBookmarkDelete, useBroadcastMutation, useEditFragment, useGameClaim, useRemoveFragment, useSignOperationByHivesigner, useSignOperationByKey, useSignOperationByKeychain };
|
|
1749
|
+
export { CONFIG, ConfigManager, mutations_exports as EcencyAnalytics, EcencyQueriesManager, HiveSignerIntegration, keychain_exports as Keychain, NaiMap, ROLES, Symbol2 as Symbol, ThreeSpeakIntegration, broadcastJson, buildProfileMetadata, checkUsernameWalletsPendingQueryOptions, decodeObj, dedupeAndSortKeyAuths, encodeObj, extractAccountProfile, getAccessToken, getAccountFullQueryOptions, getAccountPendingRecoveryQueryOptions, getAccountRcQueryOptions, getAccountRecoveriesQueryOptions, getAccountSubscriptionsQueryOptions, getActiveAccountBookmarksQueryOptions, getActiveAccountFavouritesQueryOptions, getBoundFetch, getChainPropertiesQueryOptions, getCommunitiesQueryOptions, getCommunityContextQueryOptions, getCommunityPermissions, getCommunityType, getDynamicPropsQueryOptions, getFragmentsQueryOptions, getGameStatusCheckQueryOptions, getHivePoshLinksQueryOptions, getLoginType, getPostingKey, getPromotedPostsQuery, getQueryClient, getRcStatsQueryOptions, getRefreshToken, getRelationshipBetweenAccountsQueryOptions, getSearchAccountsByUsernameQueryOptions, getStatsQueryOptions, getTrendingTagsQueryOptions, getUser, makeQueryClient, parseAsset, parseProfileMetadata, roleMap, useAccountFavouriteAdd, useAccountFavouriteDelete, useAccountRelationsUpdate, useAccountRevokeKey, useAccountRevokePosting, useAccountUpdate, useAccountUpdateKeyAuths, useAccountUpdatePassword, useAccountUpdateRecovery, useAddFragment, useBookmarkAdd, useBookmarkDelete, useBroadcastMutation, useEditFragment, useGameClaim, useRemoveFragment, useSignOperationByHivesigner, useSignOperationByKey, useSignOperationByKeychain };
|
|
1724
1750
|
//# sourceMappingURL=index.js.map
|
|
1725
1751
|
//# sourceMappingURL=index.js.map
|