Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/msal-node-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ jobs:
path: samples/msal-node-samples/${{ matrix.sample }}/node_modules
key: ${{ runner.os }}-node-e2e-${{ matrix.sample }}-${{ matrix.node }}-${{ hashFiles(format('samples/msal-node-samples/{0}/package.json', matrix.sample), 'samples/package-lock.json') }}

- name: Install msal-node-samples packages
working-directory: samples/msal-node-samples
run: npm i

- name: Install Sample
if: steps.sample-cache.outputs.cache-hit != 'true'
working-directory: samples/msal-node-samples/${{ matrix.sample }}
Expand Down Expand Up @@ -181,6 +185,10 @@ jobs:
path: samples/msal-node-samples/${{ matrix.sample }}/node_modules
key: ${{ runner.os }}-electron-e2e-${{ matrix.sample }}-${{ hashFiles(format('samples/msal-node-samples/{0}/package.json', matrix.sample), 'samples/package-lock.json') }}

- name: Install msal-node-samples packages
working-directory: samples/msal-node-samples
run: npm i

- name: Install Sample
if: steps.sample-cache.outputs.cache-hit != 'true'
working-directory: samples/msal-node-samples/${{ matrix.sample }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "Export Serializer and Deserializer from msal-node #5931",
"packageName": "@azure/msal-node",
"email": "kshabelko@microsoft.com",
"dependentChangeType": "patch"
}
8 changes: 8 additions & 0 deletions lib/msal-node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
* @module @azure/msal-node
*/

/**
* Warning: This set of exports is purely intended to be used by other MSAL libraries, and should be considered potentially unstable. We strongly discourage using them directly, you do so at your own risk.
* Breaking changes to these APIs will be shipped under a minor version, instead of a major version.
*/

import * as internals from "./internals";
export { internals };

// Interfaces
export { IPublicClientApplication } from "./client/IPublicClientApplication";
export { IConfidentialClientApplication } from "./client/IConfidentialClientApplication";
Expand Down
12 changes: 12 additions & 0 deletions lib/msal-node/src/internals.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/

/**
* Warning: This set of exports is purely intended to be used by other MSAL libraries, and should be considered potentially unstable. We strongly discourage using them directly, you do so at your own risk.
* Breaking changes to these APIs will be shipped under a minor version, instead of a major version.
*/

export { Serializer } from "./cache/serializer/Serializer";
export { Deserializer } from "./cache/serializer/Deserializer";
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
Browser,
} from "@playwright/test";

import { NodeCacheTestUtils } from "../../../e2eTestUtils/NodeCacheTestUtils";
import { NodeCacheTestUtils } from "../../NodeCacheTestUtils";
import { LabApiQueryParams } from "../../../e2eTestUtils/LabApiQueryParams";
import { AppTypes, AzureEnvironments } from "../../../e2eTestUtils/Constants";
import { LabClient } from "../../../e2eTestUtils/LabClient";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import fs from "fs";
import { IdTokenEntity } from "../../lib/msal-common/src/cache/entities/IdTokenEntity";
import { AccessTokenEntity } from "../../lib/msal-common/src/cache/entities/AccessTokenEntity";
import { RefreshTokenEntity } from "../../lib/msal-common/src/cache/entities/RefreshTokenEntity";
import { InMemoryCache } from '../../lib/msal-node/src/cache/serializer/SerializerTypes';

import { Serializer } from "../../lib/msal-node/src/cache/serializer/Serializer";
import { Deserializer } from "../../lib/msal-node/src/cache/serializer/Deserializer";
import { InMemoryCache, internals } from "@azure/msal-node";

export type tokenMap = {
idTokens: IdTokenEntity[],
Expand Down Expand Up @@ -46,7 +44,7 @@ export class NodeCacheTestUtils {
reject(err);
}
const cache = (data) ? data : this.getCacheTemplate();
const deserializedCache = Deserializer.deserializeAllCache(JSON.parse(cache));
const deserializedCache = internals.Deserializer.deserializeAllCache(JSON.parse(cache));
resolve(deserializedCache);
});
});
Expand Down Expand Up @@ -91,7 +89,7 @@ export class NodeCacheTestUtils {
deserializedCache.accessTokens[atKey].extendedExpiresOn = "0";
});

