SlideShare uma empresa Scribd logo
1 de 28
Baixar para ler offline
A shit load of 3rd party
Javascript widgets
…and a shit load of + security risks
+ page weight
+ maintenance
RICH MANALANG / @RMANALAN / ATLASSIAN

Making our web apps
<safely> hackable
Hackable => Extensible
3 C A PA B I L I T I E S

• Access to REST APIs
• Event notifications
• UI extensibility
A SHIP IN PORT IS
S A F E , B U T T H AT ' S
N O T W H AT S H I P S A R E
B U I LT F O R .
— GRACE HOPPER
C O N T R A C T B E T W E E N H O S T A N D 3 R D PA R T Y

• Ability for 3rd party to resize itself based on content size
• Ability for 3rd party to make requests with the host
• Ability for 3rd party to send and listen to events on the host
w i n d o w. p o s t M e s s a g e ( )
// Parent => IFrame
!

// Parent
var someIframe = document.getElementById('some-iframe');
someIframe.contentWindow.postMessage('yo', '*');
!
!

// IFrame
window.addEventListener('message', function (e) {
alert(e.data); // yo dude!
}, false);
w i n d o w. p o s t M e s s a g e ( )

// IFrame => Parent
!

// Parent
window.addEventListener('message', function (e) {
alert(e.data); // hey!
}, false);
!
!

// IFrame
window.postMessage('hey', '*');
w i n d o w. p o s t M e s s a g e ( )

• Prone to resource contention
• Solution: use channel messaging
postMessage + MessageChannel is raw
O T H E R A LT E R N AT I V E S …
• postMessage is IE 8+ only (partial support)
• easyXDM
• porthole
• Oasis.js
• Conductor.js
• Open web way to safely embed 3rd party code
• Sandboxing can be through an IFrame or a Web Worker
• Capability-based security
• Abstractions for services, consumers, events, and requests
• Async via Promises
• Wiretapping
// Host (parent http://example.com)

// Sandbox (IFrame http://xyz.com/iframe.html)

!
// Service to expose to sandboxes
var PingService = Oasis.Service.extend({
initialize: function() {
this.send('ping');
},
!
events: {
pong: function() {
alert("Got a pong!");
}
}
});
!
// Creates the sandbox
oasis.createSandbox('http://xyz.com/iframe.html', {
capabilities: [‘ping’],
// adapter: oasis.adapters.webworker, // no UI
services: {
ping: PingService
}
});

!
// Consumer that handles the ping capability
var PingConsumer = Oasis.Consumer.extend({
events: {
ping: function() {
this.send('pong');
}
}
});
!
// Connect to the host
Oasis.connect({
consumers: {
ping: PingConsumer // request ping capability
}
});
C o n d u c t o r. j s

• A framework for building sandboxed apps
• Gives 3rd parties a well-defined framework for building extensions
• Built on top of Oasis.js
C o n d u c t o r. j s

// Card (http://xyz.com/awesome-card.js)

!

// Load dependencies
Conductor.require('lib/jquery.js');
Conductor.require('lib/handlebars.js');

!

var template = '<div>{{message}}</div>';

!

// Define card
Conductor.card({

!

// Host (parent http://example.com)
!
// Bootstrap a new conductor instance
var conductor = new Conductor( options );
!
// Load a card
conductor.load('http://xyz.com/awesome-card.js');
!
// Add to the DOM
conductor.appendTo($('#target'));

!

!

!

// Oasis style capabilities.
consumers: {
pong: Conductor.Oasis.Consumer.extend({
requests: {
// handle requests from the host
// or other cards
},
events: {
// handle events from the host
// or other cards
}
})
},
activate: function() {
// initialize your card here...
},
compileTemplates: function(){
template = Handlebars.compile(template);
},

render: function() {
$('body').html(template({ message: "Wassup?" }));
}
});
Wa t c h @ t o m d a l e t a l k a b o u t O a s i s / C o n d u c t o r

http://j.mp/conductorjs
IMPERFECT

• CSS on host doesn’t cascade to IFrames — there’s hack (detect and pass in

parent styles to IFrame)

• Relative links open in the IFrame — there’s a “fix” (use the <base> tag)
• Dynamic resizing is an art — over/underflow detection sort of works
GRACIAS…AND PLEASE…

