@pnp/nodejs 2.10.0 → 2.13.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/LICENSE
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
SharePoint Patterns and Practices (PnP)
|
|
2
|
-
|
|
3
|
-
The MIT License (MIT)
|
|
4
|
-
|
|
5
|
-
Copyright (c) Microsoft Corporation
|
|
6
|
-
|
|
7
|
-
All rights reserved.
|
|
8
|
-
|
|
9
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
-
in the Software without restriction, including without limitation the rights
|
|
12
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
-
furnished to do so, subject to the following conditions:
|
|
15
|
-
|
|
16
|
-
The above copyright notice and this permission notice shall be included in all
|
|
17
|
-
copies or substantial portions of the Software.
|
|
18
|
-
|
|
19
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
-
SOFTWARE.
|
|
1
|
+
SharePoint Patterns and Practices (PnP)
|
|
2
|
+
|
|
3
|
+
The MIT License (MIT)
|
|
4
|
+
|
|
5
|
+
Copyright (c) Microsoft Corporation
|
|
6
|
+
|
|
7
|
+
All rights reserved.
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
package/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import "./sp-extensions/index.js";
|
|
2
|
-
import * as SPNS from "./sp-extensions/index.js";
|
|
3
|
-
export { SPNS, };
|
|
4
|
-
export { AADToken, SPOAuthEnv } from "./types.js";
|
|
5
|
-
export { ProviderHostedRequestContext } from "./providerhosted.js";
|
|
6
|
-
export * from "./net/index.js";
|
|
7
|
-
export { setProxyUrl, setProxyAgent } from "./net/proxy.js";
|
|
1
|
+
import "./sp-extensions/index.js";
|
|
2
|
+
import * as SPNS from "./sp-extensions/index.js";
|
|
3
|
+
export { SPNS, };
|
|
4
|
+
export { AADToken, SPOAuthEnv } from "./types.js";
|
|
5
|
+
export { ProviderHostedRequestContext } from "./providerhosted.js";
|
|
6
|
+
export * from "./net/index.js";
|
|
7
|
+
export { setProxyUrl, setProxyAgent } from "./net/proxy.js";
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import * as NodeFetch from "node-fetch";
|
|
2
|
-
(function (g) {
|
|
3
|
-
// patch these globally for nodejs
|
|
4
|
-
if (!g.Headers) {
|
|
5
|
-
g.Headers = NodeFetch.Headers;
|
|
6
|
-
}
|
|
7
|
-
if (!g.Request) {
|
|
8
|
-
g.Request = NodeFetch.Request;
|
|
9
|
-
}
|
|
10
|
-
if (!g.Response) {
|
|
11
|
-
g.Response = NodeFetch.Response;
|
|
12
|
-
}
|
|
13
|
-
})(global);
|
|
14
|
-
// auto populate all extensions
|
|
15
|
-
import "./sp-extensions/index.js";
|
|
16
|
-
// export extension types as a namespace
|
|
17
|
-
import * as SPNS from "./sp-extensions/index.js";
|
|
18
|
-
export { SPNS, };
|
|
19
|
-
export { SPOAuthEnv } from "./types.js";
|
|
20
|
-
export { ProviderHostedRequestContext } from "./providerhosted.js";
|
|
21
|
-
export * from "./net/index.js";
|
|
22
|
-
export { setProxyUrl, setProxyAgent } from "./net/proxy.js";
|
|
1
|
+
import * as NodeFetch from "node-fetch";
|
|
2
|
+
(function (g) {
|
|
3
|
+
// patch these globally for nodejs
|
|
4
|
+
if (!g.Headers) {
|
|
5
|
+
g.Headers = NodeFetch.Headers;
|
|
6
|
+
}
|
|
7
|
+
if (!g.Request) {
|
|
8
|
+
g.Request = NodeFetch.Request;
|
|
9
|
+
}
|
|
10
|
+
if (!g.Response) {
|
|
11
|
+
g.Response = NodeFetch.Response;
|
|
12
|
+
}
|
|
13
|
+
})(global);
|
|
14
|
+
// auto populate all extensions
|
|
15
|
+
import "./sp-extensions/index.js";
|
|
16
|
+
// export extension types as a namespace
|
|
17
|
+
import * as SPNS from "./sp-extensions/index.js";
|
|
18
|
+
export { SPNS, };
|
|
19
|
+
export { SPOAuthEnv } from "./types.js";
|
|
20
|
+
export { ProviderHostedRequestContext } from "./providerhosted.js";
|
|
21
|
+
export * from "./net/index.js";
|
|
22
|
+
export { setProxyUrl, setProxyAgent } from "./net/proxy.js";
|
|
23
23
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { TokenResponse } from "adal-node";
|
|
2
|
-
import { IHttpClientImpl } from "@pnp/common";
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* Creates a fetch client that will aquire an access token using the client credentials
|
|
6
|
-
* flow with a certificate as the credentials. Used for app only or server-to-server api
|
|
7
|
-
* requests.
|
|
8
|
-
*
|
|
9
|
-
* See https://docs.microsoft.com/en-us/azure/active-directory/develop/v1-oauth2-client-creds-grant-flow#service-to-service-access-token-request
|
|
10
|
-
*/
|
|
11
|
-
export declare class AdalCertificateFetchClient implements IHttpClientImpl {
|
|
12
|
-
private _tenant;
|
|
13
|
-
private _clientId;
|
|
14
|
-
private _thumbprint;
|
|
15
|
-
private _privateKey;
|
|
16
|
-
private _resource;
|
|
17
|
-
private _authority;
|
|
18
|
-
protected _fetchClient: IHttpClientImpl;
|
|
19
|
-
private _authContext;
|
|
20
|
-
/**
|
|
21
|
-
*
|
|
22
|
-
* @param _tenant - Azure AD tenant id (guid)
|
|
23
|
-
* @param _clientId - Client Id from Azure AD app registration
|
|
24
|
-
* @param _thumbprint - Thumbprint of the client certificate
|
|
25
|
-
* @param _privateKey - The private key for the client certificate used to sign requests
|
|
26
|
-
* @param _resource - The resource the application is requesting access to i.e. https://graph.microsoft.com, https://<tenant>.sharepoint.com, etc
|
|
27
|
-
* @param _authority - OAuth 2 authority. Defaults to https://login.windows.net as is the authority in most cases
|
|
28
|
-
* @param _fetchClient - The fetch client implementation to use when making HTTP request. Defautls to NodeFetchClient to provide transient retries.
|
|
29
|
-
*/
|
|
30
|
-
constructor(_tenant: string, _clientId: string, _thumbprint: string, _privateKey: string, _resource?: string, _authority?: string, _fetchClient?: IHttpClientImpl);
|
|
31
|
-
fetch(url: string, options?: any): Promise<Response>;
|
|
32
|
-
acquireToken(): Promise<TokenResponse>;
|
|
33
|
-
}
|
|
1
|
+
import { TokenResponse } from "adal-node";
|
|
2
|
+
import { IHttpClientImpl } from "@pnp/common";
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* Creates a fetch client that will aquire an access token using the client credentials
|
|
6
|
+
* flow with a certificate as the credentials. Used for app only or server-to-server api
|
|
7
|
+
* requests.
|
|
8
|
+
*
|
|
9
|
+
* See https://docs.microsoft.com/en-us/azure/active-directory/develop/v1-oauth2-client-creds-grant-flow#service-to-service-access-token-request
|
|
10
|
+
*/
|
|
11
|
+
export declare class AdalCertificateFetchClient implements IHttpClientImpl {
|
|
12
|
+
private _tenant;
|
|
13
|
+
private _clientId;
|
|
14
|
+
private _thumbprint;
|
|
15
|
+
private _privateKey;
|
|
16
|
+
private _resource;
|
|
17
|
+
private _authority;
|
|
18
|
+
protected _fetchClient: IHttpClientImpl;
|
|
19
|
+
private _authContext;
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @param _tenant - Azure AD tenant id (guid)
|
|
23
|
+
* @param _clientId - Client Id from Azure AD app registration
|
|
24
|
+
* @param _thumbprint - Thumbprint of the client certificate
|
|
25
|
+
* @param _privateKey - The private key for the client certificate used to sign requests
|
|
26
|
+
* @param _resource - The resource the application is requesting access to i.e. https://graph.microsoft.com, https://<tenant>.sharepoint.com, etc
|
|
27
|
+
* @param _authority - OAuth 2 authority. Defaults to https://login.windows.net as is the authority in most cases
|
|
28
|
+
* @param _fetchClient - The fetch client implementation to use when making HTTP request. Defautls to NodeFetchClient to provide transient retries.
|
|
29
|
+
*/
|
|
30
|
+
constructor(_tenant: string, _clientId: string, _thumbprint: string, _privateKey: string, _resource?: string, _authority?: string, _fetchClient?: IHttpClientImpl);
|
|
31
|
+
fetch(url: string, options?: any): Promise<Response>;
|
|
32
|
+
acquireToken(): Promise<TokenResponse>;
|
|
33
|
+
}
|
|
34
34
|
//# sourceMappingURL=adalcertificatefetchclient.d.ts.map
|
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
import { __awaiter, __generator } from "tslib";
|
|
2
|
-
import { AuthenticationContext } from "adal-node";
|
|
3
|
-
import { combine, objectDefinedNotNull, isUrlAbsolute, assign, } from "@pnp/common";
|
|
4
|
-
import { NodeFetchClient } from "./nodefetchclient.js";
|
|
5
|
-
/**
|
|
6
|
-
*
|
|
7
|
-
* Creates a fetch client that will aquire an access token using the client credentials
|
|
8
|
-
* flow with a certificate as the credentials. Used for app only or server-to-server api
|
|
9
|
-
* requests.
|
|
10
|
-
*
|
|
11
|
-
* See https://docs.microsoft.com/en-us/azure/active-directory/develop/v1-oauth2-client-creds-grant-flow#service-to-service-access-token-request
|
|
12
|
-
*/
|
|
13
|
-
var AdalCertificateFetchClient = /** @class */ (function () {
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
* @param _tenant - Azure AD tenant id (guid)
|
|
17
|
-
* @param _clientId - Client Id from Azure AD app registration
|
|
18
|
-
* @param _thumbprint - Thumbprint of the client certificate
|
|
19
|
-
* @param _privateKey - The private key for the client certificate used to sign requests
|
|
20
|
-
* @param _resource - The resource the application is requesting access to i.e. https://graph.microsoft.com, https://<tenant>.sharepoint.com, etc
|
|
21
|
-
* @param _authority - OAuth 2 authority. Defaults to https://login.windows.net as is the authority in most cases
|
|
22
|
-
* @param _fetchClient - The fetch client implementation to use when making HTTP request. Defautls to NodeFetchClient to provide transient retries.
|
|
23
|
-
*/
|
|
24
|
-
function AdalCertificateFetchClient(_tenant, _clientId, _thumbprint, _privateKey, _resource, _authority, _fetchClient) {
|
|
25
|
-
if (_resource === void 0) { _resource = "https://graph.microsoft.com"; }
|
|
26
|
-
if (_authority === void 0) { _authority = "https://login.windows.net"; }
|
|
27
|
-
if (_fetchClient === void 0) { _fetchClient = new NodeFetchClient(); }
|
|
28
|
-
this._tenant = _tenant;
|
|
29
|
-
this._clientId = _clientId;
|
|
30
|
-
this._thumbprint = _thumbprint;
|
|
31
|
-
this._privateKey = _privateKey;
|
|
32
|
-
this._resource = _resource;
|
|
33
|
-
this._authority = _authority;
|
|
34
|
-
this._fetchClient = _fetchClient;
|
|
35
|
-
this._authContext = new AuthenticationContext(combine(this._authority, this._tenant));
|
|
36
|
-
}
|
|
37
|
-
AdalCertificateFetchClient.prototype.fetch = function (url, options) {
|
|
38
|
-
if (options === void 0) { options = {}; }
|
|
39
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
40
|
-
var token;
|
|
41
|
-
return __generator(this, function (_a) {
|
|
42
|
-
switch (_a.label) {
|
|
43
|
-
case 0:
|
|
44
|
-
if (!objectDefinedNotNull(options)) {
|
|
45
|
-
options = {
|
|
46
|
-
headers: new Headers(),
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
else if (!objectDefinedNotNull(options.headers)) {
|
|
50
|
-
options = assign(options, {
|
|
51
|
-
headers: new Headers(),
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
if (!isUrlAbsolute(url)) {
|
|
55
|
-
url = combine(this._resource, url);
|
|
56
|
-
}
|
|
57
|
-
return [4 /*yield*/, this.acquireToken()];
|
|
58
|
-
case 1:
|
|
59
|
-
token = _a.sent();
|
|
60
|
-
options.headers.set("Authorization", token.tokenType + " " + token.accessToken);
|
|
61
|
-
return [4 /*yield*/, this._fetchClient.fetch(url, options)];
|
|
62
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
AdalCertificateFetchClient.prototype.acquireToken = function () {
|
|
68
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
69
|
-
var _this = this;
|
|
70
|
-
return __generator(this, function (_a) {
|
|
71
|
-
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
72
|
-
_this._authContext.acquireTokenWithClientCertificate(_this._resource, _this._clientId, _this._privateKey, _this._thumbprint, function (err, token) {
|
|
73
|
-
if (err) {
|
|
74
|
-
reject(err);
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
if (token.error) {
|
|
78
|
-
var tokenError = token;
|
|
79
|
-
reject(new Error("Error aquiring token. Error: '" + tokenError.error + "' Error Description: " + tokenError.errorDescription));
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
resolve(token);
|
|
83
|
-
});
|
|
84
|
-
})];
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
};
|
|
88
|
-
return AdalCertificateFetchClient;
|
|
89
|
-
}());
|
|
90
|
-
export { AdalCertificateFetchClient };
|
|
1
|
+
import { __awaiter, __generator } from "tslib";
|
|
2
|
+
import { AuthenticationContext } from "adal-node";
|
|
3
|
+
import { combine, objectDefinedNotNull, isUrlAbsolute, assign, } from "@pnp/common";
|
|
4
|
+
import { NodeFetchClient } from "./nodefetchclient.js";
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* Creates a fetch client that will aquire an access token using the client credentials
|
|
8
|
+
* flow with a certificate as the credentials. Used for app only or server-to-server api
|
|
9
|
+
* requests.
|
|
10
|
+
*
|
|
11
|
+
* See https://docs.microsoft.com/en-us/azure/active-directory/develop/v1-oauth2-client-creds-grant-flow#service-to-service-access-token-request
|
|
12
|
+
*/
|
|
13
|
+
var AdalCertificateFetchClient = /** @class */ (function () {
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @param _tenant - Azure AD tenant id (guid)
|
|
17
|
+
* @param _clientId - Client Id from Azure AD app registration
|
|
18
|
+
* @param _thumbprint - Thumbprint of the client certificate
|
|
19
|
+
* @param _privateKey - The private key for the client certificate used to sign requests
|
|
20
|
+
* @param _resource - The resource the application is requesting access to i.e. https://graph.microsoft.com, https://<tenant>.sharepoint.com, etc
|
|
21
|
+
* @param _authority - OAuth 2 authority. Defaults to https://login.windows.net as is the authority in most cases
|
|
22
|
+
* @param _fetchClient - The fetch client implementation to use when making HTTP request. Defautls to NodeFetchClient to provide transient retries.
|
|
23
|
+
*/
|
|
24
|
+
function AdalCertificateFetchClient(_tenant, _clientId, _thumbprint, _privateKey, _resource, _authority, _fetchClient) {
|
|
25
|
+
if (_resource === void 0) { _resource = "https://graph.microsoft.com"; }
|
|
26
|
+
if (_authority === void 0) { _authority = "https://login.windows.net"; }
|
|
27
|
+
if (_fetchClient === void 0) { _fetchClient = new NodeFetchClient(); }
|
|
28
|
+
this._tenant = _tenant;
|
|
29
|
+
this._clientId = _clientId;
|
|
30
|
+
this._thumbprint = _thumbprint;
|
|
31
|
+
this._privateKey = _privateKey;
|
|
32
|
+
this._resource = _resource;
|
|
33
|
+
this._authority = _authority;
|
|
34
|
+
this._fetchClient = _fetchClient;
|
|
35
|
+
this._authContext = new AuthenticationContext(combine(this._authority, this._tenant));
|
|
36
|
+
}
|
|
37
|
+
AdalCertificateFetchClient.prototype.fetch = function (url, options) {
|
|
38
|
+
if (options === void 0) { options = {}; }
|
|
39
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
40
|
+
var token;
|
|
41
|
+
return __generator(this, function (_a) {
|
|
42
|
+
switch (_a.label) {
|
|
43
|
+
case 0:
|
|
44
|
+
if (!objectDefinedNotNull(options)) {
|
|
45
|
+
options = {
|
|
46
|
+
headers: new Headers(),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
else if (!objectDefinedNotNull(options.headers)) {
|
|
50
|
+
options = assign(options, {
|
|
51
|
+
headers: new Headers(),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
if (!isUrlAbsolute(url)) {
|
|
55
|
+
url = combine(this._resource, url);
|
|
56
|
+
}
|
|
57
|
+
return [4 /*yield*/, this.acquireToken()];
|
|
58
|
+
case 1:
|
|
59
|
+
token = _a.sent();
|
|
60
|
+
options.headers.set("Authorization", token.tokenType + " " + token.accessToken);
|
|
61
|
+
return [4 /*yield*/, this._fetchClient.fetch(url, options)];
|
|
62
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
AdalCertificateFetchClient.prototype.acquireToken = function () {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
69
|
+
var _this = this;
|
|
70
|
+
return __generator(this, function (_a) {
|
|
71
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
72
|
+
_this._authContext.acquireTokenWithClientCertificate(_this._resource, _this._clientId, _this._privateKey, _this._thumbprint, function (err, token) {
|
|
73
|
+
if (err) {
|
|
74
|
+
reject(err);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (token.error) {
|
|
78
|
+
var tokenError = token;
|
|
79
|
+
reject(new Error("Error aquiring token. Error: '" + tokenError.error + "' Error Description: " + tokenError.errorDescription));
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
resolve(token);
|
|
83
|
+
});
|
|
84
|
+
})];
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
return AdalCertificateFetchClient;
|
|
89
|
+
}());
|
|
90
|
+
export { AdalCertificateFetchClient };
|
|
91
91
|
//# sourceMappingURL=adalcertificatefetchclient.js.map
|
package/net/adalfetchclient.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { AADToken } from "../types.js";
|
|
2
|
-
import { IHttpClientImpl } from "@pnp/common";
|
|
3
|
-
export declare class AdalFetchClient implements IHttpClientImpl {
|
|
4
|
-
private _tenant;
|
|
5
|
-
private _clientId;
|
|
6
|
-
private _secret;
|
|
7
|
-
private _resource;
|
|
8
|
-
private _authority;
|
|
9
|
-
private authContext;
|
|
10
|
-
constructor(_tenant: string, _clientId: string, _secret: string, _resource?: string, _authority?: string);
|
|
11
|
-
fetch(url: string, options: any): Promise<Response>;
|
|
12
|
-
acquireToken(): Promise<AADToken>;
|
|
13
|
-
}
|
|
1
|
+
import { AADToken } from "../types.js";
|
|
2
|
+
import { IHttpClientImpl } from "@pnp/common";
|
|
3
|
+
export declare class AdalFetchClient implements IHttpClientImpl {
|
|
4
|
+
private _tenant;
|
|
5
|
+
private _clientId;
|
|
6
|
+
private _secret;
|
|
7
|
+
private _resource;
|
|
8
|
+
private _authority;
|
|
9
|
+
private authContext;
|
|
10
|
+
constructor(_tenant: string, _clientId: string, _secret: string, _resource?: string, _authority?: string);
|
|
11
|
+
fetch(url: string, options: any): Promise<Response>;
|
|
12
|
+
acquireToken(): Promise<AADToken>;
|
|
13
|
+
}
|
|
14
14
|
//# sourceMappingURL=adalfetchclient.d.ts.map
|
package/net/adalfetchclient.js
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { AuthenticationContext } from "adal-node";
|
|
2
|
-
import { combine, objectDefinedNotNull, isUrlAbsolute, assign, } from "@pnp/common";
|
|
3
|
-
import { fetch } from "./fetch.js";
|
|
4
|
-
var AdalFetchClient = /** @class */ (function () {
|
|
5
|
-
function AdalFetchClient(_tenant, _clientId, _secret, _resource, _authority) {
|
|
6
|
-
if (_resource === void 0) { _resource = "https://graph.microsoft.com"; }
|
|
7
|
-
if (_authority === void 0) { _authority = "https://login.windows.net"; }
|
|
8
|
-
this._tenant = _tenant;
|
|
9
|
-
this._clientId = _clientId;
|
|
10
|
-
this._secret = _secret;
|
|
11
|
-
this._resource = _resource;
|
|
12
|
-
this._authority = _authority;
|
|
13
|
-
this.authContext = new AuthenticationContext(combine(this._authority, this._tenant));
|
|
14
|
-
}
|
|
15
|
-
AdalFetchClient.prototype.fetch = function (url, options) {
|
|
16
|
-
if (!objectDefinedNotNull(options)) {
|
|
17
|
-
options = {
|
|
18
|
-
headers: new Headers(),
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
else if (!objectDefinedNotNull(options.headers)) {
|
|
22
|
-
options = assign(options, {
|
|
23
|
-
headers: new Headers(),
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
if (!isUrlAbsolute(url)) {
|
|
27
|
-
url = combine(this._resource, url);
|
|
28
|
-
}
|
|
29
|
-
return this.acquireToken().then(function (token) {
|
|
30
|
-
options.headers.set("Authorization", token.tokenType + " " + token.accessToken);
|
|
31
|
-
return fetch(url, options);
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
AdalFetchClient.prototype.acquireToken = function () {
|
|
35
|
-
var _this = this;
|
|
36
|
-
return new Promise(function (resolve, reject) {
|
|
37
|
-
_this.authContext.acquireTokenWithClientCredentials(_this._resource, _this._clientId, _this._secret, function (err, token) {
|
|
38
|
-
if (err) {
|
|
39
|
-
reject(err);
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
resolve(token);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
return AdalFetchClient;
|
|
48
|
-
}());
|
|
49
|
-
export { AdalFetchClient };
|
|
1
|
+
import { AuthenticationContext } from "adal-node";
|
|
2
|
+
import { combine, objectDefinedNotNull, isUrlAbsolute, assign, } from "@pnp/common";
|
|
3
|
+
import { fetch } from "./fetch.js";
|
|
4
|
+
var AdalFetchClient = /** @class */ (function () {
|
|
5
|
+
function AdalFetchClient(_tenant, _clientId, _secret, _resource, _authority) {
|
|
6
|
+
if (_resource === void 0) { _resource = "https://graph.microsoft.com"; }
|
|
7
|
+
if (_authority === void 0) { _authority = "https://login.windows.net"; }
|
|
8
|
+
this._tenant = _tenant;
|
|
9
|
+
this._clientId = _clientId;
|
|
10
|
+
this._secret = _secret;
|
|
11
|
+
this._resource = _resource;
|
|
12
|
+
this._authority = _authority;
|
|
13
|
+
this.authContext = new AuthenticationContext(combine(this._authority, this._tenant));
|
|
14
|
+
}
|
|
15
|
+
AdalFetchClient.prototype.fetch = function (url, options) {
|
|
16
|
+
if (!objectDefinedNotNull(options)) {
|
|
17
|
+
options = {
|
|
18
|
+
headers: new Headers(),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
else if (!objectDefinedNotNull(options.headers)) {
|
|
22
|
+
options = assign(options, {
|
|
23
|
+
headers: new Headers(),
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
if (!isUrlAbsolute(url)) {
|
|
27
|
+
url = combine(this._resource, url);
|
|
28
|
+
}
|
|
29
|
+
return this.acquireToken().then(function (token) {
|
|
30
|
+
options.headers.set("Authorization", token.tokenType + " " + token.accessToken);
|
|
31
|
+
return fetch(url, options);
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
AdalFetchClient.prototype.acquireToken = function () {
|
|
35
|
+
var _this = this;
|
|
36
|
+
return new Promise(function (resolve, reject) {
|
|
37
|
+
_this.authContext.acquireTokenWithClientCredentials(_this._resource, _this._clientId, _this._secret, function (err, token) {
|
|
38
|
+
if (err) {
|
|
39
|
+
reject(err);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
resolve(token);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
return AdalFetchClient;
|
|
48
|
+
}());
|
|
49
|
+
export { AdalFetchClient };
|
|
50
50
|
//# sourceMappingURL=adalfetchclient.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { IHttpClientImpl, IFetchOptions } from "@pnp/common";
|
|
2
|
-
/**
|
|
3
|
-
* Makes requests using the fetch API adding the supplied token to the Authorization header
|
|
4
|
-
*/
|
|
5
|
-
export declare class BearerTokenFetchClient implements IHttpClientImpl {
|
|
6
|
-
private _token;
|
|
7
|
-
constructor(_token: string | null);
|
|
8
|
-
get token(): string;
|
|
9
|
-
set token(token: string);
|
|
10
|
-
fetch(url: string, options?: IFetchOptions): Promise<Response>;
|
|
11
|
-
}
|
|
1
|
+
import { IHttpClientImpl, IFetchOptions } from "@pnp/common";
|
|
2
|
+
/**
|
|
3
|
+
* Makes requests using the fetch API adding the supplied token to the Authorization header
|
|
4
|
+
*/
|
|
5
|
+
export declare class BearerTokenFetchClient implements IHttpClientImpl {
|
|
6
|
+
private _token;
|
|
7
|
+
constructor(_token: string | null);
|
|
8
|
+
get token(): string;
|
|
9
|
+
set token(token: string);
|
|
10
|
+
fetch(url: string, options?: IFetchOptions): Promise<Response>;
|
|
11
|
+
}
|
|
12
12
|
//# sourceMappingURL=bearertokenfetchclient.d.ts.map
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { mergeHeaders } from "@pnp/common";
|
|
2
|
-
import { fetch } from "./fetch.js";
|
|
3
|
-
/**
|
|
4
|
-
* Makes requests using the fetch API adding the supplied token to the Authorization header
|
|
5
|
-
*/
|
|
6
|
-
var BearerTokenFetchClient = /** @class */ (function () {
|
|
7
|
-
function BearerTokenFetchClient(_token) {
|
|
8
|
-
this._token = _token;
|
|
9
|
-
}
|
|
10
|
-
Object.defineProperty(BearerTokenFetchClient.prototype, "token", {
|
|
11
|
-
get: function () {
|
|
12
|
-
return this._token || "";
|
|
13
|
-
},
|
|
14
|
-
set: function (token) {
|
|
15
|
-
this._token = token;
|
|
16
|
-
},
|
|
17
|
-
enumerable: false,
|
|
18
|
-
configurable: true
|
|
19
|
-
});
|
|
20
|
-
BearerTokenFetchClient.prototype.fetch = function (url, options) {
|
|
21
|
-
if (options === void 0) { options = {}; }
|
|
22
|
-
var headers = new Headers();
|
|
23
|
-
mergeHeaders(headers, options.headers);
|
|
24
|
-
headers.set("Authorization", "Bearer " + this._token);
|
|
25
|
-
options.headers = headers;
|
|
26
|
-
return fetch(url, options);
|
|
27
|
-
};
|
|
28
|
-
return BearerTokenFetchClient;
|
|
29
|
-
}());
|
|
30
|
-
export { BearerTokenFetchClient };
|
|
1
|
+
import { mergeHeaders } from "@pnp/common";
|
|
2
|
+
import { fetch } from "./fetch.js";
|
|
3
|
+
/**
|
|
4
|
+
* Makes requests using the fetch API adding the supplied token to the Authorization header
|
|
5
|
+
*/
|
|
6
|
+
var BearerTokenFetchClient = /** @class */ (function () {
|
|
7
|
+
function BearerTokenFetchClient(_token) {
|
|
8
|
+
this._token = _token;
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(BearerTokenFetchClient.prototype, "token", {
|
|
11
|
+
get: function () {
|
|
12
|
+
return this._token || "";
|
|
13
|
+
},
|
|
14
|
+
set: function (token) {
|
|
15
|
+
this._token = token;
|
|
16
|
+
},
|
|
17
|
+
enumerable: false,
|
|
18
|
+
configurable: true
|
|
19
|
+
});
|
|
20
|
+
BearerTokenFetchClient.prototype.fetch = function (url, options) {
|
|
21
|
+
if (options === void 0) { options = {}; }
|
|
22
|
+
var headers = new Headers();
|
|
23
|
+
mergeHeaders(headers, options.headers);
|
|
24
|
+
headers.set("Authorization", "Bearer " + this._token);
|
|
25
|
+
options.headers = headers;
|
|
26
|
+
return fetch(url, options);
|
|
27
|
+
};
|
|
28
|
+
return BearerTokenFetchClient;
|
|
29
|
+
}());
|
|
30
|
+
export { BearerTokenFetchClient };
|
|
31
31
|
//# sourceMappingURL=bearertokenfetchclient.js.map
|
package/net/fetch.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function fetch(url: string, options: any): Promise<any>;
|
|
1
|
+
export declare function fetch(url: string, options: any): Promise<any>;
|
|
2
2
|
//# sourceMappingURL=fetch.d.ts.map
|
package/net/fetch.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { configureProxyOptions } from "./proxy.js";
|
|
2
|
-
import { default as nodeFetch } from "node-fetch";
|
|
3
|
-
export function fetch(url, options) {
|
|
4
|
-
options = configureProxyOptions(options);
|
|
5
|
-
return nodeFetch(url, options);
|
|
6
|
-
}
|
|
1
|
+
import { configureProxyOptions } from "./proxy.js";
|
|
2
|
+
import { default as nodeFetch } from "node-fetch";
|
|
3
|
+
export function fetch(url, options) {
|
|
4
|
+
options = configureProxyOptions(options);
|
|
5
|
+
return nodeFetch(url, options);
|
|
6
|
+
}
|
|
7
7
|
//# sourceMappingURL=fetch.js.map
|
package/net/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
2
|
-
export { AdalCertificateFetchClient } from "./adalcertificatefetchclient.js";
|
|
3
|
-
export { AdalFetchClient } from "./adalfetchclient.js";
|
|
4
|
-
export { BearerTokenFetchClient } from "./bearertokenfetchclient.js";
|
|
5
|
-
export { NodeFetchClient } from "./nodefetchclient.js";
|
|
6
|
-
export { SPFetchClient } from "./spfetchclient.js";
|
|
7
|
-
export { MsalFetchClient } from "./msalfetchclient.js";
|
|
8
|
-
declare module "@pnp/common" {
|
|
9
|
-
interface IConfigOptions {
|
|
10
|
-
agent?: HttpsProxyAgent;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
1
|
+
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
2
|
+
export { AdalCertificateFetchClient } from "./adalcertificatefetchclient.js";
|
|
3
|
+
export { AdalFetchClient } from "./adalfetchclient.js";
|
|
4
|
+
export { BearerTokenFetchClient } from "./bearertokenfetchclient.js";
|
|
5
|
+
export { NodeFetchClient } from "./nodefetchclient.js";
|
|
6
|
+
export { SPFetchClient } from "./spfetchclient.js";
|
|
7
|
+
export { MsalFetchClient } from "./msalfetchclient.js";
|
|
8
|
+
declare module "@pnp/common" {
|
|
9
|
+
interface IConfigOptions {
|
|
10
|
+
agent?: HttpsProxyAgent;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
package/net/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { AdalCertificateFetchClient } from "./adalcertificatefetchclient.js";
|
|
2
|
-
export { AdalFetchClient } from "./adalfetchclient.js";
|
|
3
|
-
export { BearerTokenFetchClient } from "./bearertokenfetchclient.js";
|
|
4
|
-
export { NodeFetchClient } from "./nodefetchclient.js";
|
|
5
|
-
export { SPFetchClient } from "./spfetchclient.js";
|
|
6
|
-
export { MsalFetchClient } from "./msalfetchclient.js";
|
|
1
|
+
export { AdalCertificateFetchClient } from "./adalcertificatefetchclient.js";
|
|
2
|
+
export { AdalFetchClient } from "./adalfetchclient.js";
|
|
3
|
+
export { BearerTokenFetchClient } from "./bearertokenfetchclient.js";
|
|
4
|
+
export { NodeFetchClient } from "./nodefetchclient.js";
|
|
5
|
+
export { SPFetchClient } from "./spfetchclient.js";
|
|
6
|
+
export { MsalFetchClient } from "./msalfetchclient.js";
|
|
7
7
|
//# sourceMappingURL=index.js.map
|