@synonymdev/react-native-pubky 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAmB1D,wBAAsB,IAAI,CACxB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAM3B;AAED,KAAK,UAAU,GAAG;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,UAAU,EAAE,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAsB,YAAY,CAChC,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAWnC;AAED,wBAAsB,OAAO,CAC3B,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAU3B;AAED,UAAU,IAAI;IACZ,WAAW,EAAE,OAAO,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE;QACL,OAAO,EAAE,MAAM,EAAE,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,GAAG,EAAE,MAAM,CAAC;CACb;AACD,UAAU,UAAU;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,IAAI,EAAE,CAAC;IAChB,SAAS,EAA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EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,YAAY,EAAE,CAAC;CAC/B;AAED,wBAAsB,YAAY,CAChC,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAUtC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synonymdev/react-native-pubky",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "React Native Implementation of Pubky",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/commonjs/index.js",
package/src/index.tsx CHANGED
@@ -82,11 +82,13 @@ interface ITxt {
82
82
  ttl: number;
83
83
  }
84
84
  interface IDNSPacket {
85
- dns_packet: string;
85
+ signed_packet: string;
86
86
  public_key: string;
87
- records: ITxt[];
88
87
  signature: string;
89
88
  timestamp: number;
89
+ last_seen: number;
90
+ dns_packet: string;
91
+ records: ITxt[];
90
92
  }
91
93
  export async function resolve(publicKey: string): Promise<Result<IDNSPacket>> {
92
94
  try {
@@ -99,3 +101,114 @@ export async function resolve(publicKey: string): Promise<Result<IDNSPacket>> {
99
101
  return err(JSON.stringify(e));
100
102
  }
101
103
  }
104
+
105
+ export async function signUp(
106
+ secretKey: string,
107
+ homeserver: string
108
+ ): Promise<Result<string[]>> {
109
+ try {
110
+ const res = await Pubky.signUp(secretKey, homeserver);
111
+ if (res[0] === 'error') {
112
+ return err(res[1]);
113
+ }
114
+ return ok(res[1]);
115
+ } catch (e) {
116
+ return err(JSON.stringify(e));
117
+ }
118
+ }
119
+
120
+ export async function signIn(secretKey: string): Promise<Result<string[]>> {
121
+ try {
122
+ const res = await Pubky.signIn(secretKey);
123
+ if (res[0] === 'error') {
124
+ return err(res[1]);
125
+ }
126
+ return ok(res[1]);
127
+ } catch (e) {
128
+ return err(JSON.stringify(e));
129
+ }
130
+ }
131
+
132
+ export async function signOut(secretKey: string): Promise<Result<string[]>> {
133
+ try {
134
+ const res = await Pubky.signOut(secretKey);
135
+ if (res[0] === 'error') {
136
+ return err(res[1]);
137
+ }
138
+ return ok(res[1]);
139
+ } catch (e) {
140
+ return err(JSON.stringify(e));
141
+ }
142
+ }
143
+
144
+ export async function get(url: string): Promise<Result<string[]>> {
145
+ try {
146
+ const res = await Pubky.get(url);
147
+ if (res[0] === 'error') {
148
+ return err(res[1]);
149
+ }
150
+ return ok(JSON.parse(res[1]));
151
+ } catch (e) {
152
+ return err(JSON.stringify(e));
153
+ }
154
+ }
155
+
156
+ export async function put(
157
+ url: string,
158
+ content: Object
159
+ ): Promise<Result<string[]>> {
160
+ try {
161
+ const res = await Pubky.put(url, JSON.stringify(content));
162
+ if (res[0] === 'error') {
163
+ return err(res[1]);
164
+ }
165
+ return ok(res[1]);
166
+ } catch (e) {
167
+ return err(JSON.stringify(e));
168
+ }
169
+ }
170
+
171
+ export async function publishHttps(
172
+ recordName: string,
173
+ target: string,
174
+ secretKey: string
175
+ ): Promise<Result<string[]>> {
176
+ try {
177
+ const res = await Pubky.publishHttps(recordName, target, secretKey);
178
+ if (res[0] === 'error') {
179
+ return err(res[1]);
180
+ }
181
+ return ok(res[1]);
182
+ } catch (e) {
183
+ return err(JSON.stringify(e));
184
+ }
185
+ }
186
+
187
+ interface IHttpsRecord {
188
+ name: string;
189
+ class: string;
190
+ ttl: number;
191
+ priority: number;
192
+ target: string;
193
+ port?: number;
194
+ alpn?: string[];
195
+ }
196
+
197
+ interface IHttpsResolveResult {
198
+ public_key: string;
199
+ https_records: IHttpsRecord[];
200
+ }
201
+
202
+ export async function resolveHttps(
203
+ publicKey: string
204
+ ): Promise<Result<IHttpsResolveResult>> {
205
+ try {
206
+ const res = await Pubky.resolveHttps(publicKey);
207
+ if (res[0] === 'error') {
208
+ return err(res[1]);
209
+ }
210
+ return ok(JSON.parse(res[1]));
211
+ } catch (e) {
212
+ return err(JSON.stringify(e));
213
+ }
214
+ }