in src/client.ts [461:484]
static fromSharedAccessSignature(sharedAccessSignature: string, transportCtor?: Client.TransportCtor): Client {
/*Codes_SRS_NODE_IOTHUB_CLIENT_05_005: [The fromSharedAccessSignature method shall throw ReferenceError if the sharedAccessSignature argument is falsy.]*/
if (!sharedAccessSignature) throw new ReferenceError('sharedAccessSignature is \'' + sharedAccessSignature + '\'');
/*Codes_SRS_NODE_IOTHUB_CLIENT_16_019: [The `fromSharedAccessSignature` method shall use the `Transport` constructor passed as argument to instantiate a transport object if it's not falsy.]*/
/*Codes_SRS_NODE_IOTHUB_CLIENT_16_020: [The `fromSharedAccessSignature` method shall use the default Transport (Amqp) if the `Transport` optional argument is falsy.]*/
if (!transportCtor) {
transportCtor = Amqp;
}
const sas = SharedAccessSignature.parse(sharedAccessSignature);
const decodedUri = decodeURIComponent(sas.sr);
/*Codes_SRS_NODE_IOTHUB_CLIENT_16_018: [The `fromSharedAccessSignature` method shall create a new transport instance and pass it a config object formed from the connection string given as argument.]*/
const config: Client.TransportConfigOptions = {
host: decodedUri,
keyName: sas.skn,
sharedAccessSignature: sas.toString(),
tokenCredential: undefined
};
/*Codes_SRS_NODE_IOTHUB_CLIENT_05_007: [The fromSharedAccessSignature method shall return a new instance of the Client object, as by a call to new Client(transport).]*/
return new Client(new transportCtor(config), new RestApiClient(config, packageJson.name + '/' + packageJson.version));
}