/
config.js.map
1 lines (1 loc) · 12.3 KB
/
config.js.map
1
{"version":3,"sources":["core/components/config.js"],"names":["setup","db","_db","instanceId","createUUID","secretKey","secret_key","subscribeKey","subscribe_key","publishKey","publish_key","sdkName","sdkFamily","partnerId","setAuthKey","authKey","setCipherKey","cipherKey","setFilterExpression","filterExpression","origin","secure","ssl","restore","proxy","keepAlive","keepAliveSettings","autoNetworkDetection","dedupeOnSubscribe","maximumCacheSize","customEncrypt","customDecrypt","location","protocol","logVerbosity","suppressLeaveEvents","announceFailedHeartbeats","announceSuccessfulHeartbeats","useInstanceId","useRequestId","requestMessageCountThreshold","setTransactionTimeout","transactionalRequestTimeout","setSubscribeTimeout","subscribeRequestTimeout","setSendBeaconConfig","useSendBeacon","setPresenceTimeout","presenceTimeout","heartbeatInterval","setHeartbeatInterval","setUUID","_decideUUID","uuid","val","UUID","set","_presenceTimeout","_heartbeatInterval","_subscribeRequestTimeout","_transactionalRequestTimeout","_useSendBeacon","providedUUID","get"],"mappings":";;;;;;;;AAGA;;;;AACA;;;;;;;AA8HE,wBAAiD;AAAA,QAAnCA,KAAmC,QAAnCA,KAAmC;AAAA,QAA5BC,EAA4B,QAA5BA,EAA4B;;AAAA;;AAC/C,SAAKC,GAAL,GAAWD,EAAX;;AAEA,SAAKE,UAAL,WAAwB,eAAcC,UAAd,EAAxB;AACA,SAAKC,SAAL,GAAiBL,MAAMK,SAAN,IAAmBL,MAAMM,UAA1C;AACA,SAAKC,YAAL,GAAoBP,MAAMO,YAAN,IAAsBP,MAAMQ,aAAhD;AACA,SAAKC,UAAL,GAAkBT,MAAMS,UAAN,IAAoBT,MAAMU,WAA5C;AACA,SAAKC,OAAL,GAAeX,MAAMW,OAArB;AACA,SAAKC,SAAL,GAAiBZ,MAAMY,SAAvB;AACA,SAAKC,SAAL,GAAiBb,MAAMa,SAAvB;AACA,SAAKC,UAAL,CAAgBd,MAAMe,OAAtB;AACA,SAAKC,YAAL,CAAkBhB,MAAMiB,SAAxB;;AAEA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;;yCAC7CJ,G,EAAmB;AAAE,WAAKI,kBAAL,GAA0BJ,GAA1B,CAA+B,OAAO,IAAP;AAAc;;;0CAGzD;AAAE,aAAO,KAAKK,wBAAZ;AAAuC;;;wCACnDL,G,EAAmB;AAAE,WAAKK,wBAAL,GAAgCL,GAAhC,CAAqC,OAAO,IAAP;AAAc;;;4CAE5D;AAAE,aAAO,KAAKM,4BAAZ;AAA2C;;;0CACvDN,G,EAAmB;AAAE,WAAKM,4BAAL,GAAoCN,GAApC,CAAyC,OAAO,IAAP;AAAc;;;0CAEnE;AAAE,aAAO,KAAKO,cAAZ;AAA6B;;;wCAC1CP,G,EAAoB;AAAE,WAAKO,cAAL,GAAsBP,GAAtB,CAA2B,OAAO,IAAP;AAAc;;;iCAE9D;AACnB,aAAO,QAAP;AACD;;;gCAEWQ,Y,EAA8B;AAExC,UAAIA,YAAJ,EAAkB;AAChB,eAAOA,YAAP;AACD;;AAGD,UAAI,KAAK5D,GAAL,IAAY,KAAKA,GAAL,CAAS6D,GAArB,IAA4B,KAAK7D,GAAL,CAAS6D,GAAT,CAAgB,KAAKxD,YAArB,UAAhC,EAA0E;AACxE,eAAO,KAAKL,GAAL,CAAS6D,GAAT,CAAgB,KAAKxD,YAArB,UAAP;AACD;;AAGD,qBAAa,eAAcH,UAAd,EAAb;AACD","file":"config.js","sourcesContent":["/* @flow */\n/* global location */\n\nimport uuidGenerator from './uuid';\nimport { InternalSetupStruct, DatabaseInterface, KeepAliveStruct, ProxyStruct } from '../flow_interfaces';\n\ntype ConfigConstructArgs = {\n setup: InternalSetupStruct,\n db: DatabaseInterface\n}\n\nexport default class {\n\n _db: DatabaseInterface;\n\n subscribeKey: string;\n publishKey: string;\n secretKey: string;\n cipherKey: string;\n authKey: string;\n UUID: string;\n\n proxy: ProxyStruct;\n\n /*\n if _useInstanceId is true, this instanceId will be added to all requests\n */\n instanceId: string;\n\n /*\n If the SDK is running as part of another SDK built atop of it, allow a custom pnsdk with name and version.\n */\n sdkName: string;\n\n /*\n keep track of the SDK family for identifier generator\n */\n sdkFamily: string;\n\n /*\n If the SDK is operated by a partner, allow a custom pnsdk item for them.\n */\n partnerId: string;\n\n /*\n filter expression to pass along when subscribing.\n */\n filterExpression: string;\n /*\n configuration to supress leave events; when a presence leave is performed\n this configuration will disallow the leave event from happening\n */\n suppressLeaveEvents: boolean;\n\n /*\n use SSL for http requests?\n */\n secure: boolean;\n\n // Custom optional origin.\n origin: string;\n\n // log verbosity: true to output lots of info\n logVerbosity: boolean;\n\n // if instanceId config is true, the SDK will pass the unique instance identifier to the server as instanceId=<UUID>\n useInstanceId: boolean;\n\n // if requestId config is true, the SDK will pass a unique request identifier with each request as request_id=<UUID>\n useRequestId: boolean;\n\n // use connection keep-alive for http requests\n keepAlive: ?boolean;\n\n keepAliveSettings: ?KeepAliveStruct;\n\n // if autoNetworkDetection config is true, the SDK will emit NetworkUp and NetworkDown when there changes in the networking\n autoNetworkDetection: ?boolean;\n\n // alert when a heartbeat works out.\n announceSuccessfulHeartbeats: boolean;\n announceFailedHeartbeats: boolean;\n\n /*\n how long the server will wait before declaring that the client is gone.\n */\n _presenceTimeout: number;\n\n /*\n how often (in seconds) the client should announce its presence to server\n */\n _heartbeatInterval: number;\n\n /*\n how long to wait for the server when running the subscribe loop\n */\n _subscribeRequestTimeout: number;\n /*\n how long to wait for the server when making transactional requests\n */\n _transactionalRequestTimeout: number;\n /*\n use send beacon API when unsubscribing.\n https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon\n */\n _useSendBeacon: boolean;\n\n /*\n if set, the SDK will alert if more messages arrive in one subscribe than the theshold\n */\n requestMessageCountThreshold: number;\n\n /*\n Restore subscription list on disconnection.\n */\n restore: boolean;\n\n\n /*\n support for client deduping\n */\n dedupeOnSubscribe: boolean\n maximumCacheSize: number\n\n /*\n support customp encryption and decryption functions.\n */\n customEncrypt: Function // function to support custome encryption of messages\n customDecrypt: Function // function used to decrypt old version messages\n\n constructor({ setup, db } : ConfigConstructArgs) {\n this._db = db;\n\n this.instanceId = `pn-${uuidGenerator.createUUID()}`;\n this.secretKey = setup.secretKey || setup.secret_key;\n this.subscribeKey = setup.subscribeKey || setup.subscribe_key;\n this.publishKey = setup.publishKey || setup.publish_key;\n this.sdkName = setup.sdkName;\n this.sdkFamily = setup.sdkFamily;\n this.partnerId = setup.partnerId;\n this.setAuthKey(setup.authKey);\n this.setCipherKey(setup.cipherKey);\n\n this.setFilterExpression(setup.filterExpression);\n\n this.origin = setup.origin || 'pubsub.pndsn.com';\n this.secure = setup.ssl || false;\n this.restore = setup.restore || false;\n this.proxy = setup.proxy;\n this.keepAlive = setup.keepAlive;\n this.keepAliveSettings = setup.keepAliveSettings;\n this.autoNetworkDetection = setup.autoNetworkDetection || false;\n\n this.dedupeOnSubscribe = setup.dedupeOnSubscribe || false;\n this.maximumCacheSize = setup.maximumCacheSize || 100;\n\n this.customEncrypt = setup.customEncrypt;\n this.customDecrypt = setup.customDecrypt;\n\n // if location config exist and we are in https, force secure to true.\n if (typeof location !== 'undefined' && location.protocol === 'https:') {\n this.secure = true;\n }\n\n this.logVerbosity = setup.logVerbosity || false;\n this.suppressLeaveEvents = setup.suppressLeaveEvents || false;\n\n this.announceFailedHeartbeats = setup.announceFailedHeartbeats || true;\n this.announceSuccessfulHeartbeats = setup.announceSuccessfulHeartbeats || false;\n\n this.useInstanceId = setup.useInstanceId || false;\n this.useRequestId = setup.useRequestId || false;\n\n this.requestMessageCountThreshold = setup.requestMessageCountThreshold;\n\n // set timeout to how long a transaction request will wait for the server (default 15 seconds)\n this.setTransactionTimeout(setup.transactionalRequestTimeout || 15 * 1000);\n // set timeout to how long a subscribe event loop will run (default 310 seconds)\n this.setSubscribeTimeout(setup.subscribeRequestTimeout || 310 * 1000);\n // set config on beacon (https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon) usage\n this.setSendBeaconConfig(setup.useSendBeacon || true);\n // how long the SDK will report the client to be alive before issuing a timeout\n this.setPresenceTimeout(setup.presenceTimeout || 300);\n\n if (setup.heartbeatInterval != null) {\n this.setHeartbeatInterval(setup.heartbeatInterval);\n }\n\n this.setUUID(this._decideUUID(setup.uuid)); // UUID decision depends on subKey.\n }\n\n // exposed setters\n getAuthKey(): string { return this.authKey; }\n setAuthKey(val: string): this { this.authKey = val; return this; }\n setCipherKey(val: string): this { this.cipherKey = val; return this; }\n getUUID(): string { return this.UUID; }\n setUUID(val: string): this {\n if (this._db && this._db.set) this._db.set(`${this.subscribeKey}uuid`, val);\n this.UUID = val;\n return this;\n }\n\n getFilterExpression(): string { return this.filterExpression; }\n setFilterExpression(val: string): this { this.filterExpression = val; return this; }\n\n getPresenceTimeout(): number { return this._presenceTimeout; }\n setPresenceTimeout(val: number): this {\n this._presenceTimeout = val;\n this.setHeartbeatInterval((this._presenceTimeout / 2) - 1);\n return this;\n }\n\n setProxy(proxy: ProxyStruct) {\n this.proxy = proxy;\n }\n\n getHeartbeatInterval(): number { return this._heartbeatInterval; }\n setHeartbeatInterval(val: number): this { this._heartbeatInterval = val; return this; }\n\n // deprecated setters.\n getSubscribeTimeout(): number { return this._subscribeRequestTimeout; }\n setSubscribeTimeout(val: number): this { this._subscribeRequestTimeout = val; return this; }\n\n getTransactionTimeout(): number { return this._transactionalRequestTimeout; }\n setTransactionTimeout(val: number): this { this._transactionalRequestTimeout = val; return this; }\n\n isSendBeaconEnabled(): boolean { return this._useSendBeacon; }\n setSendBeaconConfig(val: boolean): this { this._useSendBeacon = val; return this; }\n\n getVersion(): string {\n return '4.21.5';\n }\n\n _decideUUID(providedUUID: string): string {\n // if the uuid was provided by setup, use this UUID.\n if (providedUUID) {\n return providedUUID;\n }\n\n // if the database module is enabled and we have something saved, use this.\n if (this._db && this._db.get && this._db.get(`${this.subscribeKey}uuid`)) {\n return this._db.get(`${this.subscribeKey}uuid`);\n }\n\n // randomize the UUID and push to storage\n return `pn-${uuidGenerator.createUUID()}`;\n }\n}\n"]}