|  | 
| 768 | 768 |             return this; | 
| 769 | 769 |         }; | 
| 770 | 770 |         default_1.prototype.getVersion = function () { | 
| 771 |  | -            return '7.2.1'; | 
|  | 771 | +            return '7.2.2'; | 
| 772 | 772 |         }; | 
| 773 | 773 |         default_1.prototype._addPnsdkSuffix = function (name, suffix) { | 
| 774 | 774 |             this._PNSDKSuffix[name] = suffix; | 
|  | 
| 4706 | 4706 |                             } | 
| 4707 | 4707 |                             _s.label = 4; | 
| 4708 | 4708 |                         case 4: | 
| 4709 |  | -                            _s.trys.push([4, 18, , 20]); | 
|  | 4709 | +                            _s.trys.push([4, 18, , 22]); | 
| 4710 | 4710 |                             if (!(PubNubFile.supportsFileUri && input.uri)) return [3 /*break*/, 7]; | 
| 4711 | 4711 |                             _f = (_e = networking).POSTFILE; | 
| 4712 | 4712 |                             _g = [url, formFieldsWithMimeType]; | 
|  | 
| 4743 | 4743 |                             result = _s.sent(); | 
| 4744 | 4744 |                             return [3 /*break*/, 17]; | 
| 4745 | 4745 |                         case 16: throw new Error('Unsupported environment'); | 
| 4746 |  | -                        case 17: return [3 /*break*/, 20]; | 
|  | 4746 | +                        case 17: return [3 /*break*/, 22]; | 
| 4747 | 4747 |                         case 18: | 
| 4748 | 4748 |                             e_1 = _s.sent(); | 
|  | 4749 | +                            if (!e_1.response) return [3 /*break*/, 20]; | 
| 4749 | 4750 |                             return [4 /*yield*/, getErrorFromResponse(e_1.response)]; | 
| 4750 | 4751 |                         case 19: | 
| 4751 | 4752 |                             errorBody = _s.sent(); | 
| 4752 | 4753 |                             reason = /<Message>(.*)<\/Message>/gi.exec(errorBody); | 
| 4753 | 4754 |                             throw new PubNubError(reason ? "Upload to bucket failed: ".concat(reason[1]) : 'Upload to bucket failed.', e_1); | 
| 4754 |  | -                        case 20: | 
|  | 4755 | +                        case 20: throw new PubNubError('Upload to bucket failed.', e_1); | 
|  | 4756 | +                        case 21: return [3 /*break*/, 22]; | 
|  | 4757 | +                        case 22: | 
| 4755 | 4758 |                             if (result.status !== 204) { | 
| 4756 | 4759 |                                 throw new PubNubError('Upload to bucket was unsuccessful', result); | 
| 4757 | 4760 |                             } | 
| 4758 | 4761 |                             retries = config.fileUploadPublishRetryLimit; | 
| 4759 | 4762 |                             wasSuccessful = false; | 
| 4760 | 4763 |                             publishResult = { timetoken: '0' }; | 
| 4761 |  | -                            _s.label = 21; | 
| 4762 |  | -                        case 21: | 
| 4763 |  | -                            _s.trys.push([21, 23, , 24]); | 
|  | 4764 | +                            _s.label = 23; | 
|  | 4765 | +                        case 23: | 
|  | 4766 | +                            _s.trys.push([23, 25, , 26]); | 
| 4764 | 4767 |                             return [4 /*yield*/, publishFile({ | 
| 4765 | 4768 |                                     channel: channel, | 
| 4766 | 4769 |                                     message: message, | 
|  | 
| 4770 | 4773 |                                     storeInHistory: storeInHistory, | 
| 4771 | 4774 |                                     ttl: ttl, | 
| 4772 | 4775 |                                 })]; | 
| 4773 |  | -                        case 22: | 
|  | 4776 | +                        case 24: | 
| 4774 | 4777 |                             /* eslint-disable-next-line no-await-in-loop */ | 
| 4775 | 4778 |                             publishResult = _s.sent(); | 
| 4776 | 4779 |                             wasSuccessful = true; | 
| 4777 |  | -                            return [3 /*break*/, 24]; | 
| 4778 |  | -                        case 23: | 
|  | 4780 | +                            return [3 /*break*/, 26]; | 
|  | 4781 | +                        case 25: | 
| 4779 | 4782 |                             _s.sent(); | 
| 4780 | 4783 |                             retries -= 1; | 
| 4781 |  | -                            return [3 /*break*/, 24]; | 
| 4782 |  | -                        case 24: | 
| 4783 |  | -                            if (!wasSuccessful && retries > 0) return [3 /*break*/, 21]; | 
| 4784 |  | -                            _s.label = 25; | 
| 4785 |  | -                        case 25: | 
|  | 4784 | +                            return [3 /*break*/, 26]; | 
|  | 4785 | +                        case 26: | 
|  | 4786 | +                            if (!wasSuccessful && retries > 0) return [3 /*break*/, 23]; | 
|  | 4787 | +                            _s.label = 27; | 
|  | 4788 | +                        case 27: | 
| 4786 | 4789 |                             if (!wasSuccessful) { | 
| 4787 | 4790 |                                 throw new PubNubError('Publish failed. You may want to execute that operation manually using pubnub.publishFile', { | 
| 4788 | 4791 |                                     channel: channel, | 
|  | 
| 4817 | 4820 |     /**       */ | 
| 4818 | 4821 |     var getFileUrlFunction = (function (modules, _a) { | 
| 4819 | 4822 |         var channel = _a.channel, id = _a.id, name = _a.name; | 
| 4820 |  | -        var config = modules.config, networking = modules.networking; | 
|  | 4823 | +        var config = modules.config, networking = modules.networking, tokenManager = modules.tokenManager; | 
| 4821 | 4824 |         if (!channel) { | 
| 4822 | 4825 |             throw new PubNubError('Validation failed, check status for details', createValidationError("channel can't be empty")); | 
| 4823 | 4826 |         } | 
|  | 
| 4831 | 4834 |         var params = {}; | 
| 4832 | 4835 |         params.uuid = config.getUUID(); | 
| 4833 | 4836 |         params.pnsdk = generatePNSDK(config); | 
| 4834 |  | -        if (config.getAuthKey()) { | 
| 4835 |  | -            params.auth = config.getAuthKey(); | 
|  | 4837 | +        var tokenOrKey = tokenManager.getToken() || config.getAuthKey(); | 
|  | 4838 | +        if (tokenOrKey) { | 
|  | 4839 | +            params.auth = tokenOrKey; | 
| 4836 | 4840 |         } | 
| 4837 | 4841 |         if (config.secretKey) { | 
| 4838 | 4842 |             signRequest(modules, url, params, {}, { | 
|  | 
0 commit comments