Update translation web resource#69
Conversation
…plaintext secret key
| const oneMinuteInMs = 60 * oneSecondInMs; | ||
| const oneHourInMs = 60 * oneMinuteInMs; | ||
| const oneSecondInTicks = 10000000; | ||
| var Sdk = window.top.Sdk || {}; |
There was a problem hiding this comment.
Is the name "window.top.Sdk" used anywhere else? Just thinking maybe we need to have a better/more specific name.
There was a problem hiding this comment.
We are using window.top elsewhere, I have left this as is, let me know if you think it's better to use as a constant
| return lanCode; | ||
| }, | ||
| decodeToken: function(token) { | ||
| var base64Url = token.split('.')[1]; |
There was a problem hiding this comment.
null check and array length checking
| }, | ||
| decodeToken: function(token) { | ||
| var base64Url = token.split('.')[1]; | ||
| var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/'); |
| } | ||
| return ISO6391LanCode; | ||
| }, | ||
| return JSON.parse(jsonPayload); |
There was a problem hiding this comment.
let's add exception handling
| "msdyn_isdisplayable": true, | ||
| "msdyn_ocliveworkitemid@odata.bind": "/msdyn_ocliveworkitems(" + conversationId + ")" | ||
| }; | ||
| autoRenewTranslationToken: function(token, timerIds) { |
There was a problem hiding this comment.
add input parameters validations
| return token; | ||
| } | ||
| catch (error){ | ||
| console.log(error); |
| headers: { | ||
| "Content-Type": "application/json; charset=UTF-8", | ||
| "Authorization": | ||
| `Bearer ${C1WebResourceNamespace.authToken}`, |
There was a problem hiding this comment.
Don't we support the secret approach at all? we should still keep the sample around, right?
There was a problem hiding this comment.
Have added this as a separate file for implementation with translator v3 so we can keep the original sample around.
| function () { | ||
| return { | ||
| initializeNewConversation: | ||
| C1WebResourceNamespace.initializeNewConversationInWebResource, |
There was a problem hiding this comment.
nit: why breaking into new light?
| boundParameter: null, | ||
| parameterTypes: {}, | ||
| operationType: 1, // This is an action. Use '1' for functions and '2' for CRUD | ||
| operationName: "msdfm_GetTranslationToken", |
There was a problem hiding this comment.
seems this name should be more generic.
There was a problem hiding this comment.
updated name to getTranslationToken
File contains implementation on Azure Translator v3 using Bearer Token
Updating the translation web resource to fetch the token for Translator resource instead of storing in plaintext javascript which could expose the customer to security risks