npm module for A2P3
Register as a user
Create a CLI Agent at Setup and save the
npm install a2p3
Edit the config.json file and edit the
name for as appropriate
npm run-script register
When installed, a default
config.json file is created in
node_modules/a2p3 if one does not already exist. This file shold be copied up into your application directory and the
device parameter must be inserted.
register.js script will use the values in
config.json to register the app with
name at the Registrar, and registers the app at the configured
resources (defaults to all resource servers - Email, SI, Health and People) and saves all the keys and key IDs into
vault.json. See the vault.json section for more details. You should keep the contents of your
vault.json file secret!
A config.json file configures how
register.js will generate the
vault.json file, and configures
a2p3. Looked at the
register.js source to see other defaults that can be changed for more complex development environments.
vault.json file has the keys and key IDs for the Identifier Exchange (obtained when registering the App at the Registrar) and for any Resource Server. Here is a sample file:
The easy way to generate a vault.json file is to use the
If you change the
resources in your
config.json file, you can generate a new
node node_modules\a2p3\setup\register.js config.json
This assumes config.json is in the current directory.
This command will generate a new
vault.json file in the current directory for you assuming all went well.
Creates an Agent Request using the values in
vault and the supplied
params object with the following properties:
callbackURL: where the Agent will return results for the Agent Request. If
returnURL, the Agent will send back results via a redirected GET. If
callbackURL, the Agent will POST the results to the URL as a JSON message. REQUIRED.
resources: an array of resources the application would like authorization from the User to access. OPTIONAL
var a2p3 =config =vault =params =returnURL = ''resources =''''var agentRequest = a2p3
Helper routine that generates 16 bytes of random data encoded as a URL safe base 64 string.
Creates an A2P3 Resource object using the values in
Exchanges an Agent Request and IX Token at the Identifier Exchange for the Apps directed identifier for the user and Resource Server Tokens for any requested resources.
Calls the API with any parameters. Resource.exchange() MUST have been called previously. If the api is a to standaridized resource server, the host will be replaced with the first redirected resource server returned from the IX. To get results from all resource servers, use Resource.callMultiple()
Calls all supplied APIs in parrelel with the supplied parameters. Resource.exchange() MUST have been called previously. All resource servers provided by the Identifier Exchange for a standardize resource are called for any standardized resource API provided.
var a2p3 =config =vault =params =returnURL = ''resources =''''''var agentRequest = a2p3// send agentReqest to Agent, get back ixTokenvar rs config vaultdetails ='': null'': null'': nullrs// output of results: in this example, the user has health records at both BC and Alberta'':result : email: 'email@example.com''':redirect : '''':result : name: 'John Smith' photo: '''':redirect : '' '''':result : prov_number: '1111111111''':result : prov_number: '2222222222'
A2P3_specs Specifications and POC documentation
A2P3 POC Server implementation source (node.js)
A2P3_agent POC mobile agent (PhoneGap)
A2P3_bank POC mobile bank app (PhoneGap)
sample-node-a2p3 sample A2P3 application using node-a2p3