Skip to content

Commit fbf1670

Browse files
kartikmehta8kartikmehta8
andauthored
feat(sdk): port deprecation warning and @deprecated JSDoc to dev (#2252)
* feat(core): warn once per process that SelfBackendVerifier is deprecated * fix(core): share deprecation-warn sentinel across ESM/CJS bundles * fix(ci): include generated typechain types in the core-sdk build cache * feat(sdk): add @deprecated JSDoc to legacy Self Pass SDK exports * fix(qrcode-angular): tag SelfQRcodeComponent as deprecated --------- Co-authored-by: kartikmehta8 <kartik.mehta@self.xyz>
1 parent bd1cae5 commit fbf1670

9 files changed

Lines changed: 117 additions & 5 deletions

File tree

.github/actions/cache-core-sdk-build/action.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ inputs:
88
cache-version:
99
description: Cache version string
1010
required: false
11-
default: v1
11+
default: v2
1212
fail-on-cache-miss:
1313
description: Fail if cache not found (restore mode only)
1414
required: false
@@ -29,6 +29,7 @@ runs:
2929
path: |
3030
common/dist
3131
sdk/core/dist
32+
sdk/core/src/typechain-types
3233
key: core-sdk-build-${{ inputs.cache-version }}-${{ github.sha }}
3334
fail-on-cache-miss: ${{ inputs.fail-on-cache-miss }}
3435
- id: save
@@ -38,4 +39,5 @@ runs:
3839
path: |
3940
common/dist
4041
sdk/core/dist
42+
sdk/core/src/typechain-types
4143
key: core-sdk-build-${{ inputs.cache-version }}-${{ github.sha }}

.github/workflows/core-sdk-ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
uses: ./.github/actions/cache-core-sdk-build
7474
with:
7575
mode: save
76-
cache-version: v1
76+
cache-version: v2
7777

7878
lint:
7979
runs-on: ubuntu-latest
@@ -90,7 +90,7 @@ jobs:
9090
uses: ./.github/actions/cache-core-sdk-build
9191
with:
9292
mode: restore
93-
cache-version: v1
93+
cache-version: v2
9494
fail-on-cache-miss: false
9595
- name: Install Dependencies
9696
uses: ./.github/actions/pnpm-install
@@ -117,7 +117,7 @@ jobs:
117117
uses: ./.github/actions/cache-core-sdk-build
118118
with:
119119
mode: restore
120-
cache-version: v1
120+
cache-version: v2
121121
fail-on-cache-miss: false
122122
- name: Install Dependencies
123123
uses: ./.github/actions/pnpm-install
@@ -144,7 +144,7 @@ jobs:
144144
uses: ./.github/actions/cache-core-sdk-build
145145
with:
146146
mode: restore
147-
cache-version: v1
147+
cache-version: v2
148148
fail-on-cache-miss: false
149149
- name: Install Dependencies
150150
uses: ./.github/actions/pnpm-install

common/src/utils/appType.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ export interface SelfAppDisclosureConfig {
4949
minimumAge?: number;
5050
}
5151

52+
/**
53+
* @deprecated The open-source Self Pass SDK is legacy. New integrations must use
54+
* `@selfxyz/enterprise-sdk`: create a session with `SelfClient` and redirect the user
55+
* to the hosted `verificationUrl` instead of building a Self app config.
56+
* Migration guide: https://docs.self.xyz/docs/self-enterprise/migration/from-self-pass-sdk/
57+
*/
5258
export class SelfAppBuilder {
5359
private config: SelfApp;
5460

@@ -126,6 +132,12 @@ export class SelfAppBuilder {
126132
}
127133
}
128134

135+
/**
136+
* @deprecated The open-source Self Pass SDK is legacy. New integrations must use
137+
* `@selfxyz/enterprise-sdk` and redirect the user to the hosted `verificationUrl`
138+
* returned by `SelfClient` instead of constructing a universal link.
139+
* Migration guide: https://docs.self.xyz/docs/self-enterprise/migration/from-self-pass-sdk/
140+
*/
129141
export function getUniversalLink(selfApp: SelfApp): string {
130142
return `${REDIRECT_URL}?selfApp=${encodeURIComponent(JSON.stringify(selfApp))}`;
131143
}

sdk/core/src/SelfBackendVerifier.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ const CELO_TESTNET_RPC_URL = 'https://forno.celo-sepolia.celo-testnet.org';
3333
const IDENTITY_VERIFICATION_HUB_ADDRESS = '0xe57F4773bd9c9d8b6Cd70431117d353298B9f5BF';
3434
const IDENTITY_VERIFICATION_HUB_ADDRESS_STAGING = '0x16ECBA51e18a4a7e61fdC417f0d47AFEeDfbed74';
3535

36+
const DEPRECATION_WARNED_KEY = Symbol.for('selfxyz.core.deprecation-warned');
37+
38+
/**
39+
* @deprecated The open-source Self Pass SDK is legacy. New integrations must use
40+
* `SelfClient` from `@selfxyz/enterprise-sdk` — the managed verifier replaces this class.
41+
* Migration guide: https://docs.self.xyz/docs/self-enterprise/migration/from-self-pass-sdk/
42+
*/
3643
export class SelfBackendVerifier {
3744
protected scope: string;
3845
protected identityVerificationHubContract: IdentityVerificationHubImpl;
@@ -49,6 +56,12 @@ export class SelfBackendVerifier {
4956
configStorage: IConfigStorage,
5057
userIdentifierType: UserIdType
5158
) {
59+
if (!(globalThis as Record<symbol, unknown>)[DEPRECATION_WARNED_KEY]) {
60+
(globalThis as Record<symbol, unknown>)[DEPRECATION_WARNED_KEY] = true;
61+
console.warn(
62+
'[@selfxyz/core] SelfBackendVerifier is deprecated — new integrations must use @selfxyz/enterprise-sdk. Migration guide: https://docs.self.xyz/docs/self-enterprise/migration/from-self-pass-sdk/'
63+
);
64+
}
5265
const rpcUrl = mockPassport ? CELO_TESTNET_RPC_URL : CELO_MAINNET_RPC_URL;
5366
const provider = new ethers.JsonRpcProvider(rpcUrl);
5467
const identityVerificationHubAddress = mockPassport
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import test from 'node:test';
2+
import assert from 'node:assert';
3+
import { SelfBackendVerifier } from '../src/SelfBackendVerifier.js';
4+
import { AttestationId } from '../src/types/types.js';
5+
6+
const configStorage = {
7+
getConfig: async () => ({ olderThan: 18, excludedCountries: [], ofac: false }),
8+
getActionId: async () => 'test',
9+
setConfig: async () => false,
10+
};
11+
12+
const construct = () =>
13+
new SelfBackendVerifier(
14+
'test-scope',
15+
'https://example.com/api/verify',
16+
true,
17+
new Map<AttestationId, boolean>([[1, true]]),
18+
configStorage,
19+
'uuid'
20+
);
21+
22+
test('constructor warns about deprecation exactly once per process', () => {
23+
const warnings: string[] = [];
24+
const originalWarn = console.warn;
25+
console.warn = (...args: unknown[]) => {
26+
warnings.push(args.map(String).join(' '));
27+
};
28+
try {
29+
construct();
30+
construct();
31+
} finally {
32+
console.warn = originalWarn;
33+
}
34+
35+
const deprecationWarnings = warnings.filter((w) => w.includes('deprecated'));
36+
assert.equal(deprecationWarnings.length, 1);
37+
assert.ok(deprecationWarnings[0].includes('@selfxyz/enterprise-sdk'));
38+
assert.ok(
39+
deprecationWarnings[0].includes(
40+
'https://docs.self.xyz/docs/self-enterprise/migration/from-self-pass-sdk/'
41+
)
42+
);
43+
});

sdk/qrcode-angular/src/lib/common.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,12 @@ export function validateUserId(userId: string, type: UserIdType): boolean {
567567
}
568568
}
569569

570+
/**
571+
* @deprecated The open-source Self Pass SDK is legacy. New integrations must use
572+
* `@selfxyz/enterprise-sdk`: create a session with `SelfClient` and redirect the user
573+
* to the hosted `verificationUrl` instead of building a Self app config.
574+
* Migration guide: https://docs.self.xyz/docs/self-enterprise/migration/from-self-pass-sdk/
575+
*/
570576
export class SelfAppBuilder {
571577
private config: SelfApp;
572578

@@ -643,6 +649,12 @@ export class SelfAppBuilder {
643649
}
644650
}
645651

652+
/**
653+
* @deprecated The open-source Self Pass SDK is legacy. New integrations must use
654+
* `@selfxyz/enterprise-sdk` and redirect the user to the hosted `verificationUrl`
655+
* returned by `SelfClient` instead of constructing a universal link.
656+
* Migration guide: https://docs.self.xyz/docs/self-enterprise/migration/from-self-pass-sdk/
657+
*/
646658
export function getUniversalLink(selfApp: SelfApp): string {
647659
return `${REDIRECT_URL}?selfApp=${encodeURIComponent(JSON.stringify(selfApp))}`;
648660
}

sdk/qrcode-angular/src/lib/components/self-qrcode/self-qrcode.component.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ export interface SelfQRcodeProps {
3030
darkMode?: boolean;
3131
}
3232

33+
/**
34+
* @deprecated The open-source Self Pass SDK is legacy. New integrations must use
35+
* `@selfxyz/enterprise-sdk`: redirect the user to the hosted `verificationUrl` —
36+
* you no longer render your own QR code.
37+
* Migration guide: https://docs.self.xyz/docs/self-enterprise/migration/from-self-pass-sdk/
38+
*/
3339
@Component({
3440
selector: 'lib-self-qrcode',
3541
standalone: true,

sdk/qrcode/components/SelfQRcode.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ interface SelfQRcodeProps {
2828
variant?: 'hybrid' | 'desktop' | 'mobile';
2929
}
3030

31+
/**
32+
* @deprecated The open-source Self Pass SDK is legacy. New integrations must use
33+
* `@selfxyz/enterprise-sdk`: redirect the user to the hosted `verificationUrl` —
34+
* you no longer render your own QR code.
35+
* Migration guide: https://docs.self.xyz/docs/self-enterprise/migration/from-self-pass-sdk/
36+
*/
3137
const SelfQRcodeWrapper = (props: SelfQRcodeProps) => {
3238
const [isClient, setIsClient] = useState(false);
3339
useEffect(() => {
@@ -40,6 +46,12 @@ const SelfQRcodeWrapper = (props: SelfQRcodeProps) => {
4046
return <SelfQRcode {...props} />;
4147
};
4248

49+
/**
50+
* @deprecated The open-source Self Pass SDK is legacy. New integrations must use
51+
* `@selfxyz/enterprise-sdk`: redirect the user to the hosted `verificationUrl` —
52+
* you no longer render your own QR code.
53+
* Migration guide: https://docs.self.xyz/docs/self-enterprise/migration/from-self-pass-sdk/
54+
*/
4355
const SelfQRcode = ({
4456
selfApp,
4557
onSuccess,

sdk/sdk-common/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,12 @@ export function validateUserId(userId: string, type: UserIdType): boolean {
567567
}
568568
}
569569

570+
/**
571+
* @deprecated The open-source Self Pass SDK is legacy. New integrations must use
572+
* `@selfxyz/enterprise-sdk`: create a session with `SelfClient` and redirect the user
573+
* to the hosted `verificationUrl` instead of building a Self app config.
574+
* Migration guide: https://docs.self.xyz/docs/self-enterprise/migration/from-self-pass-sdk/
575+
*/
570576
export class SelfAppBuilder {
571577
private config: SelfApp;
572578

@@ -643,6 +649,12 @@ export class SelfAppBuilder {
643649
}
644650
}
645651

652+
/**
653+
* @deprecated The open-source Self Pass SDK is legacy. New integrations must use
654+
* `@selfxyz/enterprise-sdk` and redirect the user to the hosted `verificationUrl`
655+
* returned by `SelfClient` instead of constructing a universal link.
656+
* Migration guide: https://docs.self.xyz/docs/self-enterprise/migration/from-self-pass-sdk/
657+
*/
646658
export function getUniversalLink(selfApp: SelfApp): string {
647659
return `${REDIRECT_URL}?selfApp=${encodeURIComponent(JSON.stringify(selfApp))}`;
648660
}

0 commit comments

Comments
 (0)