Comparing version
@@ -16,2 +16,3 @@ import { Extra, Config, UploadProgress } from './upload'; | ||
export { getHeadersForMkFile, getHeadersForChunkUpload } from './utils'; | ||
export { urlSafeBase64Encode, urlSafeBase64Decode } from './base64'; | ||
export { CompressResult } from './compress'; | ||
@@ -18,0 +19,0 @@ export { deleteUploadedChunks, getUploadUrl } from './api'; |
@@ -33,2 +33,3 @@ import StatisticsLogger from './statisticsLog'; | ||
export { getHeadersForMkFile, getHeadersForChunkUpload } from './utils'; | ||
export { urlSafeBase64Encode, urlSafeBase64Decode } from './base64'; | ||
export { deleteUploadedChunks, getUploadUrl } from './api'; | ||
@@ -35,0 +36,0 @@ export { imageMogr2, watermark, imageInfo, exif, pipeline } from './image'; |
@@ -15,2 +15,13 @@ /** 消费者接口 */ | ||
} | ||
export interface ErrorObserver<T, E, C> { | ||
next?: (value: T) => void; | ||
error: (err: E) => void; | ||
complete?: (res: C) => void; | ||
} | ||
export interface CompletionObserver<T, E, C> { | ||
next?: (value: T) => void; | ||
error?: (err: E) => void; | ||
complete: (res: C) => void; | ||
} | ||
export declare type PartialObserver<T, E, C> = NextObserver<T, E, C> | ErrorObserver<T, E, C> | CompletionObserver<T, E, C>; | ||
export interface IUnsubscribable { | ||
@@ -26,6 +37,3 @@ /** 取消 observer 的订阅 */ | ||
export interface ISubscribable<T, E, C> { | ||
subscribe(observer?: NextObserver<T, E, C>): IUnsubscribable; | ||
subscribe(next: null | undefined, error: null | undefined, complete: (res: C) => void): IUnsubscribable; | ||
subscribe(next: null | undefined, error: (error: E) => void, complete?: (res: C) => void): IUnsubscribable; | ||
subscribe(next: (value: T) => void, error: null | undefined, complete: (res: C) => void): IUnsubscribable; | ||
subscribe(observer?: PartialObserver<T, E, C> | ((value: T) => void), error?: (error: any) => void, complete?: () => void): IUnsubscribable; | ||
} | ||
@@ -50,3 +58,3 @@ /** 表示可清理的资源,比如 Observable 的执行 */ | ||
protected destination: Partial<IObserver<T, E, C>>; | ||
constructor(observerOrNext?: NextObserver<T, E, C> | ((value: T) => void) | null, error?: ((err: E) => void) | null, complete?: ((res: C) => void) | null); | ||
constructor(observerOrNext?: PartialObserver<T, E, C> | ((value: T) => void) | null, error?: ((err: E) => void) | null, complete?: ((res: C) => void) | null); | ||
unsubscribe(): void; | ||
@@ -61,3 +69,3 @@ next(value: T): void; | ||
constructor(_subscribe: (subscriber: Subscriber<T, E, C>) => TeardownLogic); | ||
subscribe(observer: NextObserver<T, E, C>): Subscription; | ||
subscribe(observer: PartialObserver<T, E, C>): Subscription; | ||
subscribe(next: null | undefined, error: null | undefined, complete: (res: C) => void): Subscription; | ||
@@ -64,0 +72,0 @@ subscribe(next: null | undefined, error: (error: E) => void, complete?: (res: C) => void): Subscription; |
@@ -66,3 +66,8 @@ var __assign = (this && this.__assign) || function () { | ||
this.onComplete = handlers.onComplete; | ||
this.bucket = utils.getPutPolicy(this.token).bucket; | ||
try { | ||
this.bucket = utils.getPutPolicy(this.token).bucket; | ||
} | ||
catch (e) { | ||
this.onError(e); | ||
} | ||
} | ||
@@ -69,0 +74,0 @@ Base.prototype.putFile = function () { |
@@ -257,4 +257,5 @@ var __assign = (this && this.__assign) || function () { | ||
var segments = token.split(':'); | ||
var ak = segments[0]; | ||
var putPolicy = JSON.parse(urlSafeBase64Decode(segments[2])); | ||
// token 构造的差异参考:https://github.com/qbox/product/blob/master/kodo/auths/UpToken.md#admin-uptoken-authorization | ||
var ak = segments.length > 3 ? segments[1] : segments[0]; | ||
var putPolicy = JSON.parse(urlSafeBase64Decode(segments[segments.length - 1])); | ||
return { | ||
@@ -261,0 +262,0 @@ ak: ak, |
@@ -34,2 +34,16 @@ "use strict"; | ||
_Object$defineProperty(exports, "urlSafeBase64Encode", { | ||
enumerable: true, | ||
get: function get() { | ||
return _base.urlSafeBase64Encode; | ||
} | ||
}); | ||
_Object$defineProperty(exports, "urlSafeBase64Decode", { | ||
enumerable: true, | ||
get: function get() { | ||
return _base.urlSafeBase64Decode; | ||
} | ||
}); | ||
_Object$defineProperty(exports, "deleteUploadedChunks", { | ||
@@ -103,2 +117,4 @@ enumerable: true, | ||
var _base = require("./base64"); | ||
var _api = require("./api"); | ||
@@ -105,0 +121,0 @@ |
@@ -222,3 +222,8 @@ "use strict"; | ||
this.onComplete = handlers.onComplete; | ||
this.bucket = utils.getPutPolicy(this.token).bucket; | ||
try { | ||
this.bucket = utils.getPutPolicy(this.token).bucket; | ||
} catch (e) { | ||
this.onError(e); | ||
} | ||
} | ||
@@ -225,0 +230,0 @@ |
@@ -486,5 +486,6 @@ "use strict"; | ||
function getPutPolicy(token) { | ||
var segments = token.split(':'); | ||
var ak = segments[0]; | ||
var putPolicy = JSON.parse((0, _base.urlSafeBase64Decode)(segments[2])); | ||
var segments = token.split(':'); // token 构造的差异参考:https://github.com/qbox/product/blob/master/kodo/auths/UpToken.md#admin-uptoken-authorization | ||
var ak = segments.length > 3 ? segments[1] : segments[0]; | ||
var putPolicy = JSON.parse((0, _base.urlSafeBase64Decode)(segments[segments.length - 1])); | ||
return { | ||
@@ -491,0 +492,0 @@ ak: ak, |
{ | ||
"name": "qiniu-js", | ||
"jsName": "qiniu", | ||
"version": "3.0.2", | ||
"version": "3.0.3", | ||
"private": false, | ||
@@ -6,0 +6,0 @@ "description": "Javascript SDK for Qiniu Resource (Cloud) Storage AP", |
@@ -50,2 +50,4 @@ import StatisticsLogger from './statisticsLog' | ||
export { urlSafeBase64Encode, urlSafeBase64Decode } from './base64' | ||
export { CompressResult } from './compress' | ||
@@ -52,0 +54,0 @@ |
@@ -17,2 +17,16 @@ /** 消费者接口 */ | ||
export interface ErrorObserver<T, E, C> { | ||
next?: (value: T) => void | ||
error: (err: E) => void | ||
complete?: (res: C) => void | ||
} | ||
export interface CompletionObserver<T, E, C> { | ||
next?: (value: T) => void | ||
error?: (err: E) => void | ||
complete: (res: C) => void | ||
} | ||
export type PartialObserver<T, E, C> = NextObserver<T, E, C> | ErrorObserver<T, E, C> | CompletionObserver<T, E, C> | ||
export interface IUnsubscribable { | ||
@@ -31,6 +45,7 @@ /** 取消 observer 的订阅 */ | ||
export interface ISubscribable<T, E, C> { | ||
subscribe(observer?: NextObserver<T, E, C>): IUnsubscribable | ||
subscribe(next: null | undefined, error: null | undefined, complete: (res: C) => void): IUnsubscribable | ||
subscribe(next: null | undefined, error: (error: E) => void, complete?: (res: C) => void): IUnsubscribable | ||
subscribe(next: (value: T) => void, error: null | undefined, complete: (res: C) => void): IUnsubscribable | ||
subscribe( | ||
observer?: PartialObserver<T, E, C> | ((value: T) => void), | ||
error?: (error: any) => void, | ||
complete?: () => void | ||
): IUnsubscribable | ||
} | ||
@@ -73,3 +88,3 @@ | ||
constructor( | ||
observerOrNext?: NextObserver<T, E, C> | ((value: T) => void) | null, | ||
observerOrNext?: PartialObserver<T, E, C> | ((value: T) => void) | null, | ||
error?: ((err: E) => void) | null, | ||
@@ -126,3 +141,3 @@ complete?: ((res: C) => void) | null | ||
subscribe(observer: NextObserver<T, E, C>): Subscription | ||
subscribe(observer: PartialObserver<T, E, C>): Subscription | ||
subscribe(next: null | undefined, error: null | undefined, complete: (res: C) => void): Subscription | ||
@@ -132,3 +147,3 @@ subscribe(next: null | undefined, error: (error: E) => void, complete?: (res: C) => void): Subscription | ||
subscribe( | ||
observerOrNext?: NextObserver<T, E, C> | ((value: T) => void) | null, | ||
observerOrNext?: PartialObserver<T, E, C> | ((value: T) => void) | null, | ||
error?: ((err: E) => void) | null, | ||
@@ -135,0 +150,0 @@ complete?: ((res: C) => void) | null |
@@ -129,4 +129,7 @@ import * as utils from '../utils' | ||
this.onComplete = handlers.onComplete | ||
this.bucket = utils.getPutPolicy(this.token).bucket | ||
try { | ||
this.bucket = utils.getPutPolicy(this.token).bucket | ||
} catch (e) { | ||
this.onError(e) | ||
} | ||
} | ||
@@ -133,0 +136,0 @@ |
@@ -275,4 +275,5 @@ import SparkMD5 from 'spark-md5' | ||
const segments = token.split(':') | ||
const ak = segments[0] | ||
const putPolicy: PutPolicy = JSON.parse(urlSafeBase64Decode(segments[2])) | ||
// token 构造的差异参考:https://github.com/qbox/product/blob/master/kodo/auths/UpToken.md#admin-uptoken-authorization | ||
const ak = segments.length > 3 ? segments[1] : segments[0] | ||
const putPolicy: PutPolicy = JSON.parse(urlSafeBase64Decode(segments[segments.length - 1])) | ||
@@ -279,0 +280,0 @@ return { |
Sorry, the diff of this file is too big to display
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1944382
0.15%26549
0.2%