react-native-dpop 0.1.0 → 0.2.0

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/src/index.tsx CHANGED
@@ -1,5 +1,4 @@
1
- import { Platform } from 'react-native';
2
- import Dpop from './NativeDpop';
1
+ import NativeReactNativeDPoP from './NativeReactNativeDPoP';
3
2
 
4
3
  type AdditionalClaims = Record<string, unknown>;
5
4
 
@@ -51,18 +50,6 @@ type GenerateProofResult = {
51
50
  proofContext: DPoPProofContext;
52
51
  };
53
52
 
54
- const LINKING_ERROR =
55
- 'Dpop module nao encontrado. Verifique se o app Android foi recompilado apos adicionar o modulo nativo.';
56
-
57
- function requireAndroid() {
58
- if (Platform.OS !== 'android') {
59
- throw new Error('react-native-dpop (MVP atual) suporta somente Android.');
60
- }
61
- if (!Dpop) {
62
- throw new Error(LINKING_ERROR);
63
- }
64
- }
65
-
66
53
  export class DPoP {
67
54
  public readonly proof: string;
68
55
  public readonly alias?: string;
@@ -75,35 +62,30 @@ export class DPoP {
75
62
  }
76
63
 
77
64
  public async calculateThumbprint(): Promise<string> {
78
- requireAndroid();
79
- return Dpop.calculateThumbprint(this.alias ?? null);
65
+ return NativeReactNativeDPoP.calculateThumbprint(this.alias ?? null);
80
66
  }
81
67
 
82
68
  public async getPublicKey(format: PublicKeyFormat): Promise<PublicJwk | string> {
83
- requireAndroid();
84
69
  if (format === 'DER') {
85
- return Dpop.getPublicKeyDer(this.alias ?? null);
70
+ return NativeReactNativeDPoP.getPublicKeyDer(this.alias ?? null);
86
71
  }
87
72
  if (format === 'RAW') {
88
- return Dpop.getPublicKeyRaw(this.alias ?? null);
73
+ return NativeReactNativeDPoP.getPublicKeyRaw(this.alias ?? null);
89
74
  }
90
75
 
91
- return Dpop.getPublicKeyJwk(this.alias ?? null) as Promise<PublicJwk>;
76
+ return NativeReactNativeDPoP.getPublicKeyJwk(this.alias ?? null) as Promise<PublicJwk>;
92
77
  }
93
78
 
94
79
  public async signWithDpopPrivateKey(payload: string): Promise<string> {
95
- requireAndroid();
96
- return Dpop.signWithDpopPrivateKey(payload, this.alias ?? null);
80
+ return NativeReactNativeDPoP.signWithDpopPrivateKey(payload, this.alias ?? null);
97
81
  }
98
82
 
99
83
  public async isBoundToAlias(alias?: string): Promise<boolean> {
100
- requireAndroid();
101
- return Dpop.isBoundToAlias(this.proof, alias ?? this.alias ?? null);
84
+ return NativeReactNativeDPoP.isBoundToAlias(this.proof, alias ?? this.alias ?? null);
102
85
  }
103
86
 
104
87
  public static async generateProof(input: GenerateProofInput): Promise<DPoP> {
105
- requireAndroid();
106
- const result = (await Dpop.generateProof(
88
+ const result = (await NativeReactNativeDPoP.generateProof(
107
89
  input.htu,
108
90
  input.htm,
109
91
  input.nonce ?? null,
@@ -119,27 +101,22 @@ export class DPoP {
119
101
  }
120
102
 
121
103
  public static async assertHardwareBacked(alias?: string): Promise<void> {
122
- requireAndroid();
123
- await Dpop.assertHardwareBacked(alias ?? null);
104
+ await NativeReactNativeDPoP.assertHardwareBacked(alias ?? null);
124
105
  }
125
106
 
126
107
  public static async deleteKeyPair(alias?: string): Promise<void> {
127
- requireAndroid();
128
- await Dpop.deleteKeyPair(alias ?? null);
108
+ await NativeReactNativeDPoP.deleteKeyPair(alias ?? null);
129
109
  }
130
110
 
131
111
  public static async getKeyInfo(alias?: string): Promise<DPoPKeyInfo> {
132
- requireAndroid();
133
- return Dpop.getKeyInfo(alias ?? null) as Promise<DPoPKeyInfo>;
112
+ return NativeReactNativeDPoP.getKeyInfo(alias ?? null) as Promise<DPoPKeyInfo>;
134
113
  }
135
114
 
136
115
  public static async hasKeyPair(alias?: string): Promise<boolean> {
137
- requireAndroid();
138
- return Dpop.hasKeyPair(alias ?? null);
116
+ return NativeReactNativeDPoP.hasKeyPair(alias ?? null);
139
117
  }
140
118
 
141
119
  public static async rotateKeyPair(alias?: string): Promise<void> {
142
- requireAndroid();
143
- await Dpop.rotateKeyPair(alias ?? null);
120
+ await NativeReactNativeDPoP.rotateKeyPair(alias ?? null);
144
121
  }
145
122
  }
package/ios/Dpop.h DELETED
@@ -1,5 +0,0 @@
1
- #import <DpopSpec/DpopSpec.h>
2
-
3
- @interface Dpop : NSObject <NativeDpopSpec>
4
-
5
- @end
package/ios/Dpop.mm DELETED
@@ -1,21 +0,0 @@
1
- #import "Dpop.h"
2
-
3
- @implementation Dpop
4
- - (NSNumber *)multiply:(double)a b:(double)b {
5
- NSNumber *result = @(a * b);
6
-
7
- return result;
8
- }
9
-
10
- - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
11
- (const facebook::react::ObjCTurboModule::InitParams &)params
12
- {
13
- return std::make_shared<facebook::react::NativeDpopSpecJSI>(params);
14
- }
15
-
16
- + (NSString *)moduleName
17
- {
18
- return @"Dpop";
19
- }
20
-
21
- @end
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- import { TurboModuleRegistry } from 'react-native';
4
- export default TurboModuleRegistry.getEnforcing('Dpop');
5
- //# sourceMappingURL=NativeDpop.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeDpop.ts"],"mappings":";;AACA,SAASA,mBAAmB,QAAQ,cAAc;AA4BlD,eAAeA,mBAAmB,CAACC,YAAY,CAAO,MAAM,CAAC","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"NativeDpop.d.ts","sourceRoot":"","sources":["../../../src/NativeDpop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AAE9E,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC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