• Follow me at @rmanalan
• Don’t forget to take those Atlassian drink glasses home with you
• Come talk to me about an awesome job at an awesome company

Mais conteúdo relacionado

Destaque

Historia3.3 3
Historia3.3 3Historia3.3 3
Historia3.3 3katixa
 
PEK Spring Picnic 2007
PEK Spring Picnic 2007PEK Spring Picnic 2007
PEK Spring Picnic 2007Chris Johnson
 
Amy&Per Erik
Amy&Per ErikAmy&Per Erik
Amy&Per Erikvinion
 
Deforestation
DeforestationDeforestation
Deforestationkimoneill
 
Importance Of Being Driven
Importance Of Being DrivenImportance Of Being Driven
Importance Of Being DrivenAntonio Terreno
 
Publizitate eta HHPP sarrera: 4. gaia
Publizitate eta HHPP sarrera: 4. gaiaPublizitate eta HHPP sarrera: 4. gaia
Publizitate eta HHPP sarrera: 4. gaiakatixa
 
El Pollo Loco
El Pollo LocoEl Pollo Loco
El Pollo Locoburnsc62
 

Destaque (9)

Historia3.3 3
Historia3.3 3Historia3.3 3
Historia3.3 3
 
PEK Spring Picnic 2007
PEK Spring Picnic 2007PEK Spring Picnic 2007
PEK Spring Picnic 2007
 
Assignment Fireworks
Assignment FireworksAssignment Fireworks
Assignment Fireworks
 
Amy&Per Erik
Amy&Per ErikAmy&Per Erik
Amy&Per Erik
 
Deforestation
DeforestationDeforestation
Deforestation
 
Importance Of Being Driven
Importance Of Being DrivenImportance Of Being Driven
Importance Of Being Driven
 
Publizitate eta HHPP sarrera: 4. gaia
Publizitate eta HHPP sarrera: 4. gaiaPublizitate eta HHPP sarrera: 4. gaia
Publizitate eta HHPP sarrera: 4. gaia
 
Something About The Web
Something About The WebSomething About The Web
Something About The Web
 
El Pollo Loco
El Pollo LocoEl Pollo Loco
El Pollo Loco
 

Semelhante a Making our web apps safely hackable

Krzysztof Kotowicz - Hacking HTML5
Krzysztof Kotowicz - Hacking HTML5Krzysztof Kotowicz - Hacking HTML5
Krzysztof Kotowicz - Hacking HTML5DefconRussia
 
Mobile Device APIs
Mobile Device APIsMobile Device APIs
Mobile Device APIsJames Pearce
 
HTML5 Web Messaging
HTML5 Web MessagingHTML5 Web Messaging
HTML5 Web MessagingMike Taylor
 
Hacking HTML5 offensive course (Zeronights edition)
Hacking HTML5 offensive course (Zeronights edition)Hacking HTML5 offensive course (Zeronights edition)
Hacking HTML5 offensive course (Zeronights edition)Krzysztof Kotowicz
 
Creating an Effective Mobile API
Creating an Effective Mobile API Creating an Effective Mobile API
Creating an Effective Mobile API Nick DeNardis
 
Browser Horror Stories
Browser Horror StoriesBrowser Horror Stories
Browser Horror StoriesEC-Council
 
JavaScript Security: Mastering Cross Domain Communications in complex JS appl...
JavaScript Security: Mastering Cross Domain Communications in complex JS appl...JavaScript Security: Mastering Cross Domain Communications in complex JS appl...
JavaScript Security: Mastering Cross Domain Communications in complex JS appl...Thomas Witt
 
HTML5 on Mobile
HTML5 on MobileHTML5 on Mobile
HTML5 on MobileAdam Lu
 
WebSocket Perspectives 2015 - Clouds, Streams, Microservices and WoT
WebSocket Perspectives 2015 - Clouds, Streams, Microservices and WoTWebSocket Perspectives 2015 - Clouds, Streams, Microservices and WoT
WebSocket Perspectives 2015 - Clouds, Streams, Microservices and WoTFrank Greco
 