const serializedCache = Serializer.serializeAllCache(deserializedCache);
const serializedCache = internals.Serializer.serializeAllCache(deserializedCache);

return new Promise((resolve, reject) => {
fs.writeFile(cacheLocation, JSON.stringify(serializedCache, null, 1), (error) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

import puppeteer from "puppeteer";
import {Screenshot, createFolder, RETRY_TIMES} from "../../../e2eTestUtils/TestUtils";
import { NodeCacheTestUtils } from "../../../e2eTestUtils/NodeCacheTestUtils";
import { NodeCacheTestUtils } from "../../NodeCacheTestUtils";
import {
enterCredentials,
SCREENSHOT_BASE_FOLDER_NAME,
validateCacheLocation,
SAMPLE_HOME_URL
} from "../../testUtils";
import { ConfidentialClientApplication } from "../../../../lib/msal-node";
import { ConfidentialClientApplication } from "@azure/msal-node";
import { getKeyVaultSecretClient, getCredentials } from "../../../e2eTestUtils/KeyVaultUtils";

// Set test cache name/location
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

import puppeteer from "puppeteer";
import {Screenshot, createFolder, RETRY_TIMES} from "../../../e2eTestUtils/TestUtils";
import { NodeCacheTestUtils } from "../../../e2eTestUtils/NodeCacheTestUtils";
import { NodeCacheTestUtils } from "../../NodeCacheTestUtils";
import {
enterCredentials,
SCREENSHOT_BASE_FOLDER_NAME,
validateCacheLocation,
SAMPLE_HOME_URL
} from "../../testUtils";
import { PublicClientApplication } from "../../../../lib/msal-node";
import { PublicClientApplication } from "@azure/msal-node";
import { getKeyVaultSecretClient, getCredentials } from "../../../e2eTestUtils/KeyVaultUtils";

// Set test cache name/location
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import puppeteer from "puppeteer";
import {Screenshot, createFolder, setupCredentials, RETRY_TIMES} from "../../../e2eTestUtils/TestUtils";
import { NodeCacheTestUtils } from "../../../e2eTestUtils/NodeCacheTestUtils";
import { NodeCacheTestUtils } from "../../NodeCacheTestUtils";
import { LabClient } from "../../../e2eTestUtils/LabClient";
import { LabApiQueryParams } from "../../../e2eTestUtils/LabApiQueryParams";
import { AppTypes, AzureEnvironments } from "../../../e2eTestUtils/Constants";
Expand All @@ -16,7 +16,7 @@ import {
SAMPLE_HOME_URL
} from "../../testUtils";

import { PublicClientApplication } from "../../../../lib/msal-node/dist";
import { PublicClientApplication } from "@azure/msal-node";

// Set test cache name/location
const TEST_CACHE_LOCATION = `${__dirname}/data/aad.cache.json`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import puppeteer from "puppeteer";
import {Screenshot, createFolder, setupCredentials, RETRY_TIMES} from "../../../e2eTestUtils/TestUtils";
import { NodeCacheTestUtils } from "../../../e2eTestUtils/NodeCacheTestUtils";
import { NodeCacheTestUtils } from "../../NodeCacheTestUtils";
import { LabClient } from "../../../e2eTestUtils/LabClient";
import { LabApiQueryParams } from "../../../e2eTestUtils/LabApiQueryParams";
import { AppTypes, AzureEnvironments, FederationProviders, UserTypes } from "../../../e2eTestUtils/Constants";
Expand All @@ -10,7 +10,7 @@ import {
SCREENSHOT_BASE_FOLDER_NAME,
SAMPLE_HOME_URL,
} from "../../testUtils";
import { PublicClientApplication } from "../../../../lib/msal-node/";
import { PublicClientApplication } from "@azure/msal-node";

const TEST_CACHE_LOCATION = `${__dirname}/data/adfs.cache.json`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
b2cAadPpeAccountEnterCredentials,
RETRY_TIMES
} from "../../../e2eTestUtils/TestUtils";
import { NodeCacheTestUtils } from "../../../e2eTestUtils/NodeCacheTestUtils";
import { NodeCacheTestUtils } from "../../NodeCacheTestUtils";
import { LabClient } from "../../../e2eTestUtils/LabClient";
import { LabApiQueryParams } from "../../../e2eTestUtils/LabApiQueryParams";
import { AppTypes, AzureEnvironments } from "../../../e2eTestUtils/Constants";
Expand All @@ -21,7 +21,7 @@ import {
SAMPLE_HOME_URL
} from "../../testUtils";

import { PublicClientApplication } from "../../../../lib/msal-node/dist";
import { PublicClientApplication } from "@azure/msal-node";

// Set test cache name/location
const TEST_CACHE_LOCATION = `${__dirname}/data/b2c-aad.cache.json`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
b2cLocalAccountEnterCredentials,
RETRY_TIMES
} from "../../../e2eTestUtils/TestUtils";
import { NodeCacheTestUtils } from "../../../e2eTestUtils/NodeCacheTestUtils";
import { NodeCacheTestUtils } from "../../NodeCacheTestUtils";
import { LabClient } from "../../../e2eTestUtils/LabClient";
import { LabApiQueryParams } from "../../../e2eTestUtils/LabApiQueryParams";
import { B2cProviders, UserTypes } from "../../../e2eTestUtils/Constants";
Expand All @@ -21,7 +21,7 @@ import {
SAMPLE_HOME_URL
} from "../../testUtils";

import { PublicClientApplication } from "../../../../lib/msal-node/dist";
import { PublicClientApplication } from "@azure/msal-node";

// Set test cache name/location
const TEST_CACHE_LOCATION = `${__dirname}/data/b2c-local.cache.json`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
b2cMsaAccountEnterCredentials,
RETRY_TIMES
} from "../../../e2eTestUtils/TestUtils";
import { NodeCacheTestUtils } from "../../../e2eTestUtils/NodeCacheTestUtils";
import { NodeCacheTestUtils } from "../../NodeCacheTestUtils";
import { LabClient } from "../../../e2eTestUtils/LabClient";
import { LabApiQueryParams } from "../../../e2eTestUtils/LabApiQueryParams";
import { B2cProviders, UserTypes } from "../../../e2eTestUtils/Constants";
Expand All @@ -21,7 +21,7 @@ import {
SAMPLE_HOME_URL
} from "../../testUtils";

