Skip to content

Commit 3be58bd

Browse files
authored
Merge pull request #2249 from selfxyz/self-3760
feat(core): warn once per process that SelfBackendVerifier is deprecated
2 parents d9b096f + 8cb6905 commit 3be58bd

4 files changed

Lines changed: 58 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

sdk/core/src/SelfBackendVerifier.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ 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+
3638
export class SelfBackendVerifier {
3739
protected scope: string;
3840
protected identityVerificationHubContract: IdentityVerificationHubImpl;
@@ -49,6 +51,12 @@ export class SelfBackendVerifier {
4951
configStorage: IConfigStorage,
5052
userIdentifierType: UserIdType
5153
) {
54+
if (!(globalThis as Record<symbol, unknown>)[DEPRECATION_WARNED_KEY]) {
55+
(globalThis as Record<symbol, unknown>)[DEPRECATION_WARNED_KEY] = true;
56+
console.warn(
57+
'[@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/'
58+
);
59+
}
5260
const rpcUrl = mockPassport ? CELO_TESTNET_RPC_URL : CELO_MAINNET_RPC_URL;
5361
const provider = new ethers.JsonRpcProvider(rpcUrl);
5462
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+
});

0 commit comments

Comments
 (0)