@oasislabs/parcel
Advanced tools
Comparing version
@@ -1,6 +0,6 @@ | ||
import type { Opaque } from 'type-fest'; | ||
import type { Except, Opaque } from 'type-fest'; | ||
import { Consent } from './consent.js'; | ||
import type { ConsentCreateParams, ConsentId } from './consent.js'; | ||
import type { HttpClient } from './http.js'; | ||
import type { IdentityId, IdentityTokenVerifier } from './identity.js'; | ||
import type { IdentityId, IdentityTokenVerifierCreate } from './identity.js'; | ||
import type { Model, Page, PageParams, PODModel, ResourceId, WritableExcluding } from './model.js'; | ||
@@ -105,5 +105,5 @@ export declare type AppId = Opaque<ResourceId>; | ||
export declare const endpointForId: (id: AppId) => string; | ||
export declare type AppCreateParams = AppUpdateParams | { | ||
export declare type AppCreateParams = Except<AppUpdateParams, 'owner'> & { | ||
/** The credentials used to authorize clients acting as this app. */ | ||
identityTokenVerifiers: IdentityTokenVerifier[]; | ||
identityTokenVerifiers: IdentityTokenVerifierCreate[]; | ||
}; | ||
@@ -110,0 +110,0 @@ export declare type AppUpdateParams = WritableExcluding<App, 'participants' | 'trusted'>; |
@@ -1,2 +0,2 @@ | ||
import type { JsonObject, Opaque } from 'type-fest'; | ||
import type { Opaque } from 'type-fest'; | ||
import type { DatasetId } from './dataset.js'; | ||
@@ -10,3 +10,3 @@ import type { HttpClient } from './http.js'; | ||
*/ | ||
export declare type InputDatasetSpec = JsonObject & { | ||
export declare type InputDatasetSpec = { | ||
mountPath: string; | ||
@@ -18,3 +18,3 @@ id: DatasetId; | ||
*/ | ||
export declare type OutputDatasetSpec = JsonObject & { | ||
export declare type OutputDatasetSpec = { | ||
mountPath: string; | ||
@@ -26,3 +26,3 @@ owner?: IdentityId; | ||
*/ | ||
export declare type OutputDataset = JsonObject & { | ||
export declare type OutputDataset = { | ||
mountPath: string; | ||
@@ -35,3 +35,3 @@ id: DatasetId; | ||
*/ | ||
export declare type JobSpec = JsonObject & { | ||
export declare type JobSpec = { | ||
/** | ||
@@ -99,3 +99,3 @@ * A human-readable name for the job. Intended to help with monitoring and | ||
} | ||
export declare type PODJob = JsonObject & { | ||
export declare type PODJob = { | ||
readonly id: JobId; | ||
@@ -102,0 +102,0 @@ readonly spec: JobSpec; |
import EventEmitter from 'eventemitter3'; | ||
import type { Readable } from 'readable-stream'; | ||
import type { JsonObject, Opaque, RequireExactlyOne, SetOptional } from 'type-fest'; | ||
import type { Opaque, RequireExactlyOne, SetOptional } from 'type-fest'; | ||
import type { HttpClient, Download } from './http.js'; | ||
@@ -20,3 +20,3 @@ import type { IdentityId } from './identity.js'; | ||
}; | ||
declare type DatasetDetails = JsonObject & { | ||
declare type DatasetDetails = { | ||
title?: string; | ||
@@ -23,0 +23,0 @@ tags?: string[]; |
@@ -9,3 +9,2 @@ /// <reference types="node" /> | ||
import type { TokenProvider } from './token.js'; | ||
import './polyfill.js'; | ||
export declare type Config = Partial<{ | ||
@@ -12,0 +11,0 @@ apiUrl: string; |
@@ -5,3 +5,3 @@ import AbortController from 'abort-controller'; | ||
import { paramCase } from 'param-case'; | ||
import './polyfill.js'; // eslint-disable-line import/no-unassigned-import | ||
import { ReadableStreamPF } from './polyfill.js'; | ||
const DEFAULT_API_URL = 'https://api.oasislabs.com/parcel/v1'; | ||
@@ -162,7 +162,16 @@ const EXPECTED_RESPONSE_CODES = new Map([ | ||
async pipeTo(sink) { | ||
var _a; | ||
if ('getWriter' in sink) { | ||
const body = (await this.makeRequest()).body; | ||
return body ? body.pipeTo(sink) : Promise.resolve(); | ||
if (!body) | ||
return; | ||
if (body.pipeTo) { | ||
return body.pipeTo(sink); | ||
} | ||
// Firefox's native ReadableStream is missing pipeTo. | ||
body._readableStreamController = null; // https://github.com/MattiasBuelens/web-streams-polyfill/blob/36c08de/src/lib/readable-stream.ts#L407 | ||
return ReadableStreamPF.prototype.pipeTo.call(body, sink); | ||
} | ||
const Readable = (await import('stream')).Readable; | ||
const stream = await import('stream'); | ||
const Readable = (_a = stream.Readable) !== null && _a !== void 0 ? _a : stream.default.Readable; // Imported differently depending on i-dont-know-what :/ | ||
return new Promise((resolve, reject) => { | ||
@@ -169,0 +178,0 @@ Readable.from(this, { objectMode: false }) |
@@ -1,4 +0,4 @@ | ||
import type { ConditionalExcept, Except, JsonObject, JsonValue } from 'type-fest'; | ||
import type { ConditionalExcept, Except, JsonValue } from 'type-fest'; | ||
export declare type ResourceId = string; | ||
export interface PODModel extends JsonObject { | ||
export interface PODModel { | ||
/** An undifferentiated model identifier. */ | ||
@@ -5,0 +5,0 @@ id: ResourceId; |
@@ -1,1 +0,9 @@ | ||
export {}; | ||
declare const ReadableStreamPF_: { | ||
new (underlyingSource: UnderlyingByteSource, strategy?: { | ||
highWaterMark?: number | undefined; | ||
size?: undefined; | ||
} | undefined): ReadableStream<Uint8Array>; | ||
new <R = any>(underlyingSource?: UnderlyingSource<R> | undefined, strategy?: QueuingStrategy<R> | undefined): ReadableStream<R>; | ||
prototype: ReadableStream<any>; | ||
}; | ||
export { ReadableStreamPF_ as ReadableStreamPF }; |
@@ -7,5 +7,3 @@ // The following code is inlined from `ky-universal` because it uses ES modules and | ||
import fetch, { Headers, Request as RequestPF, Response as ResponsePF } from 'node-fetch'; | ||
// @ts-expect-error: The package isn't ESM-compatible. It's not used by us anyway. | ||
// eslint-disable-next-line import/extensions | ||
import { ReadableStream, WritableStream } from 'web-streams-polyfill/dist/ponyfill.es2018.js'; | ||
import { ReadableStream as ReadableStreamPF, WritableStream as WritableStreamPF, } from 'web-streams-polyfill/dist/ponyfill.es2018.js'; | ||
globalThis.fetch = (_a = globalThis.fetch) !== null && _a !== void 0 ? _a : (async (url, options) => fetch(url, { highWaterMark: 1e7 /* 10 MB */, ...options })); | ||
@@ -17,4 +15,6 @@ globalThis.Headers = (_b = globalThis.Headers) !== null && _b !== void 0 ? _b : Headers; | ||
globalThis.FormData = (_f = globalThis.FormData) !== null && _f !== void 0 ? _f : FormData; | ||
globalThis.ReadableStream = (_g = globalThis.ReadableStream) !== null && _g !== void 0 ? _g : ReadableStream; | ||
globalThis.WritableStream = (_h = globalThis.WritableStream) !== null && _h !== void 0 ? _h : WritableStream; | ||
globalThis.ReadableStream = (_g = globalThis.ReadableStream) !== null && _g !== void 0 ? _g : ReadableStreamPF; | ||
globalThis.WritableStream = (_h = globalThis.WritableStream) !== null && _h !== void 0 ? _h : WritableStreamPF; | ||
const ReadableStreamPF_ = ReadableStreamPF; | ||
export { ReadableStreamPF_ as ReadableStreamPF }; | ||
//# sourceMappingURL=polyfill.js.map |
@@ -36,2 +36,6 @@ import type { ResponsePromise } from 'ky'; | ||
/** | ||
* The audience to use when using provider's OAuth token retrieval endpoint. | ||
*/ | ||
audience: string; | ||
/** | ||
* A list of scopes that will be requested from the identity provider, which | ||
@@ -46,2 +50,3 @@ * may be different from the scopes that the identity provider actually returns. | ||
private readonly tokenEndpoint; | ||
private readonly audience; | ||
private readonly scopes; | ||
@@ -51,3 +56,3 @@ private readonly privateKey; | ||
private readonly clientAssertionLifetime; | ||
constructor({ clientId, privateKey: privateJWK, scopes, tokenEndpoint, }: RenewingTokenProviderParams); | ||
constructor({ clientId, privateKey: privateJWK, scopes, tokenEndpoint, audience, }: RenewingTokenProviderParams); | ||
protected renewToken(): Promise<Token>; | ||
@@ -58,2 +63,3 @@ } | ||
tokenEndpoint: string; | ||
audience: string; | ||
}; | ||
@@ -64,3 +70,4 @@ /** A `TokenProvider` that obtains a new token using a refresh token. */ | ||
private readonly tokenEndpoint; | ||
constructor({ refreshToken, tokenEndpoint }: RefreshingTokenProviderParams); | ||
private readonly audience; | ||
constructor({ refreshToken, tokenEndpoint, audience }: RefreshingTokenProviderParams); | ||
protected renewToken(): Promise<Token>; | ||
@@ -67,0 +74,0 @@ } |
@@ -41,3 +41,3 @@ import { KEYUTIL, KJUR } from 'jsrsasign'; | ||
export class RenewingTokenProvider extends ExpiringTokenProvider { | ||
constructor({ clientId, privateKey: privateJWK, scopes, tokenEndpoint, }) { | ||
constructor({ clientId, privateKey: privateJWK, scopes, tokenEndpoint, audience, }) { | ||
super(); | ||
@@ -50,2 +50,3 @@ this.clientAssertionLifetime = 1 * 60 * 60; // 1 hour | ||
this.tokenEndpoint = tokenEndpoint; | ||
this.audience = audience; | ||
this.scopes = scopes; | ||
@@ -70,2 +71,3 @@ } | ||
authParams.append('scope', this.scopes.join(' ')); | ||
authParams.append('audience', this.audience); | ||
return Token.fromResponse(ky.post(this.tokenEndpoint, { body: authParams })); | ||
@@ -76,6 +78,7 @@ } | ||
export class RefreshingTokenProvider extends ExpiringTokenProvider { | ||
constructor({ refreshToken, tokenEndpoint }) { | ||
constructor({ refreshToken, tokenEndpoint, audience }) { | ||
super(); | ||
this.refreshToken = refreshToken; | ||
this.tokenEndpoint = tokenEndpoint; | ||
this.audience = audience; | ||
} | ||
@@ -86,2 +89,3 @@ async renewToken() { | ||
refreshParams.append('refresh_token', this.refreshToken); | ||
refreshParams.append('audience', this.audience); | ||
const res = ky.post(this.tokenEndpoint, { body: refreshParams }); | ||
@@ -88,0 +92,0 @@ res |
{ | ||
"name": "@oasislabs/parcel", | ||
"version": "0.1.7-manual.1", | ||
"version": "0.1.7", | ||
"license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "author": "Oasis Labs <feedback@oasislabs.com>", |
@@ -1,2 +0,2 @@ | ||
import type { Opaque } from 'type-fest'; | ||
import type { Except, Opaque } from 'type-fest'; | ||
@@ -6,3 +6,3 @@ import { Consent, ConsentImpl } from './consent.js'; | ||
import type { HttpClient } from './http.js'; | ||
import type { IdentityId, IdentityTokenVerifier } from './identity.js'; | ||
import type { IdentityId, IdentityTokenVerifierCreate } from './identity.js'; | ||
import type { Model, Page, PageParams, PODModel, ResourceId, WritableExcluding } from './model.js'; | ||
@@ -187,8 +187,6 @@ | ||
export type AppCreateParams = | ||
| AppUpdateParams | ||
| { | ||
/** The credentials used to authorize clients acting as this app. */ | ||
identityTokenVerifiers: IdentityTokenVerifier[]; | ||
}; | ||
export type AppCreateParams = Except<AppUpdateParams, 'owner'> & { | ||
/** The credentials used to authorize clients acting as this app. */ | ||
identityTokenVerifiers: IdentityTokenVerifierCreate[]; | ||
}; | ||
@@ -195,0 +193,0 @@ export type AppUpdateParams = WritableExcluding<App, 'participants' | 'trusted'>; |
@@ -1,2 +0,2 @@ | ||
import type { JsonObject, Opaque } from 'type-fest'; | ||
import type { Opaque } from 'type-fest'; | ||
@@ -13,3 +13,3 @@ import type { DatasetId } from './dataset.js'; | ||
*/ | ||
export declare type InputDatasetSpec = JsonObject & { | ||
export declare type InputDatasetSpec = { | ||
mountPath: string; | ||
@@ -22,3 +22,3 @@ id: DatasetId; | ||
*/ | ||
export declare type OutputDatasetSpec = JsonObject & { | ||
export declare type OutputDatasetSpec = { | ||
mountPath: string; | ||
@@ -31,3 +31,3 @@ owner?: IdentityId; | ||
*/ | ||
export declare type OutputDataset = JsonObject & { | ||
export declare type OutputDataset = { | ||
mountPath: string; | ||
@@ -41,3 +41,3 @@ id: DatasetId; | ||
*/ | ||
export type JobSpec = JsonObject & { | ||
export type JobSpec = { | ||
/** | ||
@@ -114,3 +114,3 @@ * A human-readable name for the job. Intended to help with monitoring and | ||
export type PODJob = JsonObject & { | ||
export type PODJob = { | ||
readonly id: JobId; | ||
@@ -117,0 +117,0 @@ readonly spec: JobSpec; |
import EventEmitter from 'eventemitter3'; | ||
import FormData from 'form-data'; | ||
import type { Readable } from 'readable-stream'; | ||
import type { JsonObject, Opaque, RequireExactlyOne, SetOptional } from 'type-fest'; | ||
import type { Opaque, RequireExactlyOne, SetOptional } from 'type-fest'; | ||
@@ -26,3 +26,3 @@ import type { HttpClient, Download } from './http.js'; | ||
type DatasetDetails = JsonObject & { title?: string; tags?: string[] }; | ||
type DatasetDetails = { title?: string; tags?: string[] }; | ||
@@ -29,0 +29,0 @@ export class Dataset implements Model { |
@@ -17,3 +17,3 @@ import type { WriteStream } from 'fs'; | ||
import type { TokenProvider } from './token.js'; | ||
import './polyfill.js'; // eslint-disable-line import/no-unassigned-import | ||
import { ReadableStreamPF } from './polyfill.js'; | ||
@@ -219,6 +219,14 @@ const DEFAULT_API_URL = 'https://api.oasislabs.com/parcel/v1'; | ||
const body = (await this.makeRequest()).body; | ||
return body ? body.pipeTo(sink) : Promise.resolve(); | ||
if (!body) return; | ||
if (body.pipeTo) { | ||
return body.pipeTo(sink); | ||
} | ||
// Firefox's native ReadableStream is missing pipeTo. | ||
(body as any)._readableStreamController = null; // https://github.com/MattiasBuelens/web-streams-polyfill/blob/36c08de/src/lib/readable-stream.ts#L407 | ||
return ReadableStreamPF.prototype.pipeTo.call(body, sink); | ||
} | ||
const Readable = (await import('stream')).Readable; | ||
const stream = await import('stream'); | ||
const Readable = stream.Readable ?? stream.default.Readable; // Imported differently depending on i-dont-know-what :/ | ||
return new Promise((resolve, reject) => { | ||
@@ -225,0 +233,0 @@ Readable.from(this, { objectMode: false }) |
@@ -1,6 +0,6 @@ | ||
import type { ConditionalExcept, Except, JsonObject, JsonValue } from 'type-fest'; | ||
import type { ConditionalExcept, Except, JsonValue } from 'type-fest'; | ||
export type ResourceId = string; // Format from runtime: `<resource>-<id>` | ||
export interface PODModel extends JsonObject { | ||
export interface PODModel { | ||
/** An undifferentiated model identifier. */ | ||
@@ -7,0 +7,0 @@ id: ResourceId; |
@@ -7,5 +7,8 @@ // The following code is inlined from `ky-universal` because it uses ES modules and | ||
import fetch, { Headers, Request as RequestPF, Response as ResponsePF } from 'node-fetch'; | ||
// @ts-expect-error: The package isn't ESM-compatible. It's not used by us anyway. | ||
// eslint-disable-next-line import/extensions | ||
import { ReadableStream, WritableStream } from 'web-streams-polyfill/dist/ponyfill.es2018.js'; | ||
import { | ||
ReadableStream as ReadableStreamPF, | ||
WritableStream as WritableStreamPF, | ||
// @ts-expect-error: The package isn't ESM-compatible. | ||
// eslint-disable-next-line import/extensions | ||
} from 'web-streams-polyfill/dist/ponyfill.es2018.js'; | ||
@@ -20,3 +23,7 @@ globalThis.fetch = | ||
globalThis.FormData = globalThis.FormData ?? FormData; | ||
globalThis.ReadableStream = globalThis.ReadableStream ?? ReadableStream; | ||
globalThis.WritableStream = globalThis.WritableStream ?? WritableStream; | ||
globalThis.ReadableStream = globalThis.ReadableStream ?? ReadableStreamPF; | ||
globalThis.WritableStream = globalThis.WritableStream ?? WritableStreamPF; | ||
const ReadableStreamPF_ = ReadableStreamPF as typeof globalThis.ReadableStream; | ||
export { ReadableStreamPF_ as ReadableStreamPF }; |
@@ -69,2 +69,7 @@ import { KEYUTIL, KJUR } from 'jsrsasign'; | ||
/** | ||
* The audience to use when using provider's OAuth token retrieval endpoint. | ||
*/ | ||
audience: string; | ||
/** | ||
* A list of scopes that will be requested from the identity provider, which | ||
@@ -80,2 +85,3 @@ * may be different from the scopes that the identity provider actually returns. | ||
private readonly tokenEndpoint: string; | ||
private readonly audience: string; | ||
private readonly scopes: string[]; | ||
@@ -92,2 +98,3 @@ private readonly privateKey: string; // PKCS8-encoded | ||
tokenEndpoint, | ||
audience, | ||
}: RenewingTokenProviderParams) { | ||
@@ -102,2 +109,3 @@ super(); | ||
this.tokenEndpoint = tokenEndpoint; | ||
this.audience = audience; | ||
this.scopes = scopes; | ||
@@ -127,2 +135,3 @@ } | ||
authParams.append('scope', this.scopes.join(' ')); | ||
authParams.append('audience', this.audience); | ||
@@ -136,2 +145,3 @@ return Token.fromResponse(ky.post(this.tokenEndpoint, { body: authParams })); | ||
tokenEndpoint: string; | ||
audience: string; | ||
}; | ||
@@ -143,7 +153,9 @@ | ||
private readonly tokenEndpoint: string; | ||
private readonly audience: string; | ||
public constructor({ refreshToken, tokenEndpoint }: RefreshingTokenProviderParams) { | ||
public constructor({ refreshToken, tokenEndpoint, audience }: RefreshingTokenProviderParams) { | ||
super(); | ||
this.refreshToken = refreshToken; | ||
this.tokenEndpoint = tokenEndpoint; | ||
this.audience = audience; | ||
} | ||
@@ -155,2 +167,3 @@ | ||
refreshParams.append('refresh_token', this.refreshToken); | ||
refreshParams.append('audience', this.audience); | ||
@@ -157,0 +170,0 @@ const res = ky.post(this.tokenEndpoint, { body: refreshParams }); |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
183486
1.43%3756
1.32%1
-66.67%