Scout xss csrf_security_presentation_chicago
Scout xss csrf_security_presentation_chicagoScout xss csrf_security_presentation_chicago
Scout xss csrf_security_presentation_chicagoknaddison
 
Application Security
Application SecurityApplication Security
Application Securitynirola
 
[HEWEBAR 2012] Adaptive Images in Responsive Web Design
[HEWEBAR 2012] Adaptive Images in Responsive Web Design[HEWEBAR 2012] Adaptive Images in Responsive Web Design
[HEWEBAR 2012] Adaptive Images in Responsive Web DesignChristopher Schmitt
 
Rapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesRapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesciklum_ods
 
Hacking Client Side Insecurities
Hacking Client Side InsecuritiesHacking Client Side Insecurities
Hacking Client Side Insecuritiesamiable_indian
 
Building @Anywhere (for TXJS)
Building @Anywhere (for TXJS)Building @Anywhere (for TXJS)
Building @Anywhere (for TXJS)danwrong
 
Opening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the IslandsOpening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the IslandsBastian Hofmann
 

Semelhante a Making our web apps safely hackable (20)

Krzysztof Kotowicz - Hacking HTML5
Krzysztof Kotowicz - Hacking HTML5Krzysztof Kotowicz - Hacking HTML5
Krzysztof Kotowicz - Hacking HTML5
 
Mobile Device APIs
Mobile Device APIsMobile Device APIs
Mobile Device APIs
 
HTML5 Web Messaging
HTML5 Web MessagingHTML5 Web Messaging
HTML5 Web Messaging
 
Hacking HTML5 offensive course (Zeronights edition)
Hacking HTML5 offensive course (Zeronights edition)Hacking HTML5 offensive course (Zeronights edition)
Hacking HTML5 offensive course (Zeronights edition)
 
Creating an Effective Mobile API
Creating an Effective Mobile API Creating an Effective Mobile API
Creating an Effective Mobile API
 
Transforming WebSockets
Transforming WebSocketsTransforming WebSockets
Transforming WebSockets
 
Browser Horror Stories
Browser Horror StoriesBrowser Horror Stories
Browser Horror Stories
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScript
 
JavaScript Security: Mastering Cross Domain Communications in complex JS appl...
JavaScript Security: Mastering Cross Domain Communications in complex JS appl...JavaScript Security: Mastering Cross Domain Communications in complex JS appl...
JavaScript Security: Mastering Cross Domain Communications in complex JS appl...
 
HTML5 on Mobile
HTML5 on MobileHTML5 on Mobile
HTML5 on Mobile
 
WebSocket Perspectives 2015 - Clouds, Streams, Microservices and WoT
WebSocket Perspectives 2015 - Clouds, Streams, Microservices and WoTWebSocket Perspectives 2015 - Clouds, Streams, Microservices and WoT
WebSocket Perspectives 2015 - Clouds, Streams, Microservices and WoT
 
Scout xss csrf_security_presentation_chicago
Scout xss csrf_security_presentation_chicagoScout xss csrf_security_presentation_chicago
Scout xss csrf_security_presentation_chicago
 
Application Security
Application SecurityApplication Security
Application Security
 
Pushing the Web: Interesting things to Know
Pushing the Web: Interesting things to KnowPushing the Web: Interesting things to Know
Pushing the Web: Interesting things to Know
 
[HEWEBAR 2012] Adaptive Images in Responsive Web Design
[HEWEBAR 2012] Adaptive Images in Responsive Web Design[HEWEBAR 2012] Adaptive Images in Responsive Web Design
[HEWEBAR 2012] Adaptive Images in Responsive Web Design
 
Rapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesRapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devices
 
Hacking Client Side Insecurities
Hacking Client Side InsecuritiesHacking Client Side Insecurities
Hacking Client Side Insecurities
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScript
 
Building @Anywhere (for TXJS)
Building @Anywhere (for TXJS)Building @Anywhere (for TXJS)
Building @Anywhere (for TXJS)
 
Opening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the IslandsOpening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the Islands
 

Último

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 

