Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@microsoft/mgt-element

Package Overview
Dependencies
Maintainers
2
Versions
831
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@microsoft/mgt-element - npm Package Compare versions

Comparing version 3.1.3-preview.18925a9 to 3.1.3-preview.18d0aec

dist/es6/components/baseTaskComponent.d.ts

3

dist/es6/components/baseComponent.d.ts

@@ -8,2 +8,3 @@ /**

import { LitElement, PropertyValueMap, PropertyValues } from 'lit';
import { ProviderState } from '../providers/IProvider';
/**

@@ -36,4 +37,6 @@ * Defines media query based on component width

* @extends {LitElement}
* @deprecated Use MgtBaseTaskComponent instead
*/
export declare abstract class MgtBaseComponent extends LitElement {
protected providerState: ProviderState;
/**

@@ -40,0 +43,0 @@ * Exposes the semver of the library the component is part of

@@ -59,2 +59,3 @@ /**

* @extends {LitElement}
* @deprecated Use MgtBaseTaskComponent instead
*/

@@ -122,2 +123,3 @@ export class MgtBaseComponent extends LitElement {

super();
this.providerState = ProviderState.Loading;
/**

@@ -145,2 +147,4 @@ * Gets or sets the direction of the component

this.handleProviderUpdates = () => {
var _a, _b;
this.providerState = (_b = (_a = Providers.globalProvider) === null || _a === void 0 ? void 0 : _a.state) !== null && _b !== void 0 ? _b : ProviderState.Loading;
void this.requestStateUpdate();

@@ -318,4 +322,8 @@ };

state(),
__metadata("design:type", Number)
], MgtBaseComponent.prototype, "providerState", void 0);
__decorate([
state(),
__metadata("design:type", String)
], MgtBaseComponent.prototype, "direction", void 0);
//# sourceMappingURL=baseComponent.js.map

2

dist/es6/components/customElementHelper.d.ts

@@ -13,3 +13,3 @@ /**

*
* @param {string} disambiguation
* @param {string} disambiguation the disambiguation value to be used, should be lowercase
* @return {CustomElementHelper} the current object

@@ -16,0 +16,0 @@ * @memberof CustomElementHelper

@@ -17,3 +17,3 @@ /**

*
* @param {string} disambiguation
* @param {string} disambiguation the disambiguation value to be used, should be lowercase
* @return {CustomElementHelper} the current object

@@ -23,4 +23,7 @@ * @memberof CustomElementHelper

withDisambiguation(disambiguation) {
if (disambiguation && !this._disambiguation)
this._disambiguation = disambiguation;
if (disambiguation && !this._disambiguation) {
this._disambiguation = disambiguation.toLowerCase();
if (disambiguation !== this._disambiguation)
console.warn(`🦒: Disambiguation value, ${disambiguation}, should be lowercase. Value has been converted to lowercase, ${this._disambiguation}.`);
}
return this;

@@ -27,0 +30,0 @@ }

@@ -10,2 +10,15 @@ /**

import { TemplateContext } from '../utils/TemplateContext';
/**
* Lookup for rendered component templates and contexts by slot name.
*/
export type RenderedTemplates = Record<string, {
/**
* Reference to the data context used to render the slot.
*/
context: Record<string, unknown>;
/**
* Reference to the rendered DOM element corresponding to the slot.
*/
slot: HTMLElement;
}>;
export interface TemplateRenderedData {

@@ -16,3 +29,3 @@ templateType: string;

}
type OrderedHtmlTemplate = HTMLTemplateElement & {
export type OrderedHtmlTemplate = HTMLTemplateElement & {
templateOrder: number;

@@ -27,2 +40,3 @@ };

* @extends {MgtBaseComponent}
* @deprecated Use MgtTemplatedTaskComponent instead
*

@@ -104,3 +118,2 @@ * @fires {CustomEvent<MgtElement.TemplateRenderedData>} templateRendered - fires when a template is rendered

}
export {};
//# sourceMappingURL=templatedComponent.d.ts.map

@@ -28,2 +28,3 @@ /**

* @extends {MgtBaseComponent}
* @deprecated Use MgtTemplatedTaskComponent instead
*

@@ -30,0 +31,0 @@ * @fires {CustomEvent<MgtElement.TemplateRenderedData>} templateRendered - fires when a template is rendered

@@ -85,3 +85,3 @@ /**

request.middlewareOptions = (options) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, @typescript-eslint/dot-notation
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/dot-notation
request['_middlewareOptions'] = request['_middlewareOptions'].concat(options);

@@ -88,0 +88,0 @@ return request;

@@ -13,3 +13,5 @@ /**

export * from './components/baseProvider';
export * from './components/baseTaskComponent';
export * from './components/templatedComponent';
export * from './components/templatedTaskComponent';
export * from './components/customElementHelper';

@@ -16,0 +18,0 @@ export * from './providers/IProvider';

@@ -13,3 +13,5 @@ /**

export * from './components/baseProvider';
export * from './components/baseTaskComponent';
export * from './components/templatedComponent';
export * from './components/templatedTaskComponent';
export * from './components/customElementHelper';

@@ -16,0 +18,0 @@ export * from './providers/IProvider';

@@ -90,5 +90,5 @@ /**

static setBaseFallbackUrl() {
this._baseUrl = 'https://proxy.apisandbox.msdn.microsoft.com/svc?url=';
this._baseUrl = 'https://graph.office.net/en-us/graph/api/proxy?url=';
}
}
//# sourceMappingURL=MockMiddleware.js.map

@@ -46,3 +46,15 @@ /**

private _baseURL;
private _approvedScopes;
get approvedScopes(): string[];
set approvedScopes(value: string[]);
hasAtLeastOneApprovedScope(requiredScopeSet: string[]): boolean;
hasAllOneApprovedScope(requiredScopeSet: string[]): boolean;
/**
* Examines the currently consented scopes for any match in the requiredScopeSet to determine what, if any, scopes need to be consented to
*
* @param {string[]} requiredScopeSet an array of scopes to be checked
* @returns {string[]} if any matches in requiredScopeSet exist then an empty array is returns, otherwise an array containing the first element in the requiredScopeSet is returned
*/
needsAdditionalScopes(requiredScopeSet: string[]): string[];
/**
* The base URL to be used in the graph client config.

@@ -49,0 +61,0 @@ */

@@ -29,3 +29,28 @@ /**

}
get approvedScopes() {
return this._approvedScopes;
}
set approvedScopes(value) {
this._approvedScopes = value.map(v => v.toLowerCase());
}
hasAtLeastOneApprovedScope(requiredScopeSet) {
return requiredScopeSet.some(s => this.approvedScopes.includes(s.toLowerCase().trim()));
}
hasAllOneApprovedScope(requiredScopeSet) {
return requiredScopeSet.some(s => !this.approvedScopes.includes(s.toLowerCase().trim()));
}
/**
* Examines the currently consented scopes for any match in the requiredScopeSet to determine what, if any, scopes need to be consented to
*
* @param {string[]} requiredScopeSet an array of scopes to be checked
* @returns {string[]} if any matches in requiredScopeSet exist then an empty array is returns, otherwise an array containing the first element in the requiredScopeSet is returned
*/
needsAdditionalScopes(requiredScopeSet) {
const reqScopes = [];
if (requiredScopeSet.length && !this.hasAtLeastOneApprovedScope(requiredScopeSet)) {
reqScopes.push(requiredScopeSet[0].trim());
}
return reqScopes;
}
/**
* The base URL to be used in the graph client config.

@@ -113,2 +138,3 @@ */

this._baseURL = MICROSOFT_GRAPH_DEFAULT_ENDPOINT;
this._approvedScopes = [];
this._customHosts = undefined;

@@ -115,0 +141,0 @@ /**

@@ -36,3 +36,5 @@ /**

* @param {string} resource
* @param {string[]} [scopes]
* @param {string[]} [scopes] any additional scopes that should be requested
* Note: use `IProvider.needsAdditionalScopes(scopes)` to calculate which
* scopes, if any, need to be requested before calling `Batch.get()`
* @memberof Batch

@@ -39,0 +41,0 @@ */

@@ -55,3 +55,5 @@ /**

* @param {string} resource
* @param {string[]} [scopes]
* @param {string[]} [scopes] any additional scopes that should be requested
* Note: use `IProvider.needsAdditionalScopes(scopes)` to calculate which
* scopes, if any, need to be requested before calling `Batch.get()`
* @memberof Batch

@@ -98,3 +100,3 @@ */

}
const middlewareOptions = this.scopes.length ? prepScopes(...this.scopes) : [];
const middlewareOptions = this.scopes.length ? prepScopes(this.scopes) : [];
const batchRequest = this.graph.api('$batch').middlewareOptions(middlewareOptions);

@@ -101,0 +103,0 @@ const batchRequestBody = yield batchRequestContent.getContent();

@@ -31,9 +31,9 @@ /* eslint-disable @typescript-eslint/no-unused-expressions */

// eql for loose equality
yield expect(prepScopes(...scopes)).to.eql([]);
yield expect(prepScopes(scopes)).to.eql([]);
}));
it('should return an array of AuthenticationHandlerOptions when incremental consent is enabled', () => __awaiter(void 0, void 0, void 0, function* () {
it('should return an array of AuthenticationHandlerOptions when incremental consent is enabled with only the first scope in the list', () => __awaiter(void 0, void 0, void 0, function* () {
const scopes = ['scope1', 'scope2'];
Providers.globalProvider = new MockProvider(true);
Providers.globalProvider.isIncrementalConsentDisabled = false;
yield expect(prepScopes(...scopes)).to.eql([new AuthenticationHandlerOptions(undefined, { scopes })]);
yield expect(prepScopes(scopes)).to.eql([new AuthenticationHandlerOptions(undefined, { scopes: ['scope1'] })]);
}));

@@ -40,0 +40,0 @@ });

@@ -16,3 +16,3 @@ /**

*/
export declare const prepScopes: (...scopes: string[]) => AuthenticationHandlerOptions[];
export declare const prepScopes: (scopes: string[], provider?: import("..").IProvider) => AuthenticationHandlerOptions[];
//# sourceMappingURL=prepScopes.d.ts.map

@@ -17,7 +17,8 @@ /**

*/
export const prepScopes = (...scopes) => {
export const prepScopes = (scopes, provider = Providers.globalProvider) => {
const additionalScopes = provider.needsAdditionalScopes(scopes);
const authProviderOptions = {
scopes
scopes: additionalScopes
};
if (!Providers.globalProvider.isIncrementalConsentDisabled) {
if (!provider.isIncrementalConsentDisabled) {
return [new AuthenticationHandlerOptions(undefined, authProviderOptions)];

@@ -24,0 +25,0 @@ }

@@ -7,3 +7,3 @@ /**

*/
export declare const PACKAGE_VERSION = "3.1.3-preview.18925a9";
export declare const PACKAGE_VERSION = "3.1.3-preview.18d0aec";
//# sourceMappingURL=version.d.ts.map

@@ -9,3 +9,3 @@ /**

// ANY CHANGES WILL BE LOST DURING BUILD
export const PACKAGE_VERSION = '3.1.3-preview.18925a9';
export const PACKAGE_VERSION = '3.1.3-preview.18d0aec';
//# sourceMappingURL=version.js.map
{
"name": "@microsoft/mgt-element",
"version": "3.1.3-preview.18925a9",
"version": "3.1.3-preview.18d0aec",
"description": "Microsoft Graph Toolkit base classes",

@@ -35,5 +35,6 @@ "homepage": "https://github.com/microsoftgraph/microsoft-graph-toolkit",

"dependencies": {
"@lit/task": "^1.0.0",
"@microsoft/microsoft-graph-client": "3.0.2",
"idb": "6.0.0",
"lit": "^2.3.1"
"lit": "^3.0.0"
},

@@ -40,0 +41,0 @@ "publishConfig": {

@@ -45,4 +45,7 @@ /**

* @extends {LitElement}
* @deprecated Use MgtBaseTaskComponent instead
*/
export abstract class MgtBaseComponent extends LitElement {
@state()
protected providerState: ProviderState = ProviderState.Loading;
/**

@@ -313,2 +316,3 @@ * Exposes the semver of the library the component is part of

private readonly handleProviderUpdates = () => {
this.providerState = Providers.globalProvider?.state ?? ProviderState.Loading;
void this.requestStateUpdate();

@@ -315,0 +319,0 @@ };

@@ -17,3 +17,3 @@ /**

*
* @param {string} disambiguation
* @param {string} disambiguation the disambiguation value to be used, should be lowercase
* @return {CustomElementHelper} the current object

@@ -23,3 +23,9 @@ * @memberof CustomElementHelper

public withDisambiguation(disambiguation: string) {
if (disambiguation && !this._disambiguation) this._disambiguation = disambiguation;
if (disambiguation && !this._disambiguation) {
this._disambiguation = disambiguation.toLowerCase();
if (disambiguation !== this._disambiguation)
console.warn(
`🦒: Disambiguation value, ${disambiguation}, should be lowercase. Value has been converted to lowercase, ${this._disambiguation}.`
);
}
return this;

@@ -26,0 +32,0 @@ }

@@ -19,3 +19,3 @@ /**

*/
type RenderedTemplates = Record<
export type RenderedTemplates = Record<
string,

@@ -40,3 +40,3 @@ {

type OrderedHtmlTemplate = HTMLTemplateElement & { templateOrder: number };
export type OrderedHtmlTemplate = HTMLTemplateElement & { templateOrder: number };

@@ -50,2 +50,3 @@ /**

* @extends {MgtBaseComponent}
* @deprecated Use MgtTemplatedTaskComponent instead
*

@@ -52,0 +53,0 @@ * @fires {CustomEvent<MgtElement.TemplateRenderedData>} templateRendered - fires when a template is rendered

@@ -110,4 +110,4 @@ /**

request.middlewareOptions = (options: MiddlewareOptions[]): GraphRequest => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, @typescript-eslint/dot-notation
request['_middlewareOptions'] = request['_middlewareOptions'].concat(options);
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/dot-notation
request['_middlewareOptions'] = (request['_middlewareOptions'] as MiddlewareOptions[]).concat(options);
return request;

@@ -114,0 +114,0 @@ };

@@ -15,3 +15,5 @@ /**

export * from './components/baseProvider';
export * from './components/baseTaskComponent';
export * from './components/templatedComponent';
export * from './components/templatedTaskComponent';
export * from './components/customElementHelper';

@@ -18,0 +20,0 @@

@@ -88,4 +88,4 @@ /**

private static setBaseFallbackUrl() {
this._baseUrl = 'https://proxy.apisandbox.msdn.microsoft.com/svc?url=';
this._baseUrl = 'https://graph.office.net/en-us/graph/api/proxy?url=';
}
}

@@ -49,2 +49,3 @@ /**

}
private _state: ProviderState;

@@ -55,3 +56,34 @@ private readonly _loginChangedDispatcher = new EventDispatcher<LoginChangedEvent>();

private _approvedScopes: string[] = [];
public get approvedScopes(): string[] {
return this._approvedScopes;
}
public set approvedScopes(value: string[]) {
this._approvedScopes = value.map(v => v.toLowerCase());
}
public hasAtLeastOneApprovedScope(requiredScopeSet: string[]): boolean {
return requiredScopeSet.some(s => this.approvedScopes.includes(s.toLowerCase().trim()));
}
public hasAllOneApprovedScope(requiredScopeSet: string[]): boolean {
return requiredScopeSet.some(s => !this.approvedScopes.includes(s.toLowerCase().trim()));
}
/**
* Examines the currently consented scopes for any match in the requiredScopeSet to determine what, if any, scopes need to be consented to
*
* @param {string[]} requiredScopeSet an array of scopes to be checked
* @returns {string[]} if any matches in requiredScopeSet exist then an empty array is returns, otherwise an array containing the first element in the requiredScopeSet is returned
*/
public needsAdditionalScopes(requiredScopeSet: string[]): string[] {
const reqScopes: string[] = [];
if (requiredScopeSet.length && !this.hasAtLeastOneApprovedScope(requiredScopeSet)) {
reqScopes.push(requiredScopeSet[0].trim());
}
return reqScopes;
}
/**
* The base URL to be used in the graph client config.

@@ -58,0 +90,0 @@ */

@@ -61,3 +61,5 @@ /**

* @param {string} resource
* @param {string[]} [scopes]
* @param {string[]} [scopes] any additional scopes that should be requested
* Note: use `IProvider.needsAdditionalScopes(scopes)` to calculate which
* scopes, if any, need to be requested before calling `Batch.get()`
* @memberof Batch

@@ -110,3 +112,3 @@ */

const middlewareOptions: MiddlewareOptions[] = this.scopes.length ? prepScopes(...this.scopes) : [];
const middlewareOptions: MiddlewareOptions[] = this.scopes.length ? prepScopes(this.scopes) : [];
const batchRequest = this.graph.api('$batch').middlewareOptions(middlewareOptions);

@@ -113,0 +115,0 @@

@@ -24,9 +24,9 @@ /* eslint-disable @typescript-eslint/no-unused-expressions */

// eql for loose equality
await expect(prepScopes(...scopes)).to.eql([]);
await expect(prepScopes(scopes)).to.eql([]);
});
it('should return an array of AuthenticationHandlerOptions when incremental consent is enabled', async () => {
it('should return an array of AuthenticationHandlerOptions when incremental consent is enabled with only the first scope in the list', async () => {
const scopes = ['scope1', 'scope2'];
Providers.globalProvider = new MockProvider(true);
Providers.globalProvider.isIncrementalConsentDisabled = false;
await expect(prepScopes(...scopes)).to.eql([new AuthenticationHandlerOptions(undefined, { scopes })]);
await expect(prepScopes(scopes)).to.eql([new AuthenticationHandlerOptions(undefined, { scopes: ['scope1'] })]);
});

@@ -33,0 +33,0 @@ });

@@ -20,8 +20,9 @@ /**

export const prepScopes = (...scopes: string[]) => {
export const prepScopes = (scopes: string[], provider = Providers.globalProvider) => {
const additionalScopes = provider.needsAdditionalScopes(scopes);
const authProviderOptions = {
scopes
scopes: additionalScopes
};
if (!Providers.globalProvider.isIncrementalConsentDisabled) {
if (!provider.isIncrementalConsentDisabled) {
return [new AuthenticationHandlerOptions(undefined, authProviderOptions)];

@@ -28,0 +29,0 @@ } else {

@@ -11,2 +11,2 @@ /**

export const PACKAGE_VERSION = '3.1.3-preview.18925a9';
export const PACKAGE_VERSION = '3.1.3-preview.18d0aec';

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

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

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc