diff --git a/ClickToCall/.eslintrc.json b/ClickToCall/.eslintrc.json index dfc3da9..ed73777 100644 --- a/ClickToCall/.eslintrc.json +++ b/ClickToCall/.eslintrc.json @@ -24,7 +24,12 @@ "FirebaseKeyProvider": false, "KeyProtect": false, "USER_SECRET": false, - "KMS_ARGON_WASM_URL": false + "KMS_ARGON_WASM_URL": false, + "GooglePeopleUserManager": false, + "AUTH_CONFIGURATION": false, + "AuthenticationManager": false, + "MockUserManager": false, + "AzureUserManager": false }, "rules": @@ -34,7 +39,7 @@ [ "error", { - "varsIgnorePattern": "makeCall|KMS_ARGON_WASM_URL|CONTACT_REG_ID|ID_PROVIDER_DOMAIN|USER_SECRET|ID_PROVIDER_ENVIRONMENT|createAuthManager|createUserManager|createKeyProvider|createKeyProtect" + "varsIgnorePattern": "AUTH_CONFIGURATION|makeCall|KMS_ARGON_WASM_URL|CONTACT_REG_ID|ID_PROVIDER_DOMAIN|USER_SECRET|ID_PROVIDER_ENVIRONMENT|createAuthManager|createUserManager" } ] } diff --git a/ClickToCall/README.md b/ClickToCall/README.md index f461da6..6de350c 100644 --- a/ClickToCall/README.md +++ b/ClickToCall/README.md @@ -1,15 +1,17 @@ -![BlackBerry Spark Communications Platform](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/resources/images/bnr-bbm-enterprise-sdk-title.png) +![BlackBerry Spark Communications Services](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/resources/images/bnr-bbm-enterprise-sdk-title.png) # Click To Call Sample for JavaScript The Click to Call sample app demonstrates how to integrate a video call -experience into your website with the Spark SDK for JavaScript. This app allows a user to click a button on a webpage to start a secure video call with a predefined user or agent. The bbmChat widget handles the rendering of messages within the chat, and allows the user to send text, picture, and file messages. +experience into your website with the Spark Communications SDK. This app allows +a user to click a button on a webpage to start a secure video call with a +predefined user or agent. The bbmCall widget handles the rendering of the +incoming and outgoing video streams. ### Features This app demonstrates how easy it is to integrate the bbmCall widget into your -webpage. It initializes the Spark SDK for JavaScript, and starts a -video call with a predefined user. +webpage. It initializes the SDK, and starts a video call with a predefined user.
@@ -19,9 +21,9 @@ video call with a predefined user. ## Getting Started -This sample requires the Spark SDK, which you can find along with related resources at the location below. +This sample requires the Spark Communications SDK for JavaScript, which you can find along with related resources at the location below. -* Getting started with the [Spark SDK](https://developers.blackberry.com/us/en/products/blackberry-bbm-enterprise-sdk.html) +* Getting started with the [Spark Communications SDK](https://developers.blackberry.com/us/en/products/blackberry-spark-communications-platform.html) * [Development Guide](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/html/index.html) * [API Reference](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/reference/javascript/index.html) @@ -44,7 +46,7 @@ To use the ClickToCall example, you must set up the following elements in js/con - Oauth2 configuration (AUTH_CONFIGURATION) - A hard coded contact registration ID with whom anyone who views the page will talk (CONTACT_REG_ID) -- Your Spark user domain (ID_PROVIDER_DOMAIN) +- Your sandbox domain (ID_PROVIDER_DOMAIN) - Firebase configuration (FIREBASE_CONFIG) - User passcode (USER_SECRET) @@ -53,7 +55,7 @@ To use the ClickToCall example, you must set up the following elements in js/con Follow this guide for a walkthrough of how to integrate a video call into your webpage. - [Import the bbmCall UI widget into your web application](#importCall) -- [Initialize the Spark SDK for JavaScript](#init) +- [Initialize the SDK](#init) - [Perform setup](#setup) - [Start a video call with a predefined user](#startCall) @@ -65,7 +67,7 @@ Your web application needs to import the bbmCall widget in order to bring a vide ``` -### Initialize the Spark SDK for JavaScript +### Initialize the SDK ```javascript // Instantiate BBMEnterprise. @@ -80,7 +82,7 @@ Your web application needs to import the bbmCall widget in order to bring a vide }); ``` -For more information about setting up the Spark SDK for JavaScript, visit the [Getting Started with Web](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/html/gettingStarted-web.html) section of the guide. +For more information about setting up the SDK, visit the [Getting Started with Web](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/html/gettingStarted-web.html) section of the guide. ### Perform setup ```javascript diff --git a/ClickToCall/callPopup.html b/ClickToCall/callPopup.html index b77c492..eb04578 100644 --- a/ClickToCall/callPopup.html +++ b/ClickToCall/callPopup.html @@ -22,16 +22,37 @@ - - - - + + + + + + + + + + + + + + + + diff --git a/ClickToCall/js/callPopup.js b/ClickToCall/js/callPopup.js index c5cf30b..09f9dc1 100644 --- a/ClickToCall/js/callPopup.js +++ b/ClickToCall/js/callPopup.js @@ -31,7 +31,21 @@ bbmCallWidget = document.createElement('bbm-call'); await window.customElements.whenDefined('bbm-call'); await BBMEnterprise.validateBrowser(); - const authManager = createAuthManager(); + const authManager = new AuthenticationManager(AUTH_CONFIGURATION); + // Override getUserId() used by the MockAuthManager. + authManager.getUserId = () => new Promise((resolve, reject) => { + const userEmailDialog = document.createElement('bbm-user-email-dialog'); + document.body.appendChild(userEmailDialog); + userEmailDialog.addEventListener('Ok', e => { + userEmailDialog.parentNode.removeChild(userEmailDialog); + resolve(e.detail.userEmail); + }); + userEmailDialog.addEventListener('Cancel', () => { + userEmailDialog.parentNode.removeChild(userEmailDialog); + reject('Failed to get user email.'); + }); + }); + const authUserInfo = await authManager.authenticate(); if (!authUserInfo) { @@ -59,7 +73,6 @@ const userRegId = bbmeSdk.getRegistrationInfo().regId; contactsManager = await createUserManager(userRegId, authManager, - bbmeSdk.getIdentitiesFromAppUserId, bbmeSdk.getIdentitiesFromAppUserIds); await contactsManager.initialize(); makeCall(CONTACT_REG_ID, true); diff --git a/ClickToCall/js/config_azure.js b/ClickToCall/js/config_azure.js new file mode 100644 index 0000000..876d81c --- /dev/null +++ b/ClickToCall/js/config_azure.js @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2018 BlackBerry. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +'use strict'; + +// Reg Id of the contact to start call with. +const CONTACT_REG_ID = 'contact_reg_id'; + +// This secret is used to protect user keys. Must be individual for each user. +const USER_SECRET = 'user_secret'; + +// Refer to the guide to set up your application to use Azure: +// https://developer.blackberry.com/files/bbm-enterprise/documents/guide/html/azureForWebExamples.html + +// This domain is a string known to the BBM Enterprise server, which is +// generally a GUID. +// To create a new domain follow the link below +// https://account.good.com/#/a/organization/applications/add +const ID_PROVIDER_DOMAIN = 'your_idp_domain'; + +// The client ID of application registered on OAuth 2.0 server. +// To set up your application refer to +// https://developer.blackberry.com/files/bbm-enterprise/documents/guide/html/azureIdentityManagement.html +const CLIENT_ID = 'your_client_id'; + +// The tenant ID of your organization. +// To get your tenant ID refer to +// https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-howto-tenant +const TENANT_ID = 'your_tenant_id'; + +// ============================================================================= +// Configuration below does not require modifications. Change it only if you +// want to change existing application behavior. + +// The environment of your BBM Enterprise server. Must be either 'Sandbox' or +// 'Production'. +const ID_PROVIDER_ENVIRONMENT = 'Sandbox'; + +// The URL or relative path of the Argon2 WASM file. +const KMS_ARGON_WASM_URL = '../../sdk/argon2.wasm'; + +// This configuration contains service endpoints and information for OAuth2 +// authentication. +const AUTH_CONFIGURATION = { + // OAuth 2.0 endpoint for requesting an access token. + authService: `https://login.microsoftonline.com/${TENANT_ID}/oauth2/v2.0/authorize`, + + // The client ID of application registered on OAuth 2.0 server + clientId: CLIENT_ID, + + // Scopes of OAuth 2.0 access token (which resources it can access) + scope: `api://${CLIENT_ID}/Messaging.All https://graph.microsoft.com/User.ReadWrite https://graph.microsoft.com/User.ReadBasic.All` +}; + +// Create the user manager for the Click To Call app. +const createUserManager = (userRegId, authManager, getIdentities) => + Promise.resolve(new AzureUserManager(userRegId, authManager, getIdentities)); diff --git a/ClickToCall/js/config.js b/ClickToCall/js/config_google.js similarity index 52% rename from ClickToCall/js/config.js rename to ClickToCall/js/config_google.js index 605b253..d7150f4 100644 --- a/ClickToCall/js/config.js +++ b/ClickToCall/js/config_google.js @@ -19,12 +19,24 @@ // Reg Id of the contact to start call with const CONTACT_REG_ID = 'contact_reg_id'; -// This domain is a string known to the BBM Enterprise server, which is +// This secret is used to protect user keys. Must be individual for each user. +const USER_SECRET = 'user_secret'; + +// Refer to the guide to set up your application to use Google: +// https://developer.blackberry.com/files/bbm-enterprise/documents/guide/html/googleSignInForWebExamples.html + +// This domain is a string known to the BBM Enterprise server, which is // generally a GUID. +// To create a new domain follow the link below +// https://account.good.com/#/a/organization/applications/add const ID_PROVIDER_DOMAIN = 'your_idp_domain'; -// This secret is used to protect user keys. Must be individual for each user. -const USER_SECRET = 'user_secret'; +// The client ID of application registered on OAuth 2.0 server. +const CLIENT_ID = 'your_client_id'; + +// ============================================================================= +// Configuration below does not require modifications. Change it only if you +// want to change existing application behavior. // The environment of your BBM Enterprise server. Must be either 'Sandbox' or // 'Production'. @@ -37,43 +49,16 @@ const KMS_ARGON_WASM_URL = '../../sdk/argon2.wasm'; // authentication. const AUTH_CONFIGURATION = { // OAuth 2.0 endpoint for requesting an access token - // To use google OAuth service, put: - // 'https://accounts.google.com/o/oauth2/v2/auth' - authService : 'your_auth_service_endpoint', - - // OAuth 2.0 endpoint for token validation - // To use google toke info service, put: - // 'https://www.googleapis.com/oauth2/v3/tokeninfo' - tokenInfoService : 'your_oauth_token_info_endpoint', - - // OAuth 2.0 endpoint for obtaining user information (name, email, avatar URL) - // To use google user info service, put: - // 'https://www.googleapis.com/plus/v1/people/me' - userInfoService : 'your_oauth_user_info_endpoint', - + authService : 'https://accounts.google.com/o/oauth2/v2/auth', + // Scopes of OAuth 2.0 access token (which resources it can access) - // If google OAuth service is used, put following scopes: - // 'https://www.googleapis.com/auth/firebase https://www.googleapis.com/auth/userinfo.email' - scope : 'your_scope_oauth', - - // The client ID of application registered on OAuth 2.0 server - clientId: 'your_client_id' -}; + scope : 'https://www.googleapis.com/auth/contacts', -// Firebase config info -const FIREBASE_CONFIG = { - apiKey: 'your_api_key', - authDomain: 'your_auth_domain', - databaseURL: 'your_database_url', - projectId: 'your_project_id', - storageBucket: 'your_storage_bucket', - messagingSenderId: 'your_messaging_sender_id' + // The client ID of application registered on OAuth 2.0 server. + clientId: CLIENT_ID }; -// Create the auth manager for the Click To Call app. -const createAuthManager = () => new GoogleAuthManager(AUTH_CONFIGURATION); - // Create the user manager for the Click To Call app. -const createUserManager = (userRegId, authManager, getIdentity, getIdentities) => - FirebaseUserManager.factory.createInstance(FIREBASE_CONFIG, - userRegId, authManager, GenericUserInfo, getIdentity, getIdentities); \ No newline at end of file +const createUserManager = (userRegId, authManager, getIdentities) => + Promise.resolve(new GooglePeopleUserManager(userRegId, authManager, + getIdentities, AUTH_CONFIGURATION)); \ No newline at end of file diff --git a/ClickToCall/js/config_mock.js b/ClickToCall/js/config_mock.js new file mode 100644 index 0000000..5100aeb --- /dev/null +++ b/ClickToCall/js/config_mock.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2018 BlackBerry. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +'use strict'; + +// Reg Id of the contact to start call with +const CONTACT_REG_ID = 'contact_reg_id'; + +// This domain is a string known to the BBM Enterprise server, which is +// generally a GUID. +// To create a new domain follow the link below +// https://account.good.com/#/a/organization/applications/add +const ID_PROVIDER_DOMAIN = 'your_idp_domain'; + +// This secret is used to protect user keys. Must be individual for each user. +const USER_SECRET = 'user_secret'; + +// ============================================================================= +// Configuration below does not require modifications. Change it only if you +// want to change existing application behavior. + +const AUTH_CONFIGURATION = { }; + +// The environment of your BBM Enterprise server. Must be either 'Sandbox' or +// 'Production'. +const ID_PROVIDER_ENVIRONMENT = 'Sandbox'; + +// The URL or relative path of the Argon2 WASM file. +const KMS_ARGON_WASM_URL = '../../sdk/argon2.wasm'; + +// Create the user manager for the Click To Call app. +const createUserManager = (userRegId, authManager, getIdentities) => + Promise.resolve(new MockUserManager(userRegId, authManager, getIdentities, + ID_PROVIDER_DOMAIN)); \ No newline at end of file diff --git a/ClickToCall/js/index.js b/ClickToCall/js/index.js index 428e4ba..5e8f944 100644 --- a/ClickToCall/js/index.js +++ b/ClickToCall/js/index.js @@ -21,8 +21,8 @@ * of how to implement generic Click To Call functionality using bbm-call UI * widget. * - * When user clicks "Start Secure Call" button, application will start BBME - * call with the hard coded user RegId (CONTACT_REG_ID). + * When the user clicks the "Start Secure Call" button, the application will + * start a call with the hard coded user RegId (CONTACT_REG_ID). * * @class ClickToCall * @memberof Examples @@ -37,4 +37,4 @@ function makeCall() { alert('Failed to create popup window. Please check that your browser' + ' allows popups on this page.'); } -} \ No newline at end of file +} diff --git a/ClickToCall/package.json b/ClickToCall/package.json index ff7da97..58452c7 100644 --- a/ClickToCall/package.json +++ b/ClickToCall/package.json @@ -4,6 +4,7 @@ "version": "1.0.0", "main": "index.html", "dependencies": { - "bbmCall": "file:../support/ui/widgets/bbmCall" + "bbmCall": "file:../support/ui/widgets/bbmCall", + "bbmUserEmailDialog": "file:../support/ui/widgets/bbmUserEmailDialog" } } diff --git a/ClickToChat/.eslintrc.json b/ClickToChat/.eslintrc.json index c6bb419..9d91ff1 100644 --- a/ClickToChat/.eslintrc.json +++ b/ClickToChat/.eslintrc.json @@ -26,7 +26,12 @@ "TimeRangeFormatter": false, "MessageFormatter": false, "USER_SECRET": false, - "KMS_ARGON_WASM_URL": false + "KMS_ARGON_WASM_URL": false, + "GooglePeopleUserManager": false, + "AUTH_CONFIGURATION": false, + "AuthenticationManager": false, + "MockUserManager": false, + "AzureUserManager": false }, "rules": @@ -36,7 +41,7 @@ [ "error", { - "varsIgnorePattern": "startChat|KMS_ARGON_WASM_URL|CONTACT_REG_ID|ID_PROVIDER_DOMAIN|USER_SECRET|ID_PROVIDER_ENVIRONMENT|createAuthManager|createUserManager|createKeyProvider|createKeyProtect" + "varsIgnorePattern": "AUTH_CONFIGURATION|startChat|KMS_ARGON_WASM_URL|CONTACT_REG_ID|ID_PROVIDER_DOMAIN|USER_SECRET|ID_PROVIDER_ENVIRONMENT|createAuthManager|createUserManager" } ] } diff --git a/ClickToChat/README.md b/ClickToChat/README.md index 88f9f1b..9be6d04 100644 --- a/ClickToChat/README.md +++ b/ClickToChat/README.md @@ -1,9 +1,12 @@ -![BlackBerry Spark Communications Platform](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/resources/images/bnr-bbm-enterprise-sdk-title.png) +![BlackBerry Spark Communications Services](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/resources/images/bnr-bbm-enterprise-sdk-title.png) # Click To Chat Sample for JavaScript -The Click to Chat sample app demonstrates how to integrate a chat -experience into your website with the Spark SDK for JavaScript. This app allows a user to click a button on a webpage to start a secure chat with a predefined user or agent. The bbmChat widget handles the rendering of messages within the chat, and allows the user to send text, picture, and file messages. +The Click to Chat sample app demonstrates how to integrate a chat experience +into your website with the Spark Communications SDK. This app allows a user to +click a button on a webpage to start a secure chat with a predefined user or +agent. The bbmChat widget handles the rendering of messages within the chat, +and allows the user to send text, picture, and file messages.


