Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cosmos] Remove atob in favor of local version #5334

Merged
merged 3 commits into from
Oct 2, 2019
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
4 changes: 2 additions & 2 deletions sdk/cosmosdb/cosmos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"main": "./dist/index.js",
"module": "./dist-esm/index.js",
"browser": {
"./dist-esm/request/defaultAgent.js": "./dist-esm/request/defaultAgent.browser.js"
"./dist-esm/request/defaultAgent.js": "./dist-esm/request/defaultAgent.browser.js",
"./dist-esm/utils/atob.js": "./dist-esm/utils/atob.browser.js"
},
"files": [
"changelog.md",
Expand Down Expand Up @@ -72,7 +73,6 @@
"dependencies": {
"@azure/cosmos-sign": "^1.0.2",
"@types/debug": "^4.1.4",
"atob": "^2.1.2",
"binary-search-bounds": "^2.0.3",
"crypto-hash": "^1.1.0",
"debug": "^4.1.1",
Expand Down
2 changes: 1 addition & 1 deletion sdk/cosmosdb/cosmos/src/session/sessionContainer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import atob from "atob";
import atob from "../utils/atob";
import { Constants, getContainerLink, OperationType, ResourceType, trimSlashes } from "../common";
import { CosmosHeaders } from "../queryExecutionContext";
import { SessionContext } from "./SessionContext";
Expand Down
6 changes: 0 additions & 6 deletions sdk/cosmosdb/cosmos/src/typings/atob.d.ts

This file was deleted.

5 changes: 5 additions & 0 deletions sdk/cosmosdb/cosmos/src/utils/atob.browser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if ("function" === typeof atob) {
mengyu-zhang-dev marked this conversation as resolved.
Show resolved Hide resolved
throw new Error("Your browser environment is missing the global `atob` function");
}

export default atob;
3 changes: 3 additions & 0 deletions sdk/cosmosdb/cosmos/src/utils/atob.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function atob(str: string) {
return Buffer.from(str, "base64").toString("binary");
}