private static async step1(session: builder.Session, args?: any | builder.IDialogResult<any>, next?: (args?: builder.IDialogResult<any>) => void): Promise<void> {
        let buttons = new Array<builder.CardAction>();

        if (isMessageFromChannel(session.message)) {
            // create button to deep link to the configurable channel tab - configurable channel tab must have been added for this to work
            // pattern for configurable channel tab deep link:
            // https://teams.microsoft.com/l/entity/APP_ID/ENTITY_ID?webUrl=ENTITY_WEB_URL&label=<entityLabel>&context=CONTEXT
            // APP_ID is the appId assigned in the manifest
            // ENTITY_ID is the entityId that is set for that channel tab when your config page creates it
            // ENTITY_WEB_URL is a url that is opened in a browswer on a mobile device if this url is opened on a mobile device
            // CONTEXT is a url encoded json object with a channelId parameter inside of it
            let appId = config.get("app.appId");
            let configTabEntityId = "test123";
            let queryParams = querystring.stringify({ context: "{\"channelId\":\"" + session.message.sourceEvent.channel.id + "\"}" });
            let configTabHardCodedUrl = "https://teams.microsoft.com/l/entity/" + appId + "/" + configTabEntityId + "?" + queryParams;
            buttons.push(builder.CardAction.openUrl(session, configTabHardCodedUrl, Strings.open_configurable_tab));
        }

        // create a button to deep link to the static tab located in the 1:1 chat with the bot
        // pattern for static tab deep link:
        // (at a minimum to get to the static tab)
        // https://teams.microsoft.com/l/entity/28:BOT_ID/ENTITY_ID?conversationType=chat

        // (for sending data to that tab) - look at the HelpDialog for an example
        // https://teams.microsoft.com/l/entity/28:BOT_ID/ENTITY_ID?conversationType=chat&context=CONTEXT

        // BOT_ID is the bot id that comes from your bot registration with 28: added to the front
        // ENTITY_ID is the entityId that is set for that static tab in the manifest
        // CONTEXT is a url encoded json object with a subEntityId parameter inside of it – this is how you can pass data to your static tab
        // e.g. %7B%22subEntityId%22%3A%22SUB_ENTITY_ID_DATA%22%7D
        let botId = "28:" + config.get("bot.botId");
        let staticTabEntityId = "1on1test123"; // this comes from the manifest file
        let queryParams = querystring.stringify(
            {
                conversationType: "chat",
                context: JSON.stringify({ subEntityId: "stuff" }),
            },
        );
        let staticTabHardCodedUrl = "https://teams.microsoft.com/l/entity/" + botId + "/" + staticTabEntityId + "?" + queryParams;
        buttons.push(builder.CardAction.openUrl(session, staticTabHardCodedUrl, Strings.open_static_tab));

        let newCard = new builder.HeroCard(session)
            .text(Strings.deeplink_card_text, staticTabHardCodedUrl)
            .buttons(buttons);

        session.send(new builder.Message(session)
            .addAttachment(newCard));

        session.endDialog();
    }
示例#2
0
                    return new Promise<string>((resolve, reject) => {
                        const q = qs.stringify({
                            limit: 3
                        });

                        msg.http(FoDApiHelper.getApiUri(`/api/v3/applications/${appId}/scans?${q}`))
                            .headers({
                                'authorization': `Bearer ${token}`,
                                'content-type': 'application/octet-stream'
                            })
                            .get()((err: any, res: any, body: any) => {
                                if (err)
                                    return reject(err);

                                switch (res.statusCode) {
                                    case 200:

                                        const parsedBody = JSON.parse(body);

                                        if (parsedBody && parsedBody.totalCount) {
                                            const items = parsedBody.items.map((item: any) => {
                                                return `${item.scanType} Scan  --  Completed On: ${item.completedDateTime} -- ${item.totalIssues} Issues \
                                                        \n${FoDApiHelper.getSiteUri()}/redirect/releases/${item.releaseId}`;
                                            });

                                            return resolve(`Three most recent scans for App Id ${appId}: \n${items.join('\n')}`);
                                        }

                                        return resolve(`Sorry, I couldn't find anything.`);

                                    case 404:
                                        return resolve(`Sorry, I couldn't find anything.`);
                                }
                            });
                    });
    private static async step1(session: builder.Session, args?: any | builder.IDialogResult<any>, next?: (args?: builder.IDialogResult<any>) => void): Promise<void> {
        let buttons = new Array<builder.CardAction>();
        let botId = "28:" + config.get("bot.botId");
        let staticTabEntityId = "1on1test123"; // this comes from the manifest file
        let queryParams = querystring.stringify(
            {
                conversationType: "chat",
                // context: "{\"subEntityId\":\"allCommands\"}",
                context: JSON.stringify({ subEntityId: "allCommands" }),
            },
        );

        // hardCodedUrl has url encoded {"subEntityId":"allCommands"} set as the context
        let staticTabHardCodedUrl = "https://teams.microsoft.com/l/entity/" + botId + "/" + staticTabEntityId + "?" + queryParams;
        buttons.push(builder.CardAction.openUrl(session, staticTabHardCodedUrl, Strings.all_commands_button));

        let newCard = new builder.HeroCard(session)
            .text(Strings.help_msg)
            .buttons(buttons);

        session.send(new builder.Message(session)
            .addAttachment(newCard));

        session.endDialog();
    }
