@pnp/nodejs 2.8.0 → 2.12.0
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/LICENSE +25 -25
- package/index.d.ts +7 -7
- package/index.js +22 -22
- package/net/adalcertificatefetchclient.d.ts +33 -33
- package/net/adalcertificatefetchclient.js +90 -90
- package/net/adalfetchclient.d.ts +13 -13
- package/net/adalfetchclient.js +49 -49
- package/net/bearertokenfetchclient.d.ts +11 -11
- package/net/bearertokenfetchclient.js +30 -30
- package/net/fetch.d.ts +1 -1
- package/net/fetch.js +6 -6
- package/net/index.d.ts +12 -12
- package/net/index.js +6 -6
- package/net/msalfetchclient.d.ts +9 -9
- package/net/msalfetchclient.js +32 -32
- package/net/nodefetchclient.d.ts +23 -23
- package/net/nodefetchclient.js +117 -117
- package/net/proxy.d.ts +17 -17
- package/net/proxy.js +28 -28
- package/net/spfetchclient.d.ts +21 -21
- package/net/spfetchclient.js +110 -110
- package/package.json +5 -5
- package/providerhosted.d.ts +15 -15
- package/providerhosted.js +62 -62
- package/readme.md +21 -21
- package/sp-extensions/index.d.ts +2 -2
- package/sp-extensions/index.js +2 -2
- package/sp-extensions/stream.d.ts +29 -29
- package/sp-extensions/stream.d.ts.map +1 -1
- package/sp-extensions/stream.js +103 -106
- package/sp-extensions/stream.js.map +1 -1
- package/sptokenutils.d.ts +11 -11
- package/sptokenutils.js +111 -111
- package/types.d.ts +33 -33
- package/types.js +9 -9
package/net/spfetchclient.js
CHANGED
|
@@ -1,111 +1,111 @@
|
|
|
1
|
-
import { __awaiter, __generator } from "tslib";
|
|
2
|
-
import { combine, isUrlAbsolute } from "@pnp/common";
|
|
3
|
-
import { NodeFetchClient } from "./nodefetchclient.js";
|
|
4
|
-
import { getAddInOnlyAccessToken } from "../sptokenutils.js";
|
|
5
|
-
import { SPOAuthEnv } from "../types.js";
|
|
6
|
-
/**
|
|
7
|
-
* Fetch client for use within nodejs, requires you register a client id and secret with app only permissions.
|
|
8
|
-
*
|
|
9
|
-
* See either the MSAL client or ADAL client for more modern options
|
|
10
|
-
*/
|
|
11
|
-
var SPFetchClient = /** @class */ (function () {
|
|
12
|
-
function SPFetchClient(siteUrl, _clientId, _clientSecret, authEnv, _realm, _fetchClient) {
|
|
13
|
-
if (authEnv === void 0) { authEnv = SPOAuthEnv.SPO; }
|
|
14
|
-
if (_realm === void 0) { _realm = ""; }
|
|
15
|
-
if (_fetchClient === void 0) { _fetchClient = new NodeFetchClient(); }
|
|
16
|
-
this.siteUrl = siteUrl;
|
|
17
|
-
this._clientId = _clientId;
|
|
18
|
-
this._clientSecret = _clientSecret;
|
|
19
|
-
this.authEnv = authEnv;
|
|
20
|
-
this._realm = _realm;
|
|
21
|
-
this._fetchClient = _fetchClient;
|
|
22
|
-
this.token = null;
|
|
23
|
-
}
|
|
24
|
-
SPFetchClient.prototype.fetch = function (url, options) {
|
|
25
|
-
if (options === void 0) { options = {}; }
|
|
26
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
27
|
-
var realm, authUrl, token, uri;
|
|
28
|
-
return __generator(this, function (_a) {
|
|
29
|
-
switch (_a.label) {
|
|
30
|
-
case 0: return [4 /*yield*/, this.getRealm()];
|
|
31
|
-
case 1:
|
|
32
|
-
realm = _a.sent();
|
|
33
|
-
return [4 /*yield*/, this.getAuthUrl(realm)];
|
|
34
|
-
case 2:
|
|
35
|
-
authUrl = _a.sent();
|
|
36
|
-
return [4 /*yield*/, getAddInOnlyAccessToken(this.siteUrl, this._clientId, this._clientSecret, realm, authUrl)];
|
|
37
|
-
case 3:
|
|
38
|
-
token = _a.sent();
|
|
39
|
-
options.headers.set("Authorization", "Bearer " + token.access_token);
|
|
40
|
-
if (!options.headers.has("User-Agent")) {
|
|
41
|
-
// this marks the requests for understanding by the service
|
|
42
|
-
options.headers.append("User-Agent", "NONISV|SharePointPnP|PnPjs");
|
|
43
|
-
}
|
|
44
|
-
uri = !isUrlAbsolute(url) ? combine(this.siteUrl, url) : url;
|
|
45
|
-
return [2 /*return*/, this._fetchClient.fetch(uri, options)];
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
SPFetchClient.prototype.getAuthHostUrl = function (env) {
|
|
51
|
-
switch (env) {
|
|
52
|
-
case SPOAuthEnv.China:
|
|
53
|
-
return "accounts.accesscontrol.chinacloudapi.cn";
|
|
54
|
-
case SPOAuthEnv.Germany:
|
|
55
|
-
return "login.microsoftonline.de";
|
|
56
|
-
default:
|
|
57
|
-
return "accounts.accesscontrol.windows.net";
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
SPFetchClient.prototype.getRealm = function () {
|
|
61
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
62
|
-
var url, r, data, index;
|
|
63
|
-
return __generator(this, function (_a) {
|
|
64
|
-
switch (_a.label) {
|
|
65
|
-
case 0:
|
|
66
|
-
if (this._realm.length > 0) {
|
|
67
|
-
return [2 /*return*/, Promise.resolve(this._realm)];
|
|
68
|
-
}
|
|
69
|
-
url = combine(this.siteUrl, "_vti_bin/client.svc");
|
|
70
|
-
return [4 /*yield*/, this._fetchClient.fetch(url, {
|
|
71
|
-
"headers": {
|
|
72
|
-
"Authorization": "Bearer ",
|
|
73
|
-
},
|
|
74
|
-
"method": "POST",
|
|
75
|
-
})];
|
|
76
|
-
case 1:
|
|
77
|
-
r = _a.sent();
|
|
78
|
-
data = r.headers.get("www-authenticate") || "";
|
|
79
|
-
index = data.indexOf("Bearer realm=\"");
|
|
80
|
-
this._realm = data.substring(index + 14, index + 50);
|
|
81
|
-
return [2 /*return*/, this._realm];
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
};
|
|
86
|
-
SPFetchClient.prototype.getAuthUrl = function (realm) {
|
|
87
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
88
|
-
var url, r, json, eps;
|
|
89
|
-
return __generator(this, function (_a) {
|
|
90
|
-
switch (_a.label) {
|
|
91
|
-
case 0:
|
|
92
|
-
url = "https://" + this.getAuthHostUrl(this.authEnv) + "/metadata/json/1?realm=" + realm;
|
|
93
|
-
return [4 /*yield*/, this._fetchClient.fetch(url, { method: "GET" })];
|
|
94
|
-
case 1:
|
|
95
|
-
r = _a.sent();
|
|
96
|
-
return [4 /*yield*/, r.json()];
|
|
97
|
-
case 2:
|
|
98
|
-
json = _a.sent();
|
|
99
|
-
eps = json.endpoints.filter(function (ep) { return ep.protocol === "OAuth2"; });
|
|
100
|
-
if (eps.length > 0) {
|
|
101
|
-
return [2 /*return*/, eps[0].location];
|
|
102
|
-
}
|
|
103
|
-
throw Error("Auth URL Endpoint could not be determined from data.");
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
};
|
|
108
|
-
return SPFetchClient;
|
|
109
|
-
}());
|
|
110
|
-
export { SPFetchClient };
|
|
1
|
+
import { __awaiter, __generator } from "tslib";
|
|
2
|
+
import { combine, isUrlAbsolute } from "@pnp/common";
|
|
3
|
+
import { NodeFetchClient } from "./nodefetchclient.js";
|
|
4
|
+
import { getAddInOnlyAccessToken } from "../sptokenutils.js";
|
|
5
|
+
import { SPOAuthEnv } from "../types.js";
|
|
6
|
+
/**
|
|
7
|
+
* Fetch client for use within nodejs, requires you register a client id and secret with app only permissions.
|
|
8
|
+
*
|
|
9
|
+
* See either the MSAL client or ADAL client for more modern options
|
|
10
|
+
*/
|
|
11
|
+
var SPFetchClient = /** @class */ (function () {
|
|
12
|
+
function SPFetchClient(siteUrl, _clientId, _clientSecret, authEnv, _realm, _fetchClient) {
|
|
13
|
+
if (authEnv === void 0) { authEnv = SPOAuthEnv.SPO; }
|
|
14
|
+
if (_realm === void 0) { _realm = ""; }
|
|
15
|
+
if (_fetchClient === void 0) { _fetchClient = new NodeFetchClient(); }
|
|
16
|
+
this.siteUrl = siteUrl;
|
|
17
|
+
this._clientId = _clientId;
|
|
18
|
+
this._clientSecret = _clientSecret;
|
|
19
|
+
this.authEnv = authEnv;
|
|
20
|
+
this._realm = _realm;
|
|
21
|
+
this._fetchClient = _fetchClient;
|
|
22
|
+
this.token = null;
|
|
23
|
+
}
|
|
24
|
+
SPFetchClient.prototype.fetch = function (url, options) {
|
|
25
|
+
if (options === void 0) { options = {}; }
|
|
26
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
27
|
+
var realm, authUrl, token, uri;
|
|
28
|
+
return __generator(this, function (_a) {
|
|
29
|
+
switch (_a.label) {
|
|
30
|
+
case 0: return [4 /*yield*/, this.getRealm()];
|
|
31
|
+
case 1:
|
|
32
|
+
realm = _a.sent();
|
|
33
|
+
return [4 /*yield*/, this.getAuthUrl(realm)];
|
|
34
|
+
case 2:
|
|
35
|
+
authUrl = _a.sent();
|
|
36
|
+
return [4 /*yield*/, getAddInOnlyAccessToken(this.siteUrl, this._clientId, this._clientSecret, realm, authUrl)];
|
|
37
|
+
case 3:
|
|
38
|
+
token = _a.sent();
|
|
39
|
+
options.headers.set("Authorization", "Bearer " + token.access_token);
|
|
40
|
+
if (!options.headers.has("User-Agent")) {
|
|
41
|
+
// this marks the requests for understanding by the service
|
|
42
|
+
options.headers.append("User-Agent", "NONISV|SharePointPnP|PnPjs");
|
|
43
|
+
}
|
|
44
|
+
uri = !isUrlAbsolute(url) ? combine(this.siteUrl, url) : url;
|
|
45
|
+
return [2 /*return*/, this._fetchClient.fetch(uri, options)];
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
SPFetchClient.prototype.getAuthHostUrl = function (env) {
|
|
51
|
+
switch (env) {
|
|
52
|
+
case SPOAuthEnv.China:
|
|
53
|
+
return "accounts.accesscontrol.chinacloudapi.cn";
|
|
54
|
+
case SPOAuthEnv.Germany:
|
|
55
|
+
return "login.microsoftonline.de";
|
|
56
|
+
default:
|
|
57
|
+
return "accounts.accesscontrol.windows.net";
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
SPFetchClient.prototype.getRealm = function () {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
62
|
+
var url, r, data, index;
|
|
63
|
+
return __generator(this, function (_a) {
|
|
64
|
+
switch (_a.label) {
|
|
65
|
+
case 0:
|
|
66
|
+
if (this._realm.length > 0) {
|
|
67
|
+
return [2 /*return*/, Promise.resolve(this._realm)];
|
|
68
|
+
}
|
|
69
|
+
url = combine(this.siteUrl, "_vti_bin/client.svc");
|
|
70
|
+
return [4 /*yield*/, this._fetchClient.fetch(url, {
|
|
71
|
+
"headers": {
|
|
72
|
+
"Authorization": "Bearer ",
|
|
73
|
+
},
|
|
74
|
+
"method": "POST",
|
|
75
|
+
})];
|
|
76
|
+
case 1:
|
|
77
|
+
r = _a.sent();
|
|
78
|
+
data = r.headers.get("www-authenticate") || "";
|
|
79
|
+
index = data.indexOf("Bearer realm=\"");
|
|
80
|
+
this._realm = data.substring(index + 14, index + 50);
|
|
81
|
+
return [2 /*return*/, this._realm];
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
SPFetchClient.prototype.getAuthUrl = function (realm) {
|
|
87
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
88
|
+
var url, r, json, eps;
|
|
89
|
+
return __generator(this, function (_a) {
|
|
90
|
+
switch (_a.label) {
|
|
91
|
+
case 0:
|
|
92
|
+
url = "https://" + this.getAuthHostUrl(this.authEnv) + "/metadata/json/1?realm=" + realm;
|
|
93
|
+
return [4 /*yield*/, this._fetchClient.fetch(url, { method: "GET" })];
|
|
94
|
+
case 1:
|
|
95
|
+
r = _a.sent();
|
|
96
|
+
return [4 /*yield*/, r.json()];
|
|
97
|
+
case 2:
|
|
98
|
+
json = _a.sent();
|
|
99
|
+
eps = json.endpoints.filter(function (ep) { return ep.protocol === "OAuth2"; });
|
|
100
|
+
if (eps.length > 0) {
|
|
101
|
+
return [2 /*return*/, eps[0].location];
|
|
102
|
+
}
|
|
103
|
+
throw Error("Auth URL Endpoint could not be determined from data.");
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
return SPFetchClient;
|
|
109
|
+
}());
|
|
110
|
+
export { SPFetchClient };
|
|
111
111
|
//# sourceMappingURL=spfetchclient.js.map
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnp/nodejs",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.0",
|
|
4
4
|
"description": "pnp - provides functionality enabling the @pnp libraries within nodejs",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"typings": "./index",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@azure/msal-node": "^1.2.0",
|
|
9
|
-
"@pnp/common": "2.
|
|
10
|
-
"@pnp/logging": "2.
|
|
11
|
-
"@pnp/odata": "2.
|
|
12
|
-
"@pnp/sp": "2.
|
|
9
|
+
"@pnp/common": "2.12.0",
|
|
10
|
+
"@pnp/logging": "2.12.0",
|
|
11
|
+
"@pnp/odata": "2.12.0",
|
|
12
|
+
"@pnp/sp": "2.12.0",
|
|
13
13
|
"adal-node": "0.2.2",
|
|
14
14
|
"https-proxy-agent": "^5.0.0",
|
|
15
15
|
"jsonwebtoken": "8.5.1",
|
package/providerhosted.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { ProviderHostedConfigurationOptions } from "./types.js";
|
|
2
|
-
export declare class ProviderHostedRequestContext {
|
|
3
|
-
private siteUrl;
|
|
4
|
-
private clientId;
|
|
5
|
-
private clientSecret;
|
|
6
|
-
private realm;
|
|
7
|
-
private refreshToken;
|
|
8
|
-
private stsUri;
|
|
9
|
-
private cacheKey;
|
|
10
|
-
constructor(siteUrl: string, clientId: string, clientSecret: string, realm: string, refreshToken: string, stsUri: string, cacheKey: string);
|
|
11
|
-
static create(siteUrl: string, clientId: string, clientSecret: string, spAppToken: string): Promise<ProviderHostedRequestContext>;
|
|
12
|
-
getAddInOnlyConfig(): Promise<ProviderHostedConfigurationOptions>;
|
|
13
|
-
getUserConfig(): Promise<ProviderHostedConfigurationOptions>;
|
|
14
|
-
private getConfigOptions;
|
|
15
|
-
}
|
|
1
|
+
import { ProviderHostedConfigurationOptions } from "./types.js";
|
|
2
|
+
export declare class ProviderHostedRequestContext {
|
|
3
|
+
private siteUrl;
|
|
4
|
+
private clientId;
|
|
5
|
+
private clientSecret;
|
|
6
|
+
private realm;
|
|
7
|
+
private refreshToken;
|
|
8
|
+
private stsUri;
|
|
9
|
+
private cacheKey;
|
|
10
|
+
constructor(siteUrl: string, clientId: string, clientSecret: string, realm: string, refreshToken: string, stsUri: string, cacheKey: string);
|
|
11
|
+
static create(siteUrl: string, clientId: string, clientSecret: string, spAppToken: string): Promise<ProviderHostedRequestContext>;
|
|
12
|
+
getAddInOnlyConfig(): Promise<ProviderHostedConfigurationOptions>;
|
|
13
|
+
getUserConfig(): Promise<ProviderHostedConfigurationOptions>;
|
|
14
|
+
private getConfigOptions;
|
|
15
|
+
}
|
|
16
16
|
//# sourceMappingURL=providerhosted.d.ts.map
|
package/providerhosted.js
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
import { __awaiter, __generator } from "tslib";
|
|
2
|
-
import { validateProviderHostedRequestToken, getAddInOnlyAccessToken, getUserAccessToken } from "./sptokenutils.js";
|
|
3
|
-
var ProviderHostedRequestContext = /** @class */ (function () {
|
|
4
|
-
function ProviderHostedRequestContext(siteUrl, clientId, clientSecret, realm, refreshToken, stsUri, cacheKey) {
|
|
5
|
-
this.siteUrl = siteUrl;
|
|
6
|
-
this.clientId = clientId;
|
|
7
|
-
this.clientSecret = clientSecret;
|
|
8
|
-
this.realm = realm;
|
|
9
|
-
this.refreshToken = refreshToken;
|
|
10
|
-
this.stsUri = stsUri;
|
|
11
|
-
this.cacheKey = cacheKey;
|
|
12
|
-
}
|
|
13
|
-
ProviderHostedRequestContext.create = function (siteUrl, clientId, clientSecret, spAppToken) {
|
|
14
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
15
|
-
var payload, appctx;
|
|
16
|
-
return __generator(this, function (_a) {
|
|
17
|
-
switch (_a.label) {
|
|
18
|
-
case 0: return [4 /*yield*/, validateProviderHostedRequestToken(spAppToken, clientSecret)];
|
|
19
|
-
case 1:
|
|
20
|
-
payload = _a.sent();
|
|
21
|
-
appctx = JSON.parse(payload.appctx);
|
|
22
|
-
return [2 /*return*/, new ProviderHostedRequestContext(siteUrl, clientId, clientSecret, payload.iss.split("@")[1], payload.refreshtoken, appctx.SecurityTokenServiceUri, appctx.CacheKey)];
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
ProviderHostedRequestContext.prototype.getAddInOnlyConfig = function () {
|
|
28
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
29
|
-
var _a;
|
|
30
|
-
return __generator(this, function (_b) {
|
|
31
|
-
switch (_b.label) {
|
|
32
|
-
case 0:
|
|
33
|
-
_a = this.getConfigOptions;
|
|
34
|
-
return [4 /*yield*/, getAddInOnlyAccessToken(this.siteUrl, this.clientId, this.clientSecret, this.realm, this.stsUri)];
|
|
35
|
-
case 1: return [2 /*return*/, _a.apply(this, [_b.sent()])];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
ProviderHostedRequestContext.prototype.getUserConfig = function () {
|
|
41
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
42
|
-
var _a;
|
|
43
|
-
return __generator(this, function (_b) {
|
|
44
|
-
switch (_b.label) {
|
|
45
|
-
case 0:
|
|
46
|
-
_a = this.getConfigOptions;
|
|
47
|
-
return [4 /*yield*/, getUserAccessToken(this.siteUrl, this.clientId, this.clientSecret, this.refreshToken, this.realm, this.stsUri, this.cacheKey)];
|
|
48
|
-
case 1: return [2 /*return*/, _a.apply(this, [_b.sent()])];
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
ProviderHostedRequestContext.prototype.getConfigOptions = function (token) {
|
|
54
|
-
return {
|
|
55
|
-
headers: {
|
|
56
|
-
"Authorization": "Bearer " + token.access_token,
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
return ProviderHostedRequestContext;
|
|
61
|
-
}());
|
|
62
|
-
export { ProviderHostedRequestContext };
|
|
1
|
+
import { __awaiter, __generator } from "tslib";
|
|
2
|
+
import { validateProviderHostedRequestToken, getAddInOnlyAccessToken, getUserAccessToken } from "./sptokenutils.js";
|
|
3
|
+
var ProviderHostedRequestContext = /** @class */ (function () {
|
|
4
|
+
function ProviderHostedRequestContext(siteUrl, clientId, clientSecret, realm, refreshToken, stsUri, cacheKey) {
|
|
5
|
+
this.siteUrl = siteUrl;
|
|
6
|
+
this.clientId = clientId;
|
|
7
|
+
this.clientSecret = clientSecret;
|
|
8
|
+
this.realm = realm;
|
|
9
|
+
this.refreshToken = refreshToken;
|
|
10
|
+
this.stsUri = stsUri;
|
|
11
|
+
this.cacheKey = cacheKey;
|
|
12
|
+
}
|
|
13
|
+
ProviderHostedRequestContext.create = function (siteUrl, clientId, clientSecret, spAppToken) {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
15
|
+
var payload, appctx;
|
|
16
|
+
return __generator(this, function (_a) {
|
|
17
|
+
switch (_a.label) {
|
|
18
|
+
case 0: return [4 /*yield*/, validateProviderHostedRequestToken(spAppToken, clientSecret)];
|
|
19
|
+
case 1:
|
|
20
|
+
payload = _a.sent();
|
|
21
|
+
appctx = JSON.parse(payload.appctx);
|
|
22
|
+
return [2 /*return*/, new ProviderHostedRequestContext(siteUrl, clientId, clientSecret, payload.iss.split("@")[1], payload.refreshtoken, appctx.SecurityTokenServiceUri, appctx.CacheKey)];
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
ProviderHostedRequestContext.prototype.getAddInOnlyConfig = function () {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
29
|
+
var _a;
|
|
30
|
+
return __generator(this, function (_b) {
|
|
31
|
+
switch (_b.label) {
|
|
32
|
+
case 0:
|
|
33
|
+
_a = this.getConfigOptions;
|
|
34
|
+
return [4 /*yield*/, getAddInOnlyAccessToken(this.siteUrl, this.clientId, this.clientSecret, this.realm, this.stsUri)];
|
|
35
|
+
case 1: return [2 /*return*/, _a.apply(this, [_b.sent()])];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
ProviderHostedRequestContext.prototype.getUserConfig = function () {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
42
|
+
var _a;
|
|
43
|
+
return __generator(this, function (_b) {
|
|
44
|
+
switch (_b.label) {
|
|
45
|
+
case 0:
|
|
46
|
+
_a = this.getConfigOptions;
|
|
47
|
+
return [4 /*yield*/, getUserAccessToken(this.siteUrl, this.clientId, this.clientSecret, this.refreshToken, this.realm, this.stsUri, this.cacheKey)];
|
|
48
|
+
case 1: return [2 /*return*/, _a.apply(this, [_b.sent()])];
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
ProviderHostedRequestContext.prototype.getConfigOptions = function (token) {
|
|
54
|
+
return {
|
|
55
|
+
headers: {
|
|
56
|
+
"Authorization": "Bearer " + token.access_token,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
return ProviderHostedRequestContext;
|
|
61
|
+
}());
|
|
62
|
+
export { ProviderHostedRequestContext };
|
|
63
63
|
//# sourceMappingURL=providerhosted.js.map
|
package/readme.md
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-

|
|
2
|
-
|
|
3
|
-
The SharePoint Patterns and Practices client side libraries were created to help enable developers to do their best work, without worrying about the exact
|
|
4
|
-
REST api details. Built with feedback from the community they represent a way to simplify your day-to-day dev cycle while relying on tested and proven
|
|
5
|
-
patterns.
|
|
6
|
-
|
|
7
|
-
Please use [http://aka.ms/sppnp](http://aka.ms/sppnp) for the latest updates around the whole *SharePoint Patterns and Practices (PnP) initiative*.
|
|
8
|
-
|
|
9
|
-
## Source & Docs
|
|
10
|
-
|
|
11
|
-
This code is managed within the [main pnp repo](https://github.com/pnp/pnp), please report issues and submit pull requests there.
|
|
12
|
-
|
|
13
|
-
Please see the public site for [package documentation](https://pnp.github.io/pnpjs/).
|
|
14
|
-
|
|
15
|
-
### Code of Conduct
|
|
16
|
-
|
|
17
|
-
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
|
18
|
-
|
|
19
|
-
### "Sharing is Caring"
|
|
20
|
-
|
|
21
|
-
### Disclaimer
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
The SharePoint Patterns and Practices client side libraries were created to help enable developers to do their best work, without worrying about the exact
|
|
4
|
+
REST api details. Built with feedback from the community they represent a way to simplify your day-to-day dev cycle while relying on tested and proven
|
|
5
|
+
patterns.
|
|
6
|
+
|
|
7
|
+
Please use [http://aka.ms/sppnp](http://aka.ms/sppnp) for the latest updates around the whole *SharePoint Patterns and Practices (PnP) initiative*.
|
|
8
|
+
|
|
9
|
+
## Source & Docs
|
|
10
|
+
|
|
11
|
+
This code is managed within the [main pnp repo](https://github.com/pnp/pnp), please report issues and submit pull requests there.
|
|
12
|
+
|
|
13
|
+
Please see the public site for [package documentation](https://pnp.github.io/pnpjs/).
|
|
14
|
+
|
|
15
|
+
### Code of Conduct
|
|
16
|
+
|
|
17
|
+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
|
18
|
+
|
|
19
|
+
### "Sharing is Caring"
|
|
20
|
+
|
|
21
|
+
### Disclaimer
|
|
22
22
|
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**
|
package/sp-extensions/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./stream.js";
|
|
2
|
-
export * from "./stream.js";
|
|
1
|
+
import "./stream.js";
|
|
2
|
+
export * from "./stream.js";
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/sp-extensions/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./stream.js";
|
|
2
|
-
export * from "./stream.js";
|
|
1
|
+
import "./stream.js";
|
|
2
|
+
export * from "./stream.js";
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { ODataParser } from "@pnp/odata";
|
|
3
|
-
import { ReadStream } from "fs";
|
|
4
|
-
import { PassThrough } from "stream";
|
|
5
|
-
export interface IResponseBodyStream {
|
|
6
|
-
body: PassThrough;
|
|
7
|
-
knownLength: number;
|
|
8
|
-
}
|
|
9
|
-
export declare class StreamParser extends ODataParser<IResponseBodyStream> {
|
|
10
|
-
protected parseImpl(r: Response, resolve: (value: any) => void): void;
|
|
11
|
-
}
|
|
12
|
-
declare module "@pnp/sp/files/types" {
|
|
13
|
-
interface IFile {
|
|
14
|
-
/**
|
|
15
|
-
* Gets a PassThrough stream representing the file
|
|
16
|
-
*/
|
|
17
|
-
getStream(): Promise<IResponseBodyStream>;
|
|
18
|
-
/**
|
|
19
|
-
* Sets a file stream content chunk
|
|
20
|
-
*/
|
|
21
|
-
setStreamContentChunked(stream: ReadStream, progress?: (data: IFileUploadProgressData) => void, chunkSize?: number): Promise<IFileAddResult>;
|
|
22
|
-
}
|
|
23
|
-
interface IFiles {
|
|
24
|
-
/**
|
|
25
|
-
* Adds a file stream in chunks
|
|
26
|
-
*/
|
|
27
|
-
addChunked(url: string, content: Blob | ReadStream, progress?: (data: IFileUploadProgressData) => void, shouldOverWrite?: boolean, chunkSize?: number): Promise<IFileAddResult>;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ODataParser } from "@pnp/odata";
|
|
3
|
+
import { ReadStream } from "fs";
|
|
4
|
+
import { PassThrough } from "stream";
|
|
5
|
+
export interface IResponseBodyStream {
|
|
6
|
+
body: PassThrough;
|
|
7
|
+
knownLength: number;
|
|
8
|
+
}
|
|
9
|
+
export declare class StreamParser extends ODataParser<IResponseBodyStream> {
|
|
10
|
+
protected parseImpl(r: Response, resolve: (value: any) => void): void;
|
|
11
|
+
}
|
|
12
|
+
declare module "@pnp/sp/files/types" {
|
|
13
|
+
interface IFile {
|
|
14
|
+
/**
|
|
15
|
+
* Gets a PassThrough stream representing the file
|
|
16
|
+
*/
|
|
17
|
+
getStream(): Promise<IResponseBodyStream>;
|
|
18
|
+
/**
|
|
19
|
+
* Sets a file stream content chunk
|
|
20
|
+
*/
|
|
21
|
+
setStreamContentChunked(stream: ReadStream, progress?: (data: IFileUploadProgressData) => void, chunkSize?: number): Promise<IFileAddResult>;
|
|
22
|
+
}
|
|
23
|
+
interface IFiles {
|
|
24
|
+
/**
|
|
25
|
+
* Adds a file stream in chunks
|
|
26
|
+
*/
|
|
27
|
+
addChunked(url: string, content: Blob | ReadStream, progress?: (data: IFileUploadProgressData) => void, shouldOverWrite?: boolean, chunkSize?: number): Promise<IFileAddResult>;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
30
|
//# sourceMappingURL=stream.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../../../packages/nodejs/sp-extensions/stream.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAA0B,MAAM,YAAY,CAAC;AAGjE,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../../../packages/nodejs/sp-extensions/stream.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAA0B,MAAM,YAAY,CAAC;AAGjE,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAGrC,MAAM,WAAW,mBAAmB;IAChC,IAAI,EAAE,WAAW,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,qBAAa,YAAa,SAAQ,WAAW,CAAC,mBAAmB,CAAC;IAE9D,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI;CAGxE;AA2FD,OAAO,QAAQ,qBAAqB,CAAC;IAEjC,UAAU,KAAK;QACX;;WAEG;QACH,SAAS,IAAI,OAAO,CAAC,mBAAmB,CAAC,CAAC;QAE1C;;WAEG;QACH,uBAAuB,CACnB,MAAM,EAAE,UAAU,EAClB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,uBAAuB,KAAK,IAAI,EAClD,SAAS,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,cAAc,CAAC,CAAC;KAC9B;IAED,UAAU,MAAM;QACZ;;WAEG;QACH,UAAU,CACN,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,IAAI,GAAG,UAAU,EAC1B,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,uBAAuB,KAAK,IAAI,EAClD,eAAe,CAAC,EAAE,OAAO,EACzB,SAAS,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,cAAc,CAAC,CAAC;KAC9B;CACJ"}
|