@reclaimprotocol/js-sdk 1.3.11 → 2.0.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.
package/dist/index.d.ts CHANGED
@@ -1,51 +1,21 @@
1
- interface ProviderV2 {
2
- id: string;
1
+ interface ProviderData {
3
2
  httpProviderId: string;
4
3
  name: string;
5
- logoUrl: string;
6
4
  url: string;
7
- method?: 'GET' | 'POST';
8
5
  loginUrl: string;
9
- responseSelections: {
10
- invert: boolean;
11
- responseMatch: string;
12
- xPath?: string | undefined;
13
- jsonPath?: string | undefined;
14
- }[];
15
- headers?: {
16
- [key: string]: string;
17
- };
18
- creatorEmail: string;
19
- applicationId: string[];
20
- iconPath: {
21
- uri: string;
22
- };
23
- customInjection?: string;
24
- urlType: 'CONSTANT' | 'REGEX';
25
- proofCardTitle: string;
26
- proofCardText: string;
27
- bodySniff?: {
28
- enabled: boolean;
29
- regex?: string;
30
- };
31
- userAgent?: {
32
- ios?: string;
33
- android?: string;
34
- };
35
- geoLocation?: string;
36
- matchType?: string;
37
- injectionType: string;
38
- verificationType: string;
39
- disableRequestReplay: boolean;
6
+ responseSelections: ResponseSelection[];
7
+ bodySniff?: BodySniff;
40
8
  }
41
9
  interface ResponseSelection {
42
- JSONPath: string;
43
- XPath: string;
10
+ invert: boolean;
44
11
  responseMatch: string;
12
+ xPath?: string;
13
+ jsonPath?: string;
45
14
  }
46
15
  interface BodySniff {
47
16
  enabled: boolean;
48
- regex: string;
17
+ regex?: string;
18
+ template?: string;
49
19
  }
50
20
  interface Proof {
51
21
  identifier: string;
@@ -67,68 +37,13 @@ interface ProviderClaimData {
67
37
  owner: string;
68
38
  timestampS: number;
69
39
  context: string;
70
- /**
71
- * identifier of the claim;
72
- * Hash of (provider, parameters, context)
73
- *
74
- * This is different from the claimId returned
75
- * from the smart contract
76
- */
77
40
  identifier: string;
78
41
  epoch: number;
79
42
  }
80
- interface RequestedProofs {
81
- id: string;
82
- sessionId: string;
83
- name: string;
84
- callbackUrl: string;
85
- statusUrl: string;
86
- claims: RequestedClaim[];
87
- }
88
- interface RequestedClaim {
89
- provider: string;
90
- context: string;
91
- httpProviderId: string;
92
- payload: Payload;
93
- }
94
- interface Payload {
95
- metadata: {
96
- name: string;
97
- logoUrl: string;
98
- proofCardTitle: string;
99
- proofCardText: string;
100
- };
43
+ interface RequestedProof {
101
44
  url: string;
102
- urlType: 'CONSTANT' | 'REGEX';
103
- method: 'GET' | 'POST';
104
- login: {
105
- url: string;
106
- };
107
- responseSelections: {
108
- invert: boolean;
109
- responseMatch: string;
110
- xPath?: string;
111
- jsonPath?: string;
112
- }[];
113
- headers?: {
114
- [key: string]: string;
115
- };
116
- customInjection?: string;
117
- bodySniff?: {
118
- enabled: boolean;
119
- regex?: string;
120
- };
121
- userAgent?: {
122
- ios?: string;
123
- android?: string;
124
- };
125
- geoLocation?: string;
126
- matchType?: string;
127
- injectionType: string;
128
- verificationType: string;
129
- disableRequestReplay: boolean;
130
45
  parameters: {
131
- [key: string]: string | undefined;
46
+ [key: string]: string;
132
47
  };
133
48
  }
134
49
  interface Context {
@@ -136,10 +51,6 @@ interface Context {
136
51
  contextMessage: string;
137
52
  }
138
53
  interface Beacon {
139
- /**
140
- * Get the witnesses for the epoch specified
141
- * or the current epoch if none is specified
142
- */
143
54
  getState(epoch?: number): Promise<BeaconState>;
144
55
  close?(): Promise<void>;
145
56
  }
@@ -151,72 +62,53 @@ type BeaconState = {
151
62
  };
152
63
 
153
64
  type StartSessionParams = {
154
- onSuccessCallback: OnSuccessCallback;
155
- onFailureCallback: OnFailureCallback;
65
+ onSuccess: OnSuccess;
66
+ onError: OnError;
156
67
  };
157
- type OnSuccessCallback = (proofs: Proof[]) => void;
158
- type OnFailureCallback = (error: Error) => void;
68
+ type OnSuccess = (proof: Proof) => void;
69
+ type OnError = (error: Error) => void;
159
70
  type ProofRequestOptions = {
160
71
  log?: boolean;
161
- sessionId?: string;
72
+ acceptAiProviders?: boolean;
162
73
  };
163
- type ApplicationId = string;
164
- type Signature = string;
165
- type AppCallbackUrl = string;
166
- type SessionId = string;
167
- type StatusUrl = string;
168
- type NoReturn = void;
169
74
 
170
- declare class Reclaim {
171
- static verifySignedProof(proof: Proof): Promise<boolean>;
172
- static transformForOnchain(proof: Proof): {
173
- claimInfo: {
174
- [k: string]: string;
175
- };
176
- signedClaim: {
177
- claim: {
178
- [k: string]: string | number;
179
- };
180
- signatures: string[];
181
- };
182
- };
183
- static verifyProvider(proof: Proof, providerHash: string): boolean;
184
- static ProofRequest: {
185
- new (applicationId: string, options?: ProofRequestOptions): {
186
- applicationId: ApplicationId;
187
- signature?: string | undefined;
188
- appCallbackUrl?: string | undefined;
189
- sessionId: SessionId;
190
- statusUrl?: string | undefined;
191
- context: Context;
192
- requestedProofs?: RequestedProofs | undefined;
193
- providerId?: string | undefined;
194
- redirectUrl?: string | undefined;
195
- intervals: Map<string, NodeJS.Timer>;
196
- linkingVersion: string;
197
- timeStamp: string;
198
- addContext(address: string, message: string): NoReturn;
199
- setAppCallbackUrl(url: string): NoReturn;
200
- setRedirectUrl(url: string): NoReturn;
201
- setStatusUrl(url: string): NoReturn;
202
- setSignature(signature: Signature): NoReturn;
203
- getAppCallbackUrl(): AppCallbackUrl;
204
- getStatusUrl(): StatusUrl;
205
- getRequestedProofs(): RequestedProofs;
206
- generateSignature(applicationSecret: string): Promise<Signature>;
207
- buildProofRequest(providerId: string, redirectUser?: boolean, linkingVersion?: string): Promise<RequestedProofs>;
208
- createVerificationRequest(): Promise<{
209
- statusUrl: StatusUrl;
210
- requestUrl: string;
211
- }>;
212
- startSession({ onSuccessCallback, onFailureCallback }: StartSessionParams): Promise<void>;
213
- scheduleIntervalEndingTask(onFailureCallback: OnFailureCallback): void;
214
- availableParams(): string[];
215
- setParams(params: {
216
- [key: string]: string;
217
- }): NoReturn;
218
- };
219
- };
75
+ declare function verifyProof(proof: Proof): Promise<boolean>;
76
+ declare function transformForOnchain(proof: Proof): {
77
+ claimInfo: any;
78
+ signedClaim: any;
79
+ };
80
+ declare class ReclaimProofRequest {
81
+ private applicationId;
82
+ private signature?;
83
+ private appCallbackUrl?;
84
+ private sessionId;
85
+ private options?;
86
+ private context;
87
+ private requestedProof?;
88
+ private providerId;
89
+ private redirectUrl?;
90
+ private intervals;
91
+ private timeStamp;
92
+ private constructor();
93
+ static init(applicationId: string, appSecret: string, providerId: string, options?: ProofRequestOptions): Promise<ReclaimProofRequest>;
94
+ static fromJsonString(jsonString: string): Promise<ReclaimProofRequest>;
95
+ setAppCallbackUrl(url: string): void;
96
+ setRedirectUrl(url: string): void;
97
+ addContext(address: string, message: string): void;
98
+ setParams(params: {
99
+ [key: string]: string;
100
+ }): void;
101
+ getAppCallbackUrl(): string;
102
+ getStatusUrl(): string;
103
+ private setSignature;
104
+ private generateSignature;
105
+ private buildProofRequest;
106
+ private getRequestedProof;
107
+ private availableParams;
108
+ private clearInterval;
109
+ toJsonString(options?: ProofRequestOptions): string;
110
+ getRequestUrl(): Promise<string>;
111
+ startSession({ onSuccess, onError }: StartSessionParams): Promise<void>;
220
112
  }
221
113
 
222
- export { type Beacon, type BeaconState, type BodySniff, type Context, type Payload, type Proof, type ProviderClaimData, type ProviderV2, Reclaim, type RequestedClaim, type RequestedProofs, type ResponseSelection, type WitnessData };
114
+ export { type Beacon, type BeaconState, type BodySniff, type Context, type Proof, type ProviderClaimData, type ProviderData, ReclaimProofRequest, type RequestedProof, type ResponseSelection, type WitnessData, transformForOnchain, verifyProof };