@@ -17,7 +20,9 @@ experience into your website with the Spark SDK for JavaScript. This app allows ### Features -This app demonstrates how easy it is to integrate the bbmChat widget into your webpage. It initializes the Spark SDK for JavaScript, and starts a chat with a predefined user. The app then launches the bbmChat widget which allows the user to: +This app demonstrates how easy it is to integrate the bbmChat widget into your +webpage. It initializes the SDK, and starts a chat with a predefined user. The +app then launches the bbmChat widget which allows the user to: * View all sent and received messages in a chat * Send a text message, picture, or file attachment * Send high priority messages @@ -37,9 +42,9 @@ This app demonstrates how easy it is to integrate the bbmChat widget into your w ## Getting Started -This sample requires the Spark SDK, which you can find along with related resources at the location below. +This sample requires the Spark Communications SDK for JavaScript, which you can find along with related resources at the location below. -* Getting started with the [Spark SDK](https://developers.blackberry.com/us/en/products/blackberry-bbm-enterprise-sdk.html) +* Getting started with the [Spark Communications SDK](https://developers.blackberry.com/us/en/products/blackberry-spark-communications-platform.html) * [Development Guide](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/html/index.html) * [API Reference](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/reference/javascript/index.html) @@ -62,7 +67,7 @@ To use the ClickToChat example, you must set up the following elements in js/con - Oauth2 configuration (AUTH_CONFIGURATION) - A hardcoded contact registration ID with whom anyone who views the page will chat (CONTACT_REG_ID) -- Your Spark user domain (ID_PROVIDER_DOMAIN) +- Your sandbox domain (ID_PROVIDER_DOMAIN) - Firebase configuration (FIREBASE_CONFIG) - User passcode (USER_SECRET) @@ -71,7 +76,7 @@ To use the ClickToChat example, you must set up the following elements in js/con Follow this guide for a walkthrough of how to integrate a rich chat experience into your webpage. - [Import the bbmChat UI widget into your web application](#importChat) -- [Initialize the Spark SDK for JavaScript](#init) +- [Initialize the SDK](#init) - [Perform setup](#setup) - [Start a chat with a predefined user](#startChat) @@ -102,7 +107,7 @@ Create new instance of BBMEnterprise. }); ``` -For more information about setting up the Spark SDK for JavaScript, visit the [Getting Started with Web](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/html/gettingStarted-web.html) section of the guide. +For more information about setting up the SDK, visit the [Getting Started with Web](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/html/gettingStarted-web.html) section of the guide. ### Perform setup diff --git a/ClickToChat/index.html b/ClickToChat/index.html index dc73b7d..cc9bdc4 100644 --- a/ClickToChat/index.html +++ b/ClickToChat/index.html @@ -22,19 +22,38 @@ Click To Chat - - - - - - - - - - + + + + + + + + + + + + + + + + + + + +

