@capgo/capacitor-stripe-identity 8.0.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.
Files changed (34) hide show
  1. package/CapgoCapacitorStripeIdentity.podspec +18 -0
  2. package/LICENSE +373 -0
  3. package/Package.swift +30 -0
  4. package/README.md +267 -0
  5. package/android/build.gradle +75 -0
  6. package/android/src/main/AndroidManifest.xml +2 -0
  7. package/android/src/main/java/app/capgo/stripe/identity/IdentityVerificationSheetEvent.kt +11 -0
  8. package/android/src/main/java/app/capgo/stripe/identity/StripeIdentity.kt +103 -0
  9. package/android/src/main/java/app/capgo/stripe/identity/StripeIdentityPlugin.kt +69 -0
  10. package/android/src/main/java/app/capgo/stripe/identity/models/Executor.kt +22 -0
  11. package/android/src/main/res/.gitkeep +0 -0
  12. package/dist/docs.json +317 -0
  13. package/dist/esm/definitions.d.ts +20 -0
  14. package/dist/esm/definitions.js +2 -0
  15. package/dist/esm/definitions.js.map +1 -0
  16. package/dist/esm/events.enum.d.ts +9 -0
  17. package/dist/esm/events.enum.js +10 -0
  18. package/dist/esm/events.enum.js.map +1 -0
  19. package/dist/esm/index.d.ts +4 -0
  20. package/dist/esm/index.js +7 -0
  21. package/dist/esm/index.js.map +1 -0
  22. package/dist/esm/web.d.ts +20 -0
  23. package/dist/esm/web.js +39 -0
  24. package/dist/esm/web.js.map +1 -0
  25. package/dist/plugin.cjs.js +62 -0
  26. package/dist/plugin.cjs.js.map +1 -0
  27. package/dist/plugin.js +64 -0
  28. package/dist/plugin.js.map +1 -0
  29. package/ios/Sources/StripeIdentityPlugin/IdentityVerificationSheetEvents.swift +8 -0
  30. package/ios/Sources/StripeIdentityPlugin/Info.plist +24 -0
  31. package/ios/Sources/StripeIdentityPlugin/StripeIdentity.swift +86 -0
  32. package/ios/Sources/StripeIdentityPlugin/StripeIdentityPlugin.swift +51 -0
  33. package/ios/Tests/StripeIdentityPluginTests/StripeIdentityPluginTests.swift +15 -0
  34. package/package.json +95 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,cAAc,GAAG,cAAc,CAAuB,gBAAgB,EAAE;IAC5E,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;CAClE,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { StripeIdentityPlugin } from './definitions';\n\nconst StripeIdentity = registerPlugin<StripeIdentityPlugin>('StripeIdentity', {\n web: () => import('./web').then((m) => new m.StripeIdentityWeb()),\n});\n\nexport * from './definitions';\nexport { StripeIdentity };\n"]}
