Moonlight-io / asteroid-sdk-js

5 stars 3 forks source link

SDK 'edge' branch #5

Closed rockacola closed 4 years ago

rockacola commented 4 years ago

Purpose of this ticket is for open discussion on feature roadmap and vision of edge branch of asteroid-sdk-js project.

Overview on intentions:

rockacola commented 4 years ago

I'll be dubbed its mature release to be 0.1.0, which should include following efforts:

rockacola commented 4 years ago

@lllwvlvwlll @birmas Documentations along with asteroid-sdk-js-examples will be available in-time, as for now, here's a quick summary on my vision of the API:

The API comes in 2 flavours: class-based and functional-based.

// ES6
const AsteroidDomainUser = require('../dist').AsteroidDomainUser
const config = { networkType: 'stage' }
const adu = new AsteroidDomainUser(config)
// Noticed that the instance has no credential information at the moment
await adu.loginEmail('test@moonlight.io', 'testpassword')
// Access code and refresh code are now been stored in the instance
const res = await adu.getAttributeHeadersByTypes(['name'])

// Wait for 10 minutes so that the access code expires...
// Below will work as the instance will refresh access code automatically when needed
await adu.updatePasswordJwt('newTestPassword')
// ES6
const rpc = require('../dist').rpc
const url = 'https://stage-user.asteroid.moonlight.io/rpc'
const params = {
  email: 'test@moonlight.io',
  password: 'testpassword',
}

const res = await rpc.user.registerEmail(url, params)
console.log('access code:', res.access_code)
console.log('refresh code:', res.refresh_code)
lllwvlvwlll commented 4 years ago

This works well for me. for internal use cases, we will also need to implement the User class since the JWT tokens are representative of a user and shared across all asteroid platforms (adu and adw).

Regarding the merging of our system testing and the examples branches, I'm alright with this idea as long as the example are all written in a way that supports our test framework since this code is used by our CICD workflows.

rockacola commented 4 years ago

All implementations are now complete in edge branch as per https://github.com/Moonlight-io/asteroid-sdk-js/tree/c2d739ee0aa9fd3d2287d924bd92f7afb70ed89a onward.

lllwvlvwlll commented 4 years ago

Do you want to merge this in so we can start using this as the default architecture?

rockacola commented 4 years ago

Do you want to merge this in so we can start using this as the default architecture?

Not quite yet, this will happen after preliminary tests are complete.

rockacola commented 4 years ago

Per previous discussions, we will not take action regards to migrate effort of asteroid-testing into asteroid-sdk-js-examples

rockacola commented 4 years ago

edge branch now merged into master and released as 0.1.0.

Examples and regression tests available on asteroid-sdk-js-examples.