@ecency/sdk 1.3.4 → 1.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.d.ts +11 -1
- package/dist/browser/index.js +41 -23
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +44 -23
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +41 -23
- package/dist/node/index.mjs.map +1 -1
- package/package.json +17 -12
package/dist/browser/index.d.ts
CHANGED
|
@@ -466,6 +466,16 @@ declare function getAccountPendingRecoveryQueryOptions(username: string | undefi
|
|
|
466
466
|
};
|
|
467
467
|
};
|
|
468
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
|
+
|
|
469
479
|
declare function useSignOperationByKey(username: string | undefined): _tanstack_react_query.UseMutationResult<_hiveio_dhive.TransactionConfirmation, Error, {
|
|
470
480
|
operation: Operation;
|
|
471
481
|
keyOrSeed: string;
|
|
@@ -1029,4 +1039,4 @@ declare function getCommunityPermissions({ communityType, userRole, subscribed,
|
|
|
1029
1039
|
isModerator: boolean;
|
|
1030
1040
|
};
|
|
1031
1041
|
|
|
1032
|
-
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,29 +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
|
+
}
|
|
708
707
|
try {
|
|
709
|
-
const parsed = JSON.parse(
|
|
708
|
+
const parsed = JSON.parse(postingJsonMetadata);
|
|
710
709
|
if (parsed && typeof parsed === "object" && parsed.profile && typeof parsed.profile === "object") {
|
|
711
710
|
return parsed.profile;
|
|
712
711
|
}
|
|
713
|
-
} catch (
|
|
712
|
+
} catch (err) {
|
|
714
713
|
}
|
|
715
714
|
return {};
|
|
716
715
|
}
|
|
717
|
-
function
|
|
716
|
+
function extractAccountProfile(data) {
|
|
717
|
+
return parseProfileMetadata(data?.posting_json_metadata);
|
|
718
|
+
}
|
|
719
|
+
function buildProfileMetadata({
|
|
720
|
+
existingProfile,
|
|
718
721
|
profile,
|
|
719
|
-
tokens
|
|
720
|
-
data
|
|
722
|
+
tokens
|
|
721
723
|
}) {
|
|
722
|
-
const
|
|
723
|
-
|
|
724
|
-
|
|
724
|
+
const { tokens: profileTokens, version: _ignoredVersion, ...profileRest } = profile ?? {};
|
|
725
|
+
const metadata = R4.mergeDeep(
|
|
726
|
+
existingProfile ?? {},
|
|
727
|
+
profileRest
|
|
728
|
+
);
|
|
729
|
+
const nextTokens = tokens ?? profileTokens;
|
|
730
|
+
if (nextTokens && nextTokens.length > 0) {
|
|
731
|
+
metadata.tokens = nextTokens;
|
|
725
732
|
}
|
|
726
733
|
metadata.tokens = sanitizeTokens(metadata.tokens);
|
|
727
734
|
metadata.version = 2;
|
|
728
735
|
return metadata;
|
|
729
736
|
}
|
|
737
|
+
|
|
738
|
+
// src/modules/accounts/mutations/use-account-update.ts
|
|
730
739
|
function useAccountUpdate(username) {
|
|
731
740
|
const queryClient = useQueryClient();
|
|
732
741
|
const { data } = useQuery(getAccountFullQueryOptions(username));
|
|
@@ -737,6 +746,11 @@ function useAccountUpdate(username) {
|
|
|
737
746
|
if (!data) {
|
|
738
747
|
throw new Error("[SDK][Accounts] \u2013 cannot update not existing account");
|
|
739
748
|
}
|
|
749
|
+
const profile = buildProfileMetadata({
|
|
750
|
+
existingProfile: extractAccountProfile(data),
|
|
751
|
+
profile: payload.profile,
|
|
752
|
+
tokens: payload.tokens
|
|
753
|
+
});
|
|
740
754
|
return [
|
|
741
755
|
[
|
|
742
756
|
"account_update2",
|
|
@@ -745,7 +759,7 @@ function useAccountUpdate(username) {
|
|
|
745
759
|
json_metadata: "",
|
|
746
760
|
extensions: [],
|
|
747
761
|
posting_json_metadata: JSON.stringify({
|
|
748
|
-
profile
|
|
762
|
+
profile
|
|
749
763
|
})
|
|
750
764
|
}
|
|
751
765
|
]
|
|
@@ -757,8 +771,12 @@ function useAccountUpdate(username) {
|
|
|
757
771
|
if (!data2) {
|
|
758
772
|
return data2;
|
|
759
773
|
}
|
|
760
|
-
const obj =
|
|
761
|
-
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
|
+
});
|
|
762
780
|
return obj;
|
|
763
781
|
}
|
|
764
782
|
)
|
|
@@ -953,7 +971,7 @@ function useAccountUpdateKeyAuths(username, options) {
|
|
|
953
971
|
);
|
|
954
972
|
}
|
|
955
973
|
const prepareAuth = (keyName) => {
|
|
956
|
-
const auth =
|
|
974
|
+
const auth = R4.clone(accountData[keyName]);
|
|
957
975
|
auth.key_auths = dedupeAndSortKeyAuths(
|
|
958
976
|
keepCurrent ? auth.key_auths : [],
|
|
959
977
|
keys.map(
|
|
@@ -1024,9 +1042,9 @@ function useAccountRevokePosting(username, options) {
|
|
|
1024
1042
|
"[SDK][Accounts] \u2013\xA0cannot revoke posting for anonymous user"
|
|
1025
1043
|
);
|
|
1026
1044
|
}
|
|
1027
|
-
const posting =
|
|
1045
|
+
const posting = R4.pipe(
|
|
1028
1046
|
{},
|
|
1029
|
-
|
|
1047
|
+
R4.mergeDeep(data.posting)
|
|
1030
1048
|
);
|
|
1031
1049
|
posting.account_auths = posting.account_auths.filter(
|
|
1032
1050
|
([account]) => account !== accountName
|
|
@@ -1143,7 +1161,7 @@ function useAccountRevokeKey(username, options) {
|
|
|
1143
1161
|
);
|
|
1144
1162
|
}
|
|
1145
1163
|
const prepareAuth = (keyName) => {
|
|
1146
|
-
const auth =
|
|
1164
|
+
const auth = R4.clone(accountData[keyName]);
|
|
1147
1165
|
auth.key_auths = auth.key_auths.filter(
|
|
1148
1166
|
([key]) => key !== revokingKey.toString()
|
|
1149
1167
|
);
|
|
@@ -1728,6 +1746,6 @@ function getCommunityPermissions({
|
|
|
1728
1746
|
};
|
|
1729
1747
|
}
|
|
1730
1748
|
|
|
1731
|
-
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 };
|
|
1732
1750
|
//# sourceMappingURL=index.js.map
|
|
1733
1751
|
//# sourceMappingURL=index.js.map
|