@@ -0,0 +1,20 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ import type { StripeIdentityPlugin } from './definitions';
3
+ export interface InitializeIdentityVerificationSheetOption {
4
+ publishableKey: string;
5
+ }
6
+ export interface CreateIdentityVerificationSheetOption {
7
+ verificationId: string;
8
+ ephemeralKeySecret: string;
9
+ /**
10
+ * This client secret is used only for the web platform.
11
+ */
12
+ clientSecret?: string;
13
+ }
14
+ export declare class StripeIdentityWeb extends WebPlugin implements StripeIdentityPlugin {
15
+ private stripe;
16
+ private clientSecret;
17
+ initialize(options: InitializeIdentityVerificationSheetOption): Promise<void>;
18
+ create(options: CreateIdentityVerificationSheetOption): Promise<void>;
19
+ present(): Promise<void>;
20
+ }
@@ -0,0 +1,39 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ import { loadStripe } from '@stripe/stripe-js';
3
+ import { IdentityVerificationSheetEventsEnum } from './definitions';
4
+ export class StripeIdentityWeb extends WebPlugin {
5
+ async initialize(options) {
6
+ this.stripe = await loadStripe(options.publishableKey);
7
+ }
8
+ async create(options) {
9
+ this.clientSecret = options.clientSecret;
10
+ this.notifyListeners(IdentityVerificationSheetEventsEnum.Loaded, null);
11
+ }
12
+ async present() {
13
+ if (!this.stripe) {
14
+ throw new Error('Stripe is not initialized.');
15
+ }
16
+ if (!this.clientSecret) {
17
+ throw new Error('clientSecret is not set.');
18
+ }
19
+ const { error } = await this.stripe.verifyIdentity(this.clientSecret);
20
+ if (error) {
21
+ const { code } = error;
22
+ if (code === 'session_cancelled') {
23
+ this.notifyListeners(IdentityVerificationSheetEventsEnum.VerificationResult, {
24
+ result: IdentityVerificationSheetEventsEnum.Canceled,
25
+ });
26
+ return;
27
+ }
28
+ this.notifyListeners(IdentityVerificationSheetEventsEnum.VerificationResult, {
29
+ result: IdentityVerificationSheetEventsEnum.Failed,
30
+ error,
31
+ });
32
+ return;
33
+ }
34
+ this.notifyListeners(IdentityVerificationSheetEventsEnum.VerificationResult, {
35
+ result: IdentityVerificationSheetEventsEnum.Completed,
36
+ });
37
+ }
38
+ }
39
+ //# sourceMappingURL=web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,EAAE,mCAAmC,EAAE,MAAM,eAAe,CAAC;AAgBpE,MAAM,OAAO,iBAAkB,SAAQ,SAAS;IAG9C,KAAK,CAAC,UAAU,CAAC,OAAkD;QACjE,IAAI,CAAC,MAAM,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IACzD,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,OAA8C;QACzD,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;QACzC,IAAI,CAAC,eAAe,CAAC,mCAAmC,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACzE,CAAC;IACD,KAAK,CAAC,OAAO;QACX,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAChD,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC9C,CAAC;QACD,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACtE,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;YACvB,IAAI,IAAI,KAAK,mBAAmB,EAAE,CAAC;gBACjC,IAAI,CAAC,eAAe,CAAC,mCAAmC,CAAC,kBAAkB,EAAE;oBAC3E,MAAM,EAAE,mCAAmC,CAAC,QAAQ;iBACrD,CAAC,CAAC;gBACH,OAAO;YACT,CAAC;YACD,IAAI,CAAC,eAAe,CAAC,mCAAmC,CAAC,kBAAkB,EAAE;gBAC3E,MAAM,EAAE,mCAAmC,CAAC,MAAM;gBAClD,KAAK;aACN,CAAC,CAAC;YACH,OAAO;QACT,CAAC;QACD,IAAI,CAAC,eAAe,CAAC,mCAAmC,CAAC,kBAAkB,EAAE;YAC3E,MAAM,EAAE,mCAAmC,CAAC,SAAS;SACtD,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\nimport type { Stripe } from '@stripe/stripe-js';\nimport { loadStripe } from '@stripe/stripe-js';\n\nimport type { StripeIdentityPlugin } from './definitions';\nimport { IdentityVerificationSheetEventsEnum } from './definitions';\n\nexport interface InitializeIdentityVerificationSheetOption {\n publishableKey: string;\n}\n\nexport interface CreateIdentityVerificationSheetOption {\n verificationId: string;\n ephemeralKeySecret: string;\n\n /**\n * This client secret is used only for the web platform.\n */\n clientSecret?: string;\n}\n\nexport class StripeIdentityWeb extends WebPlugin implements StripeIdentityPlugin {\n private stripe: Stripe | null | undefined;\n private clientSecret: string | undefined;\n async initialize(options: InitializeIdentityVerificationSheetOption): Promise<void> {\n this.stripe = await loadStripe(options.publishableKey);\n }\n async create(options: CreateIdentityVerificationSheetOption): Promise<void> {\n this.clientSecret = options.clientSecret;\n this.notifyListeners(IdentityVerificationSheetEventsEnum.Loaded, null);\n }\n async present(): Promise<void> {\n if (!this.stripe) {\n throw new Error('Stripe is not initialized.');\n }\n if (!this.clientSecret) {\n throw new Error('clientSecret is not set.');\n }\n const { error } = await this.stripe.verifyIdentity(this.clientSecret);\n if (error) {\n const { code } = error;\n if (code === 'session_cancelled') {\n this.notifyListeners(IdentityVerificationSheetEventsEnum.VerificationResult, {\n result: IdentityVerificationSheetEventsEnum.Canceled,\n });\n return;\n }\n this.notifyListeners(IdentityVerificationSheetEventsEnum.VerificationResult, {\n result: IdentityVerificationSheetEventsEnum.Failed,\n error,\n });\n return;\n }\n this.notifyListeners(IdentityVerificationSheetEventsEnum.VerificationResult, {\n result: IdentityVerificationSheetEventsEnum.Completed,\n });\n }\n}\n"]}
@@ -0,0 +1,62 @@
1
+ 'use strict';
2
+
3
+ var core = require('@capacitor/core');
4
+ var stripeJs = require('@stripe/stripe-js');
5
+
6
+ exports.IdentityVerificationSheetEventsEnum = void 0;
7
+ (function (IdentityVerificationSheetEventsEnum) {
8
+ IdentityVerificationSheetEventsEnum["Loaded"] = "identityVerificationSheetLoaded";
9
+ IdentityVerificationSheetEventsEnum["FailedToLoad"] = "identityVerificationSheetFailedToLoad";
10
+ IdentityVerificationSheetEventsEnum["Completed"] = "identityVerificationSheetCompleted";
11
+ IdentityVerificationSheetEventsEnum["Canceled"] = "identityVerificationSheetCanceled";
12
+ IdentityVerificationSheetEventsEnum["Failed"] = "identityVerificationSheetFailed";
13
+ IdentityVerificationSheetEventsEnum["VerificationResult"] = "identityVerificationResult";
14
+ })(exports.IdentityVerificationSheetEventsEnum || (exports.IdentityVerificationSheetEventsEnum = {}));
15
+
16
+ const StripeIdentity = core.registerPlugin('StripeIdentity', {
17
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.StripeIdentityWeb()),
18
+ });
19
+
20
+ class StripeIdentityWeb extends core.WebPlugin {
21
+ async initialize(options) {
22
+ this.stripe = await stripeJs.loadStripe(options.publishableKey);
23
+ }
24
+ async create(options) {
25
+ this.clientSecret = options.clientSecret;
26
+ this.notifyListeners(exports.IdentityVerificationSheetEventsEnum.Loaded, null);
27
+ }
28
+ async present() {
29
+ if (!this.stripe) {
30
+ throw new Error('Stripe is not initialized.');
31
+ }
32
+ if (!this.clientSecret) {
33
+ throw new Error('clientSecret is not set.');
34
+ }
35
+ const { error } = await this.stripe.verifyIdentity(this.clientSecret);
36
+ if (error) {
37
+ const { code } = error;
38
+ if (code === 'session_cancelled') {
39
+ this.notifyListeners(exports.IdentityVerificationSheetEventsEnum.VerificationResult, {
40
+ result: exports.IdentityVerificationSheetEventsEnum.Canceled,
41
+ });
42
+ return;
43
+ }
44
+ this.notifyListeners(exports.IdentityVerificationSheetEventsEnum.VerificationResult, {
45
+ result: exports.IdentityVerificationSheetEventsEnum.Failed,
46
+ error,
47
+ });
48
+ return;
49
+ }
50
+ this.notifyListeners(exports.IdentityVerificationSheetEventsEnum.VerificationResult, {
51
+ result: exports.IdentityVerificationSheetEventsEnum.Completed,
52
+ });
53
+ }
54
+ }
55
+
56
+ var web = /*#__PURE__*/Object.freeze({
57
+ __proto__: null,
58
+ StripeIdentityWeb: StripeIdentityWeb
59
+ });
60
+
61
+ exports.StripeIdentity = StripeIdentity;
62
+ //# sourceMappingURL=plugin.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/events.enum.js","esm/index.js","esm/web.js"],"sourcesContent":["export var IdentityVerificationSheetEventsEnum;\n(function (IdentityVerificationSheetEventsEnum) {\n IdentityVerificationSheetEventsEnum[\"Loaded\"] = \"identityVerificationSheetLoaded\";\n IdentityVerificationSheetEventsEnum[\"FailedToLoad\"] = \"identityVerificationSheetFailedToLoad\";\n IdentityVerificationSheetEventsEnum[\"Completed\"] = \"identityVerificationSheetCompleted\";\n IdentityVerificationSheetEventsEnum[\"Canceled\"] = \"identityVerificationSheetCanceled\";\n IdentityVerificationSheetEventsEnum[\"Failed\"] = \"identityVerificationSheetFailed\";\n IdentityVerificationSheetEventsEnum[\"VerificationResult\"] = \"identityVerificationResult\";\n})(IdentityVerificationSheetEventsEnum || (IdentityVerificationSheetEventsEnum = {}));\n//# sourceMappingURL=events.enum.js.map","import { registerPlugin } from '@capacitor/core';\nconst StripeIdentity = registerPlugin('StripeIdentity', {\n web: () => import('./web').then((m) => new m.StripeIdentityWeb()),\n});\nexport * from './definitions';\nexport { StripeIdentity };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nimport { loadStripe } from '@stripe/stripe-js';\nimport { IdentityVerificationSheetEventsEnum } from './definitions';\nexport class StripeIdentityWeb extends WebPlugin {\n async initialize(options) {\n this.stripe = await loadStripe(options.publishableKey);\n }\n async create(options) {\n this.clientSecret = options.clientSecret;\n this.notifyListeners(IdentityVerificationSheetEventsEnum.Loaded, null);\n }\n async present() {\n if (!this.stripe) {\n throw new Error('Stripe is not initialized.');\n }\n if (!this.clientSecret) {\n throw new Error('clientSecret is not set.');\n }\n const { error } = await this.stripe.verifyIdentity(this.clientSecret);\n if (error) {\n const { code } = error;\n if (code === 'session_cancelled') {\n this.notifyListeners(IdentityVerificationSheetEventsEnum.VerificationResult, {\n result: IdentityVerificationSheetEventsEnum.Canceled,\n });\n return;\n }\n this.notifyListeners(IdentityVerificationSheetEventsEnum.VerificationResult, {\n result: IdentityVerificationSheetEventsEnum.Failed,\n error,\n });\n return;\n }\n this.notifyListeners(IdentityVerificationSheetEventsEnum.VerificationResult, {\n result: IdentityVerificationSheetEventsEnum.Completed,\n });\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["IdentityVerificationSheetEventsEnum","registerPlugin","WebPlugin","loadStripe"],"mappings":";;;;;AAAWA;AACX,CAAC,UAAU,mCAAmC,EAAE;AAChD,IAAI,mCAAmC,CAAC,QAAQ,CAAC,GAAG,iCAAiC;AACrF,IAAI,mCAAmC,CAAC,cAAc,CAAC,GAAG,uCAAuC;AACjG,IAAI,mCAAmC,CAAC,WAAW,CAAC,GAAG,oCAAoC;AAC3F,IAAI,mCAAmC,CAAC,UAAU,CAAC,GAAG,mCAAmC;AACzF,IAAI,mCAAmC,CAAC,QAAQ,CAAC,GAAG,iCAAiC;AACrF,IAAI,mCAAmC,CAAC,oBAAoB,CAAC,GAAG,4BAA4B;AAC5F,CAAC,EAAEA,2CAAmC,KAAKA,2CAAmC,GAAG,EAAE,CAAC,CAAC;;ACPhF,MAAC,cAAc,GAAGC,mBAAc,CAAC,gBAAgB,EAAE;AACxD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;AACrE,CAAC;;ACAM,MAAM,iBAAiB,SAASC,cAAS,CAAC;AACjD,IAAI,MAAM,UAAU,CAAC,OAAO,EAAE;AAC9B,QAAQ,IAAI,CAAC,MAAM,GAAG,MAAMC,mBAAU,CAAC,OAAO,CAAC,cAAc,CAAC;AAC9D,IAAI;AACJ,IAAI,MAAM,MAAM,CAAC,OAAO,EAAE;AAC1B,QAAQ,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY;AAChD,QAAQ,IAAI,CAAC,eAAe,CAACH,2CAAmC,CAAC,MAAM,EAAE,IAAI,CAAC;AAC9E,IAAI;AACJ,IAAI,MAAM,OAAO,GAAG;AACpB,QAAQ,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;AAC1B,YAAY,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC;AACzD,QAAQ;AACR,QAAQ,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;AAChC,YAAY,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC;AACvD,QAAQ;AACR,QAAQ,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC;AAC7E,QAAQ,IAAI,KAAK,EAAE;AACnB,YAAY,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK;AAClC,YAAY,IAAI,IAAI,KAAK,mBAAmB,EAAE;AAC9C,gBAAgB,IAAI,CAAC,eAAe,CAACA,2CAAmC,CAAC,kBAAkB,EAAE;AAC7F,oBAAoB,MAAM,EAAEA,2CAAmC,CAAC,QAAQ;AACxE,iBAAiB,CAAC;AAClB,gBAAgB;AAChB,YAAY;AACZ,YAAY,IAAI,CAAC,eAAe,CAACA,2CAAmC,CAAC,kBAAkB,EAAE;AACzF,gBAAgB,MAAM,EAAEA,2CAAmC,CAAC,MAAM;AAClE,gBAAgB,KAAK;AACrB,aAAa,CAAC;AACd,YAAY;AACZ,QAAQ;AACR,QAAQ,IAAI,CAAC,eAAe,CAACA,2CAAmC,CAAC,kBAAkB,EAAE;AACrF,YAAY,MAAM,EAAEA,2CAAmC,CAAC,SAAS;AACjE,SAAS,CAAC;AACV,IAAI;AACJ;;;;;;;;;"}
package/dist/plugin.js ADDED
@@ -0,0 +1,64 @@
1
+ var capacitorStripe = (function (exports, core, stripeJs) {
2
+ 'use strict';
3
+
4
+ exports.IdentityVerificationSheetEventsEnum = void 0;
5
+ (function (IdentityVerificationSheetEventsEnum) {
6
+ IdentityVerificationSheetEventsEnum["Loaded"] = "identityVerificationSheetLoaded";
7
+ IdentityVerificationSheetEventsEnum["FailedToLoad"] = "identityVerificationSheetFailedToLoad";
8
+ IdentityVerificationSheetEventsEnum["Completed"] = "identityVerificationSheetCompleted";
9
+ IdentityVerificationSheetEventsEnum["Canceled"] = "identityVerificationSheetCanceled";
10
+ IdentityVerificationSheetEventsEnum["Failed"] = "identityVerificationSheetFailed";
11
+ IdentityVerificationSheetEventsEnum["VerificationResult"] = "identityVerificationResult";
12
+ })(exports.IdentityVerificationSheetEventsEnum || (exports.IdentityVerificationSheetEventsEnum = {}));
13
+
14
+ const StripeIdentity = core.registerPlugin('StripeIdentity', {
15
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.StripeIdentityWeb()),
16
+ });
17
+
18
+ class StripeIdentityWeb extends core.WebPlugin {
19
+ async initialize(options) {
20
+ this.stripe = await stripeJs.loadStripe(options.publishableKey);
21
+ }
22
+ async create(options) {
23
+ this.clientSecret = options.clientSecret;
24
+ this.notifyListeners(exports.IdentityVerificationSheetEventsEnum.Loaded, null);
25
+ }
26
+ async present() {
27
+ if (!this.stripe) {
28
+ throw new Error('Stripe is not initialized.');
29
+ }
30
+ if (!this.clientSecret) {
31
+ throw new Error('clientSecret is not set.');
32
+ }
33
+ const { error } = await this.stripe.verifyIdentity(this.clientSecret);
34
+ if (error) {
35
+ const { code } = error;
36
+ if (code === 'session_cancelled') {
37
+ this.notifyListeners(exports.IdentityVerificationSheetEventsEnum.VerificationResult, {
38
+ result: exports.IdentityVerificationSheetEventsEnum.Canceled,
39
+ });
40
+ return;
41
+ }
42
+ this.notifyListeners(exports.IdentityVerificationSheetEventsEnum.VerificationResult, {
43
+ result: exports.IdentityVerificationSheetEventsEnum.Failed,
44
+ error,
45
+ });
46
+ return;
47
+ }
48
+ this.notifyListeners(exports.IdentityVerificationSheetEventsEnum.VerificationResult, {
49
+ result: exports.IdentityVerificationSheetEventsEnum.Completed,
50
+ });
51
+ }
52
+ }
53
+
54
+ var web = /*#__PURE__*/Object.freeze({
55
+ __proto__: null,
56
+ StripeIdentityWeb: StripeIdentityWeb
57
+ });
58
+
59
+ exports.StripeIdentity = StripeIdentity;
60
+
61
+ return exports;
62
+
63
+ })({}, capacitorExports, stripeJs);
64
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["esm/events.enum.js","esm/index.js","esm/web.js"],"sourcesContent":["export var IdentityVerificationSheetEventsEnum;\n(function (IdentityVerificationSheetEventsEnum) {\n IdentityVerificationSheetEventsEnum[\"Loaded\"] = \"identityVerificationSheetLoaded\";\n IdentityVerificationSheetEventsEnum[\"FailedToLoad\"] = \"identityVerificationSheetFailedToLoad\";\n IdentityVerificationSheetEventsEnum[\"Completed\"] = \"identityVerificationSheetCompleted\";\n IdentityVerificationSheetEventsEnum[\"Canceled\"] = \"identityVerificationSheetCanceled\";\n IdentityVerificationSheetEventsEnum[\"Failed\"] = \"identityVerificationSheetFailed\";\n IdentityVerificationSheetEventsEnum[\"VerificationResult\"] = \"identityVerificationResult\";\n})(IdentityVerificationSheetEventsEnum || (IdentityVerificationSheetEventsEnum = {}));\n//# sourceMappingURL=events.enum.js.map","import { registerPlugin } from '@capacitor/core';\nconst StripeIdentity = registerPlugin('StripeIdentity', {\n web: () => import('./web').then((m) => new m.StripeIdentityWeb()),\n});\nexport * from './definitions';\nexport { StripeIdentity };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nimport { loadStripe } from '@stripe/stripe-js';\nimport { IdentityVerificationSheetEventsEnum } from './definitions';\nexport class StripeIdentityWeb extends WebPlugin {\n async initialize(options) {\n this.stripe = await loadStripe(options.publishableKey);\n }\n async create(options) {\n this.clientSecret = options.clientSecret;\n this.notifyListeners(IdentityVerificationSheetEventsEnum.Loaded, null);\n }\n async present() {\n if (!this.stripe) {\n throw new Error('Stripe is not initialized.');\n }\n if (!this.clientSecret) {\n throw new Error('clientSecret is not set.');\n }\n const { error } = await this.stripe.verifyIdentity(this.clientSecret);\n if (error) {\n const { code } = error;\n if (code === 'session_cancelled') {\n this.notifyListeners(IdentityVerificationSheetEventsEnum.VerificationResult, {\n result: IdentityVerificationSheetEventsEnum.Canceled,\n });\n return;\n }\n this.notifyListeners(IdentityVerificationSheetEventsEnum.VerificationResult, {\n result: IdentityVerificationSheetEventsEnum.Failed,\n error,\n });\n return;\n }\n this.notifyListeners(IdentityVerificationSheetEventsEnum.VerificationResult, {\n result: IdentityVerificationSheetEventsEnum.Completed,\n });\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["IdentityVerificationSheetEventsEnum","registerPlugin","WebPlugin","loadStripe"],"mappings":";;;AAAWA;IACX,CAAC,UAAU,mCAAmC,EAAE;IAChD,IAAI,mCAAmC,CAAC,QAAQ,CAAC,GAAG,iCAAiC;IACrF,IAAI,mCAAmC,CAAC,cAAc,CAAC,GAAG,uCAAuC;IACjG,IAAI,mCAAmC,CAAC,WAAW,CAAC,GAAG,oCAAoC;IAC3F,IAAI,mCAAmC,CAAC,UAAU,CAAC,GAAG,mCAAmC;IACzF,IAAI,mCAAmC,CAAC,QAAQ,CAAC,GAAG,iCAAiC;IACrF,IAAI,mCAAmC,CAAC,oBAAoB,CAAC,GAAG,4BAA4B;IAC5F,CAAC,EAAEA,2CAAmC,KAAKA,2CAAmC,GAAG,EAAE,CAAC,CAAC;;ACPhF,UAAC,cAAc,GAAGC,mBAAc,CAAC,gBAAgB,EAAE;IACxD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;IACrE,CAAC;;ICAM,MAAM,iBAAiB,SAASC,cAAS,CAAC;IACjD,IAAI,MAAM,UAAU,CAAC,OAAO,EAAE;IAC9B,QAAQ,IAAI,CAAC,MAAM,GAAG,MAAMC,mBAAU,CAAC,OAAO,CAAC,cAAc,CAAC;IAC9D,IAAI;IACJ,IAAI,MAAM,MAAM,CAAC,OAAO,EAAE;IAC1B,QAAQ,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY;IAChD,QAAQ,IAAI,CAAC,eAAe,CAACH,2CAAmC,CAAC,MAAM,EAAE,IAAI,CAAC;IAC9E,IAAI;IACJ,IAAI,MAAM,OAAO,GAAG;IACpB,QAAQ,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;IAC1B,YAAY,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC;IACzD,QAAQ;IACR,QAAQ,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;IAChC,YAAY,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC;IACvD,QAAQ;IACR,QAAQ,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC;IAC7E,QAAQ,IAAI,KAAK,EAAE;IACnB,YAAY,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK;IAClC,YAAY,IAAI,IAAI,KAAK,mBAAmB,EAAE;IAC9C,gBAAgB,IAAI,CAAC,eAAe,CAACA,2CAAmC,CAAC,kBAAkB,EAAE;IAC7F,oBAAoB,MAAM,EAAEA,2CAAmC,CAAC,QAAQ;IACxE,iBAAiB,CAAC;IAClB,gBAAgB;IAChB,YAAY;IACZ,YAAY,IAAI,CAAC,eAAe,CAACA,2CAAmC,CAAC,kBAAkB,EAAE;IACzF,gBAAgB,MAAM,EAAEA,2CAAmC,CAAC,MAAM;IAClE,gBAAgB,KAAK;IACrB,aAAa,CAAC;IACd,YAAY;IACZ,QAAQ;IACR,QAAQ,IAAI,CAAC,eAAe,CAACA,2CAAmC,CAAC,kBAAkB,EAAE;IACrF,YAAY,MAAM,EAAEA,2CAAmC,CAAC,SAAS;IACjE,SAAS,CAAC;IACV,IAAI;IACJ;;;;;;;;;;;;;;;"}
@@ -0,0 +1,8 @@
1
+ public enum IdentityVerificationSheetEvents: String {
2
+ case Loaded = "identityVerificationSheetLoaded"
3
+ case FailedToLoad = "identityVerificationSheetFailedToLoad"
4
+ case Completed = "identityVerificationSheetCompleted"
5
+ case Canceled = "identityVerificationSheetCanceled"
6
+ case Failed = "identityVerificationSheetFailed"
7
+ case VerificationResult = "identityVerificationResult"
8
+ }
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleDevelopmentRegion</key>
6
+ <string>$(DEVELOPMENT_LANGUAGE)</string>
7
+ <key>CFBundleExecutable</key>
8
+ <string>$(EXECUTABLE_NAME)</string>
9
+ <key>CFBundleIdentifier</key>
10
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11
+ <key>CFBundleInfoDictionaryVersion</key>
12
+ <string>6.0</string>
13
+ <key>CFBundleName</key>
14
+ <string>$(PRODUCT_NAME)</string>
15
+ <key>CFBundlePackageType</key>
16
+ <string>FMWK</string>
17
+ <key>CFBundleShortVersionString</key>
18
+ <string>1.0</string>
19
+ <key>CFBundleVersion</key>
20
+ <string>$(CURRENT_PROJECT_VERSION)</string>
21
+ <key>NSPrincipalClass</key>
22
+ <string></string>
23
+ </dict>
24
+ </plist>
@@ -0,0 +1,86 @@
1
+ import Foundation
2
+ import Capacitor
3
+ import StripeIdentity
4
+
5
+ @objc public class StripeIdentity: NSObject {
6
+ weak var plugin: StripeIdentityPlugin?
7
+ var identityVerificationSheet: IdentityVerificationSheet?
8
+
9
+ func initialize(_ call: CAPPluginCall) {
10
+ call.resolve()
11
+ }
12
+
13
+ func create(_ call: CAPPluginCall) {
14
+ let verificationId = call.getString("verificationId") ?? nil
15
+ let ephemeralKeySecret = call.getString("ephemeralKeySecret") ?? nil
16
+
17
+ if verificationId == nil || ephemeralKeySecret == nil {
18
+ let errorText = "Invalid Params. this method require verificationId or ephemeralKeySecret."
19
+ self.plugin?.notifyListeners(IdentityVerificationSheetEvents.FailedToLoad.rawValue, data: ["message": errorText])
20
+ call.reject(errorText)
21
+ return
22
+ }
23
+
24
+ if let iconFileName = Bundle.main.object(forInfoDictionaryKey: "CFBundleIcons") as? [String: Any],
25
+ let primaryIcon = iconFileName["CFBundlePrimaryIcon"] as? [String: Any],
26
+ let iconFilesArray = primaryIcon["CFBundleIconFiles"] as? [String],
27
+ let fileName = iconFilesArray.first {
28
+
29
+ let configuration = IdentityVerificationSheet.Configuration(
30
+ brandLogo: UIImage(named: fileName) ?? UIImage()
31
+ )
32
+
33
+ self.identityVerificationSheet = IdentityVerificationSheet(
34
+ verificationSessionId: verificationId!,
35
+ ephemeralKeySecret: ephemeralKeySecret!,
36
+ configuration: configuration
37
+ )
38
+
39
+ self.plugin?.notifyListeners(IdentityVerificationSheetEvents.Loaded.rawValue, data: [:])
40
+ call.resolve([:])
41
+ } else {
42
+ let errorText = "CFBundleIcons or CFBundlePrimaryIcon or CFBundleIconFiles is not found. You should check ios image assets"
43
+ self.plugin?.notifyListeners(IdentityVerificationSheetEvents.FailedToLoad.rawValue, data: ["message": errorText])
44
+ call.reject(errorText)
45
+ }
46
+ }
47
+
48
+ func present(_ call: CAPPluginCall) {
49
+ DispatchQueue.main.async {
50
+ if let rootViewController = self.plugin?.getRootVC() {
51
+ self.identityVerificationSheet!.present(from: rootViewController, completion: { result in
52
+ switch result {
53
+ case .flowCompleted:
54
+ // The user has completed uploading their documents.
55
+ // Let them know that the verification is processing.
56
+ print("Verification Flow Completed!")
57
+ self.plugin?.notifyListeners(IdentityVerificationSheetEvents.VerificationResult.rawValue, data: [
58
+ "result": IdentityVerificationSheetEvents.Completed.rawValue
59
+ ])
60
+ call.resolve([:])
61
+ case .flowCanceled:
62
+ // The user did not complete uploading their documents.
63
+ // You should allow them to try again.
64
+ print("Verification Flow Canceled!")
65
+ self.plugin?.notifyListeners(IdentityVerificationSheetEvents.VerificationResult.rawValue, data: [
66
+ "result": IdentityVerificationSheetEvents.Canceled.rawValue
67
+ ])
68
+ call.resolve([:])
69
+ case .flowFailed(let error):
70
+ // If the flow fails, you should display the localized error
71
+ // message to your user using error.localizedDescription
72
+ print("Verification Flow Failed!")
73
+ print(error.localizedDescription)
74
+ self.plugin?.notifyListeners(IdentityVerificationSheetEvents.VerificationResult.rawValue, data: [
75
+ "result": IdentityVerificationSheetEvents.Failed.rawValue,
76
+ "error": [
77
+ "message": error.localizedDescription
78
+ ]
79
+ ])
80
+ call.resolve([:])
81
+ }
82
+ })
83
+ }
84
+ }
85
+ }
86
+ }
@@ -0,0 +1,51 @@
1
+ import Foundation
2
+ import Capacitor
3
+ import StripeIdentity
4
+ import PassKit
5
+
6
+ /**
7
+ * Please read the Capacitor iOS Plugin Development Guide
8
+ * here: https://capacitorjs.com/docs/plugins/ios
9
+ */
10
+ @objc(StripeIdentityPlugin)
11
+ public class StripeIdentityPlugin: CAPPlugin, CAPBridgedPlugin {
12
+ public let identifier = "StripeIdentityPlugin"
13
+ public let jsName = "StripeIdentity"
14
+ public let pluginMethods: [CAPPluginMethod] = [
15
+ CAPPluginMethod(name: "initialize", returnType: CAPPluginReturnPromise),
16
+ CAPPluginMethod(name: "create", returnType: CAPPluginReturnPromise),
17
+ CAPPluginMethod(name: "present", returnType: CAPPluginReturnPromise)
18
+ ]
19
+ private let implementation = StripeIdentity()
20
+
21
+ override public func load() {
22
+ super.load()
23
+ self.implementation.plugin = self
24
+ STPAPIClient.shared.appInfo = STPAppInfo(name: "@capgo/capacitor-stripe-identity", partnerId: nil, version: nil, url: nil)
25
+ }
26
+
27
+ @objc func initialize(_ call: CAPPluginCall) {
28
+ self.implementation.initialize(call)
29
+ }
30
+
31
+ @objc func create(_ call: CAPPluginCall) {
32
+ self.implementation.create(call)
33
+ }
34
+
35
+ @objc func present(_ call: CAPPluginCall) {
36
+ self.implementation.present(call)
37
+ }
38
+
39
+ func getRootVC() -> UIViewController? {
40
+ var window: UIWindow? = UIApplication.shared.delegate?.window ?? nil
41
+
42
+ if window == nil {
43
+ let scene: UIWindowScene? = UIApplication.shared.connectedScenes.first as? UIWindowScene
44
+ window = scene?.windows.filter({$0.isKeyWindow}).first
45
+ if window == nil {
46
+ window = scene?.windows.first
47
+ }
48
+ }
49
+ return window?.rootViewController
50
+ }
51
+ }
@@ -0,0 +1,15 @@
1
+ import XCTest
2
+ @testable import StripeIdentityPlugin
3
+
4
+ class StripeIdentityTests: XCTestCase {
5
+ func testEcho() {
6
+ // This is an example of a functional test case for a plugin.
7
+ // Use XCTAssert and related functions to verify your tests produce the correct results.
8
+
9
+ let implementation = StripeIdentity()
10
+ // let value = "Hello, World!"
11
+ // let result = implementation.echo(value)
12
+ //
13
+ // XCTAssertEqual(value, result)
14
+ }
15
+ }
package/package.json ADDED
@@ -0,0 +1,95 @@
1
+ {
2
+ "name": "@capgo/capacitor-stripe-identity",
3
+ "version": "8.0.1",
4
+ "engines": {
5
+ "node": ">=22.0.0"
6
+ },
7
+ "description": "Capacitor plugin for Stripe Identity verification.",
8
+ "main": "dist/plugin.cjs.js",
9
+ "module": "dist/esm/index.js",
10
+ "types": "dist/esm/index.d.ts",
11
+ "unpkg": "dist/plugin.js",
12
+ "files": [
13
+ "android/src/main/",
14
+ "android/build.gradle",
15
+ "dist/",
16
+ "ios/Sources",
17
+ "ios/Tests",
18
+ "Package.swift",
19
+ "CapgoCapacitorStripeIdentity.podspec"
20
+ ],
21
+ "author": "Martin Donadieu <martin@capgo.app>",
22
+ "license": "MPL-2.0",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/Cap-go/capacitor-stripe-identity.git"
26
+ },
27
+ "bugs": {
28
+ "url": "https://github.com/Cap-go/capacitor-stripe-identity/issues"
29
+ },
30
+ "keywords": [
31
+ "capacitor",
32
+ "plugin",
33
+ "stripe",
34
+ "identity",
35
+ "kyc"
36
+ ],
37
+ "scripts": {
38
+ "verify": "bun run verify:ios && bun run verify:android && bun run verify:web",
39
+ "verify:ios": "xcodebuild -scheme CapgoCapacitorStripeIdentity -destination generic/platform=iOS",
40
+ "verify:android": "cd android && ./gradlew clean build test && cd ..",
41
+ "verify:web": "bun run build",
42
+ "lint": "bun run eslint && bun run prettier -- --check && bun run swiftlint -- lint",
43
+ "fmt": "bun run eslint -- --fix && bun run prettier -- --write && bun run swiftlint -- --fix --format",
44
+ "eslint": "eslint . --ext ts",
45
+ "prettier": "prettier-pretty-check \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
46
+ "swiftlint": "node-swiftlint",
47
+ "docgen": "docgen --api StripeIdentityPlugin --output-readme README.md --output-json dist/docs.json",
48
+ "build": "bun run clean && bun run docgen && tsc && rollup -c rollup.config.mjs",
49
+ "clean": "rimraf ./dist",
50
+ "watch": "tsc --watch",
51
+ "prepublishOnly": "bun run build",
52
+ "check:wiring": "node scripts/check-capacitor-plugin-wiring.mjs",
53
+ "example:install": "cd example-app && bun install --frozen-lockfile",
54
+ "example:build": "bun run build && cd example-app && bun install --frozen-lockfile && bun run build"
55
+ },
56
+ "devDependencies": {
57
+ "@capacitor/android": "^8.0.0",
58
+ "@capacitor/core": "^8.0.0",
59
+ "@capacitor/ios": "^8.0.0",
60
+ "@ionic/eslint-config": "^0.4.0",
61
+ "@ionic/prettier-config": "^4.0.0",
62
+ "@ionic/swiftlint-config": "^2.0.0",
63
+ "@types/node": "^24.10.1",
64
+ "eslint": "^8.57.1",
65
+ "prettier": "^3.6.2",
66
+ "prettier-plugin-java": "^2.7.7",
67
+ "rimraf": "^6.1.0",
68
+ "rollup": "^4.53.2",
69
+ "swiftlint": "^2.0.0",
70
+ "typescript": "^5.9.3",
71
+ "@capacitor/docgen": "^0.3.1",
72
+ "prettier-pretty-check": "^0.2.0",
73
+ "eslint-plugin-import": "^2.31.0"
74
+ },
75
+ "peerDependencies": {
76
+ "@capacitor/core": ">=8.0.0"
77
+ },
78
+ "prettier": "@ionic/prettier-config",
79
+ "swiftlint": "@ionic/swiftlint-config",
80
+ "eslintConfig": {
81
+ "extends": "@ionic/eslint-config/recommended"
82
+ },
83
+ "capacitor": {
84
+ "ios": {
85
+ "src": "ios"
86
+ },
87
+ "android": {
88
+ "src": "android"
89
+ }
90
+ },
91
+ "dependencies": {
92
+ "@stripe/stripe-js": "^8.4.0"
93
+ },
94
+ "homepage": "https://capgo.app/docs/plugins/stripe-identity/"
95
+ }