Último (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 

Making our web apps safely hackable

  • 1.
  • 2. A shit load of 3rd party Javascript widgets
  • 3. …and a shit load of + security risks + page weight + maintenance
  • 4. RICH MANALANG / @RMANALAN / ATLASSIAN Making our web apps <safely> hackable
  • 6.
  • 7.
  • 8. 3 C A PA B I L I T I E S • Access to REST APIs • Event notifications • UI extensibility
  • 9.
  • 10. A SHIP IN PORT IS S A F E , B U T T H AT ' S N O T W H AT S H I P S A R E B U I LT F O R . — GRACE HOPPER
  • 11. C O N T R A C T B E T W E E N H O S T A N D 3 R D PA R T Y • Ability for 3rd party to resize itself based on content size • Ability for 3rd party to make requests with the host • Ability for 3rd party to send and listen to events on the host
  • 12. w i n d o w. p o s t M e s s a g e ( ) // Parent => IFrame ! // Parent var someIframe = document.getElementById('some-iframe'); someIframe.contentWindow.postMessage('yo', '*'); ! ! // IFrame window.addEventListener('message', function (e) { alert(e.data); // yo dude! }, false);
  • 13. w i n d o w. p o s t M e s s a g e ( ) // IFrame => Parent ! // Parent window.addEventListener('message', function (e) { alert(e.data); // hey! }, false); ! ! // IFrame window.postMessage('hey', '*');
  • 14. w i n d o w. p o s t M e s s a g e ( ) • Prone to resource contention • Solution: use channel messaging
  • 16. O T H E R A LT E R N AT I V E S … • postMessage is IE 8+ only (partial support) • easyXDM • porthole • Oasis.js • Conductor.js
  • 17. • Open web way to safely embed 3rd party code • Sandboxing can be through an IFrame or a Web Worker • Capability-based security • Abstractions for services, consumers, events, and requests • Async via Promises • Wiretapping
  • 18. // Host (parent http://example.com) // Sandbox (IFrame http://xyz.com/iframe.html) ! // Service to expose to sandboxes var PingService = Oasis.Service.extend({ initialize: function() { this.send('ping'); }, ! events: { pong: function() { alert("Got a pong!"); } } }); ! // Creates the sandbox oasis.createSandbox('http://xyz.com/iframe.html', { capabilities: [‘ping’], // adapter: oasis.adapters.webworker, // no UI services: { ping: PingService } }); ! // Consumer that handles the ping capability var PingConsumer = Oasis.Consumer.extend({ events: { ping: function() { this.send('pong'); } } }); ! // Connect to the host Oasis.connect({ consumers: { ping: PingConsumer // request ping capability } });
  • 19. C o n d u c t o r. j s • A framework for building sandboxed apps • Gives 3rd parties a well-defined framework for building extensions • Built on top of Oasis.js
  • 20.
  • 21.
  • 22. C o n d u c t o r. j s // Card (http://xyz.com/awesome-card.js) ! // Load dependencies Conductor.require('lib/jquery.js'); Conductor.require('lib/handlebars.js'); ! var template = '<div>{{message}}</div>'; ! // Define card Conductor.card({ ! // Host (parent http://example.com) ! // Bootstrap a new conductor instance var conductor = new Conductor( options ); ! // Load a card conductor.load('http://xyz.com/awesome-card.js'); ! // Add to the DOM conductor.appendTo($('#target')); ! ! ! // Oasis style capabilities. consumers: { pong: Conductor.Oasis.Consumer.extend({ requests: { // handle requests from the host // or other cards }, events: { // handle events from the host // or other cards } }) }, activate: function() { // initialize your card here... }, compileTemplates: function(){ template = Handlebars.compile(template); }, render: function() { $('body').html(template({ message: "Wassup?" })); } });
  • 23. Wa t c h @ t o m d a l e t a l k a b o u t O a s i s / C o n d u c t o r http://j.mp/conductorjs
  • 24. IMPERFECT • CSS on host doesn’t cascade to IFrames — there’s hack (detect and pass in parent styles to IFrame) • Relative links open in the IFrame — there’s a “fix” (use the <base> tag) • Dynamic resizing is an art — over/underflow detection sort of works
  • 25.
  • 26.
  • 27.
  • 28. GRACIAS…AND PLEASE… • Follow me at @rmanalan • Don’t forget to take those Atlassian drink glasses home with you • Come talk to me about an awesome job at an awesome company