示例#4
0
    serve(log).then((url) => {
      console.log(url);

      // Open the program in the browser.
      let query = querystring.stringify({ code });
      open_url(url + '/#' + query);
    });
    return new Promise<void>((resolve, reject) => {
      const query = {clientVersion: this.clientVersion};
      const options = {
        uri:
          API +
          '/debuggees/' +
          encodeURIComponent(debuggeeId) +
          '/breakpoints/' +
          encodeURIComponent(breakpointId) +
          '?' +
          qs.stringify(query),
        method: 'DELETE',
        json: true,
      };

      this.request(options, (err, body, response) => {
        if (err) {
          reject(err);
        } else if (!response) {
          reject(new Error('unknown error - request response missing'));
        } else if (response.statusCode !== 200) {
          reject(
            new Error(
              'unable to delete breakpoint, status code ' + response.statusCode
            )
          );
        } else if (Object.keys(body).length > 0) {
          reject(new Error('response body is non-empty'));
        } else {
          resolve();
        }
      });
    });
示例#6
0
文件: index.ts 项目: smbwain/signed
    sign(url: string, options: Types.SignMethodOptions = {}): string {
        const data : {
            e?: number,
            a?: string,
            r: string,
            m?: string
        } = {
            r: Math.floor(Math.random()*10000000000).toString()
        };

        const exp = (options.ttl ? Math.ceil(+new Date()/1000)+options.ttl : null) ||
            options.exp ||
            (this.ttl ? Math.ceil(+new Date()/1000)+this.ttl : null);
        if(exp) {
            data.e = exp;
        }

        if(options.addr) {
            data.a = options.addr;
        }

        if(options.method) {
            data.m = (Array.isArray(options.method) ? options.method.join(',') : options.method).toUpperCase();
        }

        url += (url.indexOf('?') == -1 ? '?' : '&') + 'signed='+querystring.stringify(data, ';', ':') + ';';

        const hash = createHash('md5');
        hash.update(url, 'utf8');
        hash.update(this.secret[0]);

        url += hash.digest('hex');

        return url;
    }
示例#7
0
文件: oPay.ts 项目: EJayCheng/oPay-ts
 /**
  * 提供會員系統查詢 O'Pay 訂單資訊,可透過此 API 來過濾是否為有效訂單,更多應用請參考 [FAQ](https://forum.allpay.com.tw/forum.php?mod=viewthread&tid=95&extra=page%3D1)
  */
 public async queryTradeInfo(info: ITradeInfo) {
   let body = extend<ITradeInfo>(
     {
       TimeStamp: Math.floor(Date.now() / 1000),
       MerchantID: this.config.MerchantID,
       PlatformID: ""
     },
     info
   );
   let check = new V();
   check.verify(body, {
     TimeStamp: [V.isNumber],
     MerchantID: [V.isString, V.limitLength(1, 10)],
     MerchantTradeNo: [
       V.isString,
       V.limitLength(1, 20),
       V.isNumberOrEnglishLetter
     ]
   });
   if (check.invalid) throw check.errorMessage;
   body.CheckMacValue = getMacValue(body, this.config);
   let data = qs.stringify(body);
   return request
     .post(this.config.QueryTradeInfoUrl, {
       form: body,
       headers: {
         "Content-Type": "application/x-www-form-urlencoded",
         "Content-Length": Buffer.byteLength(data)
       },
       json: false
     })
     .then(qs.parse);
 }
示例#8
0
	return getRealm(url).then(authParams => {
		var tokenUrl = `https://accounts.accesscontrol.windows.net/${authParams.realm}/tokens/OAuth/2`;
		var client_id = `${clientId}@${authParams.realm}`;
		var resource = `${authParams.client_id}/${urlParts.host}@${authParams.realm}`;

		var postBody = {
			grant_type: "client_credentials",
			client_id,
			client_secret: clientSecret,
			resource: resource,
			scope: resource
		};
		var bodyStr = querystring.stringify(postBody);

		var opts: any = {
			method: "POST",
			body: bodyStr,
			headers: {
				"Content-Type": "application/x-www-form-urlencoded",
				"Content-Length": bodyStr.length
			}
		};
		return request(tokenUrl, opts).then(data => {
			return data.access_token;
		});
	});
示例#9
0
	var authenticate = function() {
		var emitter = new events.EventEmitter

		var auth_prefixes = {
			v1: '/oauth',
			preview1: '/oauthpreview',
			openpreview1: '/oauthopenpreview',
		}

		// Set up the request
		var verb = 'POST'
		var path = path_join(auth_prefixes[_version], '/token')
		var params = querystring.stringify({grant_type: 'client_credentials'})
		var headers = {
			'authorization': 'Basic ' + new Buffer(_key + ':' + _secret).toString('base64'),
			'content-type': 'application/x-www-form-urlencoded',
			'content-length': params.length,
		}

		// Make the request and propagate the events, storing the token for later
		call(verb, path, params, headers, false)
			.on('done', function(response) {
				_token = response.access_token
				emitter.emit('ready')
			}).on('error', function(error) {
				emitter.emit('error', error)
			})

		return emitter
	}
示例#10
0
                    [SeverityType.Low, SeverityType.Medium, SeverityType.High, SeverityType.Critical].forEach((severity) => {
                        const q = qs.stringify({
                            fields: 'severityString',
                            limit: 1,
                            filters: `severity:${severity}+isSuppressed:false`,
                            excludeFilters: true
                        });

                        promises.push(
                            new Promise<ISeverityCountResult>((resolve, reject) => {
                                msg.http(FoDApiHelper.getApiUri(`/api/v3/releases/${releaseId}/vulnerabilities?${q}`))
                                    .headers({
                                        'authorization': `Bearer ${token}`,
                                        'content-type': 'application/octet-stream'
                                    })
                                    .get()((err: any, res: any, body: any) => {
                                        if (err)
                                            return reject(err);

                                        const result = JSON.parse(body);

                                        if (result && result.totalCount && result.items) {
                                            return resolve({ severityId: severity, severityType: result.items[0].severityString, count: result.totalCount });
                                        }

                                        return resolve(null);
                                    });
                            }));
                    });