@worldcoin/idkit 1.0.0-alpha.4 → 1.0.0-alpha.6

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,7 +1,7 @@
1
1
  // src/lang/index.ts
2
2
  var translations = {};
3
3
  var getLang = () => {
4
- if (typeof navigator === "undefined" || !navigator.languages)
4
+ if (!navigator?.languages)
5
5
  return;
6
6
  const supportedLang = navigator.languages.find((l) => translations[l] != void 0) ?? "";
7
7
  return translations[supportedLang];
@@ -23,8 +23,9 @@ import { shallow } from "zustand/shallow";
23
23
  import { createWithEqualityFn } from "zustand/traditional";
24
24
  import {
25
25
  AppErrorCodes,
26
- CredentialType
26
+ DEFAULT_VERIFICATION_LEVEL
27
27
  } from "@worldcoin/idkit-core";
28
+ var SELF_HOSTED_APP_ID = "self_hosted";
28
29
  var useIDKitStore = createWithEqualityFn()(
29
30
  (set, get) => ({
30
31
  app_id: "",
@@ -32,7 +33,7 @@ var useIDKitStore = createWithEqualityFn()(
32
33
  action: "",
33
34
  action_description: "",
34
35
  bridge_url: "",
35
- credential_types: [],
36
+ verification_level: DEFAULT_VERIFICATION_LEVEL,
36
37
  open: false,
37
38
  result: null,
38
39
  theme: "light",
@@ -81,24 +82,22 @@ var useIDKitStore = createWithEqualityFn()(
81
82
  action,
82
83
  app_id,
83
84
  onError,
84
- credential_types,
85
+ verification_level,
85
86
  action_description,
86
87
  bridge_url,
87
88
  autoClose,
88
- theme
89
+ theme,
90
+ advanced
89
91
  }, source) => {
90
- const sanitized_credential_types = credential_types?.filter(
91
- (type) => Object.values(CredentialType).includes(type)
92
- );
93
92
  set({
94
93
  theme,
95
94
  signal,
96
95
  action,
97
- app_id,
98
96
  autoClose,
99
97
  bridge_url,
100
- credential_types: sanitized_credential_types,
101
- action_description
98
+ action_description,
99
+ app_id: advanced?.self_hosted ? SELF_HOSTED_APP_ID : app_id,
100
+ verification_level: verification_level ?? DEFAULT_VERIFICATION_LEVEL
102
101
  });
103
102
  get().addSuccessCallback(onSuccess, source);
104
103
  if (onError)
@@ -108,7 +107,7 @@ var useIDKitStore = createWithEqualityFn()(
108
107
  },
109
108
  handleVerify: (result) => {
110
109
  set({ stage: "HOST_APP_VERIFICATION" /* HOST_APP_VERIFICATION */, processing: false });
111
- Promise.all(Object.values(get().verifyCallbacks).map((cb) => cb?.(result))).then(
110
+ Promise.all(Object.values(get().verifyCallbacks).map(async (cb) => cb?.(result))).then(
112
111
  () => {
113
112
  set({ stage: "SUCCESS" /* SUCCESS */, result });
114
113
  if (get().autoClose)
@@ -234,7 +233,7 @@ var Qrcode = ({ data, size = 300 }) => {
234
233
  });
235
234
  return dots2;
236
235
  }, [size, data]);
237
- return /* @__PURE__ */ jsx("svg", { height: size, width: size, children: dots });
236
+ return /* @__PURE__ */ jsx("svg", { height: size, width: size, "data-test-id": "qr-code", children: dots });
238
237
  };
239
238
  var QRCode_default = memo(Qrcode);
240
239
 
@@ -26,7 +26,15 @@ type WidgetConfig = {
26
26
  /** Function to trigger when verification is not successful. Should receive a single parameter of type `IErrorState` which contains the error details. */
27
27
  onError?: CallbackFn<IErrorState>;
28
28
  };
29
- type Config = IDKitConfig & Required<Pick<IDKitConfig, 'action'>> & WidgetConfig;
29
+ type Config = Required<Pick<IDKitConfig, 'action'>> & WidgetConfig & ((Exclude<IDKitConfig, 'app_id'> & {
30
+ advanced: {
31
+ self_hosted: true;
32
+ };
33
+ }) | (IDKitConfig & {
34
+ advanced?: {
35
+ self_hosted?: false;
36
+ };
37
+ }));
30
38
  type WidgetProps = Config & {
31
39
  children?: ({ open }: {
32
40
  open: () => void;
package/build/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { C as Config, W as WidgetProps, a as WidgetConfig } from './config-cd2f02fe.js';
1
+ import { C as Config, W as WidgetProps, a as WidgetConfig } from './config-6a355d3b.js';
2
2
  import { MotionProps } from 'framer-motion';
3
3
  import * as react from 'react';
4
4
  import { FC, ButtonHTMLAttributes } from 'react';
5
- import { IDKitConfig } from '@worldcoin/idkit-core';
6
- export { CredentialType, ISuccessResult } from '@worldcoin/idkit-core';
7
5
  export { solidityEncode } from '@worldcoin/idkit-core/hashing';
6
+ import { IDKitConfig } from '@worldcoin/idkit-core';
7
+ export { CredentialType, IErrorState, ISuccessResult, VerificationLevel } from '@worldcoin/idkit-core';
8
8
 
9
9
  type HookConfig = Partial<Pick<Config, 'handleVerify' | 'onSuccess'>>;
10
10
  declare const useIDKit: ({ handleVerify, onSuccess }?: HookConfig) => {