@eluvio/elv-client-js 4.0.120 → 4.0.122
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/README.md +1 -1
- package/dist/ElvClient-min.js +6 -6
- package/dist/ElvClient-node-min.js +6 -6
- package/dist/ElvFrameClient-min.js +2 -2
- package/dist/ElvWalletClient-min.js +6 -6
- package/dist/ElvWalletClient-node-min.js +9 -9
- package/dist/src/ElvClient.js +19 -13
- package/dist/src/FrameClient.js +1 -1
- package/dist/src/client/ABRPublishing.js +1 -1
- package/dist/src/client/ContentAccess.js +38 -30
- package/dist/src/client/LiveConf.js +1 -1
- package/dist/src/client/LiveStream.js +24 -11
- package/dist/src/client/Shares.js +284 -0
- package/dist/src/walletClient/ClientMethods.js +1 -1
- package/dist/src/walletClient/index.js +31 -122
- package/package.json +2 -2
- package/src/ElvClient.js +9 -2
- package/src/FrameClient.js +5 -0
- package/src/client/ABRPublishing.js +1 -1
- package/src/client/LiveStream.js +25 -12
- package/src/client/Shares.js +161 -0
- package/build/BuildDocs.js +0 -12
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Methods for creating and managing shared authorization tokens
|
|
3
|
+
*
|
|
4
|
+
* @module ElvClient/Shares
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const UrlJoin = require("url-join");
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Create a share
|
|
11
|
+
*
|
|
12
|
+
* @namedParams
|
|
13
|
+
* @param {string} objectId - The object to create a share for
|
|
14
|
+
* @param {Date} expiresAt - The expiration time of the share
|
|
15
|
+
* @param {Object=} params - Additional parameters
|
|
16
|
+
*
|
|
17
|
+
* @returns {Promise<Object>} - Info about the created share
|
|
18
|
+
*/
|
|
19
|
+
exports.CreateShare = async function({objectId, expiresAt, params={}}) {
|
|
20
|
+
const tenantId = await this.userProfileClient.TenantContractId();
|
|
21
|
+
|
|
22
|
+
params.object_id = objectId;
|
|
23
|
+
|
|
24
|
+
if(expiresAt) {
|
|
25
|
+
params.end_time = Math.floor(new Date(expiresAt).getTime() / 1000);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return await this.MakeAuthServiceRequest({
|
|
29
|
+
path: UrlJoin("as", "sharing", tenantId, "share"),
|
|
30
|
+
method: "POST",
|
|
31
|
+
body: params,
|
|
32
|
+
headers: {
|
|
33
|
+
Authorization: `Bearer ${this.signedToken}`
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* List shares associated with your tenancy
|
|
40
|
+
*
|
|
41
|
+
* @namedParams
|
|
42
|
+
* @param {string=} objectId - If specified, the results will be limited shares for the specified object
|
|
43
|
+
* @param {number=} limit=100 - Maximum number of results to return
|
|
44
|
+
* @param {number=} offset=0 - Offset from which to return results
|
|
45
|
+
*
|
|
46
|
+
* @returns {Promise<Array<Object>>} - Info about the shares
|
|
47
|
+
*/
|
|
48
|
+
exports.Shares = async function({objectId, limit=100, offset=0}={}) {
|
|
49
|
+
const tenantId = await this.userProfileClient.TenantContractId();
|
|
50
|
+
|
|
51
|
+
const response = await this.MakeAuthServiceRequest({
|
|
52
|
+
path: UrlJoin("as", "sharing", tenantId, "shares"),
|
|
53
|
+
method: objectId ? "POST" : "GET",
|
|
54
|
+
queryParams: { limit, offset },
|
|
55
|
+
body: objectId ? {object_id: objectId} : undefined,
|
|
56
|
+
format: "JSON",
|
|
57
|
+
headers: {
|
|
58
|
+
Authorization: `Bearer ${this.signedToken}`
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Convert dates from seconds to date strings
|
|
63
|
+
if(response && response.shares) {
|
|
64
|
+
response.shares = response.shares.map(share => ({
|
|
65
|
+
...share,
|
|
66
|
+
start_time: share.start_time ? new Date(share.start_time * 1000).toISOString() : null,
|
|
67
|
+
end_time: share.end_time ? new Date(share.end_time * 1000).toISOString() : null,
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return response;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Update the specified share
|
|
76
|
+
*
|
|
77
|
+
* @namedParams
|
|
78
|
+
* @param {string} shareId - The ID of the share to modify
|
|
79
|
+
* @param {Date=} expiresAt - The new expiration time of the share
|
|
80
|
+
* @param {Object=} params - Additional parameters
|
|
81
|
+
*
|
|
82
|
+
* @returns {Promise<Object>} - Info about the updated share
|
|
83
|
+
*/
|
|
84
|
+
exports.UpdateShare = async function({shareId, expiresAt, params={}}) {
|
|
85
|
+
const tenantId = await this.userProfileClient.TenantContractId();
|
|
86
|
+
|
|
87
|
+
if(expiresAt) {
|
|
88
|
+
params.end_time = Math.floor(new Date(expiresAt).getTime() / 1000);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return await this.MakeAuthServiceRequest({
|
|
92
|
+
path: UrlJoin("as", "sharing", tenantId, "share", shareId),
|
|
93
|
+
method: "PUT",
|
|
94
|
+
format: "JSON",
|
|
95
|
+
body: params,
|
|
96
|
+
headers: {
|
|
97
|
+
Authorization: `Bearer ${this.signedToken}`
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Revoke the specified share
|
|
104
|
+
*
|
|
105
|
+
* @namedParams
|
|
106
|
+
* @param {string} shareId - The ID of the share to modify
|
|
107
|
+
*/
|
|
108
|
+
exports.RevokeShare = async function({shareId}) {
|
|
109
|
+
const tenantId = await this.userProfileClient.TenantContractId();
|
|
110
|
+
|
|
111
|
+
return await this.MakeAuthServiceRequest({
|
|
112
|
+
path: UrlJoin("as", "sharing", tenantId, "share", shareId, "revoke"),
|
|
113
|
+
method: "PUT",
|
|
114
|
+
format: "JSON",
|
|
115
|
+
headers: {
|
|
116
|
+
Authorization: `Bearer ${this.signedToken}`
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Retrieve info about the specified share
|
|
123
|
+
*
|
|
124
|
+
* @namedParams
|
|
125
|
+
* @param {string} shareId - The ID of the share
|
|
126
|
+
*
|
|
127
|
+
* @returns {Promise<Object>} - Info about the share
|
|
128
|
+
*/
|
|
129
|
+
exports.ShareInfo = async function({shareId}) {
|
|
130
|
+
const {share} = await this.MakeAuthServiceRequest({
|
|
131
|
+
path: UrlJoin("as", "sharing", "share", shareId, "info"),
|
|
132
|
+
method: "GET",
|
|
133
|
+
format: "JSON"
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
if(share.start_time) {
|
|
137
|
+
share.start_time = new Date(share.start_time * 1000).toISOString();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if(share.end_time) {
|
|
141
|
+
share.end_time = new Date(share.end_time * 1000).toISOString();
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return share;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Retrieve the authorization token for the specified share
|
|
149
|
+
*
|
|
150
|
+
* @namedParams
|
|
151
|
+
* @param {string} shareId - The ID of the share
|
|
152
|
+
*
|
|
153
|
+
* @returns {Promise<Object>} - The authorization token for the share
|
|
154
|
+
*/
|
|
155
|
+
exports.RedeemShareToken = async function({shareId}) {
|
|
156
|
+
return (await this.MakeAuthServiceRequest({
|
|
157
|
+
path: UrlJoin("as", "sharing", "share", shareId, "token"),
|
|
158
|
+
method: "GET",
|
|
159
|
+
format: "JSON"
|
|
160
|
+
})).token;
|
|
161
|
+
};
|
package/build/BuildDocs.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const Showdown = require("showdown");
|
|
2
|
-
const fs = require("fs");
|
|
3
|
-
const Path = require("path");
|
|
4
|
-
|
|
5
|
-
Showdown.setFlavor("vanilla");
|
|
6
|
-
|
|
7
|
-
const markdownConverter = new Showdown.Converter();
|
|
8
|
-
|
|
9
|
-
const md = fs.readFileSync(Path.join(__dirname, "..", "docs", "abr", "index.md")).toString("utf-8");
|
|
10
|
-
const html = markdownConverter.makeHtml(md);
|
|
11
|
-
|
|
12
|
-
fs.writeFileSync(Path.join(__dirname, "..", "docs", "abr", "index.html"), html);
|