import { PublicClientApplication } from "../../../../lib/msal-node/dist";
import { PublicClientApplication } from "@azure/msal-node";

// Set test cache name/location
const TEST_CACHE_LOCATION = `${__dirname}/data/b2c-msa.cache.json`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
b2cLocalAccountEnterCredentials,
RETRY_TIMES
} from "../../../e2eTestUtils/TestUtils";
import { NodeCacheTestUtils } from "../../../e2eTestUtils/NodeCacheTestUtils";
import { NodeCacheTestUtils } from "../../NodeCacheTestUtils";
import { LabClient } from "../../../e2eTestUtils/LabClient";
import { LabApiQueryParams } from "../../../e2eTestUtils/LabApiQueryParams";
import { B2cProviders, UserTypes } from "../../../e2eTestUtils/Constants";
Expand All @@ -22,7 +22,7 @@ import {
SAMPLE_HOME_URL
} from "../../testUtils";

import { ConfidentialClientApplication } from "../../../../lib/msal-node/dist";
import { ConfidentialClientApplication } from "@azure/msal-node";

// Set test cache name/location
const TEST_CACHE_LOCATION = `${__dirname}/../data/b2c-local.cache.json`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
b2cMsaAccountEnterCredentials,
RETRY_TIMES
} from "../../../e2eTestUtils/TestUtils";
import { NodeCacheTestUtils } from "../../../e2eTestUtils/NodeCacheTestUtils";
import { NodeCacheTestUtils } from "../../NodeCacheTestUtils";
import { LabClient } from "../../../e2eTestUtils/LabClient";
import { LabApiQueryParams } from "../../../e2eTestUtils/LabApiQueryParams";
import { B2cProviders, UserTypes } from "../../../e2eTestUtils/Constants";
Expand All @@ -22,7 +22,7 @@ import {
SAMPLE_HOME_URL
} from "../../testUtils";

