This repository was archived by the owner on Oct 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Add support for Browsers & Web Sockets #29
Merged
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
81b47d2
Remove ms-rest-azure, add @azure/ms-rest-nodeauth and browserauth
bterlson 19bd8a3
Add browser support
bterlson 9995861
Add rollup configs
bterlson 1d0be5a
Add browser and dist-esm to .gitignore
bterlson 61b73b0
Add options for passing WebSocket constructor and setting WS endpoint
bterlson 8f76557
Add comment with purpose of index.browser.ts stub
bterlson a171997
Remove @azure/ms-rest-browserauth dependency as it isn't needed for now
bterlson 97ec8f6
Update typescript version
bterlson c904d84
Fix TS error with an any cast
bterlson 8159dcc
Make tests run properly
bterlson 85fdba0
Fix circular reference
bterlson 0214698
Fix audit warnings (except nyc)
bterlson adc9eb7
Explicitly import buffer
bterlson a0a62bd
Add shim for process.env
bterlson a6a0c38
Don't explicitly import mocha (the test harness will take care of that)
bterlson 15d6b29
Fix browser build and audit warnings, implement browser tests via karma
bterlson 45b34aa
Properly use configured WebSocket constructor
bterlson 9f8554a
Add tests for passing web sockets to ConnectionContextBase.create
bterlson f98cd50
Use WebSocket by default in the browser
bterlson f21c38f
Version 1.0.0-preview.2
bterlson 9c605fc
Move browser build deps to dependencies
bterlson aa95e9f
Fix syntax error in package.json
bterlson 06f62d4
Clean up lib dependencies; DOM not required anymore
bterlson 35422c5
Move rhea and rhea-promise to dev dep and peer dep
bterlson 94f9fa8
Move WebSocket types to public surface area as types are exported
bterlson 156dbc3
Move some shims to rollup config
bterlson f3cb8a4
Add a normal process shim; nextTick is required
bterlson a986899
Check for window before checking for window.WebSocket
bterlson d07cedb
peerDeps are external in rollup config as well
bterlson 7044f04
Remove some unused devdeps that crept in during rebase
bterlson c22d361
Update package-lock.json
bterlson 62fd1d9
Implement offline check for browser, fix build
bterlson b781cea
Add json plugin and dns shim to rollup config
bterlson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,29 @@ | ||
| { | ||
| "files.exclude": { | ||
| "**/.git": true, | ||
| "**/.svn": true, | ||
| "**/.DS_Store": true | ||
| }, | ||
| "[typescript]": { | ||
| "editor.formatOnSave": true, | ||
| "editor.formatOnPaste": true, | ||
| "editor.tabSize": 2, | ||
| "editor.detectIndentation": false | ||
| }, | ||
| "[json]": { | ||
| "editor.formatOnSave": true, | ||
| "editor.formatOnPaste": true, | ||
| "editor.tabSize": 2, | ||
| "editor.detectIndentation": false | ||
| }, | ||
| "[yaml]": { | ||
| "editor.formatOnSave": true, | ||
| "editor.formatOnPaste": true, | ||
| "editor.tabSize": 2, | ||
| "editor.detectIndentation": false | ||
| }, | ||
| "editor.rulers": [100], | ||
| "typescript.tsdk": "./client/node_modules/typescript/lib" | ||
| } | ||
| "files.exclude": { | ||
| "**/.git": true, | ||
| "**/.svn": true, | ||
| "**/.DS_Store": true | ||
| }, | ||
| "[typescript]": { | ||
| "editor.formatOnSave": true, | ||
| "editor.formatOnPaste": true, | ||
| "editor.tabSize": 2, | ||
| "editor.detectIndentation": false | ||
| }, | ||
| "[json]": { | ||
| "editor.formatOnSave": true, | ||
| "editor.formatOnPaste": true, | ||
| "editor.tabSize": 2, | ||
| "editor.detectIndentation": false | ||
| }, | ||
| "[yaml]": { | ||
| "editor.formatOnSave": true, | ||
| "editor.formatOnPaste": true, | ||
| "editor.tabSize": 2, | ||
| "editor.detectIndentation": false | ||
| }, | ||
| "editor.rulers": [ | ||
| 100 | ||
| ], | ||
| "typescript.tsdk": "./node_modules/typescript/lib" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| // Karma configuration | ||
| // Generated on Fri Mar 08 2019 11:00:13 GMT-0800 (Pacific Standard Time) | ||
|
|
||
| module.exports = function (config) { | ||
| config.set({ | ||
|
|
||
| // base path that will be used to resolve all patterns (eg. files, exclude) | ||
| basePath: '', | ||
|
|
||
|
|
||
| // frameworks to use | ||
| // available frameworks: https://npmjs.org/browse/keyword/karma-adapter | ||
| frameworks: ['mocha'], | ||
|
|
||
|
|
||
| // list of files / patterns to load in the browser | ||
| files: [ | ||
| './test-browser/index.js' | ||
| ], | ||
|
|
||
|
|
||
| // list of files / patterns to exclude | ||
| exclude: [ | ||
| ], | ||
|
|
||
|
|
||
| // preprocess matching files before serving them to the browser | ||
| // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor | ||
| preprocessors: { | ||
| }, | ||
|
|
||
|
|
||
| // test results reporter to use | ||
| // possible values: 'dots', 'progress' | ||
| // available reporters: https://npmjs.org/browse/keyword/karma-reporter | ||
| reporters: ['progress'], | ||
|
|
||
|
|
||
| // web server port | ||
| port: 9876, | ||
|
|
||
|
|
||
| // enable / disable colors in the output (reporters and logs) | ||
| colors: true, | ||
|
|
||
|
|
||
| // level of logging | ||
| // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG | ||
| logLevel: config.LOG_INFO, | ||
|
|
||
|
|
||
| // enable / disable watching file and executing tests whenever any file changes | ||
| autoWatch: false, | ||
|
|
||
|
|
||
| // start these browsers | ||
| // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher | ||
| browsers: ['Chrome'], | ||
|
|
||
|
|
||
| // Continuous Integration mode | ||
| // if true, Karma captures browsers, runs the tests and exits | ||
| singleRun: true, | ||
|
|
||
| // Concurrency level | ||
| // how many browser should be started simultaneous | ||
| concurrency: Infinity, | ||
|
|
||
| client: { | ||
| mocha: { | ||
| timeout: 50000 | ||
| } | ||
| } | ||
| }) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ | |
|
|
||
| import { | ||
| ApplicationTokenCredentials, DeviceTokenCredentials, UserTokenCredentials, MSITokenCredentials | ||
| } from "ms-rest-azure"; | ||
| } from "@azure/ms-rest-nodeauth"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bterlson When you tested Service Bus by pointing the amqp-common dependency to your git branch, were you able to run any of the examples like interactiveLogin, servicePrincipalLogin or the test on auth without making any changes?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ramya-rao-a I didn't try the samples. I'll report here with my findings, though I may need your help getting the AD side set up properly. |
||
| import { TokenInfo, TokenType, TokenProvider } from "./token"; | ||
| import * as Constants from "../util/constants"; | ||
|
|
||
|
|
@@ -50,26 +50,21 @@ export class AadTokenProvider implements TokenProvider { | |
| * @param {string} [audience] - The audience for which the token is desired. If not | ||
| * provided then the Endpoint from the connection string will be applied. | ||
| */ | ||
| getToken(audience?: string): Promise<TokenInfo> { | ||
| async getToken(audience?: string): Promise<TokenInfo> { | ||
| const self = this; | ||
| return new Promise<TokenInfo>((resolve, reject) => { | ||
| self.credentials.getToken((err, result) => { | ||
| if (err) { | ||
| reject(err); | ||
| } | ||
| let expiresOn = Date.now(); | ||
| if (result.expiresOn && result.expiresOn instanceof Date) { | ||
| expiresOn = result.expiresOn.getTime(); | ||
| } | ||
| const expiry = Math.floor(expiresOn / 1000) + | ||
| self.tokenValidTimeInSeconds - Constants.aadTokenValidityMarginSeconds; | ||
| const tokenObj: TokenInfo = { | ||
| expiry: expiry, | ||
| tokenType: TokenType.CbsTokenTypeJwt, | ||
| token: result.accessToken | ||
| }; | ||
| resolve(tokenObj); | ||
| }); | ||
| }); | ||
| const result = await self.credentials.getToken(); | ||
| let expiresOn = Date.now(); | ||
| if (result.expiresOn && result.expiresOn instanceof Date) { | ||
| expiresOn = result.expiresOn.getTime(); | ||
| } | ||
| const expiry = Math.floor(expiresOn / 1000) + | ||
| self.tokenValidTimeInSeconds - Constants.aadTokenValidityMarginSeconds; | ||
| const tokenObj: TokenInfo = { | ||
| expiry: expiry, | ||
| tokenType: TokenType.CbsTokenTypeJwt, | ||
| token: result.accessToken | ||
| }; | ||
|
|
||
| return tokenObj; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| /* tslint:disable */ | ||
| // This file is a stub export filling in missing capabilities in the browser. | ||
| // The AadTokenProvider is only supported in Node. | ||
| export const AadTokenProvider = undefined; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { AadTokenProvider } from "./auth/aad"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.