@@ -59,4 +78,5 @@
+ diff --git a/ClickToChat/js/config.js b/ClickToChat/js/config.js deleted file mode 100644 index e671037..0000000 --- a/ClickToChat/js/config.js +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2018 BlackBerry. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -// Reg Id of the contact to start secure chat with -const CONTACT_REG_ID = 'contact_reg_id'; - -// This domain is a string known to the BBM Enterprise server, which is -// generally a GUID. -const ID_PROVIDER_DOMAIN = 'your_idp_domain'; - -// This secret is used to protect user keys. Must be individual for each user. -const USER_SECRET = 'user_secret'; - -// The environment of your BBM Enterprise server. Must be either 'Sandbox' or -// 'Production'. -const ID_PROVIDER_ENVIRONMENT = 'Sandbox'; - -// The URL or relative path of the Argon2 WASM file. -const KMS_ARGON_WASM_URL = '../../sdk/argon2.wasm'; - -// This configuration contains service endpoints and information for OAuth2 -// authentication. -const AUTH_CONFIGURATION = { - // OAuth 2.0 endpoint for requesting an access token - // To use google OAuth service, put: - // 'https://accounts.google.com/o/oauth2/v2/auth' - authService : 'your_auth_service_endpoint', - - // OAuth 2.0 endpoint for token validation - // To use google toke info service, put: - // 'https://www.googleapis.com/oauth2/v3/tokeninfo' - tokenInfoService : 'your_oauth_token_info_endpoint', - - // OAuth 2.0 endpoint for obtaining user information (name, email, avatar URL) - // To use google user info service, put: - // 'https://www.googleapis.com/plus/v1/people/me' - userInfoService : 'your_oauth_user_info_endpoint', - - // Scopes of OAuth 2.0 access token (which resources it can access) - // If google OAuth service is used, put following scopes: - // 'https://www.googleapis.com/auth/firebase https://www.googleapis.com/auth/userinfo.email' - scope : 'your_scope_oauth', - - // The client ID of application registered on OAuth 2.0 server - clientId: 'your_client_id' -}; - -// Firebase config info. -const FIREBASE_CONFIG = { - apiKey: 'your_api_key', - authDomain: 'your_auth_domain', - databaseURL: 'your_database_url', - projectId: 'your_project_id', - storageBucket: 'your_storage_bucket', - messagingSenderId: 'your_messaging_sender_id' -}; - -// Create the auth manager for the Click To Chat app. -const createAuthManager = () => new GoogleAuthManager(AUTH_CONFIGURATION); - -// Create the user manager for the Click to chat app. -const createUserManager = (userRegId, authManager, getIdentity, getIdentities) => - FirebaseUserManager.factory.createInstance(FIREBASE_CONFIG, - userRegId, authManager, GenericUserInfo, getIdentity, getIdentities); \ No newline at end of file diff --git a/ClickToChat/js/config_azure.js b/ClickToChat/js/config_azure.js new file mode 100644 index 0000000..faf0e85 --- /dev/null +++ b/ClickToChat/js/config_azure.js @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2018 BlackBerry. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +'use strict'; + +// Reg Id of the contact to start chat with. +const CONTACT_REG_ID = 'contact_reg_id'; + +// This secret is used to protect user keys. Must be individual for each user. +const USER_SECRET = 'user_secret'; + +// Refer to the guide to set up your application to use Azure: +// https://developer.blackberry.com/files/bbm-enterprise/documents/guide/html/azureForWebExamples.html + +// This domain is a string known to the BBM Enterprise server, which is +// generally a GUID. +// To create a new domain follow the link below +// https://account.good.com/#/a/organization/applications/add +const ID_PROVIDER_DOMAIN = 'your_idp_domain'; + +// The client ID of application registered on OAuth 2.0 server. +// To set up your application refer to +// https://developer.blackberry.com/files/bbm-enterprise/documents/guide/html/azureIdentityManagement.html +const CLIENT_ID = 'your_client_id'; + +// The tenant ID of your organization. +// To get your tenant ID refer to +// https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-howto-tenant +const TENANT_ID = 'your_tenant_id'; + +// ============================================================================= +// Configuration below does not require modifications. Change it only if you +// want to change existing application behavior. + +// The environment of your BBM Enterprise server. Must be either 'Sandbox' or +// 'Production'. +const ID_PROVIDER_ENVIRONMENT = 'Sandbox'; + +// The URL or relative path of the Argon2 WASM file. +const KMS_ARGON_WASM_URL = '../../sdk/argon2.wasm'; + +// This configuration contains service endpoints and information for OAuth2 +// authentication. +const AUTH_CONFIGURATION = { + // OAuth 2.0 endpoint for requesting an access token. + authService: `https://login.microsoftonline.com/${TENANT_ID}/oauth2/v2.0/authorize`, + + // The client ID of application registered on OAuth 2.0 server + clientId: CLIENT_ID, + + // Scopes of OAuth 2.0 access token (which resources it can access) + scope: `api://${CLIENT_ID}/Messaging.All https://graph.microsoft.com/User.ReadWrite https://graph.microsoft.com/User.ReadBasic.All` +}; + +// Create the user manager for the Rich Chat app. +const createUserManager = (userRegId, authManager, getIdentities) => + Promise.resolve(new AzureUserManager(userRegId, authManager, getIdentities)); diff --git a/ClickToChat/js/config_google.js b/ClickToChat/js/config_google.js new file mode 100644 index 0000000..29177b6 --- /dev/null +++ b/ClickToChat/js/config_google.js @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2018 BlackBerry. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +'use strict'; + +// Reg Id of the contact to start chat with +const CONTACT_REG_ID = 'contact_reg_id'; + +// This secret is used to protect user keys. Must be individual for each user. +const USER_SECRET = 'user_secret'; + +// Refer to the guide to set up your application to use Google: +// https://developer.blackberry.com/files/bbm-enterprise/documents/guide/html/googleSignInForWebExamples.html + +// This domain is a string known to the BBM Enterprise server, which is +// generally a GUID. +// To create a new domain follow the link below +// https://account.good.com/#/a/organization/applications/add +const ID_PROVIDER_DOMAIN = 'your_idp_domain'; + +// The client ID of application registered on OAuth 2.0 server. +const CLIENT_ID = 'your_client_id'; + +// ============================================================================= +// Configuration below does not require modifications. Change it only if you +// want to change existing application behavior. + +// The environment of your BBM Enterprise server. Must be either 'Sandbox' or +// 'Production'. +const ID_PROVIDER_ENVIRONMENT = 'Sandbox'; + +// The URL or relative path of the Argon2 WASM file. +const KMS_ARGON_WASM_URL = '../../sdk/argon2.wasm'; + +// This configuration contains service endpoints and information for OAuth2 +// authentication. +const AUTH_CONFIGURATION = { + // OAuth 2.0 endpoint for requesting an access token + authService : 'https://accounts.google.com/o/oauth2/v2/auth', + + // Scopes of OAuth 2.0 access token (which resources it can access) + scope : 'https://www.googleapis.com/auth/contacts', + + // The client ID of application registered on OAuth 2.0 server. + clientId: CLIENT_ID +}; + +// Create the user manager for the Click To Chat app. +const createUserManager = (userRegId, authManager, getIdentities) => + Promise.resolve(new GooglePeopleUserManager(userRegId, authManager, + getIdentities, AUTH_CONFIGURATION)); \ No newline at end of file diff --git a/ClickToChat/js/config_mock.js b/ClickToChat/js/config_mock.js new file mode 100644 index 0000000..879da13 --- /dev/null +++ b/ClickToChat/js/config_mock.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2018 BlackBerry. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +'use strict'; + +// Reg Id of the contact to start call with +// Bot doesn't answer calls! Put one of your REG IDs here. +const CONTACT_REG_ID = 'contact_reg_id'; + +// This domain is a string known to the BBM Enterprise server, which is +// generally a GUID. +// To create a new domain follow the link below +// https://account.good.com/#/a/organization/applications/add +const ID_PROVIDER_DOMAIN = 'your_idp_domain'; + +// This secret is used to protect user keys. Must be individual for each user. +const USER_SECRET = 'user_secret'; + +// ============================================================================= +// Configuration below does not require modifications. Change it only if you +// want to change existing application behavior. + +const AUTH_CONFIGURATION = { }; + +// The environment of your BBM Enterprise server. Must be either 'Sandbox' or +// 'Production'. +const ID_PROVIDER_ENVIRONMENT = 'Sandbox'; + +// The URL or relative path of the Argon2 WASM file. +const KMS_ARGON_WASM_URL = '../../sdk/argon2.wasm'; + +// Create the user manager for the Click To Chat app. +const createUserManager = (userRegId, authManager, getIdentities) => + Promise.resolve(new MockUserManager(userRegId, authManager, getIdentities, + ID_PROVIDER_DOMAIN)); \ No newline at end of file diff --git a/ClickToChat/js/index.js b/ClickToChat/js/index.js index b4c138d..ac5d5ad 100644 --- a/ClickToChat/js/index.js +++ b/ClickToChat/js/index.js @@ -21,7 +21,7 @@ * of how to implement generic Click To Chat functionality using the bbm-chat UI * widget. * - * When user clicks "Start Secure Chat" button, application will start a BBME + * When the user clicks "Start Secure Chat" button, the application will start a * chat with the hard coded user RegId (CONTACT_REG_ID). * * @class ClickToChat @@ -36,7 +36,20 @@ const CHAT_DETAILS = { subject: '' }; -const authManager = createAuthManager(); +const authManager = new AuthenticationManager(AUTH_CONFIGURATION); +// Override getUserId() used by the MockAuthManager. +authManager.getUserId = () => new Promise((resolve, reject) => { + const userEmailDialog = document.createElement('bbm-user-email-dialog'); + document.body.appendChild(userEmailDialog); + userEmailDialog.addEventListener('Ok', e => { + userEmailDialog.parentNode.removeChild(userEmailDialog); + resolve(e.detail.userEmail); + }); + userEmailDialog.addEventListener('Cancel', () => { + userEmailDialog.parentNode.removeChild(userEmailDialog); + reject('Failed to get user email.'); + }); +}); window.onload = async () => { try { @@ -83,7 +96,6 @@ async function startChat() { } const userRegId = bbmeSdk.getRegistrationInfo().regId; const userManager = await createUserManager(userRegId, authManager, - bbmeSdk.getIdentitiesFromAppUserId, bbmeSdk.getIdentitiesFromAppUserIds); await userManager.initialize(); bbmChat.setBbmSdk(bbmeSdk); @@ -97,8 +109,8 @@ async function startChat() { chatPane.style.display = 'block'; } catch (error) { - const errorMessage = 'Failed to initialize Spark SDK for ' + - ` JavaScript. Error: ${error}`; + const errorMessage = + `Failed to initialize the SDK. Error: ${error}`; alert(errorMessage); isChatting = false; } @@ -106,7 +118,7 @@ async function startChat() { } /** - * This function initializes the Spark SDK. + * This function initializes the SDK. */ function initBbmeSdk() { return new Promise(async (resolve, reject) => { @@ -169,4 +181,4 @@ function initBbmeSdk() { reject(error); } }); -} \ No newline at end of file +} diff --git a/ClickToChat/package.json b/ClickToChat/package.json index 221da61..e4282f9 100644 --- a/ClickToChat/package.json +++ b/ClickToChat/package.json @@ -4,6 +4,7 @@ "version": "1.0.1", "main": "index.html", "dependencies": { - "bbmChat": "file:../support/ui/widgets/bbmChat" + "bbmChat": "file:../support/ui/widgets/bbmChat", + "bbmUserEmailDialog": "file:../support/ui/widgets/bbmUserEmailDialog" } } diff --git a/DataTransfer/.eslintrc.json b/DataTransfer/.eslintrc.json index 08ab477..828bf39 100644 --- a/DataTransfer/.eslintrc.json +++ b/DataTransfer/.eslintrc.json @@ -24,7 +24,11 @@ "KeyProtect": false, "Polymer": false, "USER_SECRET": false, - "KMS_ARGON_WASM_URL": false + "KMS_ARGON_WASM_URL": false, + "AUTH_CONFIGURATION": false, + "AuthenticationManager": false, + "MockUserManager": false, + "AzureUserManager": false }, "rules": @@ -34,7 +38,7 @@ [ "error", { - "varsIgnorePattern": "ID_PROVIDER_DOMAIN|KMS_ARGON_WASM_URL|ID_PROVIDER_ENVIRONMENT|USER_SECRET|createAuthManager|createUserManager|createKeyProvider|createKeyProtect" + "varsIgnorePattern": "AUTH_CONFIGURATION|ID_PROVIDER_DOMAIN|KMS_ARGON_WASM_URL|ID_PROVIDER_ENVIRONMENT|USER_SECRET|createAuthManager|createUserManager|createKeyProvider|createKeyProtect" } ] } diff --git a/DataTransfer/README.md b/DataTransfer/README.md index 410e45c..7deda0f 100644 --- a/DataTransfer/README.md +++ b/DataTransfer/README.md @@ -1,8 +1,8 @@ -![BlackBerry Spark Communications Platform](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/resources/images/bnr-bbm-enterprise-sdk-title.png) +![BlackBerry Spark Communications Services](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/resources/images/bnr-bbm-enterprise-sdk-title.png) # Data Transfer for JavaScript -The DataTransfer application shows how to use the peer-to-peer data connection capability in the Spark SDK for JavaScript. The data connection API allows arbitrary data to be sent securely through a familiar stream interface. +The DataTransfer application shows how to use the peer-to-peer data connection capability in the Spark Communications SDK. The data connection API allows arbitrary data to be sent securely through a familiar stream interface. ### Features @@ -20,9 +20,9 @@ The sample application allows the user to do the following: ## Getting Started -This sample requires the Spark SDK, which you can find along with related resources at the location below. +This sample requires the Spark Communications SDK for JavaScript, which you can find along with related resources at the location below. -* Getting started with the [Spark SDK](https://developers.blackberry.com/us/en/products/blackberry-bbm-enterprise-sdk.html) +* Getting started with the [Spark Communications SDK](https://developers.blackberry.com/us/en/products/blackberry-spark-communications-platform.html) * [Development Guide](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/html/index.html) * [API Reference](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/reference/javascript/index.html) @@ -44,21 +44,21 @@ Visit the [Getting Started with Web](https://developer.blackberry.com/files/bbm- To use the DataTransfer example, you must set up the following elements in js/config.js: - Oauth2 configuration (AUTH_CONFIGURATION) -- Your Spark user domain (ID_PROVIDER_DOMAIN) +- Your sandbox domain (ID_PROVIDER_DOMAIN) - Firebase configuration (FIREBASE_CONFIG) - User passcode (USER_SECRET) ## Walkthrough -Follow this guide for a walkthrough explaining how the Spark SDK for JavaScript is used to share data over a secure peer-to-peer data connection. -- [Initialize the Spark SDK for JavaScript](#init) +Follow this guide for a walkthrough explaining how the Spark Communications SDK is used to share data over a secure peer-to-peer data connection. +- [Initialize the SDK](#init) - [Perform setup](#setup) - [Creating a connection](#create) - [Receive a connection](#receive) - [Receiving a file](#receiveFile) - [Sending a file](#sendFile) -### Initialize the Spark SDK for JavaScript +### Initialize the SDK ```javascript // Create new instance of BBMEnterprise. diff --git a/DataTransfer/index.html b/DataTransfer/index.html index a1e4d2c..de9f3b3 100644 --- a/DataTransfer/index.html +++ b/DataTransfer/index.html @@ -22,18 +22,38 @@ Data Transfer + - - - + + - - + + + + + + + + + + + + + + + + diff --git a/DataTransfer/js/config_azure.js b/DataTransfer/js/config_azure.js new file mode 100644 index 0000000..a800c5f --- /dev/null +++ b/DataTransfer/js/config_azure.js @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2018 BlackBerry. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +'use strict'; + +// This secret is used to protect user keys. Must be individual for each user. +const USER_SECRET = 'user_secret'; + +// Refer to the guide to set up your application to use Azure: +// https://developer.blackberry.com/files/bbm-enterprise/documents/guide/html/azureForWebExamples.html + +// This domain is a string known to the BBM Enterprise server, which is +// generally a GUID. +// To create a new domain follow the link below +// https://account.good.com/#/a/organization/applications/add +const ID_PROVIDER_DOMAIN = 'your_idp_domain'; + +// The client ID of application registered on OAuth 2.0 server. +// To set up your application refer to +// https://developer.blackberry.com/files/bbm-enterprise/documents/guide/html/azureIdentityManagement.html +const CLIENT_ID = 'your_client_id'; + +// The tenant ID of your organization. +// To get your tenant ID refer to +// https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-howto-tenant +const TENANT_ID = 'your_tenant_id'; + +// ============================================================================= +// Configuration below does not require modifications. Change it only if you +// want to change existing application behavior. + +// The environment of your BBM Enterprise server. Must be either 'Sandbox' or +// 'Production'. +const ID_PROVIDER_ENVIRONMENT = 'Sandbox'; + +// The URL or relative path of the Argon2 WASM file. +const KMS_ARGON_WASM_URL = '../../sdk/argon2.wasm'; + +// This configuration contains service endpoints and information for OAuth2 +// authentication. +const AUTH_CONFIGURATION = { + // OAuth 2.0 endpoint for requesting an access token. + authService: `https://login.microsoftonline.com/${TENANT_ID}/oauth2/v2.0/authorize`, + + // The client ID of application registered on OAuth 2.0 server + clientId: CLIENT_ID, + + // Scopes of OAuth 2.0 access token (which resources it can access) + scope: `api://${CLIENT_ID}/Messaging.All https://graph.microsoft.com/User.ReadWrite https://graph.microsoft.com/User.ReadBasic.All` +}; \ No newline at end of file diff --git a/QuickStart/config.js b/DataTransfer/js/config_google.js similarity index 62% rename from QuickStart/config.js rename to DataTransfer/js/config_google.js index 317e80f..2655594 100644 --- a/QuickStart/config.js +++ b/DataTransfer/js/config_google.js @@ -16,12 +16,24 @@ 'use strict'; -// This domain is a string known to the BBM Enterprise server, which is +// This secret is used to protect user keys. Must be individual for each user. +const USER_SECRET = 'user_secret'; + +// Refer to the guide to set up your application to use Google: +// https://developer.blackberry.com/files/bbm-enterprise/documents/guide/html/googleSignInForWebExamples.html + +// This domain is a string known to the BBM Enterprise server, which is // generally a GUID. +// To create a new domain follow the link below +// https://account.good.com/#/a/organization/applications/add const ID_PROVIDER_DOMAIN = 'your_idp_domain'; -// This secret is used to protect user keys. Must be individual for each user. -const USER_SECRET = 'user_secret'; +// The client ID of application registered on OAuth 2.0 server. +const CLIENT_ID = 'your_client_id'; + +// ============================================================================= +// Configuration below does not require modifications. Change it only if you +// want to change existing application behavior. // The environment of your BBM Enterprise server. Must be either 'Sandbox' or // 'Production'. @@ -34,29 +46,11 @@ const KMS_ARGON_WASM_URL = '../../sdk/argon2.wasm'; // authentication. const AUTH_CONFIGURATION = { // OAuth 2.0 endpoint for requesting an access token - // To use google OAuth service, put: - // 'https://accounts.google.com/o/oauth2/v2/auth' - authService : 'your_auth_service_endpoint', - - // OAuth 2.0 endpoint for token validation - // To use google token info service, put : - // 'https://www.googleapis.com/oauth2/v3/tokeninfo' - tokenInfoService : 'your_oauth_token_info_endpoint', - - // OAuth 2.0 endpoint for obtaining user information (name, email, avatar URL) - // To use google user info service, put: - // 'https://www.googleapis.com/plus/v1/people/me' - userInfoService : 'your_oauth_user_info_endpoint', + authService : 'https://accounts.google.com/o/oauth2/v2/auth', // Scopes of OAuth 2.0 access token (which resources it can access) - // If google OAuth service is used, put following scopes: - // 'https://www.googleapis.com/auth/firebase https://www.googleapis.com/auth/userinfo.email' - scope : 'your_scope_oauth', - - // The client ID of application registered on OAuth 2.0 server - clientId: 'your_client_id' -}; + scope : 'profile', -const createAuthManager = () => { - return new GoogleAuthManager(AUTH_CONFIGURATION); -}; + // The client ID of application registered on OAuth 2.0 server. + clientId: CLIENT_ID +}; \ No newline at end of file diff --git a/DataTransfer/js/config_mock.js b/DataTransfer/js/config_mock.js new file mode 100644 index 0000000..0908d94 --- /dev/null +++ b/DataTransfer/js/config_mock.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2018 BlackBerry. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +'use strict'; + +// This domain is a string known to the BBM Enterprise server, which is +// generally a GUID. +// To create a new domain follow the link below +// https://account.good.com/#/a/organization/applications/add +const ID_PROVIDER_DOMAIN = 'your_idp_domain'; + +// This secret is used to protect user keys. Must be individual for each user. +const USER_SECRET = 'user_secret'; + +// ============================================================================= +// Configuration below does not require modifications. Change it only if you +// want to change existing application behavior. + +const AUTH_CONFIGURATION = { }; + +// The environment of your BBM Enterprise server. Must be either 'Sandbox' or +// 'Production'. +const ID_PROVIDER_ENVIRONMENT = 'Sandbox'; + +// The URL or relative path of the Argon2 WASM file. +const KMS_ARGON_WASM_URL = '../../sdk/argon2.wasm'; \ No newline at end of file diff --git a/DataTransfer/js/dataTransferElement.js b/DataTransfer/js/dataTransferElement.js index 7403e01..eb5e55a 100644 --- a/DataTransfer/js/dataTransferElement.js +++ b/DataTransfer/js/dataTransferElement.js @@ -29,8 +29,8 @@ /** * data-transfer-element element class implementation. * - * Demonstrates how to implement file transfer functionality using - * BBMEnterprise SDK for JavaScript. + * Demonstrates how to implement file transfer functionality using the + * Spark Communications SDK for JavaScript. */ class DataTransferElement extends Polymer.Element { constructor() { @@ -266,7 +266,7 @@ } if (!this.bbmSdk) { - alert('BBMEnterprise SDK for JavaScript is not initialized.'); + alert('The SDK is not initialized.'); return; } diff --git a/DataTransfer/js/index.js b/DataTransfer/js/index.js index 5de26bb..6356a0f 100644 --- a/DataTransfer/js/index.js +++ b/DataTransfer/js/index.js @@ -40,7 +40,21 @@ function initBbme() { return new Promise(async (resolve, reject) => { try { let isSyncStarted = false; - const authManager = createAuthManager(); + const authManager = new AuthenticationManager(AUTH_CONFIGURATION); + // Override getUserId() used by the MockAuthManager. + authManager.getUserId = () => new Promise((resolve, reject) => { + const userEmailDialog = document.createElement('bbm-user-email-dialog'); + document.body.appendChild(userEmailDialog); + userEmailDialog.addEventListener('Ok', e => { + userEmailDialog.parentNode.removeChild(userEmailDialog); + resolve(e.detail.userEmail); + }); + userEmailDialog.addEventListener('Cancel', () => { + userEmailDialog.parentNode.removeChild(userEmailDialog); + reject('Failed to get user email.'); + }); + }); + const authUserInfo = await authManager.authenticate(); if (!authUserInfo) { console.warn('Application will be redirected to the ' diff --git a/DataTransfer/package.json b/DataTransfer/package.json index 623d526..a91ea1f 100644 --- a/DataTransfer/package.json +++ b/DataTransfer/package.json @@ -6,7 +6,8 @@ "dependencies": { "@webcomponents/webcomponentsjs":"^1.0.20", "@npm-polymer":"https://github.com/Polymer/polymer.git#2.2.0", - "shadycss":"https://github.com/webcomponents/shadycss.git#1.1.0" + "shadycss":"https://github.com/webcomponents/shadycss.git#1.1.0", + "bbmUserEmailDialog": "file:../support/ui/widgets/bbmUserEmailDialog" } } diff --git a/KeyProviderServer/README.md b/KeyProviderServer/README.md index 3fb7f6b..b8dd6f9 100644 --- a/KeyProviderServer/README.md +++ b/KeyProviderServer/README.md @@ -1,4 +1,4 @@ -![BlackBerry Spark Communications Platform](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/resources/images/bnr-bbm-enterprise-sdk-title.png) +![BlackBerry Spark Communications Services](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/resources/images/bnr-bbm-enterprise-sdk-title.png) # KeyProviderServer Sample for JavaScript @@ -12,15 +12,14 @@ The **KeyProviderServer** demonstrates how your app can enforce access control t 4. Allows all authenticated users to read public key data. -You can use this server with popular cloud storage solutions like [Azure Cosmos DB](https://docs.microsoft.com/en-us/azure/cosmos-db/introduction). To learn more about setting up Azure Cosmos DB to store the BlackBerry Secure -Spark security keys, follow the steps provided [here](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/html/azureCloudKeyStorage.html). +You can use this server with popular cloud storage solutions like [Azure Cosmos DB](https://docs.microsoft.com/en-us/azure/cosmos-db/introduction). To learn more about setting up Azure Cosmos DB for Cloud Key Storage, follow the steps provided [here](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/html/azureCloudKeyStorage.html). ## Getting Started -These samples require the Spark SDK which you can find along with related resources at the location below. +These samples require the Spark Communications SDK for JavaScript which you can find along with related resources at the location below. -* Getting stated with the [Spark SDK](https://developers.blackberry.com/us/en/products/blackberry-bbm-enterprise-sdk.html) +* Getting stated with the [Spark Communications SDK](https://developers.blackberry.com/us/en/products/blackberry-spark-communications-platform.html) * [Development Guide](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/html/index.html) * [API Reference](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/reference/javascript/index.html) @@ -35,9 +34,7 @@ These samples require the Spark SDK which you can find along with related resour # KeyProviderServer -The cryptographic keys used by Spark to protect your communications are stored and distributed in a [cloud storage system](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/html/cloudKeyStorage.html) that you choose. Some cloud storage solutions like [Firebase](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/html/firebaseCloudKeyStorage.html) satisfy all the [requirements](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/html/cloudKeyStorage.html) to securely store and distribute keys to authenticated users. However, you may choose a different cloud storage solution that would require you to enforce access control on your application server. - - +The cryptographic keys used by Spark Communications Services to protect your communications are stored and distributed in [cloud storage system](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/html/cloudKeyStorage.html) that you choose. Some cloud storage solutions like [Firebase](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/html/firebaseCloudKeyStorage.html) satisfy all the [requirements](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/html/cloudKeyStorage.html) to securely store and distribute keys to authenticated users. However, you may choose a different cloud storage solution that would require you to enforce access control on your application server.

