Skip to content
This repository was archived by the owner on Jul 19, 2019. It is now read-only.

Migrate to Reason + add Identity submodule in preparation for further additions #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*.annot
*.cmj
*.bak
lib/bs
lib/
*.mlast
*.mliast
.vscode
Expand Down
4 changes: 3 additions & 1 deletion bsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"src",
"examples"
],
"bsc-flags": ["-bs-super-errors"],
"bs-dependencies" : [
// add your bs-dependencies here
]
],
"refmt": 3
}
28 changes: 0 additions & 28 deletions examples/examples.ml

This file was deleted.

33 changes: 33 additions & 0 deletions examples/examples.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
open Chrome.Identity;

let testGetAuthToken = () =>
getAuthToken(
mkAuthOptions(
~interactive=Js.true_,
(),
~scopes=["scope"],
~account=mkAccountInfo(~id="id", ())
),
(v) => Js.log(v)
);

let testGetProfileUserInfo = getProfileUserInfo((userInfo) => Js.log(userInfo##email));

let testRemoveCachedAuthToken = removeCachedAuthToken({"token": "token"}, () => Js.log("Success"));

let testLaunchWebAuthFlow =
launchWebAuthFlow(
mkWebFlowOptions(~url="https://example.com", ()),
(mResponseURL, ()) =>
switch (Js.Null.to_opt(mResponseURL)) {
| Some(responseUrl) => Js.log(responseUrl)
| None => Js.log("No url returned!")
}
);

let testGetRedirectURL = getRedirectURL(Js.Null.from_opt(Some("path")));

let testOnSignInChanged =
OnSignInChanged.addListener(
(accountInfo, signedIn) => Js.log(signedIn) |> ((_) => Js.log(accountInfo##id))
);
88 changes: 88 additions & 0 deletions src/IdentityRe.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/* chrome.identity.getAuthToken */
class type _accountInfo =
[@bs]
{
pub id: string
};

type accountInfo = Js.t(_accountInfo);

[@bs.obj] external mkAccountInfo : (~id: string=?, unit) => accountInfo = "";

class type _getAuthTokenOptions =
[@bs]
{
pub interactive: Js.boolean;
pub scopes: list(string);
pub account: accountInfo
};

type getAuthTokenOptions = Js.t(_getAuthTokenOptions);

[@bs.obj]
external mkAuthOptions :
(~interactive: Js.boolean=?, ~scopes: list(string)=?, ~account: accountInfo=?, unit) =>
getAuthTokenOptions =
"";

[@bs.scope ("chrome", "identity")] [@bs.val]
external getAuthToken : (getAuthTokenOptions, string => 'a) => unit =
"getAuthToken";

/* chrome.identity.getProfileUserInfo */
class type _profileUserInfo =
[@bs]
{
pub id: string;
pub email: string
};

type profileUserInfo = Js.t(_profileUserInfo);

[@bs.scope ("chrome", "identity")] [@bs.val]
external getProfileUserInfo : (profileUserInfo => 'a) => unit =
"getProfileUserInfo";

/* chrome.identity.removeCachedAuthToken */
class type _rmCachedToken =
[@bs]
{
pub token: string
};

type rmCachedTokenOptions = Js.t(_rmCachedToken);

[@bs.obj] external mkRmCachedTokenOptions : (~token: string, unit) => rmCachedTokenOptions = "";

[@bs.scope ("chrome", "identity")] [@bs.val]
external removeCachedAuthToken : (rmCachedTokenOptions, unit => 'a) => unit =
"removeCachedAuthToken";

/* chrome.identity.launchWebAuthFlow */
class type _webAuthFlowOptions =
[@bs]
{
pub url: string;
pub interactive: Js.boolean
};

type webAuthFlowOptions = Js.t(_webAuthFlowOptions);

[@bs.obj]
external mkWebFlowOptions : (~url: string, ~interactive: Js.boolean=?, unit) => webAuthFlowOptions =
"";

[@bs.scope ("chrome", "identity")] [@bs.val]
external launchWebAuthFlow : (webAuthFlowOptions, (Js.null(string), unit) => 'a) => unit =
"launchWebAuthFlow";

/* chrome.identity.getRedirectURL */
[@bs.scope ("chrome", "identity")] [@bs.val] external getRedirectURL : Js.null(string) => string =
"getRedirectURL";

/* chrome.identity.onSignInChanged.addListener */
module OnSignInChanged = {
[@bs.scope ("chrome", "identity", "onSignInChanged")] [@bs.val]
external addListener : ((accountInfo, Js.boolean) => 'a) => unit =
"addListener";
};
65 changes: 0 additions & 65 deletions src/chrome.ml

This file was deleted.

1 change: 1 addition & 0 deletions src/chrome.re
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module Identity = IdentityRe;