deso-protocol
Advanced tools
Comparing version 0.1.5 to 0.1.6
{ | ||
"name": "deso-protocol", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"type": "commonjs", | ||
"dependencies": { | ||
"deso-protocol-types": "^0.1.0", | ||
"deso-protocol-types": "^0.2.0", | ||
"axios": "^0.25.0" | ||
@@ -8,0 +8,0 @@ }, |
@@ -1,3 +0,3 @@ | ||
import { Admin } from './lib/admin/Admin'; | ||
import { Identity } from './lib/identity/Identity'; | ||
import { Identity, IdentityConfig } from './lib/identity/Identity'; | ||
import { Media } from './lib/media/Media'; | ||
import { MetaData } from './lib/meta-data/MetaData'; | ||
@@ -11,11 +11,16 @@ import { Miner } from './lib/miner/Miner'; | ||
import { User } from './lib/user/User'; | ||
import { Node } from './lib/node/Node'; | ||
import { Node } from './lib/Node/Node'; | ||
import { Wallet } from './lib/wallet/Wallet'; | ||
import { Transactions } from './lib/transaction/Transaction'; | ||
import { DAO } from './lib/dao/dao'; | ||
export interface DesoConfig { | ||
nodeUri?: string; | ||
identityConfig?: IdentityConfig; | ||
} | ||
export declare class Deso { | ||
constructor(); | ||
constructor(config?: DesoConfig); | ||
node: Node; | ||
identity: Identity; | ||
admin: Admin; | ||
private media; | ||
private admin; | ||
media: Media; | ||
metaData: MetaData; | ||
@@ -27,2 +32,3 @@ miner: Miner; | ||
social: Social; | ||
dao: DAO; | ||
posts: Posts; | ||
@@ -32,3 +38,4 @@ transaction: typeof Transactions; | ||
referral: Referral; | ||
reinitialize(): void; | ||
} | ||
export default Deso; |
@@ -15,9 +15,10 @@ "use strict"; | ||
const User_1 = require("./lib/user/User"); | ||
const Node_1 = require("./lib/node/Node"); | ||
const Node_1 = require("./lib/Node/Node"); | ||
const Wallet_1 = require("./lib/wallet/Wallet"); | ||
const Transaction_1 = require("./lib/transaction/Transaction"); | ||
const dao_1 = require("./lib/dao/dao"); | ||
class Deso { | ||
constructor() { | ||
constructor(config) { | ||
this.node = new Node_1.Node(); | ||
this.identity = new Identity_1.Identity(this.node); | ||
this.identity = new Identity_1.Identity({ node: this.node }); | ||
this.admin = new Admin_1.Admin(this.node, this.identity); | ||
@@ -31,2 +32,3 @@ this.media = new Media_1.Media(this.node, this.identity); | ||
this.social = new Social_1.Social(this.node, this.identity, this.user); | ||
this.dao = new dao_1.DAO(this.node, this.identity); | ||
this.posts = new Posts_1.Posts(this.node, this.identity); | ||
@@ -36,4 +38,26 @@ this.transaction = Transaction_1.Transactions; | ||
this.referral = new Referral_1.Referral(this.node, this.identity); | ||
this.node = new Node_1.Node(); | ||
this.identity = new Identity_1.Identity({ | ||
...config === null || config === void 0 ? void 0 : config.identityConfig, | ||
...{ node: this.node }, | ||
}); | ||
this.identity.initialize(); | ||
this.reinitialize(); | ||
} | ||
// private tutorial = new Tutorial(this.node, this.identity); | ||
reinitialize() { | ||
this.admin = new Admin_1.Admin(this.node, this.identity); | ||
this.media = new Media_1.Media(this.node, this.identity); | ||
this.metaData = new MetaData_1.MetaData(this.node, this.identity); | ||
this.miner = new Miner_1.Miner(this.node, this.identity); | ||
this.nft = new Nft_1.Nft(this.node, this.identity); | ||
this.notification = new Notification_1.Notification(this.node, this.identity); | ||
this.user = new User_1.User(this.node, this.identity); | ||
this.social = new Social_1.Social(this.node, this.identity, this.user); | ||
this.dao = new dao_1.DAO(this.node, this.identity); | ||
this.posts = new Posts_1.Posts(this.node, this.identity); | ||
this.transaction = Transaction_1.Transactions; | ||
this.wallet = new Wallet_1.Wallet(this.node, this.identity); | ||
this.referral = new Referral_1.Referral(this.node, this.identity); | ||
} | ||
} | ||
@@ -40,0 +64,0 @@ exports.Deso = Deso; |
@@ -1,4 +0,3 @@ | ||
import { Node } from '../node/Node'; | ||
import { Node } from '../Node/Node'; | ||
import { Identity } from '../identity/Identity'; | ||
import { AdminGetAllUserGlobalMetadataRequest, AdminGetAllUserGlobalMetadataResponse, AdminGetMempoolStatsResponse, AdminGetVerifiedUsersResponse, AdminGrantVerificationBadgeRequest, AdminGrantVerificationBadgeResponse, AdminRemoveVerificationBadgeRequest, AdminRemoveVerificationBadgeResponse, AdminUpdateGlobalFeedRequest, GetGlobalParamsRequest, GetGlobalParamsResponse, GetUserGlobalMetadataRequest, GetUserGlobalMetadataResponse, NodeControlRequest, NodeControlResponse, SwapIdentityRequest, SwapIdentityResponse, UpdateGlobalParamsRequest, UpdateGlobalParamsResponse, UpdateUserGlobalMetadataRequest } from 'deso-protocol-types'; | ||
export declare class Admin { | ||
@@ -8,17 +7,2 @@ private node; | ||
constructor(node: Node, identity: Identity); | ||
nodeControl(request: Partial<NodeControlRequest>): Promise<NodeControlResponse>; | ||
getMemPoolStats(): Promise<AdminGetMempoolStatsResponse>; | ||
getGlobalParams(request: Partial<GetGlobalParamsRequest>): Promise<GetGlobalParamsResponse>; | ||
updateGlobalParams(request: Partial<UpdateGlobalParamsRequest>): Promise<UpdateGlobalParamsResponse>; | ||
swapIdentity(request: Partial<SwapIdentityRequest>): Promise<SwapIdentityResponse>; | ||
updateUserGlobalMetadata(request: Partial<UpdateUserGlobalMetadataRequest>): Promise<void>; | ||
getUserGlobalMetadata(request: Partial<GetUserGlobalMetadataRequest>): Promise<GetUserGlobalMetadataResponse>; | ||
getAllUserGlobalMetadata(request: Partial<AdminGetAllUserGlobalMetadataRequest>): Promise<AdminGetAllUserGlobalMetadataResponse>; | ||
grantVerificationBadgeRequest(request: Partial<AdminGrantVerificationBadgeRequest>): Promise<AdminGrantVerificationBadgeResponse>; | ||
removeVerificationBadge(request: Partial<AdminRemoveVerificationBadgeRequest>): Promise<AdminRemoveVerificationBadgeResponse>; | ||
getVerifiedUsers(): Promise<AdminGetVerifiedUsersResponse>; | ||
getUsernameVerificationAuditLogs(request: Partial<AdminRemoveVerificationBadgeRequest>): Promise<AdminRemoveVerificationBadgeResponse>; | ||
updateGlobalFeed(request: Partial<AdminUpdateGlobalFeedRequest>): Promise<void>; | ||
pinPost(request: Partial<AdminUpdateGlobalFeedRequest>): Promise<void>; | ||
removeNilPosts(request: Partial<AdminUpdateGlobalFeedRequest>): Promise<void>; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Admin = void 0; | ||
const axios_1 = require("axios"); | ||
class Admin { | ||
@@ -10,66 +9,4 @@ constructor(node, identity) { | ||
} | ||
async nodeControl(request) { | ||
const endpoint = 'node-control'; | ||
const JWT = await this.identity.getJwt(); | ||
request = { ...request, JWT }; | ||
return await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, request); | ||
} | ||
async getMemPoolStats() { | ||
const endpoint = 'get-mempool-stats'; | ||
return await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, {}); | ||
} | ||
async getGlobalParams(request) { | ||
const endpoint = 'get-global-params'; | ||
return await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, request); | ||
} | ||
async updateGlobalParams(request) { | ||
const endpoint = 'update-global-params'; | ||
return await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, request); | ||
} | ||
async swapIdentity(request) { | ||
const endpoint = 'swap-identity'; | ||
return await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, request); | ||
} | ||
async updateUserGlobalMetadata(request) { | ||
const endpoint = 'update-user-global-metadata'; | ||
return await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, request); | ||
} | ||
async getUserGlobalMetadata(request) { | ||
const endpoint = 'get-user-global-metadata'; | ||
return await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, request); | ||
} | ||
async getAllUserGlobalMetadata(request) { | ||
const endpoint = 'get-all-user-global-metadata'; | ||
return await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, request); | ||
} | ||
async grantVerificationBadgeRequest(request) { | ||
const endpoint = 'grant-verification-badge'; | ||
return await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, request); | ||
} | ||
async removeVerificationBadge(request) { | ||
const endpoint = 'remove-verification-badge'; | ||
return await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, request); | ||
} | ||
async getVerifiedUsers() { | ||
const endpoint = 'get-verified-users'; | ||
return await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, {}); | ||
} | ||
async getUsernameVerificationAuditLogs(request) { | ||
const endpoint = 'get-username-verification-audit-logs'; | ||
return await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, request); | ||
} | ||
async updateGlobalFeed(request) { | ||
const endpoint = 'update-global-feed'; | ||
return await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, request); | ||
} | ||
async pinPost(request) { | ||
const endpoint = 'pin-post'; | ||
return await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, request); | ||
} | ||
async removeNilPosts(request) { | ||
const endpoint = 'remove-nil-posts'; | ||
return await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, request); | ||
} | ||
} | ||
exports.Admin = Admin; | ||
//# sourceMappingURL=Admin.js.map |
@@ -1,6 +0,14 @@ | ||
import { Node } from '../node/Node'; | ||
import { AppendExtraDataRequest, GetDecryptMessagesRequest, GetDecryptMessagesResponse, LoginUser, SendMessageStatelessRequest } from 'deso-protocol-types'; | ||
import { Node } from '../Node/Node'; | ||
import { AppendExtraDataRequest, DerivedPrivateUserInfo, DeSoNetwork, GetDecryptMessagesRequest, GetDecryptMessagesResponse, IdentityDeriveParams, LoginUser, SendMessageStatelessRequest } from 'deso-protocol-types'; | ||
export interface IdentityConfig { | ||
node: Node; | ||
uri?: string; | ||
network?: DeSoNetwork; | ||
} | ||
export declare class Identity { | ||
private node; | ||
constructor(node: Node); | ||
private network; | ||
constructor(config: IdentityConfig); | ||
getUri(): string; | ||
setUri(uri: string): void; | ||
getIframe(): HTMLIFrameElement; | ||
@@ -15,2 +23,3 @@ getUser(): LoginUser | null; | ||
logout(publicKey: string): Promise<boolean>; | ||
derive(params: IdentityDeriveParams): Promise<DerivedPrivateUserInfo>; | ||
private setIdentityFrame; | ||
@@ -21,2 +30,3 @@ submitTransaction(TransactionHex: string, extraData?: Omit<AppendExtraDataRequest, 'TransactionHex'>): Promise<any>; | ||
getJwt(): Promise<string>; | ||
private isTestnet; | ||
} |
@@ -5,2 +5,3 @@ "use strict"; | ||
const WindowPrompts_1 = require("./WindowPrompts"); | ||
const deso_protocol_types_1 = require("deso-protocol-types"); | ||
const IdentityHelper_1 = require("./IdentityHelper"); | ||
@@ -10,6 +11,17 @@ const WindowHandler_1 = require("./WindowHandler"); | ||
const utils_1 = require("../../utils/utils"); | ||
const BaseUri_1 = require("../state/BaseUri"); | ||
const identityUriStorageKey = 'identity_uri'; | ||
class Identity { | ||
constructor(node) { | ||
this.node = node; | ||
constructor(config) { | ||
var _a; | ||
this.node = config.node; | ||
this.network = config.network || deso_protocol_types_1.DeSoNetwork.mainnet; | ||
this.setUri((_a = config.uri) !== null && _a !== void 0 ? _a : BaseUri_1.BASE_IDENTITY_URI); | ||
} | ||
getUri() { | ||
return localStorage.getItem(identityUriStorageKey) || BaseUri_1.BASE_IDENTITY_URI; | ||
} | ||
setUri(uri) { | ||
localStorage.setItem(identityUriStorageKey, uri); | ||
} | ||
getIframe() { | ||
@@ -38,3 +50,3 @@ return (0, IdentityHelper_1.getIframe)(); | ||
const windowHandler = (event) => { | ||
if (event.origin !== 'https://identity.deso.org') { | ||
if (event.origin !== this.getUri()) { | ||
return; | ||
@@ -47,3 +59,3 @@ } | ||
payload: {}, | ||
}, 'https://identity.deso.org'); | ||
}, this.getUri()); | ||
resolve(event.data); | ||
@@ -57,3 +69,3 @@ } | ||
async login(accessLevel = '4') { | ||
const prompt = (0, WindowPrompts_1.requestLogin)(accessLevel); | ||
const prompt = (0, WindowPrompts_1.requestLogin)(accessLevel, this.getUri(), this.isTestnet()); | ||
const { key, user } = await (0, WindowHandler_1.iFrameHandler)({ | ||
@@ -71,3 +83,3 @@ iFrameMethod: 'login', | ||
} | ||
const prompt = (0, WindowPrompts_1.requestLogout)(publicKey); | ||
const prompt = (0, WindowPrompts_1.requestLogout)(publicKey, this.getUri(), this.isTestnet()); | ||
const successful = await (0, WindowHandler_1.iFrameHandler)({ | ||
@@ -79,2 +91,17 @@ iFrameMethod: 'logout', | ||
} | ||
async derive(params) { | ||
const queryParams = { | ||
callback: params.callback, | ||
webview: params.webview, | ||
publicKey: params.publicKey, | ||
transactionSpendingLimitResponse: params.transactionSpendingLimitResponse ? encodeURIComponent(JSON.stringify(params.transactionSpendingLimitResponse)) : undefined, | ||
derivedPublicKey: params.derivedPublicKey, | ||
}; | ||
const prompt = (0, WindowPrompts_1.requestDerive)(queryParams, this.getUri(), this.isTestnet()); | ||
const derivedPrivateUser = await (0, WindowHandler_1.iFrameHandler)({ | ||
iFrameMethod: 'derive', | ||
data: { prompt }, | ||
}); | ||
return derivedPrivateUser; | ||
} | ||
setIdentityFrame(createNewIdentityFrame = false) { | ||
@@ -89,3 +116,3 @@ let frame = document.getElementById('identity'); | ||
frame = document.createElement('iframe'); | ||
frame.setAttribute('src', 'https://identity.deso.org/embed?v=2'); | ||
frame.setAttribute('src', `${this.getUri()}/embed?v=2`); | ||
frame.setAttribute('id', 'identity'); | ||
@@ -98,3 +125,3 @@ frame.style.width = '100vh'; | ||
frame.style.left = '0'; | ||
frame.style.right = '0'; | ||
frame.style.top = '0'; | ||
const root = document.getElementsByTagName('body')[0]; | ||
@@ -119,3 +146,3 @@ if (root) { | ||
// user does not exist get approval | ||
return (0, IdentityHelper_1.approveSignAndSubmit)(TransactionHex); | ||
return (0, IdentityHelper_1.approveSignAndSubmit)(TransactionHex, this.getUri(), this.isTestnet()); | ||
} | ||
@@ -147,4 +174,7 @@ } | ||
} | ||
isTestnet() { | ||
return this.network === deso_protocol_types_1.DeSoNetwork.testnet; | ||
} | ||
} | ||
exports.Identity = Identity; | ||
//# sourceMappingURL=Identity.js.map |
@@ -1,4 +0,4 @@ | ||
export declare type IframeMethods = 'sign' | 'encrypt' | 'decrypt' | 'jwt' | 'login' | 'logout'; | ||
export declare type IframeMethods = 'sign' | 'encrypt' | 'decrypt' | 'jwt' | 'login' | 'logout' | 'derive'; | ||
export declare const callIdentityMethodAndExecute: (attributeValue: unknown, method: IframeMethods) => Promise<any>; | ||
export declare const approveSignAndSubmit: (transactionHex: string) => Promise<any>; | ||
export declare const approveSignAndSubmit: (transactionHex: string, uri: string, testnet?: boolean | undefined) => Promise<any>; | ||
export declare const getIframe: () => HTMLIFrameElement; |
@@ -29,4 +29,4 @@ "use strict"; | ||
exports.callIdentityMethodAndExecute = callIdentityMethodAndExecute; | ||
const approveSignAndSubmit = (transactionHex) => { | ||
const prompt = (0, WindowPrompts_1.requestApproval)(transactionHex); | ||
const approveSignAndSubmit = (transactionHex, uri, testnet) => { | ||
const prompt = (0, WindowPrompts_1.requestApproval)(transactionHex, uri, testnet); | ||
return (0, WindowHandler_1.iFrameHandler)({ iFrameMethod: 'sign', data: { prompt } }); | ||
@@ -33,0 +33,0 @@ }; |
@@ -19,3 +19,3 @@ "use strict"; | ||
const handlers = async (event, windowHandler, info) => { | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p; | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q; | ||
if (info.iFrameMethod === 'sign') { | ||
@@ -73,3 +73,2 @@ if ((_b = (_a = event === null || event === void 0 ? void 0 : event.data) === null || _a === void 0 ? void 0 : _a.payload) === null || _b === void 0 ? void 0 : _b.signedTransactionHex) { | ||
if (event.data.payload.encryptedMessage) { | ||
console.log(event.data); | ||
info.data.resolve(event.data.payload.encryptedMessage); | ||
@@ -79,4 +78,9 @@ window.removeEventListener('message', windowHandler); | ||
} | ||
if (info.iFrameMethod === 'derive' && event.data.method === 'derive') { | ||
(_q = info.data.prompt) === null || _q === void 0 ? void 0 : _q.close(); | ||
info.data.resolve(event.data.payload); | ||
window.removeEventListener('derive', windowHandler); | ||
} | ||
}; | ||
exports.handlers = handlers; | ||
//# sourceMappingURL=WindowHandler.js.map |
@@ -1,3 +0,5 @@ | ||
export declare const requestApproval: (transactionHex: string) => Window; | ||
export declare const requestLogin: (accessLevel?: string) => Window; | ||
export declare const requestLogout: (publicKey: string) => Window; | ||
import { IdentityDeriveQueryParams } from "deso-protocol-types"; | ||
export declare const requestApproval: (transactionHex: string, uri: string, testnet?: boolean | undefined) => Window; | ||
export declare const requestLogin: (accessLevel: string | undefined, uri: string, testnet?: boolean | undefined) => Window; | ||
export declare const requestLogout: (publicKey: string, uri: string, testnet?: boolean | undefined) => Window; | ||
export declare const requestDerive: (params: IdentityDeriveQueryParams, uri: string, testnet?: boolean | undefined) => Window; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.requestLogout = exports.requestLogin = exports.requestApproval = void 0; | ||
const requestApproval = (transactionHex) => { | ||
const prompt = window.open(`https://identity.deso.org/approve?tx=${transactionHex}`, null, 'toolbar=no, width=800, height=1000, top=0, left=0'); | ||
exports.requestDerive = exports.requestLogout = exports.requestLogin = exports.requestApproval = void 0; | ||
const requestApproval = (transactionHex, uri, testnet) => { | ||
const prompt = window.open(`${uri}/approve?tx=${transactionHex}${getTestnetQueryParam(testnet)}`, null, 'toolbar=no, width=800, height=1000, top=0, left=0'); | ||
return prompt; | ||
}; | ||
exports.requestApproval = requestApproval; | ||
const requestLogin = (accessLevel = '4') => { | ||
const prompt = window.open(`https://identity.deso.org/log-in?accessLevelRequest=${accessLevel}&hideJumio=true`, null, 'toolbar=no, width=800, height=1000, top=0, left=0'); | ||
const requestLogin = (accessLevel = '4', uri, testnet) => { | ||
const prompt = window.open(`${uri}/log-in?accessLevelRequest=${accessLevel}&hideJumio=true${getTestnetQueryParam(testnet)}`, null, 'toolbar=no, width=800, height=1000, top=0, left=0'); | ||
return prompt; | ||
}; | ||
exports.requestLogin = requestLogin; | ||
const requestLogout = (publicKey) => { | ||
const prompt = window.open(`https://identity.deso.org/logout?publicKey=${publicKey}`, null, 'toolbar=no, width=800, height=1000, top=0, left=0'); | ||
const requestLogout = (publicKey, uri, testnet) => { | ||
const prompt = window.open(`${uri}/logout?publicKey=${publicKey}${getTestnetQueryParam(testnet)}`, null, 'toolbar=no, width=800, height=1000, top=0, left=0'); | ||
return prompt; | ||
}; | ||
exports.requestLogout = requestLogout; | ||
const requestDerive = (params, uri, testnet) => { | ||
const queryParams = Object.entries(params || {}). | ||
filter(([_, value]) => value !== null && value !== undefined). | ||
map(([key, value]) => `${key}=${value}`); | ||
const queryString = queryParams.length || !!testnet ? `?${queryParams.join("&")}${getTestnetQueryParam(testnet, !queryParams.length)}` : ""; | ||
const prompt = window.open(`${uri}/derive${queryString}`, null, 'toolbar=no, width=800, height=1000, top=0, left=0'); | ||
return prompt; | ||
}; | ||
exports.requestDerive = requestDerive; | ||
const getTestnetQueryParam = (testnet, excludeAmp) => { | ||
return `${!!testnet ? `${!!excludeAmp ? '' : '&'}testnet=true` : ''}`; | ||
}; | ||
//# sourceMappingURL=WindowPrompts.js.map |
import { GetFullTikTokURLRequest, GetFullTikTokURLResponse, GetVideoStatusRequest, GetVideoStatusResponse, UploadImageRequest, UploadImageResponse } from 'deso-protocol-types'; | ||
import { Node } from '../node/Node'; | ||
import { Node } from '../Node/Node'; | ||
import { Identity } from '../identity/Identity'; | ||
@@ -8,6 +8,6 @@ export declare class Media { | ||
constructor(node: Node, identity: Identity); | ||
uploadImage(request: Partial<UploadImageRequest>): Promise<UploadImageResponse>; | ||
uploadVideo(request: Partial<UploadImageRequest>): Promise<UploadImageResponse>; | ||
uploadImage(request: Partial<UploadImageRequest>): Promise<UploadImageResponse | void>; | ||
private uploadVideo; | ||
getVideoStatus(request: Partial<GetVideoStatusRequest>): Promise<GetVideoStatusResponse>; | ||
getFullTikTokUrl(request: Partial<GetFullTikTokURLRequest>): Promise<GetFullTikTokURLResponse>; | ||
} |
@@ -5,2 +5,5 @@ "use strict"; | ||
const axios_1 = require("axios"); | ||
const utils_1 = require("../../utils/utils"); | ||
// import * as tus from 'tus-js-client'; | ||
// import { uploadVideo } from './Tus.config'; | ||
class Media { | ||
@@ -12,11 +15,33 @@ constructor(node, identity) { | ||
async uploadImage(request) { | ||
const endpoint = 'upload-image'; | ||
const formData = new FormData(); | ||
formData.append('file', request.file); | ||
formData.append('UserPublicKeyBase58Check', request.UserPublicKeyBase58Check); | ||
formData.append('JWT', request.JWT); | ||
return await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, request); | ||
// eslint-disable-next-line @typescript-eslint/no-this-alias | ||
const nodeRef = this.node; | ||
const JWT = await this.identity.getJwt(); | ||
if (document && !request.file) { | ||
const input = document.createElement('input'); | ||
input.type = 'file'; | ||
input.click(); | ||
const waitForSelection = new Promise((resolve, reject) => { | ||
input.onchange = () => { | ||
input && input.files && input.files[0] | ||
? resolve(input.files[0]) | ||
: reject(new Error('No File selected')); | ||
}; | ||
}); | ||
return await waitForSelection.then(function (file) { | ||
if (file) { | ||
request.file = file; | ||
return uploadImageHelper(request, nodeRef, JWT); | ||
} | ||
return; | ||
}); | ||
} | ||
else if (request.file) { | ||
return uploadImageHelper(request, nodeRef, JWT); | ||
} | ||
(0, utils_1.throwErrors)(['UserPublicKeyBase58Check', 'file'], request); | ||
} | ||
async uploadVideo(request) { | ||
const endpoint = 'get-nfts-for-user'; | ||
// TODO | ||
const endpoint = ''; | ||
// uploadVideo(`${this.node.getUri()}/${endpoint}`); | ||
return await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, request); | ||
@@ -34,2 +59,10 @@ } | ||
exports.Media = Media; | ||
const uploadImageHelper = async (request, node, JWT) => { | ||
const endpoint = 'upload-image'; | ||
const formData = new FormData(); | ||
formData.append('file', request.file); | ||
formData.append('UserPublicKeyBase58Check', request.UserPublicKeyBase58Check); | ||
formData.append('JWT', JWT); | ||
return await (await axios_1.default.post(`${node.getUri()}/${endpoint}`, formData)).data; | ||
}; | ||
//# sourceMappingURL=Media.js.map |
import { Identity } from '../identity/Identity'; | ||
import { Node } from '../node/Node'; | ||
import { Node } from '../Node/Node'; | ||
import { GetAppStateRequest, GetAppStateResponse } from 'deso-protocol-types'; | ||
@@ -4,0 +4,0 @@ export declare class MetaData { |
@@ -1,2 +0,2 @@ | ||
import { Node } from '../node/Node'; | ||
import { Node } from '../Node/Node'; | ||
import { Identity } from '../identity/Identity'; | ||
@@ -3,0 +3,0 @@ import { GetBlockTemplateRequest, GetBlockTemplateResponse } from 'deso-protocol-types'; |
import { AcceptNFTBidRequest, AcceptNFTBidResponse, AcceptNFTTransferRequest, BurnNFTRequest, BurnNFTResponse, CreateNFTBidRequest, CreateNFTBidResponse, CreateNFTRequest, CreateNFTResponse, GetNextNFTShowcaseResponse, GetNFTBidsForNFTPostRequest, GetNFTBidsForNFTPostResponse, GetNFTBidsForUserRequest, GetNFTBidsForUserResponse, GetNFTCollectionSummaryRequest, GetNFTCollectionSummaryResponse, GetNFTEntriesForPostHashRequest, GetNFTEntriesForPostHashResponse, GetNFTsForUserRequest, GetNFTsForUserResponse, GetNFTShowcaseRequest, GetNFTShowcaseResponse, TransferNFTRequest, TransferNFTResponse, UpdateNFTRequest, UpdateNFTResponse } from 'deso-protocol-types'; | ||
import { Node } from '../node/Node'; | ||
import { Node } from '../Node/Node'; | ||
import { Identity } from '../identity/Identity'; | ||
@@ -4,0 +4,0 @@ export declare class Nft { |
import { GetNotificationsCountRequest, GetNotificationsCountResponse, GetNotificationsRequest, GetNotificationsResponse, SetNotificationMetadataRequest } from 'deso-protocol-types'; | ||
import { Node } from '../node/Node'; | ||
import { Node } from '../Node/Node'; | ||
import { Identity } from '../identity/Identity'; | ||
@@ -4,0 +4,0 @@ export declare class Notification { |
import { GetDiamondsForPostRequest, AppendExtraDataRequest, GetDiamondsForPostResponse, GetLikesForPostRequest, GetLikesForPostResponse, GetPostsDiamondedBySenderForReceiverRequest, GetPostsDiamondedBySenderForReceiverResponse, GetPostsForPublicKeyRequest, GetPostsForPublicKeyResponse, GetPostsStatelessRequest, GetPostsStatelessResponse, GetQuoteRepostsForPostRequest, GetQuoteRepostsForPostResponse, GetRepostsForPostRequest, GetSinglePostRequest, GetSinglePostResponse, HotFeedPageRequest, HotFeedPageResponse, SubmitPostRequest, SubmitPostResponse } from 'deso-protocol-types'; | ||
import { Identity } from '../identity/Identity'; | ||
import { Node } from '../node/Node'; | ||
import { Node } from '../Node/Node'; | ||
import { Transactions } from '../transaction/Transaction'; | ||
@@ -5,0 +5,0 @@ export declare class Posts { |
@@ -12,2 +12,8 @@ "use strict"; | ||
async getPostsForPublicKey(request) { | ||
// const request: Partial<GetPostsForPublicKeyRequest> = { | ||
// PublicKeyBase58Check: '', | ||
// Username, | ||
// ReaderPublicKeyBase58Check, | ||
// NumToFetch: 10, | ||
// }; | ||
return (await axios_1.default.post(`${this.node.getUri()}/get-posts-for-public-key`, request)).data; | ||
@@ -28,3 +34,3 @@ } | ||
.submitTransaction(apiResponse.TransactionHex, extraData) | ||
.then(() => apiResponse) | ||
.then((txn) => { apiResponse.PostHashHex = txn.data.TxnHashHex; return apiResponse; }) | ||
.catch(() => { | ||
@@ -36,3 +42,3 @@ throw Error('something went wrong while signing'); | ||
const endpoint = 'get-posts-stateless'; | ||
return await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, request); | ||
return await (await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, request)).data; | ||
} | ||
@@ -42,27 +48,27 @@ async getSinglePost(request) { | ||
const endpoint = 'get-single-post'; | ||
return await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, request); | ||
return await (await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, request)).data; | ||
} | ||
async getHotFeed(request) { | ||
const endpoint = 'get-hot-feed'; | ||
return await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, request); | ||
return await (await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, request)).data; | ||
} | ||
async getDiamondedPosts(request) { | ||
const endpoint = 'get-diamonded-posts'; | ||
return await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, request); | ||
return await (await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, request)).data; | ||
} | ||
async getLikesForPost(request) { | ||
const endpoint = 'get-likes-for-post'; | ||
return await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, request); | ||
return await (await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, request)).data; | ||
} | ||
async getDiamondsForPost(request) { | ||
const endpoint = 'get-diamonds-for-post'; | ||
return await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, request); | ||
return await (await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, request)).data; | ||
} | ||
async getRepostsForPost(request) { | ||
const endpoint = 'get-reposts-for-post'; | ||
return await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, request); | ||
return await (await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, request)).data; | ||
} | ||
async getQuoteRepostsForPost(request) { | ||
const endpoint = 'get-quote-reposts-for-post'; | ||
return await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, request); | ||
return await (await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, request)).data; | ||
} | ||
@@ -69,0 +75,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { Node } from '../node/Node'; | ||
import { Node } from '../Node/Node'; | ||
import { Identity } from '../identity/Identity'; | ||
@@ -3,0 +3,0 @@ import { GetReferralInfoForReferralHashRequest, GetReferralInfoForReferralHashResponse, GetReferralInfoForUserRequest, GetReferralInfoForUserResponse } from 'deso-protocol-types'; |
import { CreateFollowTxnStatelessRequest, CreateFollowTxnStatelessResponse, CreateLikeStatelessRequest, CreateLikeStatelessResponse, GetDecryptMessagesResponse, GetDiamondsForPublicKeyRequest, GetDiamondsForPublicKeyResponse, GetFollowsResponse, GetFollowsStatelessRequest, GetHodlersForPublicKeyRequest, GetHodlersForPublicKeyResponse, GetMessagesStatelessRequest, IsFolllowingPublicKeyResponse, IsFollowingPublicKeyRequest, IsHodlingPublicKeyRequest, IsHodlingPublicKeyResponse, SendDiamondsRequest, SendDiamondsResponse, SendMessageStatelessRequest, UpdateProfileRequest, UpdateProfileResponse } from 'deso-protocol-types'; | ||
import { Identity } from '../identity/Identity'; | ||
import { Node } from '../node/Node'; | ||
import { Node } from '../Node/Node'; | ||
import { User } from '../user/User'; | ||
@@ -5,0 +5,0 @@ export declare class Social { |
export declare const BASE_URI: Readonly<string>; | ||
export declare const BASE_IDENTITY_URI: Readonly<string>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BASE_URI = void 0; | ||
exports.BASE_IDENTITY_URI = exports.BASE_URI = void 0; | ||
exports.BASE_URI = 'https://node.deso.org/api/v0'; | ||
exports.BASE_IDENTITY_URI = 'https://identity.deso.org'; | ||
//# sourceMappingURL=BaseUri.js.map |
import { GetTutorialCreatorResponse, GetTutorialCreatorsRequest, StartOrSkipTutorialRequest, UpdateTutorialStatusRequest } from 'deso-protocol-types'; | ||
import { Identity } from '../identity/Identity'; | ||
import { Node } from '../node/Node'; | ||
import { Node } from '../Node/Node'; | ||
export declare class Tutorial { | ||
@@ -5,0 +5,0 @@ private node; |
import { Identity } from '../identity/Identity'; | ||
import { Node } from '../node/Node'; | ||
import { GetUsersResponse, GetUsersStatelessRequest, GetSingleProfileResponse, GetSingleProfileRequest, GetProfilesRequest, GetProfilesResponse, GetUserMetadataRequest, GetUserMetadataResponse, DeletePIIRequest, BlockPublicKeyRequest, GetUserDerivedKeysRequest, BlockPublicKeyResponse, GetUserDerivedKeysResponse } from 'deso-protocol-types'; | ||
import { Node } from '../Node/Node'; | ||
import { GetUsersResponse, GetUsersStatelessRequest, GetSingleProfileResponse, GetSingleProfileRequest, GetProfilesRequest, GetProfilesResponse, GetUserMetadataRequest, GetUserMetadataResponse, DeletePIIRequest, BlockPublicKeyRequest, GetUserDerivedKeysRequest, BlockPublicKeyResponse, GetUserDerivedKeysResponse, AuthorizeDerivedKeyResponse, AuthorizeDerivedKeyParams } from 'deso-protocol-types'; | ||
export declare class User { | ||
@@ -16,2 +16,3 @@ private node; | ||
getUserDerivedKeys(request: Partial<GetUserDerivedKeysRequest>): Promise<GetUserDerivedKeysResponse>; | ||
authorizeDerivedKey(request: Partial<AuthorizeDerivedKeyParams>, broadcast: boolean): Promise<AuthorizeDerivedKeyResponse>; | ||
} |
@@ -5,2 +5,3 @@ "use strict"; | ||
const axios_1 = require("axios"); | ||
const utils_1 = require("../../utils/utils"); | ||
class User { | ||
@@ -72,4 +73,36 @@ constructor(node, identity) { | ||
} | ||
async authorizeDerivedKey(request, broadcast) { | ||
(0, utils_1.throwErrors)(["MinFeeRateNanosPerKB"], request); | ||
const derivedPrivateUser = await this.identity.derive({ | ||
publicKey: this.identity.getUserKey() || undefined, | ||
transactionSpendingLimitResponse: request.TransactionSpendingLimitResponse, | ||
derivedPublicKey: request.DerivedPublicKeyBase58Check, | ||
}); | ||
const authorizeDerivedKeyRequest = { | ||
OwnerPublicKeyBase58Check: derivedPrivateUser.publicKeyBase58Check, | ||
DerivedPublicKeyBase58Check: derivedPrivateUser.derivedPublicKeyBase58Check, | ||
ExpirationBlock: derivedPrivateUser.expirationBlock, | ||
AccessSignature: derivedPrivateUser.accessSignature, | ||
DeleteKey: request.DeleteKey, | ||
ExtraData: request.ExtraData, | ||
TransactionSpendingLimitHex: derivedPrivateUser.transactionSpendingLimitHex, | ||
Memo: request.Memo, | ||
AppName: request.AppName, | ||
TransactionFees: request.TransactionFees, | ||
MinFeeRateNanosPerKB: request.MinFeeRateNanosPerKB, | ||
}; | ||
const endpoint = 'authorize-derived-key'; | ||
const apiResponse = (await axios_1.default.post(`${this.node.getUri()}/${endpoint}`, authorizeDerivedKeyRequest)).data; | ||
if (!broadcast) { | ||
return apiResponse; | ||
} | ||
return await this.identity | ||
.submitTransaction(apiResponse.TransactionHex) | ||
.then(() => apiResponse) | ||
.catch(() => { | ||
throw Error('something went wrong while signing'); | ||
}); | ||
} | ||
} | ||
exports.User = User; | ||
//# sourceMappingURL=User.js.map |
import { SendDeSoRequest, SendDeSoResponse, TransferCreatorCoinRequest, TransferCreatorCoinResponse } from 'deso-protocol-types'; | ||
import { Identity } from '../identity/Identity'; | ||
import { Node } from '../node/Node'; | ||
import { Node } from '../Node/Node'; | ||
export declare class Wallet { | ||
@@ -5,0 +5,0 @@ private node; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
121611
86
1575
+ Addeddeso-protocol-types@0.2.1(transitive)
- Removeddeso-protocol-types@0.1.0(transitive)
Updateddeso-protocol-types@^0.2.0