import { ConfidentialClientApplication } from "../../../../lib/msal-node/dist";
import { ConfidentialClientApplication } from "@azure/msal-node";

// Set test cache name/location
const TEST_CACHE_LOCATION = `${__dirname}/../data/b2c-msa.cache.json`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* Licensed under the MIT License.
*/

import { NodeCacheTestUtils } from "../../../e2eTestUtils/NodeCacheTestUtils";
import { NodeCacheTestUtils } from "../../NodeCacheTestUtils";
import { validateCacheLocation } from "../../testUtils";
import { ConfidentialClientApplication } from "../../../../lib/msal-node/";
import { ConfidentialClientApplication } from "@azure/msal-node";
import {RETRY_TIMES} from "../../../e2eTestUtils/TestUtils";

const TEST_CACHE_LOCATION = `${__dirname}/data/aad-agc.cache.json`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { LabApiQueryParams } from "../../../e2eTestUtils/LabApiQueryParams";
import { NodeCacheTestUtils } from "../../../e2eTestUtils/NodeCacheTestUtils";
import { NodeCacheTestUtils } from "../../NodeCacheTestUtils";
import {RETRY_TIMES, retrieveAppConfiguration} from "../../../e2eTestUtils/TestUtils";
import { LabClient } from "../../../e2eTestUtils/LabClient";
import { validateCacheLocation } from "../../testUtils";
import { ConfidentialClientApplication } from "../../../../lib/msal-node/";
import { ConfidentialClientApplication } from "@azure/msal-node";
import config from "../config/AAD.json";

const TEST_CACHE_LOCATION = `${__dirname}/data/aad.cache.json`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

import puppeteer from "puppeteer";
import {Screenshot, createFolder, RETRY_TIMES} from "../../../e2eTestUtils/TestUtils";
import { NodeCacheTestUtils } from "../../../e2eTestUtils/NodeCacheTestUtils";
import { NodeCacheTestUtils } from "../../NodeCacheTestUtils";
import {
approveRemoteConnect,
enterCredentials,
enterDeviceCode,
SCREENSHOT_BASE_FOLDER_NAME,
validateCacheLocation
} from "../../testUtils";
import { Configuration, PublicClientApplication } from "../../../../lib/msal-node";
import { Configuration, PublicClientApplication } from "@azure/msal-node";
import { getKeyVaultSecretClient, getCredentials } from "../../../e2eTestUtils/KeyVaultUtils";

// Set test cache name/location
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import puppeteer from "puppeteer";
import {Screenshot, createFolder, setupCredentials, RETRY_TIMES} from "../../../e2eTestUtils/TestUtils";
import { NodeCacheTestUtils } from "../../../e2eTestUtils/NodeCacheTestUtils";
import { NodeCacheTestUtils } from "../../NodeCacheTestUtils";
import { LabClient } from "../../../e2eTestUtils/LabClient";
import { LabApiQueryParams } from "../../../e2eTestUtils/LabApiQueryParams";
import { AppTypes, AzureEnvironments } from "../../../e2eTestUtils/Constants";
Expand All @@ -17,7 +17,7 @@ import {
validateCacheLocation
} from "../../testUtils";

import { Configuration, PublicClientApplication } from "../../../../lib/msal-node";
import { Configuration, PublicClientApplication } from "@azure/msal-node";

