-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathazure-storage-sas-postman.js
2811 lines (2458 loc) · 64.5 KB
/
azure-storage-sas-postman.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
var accountName = postman.getEnvironmentVariable("device-storage-account-name");
var accountKey = postman.getEnvironmentVariable("device-storage-account-key");
var containerName = postman.getEnvironmentVariable("device-storage-container");
var postmanEnvVariableName = postman.getEnvironmentVariable("device-export-postman-env-variable-name");
var options = {
expiryPeriod: 60,
permissions: 'rwd',
serviceType: 'blob',
container: containerName,
blob: '',
resourceType: 'c',
sasVersion: '2016-05-31'
};
function AzureStorageSas(storageAccount, storageAccessKey, usePathStyleUri) {
this.storageAccount = storageAccount;
this.storageAccessKey = storageAccessKey;
this.usePathStyleUri = usePathStyleUri;
}
AzureStorageSas.prototype.generateAccountSignedQueryString = function (sharedAccessPolicy) {
var addIfNotNull = function (queryString, name, value) {
if (!objectIsNull(name) && !objectIsNull(value)) {
queryString[name] = value;
}
};
var formatAccessPolicyDates = function (accessPolicy) {
if (!objectIsNull(accessPolicy.Start)) {
if (!_.isDate(accessPolicy.Start)) {
accessPolicy.Start = new Date(accessPolicy.Start);
}
accessPolicy.Start = truncatedISO8061Date(accessPolicy.Start);
}
if (!objectIsNull(accessPolicy.Expiry)) {
if (!_.isDate(accessPolicy.Expiry)) {
accessPolicy.Expiry = new Date(accessPolicy.Expiry);
}
accessPolicy.Expiry = truncatedISO8061Date(accessPolicy.Expiry);
}
};
var queryString = {};
addIfNotNull(queryString, QueryStringConstants.SIGNED_VERSION, HeaderConstants.TARGET_STORAGE_VERSION);
// add shared access policy params
if (sharedAccessPolicy.AccessPolicy) {
formatAccessPolicyDates(sharedAccessPolicy.AccessPolicy);
addIfNotNull(queryString, QueryStringConstants.SIGNED_SERVICES, sharedAccessPolicy.AccessPolicy.Services);
addIfNotNull(queryString, QueryStringConstants.SIGNED_RESOURCE_TYPES, sharedAccessPolicy.AccessPolicy.ResourceTypes);
addIfNotNull(queryString, QueryStringConstants.SIGNED_PERMISSIONS, sharedAccessPolicy.AccessPolicy.Permissions);
addIfNotNull(queryString, QueryStringConstants.SIGNED_START, sharedAccessPolicy.AccessPolicy.Start);
addIfNotNull(queryString, QueryStringConstants.SIGNED_EXPIRY, sharedAccessPolicy.AccessPolicy.Expiry);
addIfNotNull(queryString, QueryStringConstants.SIGNED_IP, sharedAccessPolicy.AccessPolicy.IPAddressOrRange);
addIfNotNull(queryString, QueryStringConstants.SIGNED_PROTOCOL, sharedAccessPolicy.AccessPolicy.Protocols);
}
// add signature
addIfNotNull(queryString, QueryStringConstants.SIGNATURE, this._generateAccountSharedAccessSignature(sharedAccessPolicy));
return this.queryStringStringify(queryString);
};
AzureStorageSas.prototype._generateAccountSharedAccessSignature = function (sharedAccessPolicy) {
var getvalueToAppend = function (value, noNewLine) {
var returnValue = '';
if (!objectIsNull(value)) {
returnValue = value;
}
if (noNewLine !== true) {
returnValue += '\n';
}
return returnValue;
}.bind(this);
var stringToSign = getvalueToAppend(this.storageAccount) +
getvalueToAppend(sharedAccessPolicy.AccessPolicy ? sharedAccessPolicy.AccessPolicy.Permissions : '') +
getvalueToAppend(sharedAccessPolicy.AccessPolicy ? sharedAccessPolicy.AccessPolicy.Services : '') +
getvalueToAppend(sharedAccessPolicy.AccessPolicy ? sharedAccessPolicy.AccessPolicy.ResourceTypes : '') +
getvalueToAppend(sharedAccessPolicy.AccessPolicy ? sharedAccessPolicy.AccessPolicy.Start : '') +
getvalueToAppend(sharedAccessPolicy.AccessPolicy ? sharedAccessPolicy.AccessPolicy.Expiry : '') +
getvalueToAppend(sharedAccessPolicy.AccessPolicy ? sharedAccessPolicy.AccessPolicy.IPAddressOrRange : '') +
getvalueToAppend(sharedAccessPolicy.AccessPolicy ? sharedAccessPolicy.AccessPolicy.Protocols : '') +
getvalueToAppend(HeaderConstants.TARGET_STORAGE_VERSION);
return this.signer.sign(stringToSign);
};
AzureStorageSas.prototype.signRequest = function (webResource, callback) {
var getvalueToAppend = function (value, headerName) {
// Do not sign content-length 0 in 2014-08-16 and later
if (headerName === HeaderConstants.CONTENT_LENGTH && (objectIsNull(value[headerName]) || value[headerName].toString() === '0')) {
return '\n';
} else if (objectIsNull(value) || objectIsNull(value[headerName])) {
return '\n';
} else {
return value[headerName] + '\n';
}
};
var stringToSign =
webResource.method + '\n' +
getvalueToAppend(webResource.headers, HeaderConstants.CONTENT_ENCODING) +
getvalueToAppend(webResource.headers, HeaderConstants.CONTENT_LANGUAGE) +
getvalueToAppend(webResource.headers, HeaderConstants.CONTENT_LENGTH) +
getvalueToAppend(webResource.headers, HeaderConstants.CONTENT_MD5) +
getvalueToAppend(webResource.headers, HeaderConstants.CONTENT_TYPE) +
getvalueToAppend(webResource.headers, HeaderConstants.DATE) +
getvalueToAppend(webResource.headers, HeaderConstants.IF_MODIFIED_SINCE) +
getvalueToAppend(webResource.headers, HeaderConstants.IF_MATCH) +
getvalueToAppend(webResource.headers, HeaderConstants.IF_NONE_MATCH) +
getvalueToAppend(webResource.headers, HeaderConstants.IF_UNMODIFIED_SINCE) +
getvalueToAppend(webResource.headers, HeaderConstants.RANGE) +
this._getCanonicalizedHeaders(webResource) +
this._getCanonicalizedResource(webResource);
var signature = this.signer.sign(stringToSign);
webResource.withHeader(HeaderConstants.AUTHORIZATION, 'AzureStorageSas ' + this.storageAccount + ':' + signature);
callback(null);
};
AzureStorageSas.prototype._getCanonicalizedResource = function (webResource) {
var path = '/';
if (webResource.path) {
path = webResource.path;
}
var canonicalizedResource = '/' + this.storageAccount + path;
// Get the raw query string values for signing
var queryStringValues = webResource.queryString;
// Build the canonicalized resource by sorting the values by name.
if (queryStringValues) {
var paramNames = [];
Object.keys(queryStringValues).forEach(function (n) {
paramNames.push(n);
});
paramNames = paramNames.sort();
Object.keys(paramNames).forEach(function (name) {
canonicalizedResource += '\n' + paramNames[name] + ':' + queryStringValues[paramNames[name]];
});
}
return canonicalizedResource;
};
AzureStorageSas.prototype._getCanonicalizedHeaders = function (webResource) {
// Build canonicalized headers
var canonicalizedHeaders = '';
if (webResource.headers) {
var canonicalizedHeadersArray = [];
for (var header in webResource.headers) {
if (header.indexOf(HeaderConstants.PREFIX_FOR_STORAGE) === 0) {
var headerItem = { canonicalized: header.toLowerCase(), original: header };
canonicalizedHeadersArray.push(headerItem);
}
}
canonicalizedHeadersArray.sort(function (a, b) { return a.canonicalized.localeCompare(b.canonicalized); });
_.each(canonicalizedHeadersArray, function (currentHeaderItem) {
var value = webResource.headers[currentHeaderItem.original];
if (!IsNullOrEmptyOrUndefinedOrWhiteSpace(value)) {
canonicalizedHeaders += currentHeaderItem.canonicalized + ':' + value + '\n';
} else {
canonicalizedHeaders += currentHeaderItem.canonicalized + ':\n';
}
});
}
return canonicalizedHeaders;
};
AzureStorageSas.prototype.getSignedQueryString = function (options) {
var resourceName = this.createResourceName(options.container, options.blob, true);
var startDate = new Date();
startDate.setMinutes(-10);
var expiryDate = new Date(startDate);
expiryDate.setMinutes(startDate.getMinutes() + options.expiryPeriod);
var sharedAccessPolicy = {
AccessPolicy: {
Permissions: options.permissions,
Start: startDate,
Expiry: expiryDate
}
};
return this.generateSignedQueryString(options.serviceType, resourceName, sharedAccessPolicy, options.sasVersion, { resourceType: options.resourceType });
};
AzureStorageSas.prototype.createResourceName = function (containerName, blobName, forSAS) {
// Resource name
if (blobName && !forSAS) {
blobName = encodeURIComponent(blobName);
blobName = blobName.replace(/%2F/g, '/');
blobName = blobName.replace(/%5C/g, '/');
blobName = blobName.replace(/\+/g, '%20');
}
// return URI encoded resource name
if (blobName) {
return containerName + '/' + blobName;
}
else {
return containerName;
}
};
AzureStorageSas.prototype.generateSignedQueryString = function (serviceType, path, sharedAccessPolicy, sasVersion, args) {
var addIfNotNull = function (queryString, name, value) {
if (!this.objectIsNull(name) && !this.objectIsNull(value)) {
queryString[name] = value;
}
}.bind(this);
var formatAccessPolicyDates = function (accessPolicy) {
if (!this.objectIsNull(accessPolicy.Start)) {
if (!_.isDate(accessPolicy.Start)) {
accessPolicy.Start = new Date(accessPolicy.Start);
}
accessPolicy.Start = this.truncatedISO8061Date(accessPolicy.Start);
}
if (!this.objectIsNull(accessPolicy.Expiry)) {
if (!_.isDate(accessPolicy.Expiry)) {
accessPolicy.Expiry = new Date(accessPolicy.Expiry);
}
accessPolicy.Expiry = this.truncatedISO8061Date(accessPolicy.Expiry);
}
}.bind(this);
// set up optional args
var queryString;
var resourceType;
var headers;
var tableName;
if (args) {
queryString = args.queryString;
resourceType = args.resourceType;
tableName = args.tableName;
headers = args.headers;
}
if (!queryString) {
queryString = {};
}
// add shared access policy params
if (sharedAccessPolicy.AccessPolicy) {
formatAccessPolicyDates(sharedAccessPolicy.AccessPolicy);
addIfNotNull(queryString, QueryStringConstants.SIGNED_START, sharedAccessPolicy.AccessPolicy.Start);
addIfNotNull(queryString, QueryStringConstants.SIGNED_EXPIRY, sharedAccessPolicy.AccessPolicy.Expiry);
addIfNotNull(queryString, QueryStringConstants.SIGNED_PERMISSIONS, sharedAccessPolicy.AccessPolicy.Permissions);
addIfNotNull(queryString, QueryStringConstants.SIGNED_IP, sharedAccessPolicy.AccessPolicy.IPAddressOrRange);
addIfNotNull(queryString, QueryStringConstants.SIGNED_PROTOCOL, sharedAccessPolicy.AccessPolicy.Protocols);
// tables only
addIfNotNull(queryString, QueryStringConstants.STARTPK, sharedAccessPolicy.AccessPolicy.StartPk);
addIfNotNull(queryString, QueryStringConstants.ENDPK, sharedAccessPolicy.AccessPolicy.EndPk);
addIfNotNull(queryString, QueryStringConstants.STARTRK, sharedAccessPolicy.AccessPolicy.StartRk);
addIfNotNull(queryString, QueryStringConstants.ENDRK, sharedAccessPolicy.AccessPolicy.EndRk);
}
// validate and add version
var validatedSASVersionString = sasVersion; //validateVersion(sasVersion);
addIfNotNull(queryString, QueryStringConstants.SIGNED_VERSION, validatedSASVersionString);
// add signed identifier
addIfNotNull(queryString, QueryStringConstants.SIGNED_IDENTIFIER, sharedAccessPolicy.Id);
// blobs only
addIfNotNull(queryString, QueryStringConstants.SIGNED_RESOURCE, resourceType);
if (headers) {
addIfNotNull(queryString, QueryStringConstants.CACHE_CONTROL, headers.cacheControl);
addIfNotNull(queryString, QueryStringConstants.CONTENT_TYPE, headers.contentType);
addIfNotNull(queryString, QueryStringConstants.CONTENT_ENCODING, headers.contentEncoding);
addIfNotNull(queryString, QueryStringConstants.CONTENT_LANGUAGE, headers.contentLanguage);
addIfNotNull(queryString, QueryStringConstants.CONTENT_DISPOSITION, headers.contentDisposition);
}
// tables only
addIfNotNull(queryString, QueryStringConstants.TABLENAME, tableName);
// add signature
addIfNotNull(queryString, QueryStringConstants.SIGNATURE, this._generateSignature(serviceType, path, sharedAccessPolicy, validatedSASVersionString, { resourceType: resourceType, headers: headers, tableName: tableName }));
return this.queryStringStringify(queryString);
};
AzureStorageSas.prototype._generateSignature = function (serviceType, path, sharedAccessPolicy, sasVersion, args) {
var getvalueToAppend = function (value, noNewLine) {
var returnValue = '';
if (!this.objectIsNull(value)) {
returnValue = value;
}
if (noNewLine !== true) {
returnValue += '\n';
}
return returnValue;
}.bind(this);
// set up optional args
var resourceType;
var tableName;
var headers;
if (args) {
resourceType = args.resourceType;
tableName = args.tableName;
headers = args.headers;
}
// Add leading slash to path
if (path.substr(0, 1) !== '/') {
path = '/' + path;
}
var canonicalizedResource;
canonicalizedResource = '/' + serviceType + '/' + this.storageAccount + path;
var stringToSign = getvalueToAppend(sharedAccessPolicy.AccessPolicy ? sharedAccessPolicy.AccessPolicy.Permissions : '') +
getvalueToAppend(sharedAccessPolicy.AccessPolicy ? sharedAccessPolicy.AccessPolicy.Start : '') +
getvalueToAppend(sharedAccessPolicy.AccessPolicy ? sharedAccessPolicy.AccessPolicy.Expiry : '') +
getvalueToAppend(canonicalizedResource) +
getvalueToAppend(sharedAccessPolicy.Id) +
getvalueToAppend(sharedAccessPolicy.AccessPolicy ? sharedAccessPolicy.AccessPolicy.IPAddressOrRange : '') +
getvalueToAppend(sharedAccessPolicy.AccessPolicy ? sharedAccessPolicy.AccessPolicy.Protocols : '') +
sasVersion;
if (resourceType) {
stringToSign += '\n' +
getvalueToAppend(headers ? headers.cacheControl : '') +
getvalueToAppend(headers ? headers.contentDisposition : '') +
getvalueToAppend(headers ? headers.contentEncoding : '') +
getvalueToAppend(headers ? headers.contentLanguage : '') +
getvalueToAppend(headers ? headers.contentType : '', true);
}
if (tableName) {
stringToSign += '\n' +
getvalueToAppend(sharedAccessPolicy.AccessPolicy ? sharedAccessPolicy.AccessPolicy.StartPk : '') +
getvalueToAppend(sharedAccessPolicy.AccessPolicy ? sharedAccessPolicy.AccessPolicy.StartRk : '') +
getvalueToAppend(sharedAccessPolicy.AccessPolicy ? sharedAccessPolicy.AccessPolicy.EndPk : '') +
getvalueToAppend(sharedAccessPolicy.AccessPolicy ? sharedAccessPolicy.AccessPolicy.EndRk : '', true);
}
return this.signString(stringToSign);
};
AzureStorageSas.prototype.signString = function (stringToSign) {
var decodedKey = CryptoJS.enc.Base64.parse(this.storageAccessKey);
var hmac = CryptoJS.HmacSHA256(stringToSign, decodedKey); // The signature generated from the decodedKey
var digest = CryptoJS.enc.Base64.stringify(hmac);
return digest;
}
AzureStorageSas.prototype.objectIsNull = function (value) {
return _.isNull(value) || _.isUndefined(value);
};
AzureStorageSas.prototype.truncatedISO8061Date = function (date) {
var dateString = date.toISOString();
return dateString.substring(0, dateString.length - 5) + 'Z';
};
//AzureStorageSas.prototype.queryStringStringify =
var stringifyPrimitive = function (v) {
switch (typeof v) {
case 'string':
return v;
case 'boolean':
return v ? 'true' : 'false';
case 'number':
return isFinite(v) ? v : '';
default:
return '';
}
};
AzureStorageSas.prototype.queryStringStringify = function (obj, sep, eq, name) {
sep = sep || '&';
eq = eq || '=';
if (obj === null) {
obj = undefined;
}
if (typeof obj === 'object') {
return Object.keys(obj).map(function (k) {
var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
if (Array.isArray(obj[k])) {
return obj[k].map(function (v) {
return ks + encodeURIComponent(stringifyPrimitive(v));
}).join(sep);
} else {
return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
}
}).join(sep);
}
if (!name) return '';
return encodeURIComponent(stringifyPrimitive(name)) + eq +
encodeURIComponent(stringifyPrimitive(obj));
};
var storageDnsSuffix = 'core.windows.net'; //process.env.AZURE_STORAGE_DNS_SUFFIX || 'core.windows.net';
/**
* Defines constants.
*/
var Constants = {
/*
* Specifies the value to use for UserAgent header.
*/
USER_AGENT_PRODUCT_NAME: 'Azure-Storage',
/*
* Specifies the value to use for UserAgent header.
*/
USER_AGENT_PRODUCT_VERSION: '2.1.0',
/**
* The number of default concurrent requests for parallel operation.
*
* @const
* @type {string}
*/
DEFAULT_PARALLEL_OPERATION_THREAD_COUNT: 5,
/**
* Constant representing a kilobyte (Non-SI version).
*
* @const
* @type {string}
*/
KB: 1024,
/**
* Constant representing a megabyte (Non-SI version).
*
* @const
* @type {string}
*/
MB: 1024 * 1024,
/**
* Constant representing a gigabyte (Non-SI version).
*
* @const
* @type {string}
*/
GB: 1024 * 1024 * 1024,
/**
* Specifies HTTP.
*
* @const
* @type {string}
*/
HTTP: 'http:',
/**
* Specifies HTTPS.
*
* @const
* @type {string}
*/
HTTPS: 'https:',
/**
* Default HTTP port.
*
* @const
* @type {int}
*/
DEFAULT_HTTP_PORT: 80,
/**
* Default HTTPS port.
*
* @const
* @type {int}
*/
DEFAULT_HTTPS_PORT: 443,
/**
* Default client request timeout in milliseconds.
* Integer containing the number of milliseconds to wait for a server to send response headers (and start the response body) before aborting the request.
* 2 minutes by default.
*
* @constant
* @type {int}
*/
DEFAULT_CLIENT_REQUEST_TIMEOUT_IN_MS: 120000,
/**
* Marker for atom metadata.
*
* @const
* @type {string}
*/
XML_METADATA_MARKER: '$',
/**
* Marker for atom value.
*
* @const
* @type {string}
*/
XML_VALUE_MARKER: '_',
/**
* Defines the service types indicators.
*
* @const
* @enum
*/
ServiceType: {
Blob: 'blob',
Queue: 'queue',
Table: 'table',
File: 'file',
},
/**
* Specifies the location used to indicate which location the operation can be performed against.
*
* @const
* @enum
*/
RequestLocationMode: {
PRIMARY_ONLY: 0,
SECONDARY_ONLY: 1,
PRIMARY_OR_SECONDARY: 2,
},
/**
* Represents a storage service location.
*
* @const
* @enum
*/
StorageLocation: {
PRIMARY: 0,
SECONDARY: 1,
},
AccountSasConstants: {
/**
* Permission types
*
* @const
* @enum {string}
*/
Permissions: {
READ: 'r',
ADD: 'a',
CREATE: 'c',
UPDATE: 'u',
PROCESS: 'p',
WRITE: 'w',
DELETE: 'd',
LIST: 'l'
},
/**
* Services types
*
* @const
* @enum {string}
*/
Services: {
BLOB: 'b',
FILE: 'f',
QUEUE: 'q',
TABLE: 't',
},
/**
* Resources types
*
* @const
* @enum {string}
*/
Resources: {
SERVICE: 's',
CONTAINER: 'c',
OBJECT: 'o'
},
Protocols: {
HTTPSONLY: 'https',
HTTPSORHTTP: 'https,http'
},
},
/**
* Defines constants for use with shared access policies.
*/
AclConstants: {
/**
* XML element for an access policy.
*
* @const
* @type {string}
*/
ACCESS_POLICY: 'AccessPolicy',
/**
* XML element for the end time of an access policy.
*
* @const
* @type {string}
*/
EXPIRY: 'Expiry',
/**
* XML attribute for IDs.
*
* @const
* @type {string}
*/
ID: 'Id',
/**
* XML element for the permission of an access policy.
*
* @const
* @type {string}
*/
PERMISSION: 'Permission',
/**
* XML element for a signed identifier.
*
* @const
* @type {string}
*/
SIGNED_IDENTIFIER_ELEMENT: 'SignedIdentifier',
/**
* XML element for signed identifiers.
*
* @const
* @type {string}
*/
SIGNED_IDENTIFIERS_ELEMENT: 'SignedIdentifiers',
/**
* XML element for the start time of an access policy.
*
* @const
* @type {string}
*/
START: 'Start'
},
/**
* Defines constants for use with service properties.
*/
ServicePropertiesConstants: {
/**
* XML element for storage service properties.
*
* @const
* @type {string}
*/
STORAGE_SERVICE_PROPERTIES_ELEMENT: 'StorageServiceProperties',
/**
* Default analytics version to send for logging, hour metrics and minute metrics.
*
* @const
* @type {string}
*/
DEFAULT_ANALYTICS_VERSION: '1.0',
/**
* XML element for logging.
*
* @const
* @type {string}
*/
LOGGING_ELEMENT: 'Logging',
/**
* XML element for version.
*
* @const
* @type {string}
*/
VERSION_ELEMENT: 'Version',
/**
* XML element for delete.
*
* @const
* @type {string}
*/
DELETE_ELEMENT: 'Delete',
/**
* XML element for read.
*
* @const
* @type {string}
*/
READ_ELEMENT: 'Read',
/**
* XML element for write.
*
* @const
* @type {string}
*/
WRITE_ELEMENT: 'Write',
/**
* XML element for retention policy.
*
* @const
* @type {string}
*/
RETENTION_POLICY_ELEMENT: 'RetentionPolicy',
/**
* XML element for enabled.
*
* @const
* @type {string}
*/
ENABLED_ELEMENT: 'Enabled',
/**
* XML element for days.
*
* @const
* @type {string}
*/
DAYS_ELEMENT: 'Days',
/**
* XML element for HourMetrics.
*
* @const
* @type {string}
*/
HOUR_METRICS_ELEMENT: 'HourMetrics',
/**
* XML element for MinuteMetrics.
*
* @const
* @type {string}
*/
MINUTE_METRICS_ELEMENT: 'MinuteMetrics',
/**
* XML element for Cors.
*
* @const
* @type {string}
*/
CORS_ELEMENT: 'Cors',
/**
* XML element for CorsRule.
*
* @const
* @type {string}
*/
CORS_RULE_ELEMENT: 'CorsRule',
/**
* XML element for AllowedOrigins.
*
* @const
* @type {string}
*/
ALLOWED_ORIGINS_ELEMENT: 'AllowedOrigins',
/**
* XML element for AllowedMethods.
*
* @const
* @type {string}
*/
ALLOWED_METHODS_ELEMENT: 'AllowedMethods',
/**
* XML element for MaxAgeInSeconds.
*
* @const
* @type {string}
*/
MAX_AGE_IN_SECONDS_ELEMENT: 'MaxAgeInSeconds',
/**
* XML element for ExposedHeaders.
*
* @const
* @type {string}
*/
EXPOSED_HEADERS_ELEMENT: 'ExposedHeaders',
/**
* XML element for AllowedHeaders.
*
* @const
* @type {string}
*/
ALLOWED_HEADERS_ELEMENT: 'AllowedHeaders',
/**
* XML element for IncludeAPIs.
*
* @const
* @type {string}
*/
INCLUDE_APIS_ELEMENT: 'IncludeAPIs',
/**
* XML element for DefaultServiceVersion.
*
* @const
* @type {string}
*/
DEFAULT_SERVICE_VERSION_ELEMENT: 'DefaultServiceVersion'
},
/**
* Defines constants for use with blob operations.
*/
BlobConstants: {
/**
* XML element for the latest.
*
* @const
* @type {string}
*/
LATEST_ELEMENT: 'Latest',
/**
* XML element for uncommitted blocks.
*
* @const
* @type {string}
*/
UNCOMMITTED_ELEMENT: 'Uncommitted',
/**
* XML element for a block list.
*
* @const
* @type {string}
*/
BLOCK_LIST_ELEMENT: 'BlockList',
/**
* XML element for committed blocks.
*
* @const
* @type {string}
*/
COMMITTED_ELEMENT: 'Committed',
/**
* The default write page size, in bytes, used by blob streams.
*
* @const
* @type {int}
*/
DEFAULT_WRITE_PAGE_SIZE_IN_BYTES: 4 * 1024 * 1024,
/**
* The minimum write page size, in bytes, used by blob streams.
*
* @const
* @type {int}
*/
MIN_WRITE_PAGE_SIZE_IN_BYTES: 2 * 1024 * 1024,
/**
* The default maximum size, in bytes, of a blob before it must be separated into blocks.
*
* @const
* @type {int}
*/
DEFAULT_SINGLE_BLOB_PUT_THRESHOLD_IN_BYTES: 32 * 1024 * 1024,
/**
* The default write block size, in bytes, used by blob streams.
*
* @const
* @type {int}
*/
DEFAULT_WRITE_BLOCK_SIZE_IN_BYTES: 4 * 1024 * 1024,
/**
* The maximum size of a single block of block blob.
*
* @const
* @type {int}
*/
MAX_BLOCK_BLOB_BLOCK_SIZE: 100 * 1024 * 1024,
/**
* The maximum size of a single block of append blob.
*
* @const
* @type {int}
*/
MAX_APPEND_BLOB_BLOCK_SIZE: 4 * 1024 * 1024,
/**
* The maximum size, in bytes, of a blob before it must be separated into blocks.
*
* @const
* @type {int}
*/
MAX_SINGLE_UPLOAD_BLOB_SIZE_IN_BYTES: 64 * 1024 * 1024,
/**
* The maximum range get size when requesting for a contentMD5
*/
MAX_RANGE_GET_SIZE_WITH_MD5: 4 * 1024 * 1024,
/**
* The maximum page range size for a page update operation.
*/
MAX_UPDATE_PAGE_SIZE: 4 * 1024 * 1024,
/**
* The maximum buffer size for writing a stream buffer.
*/
MAX_QUEUED_WRITE_DISK_BUFFER_SIZE: 64 * 1024 * 1024,
/**
* Max size for single get page range. The max value should be 150MB
* http://blogs.msdn.com/b/windowsazurestorage/archive/2012/03/26/getting-the-page-ranges-of-a-large-page-blob-in-segments.aspx
*/
MAX_SINGLE_GET_PAGE_RANGE_SIZE: 37 * 4 * 1024 * 1024,
/**
* The size of a page, in bytes, in a page blob.
*
* @const
* @type {string}
*/
PAGE_SIZE: 512,
/**
* Resource types.
*
* @const
* @enum {string}
*/
ResourceTypes: {
CONTAINER: 'c',
BLOB: 'b'
},
/**
* List blob types.
*
* @const
* @enum {string}
*/
ListBlobTypes: {
Blob: 'b',
Directory: 'd'
},
/**
* Put page write options
*
* @const
* @enum {string}