@reclaimprotocol/inapp-rn-sdk 0.2.1 → 0.3.1
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/InappRnSdk.podspec +1 -1
- package/README.md +8 -6
- package/android/build.gradle +3 -3
- package/android/generated/java/com/reclaimprotocol/inapp_rn_sdk/NativeInappRnSdkSpec.java +13 -5
- package/android/generated/jni/RNInappRnSdkSpec-generated.cpp +11 -4
- package/android/generated/jni/react/renderer/components/RNInappRnSdkSpec/RNInappRnSdkSpecJSI-generated.cpp +10 -3
- package/android/generated/jni/react/renderer/components/RNInappRnSdkSpec/RNInappRnSdkSpecJSI.h +168 -12
- package/android/src/main/java/com/reclaimprotocol/inapp_rn_sdk/InappRnSdkModule.kt +49 -8
- package/ios/InappRnSdk.mm +33 -6
- package/ios/generated/RNInappRnSdkSpec/RNInappRnSdkSpec-generated.mm +32 -8
- package/ios/generated/RNInappRnSdkSpec/RNInappRnSdkSpec.h +53 -3
- package/ios/generated/RNInappRnSdkSpecJSI-generated.cpp +10 -3
- package/ios/generated/RNInappRnSdkSpecJSI.h +168 -12
- package/ios/inapp_rn_sdk/Api.swift +71 -20
- package/lib/commonjs/index.js +126 -30
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/{ReclaimVerificationPlatformChannel.js → platform.js} +48 -106
- package/lib/commonjs/platform.js.map +1 -0
- package/lib/commonjs/specs/NativeInappRnSdk.js.map +1 -1
- package/lib/module/index.js +127 -13
- package/lib/module/index.js.map +1 -1
- package/lib/module/{ReclaimVerificationPlatformChannel.js → platform.js} +46 -103
- package/lib/module/platform.js.map +1 -0
- package/lib/module/specs/NativeInappRnSdk.js.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +140 -8
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/platform.d.ts +18 -0
- package/lib/typescript/commonjs/src/platform.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/specs/NativeInappRnSdk.d.ts +18 -2
- package/lib/typescript/commonjs/src/specs/NativeInappRnSdk.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +140 -8
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/platform.d.ts +18 -0
- package/lib/typescript/module/src/platform.d.ts.map +1 -0
- package/lib/typescript/module/src/specs/NativeInappRnSdk.d.ts +18 -2
- package/lib/typescript/module/src/specs/NativeInappRnSdk.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/index.ts +260 -18
- package/src/platform.ts +218 -0
- package/src/specs/NativeInappRnSdk.ts +21 -2
- package/lib/commonjs/ReclaimVerificationPlatformChannel.js.map +0 -1
- package/lib/commonjs/types/proof.js +0 -16
- package/lib/commonjs/types/proof.js.map +0 -1
- package/lib/module/ReclaimVerificationPlatformChannel.js.map +0 -1
- package/lib/module/types/proof.js +0 -12
- package/lib/module/types/proof.js.map +0 -1
- package/lib/typescript/commonjs/src/ReclaimVerificationPlatformChannel.d.ts +0 -107
- package/lib/typescript/commonjs/src/ReclaimVerificationPlatformChannel.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/types/proof.d.ts +0 -33
- package/lib/typescript/commonjs/src/types/proof.d.ts.map +0 -1
- package/lib/typescript/module/src/ReclaimVerificationPlatformChannel.d.ts +0 -107
- package/lib/typescript/module/src/ReclaimVerificationPlatformChannel.d.ts.map +0 -1
- package/lib/typescript/module/src/types/proof.d.ts +0 -33
- package/lib/typescript/module/src/types/proof.d.ts.map +0 -1
- package/src/ReclaimVerificationPlatformChannel.ts +0 -363
- package/src/types/proof.ts +0 -44
package/lib/commonjs/index.js
CHANGED
|
@@ -4,49 +4,145 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ReclaimVerification = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return _ReclaimVerificationPlatformChannel.ReclaimVerificationPlatformChannel;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports, "ReclaimVerificationPlatformChannelImpl", {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
get: function () {
|
|
22
|
-
return _ReclaimVerificationPlatformChannel.ReclaimVerificationPlatformChannelImpl;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
var _ReclaimVerificationPlatformChannel = require("./ReclaimVerificationPlatformChannel.js");
|
|
7
|
+
var _platform = require("./platform.js");
|
|
8
|
+
/**
|
|
9
|
+
* [ReclaimVerification] is the main class for interacting with the Reclaim verification system.
|
|
10
|
+
* It provides methods to start verification processes, manage platform configurations,
|
|
11
|
+
* and handle verification options.
|
|
12
|
+
*
|
|
13
|
+
* The class can be instantiated with a custom platform implementation, or will use
|
|
14
|
+
* the default [PlatformImpl] if none is provided.
|
|
15
|
+
*/
|
|
26
16
|
class ReclaimVerification {
|
|
27
|
-
static
|
|
28
|
-
constructor(
|
|
29
|
-
if (
|
|
30
|
-
this.
|
|
17
|
+
static defaultPlatform = null;
|
|
18
|
+
constructor(platform) {
|
|
19
|
+
if (platform) {
|
|
20
|
+
this.platform = platform;
|
|
31
21
|
} else {
|
|
32
|
-
if (ReclaimVerification.
|
|
33
|
-
ReclaimVerification.
|
|
22
|
+
if (ReclaimVerification.defaultPlatform == null) {
|
|
23
|
+
ReclaimVerification.defaultPlatform = new _platform.PlatformImpl();
|
|
34
24
|
}
|
|
35
|
-
this.
|
|
25
|
+
this.platform = ReclaimVerification.defaultPlatform;
|
|
36
26
|
}
|
|
37
27
|
}
|
|
38
28
|
async startVerification(request) {
|
|
39
|
-
return this.
|
|
29
|
+
return this.platform.startVerification(request);
|
|
40
30
|
}
|
|
41
31
|
async ping() {
|
|
42
|
-
return this.
|
|
32
|
+
return this.platform.ping();
|
|
43
33
|
}
|
|
44
34
|
setOverrides(overrides) {
|
|
45
|
-
return this.
|
|
35
|
+
return this.platform.setOverrides(overrides);
|
|
46
36
|
}
|
|
47
37
|
clearAllOverrides() {
|
|
48
|
-
return this.
|
|
38
|
+
return this.platform.clearAllOverrides();
|
|
39
|
+
}
|
|
40
|
+
setVerificationOptions(options) {
|
|
41
|
+
return this.platform.setVerificationOptions(options);
|
|
49
42
|
}
|
|
50
43
|
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* This namespace provides types involved in initiating and managing the verification process
|
|
47
|
+
* for proving claims about user data through various providers.
|
|
48
|
+
*/
|
|
51
49
|
exports.ReclaimVerification = ReclaimVerification;
|
|
50
|
+
(function (_ReclaimVerification) {
|
|
51
|
+
/**
|
|
52
|
+
* Represents user's session information for a verification attempt.
|
|
53
|
+
* This data class contains the necessary data to identify and validate a verification session.
|
|
54
|
+
*/
|
|
55
|
+
/**
|
|
56
|
+
* Represents a request for a verification attempt.
|
|
57
|
+
*
|
|
58
|
+
* You can create a request using the [ReclaimVerification.Request] constructor or the [ReclaimVerification.Request.fromManifestMetaData] factory method.
|
|
59
|
+
*/
|
|
60
|
+
/**
|
|
61
|
+
* Contains the proof and response data after verification
|
|
62
|
+
*/
|
|
63
|
+
let ReclaimResult;
|
|
64
|
+
(function (_ReclaimResult) {
|
|
65
|
+
const isProof = _ReclaimResult.isProof = value => {
|
|
66
|
+
return typeof value === 'object' && value !== null && 'identifier' in value && 'signatures' in value && 'witnesses' in value;
|
|
67
|
+
};
|
|
68
|
+
const asProofs = _ReclaimResult.asProofs = proofs => {
|
|
69
|
+
return proofs.filter(isProof);
|
|
70
|
+
};
|
|
71
|
+
})(ReclaimResult || (ReclaimResult = _ReclaimVerification.ReclaimResult || (_ReclaimVerification.ReclaimResult = {})));
|
|
72
|
+
let Overrides;
|
|
73
|
+
(function (_Overrides) {
|
|
74
|
+
;
|
|
75
|
+
})(Overrides || (Overrides = _ReclaimVerification.Overrides || (_ReclaimVerification.Overrides = {})));
|
|
76
|
+
let ExceptionType = /*#__PURE__*/function (ExceptionType) {
|
|
77
|
+
ExceptionType["Cancelled"] = "Cancelled";
|
|
78
|
+
ExceptionType["Dismissed"] = "Dismissed";
|
|
79
|
+
ExceptionType["SessionExpired"] = "SessionExpired";
|
|
80
|
+
ExceptionType["Failed"] = "Failed";
|
|
81
|
+
return ExceptionType;
|
|
82
|
+
}({});
|
|
83
|
+
_ReclaimVerification.ExceptionType = ExceptionType;
|
|
84
|
+
class ReclaimPlatformException extends Error {
|
|
85
|
+
constructor(message, innerError) {
|
|
86
|
+
super(message);
|
|
87
|
+
this.innerError = innerError;
|
|
88
|
+
this.reason = innerError.message;
|
|
89
|
+
if ('userInfo' in innerError) {
|
|
90
|
+
const details = innerError.userInfo;
|
|
91
|
+
this.details = details;
|
|
92
|
+
if ('message' in details) {
|
|
93
|
+
this.reason = details.message || this.reason;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
static isReclaimPlatformException(error) {
|
|
98
|
+
return error instanceof ReclaimPlatformException;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
_ReclaimVerification.ReclaimPlatformException = ReclaimPlatformException;
|
|
102
|
+
class ReclaimVerificationException extends Error {
|
|
103
|
+
constructor(message, innerError, type, sessionId, didSubmitManualVerification, reason) {
|
|
104
|
+
super(message);
|
|
105
|
+
this.innerError = innerError;
|
|
106
|
+
this.type = type;
|
|
107
|
+
this.sessionId = sessionId;
|
|
108
|
+
this.didSubmitManualVerification = didSubmitManualVerification;
|
|
109
|
+
this.reason = reason;
|
|
110
|
+
}
|
|
111
|
+
static fromTypeName(name) {
|
|
112
|
+
switch (name) {
|
|
113
|
+
case "cancelled":
|
|
114
|
+
case "org.reclaimprotocol.inapp_sdk.ReclaimVerification.ReclaimVerificationException.Cancelled":
|
|
115
|
+
return ExceptionType.Cancelled;
|
|
116
|
+
case "dismissed":
|
|
117
|
+
case "org.reclaimprotocol.inapp_sdk.ReclaimVerification.ReclaimVerificationException.Dismissed":
|
|
118
|
+
return ExceptionType.Dismissed;
|
|
119
|
+
case "sessionExpired":
|
|
120
|
+
case "org.reclaimprotocol.inapp_sdk.ReclaimVerification.ReclaimVerificationException.SessionExpired":
|
|
121
|
+
return ExceptionType.SessionExpired;
|
|
122
|
+
case "failed":
|
|
123
|
+
case "org.reclaimprotocol.inapp_sdk.ReclaimVerification.ReclaimVerificationException.Failed":
|
|
124
|
+
return ExceptionType.Failed;
|
|
125
|
+
}
|
|
126
|
+
return ExceptionType.Failed;
|
|
127
|
+
}
|
|
128
|
+
static fromError(error, sessionIdHint) {
|
|
129
|
+
if ('userInfo' in error) {
|
|
130
|
+
// From native, we send information about error in userInfo
|
|
131
|
+
let userInfo = error.userInfo;
|
|
132
|
+
if (userInfo) {
|
|
133
|
+
let type = ReclaimVerification.ReclaimVerificationException.fromTypeName(userInfo.errorType);
|
|
134
|
+
let maybeSessionId = userInfo?.sessionId;
|
|
135
|
+
return new ReclaimVerificationException(error.message, error, type, typeof maybeSessionId === 'string' && maybeSessionId ? maybeSessionId : sessionIdHint, userInfo?.didSubmitManualVerification ?? false, userInfo?.reason ?? "");
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return new ReclaimVerificationException(error.message, error, ReclaimVerification.ExceptionType.Failed, sessionIdHint, false, "");
|
|
139
|
+
}
|
|
140
|
+
static isReclaimVerificationException(error) {
|
|
141
|
+
return error instanceof ReclaimVerificationException;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
_ReclaimVerification.ReclaimVerificationException = ReclaimVerificationException;
|
|
145
|
+
class Platform {}
|
|
146
|
+
_ReclaimVerification.Platform = Platform;
|
|
147
|
+
})(ReclaimVerification || (exports.ReclaimVerification = ReclaimVerification = {}));
|
|
52
148
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_platform","require","ReclaimVerification","defaultPlatform","constructor","platform","PlatformImpl","startVerification","request","ping","setOverrides","overrides","clearAllOverrides","setVerificationOptions","options","exports","_ReclaimVerification","ReclaimResult","_ReclaimResult","isProof","value","asProofs","proofs","filter","Overrides","_Overrides","ExceptionType","ReclaimPlatformException","Error","message","innerError","reason","details","userInfo","isReclaimPlatformException","error","ReclaimVerificationException","type","sessionId","didSubmitManualVerification","fromTypeName","name","Cancelled","Dismissed","SessionExpired","Failed","fromError","sessionIdHint","errorType","maybeSessionId","isReclaimVerificationException","Platform"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;AACA,IAAAA,SAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,mBAAmB,CAAC;EAG/B,OAAeC,eAAe,GAAwC,IAAI;EAEnEC,WAAWA,CAACC,QAAuC,EAAE;IAC1D,IAAIA,QAAQ,EAAE;MACZ,IAAI,CAACA,QAAQ,GAAGA,QAAQ;IAC1B,CAAC,MAAM;MACL,IAAIH,mBAAmB,CAACC,eAAe,IAAI,IAAI,EAAE;QAC/CD,mBAAmB,CAACC,eAAe,GAAG,IAAIG,sBAAY,CAAC,CAAC;MAC1D;MACA,IAAI,CAACD,QAAQ,GAAGH,mBAAmB,CAACC,eAAe;IACrD;EACF;EAEA,MAAaI,iBAAiBA,CAACC,OAAoC,EAAyC;IAC1G,OAAO,IAAI,CAACH,QAAQ,CAACE,iBAAiB,CAACC,OAAO,CAAC;EACjD;EAEA,MAAaC,IAAIA,CAAA,EAAqB;IACpC,OAAO,IAAI,CAACJ,QAAQ,CAACI,IAAI,CAAC,CAAC;EAC7B;EAEOC,YAAYA,CAACC,SAA6C,EAAE;IACjE,OAAO,IAAI,CAACN,QAAQ,CAACK,YAAY,CAACC,SAAS,CAAC;EAC9C;EAEOC,iBAAiBA,CAAA,EAAG;IACzB,OAAO,IAAI,CAACP,QAAQ,CAACO,iBAAiB,CAAC,CAAC;EAC1C;EAEOC,sBAAsBA,CAACC,OAAwD,EAAE;IACtF,OAAO,IAAI,CAACT,QAAQ,CAAC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AAIA,QAAQ,EAAE;UACZ,IAAII,IAAI,GAAGnC,mBAAmB,CAACkC,4BAA4B,CAACI,YAAY,CAACP,QAAQ,CAACe,SAAS,CAAC;UAC5F,IAAIC,cAAc,GAAGhB,QAAQ,EAAEK,SAAS;UACxC,OAAO,IAAIF,4BAA4B,CACrCD,KAAK,CAACN,OAAO,EACbM,KAAK,EACLE,IAAI,EACH,OAAOY,cAAc,KAAK,QAAQ,IAAIA,cAAc,GACjDA,cAAc,GAAGF,aAAa,EAClCd,QAAQ,EAAEM,2BAA2B,IAAI,KAAK,EAC9CN,QAAQ,EAAEF,MAAM,IAAI,EACtB,CAAC;QACH;MACF;MACA,OAAO,IAAIK,4BAA4B,CACrCD,KAAK,CAACN,OAAO,EACbM,KAAK,EACLjC,mBAAmB,CAACwB,aAAa,CAACmB,MAAM,EACxCE,aAAa,EACb,KAAK,EACL,EACF,CAAC;IACH;IAEA,OAAOG,8BAA8BA,CAACf,KAAY,EAAyC;MACzF,OAAOA,KAAK,YAAYC,4BAA4B;IACtD;EACF;EAACpB,oBAAA,CAAAoB,4BAAA,GAAAA,4BAAA;EAEM,MAAee,QAAQ,CAAC;EAY9BnC,oBAAA,CAAAmC,QAAA,GAAAA,QAAA;AAAA,GA/NcjD,mBAAmB,KAAAa,OAAA,CAAAb,mBAAA,GAAnBA,mBAAmB","ignoreList":[]}
|
|
@@ -3,118 +3,24 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.PlatformImpl = void 0;
|
|
7
7
|
var _NativeInappRnSdk = _interopRequireDefault(require("./specs/NativeInappRnSdk.js"));
|
|
8
|
-
var
|
|
8
|
+
var _index = require("./index.js");
|
|
9
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
-
|
|
11
|
-
* This namespace provides types involved in initiating and managing the verification process
|
|
12
|
-
* for proving claims about user data through various providers.
|
|
13
|
-
*/
|
|
14
|
-
let ReclaimVerificationApi = exports.ReclaimVerificationApi = void 0;
|
|
15
|
-
(function (_ReclaimVerificationApi) {
|
|
16
|
-
/**
|
|
17
|
-
* Represents user's session information for a verification attempt.
|
|
18
|
-
* This data class contains the necessary data to identify and validate a verification session.
|
|
19
|
-
*/
|
|
20
|
-
/**
|
|
21
|
-
* Represents a request for a verification attempt.
|
|
22
|
-
*
|
|
23
|
-
* You can create a request using the [ReclaimVerification.Request] constructor or the [ReclaimVerification.Request.fromManifestMetaData] factory method.
|
|
24
|
-
*/
|
|
25
|
-
/**
|
|
26
|
-
* Contains the proof and response data after verification
|
|
27
|
-
*/
|
|
28
|
-
let Overrides;
|
|
29
|
-
(function (_Overrides) {
|
|
30
|
-
;
|
|
31
|
-
})(Overrides || (Overrides = _ReclaimVerificationApi.Overrides || (_ReclaimVerificationApi.Overrides = {})));
|
|
32
|
-
let ExceptionType = /*#__PURE__*/function (ExceptionType) {
|
|
33
|
-
ExceptionType["Cancelled"] = "Cancelled";
|
|
34
|
-
ExceptionType["Dismissed"] = "Dismissed";
|
|
35
|
-
ExceptionType["SessionExpired"] = "SessionExpired";
|
|
36
|
-
ExceptionType["Failed"] = "Failed";
|
|
37
|
-
return ExceptionType;
|
|
38
|
-
}({});
|
|
39
|
-
_ReclaimVerificationApi.ExceptionType = ExceptionType;
|
|
40
|
-
class ReclaimPlatformException extends Error {
|
|
41
|
-
constructor(message, innerError) {
|
|
42
|
-
super(message);
|
|
43
|
-
this.innerError = innerError;
|
|
44
|
-
this.reason = innerError.message;
|
|
45
|
-
if ('userInfo' in innerError) {
|
|
46
|
-
const details = innerError.userInfo;
|
|
47
|
-
this.details = details;
|
|
48
|
-
if ('message' in details) {
|
|
49
|
-
this.reason = details.message || this.reason;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
static isReclaimPlatformException(error) {
|
|
54
|
-
return error instanceof ReclaimPlatformException;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
_ReclaimVerificationApi.ReclaimPlatformException = ReclaimPlatformException;
|
|
58
|
-
class ReclaimVerificationException extends Error {
|
|
59
|
-
constructor(message, innerError, type, sessionId, didSubmitManualVerification, reason) {
|
|
60
|
-
super(message);
|
|
61
|
-
this.innerError = innerError;
|
|
62
|
-
this.type = type;
|
|
63
|
-
this.sessionId = sessionId;
|
|
64
|
-
this.didSubmitManualVerification = didSubmitManualVerification;
|
|
65
|
-
this.reason = reason;
|
|
66
|
-
}
|
|
67
|
-
static fromTypeName(name) {
|
|
68
|
-
switch (name) {
|
|
69
|
-
case "cancelled":
|
|
70
|
-
case "org.reclaimprotocol.inapp_sdk.ReclaimVerification.ReclaimVerificationException.Cancelled":
|
|
71
|
-
return ExceptionType.Cancelled;
|
|
72
|
-
case "dismissed":
|
|
73
|
-
case "org.reclaimprotocol.inapp_sdk.ReclaimVerification.ReclaimVerificationException.Dismissed":
|
|
74
|
-
return ExceptionType.Dismissed;
|
|
75
|
-
case "sessionExpired":
|
|
76
|
-
case "org.reclaimprotocol.inapp_sdk.ReclaimVerification.ReclaimVerificationException.SessionExpired":
|
|
77
|
-
return ExceptionType.SessionExpired;
|
|
78
|
-
case "failed":
|
|
79
|
-
case "org.reclaimprotocol.inapp_sdk.ReclaimVerification.ReclaimVerificationException.Failed":
|
|
80
|
-
return ExceptionType.Failed;
|
|
81
|
-
}
|
|
82
|
-
return ExceptionType.Failed;
|
|
83
|
-
}
|
|
84
|
-
static fromError(error, sessionIdHint) {
|
|
85
|
-
if ('userInfo' in error) {
|
|
86
|
-
// From native, we send information about error in userInfo
|
|
87
|
-
let userInfo = error.userInfo;
|
|
88
|
-
if (userInfo) {
|
|
89
|
-
let type = ReclaimVerificationApi.ReclaimVerificationException.fromTypeName(userInfo.errorType);
|
|
90
|
-
let maybeSessionId = userInfo?.sessionId;
|
|
91
|
-
return new ReclaimVerificationException(error.message, error, type, typeof maybeSessionId === 'string' && maybeSessionId ? maybeSessionId : sessionIdHint, userInfo?.didSubmitManualVerification ?? false, userInfo?.reason ?? "");
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return new ReclaimVerificationException(error.message, error, ReclaimVerificationApi.ExceptionType.Failed, sessionIdHint, false, "");
|
|
95
|
-
}
|
|
96
|
-
static isReclaimVerificationException(error) {
|
|
97
|
-
return error instanceof ReclaimVerificationException;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
_ReclaimVerificationApi.ReclaimVerificationException = ReclaimVerificationException;
|
|
101
|
-
})(ReclaimVerificationApi || (exports.ReclaimVerificationApi = ReclaimVerificationApi = {}));
|
|
102
|
-
class ReclaimVerificationPlatformChannel {}
|
|
103
|
-
exports.ReclaimVerificationPlatformChannel = ReclaimVerificationPlatformChannel;
|
|
104
|
-
class ReclaimVerificationPlatformChannelImpl extends ReclaimVerificationPlatformChannel {
|
|
10
|
+
class PlatformImpl extends _index.ReclaimVerification.Platform {
|
|
105
11
|
async startVerification(request) {
|
|
106
12
|
try {
|
|
107
13
|
const response = await _NativeInappRnSdk.default.startVerification(request);
|
|
108
14
|
return {
|
|
109
15
|
...response,
|
|
110
|
-
proofs:
|
|
16
|
+
proofs: _index.ReclaimVerification.ReclaimResult.asProofs(response.proofs)
|
|
111
17
|
};
|
|
112
18
|
} catch (error) {
|
|
113
19
|
console.info({
|
|
114
20
|
error
|
|
115
21
|
});
|
|
116
22
|
if (error instanceof Error) {
|
|
117
|
-
throw
|
|
23
|
+
throw _index.ReclaimVerification.ReclaimVerificationException.fromError(error, request.session?.sessionId ?? "");
|
|
118
24
|
}
|
|
119
25
|
throw error;
|
|
120
26
|
}
|
|
@@ -124,14 +30,14 @@ class ReclaimVerificationPlatformChannelImpl extends ReclaimVerificationPlatform
|
|
|
124
30
|
const response = await _NativeInappRnSdk.default.startVerificationFromUrl(requestUrl);
|
|
125
31
|
return {
|
|
126
32
|
...response,
|
|
127
|
-
proofs:
|
|
33
|
+
proofs: _index.ReclaimVerification.ReclaimResult.asProofs(response.proofs)
|
|
128
34
|
};
|
|
129
35
|
} catch (error) {
|
|
130
36
|
console.info({
|
|
131
37
|
error
|
|
132
38
|
});
|
|
133
39
|
if (error instanceof Error) {
|
|
134
|
-
throw
|
|
40
|
+
throw _index.ReclaimVerification.ReclaimVerificationException.fromError(error, "");
|
|
135
41
|
}
|
|
136
42
|
throw error;
|
|
137
43
|
}
|
|
@@ -179,10 +85,10 @@ class ReclaimVerificationPlatformChannelImpl extends ReclaimVerificationPlatform
|
|
|
179
85
|
let providerRequestSubscription = _NativeInappRnSdk.default.onProviderInformationRequest(async event => {
|
|
180
86
|
try {
|
|
181
87
|
let result = await providerCallback(event);
|
|
182
|
-
_NativeInappRnSdk.default.
|
|
88
|
+
_NativeInappRnSdk.default.replyWithString(event.replyId, result);
|
|
183
89
|
} catch (error) {
|
|
184
90
|
console.error(error);
|
|
185
|
-
_NativeInappRnSdk.default.
|
|
91
|
+
_NativeInappRnSdk.default.replyWithString(event.replyId, "");
|
|
186
92
|
}
|
|
187
93
|
});
|
|
188
94
|
const cancel = () => {
|
|
@@ -256,7 +162,7 @@ class ReclaimVerificationPlatformChannelImpl extends ReclaimVerificationPlatform
|
|
|
256
162
|
capabilityAccessToken
|
|
257
163
|
});
|
|
258
164
|
} catch (error) {
|
|
259
|
-
throw new
|
|
165
|
+
throw new _index.ReclaimVerification.ReclaimPlatformException("Failed to set overrides", error);
|
|
260
166
|
}
|
|
261
167
|
}
|
|
262
168
|
async clearAllOverrides() {
|
|
@@ -265,6 +171,42 @@ class ReclaimVerificationPlatformChannelImpl extends ReclaimVerificationPlatform
|
|
|
265
171
|
this.disposeSessionManagement();
|
|
266
172
|
return _NativeInappRnSdk.default.clearAllOverrides();
|
|
267
173
|
}
|
|
174
|
+
previousAttestorAuthRequestCancelCallback = null;
|
|
175
|
+
disposeAttestorAuthRequestListener() {
|
|
176
|
+
let callback = this.previousAttestorAuthRequestCancelCallback;
|
|
177
|
+
if (callback != null && callback != undefined) {
|
|
178
|
+
callback();
|
|
179
|
+
}
|
|
180
|
+
this.previousAttestorAuthRequestCancelCallback = null;
|
|
181
|
+
}
|
|
182
|
+
async setVerificationOptions(options) {
|
|
183
|
+
let args = null;
|
|
184
|
+
if (options) {
|
|
185
|
+
let canUseAttestorAuthenticationRequest = options.fetchAttestorAuthenticationRequest != null;
|
|
186
|
+
args = {
|
|
187
|
+
canDeleteCookiesBeforeVerificationStarts: options.canDeleteCookiesBeforeVerificationStarts,
|
|
188
|
+
canUseAttestorAuthenticationRequest: canUseAttestorAuthenticationRequest
|
|
189
|
+
};
|
|
190
|
+
if (canUseAttestorAuthenticationRequest) {
|
|
191
|
+
this.disposeAttestorAuthRequestListener();
|
|
192
|
+
let attestorAuthRequestSubscription = _NativeInappRnSdk.default.onReclaimAttestorAuthRequest(async event => {
|
|
193
|
+
let result = await options.fetchAttestorAuthenticationRequest(event.reclaimHttpProviderJsonString);
|
|
194
|
+
_NativeInappRnSdk.default.replyWithString(event.replyId, result);
|
|
195
|
+
});
|
|
196
|
+
const cancel = () => {
|
|
197
|
+
attestorAuthRequestSubscription.remove();
|
|
198
|
+
};
|
|
199
|
+
this.previousAttestorAuthRequestCancelCallback = cancel;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
try {
|
|
203
|
+
return await _NativeInappRnSdk.default.setVerificationOptions({
|
|
204
|
+
options: args
|
|
205
|
+
});
|
|
206
|
+
} catch (error) {
|
|
207
|
+
throw new _index.ReclaimVerification.ReclaimPlatformException("Failed to set verification options", error);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
268
210
|
}
|
|
269
|
-
exports.
|
|
270
|
-
//# sourceMappingURL=
|
|
211
|
+
exports.PlatformImpl = PlatformImpl;
|
|
212
|
+
//# sourceMappingURL=platform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_NativeInappRnSdk","_interopRequireDefault","require","_index","e","__esModule","default","PlatformImpl","ReclaimVerification","Platform","startVerification","request","response","NativeReclaimInappModule","proofs","ReclaimResult","asProofs","error","console","info","Error","ReclaimVerificationException","fromError","session","sessionId","startVerificationFromUrl","requestUrl","ping","previousSessionManagementCancelCallback","disposeSessionManagement","callback","undefined","previousLogSubscription","disposeLogListener","remove","previousProviderRequestCancelCallback","disposeProviderRequestListener","setOverrides","provider","featureOptions","logConsumer","sessionManagement","appInfo","capabilityAccessToken","providerCallback","providerOverride","url","jsonString","canFetchProviderInformationFromHost","providerRequestSubscription","onProviderInformationRequest","event","result","replyWithString","replyId","cancel","onLogsListener","onLogs","logConsumerRequest","enableLogHandler","canSdkCollectTelemetry","canSdkPrintLogs","arg","sessionManagementRequest","enableSdkSessionManagement","sessionCreateSubscription","onSessionCreateRequest","reply","sessionUpdateSubscription","onSessionUpdateRequest","sessionLogsSubscription","onSessionLogs","onLog","ReclaimPlatformException","clearAllOverrides","previousAttestorAuthRequestCancelCallback","disposeAttestorAuthRequestListener","setVerificationOptions","options","args","canUseAttestorAuthenticationRequest","fetchAttestorAuthenticationRequest","canDeleteCookiesBeforeVerificationStarts","attestorAuthRequestSubscription","onReclaimAttestorAuthRequest","reclaimHttpProviderJsonString","exports"],"sourceRoot":"../../src","sources":["platform.ts"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAA8C,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEvC,MAAMG,YAAY,SAASC,0BAAmB,CAACC,QAAQ,CAAC;EAC3D,MAAeC,iBAAiBA,CAACC,OAAoC,EAAyC;IAC1G,IAAI;MACA,MAAMC,QAAQ,GAAG,MAAMC,yBAAwB,CAACH,iBAAiB,CAACC,OAAO,CAAC;MAC1E,OAAO;QACH,GAAGC,QAAQ;QACXE,MAAM,EAAEN,0BAAmB,CAACO,aAAa,CAACC,QAAQ,CAACJ,QAAQ,CAACE,MAAM;MACtE,CAAC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BAAwB,CAACgE,sBAAsB,CAAC;QACzDC,OAAO,EAAEC;MACb,CAAC,CAAC;IACN,CAAC,CAAC,OAAO9D,KAAK,EAAE;MACZ,MAAM,IAAIT,0BAAmB,CAACiE,wBAAwB,CAAC,oCAAoC,EAAExD,KAAc,CAAC;IAChH;EACJ;AACJ;AAACqE,OAAA,CAAA/E,YAAA,GAAAA,YAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../../src","sources":["specs/NativeInappRnSdk.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AA0BA;AACA;AACA;AACA;AACA;AA+EA;AACA;AACA;AAwBA;AACA;AACA;AAkEA;AACA;AACA;AAgDA;AAAA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../../src","sources":["specs/NativeInappRnSdk.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AA0BA;AACA;AACA;AACA;AACA;AA+EA;AACA;AACA;AAwBA;AACA;AACA;AAkEA;AACA;AACA;AAgDA;AAAA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAwGeC,gCAAmB,CAACC,YAAY,CAAO,YAAY,CAAC","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -1,30 +1,144 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { PlatformImpl } from "./platform.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* [ReclaimVerification] is the main class for interacting with the Reclaim verification system.
|
|
7
|
+
* It provides methods to start verification processes, manage platform configurations,
|
|
8
|
+
* and handle verification options.
|
|
9
|
+
*
|
|
10
|
+
* The class can be instantiated with a custom platform implementation, or will use
|
|
11
|
+
* the default [PlatformImpl] if none is provided.
|
|
12
|
+
*/
|
|
5
13
|
export class ReclaimVerification {
|
|
6
|
-
static
|
|
7
|
-
constructor(
|
|
8
|
-
if (
|
|
9
|
-
this.
|
|
14
|
+
static defaultPlatform = null;
|
|
15
|
+
constructor(platform) {
|
|
16
|
+
if (platform) {
|
|
17
|
+
this.platform = platform;
|
|
10
18
|
} else {
|
|
11
|
-
if (ReclaimVerification.
|
|
12
|
-
ReclaimVerification.
|
|
19
|
+
if (ReclaimVerification.defaultPlatform == null) {
|
|
20
|
+
ReclaimVerification.defaultPlatform = new PlatformImpl();
|
|
13
21
|
}
|
|
14
|
-
this.
|
|
22
|
+
this.platform = ReclaimVerification.defaultPlatform;
|
|
15
23
|
}
|
|
16
24
|
}
|
|
17
25
|
async startVerification(request) {
|
|
18
|
-
return this.
|
|
26
|
+
return this.platform.startVerification(request);
|
|
19
27
|
}
|
|
20
28
|
async ping() {
|
|
21
|
-
return this.
|
|
29
|
+
return this.platform.ping();
|
|
22
30
|
}
|
|
23
31
|
setOverrides(overrides) {
|
|
24
|
-
return this.
|
|
32
|
+
return this.platform.setOverrides(overrides);
|
|
25
33
|
}
|
|
26
34
|
clearAllOverrides() {
|
|
27
|
-
return this.
|
|
35
|
+
return this.platform.clearAllOverrides();
|
|
36
|
+
}
|
|
37
|
+
setVerificationOptions(options) {
|
|
38
|
+
return this.platform.setVerificationOptions(options);
|
|
28
39
|
}
|
|
29
40
|
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* This namespace provides types involved in initiating and managing the verification process
|
|
44
|
+
* for proving claims about user data through various providers.
|
|
45
|
+
*/
|
|
46
|
+
(function (_ReclaimVerification) {
|
|
47
|
+
/**
|
|
48
|
+
* Represents user's session information for a verification attempt.
|
|
49
|
+
* This data class contains the necessary data to identify and validate a verification session.
|
|
50
|
+
*/
|
|
51
|
+
/**
|
|
52
|
+
* Represents a request for a verification attempt.
|
|
53
|
+
*
|
|
54
|
+
* You can create a request using the [ReclaimVerification.Request] constructor or the [ReclaimVerification.Request.fromManifestMetaData] factory method.
|
|
55
|
+
*/
|
|
56
|
+
/**
|
|
57
|
+
* Contains the proof and response data after verification
|
|
58
|
+
*/
|
|
59
|
+
let ReclaimResult;
|
|
60
|
+
(function (_ReclaimResult) {
|
|
61
|
+
const isProof = _ReclaimResult.isProof = value => {
|
|
62
|
+
return typeof value === 'object' && value !== null && 'identifier' in value && 'signatures' in value && 'witnesses' in value;
|
|
63
|
+
};
|
|
64
|
+
const asProofs = _ReclaimResult.asProofs = proofs => {
|
|
65
|
+
return proofs.filter(isProof);
|
|
66
|
+
};
|
|
67
|
+
})(ReclaimResult || (ReclaimResult = _ReclaimVerification.ReclaimResult || (_ReclaimVerification.ReclaimResult = {})));
|
|
68
|
+
let Overrides;
|
|
69
|
+
(function (_Overrides) {
|
|
70
|
+
;
|
|
71
|
+
})(Overrides || (Overrides = _ReclaimVerification.Overrides || (_ReclaimVerification.Overrides = {})));
|
|
72
|
+
let ExceptionType = /*#__PURE__*/function (ExceptionType) {
|
|
73
|
+
ExceptionType["Cancelled"] = "Cancelled";
|
|
74
|
+
ExceptionType["Dismissed"] = "Dismissed";
|
|
75
|
+
ExceptionType["SessionExpired"] = "SessionExpired";
|
|
76
|
+
ExceptionType["Failed"] = "Failed";
|
|
77
|
+
return ExceptionType;
|
|
78
|
+
}({});
|
|
79
|
+
_ReclaimVerification.ExceptionType = ExceptionType;
|
|
80
|
+
class ReclaimPlatformException extends Error {
|
|
81
|
+
constructor(message, innerError) {
|
|
82
|
+
super(message);
|
|
83
|
+
this.innerError = innerError;
|
|
84
|
+
this.reason = innerError.message;
|
|
85
|
+
if ('userInfo' in innerError) {
|
|
86
|
+
const details = innerError.userInfo;
|
|
87
|
+
this.details = details;
|
|
88
|
+
if ('message' in details) {
|
|
89
|
+
this.reason = details.message || this.reason;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
static isReclaimPlatformException(error) {
|
|
94
|
+
return error instanceof ReclaimPlatformException;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
_ReclaimVerification.ReclaimPlatformException = ReclaimPlatformException;
|
|
98
|
+
class ReclaimVerificationException extends Error {
|
|
99
|
+
constructor(message, innerError, type, sessionId, didSubmitManualVerification, reason) {
|
|
100
|
+
super(message);
|
|
101
|
+
this.innerError = innerError;
|
|
102
|
+
this.type = type;
|
|
103
|
+
this.sessionId = sessionId;
|
|
104
|
+
this.didSubmitManualVerification = didSubmitManualVerification;
|
|
105
|
+
this.reason = reason;
|
|
106
|
+
}
|
|
107
|
+
static fromTypeName(name) {
|
|
108
|
+
switch (name) {
|
|
109
|
+
case "cancelled":
|
|
110
|
+
case "org.reclaimprotocol.inapp_sdk.ReclaimVerification.ReclaimVerificationException.Cancelled":
|
|
111
|
+
return ExceptionType.Cancelled;
|
|
112
|
+
case "dismissed":
|
|
113
|
+
case "org.reclaimprotocol.inapp_sdk.ReclaimVerification.ReclaimVerificationException.Dismissed":
|
|
114
|
+
return ExceptionType.Dismissed;
|
|
115
|
+
case "sessionExpired":
|
|
116
|
+
case "org.reclaimprotocol.inapp_sdk.ReclaimVerification.ReclaimVerificationException.SessionExpired":
|
|
117
|
+
return ExceptionType.SessionExpired;
|
|
118
|
+
case "failed":
|
|
119
|
+
case "org.reclaimprotocol.inapp_sdk.ReclaimVerification.ReclaimVerificationException.Failed":
|
|
120
|
+
return ExceptionType.Failed;
|
|
121
|
+
}
|
|
122
|
+
return ExceptionType.Failed;
|
|
123
|
+
}
|
|
124
|
+
static fromError(error, sessionIdHint) {
|
|
125
|
+
if ('userInfo' in error) {
|
|
126
|
+
// From native, we send information about error in userInfo
|
|
127
|
+
let userInfo = error.userInfo;
|
|
128
|
+
if (userInfo) {
|
|
129
|
+
let type = ReclaimVerification.ReclaimVerificationException.fromTypeName(userInfo.errorType);
|
|
130
|
+
let maybeSessionId = userInfo?.sessionId;
|
|
131
|
+
return new ReclaimVerificationException(error.message, error, type, typeof maybeSessionId === 'string' && maybeSessionId ? maybeSessionId : sessionIdHint, userInfo?.didSubmitManualVerification ?? false, userInfo?.reason ?? "");
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return new ReclaimVerificationException(error.message, error, ReclaimVerification.ExceptionType.Failed, sessionIdHint, false, "");
|
|
135
|
+
}
|
|
136
|
+
static isReclaimVerificationException(error) {
|
|
137
|
+
return error instanceof ReclaimVerificationException;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
_ReclaimVerification.ReclaimVerificationException = ReclaimVerificationException;
|
|
141
|
+
class Platform {}
|
|
142
|
+
_ReclaimVerification.Platform = Platform;
|
|
143
|
+
})(ReclaimVerification || (ReclaimVerification = {}));
|
|
30
144
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["PlatformImpl","ReclaimVerification","defaultPlatform","constructor","platform","startVerification","request","ping","setOverrides","overrides","clearAllOverrides","setVerificationOptions","options","_ReclaimVerification","ReclaimResult","_ReclaimResult","isProof","value","asProofs","proofs","filter","Overrides","_Overrides","ExceptionType","ReclaimPlatformException","Error","message","innerError","reason","details","userInfo","isReclaimPlatformException","error","ReclaimVerificationException","type","sessionId","didSubmitManualVerification","fromTypeName","name","Cancelled","Dismissed","SessionExpired","Failed","fromError","sessionIdHint","errorType","maybeSessionId","isReclaimVerificationException","Platform"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AACA,SAASA,YAAY,QAAQ,eAAY;;AAEzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,CAAC;EAG/B,OAAeC,eAAe,GAAwC,IAAI;EAEnEC,WAAWA,CAACC,QAAuC,EAAE;IAC1D,IAAIA,QAAQ,EAAE;MACZ,IAAI,CAACA,QAAQ,GAAGA,QAAQ;IAC1B,CAAC,MAAM;MACL,IAAIH,mBAAmB,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