diff --git a/KeyProviderServer/screenShots/keyProviderService-azure.png b/KeyProviderServer/screenShots/keyProviderService-azure.png index ed9b39c..9eb25ec 100644 Binary files a/KeyProviderServer/screenShots/keyProviderService-azure.png and b/KeyProviderServer/screenShots/keyProviderService-azure.png differ diff --git a/Node/GoogleLogin.js b/Node/GoogleLogin.js index 7a57d24..f169016 100644 --- a/Node/GoogleLogin.js +++ b/Node/GoogleLogin.js @@ -16,10 +16,9 @@ */ // -// The bbm sdk requires an oauth2 provider, and a key storage service. +// The bbm sdk requires an oauth2 provider. // -// This module implements both, using Google for the oauth2 provider, and -// implementing key storage using Firebase. +// This module implements it, using Google for the oauth2 provider. // // Include some needed modules. diff --git a/Node/README.md b/Node/README.md index 68d3235..f0a320e 100644 --- a/Node/README.md +++ b/Node/README.md @@ -1,9 +1,9 @@ -![BlackBerry Spark Communications Platform](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/resources/images/bnr-bbm-enterprise-sdk-title.png) +![BlackBerry Spark Communications Services](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/resources/images/bnr-bbm-enterprise-sdk-title.png) # BBMBot Sample for JavaScript The BBMBot sample app demonstrates how to build a chat bot in Node.js with the -Spark SDK. The BBMbot uses the [www.botlibre.com](www.botlibre.com) +Spark Communications SDK. The BBMbot uses the [www.botlibre.com](www.botlibre.com) webservice as an example of how to generate responses.

