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
828
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.513031b to 3.1.3-preview.52d8ad9

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

@@ -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

2

dist/es6/Graph.js

@@ -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();

@@ -0,2 +1,8 @@

/**
* -------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
* See License in the project root for license information.
* -------------------------------------------------------------------------------------------
*/
export {};
//# sourceMappingURL=equals.tests.d.ts.map

@@ -0,1 +1,7 @@

/**
* -------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
* See License in the project root for license information.
* -------------------------------------------------------------------------------------------
*/
/* eslint-disable @typescript-eslint/no-unused-expressions */

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

@@ -1,2 +0,1 @@

/* eslint-disable @typescript-eslint/no-unused-expressions */
/**

@@ -17,2 +16,9 @@ * -------------------------------------------------------------------------------------------

};
/* eslint-disable @typescript-eslint/no-unused-expressions */
/**
* -------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
* See License in the project root for license information.
* -------------------------------------------------------------------------------------------
*/
import { expect } from '@open-wc/testing';

@@ -32,9 +38,9 @@ import { fake } from 'sinon';

// 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'] })]);
}));

@@ -41,0 +47,0 @@ });

@@ -12,3 +12,3 @@ /**

_components: LocalizationRecord;
} & Record<string, string>;
} & Record<string, string | LocalizationRecord>;
/**

@@ -15,0 +15,0 @@ * Helper class for Localization

@@ -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 @@ }

@@ -0,3 +1,9 @@

/**
* -------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
* See License in the project root for license information.
* -------------------------------------------------------------------------------------------
*/
export declare const buildComponentName: (tagBase: string) => string;
export declare const registerComponent: (tagBase: string, constructor: CustomElementConstructor, options?: ElementDefinitionOptions) => void;
//# sourceMappingURL=registerComponent.d.ts.map

@@ -0,1 +1,7 @@

/**
* -------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
* See License in the project root for license information.
* -------------------------------------------------------------------------------------------
*/
import { customElementHelper } from '../components/customElementHelper';

@@ -2,0 +8,0 @@ export const buildComponentName = (tagBase) => `${customElementHelper.prefix}-${tagBase}`;

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

*/
export declare const PACKAGE_VERSION = "3.1.3-preview.513031b";
export declare const PACKAGE_VERSION = "3.1.3-preview.52d8ad9";
//# sourceMappingURL=version.d.ts.map

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

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

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

"dependencies": {
"@lit/task": "^1.0.0",
"@microsoft/microsoft-graph-client": "3.0.2",

@@ -37,0 +38,0 @@ "idb": "6.0.0",

@@ -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 @@ };

@@ -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 @@

@@ -0,1 +1,8 @@

/**
* -------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
* See License in the project root for license information.
* -------------------------------------------------------------------------------------------
*/
/* eslint-disable @typescript-eslint/no-unused-expressions */

@@ -2,0 +9,0 @@ /**

@@ -0,1 +1,8 @@

/**
* -------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
* See License in the project root for license information.
* -------------------------------------------------------------------------------------------
*/
/* eslint-disable @typescript-eslint/no-unused-expressions */

@@ -24,9 +31,9 @@ /**

// 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 +40,0 @@ });

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

_components: LocalizationRecord;
} & Record<string, string>;
} & Record<string, string | LocalizationRecord>;

@@ -18,0 +18,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 {

@@ -0,1 +1,8 @@

/**
* -------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
* See License in the project root for license information.
* -------------------------------------------------------------------------------------------
*/
import { customElementHelper } from '../components/customElementHelper';

@@ -2,0 +9,0 @@

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

export const PACKAGE_VERSION = '3.1.3-preview.513031b';
export const PACKAGE_VERSION = '3.1.3-preview.52d8ad9';

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

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