// Set test cache name/location
const TEST_CACHE_LOCATION = `${__dirname}/data/aad.cache.json`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import puppeteer from "puppeteer";
import {Screenshot, createFolder, setupCredentials, RETRY_TIMES} from "../../../e2eTestUtils/TestUtils";
import { NodeCacheTestUtils } from "../../../e2eTestUtils/NodeCacheTestUtils";
import { NodeCacheTestUtils } from "../../NodeCacheTestUtils";
import { LabClient } from "../../../e2eTestUtils/LabClient";
import { LabApiQueryParams } from "../../../e2eTestUtils/LabApiQueryParams";
import { AppTypes, AzureEnvironments, FederationProviders, UserTypes } from "../../../e2eTestUtils/Constants";
Expand All @@ -16,7 +16,7 @@ import {
validateCacheLocation
} from "../../testUtils";

import { Configuration, PublicClientApplication } from "../../../../lib/msal-node";
import { Configuration, PublicClientApplication } from "@azure/msal-node";

// Set test cache name/location
const TEST_CACHE_LOCATION = `${__dirname}/data/adfs.cache.json`;
Expand Down
6 changes: 3 additions & 3 deletions samples/msal-node-samples/on-behalf-of/test/obo-aad.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import puppeteer from "puppeteer";
import { Screenshot, createFolder, setupCredentials } from "../../../e2eTestUtils/TestUtils";
import { NodeCacheTestUtils } from "../../../e2eTestUtils/NodeCacheTestUtils";
import { NodeCacheTestUtils } from "../../NodeCacheTestUtils";
import { LabClient } from "../../../e2eTestUtils/LabClient";
import { LabApiQueryParams } from "../../../e2eTestUtils/LabApiQueryParams";
import { AppTypes, AzureEnvironments } from "../../../e2eTestUtils/Constants";
Expand Down Expand Up @@ -44,7 +44,7 @@ describe("OBO AAD Tests", () => {
let browser: puppeteer.Browser;
let context: puppeteer.BrowserContext;
let page: puppeteer.Page;

let username: string;
let accountPwd: string;

Expand Down Expand Up @@ -127,7 +127,7 @@ describe("OBO AAD Tests", () => {
await page.goto(HOME_ROUTE);
await enterCredentials(page, screenshot, username, accountPwd);
await page.waitForFunction(`window.location.href.startsWith("${SAMPLE_HOME_URL}")`);

const webApiCachedTokens = await NodeCacheTestUtils.waitForTokens(WEB_API_TEST_CACHE_LOCATION, 2000);
expect(webApiCachedTokens.accessTokens.length).toBe(1);
expect(webApiCachedTokens.idTokens.length).toBe(1);
Expand Down
1 change: 1 addition & 0 deletions samples/msal-node-samples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
"dependencies": {
"@types/express": "^4.17.11",
"@azure/msal-node": "file:../../lib/msal-node",
"express": "^4.17.1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import puppeteer from "puppeteer";
import {Screenshot, createFolder, ONE_SECOND_IN_MS, RETRY_TIMES} from "../../../e2eTestUtils/TestUtils";
import { NodeCacheTestUtils } from "../../../e2eTestUtils/NodeCacheTestUtils";
import { NodeCacheTestUtils } from "../../NodeCacheTestUtils";
import {
clickSignIn,
enterCredentials,
Expand All @@ -15,7 +15,7 @@ import {
SUCCESSFUL_GET_ALL_ACCOUNTS_ID,
validateCacheLocation,
SUCCESSFUL_SILENT_TOKEN_ACQUISITION_ID} from "../../testUtils";
import { ConfidentialClientApplication, TokenCache } from "../../../../lib/msal-node";
import { ConfidentialClientApplication, TokenCache } from "@azure/msal-node";
import { getKeyVaultSecretClient, getCredentials } from "../../../e2eTestUtils/KeyVaultUtils";

// Set test cache name/location
Expand Down
Loading