@pnp/azidjsclient 3.13.0-v3nightly.20230411
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 -0
- package/index.d.ts +9 -0
- package/index.d.ts.map +1 -0
- package/index.js +30 -0
- package/index.js.map +1 -0
- package/package.json +33 -0
- package/readme.md +21 -0
package/LICENSE
ADDED
|
@@ -0,0 +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.
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Queryable } from "@pnp/queryable/index.js";
|
|
2
|
+
import { AuthorizationCodeCredential, AzureCliCredential, AzurePowerShellCredential, ChainedTokenCredential, ClientAssertionCredential, ClientCertificateCredential, ClientSecretCredential, DefaultAzureCredential, DeviceCodeCredential, EnvironmentCredential, GetTokenOptions, InteractiveBrowserCredential, ManagedIdentityCredential, OnBehalfOfCredential, UsernamePasswordCredential, VisualStudioCodeCredential } from "@azure/identity";
|
|
3
|
+
export interface IAzureIdentityToken {
|
|
4
|
+
token: string;
|
|
5
|
+
expires: Date;
|
|
6
|
+
}
|
|
7
|
+
export declare type ValidCredential = DefaultAzureCredential | ChainedTokenCredential | EnvironmentCredential | ManagedIdentityCredential | ClientAssertionCredential | ClientCertificateCredential | ClientSecretCredential | AuthorizationCodeCredential | DeviceCodeCredential | InteractiveBrowserCredential | OnBehalfOfCredential | UsernamePasswordCredential | AzureCliCredential | AzurePowerShellCredential | VisualStudioCodeCredential;
|
|
8
|
+
export declare function AzureIdentity(credential: ValidCredential, scopes?: string[], options?: GetTokenOptions): (instance: Queryable) => Queryable;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/azidjsclient/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAEH,2BAA2B,EAC3B,kBAAkB,EAClB,yBAAyB,EACzB,sBAAsB,EACtB,yBAAyB,EACzB,2BAA2B,EAC3B,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,4BAA4B,EAC5B,yBAAyB,EACzB,oBAAoB,EACpB,0BAA0B,EAC1B,0BAA0B,EAC7B,MAAM,iBAAiB,CAAC;AAEzB,MAAM,WAAW,mBAAmB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,IAAI,CAAC;CACjB;AAED,oBAAY,eAAe,GAAG,sBAAsB,GAAG,sBAAsB,GAAG,qBAAqB,GACrG,yBAAyB,GAAG,yBAAyB,GAAG,2BAA2B,GAAG,sBAAsB,GAC5G,2BAA2B,GAAG,oBAAoB,GAAG,4BAA4B,GAAG,oBAAoB,GACxG,0BAA0B,GAAG,kBAAkB,GAAG,yBAAyB,GAAG,0BAA0B,CAAC;AAEzG,wBAAgB,aAAa,CAAC,UAAU,EAAE,eAAe,EACrD,MAAM,GAAE,MAAM,EAA6C,EAC3D,OAAO,CAAC,EAAE,eAAe,GAAG,CAAC,QAAQ,EAAE,SAAS,KAAK,SAAS,CAiCjE"}
|
package/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { PnPClientStorage, getHashCode } from "@pnp/core/index.js";
|
|
2
|
+
export function AzureIdentity(credential, scopes = ["https://graph.microsoft.com/.default"], options) {
|
|
3
|
+
const key = `AzureIdentityCredential${getHashCode(scopes.join())}`;
|
|
4
|
+
const storage = new PnPClientStorage();
|
|
5
|
+
return (instance) => {
|
|
6
|
+
instance.on.auth.replace(async (url, init) => {
|
|
7
|
+
let token;
|
|
8
|
+
let expires;
|
|
9
|
+
const tokenStore = storage.session.get(key);
|
|
10
|
+
if (tokenStore) {
|
|
11
|
+
const storedToken = JSON.parse(tokenStore);
|
|
12
|
+
if (storedToken.expires < (new Date())) {
|
|
13
|
+
token = storedToken.token;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
if (token == null) {
|
|
17
|
+
const aiToken = await credential.getToken(scopes, options);
|
|
18
|
+
// Set expiration date equal to the expiration timestamp minus 5 minutes for buffer
|
|
19
|
+
expires = new Date((new Date()).getMilliseconds() + (aiToken.expiresOnTimestamp - 300000));
|
|
20
|
+
token = aiToken.token;
|
|
21
|
+
const newToken = { token, expires };
|
|
22
|
+
storage.session.put(key, JSON.stringify(newToken));
|
|
23
|
+
}
|
|
24
|
+
init.headers = { ...init.headers, Authorization: `Bearer ${token}` };
|
|
25
|
+
return [url, init];
|
|
26
|
+
});
|
|
27
|
+
return instance;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/azidjsclient/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAgCnE,MAAM,UAAU,aAAa,CAAC,UAA2B,EACrD,SAAmB,CAAC,sCAAsC,CAAC,EAC3D,OAAyB;IAEzB,MAAM,GAAG,GAAG,0BAA0B,WAAW,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;IACnE,MAAM,OAAO,GAAG,IAAI,gBAAgB,EAAE,CAAC;IAEvC,OAAO,CAAC,QAAmB,EAAE,EAAE;QAC3B,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAQ,EAAE,IAAiB,EAAE,EAAE;YAC3D,IAAI,KAAa,CAAC;YAClB,IAAI,OAAa,CAAC;YAElB,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC5C,IAAI,UAAU,EAAE;gBACZ,MAAM,WAAW,GAAwB,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;gBAChE,IAAI,WAAW,CAAC,OAAO,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE;oBACpC,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC;iBAC7B;aACJ;YACD,IAAI,KAAK,IAAI,IAAI,EAAE;gBACf,MAAM,OAAO,GAAgB,MAAM,UAAU,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBACxE,mFAAmF;gBACnF,OAAO,GAAG,IAAI,IAAI,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,eAAe,EAAE,GAAG,CAAC,OAAO,CAAC,kBAAkB,GAAG,MAAM,CAAC,CAAC,CAAC;gBAC3F,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;gBACtB,MAAM,QAAQ,GAAwB,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;gBACzD,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;aACtD;YAED,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,aAAa,EAAE,UAAU,KAAK,EAAE,EAAE,CAAC;YAErE,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC;IACpB,CAAC,CAAC;AACN,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pnp/azidjsclient",
|
|
3
|
+
"version": "3.13.0-v3nightly.20230411",
|
|
4
|
+
"description": "pnp - provides an Azure Identity wrapper client for use with PnPjs",
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"typings": "./index",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@pnp/core": "3.13.0-v3nightly.20230411",
|
|
9
|
+
"@pnp/queryable": "3.13.0-v3nightly.20230411",
|
|
10
|
+
"@azure/identity": "3.1.3",
|
|
11
|
+
"tslib": "2.4.1"
|
|
12
|
+
},
|
|
13
|
+
"funding": {
|
|
14
|
+
"type": "individual",
|
|
15
|
+
"url": "https://github.com/sponsors/patrick-rodgers/"
|
|
16
|
+
},
|
|
17
|
+
"type": "module",
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=14.15.1"
|
|
20
|
+
},
|
|
21
|
+
"author": {
|
|
22
|
+
"name": "Microsoft and other contributors"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/pnp/pnpjs/issues"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/pnp/pnpjs",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git:github.com/pnp/pnpjs"
|
|
32
|
+
}
|
|
33
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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/community/home](http://aka.ms/community/home) for the latest updates around the whole *Microsoft 365 and Power Platform Community(PnP)* initiative.
|
|
8
|
+
## Source & Docs
|
|
9
|
+
|
|
10
|
+
This code is managed within the [main pnp repo](https://github.com/pnp/pnpjs), please report issues and submit pull requests there.
|
|
11
|
+
|
|
12
|
+
Please see the public site for [package documentation](https://pnp.github.io/pnpjs/).
|
|
13
|
+
|
|
14
|
+
### Code of Conduct
|
|
15
|
+
|
|
16
|
+
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.
|
|
17
|
+
|
|
18
|
+
### "Sharing is Caring"
|
|
19
|
+
|
|
20
|
+
### Disclaimer
|
|
21
|
+
**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.**
|