@@ -32,9 +32,9 @@ With the BBMBot example, your app can do the following: ## Getting Started -This sample requires the Spark SDK, which you can find along with related resources at the location below. +This sample requires the Spark Communications SDK for JavaScript, which you can find along with related resources at the location below. -* Getting started with the [Spark SDK](https://developers.blackberry.com/us/en/products/blackberry-bbm-enterprise-sdk.html) +* Getting started with the [Spark Communications SDK](https://developers.blackberry.com/us/en/products/blackberry-spark-communications-platform.html) * [Development Guide](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/html/index.html) * [API Reference](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/reference/javascript/index.html) @@ -53,7 +53,7 @@ Visit the [Getting Started with Node](https://developer.blackberry.com/files/bbm To use the BBMBot example, you must set up the following elements in config.js: --id_provider_domain: Your Spark user domain. +-id_provider_domain: Your sandbox domain. -firebaseConfig: The firebase API config. diff --git a/QuickStart/.eslintrc.json b/QuickStart/.eslintrc.json index d4152b1..dd56f3e 100644 --- a/QuickStart/.eslintrc.json +++ b/QuickStart/.eslintrc.json @@ -3,7 +3,8 @@ "globals": { "GoogleAuthManager": false, - "KMS_ARGON_WASM_URL": false + "KMS_ARGON_WASM_URL": false, + "AUTH_CONFIGURATION": false }, "rules": { @@ -12,7 +13,7 @@ [ "error", { - "varsIgnorePattern": "ID_PROVIDER_DOMAIN|KMS_ARGON_WASM_URL|ID_PROVIDER_ENVIRONMENT|USER_SECRET|createAuthManager" + "varsIgnorePattern": "AUTH_CONFIGURATION|ID_PROVIDER_DOMAIN|KMS_ARGON_WASM_URL|ID_PROVIDER_ENVIRONMENT|USER_SECRET|createAuthManager|USER_ID" } ] } diff --git a/QuickStart/README.md b/QuickStart/README.md index 12b574c..2a2e81b 100644 --- a/QuickStart/README.md +++ b/QuickStart/README.md @@ -1,10 +1,12 @@ -![BlackBerry Spark Communications Platform](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/resources/images/bnr-bbm-enterprise-sdk-title.png) +![BlackBerry Spark Communications Services](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/resources/images/bnr-bbm-enterprise-sdk-title.png) # Quick Start Sample for JavaScript -The Quick Start application demonstrates how you can authenticate with the Spark SDK using the [Identity Provider](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/html/identityManagement.html) -of your application. We demonstrate how you can obtain the user ID and token of your user's account -and pass them to the Spark SDK to complete setup. +The Quick Start application demonstrates how you can authenticate with the +Spark Communications SDK using the [Identity +Provider](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/html/identityManagement.html) +of your application. We demonstrate how you can obtain the user ID and token of +your user's account and pass them to the SDK to complete setup.
@@ -15,9 +17,9 @@ and pass them to the Spark SDK to complete setup. ## Getting Started -This sample requires the Spark SDK, which you can find along with related resources at the location below. +This sample requires the Spark Communications SDK for JavaScript, which you can find along with related resources at the location below. -* Getting started with the [Spark SDK](https://developers.blackberry.com/us/en/products/blackberry-bbm-enterprise-sdk.html) +* Getting started with the [Spark Communications SDK](https://developers.blackberry.com/us/en/products/blackberry-spark-communications-platform.html) * [Development Guide](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/html/index.html) * [API Reference](https://developer.blackberry.com/files/bbm-enterprise/documents/guide/reference/javascript/index.html) @@ -37,22 +39,22 @@ Visit the [Getting Started with Web](https://developer.blackberry.com/files/bbm- To use this example, you must set up the following elements in config.js: - Oauth2 configuration (AUTH_CONFIGURATION) -- Your Spark user domain (ID_PROVIDER_DOMAIN) +- Your sandbox domain (ID_PROVIDER_DOMAIN) - User passcode (USER_SECRET) ## Walkthrough -Follow this guide for a walkthrough showing how to authenticate with the Spark SDK using Google Sign-in for Web. +Follow this guide for a walkthrough showing how to authenticate with the SDK using Google Sign-in for Web. - [Validate the browser](#validateBrowser) - [Request an access token using the Google Sign-in API](#requestToken) -- [Initialize the Spark SDK](#initialize) +- [Initialize the SDK](#initialize) - [Monitor the setup state](#monitorSetup) - [Monitor for setup errors](#monitorSetupErrors) - [Perform setup](#performSetup) -### Validate that the browser supports the Spark SDK for JavaScript +### Validate that the browser supports the SDK To verify that the browser has all required features, call BBMEnterprise.validateBrowser. It will return a rejected Promise in browsers which support Promise. If Promise is not supported, it will throw an exception. @@ -80,13 +82,13 @@ function LogIn() { const authManager = createAuthManager(); authManager.authenticate() .then(userData => { - // ... Initialize the Spark SDK here ... + // ... Initialize the SDK here ... } } ``` -### Initialize the Spark SDK +### Initialize the SDK ```javascript // Construct BBMEnterprise object. diff --git a/QuickStart/config_azure.js b/QuickStart/config_azure.js new file mode 100644 index 0000000..a800c5f --- /dev/null +++ b/QuickStart/config_azure.js @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2018 BlackBerry. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +'use strict'; + +// This secret is used to protect user keys. Must be individual for each user. +const USER_SECRET = 'user_secret'; + +// Refer to the guide to set up your application to use Azure: +// https://developer.blackberry.com/files/bbm-enterprise/documents/guide/html/azureForWebExamples.html + +// This domain is a string known to the BBM Enterprise server, which is +// generally a GUID. +// To create a new domain follow the link below +// https://account.good.com/#/a/organization/applications/add +const ID_PROVIDER_DOMAIN = 'your_idp_domain'; + +// The client ID of application registered on OAuth 2.0 server. +// To set up your application refer to +// https://developer.blackberry.com/files/bbm-enterprise/documents/guide/html/azureIdentityManagement.html +const CLIENT_ID = 'your_client_id'; + +// The tenant ID of your organization. +// To get your tenant ID refer to +// https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-howto-tenant +const TENANT_ID = 'your_tenant_id'; + +// ============================================================================= +// Configuration below does not require modifications. Change it only if you +// want to change existing application behavior. + +// The environment of your BBM Enterprise server. Must be either 'Sandbox' or +// 'Production'. +const ID_PROVIDER_ENVIRONMENT = 'Sandbox'; + +// The URL or relative path of the Argon2 WASM file. +const KMS_ARGON_WASM_URL = '../../sdk/argon2.wasm'; + +// This configuration contains service endpoints and information for OAuth2 +// authentication. +const AUTH_CONFIGURATION = { + // OAuth 2.0 endpoint for requesting an access token. + authService: `https://login.microsoftonline.com/${TENANT_ID}/oauth2/v2.0/authorize`, + + // The client ID of application registered on OAuth 2.0 server + clientId: CLIENT_ID, + + // Scopes of OAuth 2.0 access token (which resources it can access) + scope: `api://${CLIENT_ID}/Messaging.All https://graph.microsoft.com/User.ReadWrite https://graph.microsoft.com/User.ReadBasic.All` +}; \ No newline at end of file diff --git a/DataTransfer/js/config.js b/QuickStart/config_google.js similarity index 61% rename from DataTransfer/js/config.js rename to QuickStart/config_google.js index 06d21d3..2655594 100644 --- a/DataTransfer/js/config.js +++ b/QuickStart/config_google.js @@ -16,12 +16,24 @@ 'use strict'; +// This secret is used to protect user keys. Must be individual for each user. +const USER_SECRET = 'user_secret'; + +// Refer to the guide to set up your application to use Google: +// https://developer.blackberry.com/files/bbm-enterprise/documents/guide/html/googleSignInForWebExamples.html + // This domain is a string known to the BBM Enterprise server, which is // generally a GUID. +// To create a new domain follow the link below +// https://account.good.com/#/a/organization/applications/add const ID_PROVIDER_DOMAIN = 'your_idp_domain'; -// This secret is used to protect user keys. Must be individual for each user. -const USER_SECRET = 'user_secret'; +// The client ID of application registered on OAuth 2.0 server. +const CLIENT_ID = 'your_client_id'; + +// ============================================================================= +// Configuration below does not require modifications. Change it only if you +// want to change existing application behavior. // The environment of your BBM Enterprise server. Must be either 'Sandbox' or // 'Production'. @@ -34,28 +46,11 @@ const KMS_ARGON_WASM_URL = '../../sdk/argon2.wasm'; // authentication. const AUTH_CONFIGURATION = { // OAuth 2.0 endpoint for requesting an access token - // To use google OAuth service, put: - // 'https://accounts.google.com/o/oauth2/v2/auth' - authService : 'your_auth_service_endpoint', - - // OAuth 2.0 endpoint for token validation - // To use google toke info service, put: - // 'https://www.googleapis.com/oauth2/v3/tokeninfo' - tokenInfoService : 'your_oauth_token_info_endpoint', - - // OAuth 2.0 endpoint for obtaining user information (name, email, avatar URL) - // To use google user info service, put: - // 'https://www.googleapis.com/plus/v1/people/me' - userInfoService : 'your_oauth_user_info_endpoint', + authService : 'https://accounts.google.com/o/oauth2/v2/auth', // Scopes of OAuth 2.0 access token (which resources it can access) - // If google OAuth service is used, put following scopes: - // 'https://www.googleapis.com/auth/firebase https://www.googleapis.com/auth/userinfo.email' - scope : 'your_scope_oauth', - - // The client ID of application registered on OAuth 2.0 server - clientId: 'your_client_id' -}; + scope : 'profile', -// Create the auth manager for the Data Transfer app. -const createAuthManager = () => new GoogleAuthManager(AUTH_CONFIGURATION); \ No newline at end of file + // The client ID of application registered on OAuth 2.0 server. + clientId: CLIENT_ID +}; \ No newline at end of file diff --git a/QuickStart/config_mock.js b/QuickStart/config_mock.js new file mode 100644 index 0000000..6040f05 --- /dev/null +++ b/QuickStart/config_mock.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2018 BlackBerry. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +'use strict'; + +// This user ID will be used as the user's identity.. +const USER_ID = 'my.user.id@blackhole.sw.rim.net'; + +// This secret is used to protect user keys. Must be individual for each user. +const USER_SECRET = 'user_secret'; + +// This domain is a string known to the BBM Enterprise server, which is +// generally a GUID. +// To create a new domain follow the link below +// https://account.good.com/#/a/organization/applications/add +const ID_PROVIDER_DOMAIN = 'your_idp_domain'; + +// ============================================================================= +// Configuration below does not require modifications. Change it only if you +// want to change existing application behavior. + +const AUTH_CONFIGURATION = { }; + +// The environment of your BBM Enterprise server. Must be either 'Sandbox' or +// 'Production'. +const ID_PROVIDER_ENVIRONMENT = 'Sandbox'; + +// The URL or relative path of the Argon2 WASM file. +const KMS_ARGON_WASM_URL = '../../sdk/argon2.wasm'; \ No newline at end of file diff --git a/QuickStart/index.html b/QuickStart/index.html index 6dd76f5..fc8752f 100644 --- a/QuickStart/index.html +++ b/QuickStart/index.html @@ -23,11 +23,26 @@ - - - + + + + + + + + + + + +