Commit ac812db 1 parent 15f718a commit ac812db Copy full SHA for ac812db
File tree 2 files changed +33
-0
lines changed
2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ import type { OptableConfig } from "../config" ;
2
+ import { fetch } from "../core/network" ;
3
+ import { User } from "./rtb2" ;
4
+
5
+ type TokenizeResponse = {
6
+ User : User ;
7
+ } ;
8
+
9
+ type TokenizeRequest = {
10
+ id : string ;
11
+ } ;
12
+
13
+ function Tokenize ( config : Required < OptableConfig > , id : string ) : Promise < TokenizeResponse > {
14
+ let request : TokenizeRequest = {
15
+ id : id ,
16
+ } ;
17
+ return fetch ( "/v1/tokenize" , config , {
18
+ method : "POST" ,
19
+ headers : {
20
+ "Content-Type" : "application/json" ,
21
+ } ,
22
+ body : JSON . stringify ( request ) ,
23
+ } ) ;
24
+ }
25
+
26
+ export { Tokenize , TokenizeRequest , TokenizeResponse } ;
27
+ export default Tokenize ;
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import {
18
18
import { Witness } from "./edge/witness" ;
19
19
import { Profile } from "./edge/profile" ;
20
20
import { sha256 } from "js-sha256" ;
21
+ import { Tokenize , TokenizeResponse } from "./edge/tokenize" ;
21
22
22
23
class OptableSDK {
23
24
public static version = buildInfo . version ;
@@ -98,6 +99,11 @@ class OptableSDK {
98
99
return Profile ( this . dcn , traits ) ;
99
100
}
100
101
102
+ async tokenize ( id : string ) : Promise < TokenizeResponse > {
103
+ await this . init ;
104
+ return Tokenize ( this . dcn , id ) ;
105
+ }
106
+
101
107
static eid ( email : string ) : string {
102
108
return email ? "e:" + sha256 . hex ( email . toLowerCase ( ) . trim ( ) ) : "" ;
103
109
}
You can’t perform that action at this time.
0 commit comments