-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update translation web resource #69
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null check and array length checking
}, | ||
decodeToken: function(token) { | ||
var base64Url = token.split('.')[1]; | ||
var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null check
} | ||
return ISO6391LanCode; | ||
}, | ||
return JSON.parse(jsonPayload); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's add exception handling
"msdyn_isdisplayable": true, | ||
"[email protected]": "/msdyn_ocliveworkitems(" + conversationId + ")" | ||
}; | ||
autoRenewTranslationToken: function(token, timerIds) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add input parameters validations
return token; | ||
} | ||
catch (error){ | ||
console.log(error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be "console.error"
headers: { | ||
"Content-Type": "application/json; charset=UTF-8", | ||
"Authorization": | ||
`Bearer ${C1WebResourceNamespace.authToken}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we support the secret approach at all? we should still keep the sample around, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems this name should be more generic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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