Skip to content

Commit

Permalink
include http-only credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
bmschmidt committed Mar 24, 2023
1 parent 97119ce commit 288c95a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 23 deletions.
5 changes: 2 additions & 3 deletions src/interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@ export default class Zoom {
const scales: Record<string, ScaleLinear<number, number>> = {};
if (extent === undefined) {
throw new Error('Error--scales created before extent present.');
return {};
}

interface Scale_datum {
Expand All @@ -316,8 +315,8 @@ export default class Zoom {
for (const [name, dim] of [
['x', width],
['y', height],
]) {
const limits = extent[name];
] as const) {
const limits = extent[name] as [number, number];
const size_range = limits[1] - limits[0];
scale_dat[name] = {
limits,
Expand Down
24 changes: 8 additions & 16 deletions src/tile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ export abstract class Tile {

export class QuadTile extends Tile {
url: string;
bearer_token = '';
key: string;
public _children: Array<this> = [];
codes: [number, number, number];
Expand All @@ -369,13 +368,10 @@ export class QuadTile extends Tile {
base_url: string,
key: string,
parent: QuadTile | null,
dataset: QuadtileSet,
prefs: APICall
dataset: QuadtileSet
) {
super(dataset);
this.url = base_url;
this.bearer_token = prefs?.bearer_token ?? '';

this.parent = parent as this;
this.key = key;
const [z, x, y] = key.split('/').map((d) => Number.parseInt(d));
Expand Down Expand Up @@ -416,16 +412,15 @@ export class QuadTile extends Tile {
let url = `${this.url}/${this.key}.feather`;
this.download_state = 'In progress';

if (this.bearer_token) {
//TODO: Atlas specific code--maybe check for nomic URL too.
if (window.localStorage.getItem('isLoggedIn') === 'true') {
url = url.replace('/public', '');
}

const request: RequestInit | undefined = this.bearer_token
? {
const request: RequestInit = {
method: 'GET',
headers: { Authorization: 'Bearer ' + this.bearer_token },
}
: undefined;
credentials: 'include',
};

this._download = fetch(url, request)
.then(async (response): Promise<void> => {
Expand Down Expand Up @@ -489,14 +484,11 @@ export class QuadTile extends Tile {
k: string,
l: string,
m: this,
data: typeof this.dataset,
prefs: APICall
data: typeof this.dataset
) => this;
if (this._children.length < this.child_locations.length) {
for (const key of this.child_locations) {
const child = new constructor(this.url, key, this, this.dataset, {
bearer_token: this.bearer_token,
});
const child = new constructor(this.url, key, this, this.dataset);
this._children.push(child);
}
}
Expand Down
4 changes: 0 additions & 4 deletions src/typing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ export function isLambdaChannel(input: RootChannel): input is LambdaChannel {
return (input as LambdaChannel).lambda !== undefined;
}

export function isDataChannel(input: RootChannel): input is DataChannel {
return (input as DataChannel).field !== undefined;
}

export function isConstantChannel(
input: RootChannel | ColorChannel
): input is ConstantChannel {
Expand Down

0 comments on commit 288c95a

Please sign in to comment.