diff --git a/README.md b/README.md index 8d2f642..1fa651e 100644 --- a/README.md +++ b/README.md @@ -45,8 +45,8 @@ You can also use the pre-built browser version located in the `dist/` directory: To configure the library: -1. Create an application in the MIRACL Trust platform. For information about how - to do it, see the +1. Create an account in the MIRACL Trust platform. For information about how to + do it, see the [Getting Started](https://miracl.com/resources/docs/guides/get-started/) guide. 2. Create a new instance of MIRACLTrust and pass the configuration as an object: diff --git a/src/client.js b/src/client.js index 0057091..00ae84e 100644 --- a/src/client.js +++ b/src/client.js @@ -1,6 +1,6 @@ -import { parseUriParams, uriEncode } from "./uri.js"; import Crypto from "./crypto.js"; import HTTP from "./http.js"; +import { parseUriParams } from "./uri.js"; import Users from "./users.js"; /** @@ -11,12 +11,6 @@ import Users from "./users.js"; * @param {string} options.seed - Hex-encoded random number generator seed * @param {string} options.deviceName - Name of the current device * @param {Object} options.userStorage - Storage for saving user data - * @param {Object} options.oidc - Parameters for initializing an OIDC auth session - * @param {string} options.oidc.client_id - OIDC Client ID - * @param {string} options.oidc.redirect_uri - OIDC redirect URI - * @param {string} options.oidc.response_type - OIDC response type. Only 'code' is supported - * @param {string} options.oidc.scope - OIDC scope. Must include 'openid' - * @param {string} options.oidc.state - OIDC state * @param {bool} options.cors - Enable CORS requests if set to 'true' * @param {number} options.requestTimeout - Time before an HTTP request times out in milliseconds * @param {string} options.applicationInfo - Set additional information that will be sent via X-MIRACL-CLIENT HTTP header @@ -50,10 +44,6 @@ export default function Client(options) { options.requestTimeout = 4000; } - if (!options.oidc) { - options.oidc = {}; - } - // Set the client name using the current lib version and provided application info options.clientName = "MIRACL Client.js/8.13.0" + (options.applicationInfo ? " " + options.applicationInfo : ""); @@ -149,9 +139,10 @@ Client.prototype.sendPushNotificationForAuth = function (userId, callback) { } const reqData = { - url: this.options.projectUrl + "/pushauth?" + uriEncode(this.options.oidc), + url: this.options.projectUrl + "/pushauth", type: "POST", data: { + projectId: this.options.projectId, prerollId: userId } }; @@ -187,16 +178,10 @@ Client.prototype.sendVerificationEmail = function (userId, callback) { type: "POST", data: { userId: userId, - mpinId: this.users.get(userId, "mpinId"), projectId: this.options.projectId, accessId: this.session.accessId, deviceName: this._getDeviceName(), - deviceTag: this._getDeviceTag(), - clientId: this.options.oidc["client_id"], - redirectURI: this.options.oidc["redirect_uri"], - scope: this.options.oidc["scope"] ? this.options.oidc["scope"].split(" ") : [], - state: this.options.oidc["state"], - nonce: this.options.oidc["nonce"] + deviceTag: this._getDeviceTag() } }; diff --git a/src/uri.js b/src/uri.js index 0f97363..96bc129 100644 --- a/src/uri.js +++ b/src/uri.js @@ -1,15 +1,3 @@ -export function uriEncode (obj) { - const str = []; - - for (const p in obj) { - if (Object.prototype.hasOwnProperty.call(obj, p)) { - str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); - } - } - - return str.join("&"); -} - export function parseUriParams (uri) { const query = uri.split("?").pop(); const queryArr = query.split("&"); diff --git a/test/test-client.js b/test/test-client.js index 9d501c0..1a0653c 100644 --- a/test/test-client.js +++ b/test/test-client.js @@ -187,19 +187,14 @@ describe("Client sendPushNotificationForAuth", () => { let client; before(() => { - const config = testConfig(); - config.oidc = { - client_id: "testClientID" // eslint-disable-line camelcase - }; - client = new Client(config); + client = new Client(testConfig()); }); it("should make a request to the pushauth endpoint", () => { - const requestStub = sinon.stub(client.http, "request").yields(null, { webOTT: "test" }); + sinon.stub(client.http, "request").yields(null, { webOTT: "test" }); client.sendPushNotificationForAuth("test@example.com", (err, data) => { expect(data).to.exist; - expect(requestStub.firstCall.args[0].url).to.equal("https://project.miracl.io/pushauth?client_id=testClientID"); expect(data.webOTT).to.equal("test"); }); });